haxe_3.2.1+dfsg.orig/.travis.yml0000664000175000017500000000466612607337712016451 0ustar andyandy00000000000000language: cpp os: - linux - osx env: global: # make variables - OCAMLC=ocamlc.opt - OCAMLOPT=ocamlopt.opt - ADD_REVISION=1 # SAUCE_USERNAME - secure: SjyKefmjUEXi0IKHGGpcbLAajU0mLHONg8aA8LoY7Q9nAkSN6Aql+fzS38Boq7w1jWn+2FOpr+4jy0l6wVd/bftsF+huFfYpFJmdh8BlKmE0K71zZAral0H1c7YxkuQpPiJCIFGXqtkvev7SWTy0z31u7kuuQeEyW27boXe5cDA= # SAUCE_ACCESS_KEY - secure: sUvWUjCyPuWht4seNa4f2VG9DkvXkhZyLZfjJO9TUAHB2JndS16E2j/qrvKEjycyH6w8tU/B9vnjDRvvGrYXxEXcBEwsJVfkorFnRl9uwGCGIYrzjMhssEl3fMYZK7P304f+gAp5ULrDBX2gIaKeSa8lUNRtz2PsZOieE4kMdhk= matrix: - TEST=third-party - TEST=macro - TEST=neko - TEST=js - TEST=php - TEST=cpp - TEST=flash9 - TEST=as3 - TEST=java - TEST=cs - TEST=python matrix: # fast_finish: true #https://github.com/travis-ci/travis-ci/issues/1696 before_script: - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then mysql -u root -e "CREATE DATABASE haxe_test;"; fi install: # For our forks that do not have mult-os enabled... - if [ -z "${TRAVIS_OS_NAME}" ]; then export TRAVIS_OS_NAME=linux; fi # Install haxe and neko dependencies - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then travis_retry sudo apt-get update -qq; travis_retry sudo apt-get install ocaml-native-compilers zlib1g-dev libgc-dev -qq; fi - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then travis_retry brew update; travis_retry brew install caskroom/cask/brew-cask; travis_retry brew install ocaml camlp4; fi # Install neko - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then travis_retry git clone https://github.com/HaxeFoundation/neko.git ~/neko; cd ~/neko && make os=${TRAVIS_OS_NAME} -s && sudo make install -s; cd $TRAVIS_BUILD_DIR; fi - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then travis_retry brew install neko --HEAD; fi script: - make -s - make tools -s - sudo make install -s - cd tests/ - mkdir ~/haxelib && haxelib setup ~/haxelib - haxe -version - haxe RunCi.hxml - neko RunCi.n branches: except: # A hack to prevent building for tags, assuming they all start with a number. # https://github.com/travis-ci/travis-ci/issues/1532 - /^[0-9]/ notifications: webhooks: urls: - https://webhooks.gitter.im/e/95a5fa471c27beee8e7c on_success: change # options: [always|never|change] default: always on_failure: always # options: [always|never|change] default: always on_start: false # default: false haxe_3.2.1+dfsg.orig/CONTRIBUTING.md0000664000175000017500000000270212607337712016556 0ustar andyandy00000000000000Things to check before/while filing an issue: - Check if you actually suspect that there's an issue in the Haxe code. If you find yourself writing "How do I..." you may want to consider a different communication channel. Refer to http://haxe.org/community/community-support.html for more information. - Reduce your code to a minimal example (see http://sscce.org/). In particular avoid library dependencies: If you cannot reproduce your issue without using a specific library, it might not be a Haxe issue to begin with. - Check if your problems are already resolved in the Haxe development version (for builds see http://builds.haxe.org/). - Most targets produce readable code. If you suspect the generated code to be wrong, try checking the output. Note that you can add `-D dump=pretty` to your compilation parameters and find the code which is passed to the generators in a `dump` sub directory. Other remarks: - Sometimes people try to be particularly helpful by not only including broken parts in their code, but also "similar" code which is working. More often than not this is more distracting than helpful. If you want to highlight something like this, consider adding the working code commented out. - We do not require a classic "What do you see/what do you expect?" form, but in some cases it is hard to figure out where you think the actual problem is otherwise. - We're keeping this page quite short so there's a higher chance that people actually read it. haxe_3.2.1+dfsg.orig/Makefile0000664000175000017500000002254012607337712015767 0ustar andyandy00000000000000# Haxe compiler Makefile # # - use 'make' to build all # - use 'make haxe' to build only the compiler (not the libraries) # - if you want to build quickly, install 'ocamlopt.opt' and change OCAMLOPT=ocamlopt.opt # # Windows users : # - use 'make -f Makefile.win' to build for Windows # - use 'make MSVC=1 -f Makefile.win' to build for Windows with OCaml/MSVC # .SUFFIXES : .ml .mli .cmo .cmi .cmx .mll .mly INSTALL_DIR=/usr INSTALL_BIN_DIR=$(INSTALL_DIR)/bin INSTALL_LIB_DIR=$(INSTALL_DIR)/lib/haxe OUTPUT=haxe EXTENSION= OCAMLOPT?=ocamlopt OCAMLC?=ocamlc LFLAGS= CFLAGS= -g -I libs/extlib -I libs/extc -I libs/neko -I libs/javalib -I libs/ziplib -I libs/swflib -I libs/xml-light -I libs/ttflib -I libs/ilib -I libs/objsize LIBS=unix str libs/extlib/extLib libs/xml-light/xml-light libs/swflib/swflib \ libs/extc/extc libs/neko/neko libs/javalib/java libs/ziplib/zip \ libs/ttflib/ttf libs/ilib/il libs/objsize/objsize NATIVE_LIBS=-cclib libs/extc/extc_stubs.o -cclib libs/extc/process_stubs.o -cclib -lz -cclib libs/objsize/c_objsize.o ifeq ($(BYTECODE),1) TARGET_FLAG = bytecode COMPILER = $(OCAMLC) LIB_EXT = cma MODULE_EXT = cmo NATIVE_LIB_FLAG = -custom else TARGET_FLAG = native COMPILER = $(OCAMLOPT) LIB_EXT = cmxa MODULE_EXT = cmx endif CC_CMD = $(COMPILER) $(CFLAGS) -c $< CC_PARSER_CMD = $(COMPILER) -pp camlp4o $(CFLAGS) -c parser.ml RELDIR=../../.. MODULES=ast type lexer common genxml parser typecore optimizer typeload \ codegen gencommon genas3 gencpp genjs genneko genphp \ genswf9 genswf genjava gencs genpy interp dce analyzer filters typer matcher version main ADD_REVISION?=0 BRANCH=$(shell echo $$APPVEYOR_REPO_NAME | grep -q /haxe && echo $$APPVEYOR_REPO_BRANCH || echo $$TRAVIS_REPO_SLUG | grep -q /haxe && echo $$TRAVIS_BRANCH || git rev-parse --abbrev-ref HEAD) COMMIT_SHA=$(shell git rev-parse --short HEAD) COMMIT_DATE=$(shell git show -s --format=%ci HEAD | grep -oh ....-..-..) PACKAGE_FILE_NAME=haxe_$(COMMIT_DATE)_$(BRANCH)_$(COMMIT_SHA) # using $(CURDIR) on Windows will not work since it might be a Cygwin path ifdef SYSTEMROOT EXTENSION=.exe else export HAXE_STD_PATH=$(CURDIR)/std endif all: libs haxe libs: make -C libs/extlib OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/extc OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/neko OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/javalib OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/ilib OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/ziplib OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/swflib OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/xml-light OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/ttflib OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) make -C libs/objsize OCAMLOPT=$(OCAMLOPT) OCAMLC=$(OCAMLC) $(TARGET_FLAG) haxe: $(MODULES:=.$(MODULE_EXT)) $(COMPILER) -o $(OUTPUT) $(NATIVE_LIBS) $(NATIVE_LIB_FLAG) $(LFLAGS) $(LIBS:=.$(LIB_EXT)) $(MODULES:=.$(MODULE_EXT)) haxelib: (cd $(CURDIR)/extra/haxelib_src && $(CURDIR)/$(OUTPUT) haxelib.hxml && nekotools boot bin/haxelib.n) cp extra/haxelib_src/bin/haxelib$(EXTENSION) haxelib$(EXTENSION) tools: haxelib install: -rm -f $(INSTALL_LIB_DIR) -mkdir -p $(INSTALL_LIB_DIR) rm -rf $(INSTALL_LIB_DIR)/std cp -rf std $(INSTALL_LIB_DIR)/std cp -rf extra $(INSTALL_LIB_DIR) -mkdir -p $(INSTALL_LIB_DIR)/lib rm -f $(INSTALL_BIN_DIR)/haxe cp haxe $(INSTALL_LIB_DIR) ln -s $(INSTALL_LIB_DIR)/haxe $(INSTALL_BIN_DIR)/haxe chmod -R a+rx $(INSTALL_LIB_DIR) chmod 777 $(INSTALL_LIB_DIR)/lib # cp extra/haxelib_src/haxelib_script.sh $(INSTALL_DIR)/bin/haxelib echo "#!/bin/sh" > $(INSTALL_BIN_DIR)/haxelib echo "exec haxe -cp $(INSTALL_LIB_DIR)/extra/haxelib_src/src --run tools.haxelib.Main \"\$$@\"" >> $(INSTALL_BIN_DIR)/haxelib chmod a+rx $(INSTALL_BIN_DIR)/haxe $(INSTALL_BIN_DIR)/haxelib # will install native version of the tools instead of script ones install_tools: tools cp haxelib ${INSTALL_BIN_DIR}/haxelib chmod a+rx $(INSTALL_BIN_DIR)/haxelib uninstall: rm -rf $(INSTALL_BIN_DIR)/haxe $(INSTALL_BIN_DIR)/haxelib $(INSTALL_LIB_DIR) # Modules analyzer.$(MODULE_EXT): ast.$(MODULE_EXT) type.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) codegen.$(MODULE_EXT): optimizer.$(MODULE_EXT) typeload.$(MODULE_EXT) typecore.$(MODULE_EXT) type.$(MODULE_EXT) genxml.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT) common.$(MODULE_EXT): type.$(MODULE_EXT) ast.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT) dce.$(MODULE_EXT): ast.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) type.$(MODULE_EXT) filters.$(MODULE_EXT): ast.$(MODULE_EXT) analyzer.$(MODULE_EXT) common.$(MODULE_EXT) type.$(MODULE_EXT) dce.$(MODULE_EXT) codegen.$(MODULE_EXT) typecore.$(MODULE_EXT) genas3.$(MODULE_EXT): type.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) gencommon.$(MODULE_EXT): type.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT) gencpp.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) gencommon.$(MODULE_EXT) gencs.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) gencommon.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT) genjava.$(MODULE_EXT): type.$(MODULE_EXT) gencommon.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) genjs.$(MODULE_EXT): type.$(MODULE_EXT) optimizer.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) genneko.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) genphp.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) genpy.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) genswf.$(MODULE_EXT): type.$(MODULE_EXT) genswf9.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT) genswf9.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) genxml.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT) interp.$(MODULE_EXT): typecore.$(MODULE_EXT) type.$(MODULE_EXT) lexer.$(MODULE_EXT) genneko.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) genswf.$(MODULE_EXT) genjava.$(MODULE_EXT) gencs.$(MODULE_EXT) parser.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT) matcher.$(MODULE_EXT): optimizer.$(MODULE_EXT) codegen.$(MODULE_EXT) typecore.$(MODULE_EXT) type.$(MODULE_EXT) typer.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT) main.$(MODULE_EXT): filters.$(MODULE_EXT) matcher.$(MODULE_EXT) typer.$(MODULE_EXT) typeload.$(MODULE_EXT) typecore.$(MODULE_EXT) type.$(MODULE_EXT) parser.$(MODULE_EXT) optimizer.$(MODULE_EXT) lexer.$(MODULE_EXT) interp.$(MODULE_EXT) genxml.$(MODULE_EXT) genswf.$(MODULE_EXT) genphp.$(MODULE_EXT) genneko.$(MODULE_EXT) genjs.$(MODULE_EXT) gencpp.$(MODULE_EXT) genas3.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) gencommon.$(MODULE_EXT) genjava.$(MODULE_EXT) gencs.$(MODULE_EXT) genpy.$(MODULE_EXT) version.$(MODULE_EXT) libs/ilib/il.$(LIB_EXT) optimizer.$(MODULE_EXT): typecore.$(MODULE_EXT) type.$(MODULE_EXT) parser.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT) parser.$(MODULE_EXT): parser.ml lexer.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT) $(CC_PARSER_CMD) type.$(MODULE_EXT): ast.$(MODULE_EXT) typecore.$(MODULE_EXT): type.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT) typeload.$(MODULE_EXT): typecore.$(MODULE_EXT) type.$(MODULE_EXT) parser.$(MODULE_EXT) optimizer.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT) typer.$(MODULE_EXT): typeload.$(MODULE_EXT) typecore.$(MODULE_EXT) type.$(MODULE_EXT) parser.$(MODULE_EXT) optimizer.$(MODULE_EXT) lexer.$(MODULE_EXT) interp.$(MODULE_EXT) genneko.$(MODULE_EXT) genjs.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT) filters.$(MODULE_EXT) gencommon.$(MODULE_EXT) lexer.$(MODULE_EXT): lexer.ml lexer.$(MODULE_EXT): ast.$(MODULE_EXT) ast.$(MODULE_EXT): version.$(MODULE_EXT): $(MAKE) -f Makefile.version_extra -s ADD_REVISION=$(ADD_REVISION) BRANCH=$(BRANCH) COMMIT_SHA=$(COMMIT_SHA) COMMIT_DATE=$(COMMIT_DATE) > version.ml $(COMPILER) $(CFLAGS) -c version.ml # Package package_bin: mkdir -p out rm -rf $(PACKAGE_FILE_NAME) $(PACKAGE_FILE_NAME).tar.gz # Copy the package contents to $(PACKAGE_FILE_NAME) mkdir -p $(PACKAGE_FILE_NAME) cp -r $(OUTPUT) haxelib$(EXTENSION) std extra/LICENSE.txt extra/CONTRIB.txt extra/CHANGES.txt $(PACKAGE_FILE_NAME) # archive tar -zcf out/$(PACKAGE_FILE_NAME).tar.gz $(PACKAGE_FILE_NAME) rm -r $(PACKAGE_FILE_NAME) # Clean clean: clean_libs clean_haxe clean_tools clean_libs: make -C libs/extlib clean make -C libs/extc clean make -C libs/neko clean make -C libs/ziplib clean make -C libs/javalib clean make -C libs/ilib clean make -C libs/swflib clean make -C libs/xml-light clean make -C libs/ttflib clean make -C libs/objsize clean clean_haxe: rm -f $(MODULES:=.obj) $(MODULES:=.o) $(MODULES:=.cmx) $(MODULES:=.cmi) $(MODULES:=.cmo) lexer.ml $(OUTPUT) clean_tools: rm -f $(OUTPUT) haxelib # SUFFIXES .ml.cmx: $(CC_CMD) .ml.cmo: $(CC_CMD) .mll.ml: ocamllex $< .PHONY: haxe libs version.cmx version.cmo haxelib haxe_3.2.1+dfsg.orig/Makefile.version_extra0000664000175000017500000000066612607337712020663 0ustar andyandy00000000000000# A hack to print the content of version.ml consistently across Windows (cygwin / command prompt) and Unix. # The hack: http://stackoverflow.com/a/7284135/267998 # The issue: https://github.com/HaxeFoundation/haxe/commit/4f8f6a99ddf810ea045492cdd6d40c55abc03e15#commitcomment-10660400 all: ; ifneq ($(ADD_REVISION),0) $(info let version_extra = Some "(git build $(BRANCH) @ $(COMMIT_SHA))") else $(info let version_extra = None) endifhaxe_3.2.1+dfsg.orig/Makefile.win0000664000175000017500000000324412607337712016563 0ustar andyandy00000000000000include Makefile OUTPUT=haxe.exe EXTENSION=.exe OCAMLOPT=ocamlopt.opt kill: -@taskkill /F /IM haxe.exe # allow Ocaml/Mingw as well NATIVE_LIBS += -I "c:/program files/mingw/lib/" # use make WODI=wodi32 -f Makefile.win to build using WODI 32bit ifdef WODI NATIVE_LIBS += -I "/opt/${WODI}/lib" endif # use make MSVC=1 -f Makefile.win to build for OCaml/MSVC ifeq (${MSVC}, 1) NATIVE_LIBS = shell32.lib libs/extc/extc_stubs.obj libs/extc/process_stubs.obj libs/extc/zlib/zlib.lib libs/objsize/c_objsize.obj endif ifeq (${MSVC_OUTPUT}, 1) FILTER=sed 's/File "\([^"]\+\)", line \([0-9]\+\), \(.*\)/\1(\2): \3/' tmp.cmi endif ifeq (${FD_OUTPUT}, 1) FILTER=sed '/File/{ N; s/File "\([^"]\+\)", line \([0-9]\+\), characters \([0-9-]\+\):[\r\n]*\(.*\)/\1:\2: characters \3 : \4/ }' tmp.cmi endif ifdef FILTER CC_CMD=($(OCAMLOPT) $(CFLAGS) -c $< 2>tmp.cmi && $(FILTER)) || ($(FILTER) && exit 1) CC_PARSER_CMD=($(OCAMLOPT) -pp camlp4o $(CFLAGS) -c parser.ml 2>tmp.cmi && $(FILTER)) || ($(FILTER) && exit 1) endif package_bin: mkdir -p out rm -rf $(PACKAGE_FILE_NAME) $(PACKAGE_FILE_NAME).zip temp.zip # Copy the package contents to $(PACKAGE_FILE_NAME) # Using poor man's cp (zip then unzip), because cp in cygwin is quite broken mkdir -p $(PACKAGE_FILE_NAME) 7za a -y -tzip -mx0 temp.zip $(OUTPUT) haxelib$(EXTENSION) std > log.txt || type log.txt cd extra && 7za a -y -tzip -mx0 ../temp.zip LICENSE.txt CONTRIB.txt CHANGES.txt > log.txt || type log.txt 7za x -y temp.zip -o$(PACKAGE_FILE_NAME) > log.txt || type log.txt rm temp.zip # archive 7za a -r -tzip out/$(PACKAGE_FILE_NAME).zip $(PACKAGE_FILE_NAME) > log.txt || type log.txt rm -r $(PACKAGE_FILE_NAME) rm log.txt extra/log.txthaxe_3.2.1+dfsg.orig/README.md0000664000175000017500000000765212607337712015615 0ustar andyandy00000000000000 # [Haxe logo](http://haxe.org) - [The Cross-Platform Toolkit](http://haxe.org) [![TravisCI Build Status](https://travis-ci.org/HaxeFoundation/haxe.svg?branch=development)](https://travis-ci.org/HaxeFoundation/haxe) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/HaxeFoundation/haxe?branch=development&svg=true)](https://ci.appveyor.com/project/HaxeFoundation/haxe) [![SauceLabs Test Status](https://saucelabs.com/buildstatus/haxe)](https://saucelabs.com/u/haxe) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/HaxeFoundation/haxe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) Haxe is an open source toolkit that allows you to easily build cross-platform tools and applications that target many mainstream platforms. The Haxe toolkit includes: * **The Haxe programming language**, a modern, high-level, strictly-typed programming language * **The Haxe cross-compiler**, a state-of-the-art, lightning-speed compiler for many targets * **The Haxe standard library**, a complete, cross-platform library of common functionality Haxe allows you to compile for the following targets: * ActionScript 3 * C++ * C# * Flash * Java * JavaScript * NekoVM * PHP * Python You can try Haxe directly from your browser at [try.haxe.org](http://try.haxe.org)! For more information about Haxe, head to the [offical Haxe website](http://haxe.org). ## License The Haxe project has several licenses, covering different parts of the projects. * The Haxe compiler is released under the GNU General Public License version 2 or any later version. * The Haxe libraries are released under a "two-clause" BSD license. * The Neko runtime is licensed under the GNU Lesser General Public License version 2.1 or any later version. For the complete Haxe licenses, please see http://haxe.org/foundation/open-source.html or [extra/LICENSE.txt](extra/LICENSE.txt). ## Installing Haxe The latest stable release is [Haxe 3.2.0-rc2](http://haxe.org/download/version/3.2.0-rc.2/). Pre-built binaries are available for your platform: * **[Windows installer](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-win.exe)** * **[Windows binaries](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-win.zip)** * **[OSX installer](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-osx-installer.pkg)** * **[OSX binaries](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-osx.tar.gz)** * **[Linux 32-bit binaries](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-linux32.tar.gz)** * **[Linux 64-bit binaries](http://haxe.org/download/file/3.2.0-rc.2/haxe-3.2.0-rc2-linux64.tar.gz)** Automated development builds are available from [build.haxe.org](http://build.haxe.org). ## Building from source 1. Clone the repository using git. Be sure to initialize and fetch the submodules. git clone --recursive git://github.com/HaxeFoundation/haxe.git cd haxe 2. Follow the [documentation on building Haxe for your platform](http://haxe.org/documentation/introduction/building-haxe.html). ## Using Haxe For information on on using Haxe, consult the [Haxe documentation](http://haxe.org/documentation): * [Haxe Introduction](http://haxe.org/documentation/introduction), an introduction to the Haxe toolkit * [The Haxe Manual](http://haxe.org/manual), the reference manual for the Haxe language * [Haxe API](http://api.haxe.org), documentation for the Haxe standard and native APIs * [Haxelib](http://lib.haxe.org), a repository of Haxe libraries for a variety of needs ## Community You can get help and talk with fellow Haxers from around the world via: * the [official Haxe Google Group](https://groups.google.com/forum/#!forum/haxelang) * the [Haxe IRC chatroom](http://unic0rn.github.io/tiramisu/haxe), #haxe on chat.freenode.net ## Version compatibility Haxe | neko ---- | ----- 2.* | 1.* 3.0.0 | 2.0.0 3.1.3 | 2.0.0 haxe_3.2.1+dfsg.orig/analyzer.ml0000664000175000017500000014210312607337712016504 0ustar andyandy00000000000000open Ast open Type open Common open Typecore let s_expr = s_expr (s_type (print_context())) let s_expr_pretty = s_expr_pretty "" (s_type (print_context())) let debug e = print_endline (s_expr e) let debug_pretty s e = Printf.printf "%s %s\n" s (s_expr_pretty e) let flag_no_check = "no_check" let flag_check = "check" let flag_no_const_propagation = "no_const_propagation" let flag_const_propagation = "const_propagation" let flag_no_local_dce = "no_local_dce" let flag_local_dce = "local_dce" let flag_ignore = "ignore" let flag_no_simplification = "no_simplification" let flag_check_has_effect = "check_has_effect" let flag_no_check_has_effect = "no_check_has_effect" let has_analyzer_option meta s = try let rec loop ml = match ml with | (Meta.Analyzer,el,_) :: ml -> if List.exists (fun (e,p) -> match e with | EConst(Ident s2) when s = s2 -> true | _ -> false ) el then true else loop ml | _ :: ml -> loop ml | [] -> false in loop meta with Not_found -> false let is_ignored meta = try let rec loop ml = match ml with | (Meta.Analyzer,el,_) :: ml -> if List.exists (fun (e,p) -> match e with | EConst(Ident s2) when flag_ignore = s2 -> true | _ -> false ) el then true else loop ml | (Meta.HasUntyped,_,_) :: _ -> true | _ :: ml -> loop ml | [] -> false in loop meta with Not_found -> false let rec get_type_meta t = match t with | TMono r -> begin match !r with | None -> raise Not_found | Some t -> get_type_meta t end | TLazy f -> get_type_meta (!f()) | TInst(c,_) -> c.cl_meta | TEnum(en,_) -> en.e_meta | TAbstract(a,_) -> a.a_meta | TType(t,_) -> t.t_meta | TAnon _ | TFun _ | TDynamic _ -> raise Not_found let type_has_analyzer_option t s = try has_analyzer_option (get_type_meta t) s with Not_found -> false let is_enum_type t = match follow t with | TEnum(_) -> true | _ -> false let rec awkward_get_enum_index com e = match e.eexpr with | TArray(e1,{eexpr = TConst(TInt i)}) when com.platform = Js && Int32.to_int i = 1 && is_enum_type e1.etype -> e1 | TCall({eexpr = TField(e1, FDynamic "__Index")},[]) when com.platform = Cpp && is_enum_type e1.etype -> e1 | TField(e1,FDynamic "index") when com.platform = Neko && is_enum_type e1.etype -> e1 | TParenthesis e1 | TCast(e1,None) | TMeta(_,e1) -> awkward_get_enum_index com e1 | _ -> raise Not_found (* This module simplifies the AST by introducing temporary variables for complex expressions in many places. In particular, it ensures that no branching can occur in value-places so that we can later insert SSA PHI nodes without worrying about their placement. *) module Simplifier = struct let mk_block_context com = let block_el = ref [] in let push e = block_el := e :: !block_el in let assign ev e = let mk_assign e2 = match e2.eexpr with | TBreak | TContinue | TThrow _ | TReturn _ -> e2 | _ -> mk (TBinop(OpAssign,ev,e2)) e2.etype e2.epos in let rec loop e = match e.eexpr with | TBlock el -> begin match List.rev el with | e1 :: el -> let el = List.rev ((loop e1) :: el) in {e with eexpr = TBlock el} | _ -> mk_assign e end | TIf(e1,e2,eo) -> let e2 = loop e2 in let eo = match eo with None -> None | Some e3 -> Some (loop e3) in {e with eexpr = TIf(e1,e2,eo)} | TSwitch(e1,cases,edef) -> let cases = List.map (fun (el,e) -> let e = loop e in el,e ) cases in let edef = match edef with None -> None | Some edef -> Some (loop edef) in {e with eexpr = TSwitch(e1,cases,edef)} | TTry(e1,catches) -> let e1 = loop e1 in let catches = List.map (fun (v,e) -> let e = loop e in v,e ) catches in {e with eexpr = TTry(e1,catches)} | TParenthesis e1 | TMeta(_,e1) -> loop e1 (* this is still weird, have to review *) (* | TBinop(OpAssign,({eexpr = TLocal _} as e1),e2) -> push e; mk_assign e1 *) (* | TBinop(OpAssignOp op,({eexpr = TLocal _} as e1),e2) -> push e; mk_assign e1 *) | _ -> mk_assign e in loop e in let declare_temp t eo p = let v = alloc_var "tmp" t in v.v_meta <- [Meta.CompilerGenerated,[],p]; let e_v = mk (TLocal v) t p in let declare e_init = let e = mk (TVar (v,e_init)) com.basic.tvoid p in push e; in let e_v = match eo with | None -> declare None; e_v | Some e1 -> begin match e1.eexpr with | TThrow _ | TReturn _ | TBreak | TContinue -> e1 | _ -> let rec loop e_v e = match e.eexpr with | TParenthesis e1 -> loop {e_v with eexpr = TParenthesis e_v} e1 | TMeta(m,e1) -> loop {e_v with eexpr = TMeta(m,e_v)} e1 | _ -> e_v,e in let e_v',e1 = loop e_v e1 in let e1 = assign e_v e1 in begin match e1.eexpr with | TBinop(OpAssign,{eexpr = TLocal v1},e2) when v == v1 -> declare (Some e2) | _ -> declare None; push e1 end; e_v' end in e_v in let rec push_block () = let cur = !block_el in block_el := []; fun () -> let added = !block_el in block_el := cur; List.rev added and block f el = let close = push_block() in List.iter (fun e -> push (f e) ) el; close() in block,declare_temp,fun () -> !block_el let apply com e = let block,declare_temp,close_block = mk_block_context com in let skip_binding ?(allow_tlocal=false) e = let rec loop e = match e.eexpr with | TConst _ | TTypeExpr _ | TFunction _ -> () | TLocal _ when allow_tlocal -> () | TParenthesis e1 | TCast(e1,None) -> Type.iter loop e | TField(_,(FStatic(c,cf) | FInstance(c,_,cf))) when has_analyzer_option cf.cf_meta flag_no_simplification || has_analyzer_option c.cl_meta flag_no_simplification -> () | TField({eexpr = TLocal _},_) when allow_tlocal -> () | TCall({eexpr = TField(_,(FStatic(c,cf) | FInstance(c,_,cf)))},el) when has_analyzer_option cf.cf_meta flag_no_simplification || has_analyzer_option c.cl_meta flag_no_simplification -> () | TCall({eexpr = TLocal { v_name = "__cpp__" } },_) -> () | TField(_,FEnum _) -> () | TField(_,FDynamic _) -> () | _ when (try ignore(awkward_get_enum_index com e); true with Not_found -> false) -> () | _ -> raise Exit in try loop e; true with Exit -> begin match follow e.etype with | TAbstract({a_path = [],"Void"},_) -> true | TInst ({ cl_path = [],"Array" }, _) when com.platform = Cpp -> true | _ -> false end in let has_unbound = ref false in let rec loop e = match e.eexpr with | TCall({eexpr = TLocal v | TField({eexpr = TLocal v},_)},_) | TField({eexpr = TLocal v},_) | TLocal v when Meta.has Meta.Unbound v.v_meta && v.v_name <> "`trace" -> has_unbound := true; e | TBlock el -> {e with eexpr = TBlock (block loop el)} | TCall({eexpr = TField(_,(FStatic(c,cf) | FInstance(c,_,cf)))},el) when has_analyzer_option cf.cf_meta flag_no_simplification || has_analyzer_option c.cl_meta flag_no_simplification -> e | TField(_,(FStatic(c,cf) | FInstance(c,_,cf))) when has_analyzer_option cf.cf_meta flag_no_simplification || has_analyzer_option c.cl_meta flag_no_simplification -> e | TCall(e1,el) -> let rec is_valid_call_target e = match e.eexpr with | TFunction _ | TField _ | TLocal _ | TConst (TSuper) -> true | TParenthesis e1 | TCast(e1,None) | TMeta(_,e1) -> is_valid_call_target e1 | _ -> false in let e1 = if is_valid_call_target e1 then loop e1 else bind e1 in let check e t = if type_has_analyzer_option t flag_no_simplification then e else bind e in let el = match e1.eexpr,follow e1.etype with | TConst TSuper,_ when com.platform = Java || com.platform = Cs -> (* they hate you if you mess up the super call *) el | _,TFun _ | TConst TSuper,_ -> Codegen.UnificationCallback.check_call check el e1.etype | _ -> (* too dangerous *) List.map loop el in {e with eexpr = TCall(e1,el)} | TNew(c,tl,el) -> {e with eexpr = TNew(c,tl,ordered_list el)} | TArrayDecl el -> {e with eexpr = TArrayDecl (ordered_list el)} | TObjectDecl fl -> let el = ordered_list (List.map snd fl) in {e with eexpr = TObjectDecl (List.map2 (fun (n,_) e -> n,e) fl el)} | TBinop(OpBoolAnd | OpBoolOr as op,e1,e2) -> let e1 = loop e1 in let e_then = mk (TBlock (block loop [e2])) e2.etype e2.epos in let e_if,e_else = if op = OpBoolOr then mk (TUnop(Not,Prefix,e1)) com.basic.tbool e.epos,mk (TConst (TBool(true))) com.basic.tbool e.epos else e1,mk (TConst (TBool(false))) com.basic.tbool e.epos in loop (mk (TIf(e_if,e_then,Some e_else)) com.basic.tbool e.epos) | TBinop((OpAssign | OpAssignOp _) as op,{eexpr = TArray(e11,e12)},e2) -> let e1 = match ordered_list [e11;e12] with | [e1;e2] -> {e with eexpr = TArray(e1,e2)} | _ -> assert false in let e2 = bind e2 in {e with eexpr = TBinop(op,e1,e2)} | TBinop((OpAssign | OpAssignOp _) as op,e1,e2) -> let e2 = bind ~allow_tlocal:true e2 in let e1 = loop e1 in {e with eexpr = TBinop(op,e1,e2)} | TBinop(op,e1,e2) -> begin match ordered_list [e1;e2] with | [e1;e2] -> {e with eexpr = TBinop(op,e1,e2)} | _ -> assert false end | TArray(e1,e2) -> begin match ordered_list [e1;e2] with | [e1;e2] -> {e with eexpr = TArray(e1,e2)} | _ -> assert false end | TWhile(e1,e2,flag) when (match e1.eexpr with TConst(TBool true) | TParenthesis {eexpr = TConst(TBool true)} -> false | _ -> true) -> let p = e.epos in let e_break = mk TBreak t_dynamic p in let e_not = mk (TUnop(Not,Prefix,Codegen.mk_parent e1)) e1.etype e1.epos in let e_if eo = mk (TIf(e_not,e_break,eo)) com.basic.tvoid p in let rec map_continue e = match e.eexpr with | TContinue -> (e_if (Some e)) | TWhile _ | TFor _ -> e | _ -> Type.map_expr map_continue e in let e2 = if flag = NormalWhile then e2 else map_continue e2 in let e_if = e_if None in let e_if = mk (TMeta((Meta.Custom ":whileCond",[],e_if.epos), e_if)) e_if.etype e_if.epos in let e_block = if flag = NormalWhile then Type.concat e_if e2 else Type.concat e2 e_if in let e_true = mk (TConst (TBool true)) com.basic.tbool p in let e = mk (TWhile(Codegen.mk_parent e_true,e_block,NormalWhile)) e.etype p in loop e | TFor(v,e1,e2) -> let e1 = bind e1 in let e2 = loop e2 in {e with eexpr = TFor(v,e1,e2)} | TIf(e1,e2,eo) -> let e1 = bind e1 in let e2 = loop e2 in let eo = match eo with None -> None | Some e -> Some (loop e) in {e with eexpr = TIf(e1,e2,eo)} | TSwitch (e1,cases,eo) -> let e1 = bind e1 in let cases = List.map (fun (el,e) -> let el = List.map loop el in let e = loop e in el,e ) cases in let eo = match eo with None -> None | Some e -> Some (loop e) in {e with eexpr = TSwitch(e1,cases,eo)} | TVar(v,Some e1) -> let e1 = match e1.eexpr with | TFunction _ -> loop e1 | TArrayDecl [{eexpr = TFunction _}] -> loop e1 | _ -> bind ~allow_tlocal:true e1 in {e with eexpr = TVar(v,Some e1)} | TUnop((Neg | NegBits | Not) as op,flag,e1) -> let e1 = bind e1 in {e with eexpr = TUnop(op,flag,e1)} | TField(e1,fa) -> let e1 = bind ~allow_tlocal:true e1 in {e with eexpr = TField(e1,fa)} | TReturn (Some ({eexpr = TThrow _ | TReturn _} as e1)) -> loop e1 (* this is a bit hackish *) | TReturn (Some e1) -> let e1 = bind e1 in {e with eexpr = TReturn (Some e1)} | TThrow e1 -> let e1 = bind e1 in {e with eexpr = TThrow e1} | TCast(e1,mto) -> let e1 = bind ~allow_tlocal:true e1 in {e with eexpr = TCast(e1,mto)} | _ -> Type.map_expr loop e and bind ?(allow_tlocal=false) e = let e = loop e in if skip_binding ~allow_tlocal e then e else declare_temp e.etype (Some e) e.epos and ordered_list el = if List.for_all (skip_binding ~allow_tlocal:true) el then List.map loop el else List.map bind el in let e = loop e in !has_unbound,match close_block() with | [] -> e | el -> mk (TBlock (List.rev (e :: el))) e.etype e.epos let unapply com e = let var_map = ref IntMap.empty in let rec get_assignment_to v e = match e.eexpr with | TBinop(OpAssign,{eexpr = TLocal v2},e2) when v == v2 -> Some e2 | TBlock [e] -> get_assignment_to v e | TIf(e1,e2,Some e3) -> begin match get_assignment_to v e2,get_assignment_to v e3 with | Some e2,Some e3 -> Some ({e with eexpr = TIf(e1,e2,Some e3)}) | _ -> None end | _ -> None in let if_or_op e e1 e2 e3 = match e1.eexpr,e3.eexpr with | TUnop(Not,Prefix,e1),TConst (TBool true) -> {e with eexpr = TBinop(OpBoolOr,e1,e2)} | _,TConst (TBool false) -> {e with eexpr = TBinop(OpBoolAnd,e1,e2)} | _ -> {e with eexpr = TIf(e1,e2,Some e3)} in let rec loop e = match e.eexpr with | TBlock el -> let rec loop2 el = match el with | e :: el -> begin match e.eexpr with | TVar(v,Some e1) when Meta.has Meta.CompilerGenerated v.v_meta -> if el = [] then [loop e1] else begin var_map := IntMap.add v.v_id (loop e1) !var_map; loop2 el end | TVar(v,None) when not (com.platform = Php) -> begin match el with | {eexpr = TBinop(OpAssign,{eexpr = TLocal v2},e2)} :: el when v == v2 -> let e = {e with eexpr = TVar(v,Some e2)} in loop2 (e :: el) | ({eexpr = TIf(e1,e2,Some e3)} as e_if) :: el -> let e1 = loop e1 in let e2 = loop e2 in let e3 = loop e3 in begin match get_assignment_to v e2,get_assignment_to v e3 with | Some e2,Some e3 -> let e_if = if_or_op e_if (loop e1) (loop e2) (loop e3) in let e = {e with eexpr = TVar(v,Some e_if)} in loop2 (e :: el) | _ -> let e_if = {e_if with eexpr = TIf(e1,e2,Some e3)} in e :: e_if :: loop2 el end | _ -> let e = loop e in e :: loop2 el end | TReturn (Some e1) when (match follow e1.etype with TAbstract({a_path=[],"Void"},_) -> true | _ -> false) -> [(loop e1);{e with eexpr = TReturn None}] | _ -> let e = loop e in e :: loop2 el end | [] -> [] in let el = loop2 el in {e with eexpr = TBlock el} | TLocal v when Meta.has Meta.CompilerGenerated v.v_meta -> begin try IntMap.find v.v_id !var_map with Not_found -> e end | TWhile(e1,e2,flag) -> let e1 = loop e1 in let e2 = loop e2 in let extract_cond e = match e.eexpr with | TIf({eexpr = TUnop(Not,_,e1)},_,_) -> e1 | TBreak -> raise Exit (* can happen due to optimization, not so easy to deal with because there might be other breaks/continues *) | _ -> assert false in let e1,e2,flag = try begin match e2.eexpr with | TBlock el -> begin match el with | {eexpr = TMeta((Meta.Custom ":whileCond",_,_),e1)} :: el -> let e1 = extract_cond e1 in e1,{e2 with eexpr = TBlock el},NormalWhile | _ -> e1,e2,flag (* issue 3844 *) (* begin match List.rev el with | {eexpr = TMeta((Meta.Custom ":whileCond",_,_),e1)} :: el -> let e1 = extract_cond e1 in e1,{e2 with eexpr = TBlock (List.rev el)},DoWhile | _ -> e1,e2,flag end *) end | _ -> e1,e2,flag end with Exit -> e1,e2,flag in {e with eexpr = TWhile(e1,e2,flag)} | TIf(e1,e2,Some e3) -> let e1 = loop e1 in let e2 = loop e2 in let e3 = loop e3 in if_or_op e e1 e2 e3 | _ -> Type.map_expr loop e in loop e end module Ssa = struct type var_map = tvar IntMap.t type condition = | Equal of tvar * texpr | NotEqual of tvar * texpr type node_data = { nd_pos: pos; mutable nd_var_map : var_map; mutable nd_terminates : bool; } type join_node = { mutable branches : node_data list; } type ssa_context = { com : Common.context; mutable cleanup : (unit -> unit) list; mutable cur_data : node_data; mutable var_conds : (condition list) IntMap.t; mutable loop_stack : (join_node * join_node) list; mutable exception_stack : join_node list; mutable block_depth : int; } let s_cond = function | Equal(v,e) -> Printf.sprintf "%s == %s" v.v_name (s_expr_pretty e) | NotEqual(v,e) -> Printf.sprintf "%s != %s" v.v_name (s_expr_pretty e) let s_conds conds = String.concat " && " (List.map s_cond conds) let mk_loc v p = mk (TLocal v) v.v_type p let mk_phi = let v_phi = alloc_var "__ssa_phi__" t_dynamic in (fun vl p -> let e = mk (TCall(mk_loc v_phi p,(List.map (fun (v,p) -> mk_loc v p) vl))) t_dynamic p in e ) (* TODO: make sure this is conservative *) let can_throw e = let rec loop e = match e.eexpr with | TConst _ | TLocal _ | TTypeExpr _ | TFunction _ | TBlock _ -> () | TCall _ | TNew _ | TThrow _ | TCast(_,Some _) -> raise Exit | _ -> Type.iter loop e in try loop e; false with Exit -> true let mk_join_node() = { branches = [] } let mk_node_data p = { nd_pos = p; nd_var_map = IntMap.empty; nd_terminates = false; } let add_branch join branch p = join.branches <- {branch with nd_pos = p} :: join.branches let branch ctx p = let old_map = ctx.cur_data.nd_var_map in let old_term = ctx.cur_data.nd_terminates in ctx.cur_data.nd_terminates <- false; (fun join -> add_branch join ctx.cur_data p; ctx.cur_data.nd_var_map <- old_map; ctx.cur_data.nd_terminates <- old_term; ) let terminate ctx = ctx.cur_data.nd_terminates <- true let set_loop_join ctx join_top join_bottom = ctx.loop_stack <- (join_top,join_bottom) :: ctx.loop_stack; (fun () -> ctx.loop_stack <- List.tl ctx.loop_stack ) let set_exception_join ctx join = ctx.exception_stack <- join :: ctx.exception_stack; (fun () -> ctx.exception_stack <- List.tl ctx.exception_stack; ) let create_v_extra v = match v.v_extra with | Some (_,Some _) -> () | Some (tl,None) -> let e_extra = mk (TObjectDecl []) t_dynamic null_pos in v.v_extra <- Some (tl,Some e_extra) | None -> let e_extra = mk (TObjectDecl []) t_dynamic null_pos in v.v_extra <- Some ([],Some e_extra) let set_v_extra_value v s e = match v.v_extra with | Some (tl, Some {eexpr = TObjectDecl fl}) -> let rec loop fl = match fl with | (s',_) :: fl when s' = s -> (s,e) :: fl | f1 :: fl -> f1 :: loop fl | [] -> [s,e] in let e_extra = mk (TObjectDecl (loop fl)) t_dynamic null_pos in v.v_extra <- Some (tl, Some e_extra) | _ -> assert false let get_origin_var v = match v.v_extra with | Some (_,Some {eexpr = TObjectDecl fl}) -> begin match List.assoc "origin_var" fl with | {eexpr = TLocal v'} -> v' | _ -> raise Not_found end | _ -> raise Not_found let set_origin_var v v_origin p = let ev = mk_loc v_origin p in set_v_extra_value v "origin_var" ev let get_var_value v = match v.v_extra with | Some (_,Some {eexpr = TObjectDecl fl}) -> List.assoc "var_value" fl | _ -> raise Not_found let set_var_value v e = set_v_extra_value v "var_value" e let get_var_usage_count v = match v.v_extra with | Some (_,Some {eexpr = TObjectDecl fl}) -> begin try begin match List.assoc "usage_count" fl with | {eexpr = TConst (TInt i32)} -> Int32.to_int i32 | _ -> 0 end with Not_found -> 0 end | _ -> raise Not_found let set_var_usage_count v i = let e = mk (TConst (TInt (Int32.of_int i))) t_dynamic null_pos in set_v_extra_value v "usage_count" e let declare_var ctx v p = let old = v.v_extra in ctx.cleanup <- (fun () -> v.v_extra <- old ) :: ctx.cleanup; ctx.cur_data.nd_var_map <- IntMap.add v.v_id v ctx.cur_data.nd_var_map; v.v_meta <- ((Meta.Custom ":blockDepth",[EConst (Int (string_of_int ctx.block_depth)),p],p)) :: v.v_meta; v.v_extra <- None; create_v_extra v; set_origin_var v v p let assign_var ctx v e p = if v.v_capture then v else begin let i = match v.v_extra with | Some (l,eo) -> v.v_extra <- Some (("",t_dynamic) :: l,eo); List.length l + 1 | _ -> error "Something went wrong" p in let v' = alloc_var (Printf.sprintf "%s<%i>" v.v_name i) v.v_type in create_v_extra v'; v'.v_meta <- [(Meta.Custom ":ssa"),[],p]; set_origin_var v' v p; ctx.cur_data.nd_var_map <- IntMap.add v.v_id v' ctx.cur_data.nd_var_map; set_var_value v' e; v' end let get_var ctx v p = try IntMap.find v.v_id ctx.cur_data.nd_var_map with Not_found -> if not (has_meta Meta.Unbound v.v_meta) then error (Printf.sprintf "Unbound variable %s" v.v_name) p; v let close_join_node ctx node p = let terminates = ref true in let branches = List.filter (fun branch -> if branch.nd_terminates then false else begin terminates := false; true end ) node.branches in match branches with | [] -> () | branch :: branches -> let vars = ref (IntMap.map (fun v -> [v,branch.nd_pos]) branch.nd_var_map) in let rec handle_branch branch = IntMap.iter (fun i v -> try let vl = IntMap.find i !vars in if not (List.exists (fun (v',_) -> v == v') vl) then vars := IntMap.add i ((v,p) :: vl) !vars with Not_found -> () ) branch.nd_var_map; in List.iter handle_branch branches; ctx.cur_data.nd_terminates <- !terminates; IntMap.iter (fun i vl -> match vl with | [v,p] -> ctx.cur_data.nd_var_map <- IntMap.add i v ctx.cur_data.nd_var_map; | (v',_) :: _ -> let v = get_origin_var v' in ignore(assign_var ctx v (mk_phi vl p) p) | _ -> assert false ) !vars let invert_cond = function | Equal(v,e) -> NotEqual(v,e) | NotEqual(v,e) -> Equal(v,e) let invert_conds = List.map invert_cond let rec eval_cond ctx e = match e.eexpr with | TBinop(OpNotEq,{eexpr = TLocal v},e1) -> [NotEqual(v,e1)] | TBinop(OpEq,{eexpr = TLocal v},e1) -> [Equal(v,e1)] | TUnop(Not,_,e1) -> invert_conds (eval_cond ctx e1) | TLocal v -> begin try eval_cond ctx (get_var_value v) with Not_found -> [] end | _ -> [] let append_cond ctx v cond p = begin try let conds = IntMap.find v.v_id ctx.var_conds in ctx.var_conds <- IntMap.add v.v_id (cond :: conds) ctx.var_conds with Not_found -> ctx.var_conds <- IntMap.add v.v_id [cond] ctx.var_conds end (* let apply_cond ctx = function | Equal({v_extra = Some(_,Some {eexpr = TLocal v})} as v0,e1) -> let v' = assign_var ctx v (mk_loc v0 e1.epos) e1.epos in append_cond ctx v' (Equal(v',e1)) e1.epos | NotEqual({v_extra = Some(_,Some {eexpr = TLocal v})} as v0,e1) -> let v' = assign_var ctx v (mk_loc v0 e1.epos) e1.epos in append_cond ctx v' (NotEqual(v',e1)) e1.epos | _ -> () let apply_not_null_cond ctx v p = apply_cond ctx (NotEqual(v,(mk (TConst TNull) t_dynamic p))) *) let apply com e = let rec handle_if ctx f econd eif eelse = let econd = loop ctx econd in (* let cond = eval_cond ctx econd in *) let join = mk_join_node() in let close = branch ctx eif.epos in (* List.iter (apply_cond ctx) cond; *) let eif = loop ctx eif in close join; let eelse = match eelse with | None -> (* let cond = invert_conds cond in *) (* List.iter (apply_cond ctx) cond; *) add_branch join ctx.cur_data e.epos; None | Some e -> let close = branch ctx e.epos in (* let cond = invert_conds cond in *) (* List.iter (apply_cond ctx) cond; *) let eelse = loop ctx e in close join; Some eelse in close_join_node ctx join e.epos; f econd eif eelse and handle_loop_body ctx e = let join_top = mk_join_node() in let join_bottom = mk_join_node() in let unset = set_loop_join ctx join_top join_bottom in let close = branch ctx e.epos in ignore(loop ctx e); (* TODO: I don't know if this is sane. *) close join_top; add_branch join_top ctx.cur_data e.epos; close_join_node ctx join_top e.epos; let ebody = loop ctx e in ctx.cur_data.nd_terminates <- false; unset(); close_join_node ctx join_bottom e.epos; ebody and loop ctx e = match e.eexpr with (* var declarations *) | TVar(v,eo) -> declare_var ctx v e.epos; let eo = match eo with | None -> None | Some e -> let e = loop ctx e in set_var_value v e; Some e in {e with eexpr = TVar(v,eo)} | TFunction tf -> let close = branch ctx e.epos in List.iter (fun (v,co) -> declare_var ctx v e.epos; (* match co with | Some TNull when (match v.v_type with TType({t_path=["haxe"],"PosInfos"},_) -> false | _ -> true) -> () | _ -> apply_not_null_cond ctx v e.epos *) ) tf.tf_args; let e' = loop ctx tf.tf_expr in close (mk_join_node()); {e with eexpr = TFunction {tf with tf_expr = e'}} (* var modifications *) | TBinop(OpAssign,({eexpr = TLocal v} as e1),e2) when v.v_name <> "this" -> let e2 = loop ctx e2 in let _ = assign_var ctx v e2 e1.epos in {e with eexpr = TBinop(OpAssign,e1,e2)} | TBinop(OpAssignOp op,({eexpr = TLocal v} as e1),e2) -> let e1 = loop ctx e1 in let e2 = loop ctx e2 in let e_op = mk (TBinop(op,e1,e2)) e.etype e.epos in let _ = assign_var ctx v e_op e1.epos in {e with eexpr = TBinop(OpAssignOp op,e1,e2)} | TUnop((Increment | Decrement as op),flag,({eexpr = TLocal v} as e1)) -> let op = match op with Increment -> OpAdd | Decrement -> OpSub | _ -> assert false in let e_one = mk (TConst (TInt (Int32.of_int 1))) com.basic.tint e.epos in let e1 = loop ctx e1 in let e_op = mk (TBinop(op,e1,e_one)) e.etype e.epos in let _ = assign_var ctx v e_op e1.epos in e (* var user *) | TLocal v -> let v = get_var ctx v e.epos in {e with eexpr = TLocal v} (* control flow *) | TIf(econd,eif,eelse) -> let f econd eif eelse = {e with eexpr = TIf(econd,eif,eelse)} in handle_if ctx f econd eif eelse | TSwitch(e1,cases,edef) -> let e1 = loop ctx e1 in let join = mk_join_node() in let cases = List.map (fun (el,e) -> let close = branch ctx e.epos in let el = List.map (loop ctx) el in let e = loop ctx e in close join; el,e ) cases in let edef = match edef with | Some e -> let close = branch ctx e.epos in let e = loop ctx e in close join; Some e | None -> begin match e1.eexpr with | TMeta((Meta.Exhaustive,_,_),_) | TParenthesis({eexpr = TMeta((Meta.Exhaustive,_,_),_)}) -> () | _ -> add_branch join ctx.cur_data e.epos; end; None in close_join_node ctx join e.epos; let e = {e with eexpr = TSwitch(e1,cases,edef)} in e | TWhile(econd,ebody,mode) -> let econd = loop ctx econd in let ebody = handle_loop_body ctx ebody in let e = {e with eexpr = TWhile(econd,ebody,mode)} in e | TFor(v,e1,ebody) -> declare_var ctx v e.epos; (* apply_not_null_cond ctx v e1.epos; *) let v' = IntMap.find v.v_id ctx.cur_data.nd_var_map in let e1 = loop ctx e1 in let ebody = handle_loop_body ctx ebody in let e = {e with eexpr = TFor(v',e1,ebody)} in e | TTry(e1,catches) -> let join_ex = mk_join_node() in let join_bottom = mk_join_node() in let unset = set_exception_join ctx join_ex in let e1 = loop ctx e1 in unset(); add_branch join_bottom ctx.cur_data e.epos; close_join_node ctx join_ex e.epos; let catches = List.map (fun (v,e) -> declare_var ctx v e.epos; (* apply_not_null_cond ctx v e.epos; *) let close = branch ctx e.epos in let e = loop ctx e in close join_bottom; v,e ) catches in close_join_node ctx join_bottom e.epos; let e = {e with eexpr = TTry(e1,catches)} in e | TBreak -> begin match ctx.loop_stack with | [] -> error "Break outside loop" e.epos | (_,join) :: _ -> add_branch join ctx.cur_data e.epos end; terminate ctx; e | TContinue -> begin match ctx.loop_stack with | [] -> error "Continue outside loop" e.epos | (join,_) :: _ -> add_branch join ctx.cur_data e.epos end; terminate ctx; e | TThrow e1 -> let e1 = loop ctx e1 in begin match ctx.exception_stack with | join :: _ -> add_branch join ctx.cur_data e.epos | _ -> () end; terminate ctx; {e with eexpr = TThrow e1} | TReturn eo -> let eo = match eo with None -> None | Some e -> Some (loop ctx e) in terminate ctx; {e with eexpr = TReturn eo} | TBlock el -> let rec loop2 el = match el with | [] -> [] | e :: el -> if ctx.cur_data.nd_terminates then begin (* ctx.com.warning (Printf.sprintf "Unreachable code: %s" (s_expr_pretty e)) e.epos; *) [] end else let e = loop ctx e in e :: (loop2 el) in ctx.block_depth <- ctx.block_depth + 1; let el = loop2 el in ctx.block_depth <- ctx.block_depth - 1; {e with eexpr = TBlock(el)} | _ -> begin match ctx.exception_stack with | join :: _ when can_throw e -> add_branch join ctx.cur_data e.epos | _ -> () end; Type.map_expr (loop ctx) e in let ctx = { com = com; cur_data = mk_node_data e.epos; var_conds = IntMap.empty; loop_stack = []; exception_stack = []; cleanup = []; block_depth = 0; } in let e = loop ctx e in e,ctx let unapply com e = let rec loop e = match e.eexpr with | TFor(v,e1,e2) when Meta.has (Meta.Custom ":ssa") v.v_meta -> let v' = get_origin_var v in let e1 = loop e1 in let e2 = loop e2 in {e with eexpr = TFor(v',e1,e2)} | TLocal v when Meta.has (Meta.Custom ":ssa") v.v_meta -> let v' = get_origin_var v in {e with eexpr = TLocal v'} | TBlock el -> let rec filter e = match e.eexpr with | TMeta((Meta.Custom ":ssa",_,_),_) -> false | _ -> true in let el = List.filter filter el in let el = List.map loop el in {e with eexpr = TBlock el} | _ -> Type.map_expr loop e in loop e end module ConstPropagation = struct open Ssa let expr_eq e1 e2 = match e1.eexpr,e2.eexpr with | TConst ct1, TConst ct2 -> ct1 = ct2 | _ -> false let get_block_depth v = try let i = match Meta.get (Meta.Custom ":blockDepth") v.v_meta with | _,[EConst(Int s),_],_ -> int_of_string s | _ -> raise Not_found in i with Not_found -> -1 let can_be_inlined com v0 e = type_iseq v0.v_type e.etype && match e.eexpr with | TConst ct -> begin match ct with | TThis | TSuper -> false (* Some targets don't like seeing null in certain places and won't even compile. We have to detect `if (x != null) in order for this to work. *) | TNull when (match com.platform with Php | Cpp -> true | _ -> false) -> false | _ -> true end | TLocal v -> not (Meta.has Meta.CompilerGenerated v.v_meta) && begin try let v' = Ssa.get_origin_var v in begin match v'.v_extra with | Some ([],_) -> get_block_depth v <= get_block_depth v0 | _ -> false end with Not_found -> false end | TEnumParameter _ when not (com.platform = Php) -> Ssa.get_var_usage_count v0 <= 1 | _ -> false let semi_awkward_enum_value ssa e i = match e.eexpr with | TCall({eexpr = TField(_,FEnum _)},el) -> (try List.nth el i with Failure _ -> raise Not_found) | _ -> raise Not_found let rec local ssa force v e = begin try if v.v_capture then raise Not_found; if type_has_analyzer_option v.v_type flag_no_const_propagation then raise Not_found; begin match follow v.v_type with | TDynamic _ -> raise Not_found | _ -> () end; let e = Ssa.get_var_value v in let old = v.v_extra in v.v_extra <- None; let e = value ssa force e in v.v_extra <- old; Ssa.set_var_value v e; e with Not_found -> e end (* force must only be true if the value is not used in the output *) and value ssa force e = match e.eexpr with | TUnop((Increment | Decrement),_,_) | TBinop(OpAssignOp _,_,_) | TBinop(OpAssign,_,_) -> e | TBinop(op,e1,e2) -> let e1 = value ssa force e1 in let e2 = value ssa force e2 in let e = {e with eexpr = TBinop(op,e1,e2)} in let e' = Optimizer.optimize_binop e op e1 e2 in if e == e' then e else value ssa force e' | TUnop(op,flag,e1) -> let e1 = value ssa force e1 in let e = {e with eexpr = TUnop(op,flag,e1)} in let e' = Optimizer.optimize_unop e op flag e1 in if e == e' then e else value ssa force e' | TCall (({eexpr = TLocal {v_name = "__ssa_phi__"}} as ephi),el) -> let el = List.map (value ssa force) el in begin match el with | [] -> assert false | e1 :: el -> if List.for_all (fun e2 -> expr_eq e1 e2) el then value ssa force e1 else {e with eexpr = TCall(ephi, e1 :: el)} end | TParenthesis e1 | TMeta(_,e1) -> value ssa force e1 | TLocal v -> let e' = local ssa force v e in if force || can_be_inlined ssa.com v e' then e' else e | TEnumParameter(e1,ef,i) -> let ev = value ssa true e1 in begin try value ssa force (semi_awkward_enum_value ssa ev i) with Not_found -> e end | _ -> e (* TODO: the name is quite accurate *) let awkward_get_enum_index ssa e = let e = awkward_get_enum_index ssa.com e in let ev = (value ssa true e) in match ev.eexpr with | TField(_,FEnum(_,ef)) -> TInt (Int32.of_int ef.ef_index) | TCall({eexpr = TField(_,FEnum(_,ef))},_) -> TInt (Int32.of_int ef.ef_index) | _ -> raise Not_found let apply ssa e = let rec loop e = match e.eexpr with | TLocal v when not (Meta.has Meta.Unbound v.v_meta) -> set_var_usage_count v (get_var_usage_count v + 1); | _ -> Type.iter loop e in loop e; let had_function = ref false in let rec loop e = match e.eexpr with | TFunction _ when !had_function -> e | TFunction tf -> had_function := true; {e with eexpr = TFunction {tf with tf_expr = loop tf.tf_expr}} | TLocal v -> let e' = local ssa false v e in if can_be_inlined ssa.com v e' then e' else e | TCall({eexpr = TField(_,(FStatic(_,cf) | FInstance(_,_,cf) | FAnon cf))},el) when has_analyzer_option cf.cf_meta flag_no_const_propagation -> e | TCall(e1,el) -> let e1 = loop e1 in let check e t = if type_has_analyzer_option t flag_no_const_propagation then e else loop e in let el = Codegen.UnificationCallback.check_call check el e1.etype in {e with eexpr = TCall(e1,el)} (* | TField(e1,fa) -> let e1' = loop e1 in let fa = if e1' != e1 then begin try quick_field e1'.etype (field_name fa) with Not_found -> fa end else fa in {e with eexpr = TField(e1',fa)} *) | TUnop((Increment | Decrement),_,_) -> e | TBinop(OpAssignOp op,e1,e2) -> let e2 = loop e2 in {e with eexpr = TBinop(OpAssignOp op,e1,e2)} | TBinop(OpAssign,({eexpr = TLocal _} as e1),e2) -> let e2 = loop e2 in {e with eexpr = TBinop(OpAssign,e1,e2)} | TBinop(op,e1,e2) -> let e1 = loop e1 in let e2 = loop e2 in let e = {e with eexpr = TBinop(op,e1,e2)} in let e' = Optimizer.optimize_binop e op e1 e2 in e' | TUnop(op,flag,e1) -> let e1 = loop e1 in let e = {e with eexpr = TUnop(op,flag,e1)} in let e' = Optimizer.optimize_unop e op flag e1 in e' | TIf(e1,e2,eo) -> let e1 = loop e1 in let e2 = loop e2 in let rec check_const e1 = match e1.eexpr with | TConst (TBool true) -> e2 | TConst (TBool false) -> begin match eo with | None -> mk (TConst TNull) t_dynamic e.epos | Some e -> loop e end | TParenthesis e1 -> check_const e1 | _ -> let eo = match eo with None -> None | Some e -> Some (loop e) in {e with eexpr = TIf(e1,e2,eo)} in check_const e1 | TSwitch(e1,cases,edef) -> let e1 = loop e1 in let rec check_constant e = match e.eexpr with | TConst ct -> ct | TParenthesis e1 | TCast(e1,None) | TMeta(_,e1) -> check_constant e1 | _ -> awkward_get_enum_index ssa e in begin try let ct = check_constant e1 in begin try let _,e = List.find (fun (el,_) -> List.exists (fun e -> match e.eexpr with | TConst ct2 -> ct = ct2 | _ -> false ) el ) cases in loop e with Not_found -> begin match edef with None -> raise Not_found | Some e -> loop e end end with Not_found -> let cases = List.map (fun (el,e) -> el,loop e) cases in let edef = match edef with None -> None | Some e -> Some (loop e) in {e with eexpr = TSwitch(e1,cases,edef)} end | _ -> Type.map_expr loop e in loop e end module EffectChecker = struct let run com is_var_expression e = let has_effect e = match e.eexpr with | TVar _ -> true | _ -> Optimizer.has_side_effect e in let e = if is_var_expression then (* var initialization expressions are like assignments, so let's cheat a bit here *) snd (Simplifier.apply com (Codegen.binop OpAssign (mk (TConst TNull) t_dynamic e.epos) e e.etype e.epos)) else e in let rec loop e = match e.eexpr with | TBlock el -> List.iter (fun e -> if not (has_effect e) then com.warning "This expression has no effect" e.epos ) el | _ -> Type.iter loop e in loop e end module Checker = struct open Ssa let apply ssa e = let given_warnings = ref PMap.empty in let add_pos p = given_warnings := PMap.add p true !given_warnings in let resolve_value v = let e' = Ssa.get_var_value v in begin match e'.eexpr with | TLocal v' when v == v' -> e' | _ -> e' end in let rec is_null_expr e = match e.eexpr with | TConst TNull -> true | TLocal v -> (try is_null_expr (resolve_value v) with Not_found -> false) | _ -> false in let can_be_null v = not (has_meta Meta.NotNull v.v_meta) && try not (List.exists (fun cond -> match cond with | NotEqual(v',e) when v == v' && is_null_expr e -> true | _ -> false ) (IntMap.find v.v_id ssa.var_conds)) with Not_found -> true in let return b p = if b then add_pos p; b in let rec can_be_null_expr vstack e = if PMap.mem e.epos !given_warnings then false else match e.eexpr with | TConst TNull -> add_pos e.epos; true | TBinop((OpAssign | OpAssignOp _),_,e1) -> can_be_null_expr vstack e1 | TBinop _ | TUnop _ -> false | TConst _ | TTypeExpr _ | TNew _ | TObjectDecl _ | TArrayDecl _ | TEnumParameter _ | TFunction _ | TVar _ -> false | TFor _ | TWhile _ | TIf _ | TSwitch _ | TTry _ | TReturn _ | TBreak | TContinue | TThrow _ -> assert false | TField _ | TBlock _ | TArray _ -> false (* TODO *) | TCall ({eexpr = TLocal {v_name = "__ssa_phi__"}},el) -> List.exists (can_be_null_expr vstack) el | TLocal v -> if List.mem v.v_id vstack then false (* not really, but let's not be a nuisance *) else return (can_be_null v && (try can_be_null_expr (v.v_id :: vstack) (resolve_value v) with Not_found -> true)) e.epos; | TMeta(_,e1) | TParenthesis e1 | TCast(e1,_) -> can_be_null_expr vstack e1 | TCall(e1,_) -> begin match follow e1.etype with | TFun(_,r) -> return (is_explicit_null r) e1.epos | _ -> false end in let check_null e p = if can_be_null_expr [] e then begin ssa.com.warning "Possible null exception" p; end in let rec loop e = match e.eexpr with | TField(e1,fa) -> let e1 = loop e1 in check_null e1 e.epos; {e with eexpr = TField(e1,fa)} | TMeta((Meta.Analyzer,[EConst(Ident "testIsNull"),_],_),e1) -> if not (can_be_null_expr [] e) then error "Analyzer did not find a possible null exception" e.epos; e | TMeta((Meta.Analyzer,[EConst(Ident "testIsNotNull"),_],_),e1) -> if (can_be_null_expr [] e) then error "Analyzer found a possible null exception" e.epos; e | _ -> Type.map_expr loop e in loop e; end let rec lrev_iter f el = match el with | e :: el -> lrev_iter f el; f e | [] -> () let rev_iter f e = match e.eexpr with | TConst _ | TLocal _ | TBreak | TContinue | TTypeExpr _ -> () | TArray (e1,e2) | TBinop (_,e1,e2) | TFor (_,e1,e2) | TWhile (e1,e2,_) -> f e2; f e1; | TThrow e | TField (e,_) | TEnumParameter (e,_,_) | TParenthesis e | TCast (e,_) | TUnop (_,_,e) | TMeta(_,e) -> f e | TArrayDecl el | TNew (_,_,el) | TBlock el -> lrev_iter f el | TObjectDecl fl -> lrev_iter (fun (_,e) -> f e) fl | TCall (e,el) -> f e; lrev_iter f el | TVar (v,eo) -> (match eo with None -> () | Some e -> f e) | TFunction fu -> f fu.tf_expr | TIf (e,e1,e2) -> (match e2 with None -> () | Some e -> f e); f e1; f e; | TSwitch (e,cases,def) -> (match def with None -> () | Some e -> f e); lrev_iter (fun (el,e2) -> lrev_iter f el; f e2) cases; f e; | TTry (e,catches) -> lrev_iter (fun (_,e) -> f e) catches; f e; | TReturn eo -> (match eo with None -> () | Some e -> f e) module LocalDce = struct let apply e = let is_used v = Meta.has Meta.Used v.v_meta || type_has_analyzer_option v.v_type flag_no_local_dce || v.v_capture in let is_ref_type t = match t with | TType({t_path = ["cs"],("Ref" | "Out")},_) -> true | _ -> false in let rec use v = if not (Meta.has Meta.Used v.v_meta) then begin v.v_meta <- (Meta.Used,[],Ast.null_pos) :: v.v_meta; try use (Ssa.get_origin_var v) with Not_found -> () end in let rec has_side_effect e = let rec loop e = match e.eexpr with | TLocal v when Meta.has Meta.CompilerGenerated v.v_meta -> (try loop (Ssa.get_var_value v) with Not_found -> ()) | TBinop((OpAssign | OpAssignOp _),{eexpr = TLocal v},e2) when is_used v || has_side_effect e2 || is_ref_type v.v_type -> raise Exit | TVar(v,None) when is_used v -> raise Exit | TVar(v,Some e1) when is_used v || has_side_effect e1 -> raise Exit | TConst _ | TLocal _ | TTypeExpr _ | TFunction _ -> () | TCall ({ eexpr = TField(_,FStatic({ cl_path = ([],"Std") },{ cf_name = "string" })) },args) -> Type.iter loop e | TCall (({eexpr = TLocal {v_name = "__ssa_phi__"}}),el) -> () | TCall ({eexpr = TField(_,FEnum _)},_) -> Type.iter loop e | TNew _ | TCall _ | TBinop ((OpAssignOp _ | OpAssign),_,_) | TUnop ((Increment|Decrement),_,_) -> raise Exit | TReturn _ | TBreak | TContinue | TThrow _ | TCast (_,Some _) -> raise Exit | TFor _ -> raise Exit | TArray _ | TEnumParameter _ | TCast (_,None) | TBinop _ | TUnop _ | TParenthesis _ | TMeta _ | TWhile _ | TField _ | TIf _ | TTry _ | TSwitch _ | TArrayDecl _ | TBlock _ | TObjectDecl _ | TVar _ -> Type.iter loop e in try loop e; false with Exit -> true in let rec collect e = match e.eexpr with | TLocal v -> use v | TVar(v,_) when not (is_used v) -> (* TODO: this is probably dangerous *) () | _ -> rev_iter collect e in let rec loop need_val e = match e.eexpr with | TLocal v -> use v; e | TBinop(OpAssign,({eexpr = TLocal v} as e1),e2) -> let e2 = loop false e2 in if not (is_used v) && not (is_ref_type v.v_type) then e2 else {e with eexpr = TBinop(OpAssign,{e1 with eexpr = TLocal v},e2)} | TVar(v,Some e1) when not (is_used v) -> let e1 = if has_side_effect e1 then loop true e1 else e1 in e1 | TWhile(e1,e2,flag) -> collect e2; let e2 = loop false e2 in let e1 = loop false e1 in {e with eexpr = TWhile(e1,e2,flag)} | TFor(v,e1,e2) -> collect e2; let e2 = loop false e2 in let e1 = loop false e1 in {e with eexpr = TFor(v,e1,e2)} | TBlock el -> let rec block el = match el with | e :: el -> let el = block el in if not need_val && not (has_side_effect e) then el else begin let e = loop false e in e :: el end | [] -> [] in {e with eexpr = TBlock (block el)} | TCall(e1, el) -> let el = List.rev_map (loop true) (List.rev el) in let e1 = loop false e1 in {e with eexpr = TCall(e1,el)} | TIf(e1,e2,e3) -> let e3 = match e3 with None -> None | Some e -> Some (loop need_val e) in let e2 = loop need_val e2 in let e1 = loop false e1 in {e with eexpr = TIf(e1,e2,e3)} | TArrayDecl el -> let el = List.rev_map (loop true) (List.rev el) in {e with eexpr = TArrayDecl el} | TObjectDecl fl -> let fl = List.rev_map (fun (s,e) -> s,loop true e) (List.rev fl) in {e with eexpr = TObjectDecl fl} | _ -> Type.map_expr (loop false) e in loop false e end module Config = struct type analyzer_config = { analyzer_use : bool; simplifier_apply : bool; ssa_apply : bool; const_propagation : bool; check : bool; check_has_effect : bool; local_dce : bool; ssa_unapply : bool; simplifier_unapply : bool; } let get_base_config com = { analyzer_use = true; simplifier_apply = true; ssa_apply = true; const_propagation = not (Common.raw_defined com "analyzer-no-const-propagation"); check_has_effect = (Common.raw_defined com "analyzer-check-has-effect"); check = not (Common.raw_defined com "analyzer-no-check"); local_dce = not (Common.raw_defined com "analyzer-no-local-dce") && not (Common.defined com Define.As3); ssa_unapply = not (Common.raw_defined com "analyzer-no-ssa-unapply"); simplifier_unapply = not (Common.raw_defined com "analyzer-no-simplify-unapply"); } let update_config_from_meta config meta = List.fold_left (fun config meta -> match meta with | (Meta.Analyzer,el,_) -> List.fold_left (fun config e -> match fst e with | EConst (Ident s) when s = flag_no_check -> { config with check = false} | EConst (Ident s) when s = flag_check -> { config with check = true} | EConst (Ident s) when s = flag_no_const_propagation -> { config with const_propagation = false} | EConst (Ident s) when s = flag_const_propagation -> { config with const_propagation = true} | EConst (Ident s) when s = flag_no_local_dce -> { config with local_dce = false} | EConst (Ident s) when s = flag_local_dce -> { config with local_dce = true} | EConst (Ident s) when s = flag_no_check_has_effect -> { config with check_has_effect = false} | EConst (Ident s) when s = flag_check_has_effect -> { config with check_has_effect = true} | _ -> config ) config el | _ -> config ) config meta let get_class_config com c = let config = get_base_config com in update_config_from_meta config c.cl_meta let get_field_config com c cf = let config = get_class_config com c in update_config_from_meta config cf.cf_meta end module Run = struct open Config let run_on_expr com config is_var_expression e = let do_simplify = (not (Common.defined com Define.NoSimplify) ) && match com.platform with | Cpp when Common.defined com Define.Cppia -> false | Cpp | Python -> true | _ -> false in let with_timer s f = let timer = timer s in let r = f() in timer(); r in try let has_unbound,e = if do_simplify || config.analyzer_use then with_timer "analyzer-simplify-apply" (fun () -> Simplifier.apply com e) else false,e in let e = if config.analyzer_use && not has_unbound then begin if config.check_has_effect then EffectChecker.run com is_var_expression e; let e,ssa = with_timer "analyzer-ssa-apply" (fun () -> Ssa.apply com e) in let e = if config.const_propagation then with_timer "analyzer-const-propagation" (fun () -> ConstPropagation.apply ssa e) else e in (* let e = if config.check then with_timer "analyzer-checker" (fun () -> Checker.apply ssa e) else e in *) let e = if config.local_dce && config.analyzer_use && not has_unbound && not is_var_expression then with_timer "analyzer-local-dce" (fun () -> LocalDce.apply e) else e in let e = if config.ssa_unapply then with_timer "analyzer-ssa-unapply" (fun () -> Ssa.unapply com e) else e in List.iter (fun f -> f()) ssa.Ssa.cleanup; e end else e in let e = if not do_simplify && not (Common.raw_defined com "analyzer-no-simplify-unapply") then with_timer "analyzer-simplify-unapply" (fun () -> Simplifier.unapply com e) else e in e with Exit -> e let run_on_field ctx config cf = match cf.cf_expr with | Some e when not (is_ignored cf.cf_meta) && not (Codegen.is_removable_field ctx cf) -> let config = update_config_from_meta config cf.cf_meta in let is_var_expression = match cf.cf_kind with | Var _ -> true | _ -> false in cf.cf_expr <- Some (run_on_expr ctx.com config is_var_expression e); | _ -> () let run_on_class ctx config c = let config = update_config_from_meta config c.cl_meta in let process_field cf = run_on_field ctx config cf in List.iter process_field c.cl_ordered_fields; List.iter process_field c.cl_ordered_statics; (match c.cl_constructor with | None -> () | Some f -> process_field f); (match c.cl_init with | None -> () | Some e -> (* never optimize init expressions (too messy) *) c.cl_init <- Some (run_on_expr ctx.com {config with analyzer_use = false} false e)) let run_on_type ctx config t = match t with | TClassDecl c when (is_ignored c.cl_meta) -> () | TClassDecl c -> run_on_class ctx config c | TEnumDecl _ -> () | TTypeDecl _ -> () | TAbstractDecl _ -> () let run_on_types ctx types = let com = ctx.com in let config = get_base_config com in List.iter (run_on_type ctx config) types end haxe_3.2.1+dfsg.orig/appveyor.yml0000664000175000017500000000532312607337712016717 0ustar andyandy00000000000000version: "{build}" platform: - Win32 environment: global: NEKO_ROOT: C:/projects/neko HAXELIB_ROOT: C:/projects/haxelib CYG_ARCH: x86 CYG_ROOT: C:/cygwin CYG_SETUP: C:/cygwin/setup-x86.exe MINGW_ARCH: i686 WODI: wodi32 ADD_REVISION: 1 OCAMLOPT: ocamlopt.opt matrix: - TEST: "neko,cs,java,macro" - TEST: "cpp" skip_tags: true install: - 'git submodule update --init --recursive' - cinst 7zip.commandline -y # Install ocaml using wodi - appveyor DownloadFile "http://cygwin.com/setup-%CYG_ARCH%.exe" -FileName "%CYG_ROOT%\setup.exe" - '%CYG_ROOT%/setup.exe -g -q -R "%CYG_ROOT%" -P dos2unix -P diffutils -P cpio -P make -P patch -P mingw64-%MINGW_ARCH%-gcc-core -P mingw64-%MINGW_ARCH%-gcc-g++ > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin" > log.txt || type log.txt' # The archive is a dropbox hosted version of https://github.com/fdopen/godi-repo/issues/7#issuecomment-98480339 - '%CYG_ROOT%/bin/bash -lc "wget -q https://dl.dropboxusercontent.com/u/2661116/wodi/%WODI%.tar.xz -O /tmp/%WODI%.tar.xz" > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "cd /tmp && rm -rf %WODI% && tar -xf %WODI%.tar.xz && bash %WODI%/install.sh" > log.txt || type log.txt' - '%CYG_ROOT%/bin/bash -lc "godi_add godi-zip" > log.txt || type log.txt' - 'set PATH=%PATH%;%CYG_ROOT%/opt/%WODI%/bin' # Install neko - cinst make -y - 'git clone --recursive https://github.com/HaxeFoundation/neko.git %NEKO_ROOT%' - 'cd %NEKO_ROOT%' - set PATH=%PATH%;%NEKO_ROOT%/bin - msbuild neko_vc10.sln /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" > log.txt || type log.txt - msbuild libs/libs_vc10.sln /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" > log.txt || type log.txt - copy /y libs\include\gc\gc.dll bin - cd %NEKO_ROOT%/src - neko ../boot/nekoc tools/install.neko - neko tools/install -nolibs > log.txt || type log.txt - neko -version build_script: - 'cd %APPVEYOR_BUILD_FOLDER%' - 'set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%' - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win"' - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win tools"' - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -s -f Makefile.win package_bin"' - dir %APPVEYOR_BUILD_FOLDER%\out - cd %APPVEYOR_BUILD_FOLDER%/tests/ - mkdir "%HAXELIB_ROOT%" - haxelib setup "%HAXELIB_ROOT%" test_script: - cd %APPVEYOR_BUILD_FOLDER%/tests/ - haxe -version - haxe RunCi.hxml - neko RunCi.n artifacts: - path: out/haxe_*.zip haxe_3.2.1+dfsg.orig/ast.ml0000664000175000017500000004105212607337712015447 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) type pos = { pfile : string; pmin : int; pmax : int; } module IntMap = Map.Make(struct type t = int let compare a b = a - b end) module Meta = struct type strict_meta = | Abi | Abstract | Access | Accessor | Allow | Analyzer | Annotation | ArrayAccess | Ast | AutoBuild | Bind | Bitmap | BridgeProperties | Build | BuildXml | Callable | Class | ClassCode | Commutative | CompilerGenerated | CoreApi | CoreType | CppFileCode | CppInclude | CppNamespaceCode | CsNative | Dce | Debug | Decl | DefParam | Delegate | Depend | Deprecated | DirectlyUsed | DynamicObject | Enum | EnumConstructorParam | Event | Exhaustive | Expose | Extern | FakeEnum | File | Final | FlatEnum | Font | Forward | From | FunctionCode | FunctionTailCode | Generic | GenericBuild | GenericInstance | Getter | Hack | HasUntyped | HaxeGeneric | HeaderClassCode | HeaderCode | HeaderInclude | HeaderNamespaceCode | HxGen | IfFeature | Impl | PythonImport | ImplicitCast | Include | InitPackage | Internal | IsVar | JavaCanonical | JavaNative | JsRequire | Keep | KeepInit | KeepSub | LibType | Meta | Macro | MaybeUsed | MergeBlock | MultiType | Native | NativeChildren | NativeGen | NativeGeneric | NativeProperty | NoCompletion | NoDebug | NoDoc | NoExpr | NoImportGlobal | NonVirtual | NoPackageRestrict | NoPrivateAccess | NoStack | NotNull | NoUsing | Ns | Op | Optional | Overload | PrivateAccess | Property | Protected | Public | PublicFields | QuotedField | ReadOnly | RealPath | Remove | Require | RequiresAssign (* | Resolve *) | ReplaceReflection | Rtti | Runtime | RuntimeValue | SelfCall | Setter | SkipCtor | SkipReflection | Sound | SourceFile | StoredTypedExpr | Strict | Struct | StructAccess | SuppressWarnings | This | Throws | To | ToString | Transient | ValueUsed | Volatile | Unbound | UnifyMinDynamic | Unreflective | Unsafe | Usage | Used | Value | Void | Last (* do not put any custom metadata after Last *) | Dollar of string | Custom of string let has m ml = List.exists (fun (m2,_,_) -> m = m2) ml let get m ml = List.find (fun (m2,_,_) -> m = m2) ml let to_string_ref = ref (fun _ -> assert false) let to_string (m : strict_meta) : string = !to_string_ref m end type keyword = | Function | Class | Var | If | Else | While | Do | For | Break | Continue | Return | Extends | Implements | Import | Switch | Case | Default | Static | Public | Private | Try | Catch | New | This | Throw | Extern | Enum | In | Interface | Untyped | Cast | Override | Typedef | Dynamic | Package | Inline | Using | Null | True | False | Abstract | Macro type binop = | OpAdd | OpMult | OpDiv | OpSub | OpAssign | OpEq | OpNotEq | OpGt | OpGte | OpLt | OpLte | OpAnd | OpOr | OpXor | OpBoolAnd | OpBoolOr | OpShl | OpShr | OpUShr | OpMod | OpAssignOp of binop | OpInterval | OpArrow type unop = | Increment | Decrement | Not | Neg | NegBits type constant = | Int of string | Float of string | String of string | Ident of string | Regexp of string * string type token = | Eof | Const of constant | Kwd of keyword | Comment of string | CommentLine of string | Binop of binop | Unop of unop | Semicolon | Comma | BrOpen | BrClose | BkOpen | BkClose | POpen | PClose | Dot | DblDot | Arrow | IntInterval of string | Sharp of string | Question | At | Dollar of string type unop_flag = | Prefix | Postfix type while_flag = | NormalWhile | DoWhile type type_path = { tpackage : string list; tname : string; tparams : type_param_or_const list; tsub : string option; } and type_param_or_const = | TPType of complex_type | TPExpr of expr and complex_type = | CTPath of type_path | CTFunction of complex_type list * complex_type | CTAnonymous of class_field list | CTParent of complex_type | CTExtend of type_path list * class_field list | CTOptional of complex_type and func = { f_params : type_param list; f_args : (string * bool * complex_type option * expr option) list; f_type : complex_type option; f_expr : expr option; } and expr_def = | EConst of constant | EArray of expr * expr | EBinop of binop * expr * expr | EField of expr * string | EParenthesis of expr | EObjectDecl of (string * expr) list | EArrayDecl of expr list | ECall of expr * expr list | ENew of type_path * expr list | EUnop of unop * unop_flag * expr | EVars of (string * complex_type option * expr option) list | EFunction of string option * func | EBlock of expr list | EFor of expr * expr | EIn of expr * expr | EIf of expr * expr * expr option | EWhile of expr * expr * while_flag | ESwitch of expr * (expr list * expr option * expr option) list * expr option option | ETry of expr * (string * complex_type * expr) list | EReturn of expr option | EBreak | EContinue | EUntyped of expr | EThrow of expr | ECast of expr * complex_type option | EDisplay of expr * bool | EDisplayNew of type_path | ETernary of expr * expr * expr | ECheckType of expr * complex_type | EMeta of metadata_entry * expr and expr = expr_def * pos and type_param = { tp_name : string; tp_params : type_param list; tp_constraints : complex_type list; } and documentation = string option and metadata_entry = (Meta.strict_meta * expr list * pos) and metadata = metadata_entry list and access = | APublic | APrivate | AStatic | AOverride | ADynamic | AInline | AMacro and class_field_kind = | FVar of complex_type option * expr option | FFun of func | FProp of string * string * complex_type option * expr option and class_field = { cff_name : string; cff_doc : documentation; cff_pos : pos; mutable cff_meta : metadata; mutable cff_access : access list; mutable cff_kind : class_field_kind; } type enum_flag = | EPrivate | EExtern type class_flag = | HInterface | HExtern | HPrivate | HExtends of type_path | HImplements of type_path type abstract_flag = | APrivAbstract | AFromType of complex_type | AToType of complex_type | AIsType of complex_type type enum_constructor = { ec_name : string; ec_doc : documentation; ec_meta : metadata; ec_args : (string * bool * complex_type) list; ec_pos : pos; ec_params : type_param list; ec_type : complex_type option; } type ('a,'b) definition = { d_name : string; d_doc : documentation; d_params : type_param list; d_meta : metadata; d_flags : 'a list; d_data : 'b; } type import_mode = | INormal | IAsName of string | IAll type type_def = | EClass of (class_flag, class_field list) definition | EEnum of (enum_flag, enum_constructor list) definition | ETypedef of (enum_flag, complex_type) definition | EAbstract of (abstract_flag, class_field list) definition | EImport of (string * pos) list * import_mode | EUsing of type_path type type_decl = type_def * pos type package = string list * type_decl list exception Error of string * pos let is_lower_ident i = let rec loop p = match String.unsafe_get i p with | 'a'..'z' -> true | '_' -> if p + 1 < String.length i then loop (p + 1) else true | _ -> false in loop 0 let pos = snd let rec is_postfix (e,_) op = match op with | Increment | Decrement -> true | Not | Neg | NegBits -> false let is_prefix = function | Increment | Decrement -> true | Not | Neg | NegBits -> true let base_class_name = snd let null_pos = { pfile = "?"; pmin = -1; pmax = -1 } let punion p p2 = { pfile = p.pfile; pmin = min p.pmin p2.pmin; pmax = max p.pmax p2.pmax; } let rec punion_el el = match el with | [] -> null_pos | (_,p) :: [] -> p | (_,p) :: el -> punion p (punion_el el) let s_type_path (p,s) = match p with [] -> s | _ -> String.concat "." p ^ "." ^ s let parse_path s = match List.rev (ExtString.String.nsplit s ".") with | [] -> failwith "Invalid empty path" | x :: l -> List.rev l, x let s_escape ?(hex=true) s = let b = Buffer.create (String.length s) in for i = 0 to (String.length s) - 1 do match s.[i] with | '\n' -> Buffer.add_string b "\\n" | '\t' -> Buffer.add_string b "\\t" | '\r' -> Buffer.add_string b "\\r" | '"' -> Buffer.add_string b "\\\"" | '\\' -> Buffer.add_string b "\\\\" | c when int_of_char c < 32 && hex -> Buffer.add_string b (Printf.sprintf "\\x%.2X" (int_of_char c)) | c -> Buffer.add_char b c done; Buffer.contents b let s_constant = function | Int s -> s | Float s -> s | String s -> "\"" ^ s_escape s ^ "\"" | Ident s -> s | Regexp (r,o) -> "~/" ^ r ^ "/" let s_access = function | APublic -> "public" | APrivate -> "private" | AStatic -> "static" | AOverride -> "override" | ADynamic -> "dynamic" | AInline -> "inline" | AMacro -> "macro" let s_keyword = function | Function -> "function" | Class -> "class" | Static -> "static" | Var -> "var" | If -> "if" | Else -> "else" | While -> "while" | Do -> "do" | For -> "for" | Break -> "break" | Return -> "return" | Continue -> "continue" | Extends -> "extends" | Implements -> "implements" | Import -> "import" | Switch -> "switch" | Case -> "case" | Default -> "default" | Private -> "private" | Public -> "public" | Try -> "try" | Catch -> "catch" | New -> "new" | This -> "this" | Throw -> "throw" | Extern -> "extern" | Enum -> "enum" | In -> "in" | Interface -> "interface" | Untyped -> "untyped" | Cast -> "cast" | Override -> "override" | Typedef -> "typedef" | Dynamic -> "dynamic" | Package -> "package" | Inline -> "inline" | Using -> "using" | Null -> "null" | True -> "true" | False -> "false" | Abstract -> "abstract" | Macro -> "macro" let rec s_binop = function | OpAdd -> "+" | OpMult -> "*" | OpDiv -> "/" | OpSub -> "-" | OpAssign -> "=" | OpEq -> "==" | OpNotEq -> "!=" | OpGte -> ">=" | OpLte -> "<=" | OpGt -> ">" | OpLt -> "<" | OpAnd -> "&" | OpOr -> "|" | OpXor -> "^" | OpBoolAnd -> "&&" | OpBoolOr -> "||" | OpShr -> ">>" | OpUShr -> ">>>" | OpShl -> "<<" | OpMod -> "%" | OpAssignOp op -> s_binop op ^ "=" | OpInterval -> "..." | OpArrow -> "=>" let s_unop = function | Increment -> "++" | Decrement -> "--" | Not -> "!" | Neg -> "-" | NegBits -> "~" let s_token = function | Eof -> "" | Const c -> s_constant c | Kwd k -> s_keyword k | Comment s -> "/*"^s^"*/" | CommentLine s -> "//"^s | Binop o -> s_binop o | Unop o -> s_unop o | Semicolon -> ";" | Comma -> "," | BkOpen -> "[" | BkClose -> "]" | BrOpen -> "{" | BrClose -> "}" | POpen -> "(" | PClose -> ")" | Dot -> "." | DblDot -> ":" | Arrow -> "->" | IntInterval s -> s ^ "..." | Sharp s -> "#" ^ s | Question -> "?" | At -> "@" | Dollar v -> "$" ^ v let unescape s = let b = Buffer.create 0 in let rec loop esc i = if i = String.length s then () else let c = s.[i] in if esc then begin let inext = ref (i + 1) in (match c with | 'n' -> Buffer.add_char b '\n' | 'r' -> Buffer.add_char b '\r' | 't' -> Buffer.add_char b '\t' | '"' | '\'' | '\\' -> Buffer.add_char b c | '0'..'3' -> let c = (try char_of_int (int_of_string ("0o" ^ String.sub s i 3)) with _ -> raise Exit) in Buffer.add_char b c; inext := !inext + 2; | 'x' -> let c = (try char_of_int (int_of_string ("0x" ^ String.sub s (i+1) 2)) with _ -> raise Exit) in Buffer.add_char b c; inext := !inext + 2; | 'u' -> let (u, a) = try (int_of_string ("0x" ^ String.sub s (i+1) 4), 4) with _ -> try assert (s.[i+1] = '{'); let l = String.index_from s (i+3) '}' - (i+2) in let u = int_of_string ("0x" ^ String.sub s (i+2) l) in assert (u <= 0x10FFFF); (u, l+2) with _ -> raise Exit in let ub = UTF8.Buf.create 0 in UTF8.Buf.add_char ub (UChar.uchar_of_int u); Buffer.add_string b (UTF8.Buf.contents ub); inext := !inext + a; | _ -> raise Exit); loop false !inext; end else match c with | '\\' -> loop true (i + 1) | c -> Buffer.add_char b c; loop false (i + 1) in loop false 0; Buffer.contents b let map_expr loop (e,p) = let opt f o = match o with None -> None | Some v -> Some (f v) in let rec tparam = function | TPType t -> TPType (ctype t) | TPExpr e -> TPExpr (loop e) and cfield f = { f with cff_kind = (match f.cff_kind with | FVar (t,e) -> FVar (opt ctype t, opt loop e) | FFun f -> FFun (func f) | FProp (get,set,t,e) -> FProp (get,set,opt ctype t,opt loop e)) } and ctype = function | CTPath t -> CTPath (tpath t) | CTFunction (cl,c) -> CTFunction (List.map ctype cl, ctype c) | CTAnonymous fl -> CTAnonymous (List.map cfield fl) | CTParent t -> CTParent (ctype t) | CTExtend (tl,fl) -> CTExtend (List.map tpath tl, List.map cfield fl) | CTOptional t -> CTOptional (ctype t) and tparamdecl t = { tp_name = t.tp_name; tp_constraints = List.map ctype t.tp_constraints; tp_params = List.map tparamdecl t.tp_params } and func f = { f_params = List.map tparamdecl f.f_params; f_args = List.map (fun (n,o,t,e) -> n,o,opt ctype t,opt loop e) f.f_args; f_type = opt ctype f.f_type; f_expr = opt loop f.f_expr; } and tpath t = { t with tparams = List.map tparam t.tparams } in let e = (match e with | EConst _ -> e | EArray (e1,e2) -> EArray (loop e1, loop e2) | EBinop (op,e1,e2) -> EBinop (op,loop e1, loop e2) | EField (e,f) -> EField (loop e, f) | EParenthesis e -> EParenthesis (loop e) | EObjectDecl fl -> EObjectDecl (List.map (fun (f,e) -> f,loop e) fl) | EArrayDecl el -> EArrayDecl (List.map loop el) | ECall (e,el) -> ECall (loop e, List.map loop el) | ENew (t,el) -> ENew (tpath t,List.map loop el) | EUnop (op,f,e) -> EUnop (op,f,loop e) | EVars vl -> EVars (List.map (fun (n,t,eo) -> n,opt ctype t,opt loop eo) vl) | EFunction (n,f) -> EFunction (n,func f) | EBlock el -> EBlock (List.map loop el) | EFor (e1,e2) -> EFor (loop e1, loop e2) | EIn (e1,e2) -> EIn (loop e1, loop e2) | EIf (e,e1,e2) -> EIf (loop e, loop e1, opt loop e2) | EWhile (econd,e,f) -> EWhile (loop econd, loop e, f) | ESwitch (e,cases,def) -> ESwitch (loop e, List.map (fun (el,eg,e) -> List.map loop el, opt loop eg, opt loop e) cases, opt (opt loop) def) | ETry (e, catches) -> ETry (loop e, List.map (fun (n,t,e) -> n,ctype t,loop e) catches) | EReturn e -> EReturn (opt loop e) | EBreak -> EBreak | EContinue -> EContinue | EUntyped e -> EUntyped (loop e) | EThrow e -> EThrow (loop e) | ECast (e,t) -> ECast (loop e,opt ctype t) | EDisplay (e,f) -> EDisplay (loop e,f) | EDisplayNew t -> EDisplayNew (tpath t) | ETernary (e1,e2,e3) -> ETernary (loop e1,loop e2,loop e3) | ECheckType (e,t) -> ECheckType (loop e, ctype t) | EMeta (m,e) -> EMeta(m, loop e) ) in (e,p) let rec s_expr (e,_) = match e with | EConst c -> s_constant c | EParenthesis e -> "(" ^ (s_expr e) ^ ")" | EArrayDecl el -> "[" ^ (String.concat "," (List.map s_expr el)) ^ "]" | EObjectDecl fl -> "{" ^ (String.concat "," (List.map (fun (n,e) -> n ^ ":" ^ (s_expr e)) fl)) ^ "}" | EBinop (op,e1,e2) -> s_expr e1 ^ s_binop op ^ s_expr e2 | ECall (e,el) -> s_expr e ^ "(" ^ (String.concat ", " (List.map s_expr el)) ^ ")" | EField (e,f) -> s_expr e ^ "." ^ f | _ -> "'???'" let get_value_meta meta = try begin match Meta.get Meta.Value meta with | (_,[EObjectDecl values,_],_) -> List.fold_left (fun acc (s,e) -> PMap.add s e acc) PMap.empty values | _ -> raise Not_found end with Not_found -> PMap.empty let rec string_list_of_expr_path_raise (e,p) = match e with | EConst (Ident i) -> [i] | EField (e,f) -> f :: string_list_of_expr_path_raise e | _ -> raise Exit haxe_3.2.1+dfsg.orig/codegen.ml0000664000175000017500000020226212607337712016266 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open Common open Typecore (* -------------------------------------------------------------------------- *) (* TOOLS *) let field e name t p = mk (TField (e,try quick_field e.etype name with Not_found -> assert false)) t p let fcall e name el ret p = let ft = tfun (List.map (fun e -> e.etype) el) ret in mk (TCall (field e name ft p,el)) ret p let mk_parent e = mk (TParenthesis e) e.etype e.epos let string com str p = mk (TConst (TString str)) com.basic.tstring p let binop op a b t p = mk (TBinop (op,a,b)) t p let index com e index t p = mk (TArray (e,mk (TConst (TInt (Int32.of_int index))) com.basic.tint p)) t p let maybe_cast e t = try type_eq EqDoNotFollowNull e.etype t; e with Unify_error _ -> mk (TCast(e,None)) t e.epos let type_constant com c p = let t = com.basic in match c with | Int s -> if String.length s > 10 && String.sub s 0 2 = "0x" then error "Invalid hexadecimal integer" p; (try mk (TConst (TInt (Int32.of_string s))) t.tint p with _ -> mk (TConst (TFloat s)) t.tfloat p) | Float f -> mk (TConst (TFloat f)) t.tfloat p | String s -> mk (TConst (TString s)) t.tstring p | Ident "true" -> mk (TConst (TBool true)) t.tbool p | Ident "false" -> mk (TConst (TBool false)) t.tbool p | Ident "null" -> mk (TConst TNull) (t.tnull (mk_mono())) p | Ident t -> error ("Invalid constant : " ^ t) p | Regexp _ -> error "Invalid constant" p let rec type_constant_value com (e,p) = match e with | EConst c -> type_constant com c p | EParenthesis e -> type_constant_value com e | EObjectDecl el -> mk (TObjectDecl (List.map (fun (n,e) -> n, type_constant_value com e) el)) (TAnon { a_fields = PMap.empty; a_status = ref Closed }) p | EArrayDecl el -> mk (TArrayDecl (List.map (type_constant_value com) el)) (com.basic.tarray t_dynamic) p | _ -> error "Constant value expected" p let rec has_properties c = List.exists (fun f -> match f.cf_kind with | Var { v_read = AccCall } -> true | Var { v_write = AccCall } -> true | _ when Meta.has Meta.Accessor f.cf_meta -> true | _ -> false ) c.cl_ordered_fields || (match c.cl_super with Some (c,_) -> has_properties c | _ -> false) let get_properties fields = List.fold_left (fun acc f -> if Meta.has Meta.Accessor f.cf_meta then (f.cf_name, f.cf_name) :: acc else let acc = (match f.cf_kind with | Var { v_read = AccCall } -> ("get_" ^ f.cf_name , "get_" ^ f.cf_name) :: acc | _ -> acc) in match f.cf_kind with | Var { v_write = AccCall } -> ("set_" ^ f.cf_name , "set_" ^ f.cf_name) :: acc | _ -> acc ) [] fields let add_property_field com c = let p = c.cl_pos in let props = get_properties (c.cl_ordered_statics @ c.cl_ordered_fields) in match props with | [] -> () | _ -> let fields,values = List.fold_left (fun (fields,values) (n,v) -> let cf = mk_field n com.basic.tstring p in PMap.add n cf fields,(n, string com v p) :: values ) (PMap.empty,[]) props in let t = mk_anon fields in let e = mk (TObjectDecl values) t p in let cf = mk_field "__properties__" t p in cf.cf_expr <- Some e; c.cl_statics <- PMap.add cf.cf_name cf c.cl_statics; c.cl_ordered_statics <- cf :: c.cl_ordered_statics let is_removable_field ctx f = Meta.has Meta.Extern f.cf_meta || Meta.has Meta.Generic f.cf_meta || (match f.cf_kind with | Var {v_read = AccRequire (s,_)} -> true | Method MethMacro -> not ctx.in_macro | _ -> false) let escape_res_name name allow_dirs = ExtString.String.replace_chars (fun chr -> if (chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || (chr >= '0' && chr <= '9') || chr = '_' || chr = '.' then Char.escaped chr else if chr = '/' && allow_dirs then "/" else "-x" ^ (string_of_int (Char.code chr))) name (* -------------------------------------------------------------------------- *) (* REMOTING PROXYS *) let extend_remoting ctx c t p async prot = if c.cl_super <> None then error "Cannot extend several classes" p; (* remove forbidden packages *) let rules = ctx.com.package_rules in ctx.com.package_rules <- PMap.foldi (fun key r acc -> match r with Forbidden -> acc | _ -> PMap.add key r acc) rules PMap.empty; (* parse module *) let path = (t.tpackage,t.tname) in let new_name = (if async then "Async_" else "Remoting_") ^ t.tname in (* check if the proxy already exists *) let t = (try Typeload.load_type_def ctx p { tpackage = fst path; tname = new_name; tparams = []; tsub = None } with Error (Module_not_found _,p2) when p == p2 -> (* build it *) Common.log ctx.com ("Building proxy for " ^ s_type_path path); let file, decls = (try Typeload.parse_module ctx path p with | Not_found -> ctx.com.package_rules <- rules; error ("Could not load proxy module " ^ s_type_path path ^ (if fst path = [] then " (try using absolute path)" else "")) p | e -> ctx.com.package_rules <- rules; raise e) in ctx.com.package_rules <- rules; let base_fields = [ { cff_name = "__cnx"; cff_pos = p; cff_doc = None; cff_meta = []; cff_access = []; cff_kind = FVar (Some (CTPath { tpackage = ["haxe";"remoting"]; tname = if async then "AsyncConnection" else "Connection"; tparams = []; tsub = None }),None) }; { cff_name = "new"; cff_pos = p; cff_doc = None; cff_meta = []; cff_access = [APublic]; cff_kind = FFun { f_args = ["c",false,None,None]; f_type = None; f_expr = Some (EBinop (OpAssign,(EConst (Ident "__cnx"),p),(EConst (Ident "c"),p)),p); f_params = [] } }; ] in let tvoid = CTPath { tpackage = []; tname = "Void"; tparams = []; tsub = None } in let build_field is_public acc f = if f.cff_name = "new" then acc else match f.cff_kind with | FFun fd when (is_public || List.mem APublic f.cff_access) && not (List.mem AStatic f.cff_access) -> if List.exists (fun (_,_,t,_) -> t = None) fd.f_args then error ("Field " ^ f.cff_name ^ " type is not complete and cannot be used by RemotingProxy") p; let eargs = [EArrayDecl (List.map (fun (a,_,_,_) -> (EConst (Ident a),p)) fd.f_args),p] in let ftype = (match fd.f_type with Some (CTPath { tpackage = []; tname = "Void" }) -> None | _ -> fd.f_type) in let fargs, eargs = if async then match ftype with | Some tret -> fd.f_args @ ["__callb",true,Some (CTFunction ([tret],tvoid)),None], eargs @ [EConst (Ident "__callb"),p] | _ -> fd.f_args, eargs @ [EConst (Ident "null"),p] else fd.f_args, eargs in let id = (EConst (String f.cff_name), p) in let id = if prot then id else ECall ((EConst (Ident "__unprotect__"),p),[id]),p in let expr = ECall ( (EField ( (ECall ((EField ((EConst (Ident "__cnx"),p),"resolve"),p),[id]),p), "call") ,p),eargs),p in let expr = if async || ftype = None then expr else (EReturn (Some expr),p) in let fd = { f_params = fd.f_params; f_args = fargs; f_type = if async then None else ftype; f_expr = Some (EBlock [expr],p); } in { cff_name = f.cff_name; cff_pos = p; cff_doc = None; cff_meta = []; cff_access = [APublic]; cff_kind = FFun fd } :: acc | _ -> acc in let decls = List.map (fun d -> match d with | EClass c, p when c.d_name = t.tname -> let is_public = List.mem HExtern c.d_flags || List.mem HInterface c.d_flags in let fields = List.rev (List.fold_left (build_field is_public) base_fields c.d_data) in (EClass { c with d_flags = []; d_name = new_name; d_data = fields },p) | _ -> d ) decls in let m = Typeload.type_module ctx (t.tpackage,new_name) file decls p in add_dependency ctx.m.curmod m; try List.find (fun tdecl -> snd (t_path tdecl) = new_name) m.m_types with Not_found -> error ("Module " ^ s_type_path path ^ " does not define type " ^ t.tname) p ) in match t with | TClassDecl c2 when c2.cl_params = [] -> ignore(c2.cl_build()); c.cl_super <- Some (c2,[]); | _ -> error "Remoting proxy must be a class without parameters" p (* -------------------------------------------------------------------------- *) (* HAXE.RTTI.GENERIC *) exception Generic_Exception of string * Ast.pos type generic_context = { ctx : typer; subst : (t * t) list; name : string; p : pos; mutable mg : module_def option; } let make_generic ctx ps pt p = let rec loop l1 l2 = match l1, l2 with | [] , [] -> [] | (x,TLazy f) :: l1, _ -> loop ((x,(!f)()) :: l1) l2 | (_,t1) :: l1 , t2 :: l2 -> (t1,t2) :: loop l1 l2 | _ -> assert false in let name = String.concat "_" (List.map2 (fun (s,_) t -> let s_type_path_underscore (p,s) = match p with [] -> s | _ -> String.concat "_" p ^ "_" ^ s in let rec loop top t = match follow t with | TInst(c,tl) -> (s_type_path_underscore c.cl_path) ^ (loop_tl tl) | TEnum(en,tl) -> (s_type_path_underscore en.e_path) ^ (loop_tl tl) | TAbstract(a,tl) -> (s_type_path_underscore a.a_path) ^ (loop_tl tl) | _ when not top -> "_" (* allow unknown/incompatible types as type parameters to retain old behavior *) | TMono _ -> raise (Generic_Exception (("Could not determine type for parameter " ^ s), p)) | t -> raise (Generic_Exception (("Type parameter must be a class or enum instance (found " ^ (s_type (print_context()) t) ^ ")"), p)) and loop_tl tl = match tl with | [] -> "" | tl -> "_" ^ String.concat "_" (List.map (loop false) tl) in loop true t ) ps pt) in { ctx = ctx; subst = loop ps pt; name = name; p = p; mg = None; } let rec generic_substitute_type gctx t = match t with | TInst ({ cl_kind = KGeneric } as c2,tl2) -> (* maybe loop, or generate cascading generics *) let _, _, f = gctx.ctx.g.do_build_instance gctx.ctx (TClassDecl c2) gctx.p in let t = f (List.map (generic_substitute_type gctx) tl2) in (match follow t,gctx.mg with TInst(c,_), Some m -> add_dependency m c.cl_module | _ -> ()); t | _ -> try generic_substitute_type gctx (List.assq t gctx.subst) with Not_found -> Type.map (generic_substitute_type gctx) t let generic_substitute_expr gctx e = let vars = Hashtbl.create 0 in let build_var v = try Hashtbl.find vars v.v_id with Not_found -> let v2 = alloc_var v.v_name (generic_substitute_type gctx v.v_type) in v2.v_meta <- v.v_meta; Hashtbl.add vars v.v_id v2; v2 in let rec build_expr e = match e.eexpr with | TField(e1, FInstance({cl_kind = KGeneric} as c,tl,cf)) -> let _, _, f = gctx.ctx.g.do_build_instance gctx.ctx (TClassDecl c) gctx.p in let t = f (List.map (generic_substitute_type gctx) tl) in build_expr {e with eexpr = TField(e1,quick_field t cf.cf_name)} | _ -> map_expr_type build_expr (generic_substitute_type gctx) build_var e in build_expr e let has_ctor_constraint c = match c.cl_kind with | KTypeParameter tl -> List.exists (fun t -> match follow t with | TAnon a when PMap.mem "new" a.a_fields -> true | _ -> false ) tl; | _ -> false let get_short_name = let i = ref (-1) in (fun () -> incr i; Printf.sprintf "Hx___short___hx_type_%i" !i ) let rec build_generic ctx c p tl = let pack = fst c.cl_path in let recurse = ref false in let rec check_recursive t = match follow t with | TInst (c2,tl) -> (match c2.cl_kind with | KTypeParameter tl -> if not (Typeload.is_generic_parameter ctx c2) && has_ctor_constraint c2 then error "Type parameters with a constructor cannot be used non-generically" p; recurse := true | _ -> ()); List.iter check_recursive tl; | _ -> () in List.iter check_recursive tl; if !recurse then begin TInst (c,tl) (* build a normal instance *) end else begin let gctx = make_generic ctx c.cl_params tl p in let name = (snd c.cl_path) ^ "_" ^ gctx.name in try Typeload.load_instance ctx { tpackage = pack; tname = name; tparams = []; tsub = None } p false with Error(Module_not_found path,_) when path = (pack,name) -> let m = (try Hashtbl.find ctx.g.modules (Hashtbl.find ctx.g.types_module c.cl_path) with Not_found -> assert false) in let ctx = { ctx with m = { ctx.m with module_types = m.m_types @ ctx.m.module_types } } in ignore(c.cl_build()); (* make sure the super class is already setup *) let mg = { m_id = alloc_mid(); m_path = (pack,name); m_types = []; m_extra = module_extra (s_type_path (pack,name)) m.m_extra.m_sign 0. MFake; } in gctx.mg <- Some mg; let cg = mk_class mg (pack,name) c.cl_pos in mg.m_types <- [TClassDecl cg]; Hashtbl.add ctx.g.modules mg.m_path mg; add_dependency mg m; add_dependency ctx.m.curmod mg; (* ensure that type parameters are set in dependencies *) let dep_stack = ref [] in let rec loop t = if not (List.memq t !dep_stack) then begin dep_stack := t :: !dep_stack; match t with | TInst (c,tl) -> add_dep c.cl_module tl | TEnum (e,tl) -> add_dep e.e_module tl | TType (t,tl) -> add_dep t.t_module tl | TAbstract (a,tl) -> add_dep a.a_module tl | TMono r -> (match !r with | None -> () | Some t -> loop t) | TLazy f -> loop ((!f)()); | TDynamic t2 -> if t == t2 then () else loop t2 | TAnon a -> PMap.iter (fun _ f -> loop f.cf_type) a.a_fields | TFun (args,ret) -> List.iter (fun (_,_,t) -> loop t) args; loop ret end and add_dep m tl = add_dependency mg m; List.iter loop tl in List.iter loop tl; let build_field cf_old = let cf_new = {cf_old with cf_pos = cf_old.cf_pos} in (* copy *) let f () = let t = generic_substitute_type gctx cf_old.cf_type in ignore (follow t); begin try (match cf_old.cf_expr with | None -> begin match cf_old.cf_kind with | Method _ when not c.cl_interface && not c.cl_extern -> display_error ctx (Printf.sprintf "Field %s has no expression (possible typing order issue)" cf_new.cf_name) cf_new.cf_pos; display_error ctx (Printf.sprintf "While building %s" (s_type_path cg.cl_path)) p; | _ -> () end | Some e -> cf_new.cf_expr <- Some (generic_substitute_expr gctx e) ) with Unify_error l -> error (error_msg (Unify l)) cf_new.cf_pos end; t in let r = exc_protect ctx (fun r -> let t = mk_mono() in r := (fun() -> t); unify_raise ctx (f()) t p; t ) "build_generic" in delay ctx PForce (fun() -> ignore ((!r)())); cf_new.cf_type <- TLazy r; cf_new in if c.cl_init <> None || c.cl_dynamic <> None then error "This class can't be generic" p; List.iter (fun cf -> match cf.cf_kind with | Method MethMacro when not ctx.in_macro -> () | _ -> error "A generic class can't have static fields" cf.cf_pos ) c.cl_ordered_statics; cg.cl_super <- (match c.cl_super with | None -> None | Some (cs,pl) -> let find_class subst = let rec loop subst = match subst with | (TInst(c,[]),t) :: subst when c == cs -> t | _ :: subst -> loop subst | [] -> raise Not_found in try if pl <> [] then raise Not_found; let t = loop subst in (* extended type parameter: concrete type must have a constructor, but generic base class must not have one *) begin match follow t,c.cl_constructor with | TInst(cs,_),None -> ignore(cs.cl_build()); begin match cs.cl_constructor with | None -> error ("Cannot use " ^ (s_type_path cs.cl_path) ^ " as type parameter because it is extended and has no constructor") p | _ -> () end; | _,Some cf -> error "Generics extending type parameters cannot have constructors" cf.cf_pos | _ -> () end; t with Not_found -> apply_params c.cl_params tl (TInst(cs,pl)) in let ts = follow (find_class gctx.subst) in let cs,pl = Typeload.check_extends ctx c ts p in match cs.cl_kind with | KGeneric -> (match build_generic ctx cs p pl with | TInst (cs,pl) -> Some (cs,pl) | _ -> assert false) | _ -> Some(cs,pl) ); Typeload.add_constructor ctx cg false p; cg.cl_kind <- KGenericInstance (c,tl); cg.cl_meta <- (Meta.NoDoc,[],p) :: cg.cl_meta; cg.cl_interface <- c.cl_interface; cg.cl_constructor <- (match cg.cl_constructor, c.cl_constructor, c.cl_super with | _, Some cf, _ -> Some (build_field cf) | Some ctor, _, _ -> Some ctor | None, None, None -> None | _ -> error "Please define a constructor for this class in order to use it as generic" c.cl_pos ); cg.cl_implements <- List.map (fun (i,tl) -> (match follow (generic_substitute_type gctx (TInst (i, List.map (generic_substitute_type gctx) tl))) with | TInst (i,tl) -> i, tl | _ -> assert false) ) c.cl_implements; cg.cl_ordered_fields <- List.map (fun f -> let f = build_field f in cg.cl_fields <- PMap.add f.cf_name f cg.cl_fields; f ) c.cl_ordered_fields; (* In rare cases the class name can become too long, so let's shorten it (issue #3090). *) if String.length (snd cg.cl_path) > 254 then begin let n = get_short_name () in cg.cl_meta <- (Meta.Native,[EConst(String (n)),p],p) :: cg.cl_meta; end; TInst (cg,[]) end (* -------------------------------------------------------------------------- *) (* HAXE.XML.PROXY *) let extend_xml_proxy ctx c t file p = let t = Typeload.load_complex_type ctx p t in let file = (try Common.find_file ctx.com file with Not_found -> file) in add_dependency c.cl_module (create_fake_module ctx file); let used = ref PMap.empty in let print_results() = PMap.iter (fun id used -> if not used then ctx.com.warning (id ^ " is not used") p; ) (!used) in let check_used = Common.defined ctx.com Define.CheckXmlProxy in if check_used then ctx.g.hook_generate <- print_results :: ctx.g.hook_generate; try let rec loop = function | Xml.Element (_,attrs,childs) -> (try let id = List.assoc "id" attrs in if PMap.mem id c.cl_fields then error ("Duplicate id " ^ id) p; let t = if not check_used then t else begin used := PMap.add id false (!used); let ft() = used := PMap.add id true (!used); t in TLazy (ref ft) end in let f = { cf_name = id; cf_type = t; cf_public = true; cf_pos = p; cf_doc = None; cf_meta = no_meta; cf_kind = Var { v_read = AccResolve; v_write = AccNo }; cf_params = []; cf_expr = None; cf_overloads = []; } in c.cl_fields <- PMap.add id f c.cl_fields; with Not_found -> ()); List.iter loop childs; | Xml.PCData _ -> () in loop (Xml.parse_file file) with | Xml.Error e -> error ("XML error " ^ Xml.error e) p | Xml.File_not_found f -> error ("XML File not found : " ^ f) p (* -------------------------------------------------------------------------- *) (* BUILD META DATA OBJECT *) let build_metadata com t = let api = com.basic in let p, meta, fields, statics = (match t with | TClassDecl c -> let fields = List.map (fun f -> f.cf_name,f.cf_meta) (c.cl_ordered_fields @ (match c.cl_constructor with None -> [] | Some f -> [{ f with cf_name = "_" }])) in let statics = List.map (fun f -> f.cf_name,f.cf_meta) c.cl_ordered_statics in (c.cl_pos, ["",c.cl_meta],fields,statics) | TEnumDecl e -> (e.e_pos, ["",e.e_meta],List.map (fun n -> n, (PMap.find n e.e_constrs).ef_meta) e.e_names, []) | TTypeDecl t -> (t.t_pos, ["",t.t_meta],(match follow t.t_type with TAnon a -> PMap.fold (fun f acc -> (f.cf_name,f.cf_meta) :: acc) a.a_fields [] | _ -> []),[]) | TAbstractDecl a -> (a.a_pos, ["",a.a_meta],[],[]) ) in let filter l = let l = List.map (fun (n,ml) -> n, ExtList.List.filter_map (fun (m,el,p) -> match m with Meta.Custom s when String.length s > 0 && s.[0] <> ':' -> Some (s,el,p) | _ -> None) ml) l in List.filter (fun (_,ml) -> ml <> []) l in let meta, fields, statics = filter meta, filter fields, filter statics in let make_meta_field ml = let h = Hashtbl.create 0 in mk (TObjectDecl (List.map (fun (f,el,p) -> if Hashtbl.mem h f then error ("Duplicate metadata '" ^ f ^ "'") p; Hashtbl.add h f (); f, mk (match el with [] -> TConst TNull | _ -> TArrayDecl (List.map (type_constant_value com) el)) (api.tarray t_dynamic) p ) ml)) t_dynamic p in let make_meta l = mk (TObjectDecl (List.map (fun (f,ml) -> f,make_meta_field ml) l)) t_dynamic p in if meta = [] && fields = [] && statics = [] then None else let meta_obj = [] in let meta_obj = (if fields = [] then meta_obj else ("fields",make_meta fields) :: meta_obj) in let meta_obj = (if statics = [] then meta_obj else ("statics",make_meta statics) :: meta_obj) in let meta_obj = (try ("obj", make_meta_field (List.assoc "" meta)) :: meta_obj with Not_found -> meta_obj) in Some (mk (TObjectDecl meta_obj) t_dynamic p) (* -------------------------------------------------------------------------- *) (* MACRO TYPE *) let get_macro_path ctx e args p = let rec loop e = match fst e with | EField (e,f) -> f :: loop e | EConst (Ident i) -> [i] | _ -> error "Invalid macro call" p in let path = match e with | (EConst(Ident i)),_ -> let path = try if not (PMap.mem i ctx.curclass.cl_statics) then raise Not_found; ctx.curclass.cl_path with Not_found -> try (t_infos (fst (PMap.find i ctx.m.module_globals))).mt_path with Not_found -> error "Invalid macro call" p in i :: (snd path) :: (fst path) | _ -> loop e in (match path with | meth :: cl :: path -> (List.rev path,cl), meth, args | _ -> error "Invalid macro call" p) let build_macro_type ctx pl p = let path, field, args = (match pl with | [TInst ({ cl_kind = KExpr (ECall (e,args),_) },_)] | [TInst ({ cl_kind = KExpr (EArrayDecl [ECall (e,args),_],_) },_)] -> get_macro_path ctx e args p | _ -> error "MacroType requires a single expression call parameter" p ) in let old = ctx.ret in let t = (match ctx.g.do_macro ctx MMacroType path field args p with | None -> mk_mono() | Some _ -> ctx.ret ) in ctx.ret <- old; t let build_macro_build ctx c pl cfl p = let path, field, args = match Meta.get Meta.GenericBuild c.cl_meta with | _,[ECall(e,args),_],_ -> get_macro_path ctx e args p | _ -> error "genericBuild requires a single expression call parameter" p in let old = ctx.ret,ctx.g.get_build_infos in ctx.g.get_build_infos <- (fun() -> Some (TClassDecl c, pl, cfl)); let t = (match ctx.g.do_macro ctx MMacroType path field args p with | None -> mk_mono() | Some _ -> ctx.ret ) in ctx.ret <- fst old; ctx.g.get_build_infos <- snd old; t (* -------------------------------------------------------------------------- *) (* API EVENTS *) let build_instance ctx mtype p = match mtype with | TClassDecl c -> if ctx.pass > PBuildClass then ignore(c.cl_build()); let build f s = let r = exc_protect ctx (fun r -> let t = mk_mono() in r := (fun() -> t); unify_raise ctx (f()) t p; t ) s in delay ctx PForce (fun() -> ignore ((!r)())); TLazy r in let ft = (fun pl -> match c.cl_kind with | KGeneric -> build (fun () -> build_generic ctx c p pl) "build_generic" | KMacroType -> build (fun () -> build_macro_type ctx pl p) "macro_type" | KGenericBuild cfl -> build (fun () -> build_macro_build ctx c pl cfl p) "generic_build" | _ -> TInst (c,pl) ) in c.cl_params , c.cl_path , ft | TEnumDecl e -> e.e_params , e.e_path , (fun t -> TEnum (e,t)) | TTypeDecl t -> t.t_params , t.t_path , (fun tl -> TType(t,tl)) | TAbstractDecl a -> a.a_params, a.a_path, (fun tl -> TAbstract(a,tl)) let on_inherit ctx c p h = match h with | HExtends { tpackage = ["haxe";"remoting"]; tname = "Proxy"; tparams = [TPType(CTPath t)] } -> extend_remoting ctx c t p false true; false | HExtends { tpackage = ["haxe";"remoting"]; tname = "AsyncProxy"; tparams = [TPType(CTPath t)] } -> extend_remoting ctx c t p true true; false | HExtends { tpackage = ["haxe";"xml"]; tname = "Proxy"; tparams = [TPExpr(EConst (String file),p);TPType t] } -> extend_xml_proxy ctx c t file p; true | _ -> true (* -------------------------------------------------------------------------- *) (* ABSTRACT CASTS *) module AbstractCast = struct let cast_stack = ref [] let make_static_call ctx c cf a pl args t p = make_static_call ctx c cf (apply_params a.a_params pl) args t p let do_check_cast ctx tleft eright p = let recurse cf f = if cf == ctx.curfield || List.mem cf !cast_stack then error "Recursive implicit cast" p; cast_stack := cf :: !cast_stack; let r = f() in cast_stack := List.tl !cast_stack; r in let find a tl f = let tcf,cf = f() in if (Meta.has Meta.MultiType a.a_meta) then mk_cast eright tleft p else match a.a_impl with | Some c -> recurse cf (fun () -> let ret = make_static_call ctx c cf a tl [eright] tleft p in { ret with eexpr = TMeta( (Meta.ImplicitCast,[],ret.epos), ret) } ) | None -> assert false in if type_iseq tleft eright.etype then eright else begin let rec loop tleft tright = match follow tleft,follow tright with | TAbstract(a1,tl1),TAbstract(a2,tl2) -> begin try find a2 tl2 (fun () -> Abstract.find_to a2 tl2 tleft) with Not_found -> try find a1 tl1 (fun () -> Abstract.find_from a1 tl1 eright.etype tleft) with Not_found -> raise Not_found end | TAbstract(a,tl),_ -> begin try find a tl (fun () -> Abstract.find_from a tl eright.etype tleft) with Not_found -> let rec loop2 tcl = match tcl with | tc :: tcl -> if not (type_iseq tc tleft) then loop (apply_params a.a_params tl tc) tright else loop2 tcl | [] -> raise Not_found in loop2 a.a_from end | _,TAbstract(a,tl) -> begin try find a tl (fun () -> Abstract.find_to a tl tleft) with Not_found -> let rec loop2 tcl = match tcl with | tc :: tcl -> if not (type_iseq tc tright) then loop tleft (apply_params a.a_params tl tc) else loop2 tcl | [] -> raise Not_found in loop2 a.a_to end | _ -> raise Not_found in loop tleft eright.etype end let cast_or_unify_raise ctx tleft eright p = try if ctx.com.display <> DMNone then raise Not_found; do_check_cast ctx tleft eright p with Not_found -> unify_raise ctx eright.etype tleft p; eright let cast_or_unify ctx tleft eright p = try cast_or_unify_raise ctx tleft eright p with Error (Unify _ as err,_) -> if not ctx.untyped then display_error ctx (error_msg err) p; eright let find_array_access_raise ctx a pl e1 e2o p = let is_set = e2o <> None in let ta = apply_params a.a_params pl a.a_this in let rec loop cfl = match cfl with | [] -> raise Not_found | cf :: cfl when not (Ast.Meta.has Ast.Meta.ArrayAccess cf.cf_meta) -> loop cfl | cf :: cfl -> let monos = List.map (fun _ -> mk_mono()) cf.cf_params in let map t = apply_params a.a_params pl (apply_params cf.cf_params monos t) in let check_constraints () = List.iter2 (fun m (name,t) -> match follow t with | TInst ({ cl_kind = KTypeParameter constr },_) when constr <> [] -> List.iter (fun tc -> match follow m with TMono _ -> raise (Unify_error []) | _ -> Type.unify m (map tc) ) constr | _ -> () ) monos cf.cf_params; in match follow (map cf.cf_type) with | TFun([(_,_,tab);(_,_,ta1);(_,_,ta2)],r) as tf when is_set -> begin try Type.unify tab ta; let e1 = cast_or_unify_raise ctx ta1 e1 p in let e2o = match e2o with None -> None | Some e2 -> Some (cast_or_unify_raise ctx ta2 e2 p) in check_constraints(); cf,tf,r,e1,e2o with Unify_error _ | Error (Unify _,_) -> loop cfl end | TFun([(_,_,tab);(_,_,ta1)],r) as tf when not is_set -> begin try Type.unify tab ta; let e1 = cast_or_unify_raise ctx ta1 e1 p in check_constraints(); cf,tf,r,e1,None with Unify_error _ | Error (Unify _,_) -> loop cfl end | _ -> loop cfl in loop a.a_array let find_array_access ctx a tl e1 e2o p = try find_array_access_raise ctx a tl e1 e2o p with Not_found -> match e2o with | None -> error (Printf.sprintf "No @:arrayAccess function accepts argument of %s" (s_type (print_context()) e1.etype)) p | Some e2 -> error (Printf.sprintf "No @:arrayAccess function accepts arguments of %s and %s" (s_type (print_context()) e1.etype) (s_type (print_context()) e2.etype)) p let find_multitype_specialization com a pl p = let m = mk_mono() in let tl = match Meta.get Meta.MultiType a.a_meta with | _,[],_ -> pl | _,el,_ -> let relevant = Hashtbl.create 0 in List.iter (fun e -> match fst e with | EConst(Ident s) -> Hashtbl.replace relevant s true | _ -> error "Type parameter expected" (pos e) ) el; let tl = List.map2 (fun (n,_) t -> if Hashtbl.mem relevant n || not (has_mono t) then t else t_dynamic) a.a_params pl in if com.platform = Js && a.a_path = ([],"Map") then begin match tl with | t1 :: _ -> let rec loop stack t = if List.exists (fun t2 -> fast_eq t t2) stack then t else begin let stack = t :: stack in match follow t with | TAbstract ({ a_path = [],"Class" },_) -> error (Printf.sprintf "Cannot use %s as key type to Map because Class is not comparable" (s_type (print_context()) t1)) p; | TEnum(en,tl) -> PMap.iter (fun _ ef -> ignore(loop stack ef.ef_type)) en.e_constrs; Type.map (loop stack) t | t -> Type.map (loop stack) t end in ignore(loop [] t1) | _ -> assert false end; tl in let _,cf = try Abstract.find_to a tl m with Not_found -> let at = apply_params a.a_params pl a.a_this in let st = s_type (print_context()) at in if has_mono at then error ("Type parameters of multi type abstracts must be known (for " ^ st ^ ")") p else error ("Abstract " ^ (s_type_path a.a_path) ^ " has no @:to function that accepts " ^ st) p; in cf, follow m let handle_abstract_casts ctx e = let rec loop ctx e = match e.eexpr with | TNew({cl_kind = KAbstractImpl a} as c,pl,el) -> (* a TNew of an abstract implementation is only generated if it is a multi type abstract *) let cf,m = find_multitype_specialization ctx.com a pl e.epos in let e = make_static_call ctx c cf a pl ((mk (TConst TNull) (TAbstract(a,pl)) e.epos) :: el) m e.epos in {e with etype = m} | TCall({eexpr = TField(_,FStatic({cl_path=[],"Std"},{cf_name = "string"}))},[e1]) when (match follow e1.etype with TAbstract({a_impl = Some _},_) -> true | _ -> false) -> begin match follow e1.etype with | TAbstract({a_impl = Some c} as a,tl) -> begin try let cf = PMap.find "toString" c.cl_statics in make_static_call ctx c cf a tl [e1] ctx.t.tstring e.epos with Not_found -> e end | _ -> assert false end | TCall(e1, el) -> begin try let rec find_abstract e = match follow e.etype,e.eexpr with | TAbstract(a,pl),_ when Meta.has Meta.MultiType a.a_meta -> a,pl,e | _,TCast(e1,None) -> find_abstract e1 | _ -> raise Not_found in let rec find_field e1 = match e1.eexpr with | TCast(e2,None) -> {e1 with eexpr = TCast(find_field e2,None)} | TField(e2,fa) -> let a,pl,e2 = find_abstract e2 in let m = Abstract.get_underlying_type a pl in let fname = field_name fa in let el = List.map (loop ctx) el in begin try let fa = quick_field m fname in let get_fun_type t = match follow t with | TFun(_,tr) as tf -> tf,tr | _ -> raise Not_found in let tf,tr = match fa with | FStatic(_,cf) -> get_fun_type cf.cf_type | FInstance(c,tl,cf) -> get_fun_type (apply_params c.cl_params tl cf.cf_type) | FAnon cf -> get_fun_type cf.cf_type | _ -> raise Not_found in let ef = mk (TField({e2 with etype = m},fa)) tf e2.epos in let ecall = make_call ctx ef el tr e.epos in if not (type_iseq ecall.etype e.etype) then mk (TCast(ecall,None)) e.etype e.epos else ecall with Not_found -> (* quick_field raises Not_found if m is an abstract, we have to replicate the 'using' call here *) match follow m with | TAbstract({a_impl = Some c} as a,pl) -> let cf = PMap.find fname c.cl_statics in make_static_call ctx c cf a pl (e2 :: el) e.etype e.epos | _ -> raise Not_found end | _ -> raise Not_found in find_field e1 with Not_found -> Type.map_expr (loop ctx) e end | _ -> Type.map_expr (loop ctx) e in loop ctx e end module PatternMatchConversion = struct type cctx = { ctx : typer; mutable eval_stack : ((tvar * pos) * texpr) list list; dt_lookup : dt array; } let is_declared cctx v = let rec loop sl = match sl with | stack :: sl -> List.exists (fun ((v2,_),_) -> v == v2) stack || loop sl | [] -> false in loop cctx.eval_stack let group_cases cases = let dt_eq dt1 dt2 = match dt1,dt2 with | DTGoto i1, DTGoto i2 when i1 = i2 -> true (* TODO equal bindings *) | _ -> false in match List.rev cases with | [] -> [] | [con,dt] -> [[con],dt] | (con,dt) :: cases -> let tmp,ldt,cases = List.fold_left (fun (tmp,ldt,acc) (con,dt) -> if dt_eq dt ldt then (con :: tmp,dt,acc) else ([con],dt,(tmp,ldt) :: acc) ) ([con],dt,[]) cases in match tmp with | [] -> cases | tmp -> ((tmp,ldt) :: cases) let replace_locals e = let v_known = ref IntMap.empty in let copy v = let v' = alloc_var v.v_name v.v_type in v_known := IntMap.add v.v_id v' !v_known; v' in let rec loop e = match e.eexpr with | TVar(v,e1) -> let v' = copy v in let e1 = match e1 with None -> None | Some e -> Some (loop e) in {e with eexpr = TVar(v',e1)} | TFor(v,e1,e2) -> let v' = copy v in let e1 = loop e1 in let e2 = loop e2 in {e with eexpr = TFor(v',e1,e2)} | TTry(e1,catches) -> let e1 = loop e1 in let catches = List.map (fun (v,e) -> let v' = copy v in let e = loop e in v',e ) catches in {e with eexpr = TTry(e1,catches)} | TLocal v -> let v' = try IntMap.find v.v_id !v_known with Not_found -> v in {e with eexpr = TLocal v'} | _ -> Type.map_expr loop e in loop e let rec convert_dt cctx dt = match dt with | DTBind (bl,dt) -> cctx.eval_stack <- bl :: cctx.eval_stack; let e = convert_dt cctx dt in cctx.eval_stack <- List.tl cctx.eval_stack; let vl,el = List.fold_left (fun (vl,el) ((v,p),e) -> if is_declared cctx v then vl, (mk (TBinop(OpAssign,mk (TLocal v) v.v_type p,e)) e.etype e.epos) :: el else ((v,p,Some e) :: vl), el ) ([],[e]) bl in let el_v = List.map (fun (v,p,eo) -> mk (TVar (v,eo)) cctx.ctx.t.tvoid p) vl in mk (TBlock (el_v @ el)) e.etype e.epos | DTGoto i -> convert_dt cctx (cctx.dt_lookup.(i)) | DTExpr e -> e | DTGuard(e,dt1,dt2) -> let ethen = convert_dt cctx dt1 in mk (TIf(e,ethen,match dt2 with None -> None | Some dt -> Some (convert_dt cctx dt))) ethen.etype (punion e.epos ethen.epos) | DTSwitch({eexpr = TMeta((Meta.Exhaustive,_,_),_)},[_,dt],None) -> convert_dt cctx dt | DTSwitch(e_st,cl,dto) -> let def = match dto with None -> None | Some dt -> Some (convert_dt cctx dt) in let cases = group_cases cl in let cases = List.map (fun (cl,dt) -> let e = convert_dt cctx dt in (* The macro interpreter does not care about unique locals and we don't run the analyzer on the output, so let's save some time here (issue #3937) *) let e = if cctx.ctx.in_macro then e else replace_locals e in cl,e ) cases in mk (TSwitch(e_st,cases,def)) (mk_mono()) e_st.epos let to_typed_ast ctx dt p = let first = dt.dt_dt_lookup.(dt.dt_first) in let cctx = { ctx = ctx; dt_lookup = dt.dt_dt_lookup; eval_stack = []; } in let e = convert_dt cctx first in let e = { e with epos = p; etype = dt.dt_type} in if dt.dt_var_init = [] then e else begin let el_v = List.map (fun (v,eo) -> mk (TVar (v,eo)) cctx.ctx.t.tvoid p) dt.dt_var_init in mk (TBlock (el_v @ [e])) dt.dt_type e.epos end end (* -------------------------------------------------------------------------- *) (* USAGE *) let detect_usage com = let usage = ref [] in List.iter (fun t -> match t with | TClassDecl c -> let check_constructor c p = try let _,cf = get_constructor (fun cf -> cf.cf_type) c in if Meta.has Meta.Usage cf.cf_meta then usage := p :: !usage; with Not_found -> () in let rec expr e = match e.eexpr with | TField(_,FEnum(_,ef)) when Meta.has Meta.Usage ef.ef_meta -> let p = {e.epos with pmin = e.epos.pmax - (String.length ef.ef_name)} in usage := p :: !usage; Type.iter expr e | TField(_,(FAnon cf | FInstance (_,_,cf) | FStatic (_,cf) | FClosure (_,cf))) when Meta.has Meta.Usage cf.cf_meta -> let p = {e.epos with pmin = e.epos.pmax - (String.length cf.cf_name)} in usage := p :: !usage; Type.iter expr e | TLocal v when Meta.has Meta.Usage v.v_meta -> usage := e.epos :: !usage | TVar (v,_) when com.display = DMPosition && Meta.has Meta.Usage v.v_meta -> raise (Typecore.DisplayPosition [e.epos]) | TFunction tf when com.display = DMPosition && List.exists (fun (v,_) -> Meta.has Meta.Usage v.v_meta) tf.tf_args -> raise (Typecore.DisplayPosition [e.epos]) | TTypeExpr mt when (Meta.has Meta.Usage (t_infos mt).mt_meta) -> usage := e.epos :: !usage | TNew (c,_,_) -> check_constructor c e.epos; Type.iter expr e; | TCall({eexpr = TConst TSuper},_) -> begin match c.cl_super with | Some (c,_) -> check_constructor c e.epos | _ -> () end | _ -> Type.iter expr e in let field cf = ignore(follow cf.cf_type); match cf.cf_expr with None -> () | Some e -> expr e in (match c.cl_constructor with None -> () | Some cf -> field cf); (match c.cl_init with None -> () | Some e -> expr e); List.iter field c.cl_ordered_statics; List.iter field c.cl_ordered_fields; | _ -> () ) com.types; let usage = List.sort (fun p1 p2 -> let c = compare p1.pfile p2.pfile in if c <> 0 then c else compare p1.pmin p2.pmin ) !usage in raise (Typecore.DisplayPosition usage) let update_cache_dependencies com = let rec check_t m t = match t with | TInst(c,tl) -> add_dependency m c.cl_module; List.iter (check_t m) tl; | TEnum(en,tl) -> add_dependency m en.e_module; List.iter (check_t m) tl; | TType(t,tl) -> add_dependency m t.t_module; List.iter (check_t m) tl; | TAbstract(a,tl) -> add_dependency m a.a_module; List.iter (check_t m) tl; | TFun(targs,tret) -> List.iter (fun (_,_,t) -> check_t m t) targs; check_t m tret; | TAnon an -> PMap.iter (fun _ cf -> check_field m cf) an.a_fields | TMono r -> (match !r with | Some t -> check_t m t | _ -> ()) | TLazy f -> check_t m (!f()) | TDynamic t -> if t == t_dynamic then () else check_t m t and check_field m cf = check_t m cf.cf_type in List.iter (fun t -> match t with | TClassDecl c -> List.iter (check_field c.cl_module) c.cl_ordered_statics; List.iter (check_field c.cl_module) c.cl_ordered_fields; (match c.cl_constructor with None -> () | Some cf -> check_field c.cl_module cf); | _ -> () ) com.types (* -------------------------------------------------------------------------- *) (* STACK MANAGEMENT EMULATION *) type stack_context = { stack_var : string; stack_exc_var : string; stack_pos_var : string; stack_pos : pos; stack_expr : texpr; stack_pop : texpr; stack_save_pos : texpr; stack_restore : texpr list; stack_push : tclass -> string -> texpr; stack_return : texpr -> texpr; } let stack_context_init com stack_var exc_var pos_var tmp_var use_add p = let t = com.basic in let st = t.tarray t.tstring in let stack_var = alloc_var stack_var st in let exc_var = alloc_var exc_var st in let pos_var = alloc_var pos_var t.tint in let stack_e = mk (TLocal stack_var) st p in let exc_e = mk (TLocal exc_var) st p in let stack_pop = fcall stack_e "pop" [] t.tstring p in let stack_push c m = fcall stack_e "push" [ if use_add then binop OpAdd (string com (s_type_path c.cl_path ^ "::") p) (string com m p) t.tstring p else string com (s_type_path c.cl_path ^ "::" ^ m) p ] t.tvoid p in let stack_return e = let tmp = alloc_var tmp_var e.etype in mk (TBlock [ mk (TVar (tmp, Some e)) t.tvoid e.epos; stack_pop; mk (TReturn (Some (mk (TLocal tmp) e.etype e.epos))) e.etype e.epos ]) e.etype e.epos in { stack_var = stack_var.v_name; stack_exc_var = exc_var.v_name; stack_pos_var = pos_var.v_name; stack_pos = p; stack_expr = stack_e; stack_pop = stack_pop; stack_save_pos = mk (TVar (pos_var, Some (field stack_e "length" t.tint p))) t.tvoid p; stack_push = stack_push; stack_return = stack_return; stack_restore = [ binop OpAssign exc_e (mk (TArrayDecl []) st p) st p; mk (TWhile ( mk_parent (binop OpGte (field stack_e "length" t.tint p) (mk (TLocal pos_var) t.tint p) t.tbool p), fcall exc_e "unshift" [fcall stack_e "pop" [] t.tstring p] t.tvoid p, NormalWhile )) t.tvoid p; fcall stack_e "push" [index com exc_e 0 t.tstring p] t.tvoid p ]; } let stack_init com use_add = stack_context_init com "$s" "$e" "$spos" "$tmp" use_add null_pos let rec stack_block_loop ctx e = match e.eexpr with | TFunction _ -> e | TReturn None | TReturn (Some { eexpr = TConst _ }) | TReturn (Some { eexpr = TLocal _ }) -> mk (TBlock [ ctx.stack_pop; e; ]) e.etype e.epos | TReturn (Some e) -> ctx.stack_return (stack_block_loop ctx e) | TTry (v,cases) -> let v = stack_block_loop ctx v in let cases = List.map (fun (v,e) -> let e = stack_block_loop ctx e in let e = (match (mk_block e).eexpr with | TBlock l -> mk (TBlock (ctx.stack_restore @ l)) e.etype e.epos | _ -> assert false ) in v , e ) cases in mk (TTry (v,cases)) e.etype e.epos | _ -> map_expr (stack_block_loop ctx) e let stack_block ctx c m e = match (mk_block e).eexpr with | TBlock l -> mk (TBlock ( ctx.stack_push c m :: ctx.stack_save_pos :: List.map (stack_block_loop ctx) l @ [ctx.stack_pop] )) e.etype e.epos | _ -> assert false (* -------------------------------------------------------------------------- *) (* FIX OVERRIDES *) (* on some platforms which doesn't support type parameters, we must have the exact same type for overriden/implemented function as the original one *) let rec find_field com c f = try (match c.cl_super with | None -> raise Not_found | Some ( {cl_path = (["cpp"],"FastIterator")}, _ ) -> raise Not_found (* This is a strongly typed 'extern' and the usual rules don't apply *) | Some (c,_) -> find_field com c f) with Not_found -> try if com.platform = Cpp then (* Cpp uses delegation for interfaces *) raise Not_found; let rec loop = function | [] -> raise Not_found | (c,_) :: l -> try find_field com c f with Not_found -> loop l in loop c.cl_implements with Not_found -> let f = PMap.find f.cf_name c.cl_fields in (match f.cf_kind with Var { v_read = AccRequire _ } -> raise Not_found | _ -> ()); f let fix_override com c f fd = let f2 = (try Some (find_field com c f) with Not_found -> None) in match f2,fd with | Some (f2), Some(fd) -> let targs, tret = (match follow f2.cf_type with TFun (args,ret) -> args, ret | _ -> assert false) in let changed_args = ref [] in let prefix = "_tmp_" in let nargs = List.map2 (fun ((v,ct) as cur) (_,_,t2) -> try type_eq EqStrict (monomorphs c.cl_params (monomorphs f.cf_params v.v_type)) t2; (* Flash generates type parameters with a single constraint as that constraint type, so we have to detect this case and change the variable (issue #2712). *) begin match follow v.v_type with | TInst({cl_kind = KTypeParameter [tc]} as cp,_) when com.platform = Flash -> if List.mem_assoc (snd cp.cl_path) c.cl_params then raise (Unify_error []) | _ -> () end; cur with Unify_error _ -> let v2 = alloc_var (prefix ^ v.v_name) t2 in changed_args := (v,v2) :: !changed_args; v2,ct ) fd.tf_args targs in let fd2 = { tf_args = nargs; tf_type = tret; tf_expr = (match List.rev !changed_args with | [] -> fd.tf_expr | args -> let e = fd.tf_expr in let el = (match e.eexpr with TBlock el -> el | _ -> [e]) in let p = (match el with [] -> e.epos | e :: _ -> e.epos) in let el_v = List.map (fun (v,v2) -> mk (TVar (v,Some (mk (TCast (mk (TLocal v2) v2.v_type p,None)) v.v_type p))) com.basic.tvoid p ) args in { e with eexpr = TBlock (el_v @ el) } ); } in (* as3 does not allow wider visibility, so the base method has to be made public *) if Common.defined com Define.As3 && f.cf_public then f2.cf_public <- true; let targs = List.map (fun(v,c) -> (v.v_name, Option.is_some c, v.v_type)) nargs in let fde = (match f.cf_expr with None -> assert false | Some e -> e) in f.cf_expr <- Some { fde with eexpr = TFunction fd2 }; f.cf_type <- TFun(targs,tret); | Some(f2), None when c.cl_interface -> let targs, tret = (match follow f2.cf_type with TFun (args,ret) -> args, ret | _ -> assert false) in f.cf_type <- TFun(targs,tret) | _ -> () let fix_overrides com t = match t with | TClassDecl c -> (* overrides can be removed from interfaces *) if c.cl_interface then c.cl_ordered_fields <- List.filter (fun f -> try if find_field com c f == f then raise Not_found; c.cl_fields <- PMap.remove f.cf_name c.cl_fields; false; with Not_found -> true ) c.cl_ordered_fields; List.iter (fun f -> match f.cf_expr, f.cf_kind with | Some { eexpr = TFunction fd }, Method (MethNormal | MethInline) -> fix_override com c f (Some fd) | None, Method (MethNormal | MethInline) when c.cl_interface -> fix_override com c f None | _ -> () ) c.cl_ordered_fields | _ -> () (* PHP does not allow abstract classes extending other abstract classes to override any fields, so these duplicates must be removed from the child interface *) let fix_abstract_inheritance com t = match t with | TClassDecl c when c.cl_interface -> c.cl_ordered_fields <- List.filter (fun f -> let b = try (find_field com c f) == f with Not_found -> false in if not b then c.cl_fields <- PMap.remove f.cf_name c.cl_fields; b; ) c.cl_ordered_fields | _ -> () (* -------------------------------------------------------------------------- *) (* MISC FEATURES *) let rec is_volatile t = match t with | TMono r -> (match !r with | Some t -> is_volatile t | _ -> false) | TLazy f -> is_volatile (!f()) | TType (t,tl) -> (match t.t_path with | _ -> is_volatile (apply_params t.t_params tl t.t_type)) | _ -> false let set_default ctx a c p = let t = a.v_type in let ve = mk (TLocal a) t p in let cond = TBinop (OpEq,ve,mk (TConst TNull) t p) in mk (TIf (mk_parent (mk cond ctx.basic.tbool p), mk (TBinop (OpAssign,ve,mk (TConst c) t p)) t p,None)) ctx.basic.tvoid p let bytes_serialize data = let b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" in let tbl = Array.init (String.length b64) (fun i -> String.get b64 i) in Base64.str_encode ~tbl data (* Tells if the constructor might be called without any issue whatever its parameters *) let rec constructor_side_effects e = match e.eexpr with | TBinop (op,_,_) when op <> OpAssign -> true | TField (_,FEnum _) -> false | TUnop _ | TArray _ | TField _ | TEnumParameter _ | TCall _ | TNew _ | TFor _ | TWhile _ | TSwitch _ | TReturn _ | TThrow _ -> true | TBinop _ | TTry _ | TIf _ | TBlock _ | TVar _ | TFunction _ | TArrayDecl _ | TObjectDecl _ | TParenthesis _ | TTypeExpr _ | TLocal _ | TMeta _ | TConst _ | TContinue | TBreak | TCast _ -> try Type.iter (fun e -> if constructor_side_effects e then raise Exit) e; false; with Exit -> true let make_valid_filename s = let r = Str.regexp "[^A-Za-z0-9_\\-\\.,]" in Str.global_substitute r (fun s -> "_") s (* Make a dump of the full typed AST of all types *) let rec create_dumpfile acc = function | [] -> assert false | d :: [] -> let d = make_valid_filename d in let ch = open_out (String.concat "/" (List.rev (d :: acc)) ^ ".dump") in let buf = Buffer.create 0 in buf, (fun () -> output_string ch (Buffer.contents buf); close_out ch) | d :: l -> let dir = String.concat "/" (List.rev (d :: acc)) in if not (Sys.file_exists dir) then Unix.mkdir dir 0o755; create_dumpfile (d :: acc) l let dump_types com = let s_type = s_type (Type.print_context()) in let params = function [] -> "" | l -> Printf.sprintf "<%s>" (String.concat "," (List.map (fun (n,t) -> n ^ " : " ^ s_type t) l)) in let s_expr = match Common.defined_value_safe com Define.Dump with | "pretty" -> Type.s_expr_pretty "\t" | "legacy" -> Type.s_expr | _ -> Type.s_expr_ast (not (Common.defined com Define.DumpIgnoreVarIds)) "\t" in List.iter (fun mt -> let path = Type.t_path mt in let buf,close = create_dumpfile [] ("dump" :: (Common.platform_name com.platform) :: fst path @ [snd path]) in let print fmt = Printf.kprintf (fun s -> Buffer.add_string buf s) fmt in (match mt with | Type.TClassDecl c -> let rec print_field stat f = print "\t%s%s%s%s" (if stat then "static " else "") (if f.cf_public then "public " else "") f.cf_name (params f.cf_params); print "(%s) : %s" (s_kind f.cf_kind) (s_type f.cf_type); (match f.cf_expr with | None -> () | Some e -> print "\n\n\t = %s" (s_expr s_type e)); print "\n\n"; List.iter (fun f -> print_field stat f) f.cf_overloads in print "%s%s%s %s%s" (if c.cl_private then "private " else "") (if c.cl_extern then "extern " else "") (if c.cl_interface then "interface" else "class") (s_type_path path) (params c.cl_params); (match c.cl_super with None -> () | Some (c,pl) -> print " extends %s" (s_type (TInst (c,pl)))); List.iter (fun (c,pl) -> print " implements %s" (s_type (TInst (c,pl)))) c.cl_implements; (match c.cl_dynamic with None -> () | Some t -> print " implements Dynamic<%s>" (s_type t)); (match c.cl_array_access with None -> () | Some t -> print " implements ArrayAccess<%s>" (s_type t)); print "{\n"; (match c.cl_constructor with | None -> () | Some f -> print_field false f); List.iter (print_field false) c.cl_ordered_fields; List.iter (print_field true) c.cl_ordered_statics; (match c.cl_init with | None -> () | Some e -> print "\n\n\t__init__ = "; print "%s" (s_expr s_type e); print "}\n"); print "}"; | Type.TEnumDecl e -> print "%s%senum %s%s {\n" (if e.e_private then "private " else "") (if e.e_extern then "extern " else "") (s_type_path path) (params e.e_params); List.iter (fun n -> let f = PMap.find n e.e_constrs in print "\t%s : %s;\n" f.ef_name (s_type f.ef_type); ) e.e_names; print "}" | Type.TTypeDecl t -> print "%stype %s%s = %s" (if t.t_private then "private " else "") (s_type_path path) (params t.t_params) (s_type t.t_type); | Type.TAbstractDecl a -> print "%sabstract %s%s {}" (if a.a_private then "private " else "") (s_type_path path) (params a.a_params); ); close(); ) com.types let dump_dependencies com = let buf,close = create_dumpfile [] ["dump";Common.platform_name com.platform;".dependencies"] in let print fmt = Printf.kprintf (fun s -> Buffer.add_string buf s) fmt in let dep = Hashtbl.create 0 in List.iter (fun m -> print "%s:\n" m.m_extra.m_file; PMap.iter (fun _ m2 -> print "\t%s\n" (m2.m_extra.m_file); let l = try Hashtbl.find dep m2.m_extra.m_file with Not_found -> [] in Hashtbl.replace dep m2.m_extra.m_file (m :: l) ) m.m_extra.m_deps; ) com.Common.modules; close(); let buf,close = create_dumpfile [] ["dump";Common.platform_name com.platform;".dependants"] in let print fmt = Printf.kprintf (fun s -> Buffer.add_string buf s) fmt in Hashtbl.iter (fun n ml -> print "%s:\n" n; List.iter (fun m -> print "\t%s\n" (m.m_extra.m_file); ) ml; ) dep; close() (* Build a default safe-cast expression : { var $t = ; if( Std.is($t,) ) $t else throw "Class cast error"; } *) let default_cast ?(vtmp="$t") com e texpr t p = let api = com.basic in let mk_texpr = function | TClassDecl c -> TAnon { a_fields = PMap.empty; a_status = ref (Statics c) } | TEnumDecl e -> TAnon { a_fields = PMap.empty; a_status = ref (EnumStatics e) } | TAbstractDecl a -> TAnon { a_fields = PMap.empty; a_status = ref (AbstractStatics a) } | TTypeDecl _ -> assert false in let vtmp = alloc_var vtmp e.etype in let var = mk (TVar (vtmp,Some e)) api.tvoid p in let vexpr = mk (TLocal vtmp) e.etype p in let texpr = mk (TTypeExpr texpr) (mk_texpr texpr) p in let std = (try List.find (fun t -> t_path t = ([],"Std")) com.types with Not_found -> assert false) in let fis = (try let c = (match std with TClassDecl c -> c | _ -> assert false) in FStatic (c, PMap.find "is" c.cl_statics) with Not_found -> assert false ) in let std = mk (TTypeExpr std) (mk_texpr std) p in let is = mk (TField (std,fis)) (tfun [t_dynamic;t_dynamic] api.tbool) p in let is = mk (TCall (is,[vexpr;texpr])) api.tbool p in let exc = mk (TThrow (mk (TConst (TString "Class cast error")) api.tstring p)) t p in let check = mk (TIf (mk_parent is,mk (TCast (vexpr,None)) t p,Some exc)) t p in mk (TBlock [var;check;vexpr]) t p (** Overload resolution **) module Overloads = struct let rec simplify_t t = match t with | TAbstract(a,_) when Meta.has Meta.CoreType a.a_meta -> t | TInst _ | TEnum _ -> t | TAbstract(a,tl) -> simplify_t (Abstract.get_underlying_type a tl) | TType(({ t_path = [],"Null" } as t), [t2]) -> (match simplify_t t2 with | (TAbstract(a,_) as t2) when Meta.has Meta.CoreType a.a_meta -> TType(t, [simplify_t t2]) | (TEnum _ as t2) -> TType(t, [simplify_t t2]) | t2 -> t2) | TType(t, tl) -> simplify_t (apply_params t.t_params tl t.t_type) | TMono r -> (match !r with | Some t -> simplify_t t | None -> t_dynamic) | TAnon _ -> t_dynamic | TDynamic _ -> t | TLazy f -> simplify_t (!f()) | TFun _ -> t (* rate type parameters *) let rate_tp tlfun tlarg = let acc = ref 0 in List.iter2 (fun f a -> if not (type_iseq f a) then incr acc) tlfun tlarg; !acc (** The rate function returns an ( int * int ) type. The smaller the int, the best rated the caller argument is in comparison with the callee. The first int refers to how many "conversions" would be necessary to convert from the callee to the caller type, and the second refers to the type parameters. **) let rec rate_conv cacc tfun targ = match simplify_t tfun, simplify_t targ with | TInst({ cl_interface = true } as cf, tlf), TInst(ca, tla) -> (* breadth-first *) let stack = ref [0,ca,tla] in let cur = ref (0, ca,tla) in let rec loop () = match !stack with | [] -> (let acc, ca, tla = !cur in match ca.cl_super with | None -> raise Not_found | Some (sup,tls) -> cur := (acc+1,sup,List.map (apply_params ca.cl_params tla) tls); stack := [!cur]; loop()) | (acc,ca,tla) :: _ when ca == cf -> acc,tla | (acc,ca,tla) :: s -> stack := s @ List.map (fun (c,tl) -> (acc+1,c,List.map (apply_params ca.cl_params tla) tl)) ca.cl_implements; loop() in let acc, tla = loop() in (cacc + acc, rate_tp tlf tla) | TInst(cf,tlf), TInst(ca,tla) -> let rec loop acc ca tla = if cf == ca then acc, tla else match ca.cl_super with | None -> raise Not_found | Some(sup,stl) -> loop (acc+1) sup (List.map (apply_params ca.cl_params tla) stl) in let acc, tla = loop 0 ca tla in (cacc + acc, rate_tp tlf tla) | TEnum(ef,tlf), TEnum(ea, tla) -> if ef != ea then raise Not_found; (cacc, rate_tp tlf tla) | TDynamic _, TDynamic _ -> (cacc, 0) | TDynamic _, _ -> (max_int, 0) (* a function with dynamic will always be worst of all *) | TAbstract(a, _), TDynamic _ when Meta.has Meta.CoreType a.a_meta -> (cacc + 2, 0) (* a dynamic to a basic type will have an "unboxing" penalty *) | _, TDynamic _ -> (cacc + 1, 0) | TAbstract(af,tlf), TAbstract(aa,tla) -> (if af == aa then (cacc, rate_tp tlf tla) else let ret = ref None in if List.exists (fun t -> try ret := Some (rate_conv (cacc+1) (apply_params af.a_params tlf t) targ); true with | Not_found -> false ) af.a_from then Option.get !ret else if List.exists (fun t -> try ret := Some (rate_conv (cacc+1) tfun (apply_params aa.a_params tla t)); true with | Not_found -> false ) aa.a_to then Option.get !ret else raise Not_found) | TType({ t_path = [], "Null" }, [tf]), TType({ t_path = [], "Null" }, [ta]) -> rate_conv (cacc+0) tf ta | TType({ t_path = [], "Null" }, [tf]), ta -> rate_conv (cacc+1) tf ta | tf, TType({ t_path = [], "Null" }, [ta]) -> rate_conv (cacc+1) tf ta | TFun _, TFun _ -> (* unify will make sure they are compatible *) cacc,0 | tfun,targ -> raise Not_found let is_best arg1 arg2 = (List.for_all2 (fun v1 v2 -> v1 <= v2) arg1 arg2) && (List.exists2 (fun v1 v2 -> v1 < v2) arg1 arg2) let rec rm_duplicates acc ret = match ret with | [] -> acc | ( el, t, _ ) :: ret when List.exists (fun (_,t2,_) -> type_iseq t t2) acc -> rm_duplicates acc ret | r :: ret -> rm_duplicates (r :: acc) ret let s_options rated = String.concat ",\n" (List.map (fun ((elist,t,_),rate) -> "( " ^ (String.concat "," (List.map (fun(e,_) -> s_expr (s_type (print_context())) e) elist)) ^ " ) => " ^ "( " ^ (String.concat "," (List.map (fun (i,i2) -> string_of_int i ^ ":" ^ string_of_int i2) rate)) ^ " ) => " ^ (s_type (print_context()) t) ) rated) let count_optionals elist = List.fold_left (fun acc (_,is_optional) -> if is_optional then acc + 1 else acc) 0 elist let rec fewer_optionals acc compatible = match acc, compatible with | _, [] -> acc | [], c :: comp -> fewer_optionals [c] comp | (elist_acc, _, _) :: _, ((elist, _, _) as cur) :: comp -> let acc_opt = count_optionals elist_acc in let comp_opt = count_optionals elist in if acc_opt = comp_opt then fewer_optionals (cur :: acc) comp else if acc_opt < comp_opt then fewer_optionals acc comp else fewer_optionals [cur] comp let reduce_compatible compatible = match fewer_optionals [] (rm_duplicates [] compatible) with | [] -> [] | [v] -> [v] | compatible -> (* convert compatible into ( rate * compatible_type ) list *) let rec mk_rate acc elist args = match elist, args with | [], [] -> acc | (_,true) :: elist, _ :: args -> mk_rate acc elist args | (e,false) :: elist, (n,o,t) :: args -> (* if the argument is an implicit cast, we need to start with a penalty *) (* The penalty should be higher than any other implicit cast - other than Dynamic *) (* since Dynamic has a penalty of max_int, we'll impose max_int - 1 to it *) (match e.eexpr with | TMeta( (Meta.ImplicitCast,_,_), _) -> mk_rate ((max_int - 1, 0) :: acc) elist args | _ -> mk_rate (rate_conv 0 t e.etype :: acc) elist args) | _ -> assert false in let rated = ref [] in List.iter (function | (elist,TFun(args,ret),d) -> (try rated := ( (elist,TFun(args,ret),d), mk_rate [] elist args ) :: !rated with | Not_found -> ()) | _ -> assert false ) compatible; let rec loop best rem = match best, rem with | _, [] -> best | [], r1 :: rem -> loop [r1] rem | (bover, bargs) :: b1, (rover, rargs) :: rem -> if is_best bargs rargs then loop best rem else if is_best rargs bargs then loop (loop b1 [rover,rargs]) rem else (* equally specific *) loop ( (rover,rargs) :: best ) rem in let r = loop [] !rated in List.map fst r end;; module UnificationCallback = struct let tf_stack = ref [] let check_call_params f el tl = let rec loop acc el tl = match el,tl with | e :: el, (n,_,t) :: tl -> loop ((f e t) :: acc) el tl | [], [] -> acc | [],_ -> acc | e :: el, [] -> loop (e :: acc) el [] in List.rev (loop [] el tl) let check_call f el t = match follow t with | TFun(args,_) -> check_call_params f el args | _ -> List.map (fun e -> f e t_dynamic) el let rec run f e = let f e t = (* TODO: I don't think this should cause errors on Flash target *) (* if not (type_iseq e.etype t) then f e t else e *) f e t in let check e = match e.eexpr with | TBinop((OpAssign | OpAssignOp _ as op),e1,e2) -> let e2 = f e2 e1.etype in {e with eexpr = TBinop(op,e1,e2)} | TVar(v,Some ev) -> let eo = Some (f ev v.v_type) in { e with eexpr = TVar(v,eo) } | TCall(e1,el) -> let el = check_call f el e1.etype in {e with eexpr = TCall(e1,el)} | TNew(c,tl,el) -> begin try let tcf,_ = get_constructor (fun cf -> apply_params c.cl_params tl cf.cf_type) c in let el = check_call f el tcf in {e with eexpr = TNew(c,tl,el)} with Not_found -> e end | TArrayDecl el -> begin match follow e.etype with | TInst({cl_path=[],"Array"},[t]) -> {e with eexpr = TArrayDecl(List.map (fun e -> f e t) el)} | _ -> e end | TObjectDecl fl -> begin match follow e.etype with | TAnon an -> let fl = List.map (fun (n,e) -> let e = try let t = (PMap.find n an.a_fields).cf_type in f e t with Not_found -> e in n,e ) fl in { e with eexpr = TObjectDecl fl } | _ -> e end | TReturn (Some e1) -> begin match !tf_stack with | tf :: _ -> { e with eexpr = TReturn (Some (f e1 tf.tf_type))} | _ -> e end | _ -> e in match e.eexpr with | TFunction tf -> tf_stack := tf :: !tf_stack; let etf = {e with eexpr = TFunction({tf with tf_expr = run f tf.tf_expr})} in tf_stack := List.tl !tf_stack; etf | _ -> check (Type.map_expr (run f) e) end;; module DeprecationCheck = struct let curclass = ref null_class let warned_positions = Hashtbl.create 0 let print_deprecation_message com meta s p_usage = let s = match meta with | _,[EConst(String s),_],_ -> s | _ -> Printf.sprintf "Usage of this %s is deprecated" s in if not (Hashtbl.mem warned_positions p_usage) then begin Hashtbl.replace warned_positions p_usage true; com.warning s p_usage; end let check_meta com meta s p_usage = try print_deprecation_message com (Meta.get Meta.Deprecated meta) s p_usage; with Not_found -> () let check_cf com cf p = check_meta com cf.cf_meta "field" p let check_class com c p = if c != !curclass then check_meta com c.cl_meta "class" p let check_enum com en p = check_meta com en.e_meta "enum" p let check_ef com ef p = check_meta com ef.ef_meta "enum field" p let check_typedef com t p = check_meta com t.t_meta "typedef" p let check_module_type com mt p = match mt with | TClassDecl c -> check_class com c p | TEnumDecl en -> check_enum com en p | _ -> () let run com = let rec expr e = match e.eexpr with | TField(e1,fa) -> expr e1; begin match fa with | FStatic(c,cf) | FInstance(c,_,cf) -> check_class com c e.epos; check_cf com cf e.epos | FAnon cf -> check_cf com cf e.epos | FClosure(co,cf) -> (match co with None -> () | Some (c,_) -> check_class com c e.epos); check_cf com cf e.epos | FEnum(en,ef) -> check_enum com en e.epos; check_ef com ef e.epos; | _ -> () end | TNew(c,_,el) -> List.iter expr el; check_class com c e.epos; (match c.cl_constructor with None -> () | Some cf -> check_cf com cf e.epos) | TTypeExpr(mt) | TCast(_,Some mt) -> check_module_type com mt e.epos | TMeta((Meta.Deprecated,_,_) as meta,e1) -> print_deprecation_message com meta "field" e1.epos; expr e1; | _ -> Type.iter expr e in List.iter (fun t -> match t with | TClassDecl c -> curclass := c; let field cf = match cf.cf_expr with None -> () | Some e -> expr e in (match c.cl_constructor with None -> () | Some cf -> field cf); (match c.cl_init with None -> () | Some e -> expr e); List.iter field c.cl_ordered_statics; List.iter field c.cl_ordered_fields; | _ -> () ) com.types end let interpolate_code com code tl f_string f_expr p = let exprs = Array.of_list tl in let i = ref 0 in let err msg = let pos = { p with pmin = p.pmin + !i } in com.error msg pos in let regex = Str.regexp "[{}]" in let rec loop m = match m with | [] -> () | Str.Text txt :: tl -> i := !i + String.length txt; f_string txt; loop tl | Str.Delim a :: Str.Delim b :: tl when a = b -> i := !i + 2; f_string a; loop tl | Str.Delim "{" :: Str.Text n :: Str.Delim "}" :: tl -> (try let expr = Array.get exprs (int_of_string n) in f_expr expr; i := !i + 2 + String.length n; loop tl with | Failure "int_of_string" -> err ("Index expected. Got " ^ n) | Invalid_argument _ -> err ("Out-of-bounds special parameter: " ^ n)) | Str.Delim x :: _ -> err ("Unexpected " ^ x) in loop (Str.full_split regex code) haxe_3.2.1+dfsg.orig/common.ml0000664000175000017500000013147512607337712016161 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type type package_rule = | Forbidden | Directory of string | Remap of string type pos = Ast.pos type basic_types = { mutable tvoid : t; mutable tint : t; mutable tfloat : t; mutable tbool : t; mutable tnull : t -> t; mutable tstring : t; mutable tarray : t -> t; } type stats = { s_files_parsed : int ref; s_classes_built : int ref; s_methods_typed : int ref; s_macros_called : int ref; } type platform = | Cross | Js | Neko | Flash | Php | Cpp | Cs | Java | Python (** The capture policy tells which handling we make of captured locals (the locals which are referenced in local functions) See details/implementation in Codegen.captured_vars *) type capture_policy = (** do nothing, let the platform handle it *) | CPNone (** wrap all captured variables into a single-element array to allow modifications *) | CPWrapRef (** similar to wrap ref, but will only apply to the locals that are declared in loops *) | CPLoopVars type platform_config = { (** has a static type system, with not-nullable basic types (Int/Float/Bool) *) pf_static : bool; (** has access to the "sys" package *) pf_sys : bool; (** local variables are block-scoped *) pf_locals_scope : bool; (** captured local variables are scoped *) pf_captured_scope : bool; (** generated locals must be absolutely unique wrt the current function *) pf_unique_locals : bool; (** captured variables handling (see before) *) pf_capture_policy : capture_policy; (** when calling a method with optional args, do we replace the missing args with "null" constants *) pf_pad_nulls : bool; (** add a final return to methods not having one already - prevent some compiler warnings *) pf_add_final_return : bool; (** does the platform natively support overloaded functions *) pf_overload : bool; (** does the platform generator handle pattern matching *) pf_pattern_matching : bool; (** can the platform use default values for non-nullable arguments *) pf_can_skip_non_nullable_argument : bool; (** type paths that are reserved on the platform *) pf_reserved_type_paths : path list; } type display_mode = | DMNone | DMDefault | DMUsage | DMPosition | DMToplevel | DMResolve of string | DMType type context = { (* config *) version : int; args : string list; mutable sys_args : string list; mutable display : display_mode; mutable debug : bool; mutable verbose : bool; mutable foptimize : bool; mutable platform : platform; mutable config : platform_config; mutable std_path : string list; mutable class_path : string list; mutable main_class : Type.path option; mutable defines : (string,string) PMap.t; mutable package_rules : (string,package_rule) PMap.t; mutable error : string -> pos -> unit; mutable warning : string -> pos -> unit; mutable load_extern_type : (path -> pos -> (string * Ast.package) option) list; (* allow finding types which are not in sources *) mutable filters : (unit -> unit) list; mutable final_filters : (unit -> unit) list; mutable defines_signature : string option; mutable print : string -> unit; mutable get_macros : unit -> context option; mutable run_command : string -> int; file_lookup_cache : (string,string option) Hashtbl.t; mutable stored_typed_exprs : (int, texpr) PMap.t; (* output *) mutable file : string; mutable flash_version : float; mutable features : (string,bool) Hashtbl.t; mutable modules : Type.module_def list; mutable main : Type.texpr option; mutable types : Type.module_type list; mutable resources : (string,string) Hashtbl.t; mutable neko_libs : string list; mutable php_front : string option; mutable php_lib : string option; mutable php_prefix : string option; mutable swf_libs : (string * (unit -> Swf.swf) * (unit -> ((string list * string),As3hl.hl_class) Hashtbl.t)) list; mutable java_libs : (string * bool * (unit -> unit) * (unit -> (path list)) * (path -> ((JData.jclass * string * string) option))) list; (* (path,std,close,all_files,lookup) *) mutable net_libs : (string * bool * (unit -> path list) * (path -> IlData.ilclass option)) list; (* (path,std,all_files,lookup) *) mutable net_std : string list; net_path_map : (path,string list * string list * string) Hashtbl.t; mutable c_args : string list; mutable js_gen : (unit -> unit) option; (* typing *) mutable basic : basic_types; memory_marker : float array; } exception Abort of string * Ast.pos let display_default = ref DMNone module Define = struct type strict_defined = | AbsolutePath | AdvancedTelemetry | Analyzer | As3 | CheckXmlProxy | CoreApi | CoreApiSerialize | Cppia | Dce | DceDebug | Debug | Display | DllExport | DllImport | DocGen | Dump | DumpDependencies | DumpIgnoreVarIds | EraseGenerics | Fdb | FileExtension | FlashStrict | FlashUseStage | ForceLibCheck | ForceNativeProperty | FormatWarning | GencommonDebug | HaxeBoot | HaxeVer | HxcppApiLevel | IncludePrefix | Interp | JavaVer | JsClassic | JsEs5 | JsUnflatten | KeepOldOutput | LoopUnrollMaxCost | Macro | MacroTimes | NekoSource | NekoV1 | NetworkSandbox | NetVer | NetTarget | NoCompilation | NoCOpt | NoDeprecationWarnings | NoFlashOverride | NoDebug | NoInline | NoOpt | NoPatternMatching | NoRoot | NoSimplify | NoSwfCompress | NoTraces | PhpPrefix | RealPosition | ReplaceFiles | Scriptable | ShallowExpose | SourceMapContent | Swc | SwfCompressLevel | SwfDebugPassword | SwfDirectBlit | SwfGpu | SwfMetadata | SwfPreloaderFrame | SwfProtected | SwfScriptTimeout | SwfUseDoAbc | Sys | Unsafe | UseNekoc | UseRttiDoc | Vcproj | NoMacroCache | Last (* must be last *) let infos = function | AbsolutePath -> ("absolute_path","Print absolute file path in trace output") | AdvancedTelemetry -> ("advanced-telemetry","Allow the SWF to be measured with Monocle tool") | Analyzer -> ("analyzer","Use static analyzer for optimization (experimental)") | As3 -> ("as3","Defined when outputing flash9 as3 source code") | CheckXmlProxy -> ("check_xml_proxy","Check the used fields of the xml proxy") | CoreApi -> ("core_api","Defined in the core api context") | CoreApiSerialize -> ("core_api_serialize","Sets so some generated core api classes be marked with the Serializable attribute on C#") | Cppia -> ("cppia", "Generate experimental cpp instruction assembly") | Dce -> ("dce","The current DCE mode") | DceDebug -> ("dce_debug","Show DCE log") | Debug -> ("debug","Activated when compiling with -debug") | Display -> ("display","Activated during completion") | DllExport -> ("dll_export", "GenCPP experimental linking") | DllImport -> ("dll_import", "GenCPP experimental linking") | DocGen -> ("doc_gen","Do not perform any removal/change in order to correctly generate documentation") | Dump -> ("dump","Dump the complete typed AST for internal debugging") | DumpDependencies -> ("dump_dependencies","Dump the classes dependencies") | DumpIgnoreVarIds -> ("dump_ignore_var_ids","Dump files do not contain variable IDs (helps with diff)") | EraseGenerics -> ("erase_generics","Erase generic classes on C#") | Fdb -> ("fdb","Enable full flash debug infos for FDB interactive debugging") | FileExtension -> ("file_extension","Output filename extension for cpp source code") | FlashStrict -> ("flash_strict","More strict typing for flash target") | FlashUseStage -> ("flash_use_stage","Keep the SWF library initial stage") (* force_lib_check is only here as a debug facility - compiler checking allows errors to be found more easily *) | ForceLibCheck -> ("force_lib_check","Force the compiler to check -net-lib and -java-lib added classes (internal)") | ForceNativeProperty -> ("force_native_property","Tag all properties with :nativeProperty metadata for 3.1 compatibility") | FormatWarning -> ("format_warning","Print a warning for each formated string, for 2.x compatibility") | GencommonDebug -> ("gencommon_debug","GenCommon internal") | HaxeBoot -> ("haxe_boot","Given the name 'haxe' to the flash boot class instead of a generated name") | HaxeVer -> ("haxe_ver","The current Haxe version value") | HxcppApiLevel -> ("hxcpp_api_level","Provided to allow compatibility between hxcpp versions") | IncludePrefix -> ("include_prefix","prepend path to generated include files") | Interp -> ("interp","The code is compiled to be run with --interp") | JavaVer -> ("java_ver", " Sets the Java version to be targeted") | JsClassic -> ("js_classic","Don't use a function wrapper and strict mode in JS output") | JsEs5 -> ("js_es5","Generate JS for ES5-compliant runtimes") | JsUnflatten -> ("js_unflatten","Generate nested objects for packages and types") | KeepOldOutput -> ("keep_old_output","Keep old source files in the output directory (for C#/Java)") | LoopUnrollMaxCost -> ("loop_unroll_max_cost","Maximum cost (number of expressions * iterations) before loop unrolling is canceled (default 250)") | Macro -> ("macro","Defined when we compile code in the macro context") | MacroTimes -> ("macro_times","Display per-macro timing when used with --times") | NetVer -> ("net_ver", " Sets the .NET version to be targeted") | NetTarget -> ("net_target", " Sets the .NET target. Defaults to \"net\". xbox, micro (Micro Framework), compact (Compact Framework) are some valid values") | NekoSource -> ("neko_source","Output neko source instead of bytecode") | NekoV1 -> ("neko_v1","Keep Neko 1.x compatibility") | NetworkSandbox -> ("network-sandbox","Use local network sandbox instead of local file access one") | NoCompilation -> ("no-compilation","Disable final compilation for Cs, Cpp and Java") | NoCOpt -> ("no_copt","Disable completion optimization (for debug purposes)") | NoDebug -> ("no_debug","Remove all debug macros from cpp output") | NoDeprecationWarnings -> ("no-deprecation-warnings","Do not warn if fields annotated with @:deprecated are used") | NoFlashOverride -> ("no-flash-override", "Change overrides on some basic classes into HX suffixed methods, flash only") | NoOpt -> ("no_opt","Disable optimizations") | NoPatternMatching -> ("no_pattern_matching","Disable pattern matching") | NoInline -> ("no_inline","Disable inlining") | NoRoot -> ("no_root","Generate top-level types into haxe.root namespace") | NoMacroCache -> ("no_macro_cache","Disable macro context caching") | NoSimplify -> "no_simplify",("Disable simplification filter") | NoSwfCompress -> ("no_swf_compress","Disable SWF output compression") | NoTraces -> ("no_traces","Disable all trace calls") | PhpPrefix -> ("php_prefix","Compiled with --php-prefix") | RealPosition -> ("real_position","Disables haxe source mapping when targetting C#") | ReplaceFiles -> ("replace_files","GenCommon internal") | Scriptable -> ("scriptable","GenCPP internal") | ShallowExpose -> ("shallow-expose","Expose types to surrounding scope of Haxe generated closure without writing to window object") | SourceMapContent -> ("source-map-content","Include the hx sources as part of the JS source map") | Swc -> ("swc","Output a SWC instead of a SWF") | SwfCompressLevel -> ("swf_compress_level"," Set the amount of compression for the SWF output") | SwfDebugPassword -> ("swf_debug_password", "Set a password for debugging") | SwfDirectBlit -> ("swf_direct_blit", "Use hardware acceleration to blit graphics") | SwfGpu -> ("swf_gpu", "Use GPU compositing features when drawing graphics") | SwfMetadata -> ("swf_metadata", "= Include contents of as metadata in the swf") | SwfPreloaderFrame -> ("swf_preloader_frame", "Insert empty first frame in swf") | SwfProtected -> ("swf_protected","Compile Haxe private as protected in the SWF instead of public") | SwfScriptTimeout -> ("swf_script_timeout", "Maximum ActionScript processing time before script stuck dialog box displays (in seconds)") | SwfUseDoAbc -> ("swf_use_doabc", "Use DoAbc swf-tag instead of DoAbcDefine") | Sys -> ("sys","Defined for all system platforms") | Unsafe -> ("unsafe","Allow unsafe code when targeting C#") | UseNekoc -> ("use_nekoc","Use nekoc compiler instead of internal one") | UseRttiDoc -> ("use_rtti_doc","Allows access to documentation during compilation") | Vcproj -> ("vcproj","GenCPP internal") | Last -> assert false end module MetaInfo = struct open Meta type meta_usage = | TClass | TClassField | TAbstract | TAbstractField | TEnum | TTypedef | TAnyField | TExpr type meta_parameter = | HasParam of string | Platform of platform | Platforms of platform list | UsedOn of meta_usage | UsedOnEither of meta_usage list | Internal let to_string = function | Abi -> ":abi",("Function ABI/calling convention",[Platforms [Cpp]]) | Abstract -> ":abstract",("Sets the underlying class implementation as 'abstract'",[Platforms [Java;Cs]]) | Access -> ":access",("Forces private access to package, type or field",[HasParam "Target path";UsedOnEither [TClass;TClassField]]) | Accessor -> ":accessor",("Used internally by DCE to mark property accessors",[UsedOn TClassField;Internal]) | Allow -> ":allow",("Allows private access from package, type or field",[HasParam "Target path";UsedOnEither [TClass;TClassField]]) | Analyzer -> ":analyzer",("Used to configure the static analyzer",[]) | Annotation -> ":annotation",("Annotation (@interface) definitions on -java-lib imports will be annotated with this metadata. Has no effect on types compiled by Haxe",[Platform Java; UsedOn TClass]) | ArrayAccess -> ":arrayAccess",("Allows [] access on an abstract",[UsedOnEither [TAbstract;TAbstractField]]) | Ast -> ":ast",("Internally used to pass the AST source into the typed AST",[Internal]) | AutoBuild -> ":autoBuild",("Extends @:build metadata to all extending and implementing classes",[HasParam "Build macro call";UsedOn TClass]) | Bind -> ":bind",("Override Swf class declaration",[Platform Flash;UsedOn TClass]) | Bitmap -> ":bitmap",("Embeds given bitmap data into the class (must extend flash.display.BitmapData)",[HasParam "Bitmap file path";UsedOn TClass;Platform Flash]) | BridgeProperties -> ":bridgeProperties",("Creates native property bridges for all Haxe properties in this class",[UsedOn TClass;Platform Cs]) | Build -> ":build",("Builds a class or enum from a macro",[HasParam "Build macro call";UsedOnEither [TClass;TEnum]]) | BuildXml -> ":buildXml",("Specify xml data to be injected into Build.xml",[Platform Cpp]) | Callable -> ":callable",("Abstract forwards call to its underlying type",[UsedOn TAbstract]) | Class -> ":class",("Used internally to annotate an enum that will be generated as a class",[Platforms [Java;Cs]; UsedOn TEnum; Internal]) | ClassCode -> ":classCode",("Used to inject platform-native code into a class",[Platforms [Java;Cs]; UsedOn TClass]) | Commutative -> ":commutative",("Declares an abstract operator as commutative",[UsedOn TAbstractField]) | CompilerGenerated -> ":compilerGenerated",("Marks a field as generated by the compiler. Shouldn't be used by the end user",[Platforms [Java;Cs]]) | CoreApi -> ":coreApi",("Identifies this class as a core api class (forces Api check)",[UsedOnEither [TClass;TEnum;TTypedef;TAbstract]]) | CoreType -> ":coreType",("Identifies an abstract as core type so that it requires no implementation",[UsedOn TAbstract]) | CppFileCode -> ":cppFileCode",("Code to be injected into generated cpp file",[Platform Cpp]) | CppInclude -> ":cppInclude",("File to be included in generated cpp file",[Platform Cpp]) | CppNamespaceCode -> ":cppNamespaceCode",("",[Platform Cpp]) | CsNative -> ":csNative",("Automatically added by -net-lib on classes generated from .NET DLL files",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal]) | Dce -> ":dce",("Forces dead code elimination even when -dce full is not specified",[UsedOnEither [TClass;TEnum]]) | Debug -> ":debug",("Forces debug information to be generated into the Swf even without -debug",[UsedOnEither [TClass;TClassField]; Platform Flash]) | Decl -> ":decl",("",[Platform Cpp]) | DefParam -> ":defParam",("?",[]) | Delegate -> ":delegate",("Automatically added by -net-lib on delegates",[Platform Cs; UsedOn TAbstract]) | Depend -> ":depend",("",[Platform Cpp]) | Deprecated -> ":deprecated",("Automatically added by -java-lib on class fields annotated with @Deprecated annotation. Has no effect on types compiled by Haxe",[Platform Java; UsedOnEither [TClass;TEnum;TClassField]]) | DirectlyUsed -> ":directlyUsed",("Marks types that are directly referenced by non-extern code",[Internal]) | DynamicObject -> ":dynamicObject",("Used internally to identify the Dynamic Object implementation",[Platforms [Java;Cs]; UsedOn TClass; Internal]) | Enum -> ":enum",("Used internally to annotate a class that was generated from an enum",[Platforms [Java;Cs]; UsedOn TClass; Internal]) | EnumConstructorParam -> ":enumConstructorParam",("Used internally to annotate GADT type parameters",[UsedOn TClass; Internal]) | Event -> ":event",("Automatically added by -net-lib on events. Has no effect on types compiled by Haxe",[Platform Cs; UsedOn TClassField]) | Exhaustive -> ":exhaustive",("",[Internal]) | Expose -> ":expose",("Makes the class available on the window object",[HasParam "?Name=Class path";UsedOn TClass;Platform Js]) | Extern -> ":extern",("Marks the field as extern so it is not generated",[UsedOn TClassField]) | FakeEnum -> ":fakeEnum",("Treat enum as collection of values of the specified type",[HasParam "Type name";UsedOn TEnum]) | File -> ":file",("Includes a given binary file into the target Swf and associates it with the class (must extend flash.utils.ByteArray)",[HasParam "File path";UsedOn TClass;Platform Flash]) | Final -> ":final",("Prevents a class from being extended",[UsedOn TClass]) | FlatEnum -> ":flatEnum",("Internally used to mark an enum as being flat, i.e. having no function constructors",[UsedOn TEnum; Internal]) | Font -> ":font",("Embeds the given TrueType font into the class (must extend flash.text.Font)",[HasParam "TTF path";HasParam "Range String";UsedOn TClass]) | Forward -> ":forward",("Forwards field access to underlying type",[HasParam "List of field names";UsedOn TAbstract]) | From -> ":from",("Specifies that the field of the abstract is a cast operation from the type identified in the function",[UsedOn TAbstractField]) | FunctionCode -> ":functionCode",("",[Platform Cpp]) | FunctionTailCode -> ":functionTailCode",("",[Platform Cpp]) | Generic -> ":generic",("Marks a class or class field as generic so each type parameter combination generates its own type/field",[UsedOnEither [TClass;TClassField]]) | GenericBuild -> ":genericBuild",("Builds instances of a type using the specified macro",[UsedOn TClass]) | GenericInstance -> ":genericInstance",("Internally used to mark instances of @:generic methods",[UsedOn TClassField;Internal]) | Getter -> ":getter",("Generates a native getter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash]) | Hack -> ":hack",("Allows extending classes marked as @:final",[UsedOn TClass]) | HasUntyped -> (":has_untyped",("Used by the typer to mark fields that have untyped expressions",[Internal])) | HaxeGeneric -> ":haxeGeneric",("Used internally to annotate non-native generic classes",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal]) | HeaderClassCode -> ":headerClassCode",("Code to be injected into the generated class, in the header",[Platform Cpp]) | HeaderCode -> ":headerCode",("Code to be injected into the generated header file",[Platform Cpp]) | HeaderInclude -> ":headerInclude",("File to be included in generated header file",[Platform Cpp]) | HeaderNamespaceCode -> ":headerNamespaceCode",("",[Platform Cpp]) | HxGen -> ":hxGen",("Annotates that an extern class was generated by Haxe",[Platforms [Java;Cs]; UsedOnEither [TClass;TEnum]]) | IfFeature -> ":ifFeature",("Causes a field to be kept by DCE if the given feature is part of the compilation",[HasParam "Feature name";UsedOn TClassField]) | Impl -> ":impl",("Used internally to mark abstract implementation fields",[UsedOn TAbstractField; Internal]) | PythonImport -> ":pythonImport",("Generates python import statement for extern classes",[Platforms [Python]; UsedOn TClass]) | ImplicitCast -> ":implicitCast",("Generated automatically on the AST when an implicit abstract cast happens",[Internal; UsedOn TExpr]) | Include -> ":include",("",[Platform Cpp]) | InitPackage -> ":initPackage",("?",[]) | Meta.Internal -> ":internal",("Generates the annotated field/class with 'internal' access",[Platforms [Java;Cs]; UsedOnEither[TClass;TEnum;TClassField]]) | IsVar -> ":isVar",("Forces a physical field to be generated for properties that otherwise would not require one",[UsedOn TClassField]) | JavaCanonical -> ":javaCanonical",("Used by the Java target to annotate the canonical path of the type",[HasParam "Output type package";HasParam "Output type name";UsedOnEither [TClass;TEnum]; Platform Java]) | JavaNative -> ":javaNative",("Automatically added by -java-lib on classes generated from JAR/class files",[Platform Java; UsedOnEither[TClass;TEnum]; Internal]) | JsRequire -> ":jsRequire",("Generate javascript module require expression for given extern",[Platform Js; UsedOn TClass]) | Keep -> ":keep",("Causes a field or type to be kept by DCE",[]) | KeepInit -> ":keepInit",("Causes a class to be kept by DCE even if all its field are removed",[UsedOn TClass]) | KeepSub -> ":keepSub",("Extends @:keep metadata to all implementing and extending classes",[UsedOn TClass]) | LibType -> ":libType",("Used by -net-lib and -java-lib to mark a class that shouldn't be checked (overrides, interfaces, etc) by the type loader",[Internal; UsedOn TClass; Platforms [Java;Cs]]) | Meta -> ":meta",("Internally used to mark a class field as being the metadata field",[]) | Macro -> ":macro",("(deprecated)",[]) | MaybeUsed -> ":maybeUsed",("Internally used by DCE to mark fields that might be kept",[Internal]) | MergeBlock -> ":mergeBlock",("Merge the annotated block into the current scope",[UsedOn TExpr]) | MultiType -> ":multiType",("Specifies that an abstract chooses its this-type from its @:to functions",[UsedOn TAbstract; HasParam "Relevant type parameters"]) | Native -> ":native",("Rewrites the path of a class or enum during generation",[HasParam "Output type path";UsedOnEither [TClass;TEnum]]) | NativeChildren -> ":nativeChildren",("Annotates that all children from a type should be treated as if it were an extern definition - platform native",[Platforms [Java;Cs]; UsedOn TClass]) | NativeGen -> ":nativeGen",("Annotates that a type should be treated as if it were an extern definition - platform native",[Platforms [Java;Cs;Python]; UsedOnEither[TClass;TEnum]]) | NativeGeneric -> ":nativeGeneric",("Used internally to annotate native generic classes",[Platform Cs; UsedOnEither[TClass;TEnum]; Internal]) | NativeProperty -> ":nativeProperty",("Use native properties which will execute even with dynamic usage",[Platform Cpp]) | NoCompletion -> ":noCompletion",("Prevents the compiler from suggesting completion on this field",[UsedOn TClassField]) | NoDebug -> ":noDebug",("Does not generate debug information into the Swf even if -debug is set",[UsedOnEither [TClass;TClassField];Platform Flash]) | NoDoc -> ":noDoc",("Prevents a type from being included in documentation generation",[]) | NoExpr -> ":noExpr",("Internally used to mark abstract fields which have no expression by design",[Internal]) | NoImportGlobal -> ":noImportGlobal",("Prevents a static field from being imported with import Class.*",[UsedOn TAnyField]) | NonVirtual -> ":nonVirtual",("Declares function to be non-virtual in cpp",[Platform Cpp]) | NoPackageRestrict -> ":noPackageRestrict",("Allows a module to be accessed across all targets if found on its first type",[Internal]) | NoPrivateAccess -> ":noPrivateAccess",("Disallow private access to anything for the annotated expression",[UsedOn TExpr]) | NoStack -> ":noStack",("",[Platform Cpp]) | NotNull -> ":notNull",("Declares an abstract type as not accepting null values",[UsedOn TAbstract]) | NoUsing -> ":noUsing",("Prevents a field from being used with 'using'",[UsedOn TClassField]) | Ns -> ":ns",("Internally used by the Swf generator to handle namespaces",[Platform Flash]) | Op -> ":op",("Declares an abstract field as being an operator overload",[HasParam "The operation";UsedOn TAbstractField]) | Optional -> ":optional",("Marks the field of a structure as optional",[UsedOn TClassField]) | Overload -> ":overload",("Allows the field to be called with different argument types",[HasParam "Function specification (no expression)";UsedOn TClassField]) | Public -> ":public",("Marks a class field as being public",[UsedOn TClassField]) | PublicFields -> ":publicFields",("Forces all class fields of inheriting classes to be public",[UsedOn TClass]) | QuotedField -> ":quotedField",("Used internally to mark structure fields which are quoted in syntax",[Internal]) | PrivateAccess -> ":privateAccess",("Allow private access to anything for the annotated expression",[UsedOn TExpr]) | Protected -> ":protected",("Marks a class field as being protected",[UsedOn TClassField]) | Property -> ":property",("Marks a property field to be compiled as a native C# property",[UsedOn TClassField;Platform Cs]) | ReadOnly -> ":readOnly",("Generates a field with the 'readonly' native keyword",[Platform Cs; UsedOn TClassField]) | RealPath -> ":realPath",("Internally used on @:native types to retain original path information",[Internal]) | Remove -> ":remove",("Causes an interface to be removed from all implementing classes before generation",[UsedOn TClass]) | Require -> ":require",("Allows access to a field only if the specified compiler flag is set",[HasParam "Compiler flag to check";UsedOn TClassField]) | RequiresAssign -> ":requiresAssign",("Used internally to mark certain abstract operator overloads",[Internal]) (* | Resolve -> ":resolve",("Abstract fields marked with this metadata can be used to resolve unknown fields",[UsedOn TClassField]) *) | ReplaceReflection -> ":replaceReflection",("Used internally to specify a function that should replace its internal __hx_functionName counterpart",[Platforms [Java;Cs]; UsedOnEither[TClass;TEnum]; Internal]) | Rtti -> ":rtti",("Adds runtime type informations",[UsedOn TClass]) | Runtime -> ":runtime",("?",[]) | RuntimeValue -> ":runtimeValue",("Marks an abstract as being a runtime value",[UsedOn TAbstract]) | SelfCall -> ":selfCall",("Translates method calls into calling object directly",[UsedOn TClassField; Platform Js]) | Setter -> ":setter",("Generates a native setter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash]) | StoredTypedExpr -> ":storedTypedExpr",("Used internally to reference a typed expression returned from a macro",[Internal]) | SkipCtor -> ":skipCtor",("Used internally to generate a constructor as if it were a native type (no __hx_ctor)",[Platforms [Java;Cs]; Internal]) | SkipReflection -> ":skipReflection",("Used internally to annotate a field that shouldn't have its reflection data generated",[Platforms [Java;Cs]; UsedOn TClassField; Internal]) | Sound -> ":sound",( "Includes a given .wav or .mp3 file into the target Swf and associates it with the class (must extend flash.media.Sound)",[HasParam "File path";UsedOn TClass;Platform Flash]) | SourceFile -> ":sourceFile",("Source code filename for external class",[Platform Cpp]) | Strict -> ":strict",("Used to declare a native C# attribute or a native Java metadata. Is type checked",[Platforms [Java;Cs]]) | Struct -> ":struct",("Marks a class definition as a struct",[Platform Cs; UsedOn TClass]) | StructAccess -> ":structAccess",("Marks an extern class as using struct access('.') not pointer('->')",[Platform Cpp; UsedOn TClass]) | SuppressWarnings -> ":suppressWarnings",("Adds a SuppressWarnings annotation for the generated Java class",[Platform Java; UsedOn TClass]) | Throws -> ":throws",("Adds a 'throws' declaration to the generated function",[HasParam "Type as String"; Platform Java; UsedOn TClassField]) | This -> ":this",("Internally used to pass a 'this' expression to macros",[Internal; UsedOn TExpr]) | To -> ":to",("Specifies that the field of the abstract is a cast operation to the type identified in the function",[UsedOn TAbstractField]) | ToString -> ":toString",("Internally used",[Internal]) | Transient -> ":transient",("Adds the 'transient' flag to the class field",[Platform Java; UsedOn TClassField]) | ValueUsed -> ":valueUsed",("Internally used by DCE to mark an abstract value as used",[Internal]) | Volatile -> ":volatile",("",[Platforms [Java;Cs]]) | Unbound -> ":unbound", ("Compiler internal to denote unbounded global variable",[]) | UnifyMinDynamic -> ":unifyMinDynamic",("Allows a collection of types to unify to Dynamic",[UsedOn TClassField]) | Unreflective -> ":unreflective",("",[Platform Cpp]) | Unsafe -> ":unsafe",("Declares a class, or a method with the C#'s 'unsafe' flag",[Platform Cs; UsedOnEither [TClass;TClassField]]) | Usage -> ":usage",("?",[]) | Used -> ":used",("Internally used by DCE to mark a class or field as used",[Internal]) | Value -> ":value",("Used to store default values for fields and function arguments",[UsedOn TClassField]) | Void -> ":void",("Use Cpp native 'void' return type",[Platform Cpp]) | Last -> assert false (* do not put any custom metadata after Last *) | Dollar s -> "$" ^ s,("",[]) | Custom s -> s,("",[]) let hmeta = let h = Hashtbl.create 0 in let rec loop i = let m = Obj.magic i in if m <> Last then begin Hashtbl.add h (fst (to_string m)) m; loop (i + 1); end; in loop 0; h let parse s = try Hashtbl.find hmeta (":" ^ s) with Not_found -> Custom (":" ^ s) let from_string s = if s = "" then Custom "" else match s.[0] with | ':' -> (try Hashtbl.find hmeta s with Not_found -> Custom s) | '$' -> Dollar (String.sub s 1 (String.length s - 1)) | _ -> Custom s end let stats = { s_files_parsed = ref 0; s_classes_built = ref 0; s_methods_typed = ref 0; s_macros_called = ref 0; } let default_config = { pf_static = true; pf_sys = true; pf_locals_scope = true; pf_captured_scope = true; pf_unique_locals = false; pf_capture_policy = CPNone; pf_pad_nulls = false; pf_add_final_return = false; pf_overload = false; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = true; pf_reserved_type_paths = []; } let get_config com = let defined f = PMap.mem (fst (Define.infos f)) com.defines in match com.platform with | Cross -> default_config | Js -> { pf_static = false; pf_sys = false; pf_locals_scope = false; pf_captured_scope = false; pf_unique_locals = false; pf_capture_policy = CPLoopVars; pf_pad_nulls = false; pf_add_final_return = false; pf_overload = false; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = true; pf_reserved_type_paths = [([],"Object");([],"Error")]; } | Neko -> { pf_static = false; pf_sys = true; pf_locals_scope = true; pf_captured_scope = true; pf_unique_locals = false; pf_capture_policy = CPNone; pf_pad_nulls = true; pf_add_final_return = false; pf_overload = false; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = true; pf_reserved_type_paths = []; } | Flash when defined Define.As3 -> { pf_static = true; pf_sys = false; pf_locals_scope = false; pf_captured_scope = true; pf_unique_locals = true; pf_capture_policy = CPLoopVars; pf_pad_nulls = false; pf_add_final_return = true; pf_overload = false; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = false; pf_reserved_type_paths = []; } | Flash -> { pf_static = true; pf_sys = false; pf_locals_scope = true; pf_captured_scope = true; (* handled by genSwf9 *) pf_unique_locals = false; pf_capture_policy = CPLoopVars; pf_pad_nulls = false; pf_add_final_return = false; pf_overload = false; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = false; pf_reserved_type_paths = [([],"Object");([],"Error")]; } | Php -> { pf_static = false; pf_sys = true; pf_locals_scope = false; (* some duplicate work is done in genPhp *) pf_captured_scope = false; pf_unique_locals = false; pf_capture_policy = CPNone; pf_pad_nulls = true; pf_add_final_return = false; pf_overload = false; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = true; pf_reserved_type_paths = []; } | Cpp -> { pf_static = true; pf_sys = true; pf_locals_scope = true; pf_captured_scope = true; pf_unique_locals = false; pf_capture_policy = CPWrapRef; pf_pad_nulls = true; pf_add_final_return = true; pf_overload = false; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = true; pf_reserved_type_paths = []; } | Cs -> { pf_static = true; pf_sys = true; pf_locals_scope = false; pf_captured_scope = true; pf_unique_locals = true; pf_capture_policy = CPWrapRef; pf_pad_nulls = true; pf_add_final_return = false; pf_overload = true; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = true; pf_reserved_type_paths = []; } | Java -> { pf_static = true; pf_sys = true; pf_locals_scope = false; pf_captured_scope = true; pf_unique_locals = false; pf_capture_policy = CPWrapRef; pf_pad_nulls = true; pf_add_final_return = false; pf_overload = true; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = true; pf_reserved_type_paths = []; } | Python -> { pf_static = false; pf_sys = true; pf_locals_scope = false; pf_captured_scope = false; pf_unique_locals = false; pf_capture_policy = CPLoopVars; pf_pad_nulls = false; pf_add_final_return = false; pf_overload = false; pf_pattern_matching = false; pf_can_skip_non_nullable_argument = true; pf_reserved_type_paths = []; } let memory_marker = [|Unix.time()|] let create v args = let m = Type.mk_mono() in { version = v; args = args; sys_args = args; debug = false; display = !display_default; verbose = false; foptimize = true; features = Hashtbl.create 0; platform = Cross; config = default_config; print = (fun s -> print_string s; flush stdout); run_command = Sys.command; std_path = []; class_path = []; main_class = None; defines = PMap.add "true" "1" (if !display_default <> DMNone then PMap.add "display" "1" PMap.empty else PMap.empty); package_rules = PMap.empty; file = ""; types = []; filters = []; final_filters = []; modules = []; main = None; flash_version = 10.; resources = Hashtbl.create 0; php_front = None; php_lib = None; swf_libs = []; java_libs = []; net_libs = []; net_std = []; net_path_map = Hashtbl.create 0; c_args = []; neko_libs = []; php_prefix = None; js_gen = None; load_extern_type = []; defines_signature = None; get_macros = (fun() -> None); warning = (fun _ _ -> assert false); error = (fun _ _ -> assert false); basic = { tvoid = m; tint = m; tfloat = m; tbool = m; tnull = (fun _ -> assert false); tstring = m; tarray = (fun _ -> assert false); }; file_lookup_cache = Hashtbl.create 0; stored_typed_exprs = PMap.empty; memory_marker = memory_marker; } let log com str = if com.verbose then com.print (str ^ "\n") let clone com = let t = com.basic in { com with basic = { t with tvoid = t.tvoid }; main_class = None; features = Hashtbl.create 0; file_lookup_cache = Hashtbl.create 0; } let file_time file = try (Unix.stat file).Unix.st_mtime with _ -> 0. let get_signature com = match com.defines_signature with | Some s -> s | None -> let str = String.concat "@" (PMap.foldi (fun k v acc -> (* don't make much difference between these special compilation flags *) match k with | "display" | "use_rtti_doc" | "macrotimes" -> acc | _ -> k :: v :: acc ) com.defines []) in let s = Digest.string str in com.defines_signature <- Some s; s let file_extension file = match List.rev (ExtString.String.nsplit file ".") with | e :: _ -> String.lowercase e | [] -> "" let platforms = [ Js; Neko; Flash; Php; Cpp; Cs; Java; Python; ] let platform_name = function | Cross -> "cross" | Js -> "js" | Neko -> "neko" | Flash -> "flash" | Php -> "php" | Cpp -> "cpp" | Cs -> "cs" | Java -> "java" | Python -> "python" let flash_versions = List.map (fun v -> let maj = int_of_float v in let min = int_of_float (mod_float (v *. 10.) 10.) in v, string_of_int maj ^ (if min = 0 then "" else "_" ^ string_of_int min) ) [9.;10.;10.1;10.2;10.3;11.;11.1;11.2;11.3;11.4;11.5;11.6;11.7;11.8;11.9;12.0;13.0;14.0;15.0;16.0;17.0] let flash_version_tag = function | 6. -> 6 | 7. -> 7 | 8. -> 8 | 9. -> 9 | 10. | 10.1 -> 10 | 10.2 -> 11 | 10.3 -> 12 | 11. -> 13 | 11.1 -> 14 | 11.2 -> 15 | 11.3 -> 16 | 11.4 -> 17 | 11.5 -> 18 | 11.6 -> 19 | 11.7 -> 20 | 11.8 -> 21 | 11.9 -> 22 | 12.0 -> 23 | 13.0 -> 24 | 14.0 -> 25 | 15.0 -> 26 | 16.0 -> 27 | 17.0 -> 28 | v -> failwith ("Invalid SWF version " ^ string_of_float v) let raw_defined ctx v = PMap.mem v ctx.defines let defined ctx v = raw_defined ctx (fst (Define.infos v)) let raw_defined_value ctx k = PMap.find k ctx.defines let defined_value ctx v = raw_defined_value ctx (fst (Define.infos v)) let defined_value_safe ctx v = try defined_value ctx v with Not_found -> "" let raw_define ctx v = let k,v = try ExtString.String.split v "=" with _ -> v,"1" in ctx.defines <- PMap.add k v ctx.defines; let k = String.concat "_" (ExtString.String.nsplit k "-") in ctx.defines <- PMap.add k v ctx.defines; ctx.defines_signature <- None let define_value ctx k v = raw_define ctx (fst (Define.infos k) ^ "=" ^ v) let define ctx v = raw_define ctx (fst (Define.infos v)) let init_platform com pf = com.platform <- pf; let name = platform_name pf in let forbid acc p = if p = name || PMap.mem p acc then acc else PMap.add p Forbidden acc in com.package_rules <- List.fold_left forbid com.package_rules (List.map platform_name platforms); com.config <- get_config com; (* if com.config.pf_static then define com "static"; *) if com.config.pf_sys then define com Define.Sys else com.package_rules <- PMap.add "sys" Forbidden com.package_rules; raw_define com name let add_feature com f = Hashtbl.replace com.features f true let has_dce com = (try defined_value com Define.Dce <> "no" with Not_found -> false) (* TODO: The has_dce check is there because we mark types with @:directlyUsed in the DCE filter, which is not run in dce=no and thus we can't know if a type is used directly or not, so we just assume that they are. If we had dce filter always running (even with dce=no), we would have types marked with @:directlyUsed and we wouldn't need to generate unnecessary imports in dce=no, but that's good enough for now. *) let is_directly_used com meta = not (has_dce com) || Ast.Meta.has Ast.Meta.DirectlyUsed meta let rec has_feature com f = try Hashtbl.find com.features f with Not_found -> if com.types = [] then not (has_dce com) else match List.rev (ExtString.String.nsplit f ".") with | [] -> assert false | [cl] -> has_feature com (cl ^ ".*") | meth :: cl :: pack -> let r = (try let path = List.rev pack, cl in (match List.find (fun t -> t_path t = path && not (Ast.Meta.has Ast.Meta.RealPath (t_infos t).mt_meta)) com.types with | t when meth = "*" -> (match t with TAbstractDecl a -> Ast.Meta.has Ast.Meta.ValueUsed a.a_meta | _ -> Ast.Meta.has Ast.Meta.Used (t_infos t).mt_meta) | TClassDecl ({cl_extern = true} as c) when com.platform <> Js || cl <> "Array" && cl <> "Math" -> Meta.has Meta.Used (try PMap.find meth c.cl_statics with Not_found -> PMap.find meth c.cl_fields).cf_meta | TClassDecl c -> PMap.exists meth c.cl_statics || PMap.exists meth c.cl_fields | _ -> false) with Not_found -> false ) in let r = r || not (has_dce com) in Hashtbl.add com.features f r; r let allow_package ctx s = try if (PMap.find s ctx.package_rules) = Forbidden then ctx.package_rules <- PMap.remove s ctx.package_rules with Not_found -> () let error msg p = raise (Abort (msg,p)) let platform ctx p = ctx.platform = p let add_filter ctx f = ctx.filters <- f :: ctx.filters let add_final_filter ctx f = ctx.final_filters <- f :: ctx.final_filters let find_file ctx f = try (match Hashtbl.find ctx.file_lookup_cache f with | None -> raise Exit | Some f -> f) with Exit -> raise Not_found | Not_found -> let rec loop had_empty = function | [] when had_empty -> raise Not_found | [] -> loop true [""] | p :: l -> let file = p ^ f in if Sys.file_exists file then file else loop (had_empty || p = "") l in let r = (try Some (loop false ctx.class_path) with Not_found -> None) in Hashtbl.add ctx.file_lookup_cache f r; (match r with | None -> raise Not_found | Some f -> f) let get_full_path f = try Extc.get_full_path f with _ -> f let unique_full_path = if Sys.os_type = "Win32" || Sys.os_type = "Cygwin" then (fun f -> String.lowercase (get_full_path f)) else get_full_path let normalize_path p = let l = String.length p in if l = 0 then "./" else match p.[l-1] with | '\\' | '/' -> p | _ -> p ^ "/" let rec mkdir_recursive base dir_list = match dir_list with | [] -> () | dir :: remaining -> let path = match base with | "" -> dir | "/" -> "/" ^ dir | _ -> base ^ "/" ^ dir in if not ( (path = "") || ( ((String.length path) = 2) && ((String.sub path 1 1) = ":") ) ) then if not (Sys.file_exists path) then Unix.mkdir path 0o755; mkdir_recursive (if (path = "") then "/" else path) remaining let mkdir_from_path path = let parts = Str.split_delim (Str.regexp "[\\/]+") path in match parts with | [] -> (* path was "" *) () | _ -> let dir_list = List.rev (List.tl (List.rev parts)) in mkdir_recursive "" dir_list let mem_size v = Objsize.size_with_headers (Objsize.objsize v [] []) (* ------------------------- TIMERS ----------------------------- *) type timer_infos = { name : string; mutable start : float list; mutable total : float; } let get_time = Extc.time let htimers = Hashtbl.create 0 let new_timer name = try let t = Hashtbl.find htimers name in t.start <- get_time() :: t.start; t with Not_found -> let t = { name = name; start = [get_time()]; total = 0.; } in Hashtbl.add htimers name t; t let curtime = ref [] let close t = let start = (match t.start with | [] -> assert false | s :: l -> t.start <- l; s ) in let now = get_time() in let dt = now -. start in t.total <- t.total +. dt; let rec loop() = match !curtime with | [] -> failwith ("Timer " ^ t.name ^ " closed while not active") | tt :: l -> curtime := l; if t != tt then loop() in loop(); (* because of rounding errors while adding small times, we need to make sure that we don't have start > now *) List.iter (fun ct -> ct.start <- List.map (fun t -> let s = t +. dt in if s > now then now else s) ct.start) !curtime let timer name = let t = new_timer name in curtime := t :: !curtime; (function() -> close t) let rec close_times() = match !curtime with | [] -> () | t :: _ -> close t; close_times() ;; Ast.Meta.to_string_ref := fun m -> fst (MetaInfo.to_string m) (* Taken from OCaml source typing/oprint.ml This is a better version of string_of_float which prints without loss of precision so that float_of_string (float_repres x) = x for all floats x *) let valid_float_lexeme s = let l = String.length s in let rec loop i = if i >= l then s ^ "." else match s.[i] with | '0' .. '9' | '-' -> loop (i+1) | _ -> s in loop 0 let float_repres f = match classify_float f with | FP_nan -> "nan" | FP_infinite -> if f < 0.0 then "neg_infinity" else "infinity" | _ -> let float_val = let s1 = Printf.sprintf "%.12g" f in if f = float_of_string s1 then s1 else let s2 = Printf.sprintf "%.15g" f in if f = float_of_string s2 then s2 else Printf.sprintf "%.18g" f in valid_float_lexeme float_val haxe_3.2.1+dfsg.orig/dce.ml0000664000175000017500000006010312607337712015411 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Common open Type type dce = { com : context; full : bool; std_dirs : string list; debug : bool; follow_expr : dce -> texpr -> unit; mutable curclass : tclass; mutable added_fields : (tclass * tclass_field * bool) list; mutable marked_fields : tclass_field list; mutable marked_maybe_fields : tclass_field list; mutable t_stack : t list; mutable ts_stack : t list; mutable features : (string,(tclass * tclass_field * bool) list) Hashtbl.t; } (* checking *) (* check for @:keepSub metadata, which forces @:keep on child classes *) let rec super_forces_keep c = Meta.has Meta.KeepSub c.cl_meta || match c.cl_super with | Some (csup,_) -> super_forces_keep csup | _ -> false let is_std_file dce file = List.exists (ExtString.String.starts_with file) dce.std_dirs (* check if a class is kept entirely *) let keep_whole_class dce c = Meta.has Meta.Keep c.cl_meta || not (dce.full || is_std_file dce c.cl_module.m_extra.m_file || has_meta Meta.Dce c.cl_meta) || super_forces_keep c || (match c with | { cl_path = ([],("Math"|"Array"))} when dce.com.platform = Js -> false | { cl_extern = true } | { cl_path = ["flash";"_Boot"],"RealBoot" } -> true | { cl_path = [],"String" } | { cl_path = [],"Array" } -> not (dce.com.platform = Js) | _ -> false) let keep_whole_enum dce en = Meta.has Meta.Keep en.e_meta || not (dce.full || is_std_file dce en.e_module.m_extra.m_file || has_meta Meta.Dce en.e_meta) (* check if a field is kept *) let keep_field dce cf = Meta.has Meta.Keep cf.cf_meta || Meta.has Meta.Used cf.cf_meta || cf.cf_name = "__init__" || is_extern_field cf (* marking *) let rec check_feature dce s = try let l = Hashtbl.find dce.features s in List.iter (fun (c,cf,stat) -> mark_field dce c cf stat ) l; Hashtbl.remove dce.features s; with Not_found -> () and check_and_add_feature dce s = check_feature dce s; Common.add_feature dce.com s; (* mark a field as kept *) and mark_field dce c cf stat = let add cf = if not (Meta.has Meta.Used cf.cf_meta) then begin cf.cf_meta <- (Meta.Used,[],cf.cf_pos) :: cf.cf_meta; dce.added_fields <- (c,cf,stat) :: dce.added_fields; dce.marked_fields <- cf :: dce.marked_fields; check_feature dce (Printf.sprintf "%s.%s" (s_type_path c.cl_path) cf.cf_name); end in if cf.cf_name = "new" then begin let rec loop c = match c.cl_super with | None -> () | Some (csup,_) -> begin match csup.cl_constructor with | None -> () | Some cf -> add cf end; loop csup in loop c end; if not (PMap.mem cf.cf_name (if stat then c.cl_statics else c.cl_fields)) then begin match c.cl_super with | None -> add cf | Some (c,_) -> mark_field dce c cf stat end else add cf let rec update_marked_class_fields dce c = (* mark all :?used fields as surely :used now *) List.iter (fun cf -> if Meta.has Meta.MaybeUsed cf.cf_meta then mark_field dce c cf true ) c.cl_ordered_statics; List.iter (fun cf -> if Meta.has Meta.MaybeUsed cf.cf_meta then mark_field dce c cf false ) c.cl_ordered_fields; (* we always have to keep super classes and implemented interfaces *) (match c.cl_init with None -> () | Some init -> dce.follow_expr dce init); List.iter (fun (c,_) -> mark_class dce c) c.cl_implements; (match c.cl_super with None -> () | Some (csup,pl) -> mark_class dce csup) (* mark a class as kept. If the class has fields marked as @:?keep, make sure to keep them *) and mark_class dce c = if not (Meta.has Meta.Used c.cl_meta) then begin c.cl_meta <- (Meta.Used,[],c.cl_pos) :: c.cl_meta; check_feature dce (Printf.sprintf "%s.*" (s_type_path c.cl_path)); update_marked_class_fields dce c; end let rec mark_enum dce e = if not (Meta.has Meta.Used e.e_meta) then begin e.e_meta <- (Meta.Used,[],e.e_pos) :: e.e_meta; check_and_add_feature dce "has_enum"; check_feature dce (Printf.sprintf "%s.*" (s_type_path e.e_path)); PMap.iter (fun _ ef -> mark_t dce ef.ef_pos ef.ef_type) e.e_constrs; end and mark_abstract dce a = if not (Meta.has Meta.Used a.a_meta) then begin check_feature dce (Printf.sprintf "%s.*" (s_type_path a.a_path)); a.a_meta <- (Meta.Used,[],a.a_pos) :: a.a_meta end (* mark a type as kept *) and mark_t dce p t = if not (List.exists (fun t2 -> Type.fast_eq t t2) dce.t_stack) then begin dce.t_stack <- t :: dce.t_stack; begin match follow t with | TInst({cl_kind = KTypeParameter tl} as c,pl) -> if not (Meta.has Meta.Used c.cl_meta) then begin c.cl_meta <- (Meta.Used,[],c.cl_pos) :: c.cl_meta; List.iter (mark_t dce p) tl; end; List.iter (mark_t dce p) pl | TInst(c,pl) -> mark_class dce c; List.iter (mark_t dce p) pl | TFun(args,ret) -> List.iter (fun (_,_,t) -> mark_t dce p t) args; mark_t dce p ret | TEnum(e,pl) -> mark_enum dce e; List.iter (mark_t dce p) pl | TAbstract(a,pl) when Meta.has Meta.MultiType a.a_meta -> begin try mark_t dce p (snd (Codegen.AbstractCast.find_multitype_specialization dce.com a pl p)) with Typecore.Error _ -> () end | TAbstract(a,pl) -> mark_abstract dce a; List.iter (mark_t dce p) pl; if not (Meta.has Meta.CoreType a.a_meta) then mark_t dce p (Abstract.get_underlying_type a pl) | TLazy _ | TDynamic _ | TType _ | TAnon _ | TMono _ -> () end; dce.t_stack <- List.tl dce.t_stack end let mark_mt dce mt = match mt with | TClassDecl c -> mark_class dce c; | TEnumDecl e -> mark_enum dce e | TAbstractDecl a -> (* abstract 'feature' is defined as the abstract type beeing used as a value, not as a type *) if not (Meta.has Meta.ValueUsed a.a_meta) then a.a_meta <- (Meta.ValueUsed,[],a.a_pos) :: a.a_meta; mark_abstract dce a | TTypeDecl _ -> () (* find all dependent fields by checking implementing/subclassing types *) let rec mark_dependent_fields dce csup n stat = List.iter (fun mt -> match mt with | TClassDecl c when is_parent csup c -> let rec loop c = (try let cf = PMap.find n (if stat then c.cl_statics else c.cl_fields) in (* if it's clear that the class is kept, the field has to be kept as well. This is also true for extern interfaces because we cannot remove fields from them *) if Meta.has Meta.Used c.cl_meta || (csup.cl_interface && csup.cl_extern) then mark_field dce c cf stat (* otherwise it might be kept if the class is kept later, so mark it as :?used *) else if not (Meta.has Meta.MaybeUsed cf.cf_meta) then begin cf.cf_meta <- (Meta.MaybeUsed,[],cf.cf_pos) :: cf.cf_meta; dce.marked_maybe_fields <- cf :: dce.marked_maybe_fields; end with Not_found -> (* if the field is not present on current class, it might come from a base class *) (match c.cl_super with None -> () | Some (csup,_) -> loop csup)) in loop c | _ -> () ) dce.com.types (* expr and field evaluation *) let opt f e = match e with None -> () | Some e -> f e let rec to_string dce t = match t with | TInst(c,tl) -> field dce c "toString" false; | TType(tt,tl) -> if not (List.exists (fun t2 -> Type.fast_eq t t2) dce.ts_stack) then begin dce.ts_stack <- t :: dce.ts_stack; to_string dce (apply_params tt.t_params tl tt.t_type) end | TAbstract({a_impl = Some c} as a,tl) -> if Meta.has Meta.CoreType a.a_meta then field dce c "toString" false else to_string dce (Abstract.get_underlying_type a tl) | TMono r -> (match !r with | Some t -> to_string dce t | _ -> ()) | TLazy f -> to_string dce (!f()) | TDynamic t -> if t == t_dynamic then () else to_string dce t | TEnum _ | TFun _ | TAnon _ | TAbstract({a_impl = None},_) -> (* if we to_string these it does not imply that we need all its sub-types *) () and field dce c n stat = let find_field n = if n = "new" then match c.cl_constructor with | None -> raise Not_found | Some cf -> cf else PMap.find n (if stat then c.cl_statics else c.cl_fields) in (try let cf = find_field n in mark_field dce c cf stat; with Not_found -> try if c.cl_interface then begin let rec loop cl = match cl with | [] -> raise Not_found | (c,_) :: cl -> try field dce c n stat with Not_found -> loop cl in loop c.cl_implements end else match c.cl_super with Some (csup,_) -> field dce csup n stat | None -> raise Not_found with Not_found -> try match c.cl_kind with | KTypeParameter tl -> let rec loop tl = match tl with | [] -> raise Not_found | TInst(c,_) :: cl -> (try field dce c n stat with Not_found -> loop cl) | t :: tl -> loop tl in loop tl | _ -> raise Not_found with Not_found -> if dce.debug then prerr_endline ("[DCE] Field " ^ n ^ " not found on " ^ (s_type_path c.cl_path)) else ()) and mark_directly_used_class c = if not (Meta.has Meta.DirectlyUsed c.cl_meta) then c.cl_meta <- (Meta.DirectlyUsed,[],c.cl_pos) :: c.cl_meta and mark_directly_used_enum e = if not (Meta.has Meta.DirectlyUsed e.e_meta) then e.e_meta <- (Meta.DirectlyUsed,[],e.e_pos) :: e.e_meta and mark_directly_used_mt mt = match mt with | TClassDecl c -> mark_directly_used_class c | TEnumDecl e -> mark_directly_used_enum e | _ -> () and check_dynamic_write dce fa = let n = field_name fa in check_and_add_feature dce ("dynamic_write"); check_and_add_feature dce ("dynamic_write." ^ n) and check_anon_optional_write dce fa = let n = field_name fa in check_and_add_feature dce ("anon_optional_write"); check_and_add_feature dce ("anon_optional_write." ^ n) and check_anon_write dce fa = let n = field_name fa in check_and_add_feature dce ("anon_write"); check_and_add_feature dce ("anon_write." ^ n) and is_array t = match follow t with | TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) -> is_array (Abstract.get_underlying_type a tl) | TInst({ cl_path = ([], "Array")},_) -> true | _ -> false and is_dynamic t = match follow t with | TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) -> is_dynamic (Abstract.get_underlying_type a tl) | TDynamic _ -> true | _ -> false and is_string t = match follow t with | TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) -> is_string (Abstract.get_underlying_type a tl) | TInst( { cl_path = ([], "String")}, _) -> true | _ -> false and is_const_string e = match e.eexpr with | TConst(TString(_)) -> true | _ -> false and expr dce e = mark_t dce e.epos e.etype; match e.eexpr with | TNew(c,pl,el) -> mark_class dce c; mark_directly_used_class c; field dce c "new" false; List.iter (expr dce) el; List.iter (mark_t dce e.epos) pl; | TVar (v,e1) -> opt (expr dce) e1; mark_t dce e.epos v.v_type; | TCast(e, Some mt) -> check_feature dce "typed_cast"; mark_mt dce mt; mark_directly_used_mt mt; expr dce e; | TObjectDecl(vl) -> check_and_add_feature dce "has_anon"; List.iter (fun (_,e) -> expr dce e) vl; | TTypeExpr mt -> mark_mt dce mt; mark_directly_used_mt mt; | TTry(e, vl) -> expr dce e; List.iter (fun (v,e) -> if v.v_type != t_dynamic then check_feature dce "typed_catch"; expr dce e; mark_t dce e.epos v.v_type; ) vl; | TCall ({eexpr = TLocal ({v_name = "`trace"})},[p;{ eexpr = TObjectDecl(v)}]) -> check_and_add_feature dce "has_anon_trace"; List.iter (fun (_,e) -> expr dce e) v; expr dce p; | TCall ({eexpr = TLocal ({v_name = "__define_feature__"})},[{eexpr = TConst (TString ft)};e]) -> Hashtbl.replace dce.curclass.cl_module.m_extra.m_features ft true; check_feature dce ft; expr dce e; (* keep toString method when the class is argument to Std.string or haxe.Log.trace *) | TCall ({eexpr = TField({eexpr = TTypeExpr (TClassDecl ({cl_path = (["haxe"],"Log")} as c))},FStatic (_,{cf_name="trace"}))} as ef, ((e2 :: el) as args)) | TCall ({eexpr = TField({eexpr = TTypeExpr (TClassDecl ({cl_path = ([],"Std")} as c))},FStatic (_,{cf_name="string"}))} as ef, ((e2 :: el) as args)) -> mark_class dce c; to_string dce e2.etype; begin match el with | [{eexpr = TObjectDecl fl}] -> begin try begin match List.assoc "customParams" fl with | {eexpr = TArrayDecl el} -> List.iter (fun e -> to_string dce e.etype) el | _ -> () end with Not_found -> () end | _ -> () end; expr dce ef; List.iter (expr dce) args; | TCall ({eexpr = TConst TSuper} as e,el) -> mark_t dce e.epos e.etype; List.iter (expr dce) el; | TBinop(OpAdd,e1,e2) when is_dynamic e1.etype || is_dynamic e2.etype -> check_and_add_feature dce "add_dynamic"; expr dce e1; expr dce e2; | TBinop( (OpAdd | (OpAssignOp OpAdd)),e1,e2) when ((is_string e1.etype || is_string e2.etype) && not ( is_const_string e1 && is_const_string e2)) -> check_and_add_feature dce "unsafe_string_concat"; expr dce e1; expr dce e2; | TArray(({etype = TDynamic t} as e1),e2) when t == t_dynamic -> check_and_add_feature dce "dynamic_array_read"; expr dce e1; expr dce e2; | TBinop( (OpAssign | OpAssignOp _), ({eexpr = TArray({etype = TDynamic t},_)} as e1), e2) when t == t_dynamic -> check_and_add_feature dce "dynamic_array_write"; expr dce e1; expr dce e2; | TArray(({etype = t} as e1),e2) when is_array t -> check_and_add_feature dce "array_read"; expr dce e1; expr dce e2; | TBinop( (OpAssign | OpAssignOp _), ({eexpr = TArray({etype = t},_)} as e1), e2) when is_array t -> check_and_add_feature dce "array_write"; expr dce e1; expr dce e2; | TBinop(OpAssign,({eexpr = TField(_,(FDynamic _ as fa) )} as e1),e2) -> check_dynamic_write dce fa; expr dce e1; expr dce e2; | TBinop(OpAssign,({eexpr = TField(_,(FAnon cf as fa) )} as e1),e2) -> if Meta.has Meta.Optional cf.cf_meta then check_anon_optional_write dce fa else check_anon_write dce fa; expr dce e1; expr dce e2; | TBinop(OpAssignOp op,({eexpr = TField(_,(FDynamic _ as fa) )} as e1),e2) -> check_dynamic_write dce fa; expr dce e1; expr dce e2; | TBinop(OpAssignOp op,({eexpr = TField(_,(FAnon cf as fa) )} as e1),e2) -> if Meta.has Meta.Optional cf.cf_meta then check_anon_optional_write dce fa else check_anon_write dce fa; expr dce e1; expr dce e2; | TBinop(OpEq,({ etype = t1} as e1), ({ etype = t2} as e2) ) when is_dynamic t1 || is_dynamic t2 -> check_and_add_feature dce "dynamic_binop_=="; expr dce e1; expr dce e2; | TBinop(OpEq,({ etype = t1} as e1), ({ etype = t2} as e2) ) when is_dynamic t1 || is_dynamic t2 -> check_and_add_feature dce "dynamic_binop_!="; expr dce e1; expr dce e2; | TBinop(OpMod,e1,e2) -> check_and_add_feature dce "binop_%"; expr dce e1; expr dce e2; | TBinop(OpUShr,e1,e2) -> check_and_add_feature dce "binop_>>>"; expr dce e1; expr dce e2; | TField(e,fa) -> begin match fa with | FStatic(c,cf) -> mark_class dce c; mark_field dce c cf true; | FInstance(c,_,cf) -> mark_class dce c; mark_field dce c cf false; | _ -> let n = field_name fa in (match fa with | FAnon cf -> if Meta.has Meta.Optional cf.cf_meta then begin check_and_add_feature dce "anon_optional_read"; check_and_add_feature dce ("anon_optional_read." ^ n); end else begin check_and_add_feature dce "anon_read"; check_and_add_feature dce ("anon_read." ^ n); end | FDynamic _ -> check_and_add_feature dce "dynamic_read"; check_and_add_feature dce ("dynamic_read." ^ n); | _ -> ()); begin match follow e.etype with | TInst(c,_) -> mark_class dce c; field dce c n false; | TAnon a -> (match !(a.a_status) with | Statics c -> mark_class dce c; field dce c n true; | _ -> ()) | _ -> () end; end; expr dce e; | TThrow e -> check_and_add_feature dce "has_throw"; to_string dce e.etype; expr dce e | _ -> Type.iter (expr dce) e let fix_accessors com = List.iter (fun mt -> match mt with | (TClassDecl c) -> let rec has_accessor c n stat = PMap.mem n (if stat then c.cl_statics else c.cl_fields) || match c.cl_super with Some (csup,_) -> has_accessor csup n stat | None -> false in let check_prop stat cf = (match cf.cf_kind with | Var {v_read = AccCall; v_write = a} -> let s = "get_" ^ cf.cf_name in cf.cf_kind <- Var {v_read = if has_accessor c s stat then AccCall else AccNever; v_write = a} | _ -> ()); (match cf.cf_kind with | Var {v_write = AccCall; v_read = a} -> let s = "set_" ^ cf.cf_name in cf.cf_kind <- Var {v_write = if has_accessor c s stat then AccCall else AccNever; v_read = a} | _ -> ()) in List.iter (check_prop true) c.cl_ordered_statics; List.iter (check_prop false) c.cl_ordered_fields; | _ -> () ) com.types let run com main full = let dce = { com = com; full = full; std_dirs = if full then [] else List.map Common.unique_full_path com.std_path; debug = Common.defined com Define.DceDebug; added_fields = []; follow_expr = expr; marked_fields = []; marked_maybe_fields = []; t_stack = []; ts_stack = []; features = Hashtbl.create 0; curclass = null_class; } in begin match main with | Some {eexpr = TCall({eexpr = TField(e,(FStatic(c,cf)))},_)} -> cf.cf_meta <- (Meta.Keep,[],cf.cf_pos) :: cf.cf_meta | _ -> () end; List.iter (fun m -> List.iter (fun (s,v) -> if Hashtbl.mem dce.features s then Hashtbl.replace dce.features s (v :: Hashtbl.find dce.features s) else Hashtbl.add dce.features s [v] ) m.m_extra.m_if_feature; ) com.modules; (* first step: get all entry points, which is the main method and all class methods which are marked with @:keep *) List.iter (fun t -> match t with | TClassDecl c -> let keep_class = keep_whole_class dce c && (not c.cl_extern || c.cl_interface) in let loop stat cf = if keep_class || keep_field dce cf then mark_field dce c cf stat in List.iter (loop true) c.cl_ordered_statics; List.iter (loop false) c.cl_ordered_fields; begin match c.cl_constructor with | Some cf -> loop false cf | None -> () end; begin match c.cl_init with | Some e when keep_class || Meta.has Meta.KeepInit c.cl_meta -> (* create a fake field to deal with our internal logic (issue #3286) *) let cf = mk_field "__init__" e.etype e.epos in cf.cf_expr <- Some e; loop true cf | _ -> () end; | TEnumDecl en when keep_whole_enum dce en -> mark_enum dce en | _ -> () ) com.types; if dce.debug then begin List.iter (fun (c,cf,_) -> match cf.cf_expr with | None -> () | Some _ -> print_endline ("[DCE] Entry point: " ^ (s_type_path c.cl_path) ^ "." ^ cf.cf_name) ) dce.added_fields; end; (* second step: initiate DCE passes and keep going until no new fields were added *) let rec loop () = match dce.added_fields with | [] -> () | cfl -> dce.added_fields <- []; (* extend to dependent (= overriding/implementing) class fields *) List.iter (fun (c,cf,stat) -> mark_dependent_fields dce c cf.cf_name stat) cfl; (* mark fields as used *) List.iter (fun (c,cf,stat) -> if not (is_extern_field cf) then mark_class dce c; mark_field dce c cf stat; mark_t dce cf.cf_pos cf.cf_type ) cfl; (* follow expressions to new types/fields *) List.iter (fun (c,cf,_) -> dce.curclass <- c; opt (expr dce) cf.cf_expr; List.iter (fun cf -> if cf.cf_expr <> None then opt (expr dce) cf.cf_expr) cf.cf_overloads ) cfl; loop () in loop (); (* third step: filter types *) let rec loop acc types = match types with | (TClassDecl c) as mt :: l when keep_whole_class dce c -> loop (mt :: acc) l | (TClassDecl c) as mt :: l -> let check_property cf stat = let add_accessor_metadata cf = if not (Meta.has Meta.Accessor cf.cf_meta) then cf.cf_meta <- (Meta.Accessor,[],c.cl_pos) :: cf.cf_meta in begin match cf.cf_kind with | Var {v_read = AccCall} -> begin try add_accessor_metadata (PMap.find ("get_" ^ cf.cf_name) (if stat then c.cl_statics else c.cl_fields)) with Not_found -> () end | _ -> () end; begin match cf.cf_kind with | Var {v_write = AccCall} -> begin try add_accessor_metadata (PMap.find ("set_" ^ cf.cf_name) (if stat then c.cl_statics else c.cl_fields)) with Not_found -> () end | _ -> () end; in (* add :keep so subsequent filter calls do not process class fields again *) c.cl_meta <- (Meta.Keep,[],c.cl_pos) :: c.cl_meta; c.cl_ordered_statics <- List.filter (fun cf -> let b = keep_field dce cf in if not b then begin if dce.debug then print_endline ("[DCE] Removed field " ^ (s_type_path c.cl_path) ^ "." ^ (cf.cf_name)); check_property cf true; c.cl_statics <- PMap.remove cf.cf_name c.cl_statics; end; b ) c.cl_ordered_statics; c.cl_ordered_fields <- List.filter (fun cf -> let b = keep_field dce cf in if not b then begin if dce.debug then print_endline ("[DCE] Removed field " ^ (s_type_path c.cl_path) ^ "." ^ (cf.cf_name)); check_property cf false; c.cl_fields <- PMap.remove cf.cf_name c.cl_fields; end; b ) c.cl_ordered_fields; (match c.cl_constructor with Some cf when not (keep_field dce cf) -> c.cl_constructor <- None | _ -> ()); let inef cf = not (is_extern_field cf) in let has_non_extern_fields = List.exists inef c.cl_ordered_fields || List.exists inef c.cl_ordered_statics in (* we keep a class if it was used or has a used field *) if Meta.has Meta.Used c.cl_meta || has_non_extern_fields then loop (mt :: acc) l else begin (match c.cl_init with | Some f when Meta.has Meta.KeepInit c.cl_meta -> (* it means that we only need the __init__ block *) c.cl_extern <- true; loop (mt :: acc) l | _ -> if dce.debug then print_endline ("[DCE] Removed class " ^ (s_type_path c.cl_path)); loop acc l) end | (TEnumDecl en) as mt :: l when Meta.has Meta.Used en.e_meta || en.e_extern || keep_whole_enum dce en -> loop (mt :: acc) l | TEnumDecl e :: l -> if dce.debug then print_endline ("[DCE] Removed enum " ^ (s_type_path e.e_path)); loop acc l | mt :: l -> loop (mt :: acc) l | [] -> acc in com.types <- loop [] (List.rev com.types); (* extra step to adjust properties that had accessors removed (required for Php and Cpp) *) fix_accessors com; (* remove "override" from fields that do not override anything anymore *) List.iter (fun mt -> match mt with | TClassDecl c -> c.cl_overrides <- List.filter (fun s -> let rec loop c = match c.cl_super with | Some (csup,_) when PMap.mem s.cf_name csup.cl_fields -> true | Some (csup,_) -> loop csup | None -> false in loop c ) c.cl_overrides; | _ -> () ) com.types; (* mark extern classes as really used if they are extended by non-extern ones *) List.iter (function | TClassDecl ({cl_extern = false; cl_super = Some ({cl_extern = true} as csup, _)}) -> mark_directly_used_class csup | TClassDecl ({cl_extern = false} as c) when c.cl_implements <> [] -> List.iter (fun (iface,_) -> if (iface.cl_extern) then mark_directly_used_class iface) c.cl_implements; | _ -> () ) com.types; (* cleanup added fields metadata - compatibility with compilation server *) let rec remove_meta m = function | [] -> [] | (m2,_,_) :: l when m = m2 -> l | x :: l -> x :: remove_meta m l in List.iter (fun cf -> cf.cf_meta <- remove_meta Meta.Used cf.cf_meta) dce.marked_fields; List.iter (fun cf -> cf.cf_meta <- remove_meta Meta.MaybeUsed cf.cf_meta) dce.marked_maybe_fields; haxe_3.2.1+dfsg.orig/extra/CHANGES.txt0000664000175000017500000022140212607337712017261 0ustar andyandy000000000000002015-10-11: 3.2.1 Bugfixes: cs/java : fixed `-dce no` issues cs/java : fixed how KExpr type parameters are generated cs : fixed enum creation by reflection problem cpp : do not rely in reflection to make interfaces work for non-first interface parents cpp : fixed setting of static variables via reflection when class has no member variables cpp : make sure StringMap's h field is kept if we use StringMap js : Avoid the use of `eval`/`Function` to get the top-level defined type/var to not break ContentSecurityPolicy 2015-05-12: 3.2.0 New features: all : added @:noPrivateAccess to re-enable access restrictions within @:privateAccess cpp : some support for @:nativeGen metadata Bugfixes: all : fixed detection of @:generic classes with constructor constraints all : fixed variable initialization check issue in loop condition all : fixed pattern matching on @:enum abstracts via field access (#4084) all : fixed missing implicit casts in Map literals (#4100) all : fixed various minor issues in haxe.xml.Parser all : fixed class path issue when HAXE_STD_PATH is set (#4163) js : fixed DCE issue related to printing enums (#4197) js : fixed various issues with the new Bytes implementation php : fixed EOF handling in FileInput.readByte (#4082) cs/java : fixed Math.fround implementation (#4177) cs/java : fixed some cases of Std.parseInt failing (#4132) cpp : fixed compilation without -main (#4199) General improvements and optimizations: all : --macro keep no longer causes types to be included for compilation php : support interpolation in __php__ code js : added variable number of arguments support in js.html.* classes js : refined new HTML externs Macro features and changes: macro : [breaking] synced FClosure and FInstance with the compiler updates 2015-03-15: 3.2.0-RC1 This release removes support for Flash 8 target New features: all : added --display mode for toplevel completion all : added --display mode for position and usage information all : allowed @:callable on abstracts to forward calls to their underlying type all : allowed pattern matching on getters all : allowed @:native on class fields all : added static analyzer with constant propagation all : added Haxe-based XML implementation python : added python target flash : flash player 12-14 support js : added @:jsRequire and js.Lib.require js : support haxe.CallStack.exceptionStack cs : added @:bridgeProperties cs : added -D erase_generics cs : added -D dll_import to import haxe-generated dlls java/cs : added `sys.db` package java/cs : clean unused files in output folder, unless `-D keep_old_output` is defined java/cs : added `-c-arg` to add C#/Java compiler arguments cpp : inititial implementation of cppia scripting Bugfixes: all : fixed nullability of abstracts over functions all : fixed some equality checks between UInt and Int all : fixed rare issue with abstract casts all : fixed some internal code which relied on unspecified evaluation order all : fixed exhaustiveness checks involving guards all : fixed issue involving recursively constrained type parameters and @:generic all : fixed type inference issue in map literals all : fixed type inference issue when calling abstract method from within the abstract all : fixed several abstract variance issues all : fixed DCE issues with interface properties all : fixed variance issue with function variables and dynamic methods on interfaces all : fixed pattern matching on empty arrays that are typed as Dynamic all : fixed various @:generic issues all : fixed default cases on @:enum abstract being omitted all : fixed various expression positions all : disallowed break/continue in closures in loops all : disallowed inline functions in value places all : fixed parsing of cast followed by parentheses all : fixed resource naming in case of invalid file system characters all : fixed issue with inlined array declarations with field access cpp : fixed issue with the side-effect handler cpp : fixed issue with NativeArray in --no-inline mode php : fixed issue with invalid references for closures in for-loops php : fixed Reflect.compare and string comparison for numeric strings cs/java : fixed various issues with -java-lib and -net-lib. cs/java : added @:libType to skip checking on -java-lib / -net-lib types cs/java : compilation server now works with C#/Java [experimental support] cs : fixed Type.enumIndex / switch on C# native enums cs : fixed reflection on COM types java : fixed sys.net.Socket server implementation spod : various fixes - working now on cpp, java, neko, php and c# cpp : improved boot order, with enums constants first General improvements and optimizations: all : disallowed using `super` in value positions all : check exhaustiveness of explicit Null types all : resolve unqualified identifiers to @:enum abstract constructors all : determine @:generic type parameters from constructor call if possible all : properly disallowed field redefinition in extending interface all : properly disallowed leading zeroes for Int and Float literals all : allowed variance on interface variables all : allowed pattern matching on arrays if they are typed as Dynamic all : allowed pattern matching on fields of parent classes all : -D doc-gen no longer implies -dce no all : allowed matching against null on any enum instance flash/js: optimized haxe.ds.StringMap neko : create output directory if it does not exist js : inline Math methods and fields cs/java : optimized Reflect.fields on dynamic structures cs/java : haxe will now clear output directory of old files (use -D keep-old-output to keep them) cs : optimized field lookup structure cs : optimized casting of parametrized types cs : beautify c# code output cs : added `cs.Flags` to manipulate C# enums that can be also flags xml : improved documentation generation and fixed missing entity escaping cpp : property access via Dynamic variables now requires property to be declared with @:nativeProperty cpp : allow injection of code from relative paths using @:sourceFile and @:cppInclude cpp : stronger typing of native functions via cpp.Function + cpp.Callable cpp : moved 'Class' implementation to hx namespace to improve objective C interaction cpp : added file_extension define to change the output filename extension (eg, ".mm") cpp : added pre-calculated hashes to string constants to allow faster lookups cpp : map implementation allows strongly typed interactions in some cases (avoids boxing) cpp : added native WeakMap implementation cpp : put each resource into own cpp file to allow more data/smaller files Standard Library: all : added typed arrays to haxe.io package all : added haxe.ds.Either all : added haxe.extern.Rest type for representing "rest" arguments in extern method signatures all : added haxe.extern.EitherType abstract type for dealing with externs for dynamic targets all : added haxe.DynamicAccess type for working with dynamic anonymous structures using a Map-like interface all : [breaking] changed haxe.ds.Vector.get to return T instead of Null all : added haxe.macro.Compiler.addGlobalMetadata all : changed haxe.Int64 to be an abstract type instead of a class js : updated HTML externs Macro features and changes: macro : added Context.getLocalTVars macro : added TypedExprTools.iter macro : added Context.getCallArguments macro : changed @:genericBuild macros to prefer ComplexType returns macro : [breaking] extended TAnonymous structures now have AExtend status instead of AClosed macro : added Context.getDefines macro : fixed file_seek from end (position was inversed) macro : added Context.storeTypedExpr macro : allowed type name reification Deprecations: all : deprecated structurally extending classes and interfaces sys : Sys.command shell special chars (&|<>#;*?(){}$) are now properly escaped java/cs : Lib.nativeType is now renamed to Lib.getNativeType 2014-04-13: 3.1.3 Bugfixes: all : fixed handling of abstract variance flash : ensure correct endianess in haxe.io.BytesBuffer cpp : fixed issue involving class paths with spaces php : fixed >>> macro : fixed haxe.macro.Compiler.keep General improvements and optimizations: all : give @:deprecated warnings by default, allow -D no-deprecation-warnings cpp : optimized Vector implementation Standard Library: all : renamed Bytes.readDouble/Float to getDouble/Float to avoid inheritance issues all : deprecated Bytes.readString in favor of getString all : added pretty-printing to haxe.format.JsonPrinter (and haxe.Json) 2014-03-29: 3.1.2 Bugfixes: all : disallowed spaces between >>, >>>, >>= and >>>= all : fix branching issue when switching on Dynamic values with only one case all : added missing abstract cast call when checking for equality all : fixed member fields initializations on parent classes that have no constructor all : fixed toString usage of abstracts which are argument to Std.string flash : avoid rare FP 12 PPAPI JIT crash cpp : fixed bug in side-effect handler which caused incorrect behavior of while loops js : fixed missing print function for enum values with DCE macro : make sure member field initializations are respected General improvements and optimizations: all : cached file exist checks to speed up compilations with a lot of class paths all : improved completion related to super class fields all : allowed iterating on abstract which have get_length and @:arrayAccess fields js : improved Type.allEnums implementation to avoid issues with obfuscation Standard Library: all : added haxe.io.Bytes.readDouble/Float all : added haxe.io.BytesBuffer.addString/Float/Double 2014-03-15: 3.1.1 New features: all : added -D deprecation-warnings all : allowed \u escape sequences in strings cs : implemented haxe.CallStack Bugfixes: all : fixed wrong handling of "" and null in haxe.io.Path.join all : fixed invalid cast-to-self generation on some abstracts all : removed @:to Dynamic from UInt to avoid issues in the Map selection algorithm all : fixed various issues with UInt all : fixed position setter in haxe.io.BytesInput all : fixed various issues with member/static extension macros flash : fixed invalid override involving single-constraint type parameters flash8 : fixed various bugs js : fixed a problem with Std.string(null) being optimized incorrectly js : fixed custom generators cpp : dealt with string literals that are too long for MSVC cs : fixed various issues with -net-lib 2014-03-04: 3.1.0 New features: all : allowed null-patterns in pattern matching all : allowed extractors in pattern matching using => syntax all : allowed extending generic type parameters all : allowed (expr : type) syntax (ECheckType) all : allowed @:enum and @:forward on abstracts all : allowed using abstracts as static extension all : allowed Class.new all : added EnumValue.match all : allow multiple structural extension using { > T1, > T2, fields } all : inline array and structure declarations if possible cs : added -net-lib cs : support for native delegates cs : support for attributes cs : support for events Standard Library: all : support abstract types in haxe.rtti.XmlParser all : added Std.instance all : added length field to BytesBuffer, BytesOutput, BytesInput and StringBuf all : added UInt for all targets all : added Array.indexOf and Array.lastIndexOf all : added haxe.xml.Printer all : added haxe.Int32 as abstract type all : added haxe.format.JsonParser/Printer General improvements and optimizations: all : optimized pattern matching output all : allowed recursive type parameter constraints all : improved support of custom @:coreType abstracts all : evaluate conditional expressions in @:require all : improved inline constructors by detecting more cases where it can be applied js : improved inlining js : always use JSON extern (compile with -D old-browser to disable) js : added -D js-flatten js : added -D js-es5 cpp : improved side-effect detection Bugfixes: all : inlining a parameter which has side effects will not remove it even if not used all : implemented constraints check on enum and enum field type parameters all : fixed memory leak in compilation server and optimized caching in general all : fixed issue with invalid lowercase class name in Windows completion flash : fixed font embedding with UTF8 chars flash : give error if non-nullable basic types are skipped in a call flash : give error if assigned parent class field values would be overwritten by super() Macro features and changes: macro : add Context.onAfterGenerate macro : add Context.typeExpr macro : add Context.getExpectedType macro : add ExprTools.getValue macro : allowed $v{(c:Float|Int|String)} macro : resolve error line number in external files macro : rewrote macros used as static extension macro : exposed typed AST macro : added @:genericBuild macro : [breaking] first argument of ComplexType.TExtend is now Array instead of TypePath macro : improved expression printing 2013-09-25: 3.0.1 all : minor DCE bug fix 2013-05-25: 3.0.0 all : added haxe.ds.BalancedTree all : added haxe.ds.EnumValueMap all : allow enum constructors as keys to Map all : haxe.ds.ObjectMap is now correctly constrained on all targets all : preliminary support of -D display-mode=usage|position|metadata all : improved pattern matcher error messages all : allow inline constructors all : allow abstract member macros (not for @:op, @:arrayAccess, @:from, @:to) all : allow abstract type parameter variance all : do not generate hidden null on if without else macro : made abstract structure available 2013-05-08: 3.0.0-RC2 all : improved abstract support all : renamed HAXE_LIBRARY_PATH to HAXE_STD_PATH all : added inlinable constructors all : renamed haxe.ds.FastCell to GenericCell all : fixed >= operator in #if conditionals all : improved completion support for Unknown results all : allowed [] access for Map all : added haxe.ds.WeakMap (not yet supported on all platforms) all : all trace parameters are now printed by default all : added --help-metas all : improved completion all : improved pattern matching variable capture and GADT support js : cached $bind results (unique closure creation per instance) js : removed --js-modern (now as default) cpp : added socket.setFastSend flash : update player 11.7 api flash : improved @:font, @:sound and @:bitmap support neko/java/cs : improved Array performances when growing with [] java : added -java-lib support java : added sys.net package implementation (alpha) java : complete java std library through hxjava haxelib java/cs : added support for overloaded function declarations java/cs : overload selection algorithm cs : operator overloading is now accessible through Haxe cs : source mapping; can be disabled with -D real_position as3 : fixed rare syntax ambiguity php : removed initialization of some inline fields macro : fixed several issues with 'using' a macro function macro : improved expression printing 2013-02-24: 3.0.0-RC flash : updated player 11.4 api all : allowed named functions as r-value all : fixed using + overload usage all : allow any type constraint for type parameters all : make property type optional (when a initial value is set) all : Std.random(x) when x <= 0 is now always 0 spod : added serialized data with SData all : Dispatcher will now throw DETooManyValues all : speed up neko compilation by using native compiler all : allow @:generic on functions all : allow constructing generic type parameters swf : added support for SWC files in -swf-lib macro : added Context.onTypeNotFound callback for unresolved types js : no JS embed as default (use -D embed-js instead) all : added abstract types (Int/Float/Bool/Void/Class/Enum/EnumValue) all : added --help-defines all : changed DCE with three modes : std(default), no and full all : Haxe3 packages changes (see http://haxe.org/manual/haxe3) all : Removed haxe.Int32, haxe.Firebug, haxe.TimerQueue all : added -D key=value and #if (key >= value) operations all : StringTools.htmlEscape/unescape nows handle "/" and '/' all : using and import must now appear before any type declaration in a file all : no longer create variable fields for pure getter/setter properties (unless @:isVar is used) all : use default get_prop/set_prop instead of custom getter/setter names for properties js : added JQuery.delegateTarget macro : removed EType and CType, added EMeta, modified ESwitch all : allow @metadata expr all : replaced haxe.rtti.Generic interface with @:generic metadata all : no longer infer arrays of mixed types as Array all : all type/import/enum constructor resolution now follows the shadowing principle (latest has priority) all : added EReg.matchSub, renamed EReg.customReplace to map all : no longer allow initialization of extern non-inline variables swf : fixed out of memory errors on very large swf-lib files swf : added -D swf_preloader_frame, swf_gpu, swf_direct_blit swf : added -D swf_script_timeout=seconds, swf_debug_password=password, swf_metadata=file swf : added -swf-lib-extern swf : added @:font support (beta) all : added GADT support in enums all : added pattern matching (beta) all : changed callback(func, args) to func.bind(args) macro : added haxe.macro.ExprTools/ComplexTypeTools/TypeTools macro : changed reification syntax to ${expr}, $a{array}, $p{path}, $v{value} macro : allow macro @:pos(pos-expr) to inject positions for reification all : added array comprehension flash : Vector.length is now Int instead of UInt all : moved haxe.BaseCode, haxe.Md5 and haxe.SHA1 to haxe.crypto package all : disallow Void variables and arguments (still allow S -> T to S -> Void) all : added Array.map/filter all : added spell check suggestions for enum constructors and fields all : added opaque abstract(T) types all : allow operator overloading on opaque abstract types all : renamed IntIter to IntIterator all : added Map all : added haxe.ds with StringMap, IntMap, HashMap, ObjectMap, Vector, GenericStack all : removed Hash, IntHash and haxe.FastList in favor of the types in haxe.ds all : haxe.xml.Parser now handles entities consistently across platforms all : renamed HAXE_LIBRARY_PATH environment variable to HAXE_STD_PATH 2012-07-16: 2.10 java/cs : added two new targets (beta) all : fixed List and Null for first, last, pop js : added js.Lib.debug() flash : fixed Xml.parent() when no parent flash : fixed haxe.io.Bytes.blit when len=0 js/php/flash8 : fixed haxe.Int32.mul overflow on 52 bits js : fixed haxe.Utf8 usage (static 'length' issue) all : does not allow overriding var/prop flash : removed wrapping for Xml nodes, use instead specific compare when comparing two typed nodes js : use new haxe.xml.Parser (faster, not based on Regexp) flash : fixed completion issue with for( x in Vector ) all : optimized Std.int(123) and Std.int(123.45) flash : bugfix for @:bitmap with 24-bits PNG (flash decode wrong colors) as3 : fixed EnumValue becomes Object js : removed js.Lib.isIE/isOpera (not complete, use js.JQuery.browser instead) all : function parameters are nullable if they are declared with '?' all : added support for finding common base types of multiple types (unify_min) for array, switch, if php : do not implement duplicate interfaces haxelib : added git support through haxelib git all : allow derived classes to widen method visibility macro : added haxe.macro.Context.getLocalMethod macro : improved support of "using" macro functions php : optimized Xml implementation php : fixed Reflect.get/setProperty not working on PHP < 5.3 all : support for callback(f, _, x) all : allow private access between classes that have a common base class all : added Output.writeFloat/Double and Input.readFloat/Double all : support for var:{x:Float} = { x = 1 } constant structure subtyping all : allow contravariant function arguments and covariant function returns in overrides macro : support for final Array argument as rest argument macro : use top-down inference on macro calls all : made "using" imply "import" all : made String concat more consistent across platforms (add Std.string wrappers) all : allow direct member variable/property and static property initialization js : greatly reduced amount of generated code by using smarter DCE php : made modulo operations more consistent all : allow local functions to have both type parameters and be inlined all : functions type parameters can be constraint (will be checked at end of compilation) macro : use NekoVM runtime for regexps, process and xml parsing flash : allow @:getter/@:setter in interfaces flash : added support for "arguments" in methods all : not used enums and inline var/methods are now removed by DCE all : allow @:overload to use type parameters and not-absolute type paths all : ensure that Std.string of arrays and enums are now consistent across platforms all : allow to inline functions containing other functions xml : added metadata output to xml generator macro : added macro and macro : reification all : renamed type(e) to $type(e) as3 : support for metadata and resources, and other fixes 2012-04-14: 2.09 all : optimized const == const and const != const (with different const types) all : add Type.allEnums(e) all : big improvements with completion speed and fixed many issues flash9 : fixed -D swfprotected with swc output neko : added ~ implementation js : upgraded jquery version, more api overloads sys : added "in" operator for spod macros, added relation access in expressions macro : added ECheckType macro : added TLazy for not-yet-typed class fields js/php/neko : added haxe.web.Request all : added Std.format js : trace() output fallback on console.log if no id="haxe:trace" all : ensure that Std.is(2.0,Int) returns true on all platforms js : replaced $closure by function.$bind + changes in output format all : allowed @:extern on static methods (no generate + no closure + force inlining) all : added documentation in --display infos + display overloads in completion js : removed --js-namespace, added $hxClasses flash : output traces to native trace() when using -D fdb or -D nativeTrace all : allowed abitrary string fields in anonymous objects all : allowed optional structure fields (for constant structs) all : allowed optional args in functions types (?Int -> Void) all : added Reflect.getProperty/setProperty (except flash8) all : added --wait and --cwd and --connect (parsed files and module caching) all : fixed completion in macros calls arguments all : fixed DCE removing empty but still used interfaces/superclasses all : added haxe.Utf8 (crossplatform) neko : Reflect now uses $fasthash (require neko 1.8.2) all : allow \uXXXX in regexp (although not supported everywhere) js : make difference between values and statements expressions in JSGenApi js : added source mapping with -debug (replace previous stack emulation) flash : added @:file("a.dat") class File extends flash.utils.ByteArray flash : added @:sound("file.wav|mp3") class S extends flash.media.Sound js : added --js-modern for wrapping output in a closure and ES5 strict mode all : null, true and false are now keywords all : neko.io.Path, cpp.io.Path and php.io.Path are now haxe.io.Path neko, cpp, php : added Sys class, sys.io and sys.net packages and "sys" define all : allow to access root package with std prefix (std.Type for example) all : added haxe.EnumFlags sys : io.File.getChar/stdin/stdout/stderr are now in Sys class cpp : Reflect.getField and Reflect.setField no longer call property functions. Use Reflect.getProperty and Refelect.setProperty instead. cpp : Default arguments now use Null for performance increase and interface compatibility cpp : Added metadata options for injecting native cpp code into headers, classes and functions php : added php.Lib.mail (hotfix) fixed bug in completion and disabled profiling on Linux (hotfix) fixed $ssize when doing new String(v) in neko (hotfix) fixed bug with properties in interfaces for Flash & PHP 2011-09-25: 2.08 js : added js.JQuery all : added @:overload js : upgraded js.SWFObject from 1.4.4 inlined to 1.5 embedded js : code generator beautify all : ensure that modifying returned Type.getEnumConstructs array does not affect enum all : allow macro typed parameters (other than Expr) flash : added flash11 apis neko : added support for https to haxe.Http (using hxssl library) all : added haxe.Int64 all : added haxe.Int32 isNeg,isZero,ucompare, fixed overflows for js/flash8/php all : bugfix when optimizing inlined immediate function call all : fixed "using" on macro function all : allowed member macros functions (called as static) neko : allowed serialization of haxe.Int32 (as Int) all : fixed invalid optimization of two constant numbers comparison flash8 : bugfix Std.parseInt with some hex values flash9 : added flash.utils.RegExp all : changed @:build behavior, now takes/returns a var with anonymous fields all : added @:native support for enums neko : changed the result of array-assign expression (was null) flash9 : no longer auto create enums from SWF classes (need explicit "enum" type patch) all : optimized variable tracking/renaming all : optimized macro engine (speed x2) all : added -D macrotimes support flash9 : store resources in bytes tag instead of bytecode all : allow $ prefixed identifiers (for macros usage only) all : allow to access modules subtype statics with pack.Mod.Type.value and fixed identifier resolution order flash9 : added @:bitmap("file") for simple embedding all : added haxe.web.Dispatch js : added js.Storage all : allow this + member variables access in local functions added untyped __this__ support and transition error all : added haxe.macro.MacroType neko : neko.Lib.serialize/unserialize now returns bytes neko : added sys.db package (crossplatform with -D spod_macro support) spod_macro now uses wrappers for Bytes (require neko 1.8.2) php : added --php-prefix for prefixing generated files and class names all : added type_expr_with_type enum support php/js : fixed adding 'null' to StringBuf all : added haxe.macro.Context.defineType 2011-01-30: 2.07 all : fixed completion support with --remap all : added macros, added --interp all : removed 'here' special identifier neko : fixed neko.Web.getParamsString() returning "null" instead of "" flash9 : fixed issue with @:bind flash9 : added some missing errors flash9 : fixed TypedDictionary.exists all : added @:build and @:autoBuild for enums and classes neko : Std.parseFloat now returns NaN with invalid string php: fixed Array.push must return the current length (issue 219) php: fixed EReg.replace (issue 194) php: FileSystem.readDirectory now skips '.' and '..' to be consistent with neko (issue 226) flash9 : add trace text on stage (always over current and subclips) flash9 : delay SWF initialization until it's added on stage and stageWidth > 0 (this can be disabled with -D dontWaitStage) all : added haxe.Timer.measure all : added Lambda.indexOf and Lambda.concat all : no longer allow inline vars as metadata values neko : added getFieldsNames to neko.db.ResultSet (supported in Neko 1.8.2 mysql driver) all : added --macro and haxe.macro.Compiler all : allow macro type patches flash9 : changed --gen-hx-classes implementation now use 'haxe -swf-lib lib.swf --gen-hx-classes' instead flash9 : added @:getter and @:setter all : added @:require flash9 : moved vector utils functions from flash.Lib to flash.Vector flash9 : added support for FP 10.1 and 10.2 flash9 : added @:meta(Meta(k="v")) support all : improved #if support (fixed ! precedence) all : lookup unqualified types in all package hierarchy and not only in current package flash : set default flash version to 10 (-swf9 deprecated, use -swf-version 8 for avm1) php : added --php-lib to allow to rename the destination path of the generated lib all : added --dead-code-elimination, removes unused functions from the output (beta feature could not make in the final release) all : added @:keep to prevent --dead-code-elimination of class/method flash9 : fixed issues with loading a Haxe SWF (boot_XXXX class extends flash.Boot) all : allow to inline override methods (if the superclass method is not inlined already) all : fixed escape sequences in literal regular expressions flash9 : fixed Xml.setNodeValue all : removed -excluded, replaced by --macro excludeFile('filename') all : added --macro exclude('package') and --macro include('package') all : importing a typedef of an enum allow to access its constructors all : removed String.cca (replaced by StringTools.fastCodeAt + StringTools.isEOF) flash9 : fixed use of default values when null is passed for nullable basic types all : fixed issues with inlining and class/function type parameters all : big speedup for compiler internal completion all : added --macro keepClass('classname') flash9 : fixed Xml.nodeValue for comments (does not include ) all : added named local functions (allow self-recursion) all : use left-assoc for (==,!=,>,>=,<,<=)(==,!=,>,>=,<,<=) (&&)(&&) and (||)(||) all : give prefix unary operators higher priority than ?: php : fixed XML parsing cpp : many fixes 2010-08-14: 2.06 neko : change serializer to be able to handle instances of basic classes from other modules js : add Document.createTextNode all : bugfix with inline when modifying var with same name as one of current local flash9 : classes implementing ArrayAccess are now dynamic (including TypedDictionary) all : allow "using" on typedefs as3 : minor fixes in genas3 and --gen-hx-classes as3 : fix with readonly/writeonly properties accesses flash9 : list native getter/setters in Type API class/instance fields all : make haxe.rtti.Generic typing lazy (fix for self-recursion) all : allow haxe.rtti.Generic + inheritance all : added resource size limit to 12MB (ocaml max_string_size is 16MB + b64) flash : changes in swf handling to work with >16MB swfs flash9 : only init dynamic methods if not already defined (in subclass) std : added haxe.SHA1 compiler : added TCast, allow cast optimization on flash9/cpp as3 : fixed Std.__init__ generating 'null' compiler : fixed -no-opt flash : allow several -swf-lib no longer support automatic creation of classes for f8 swfs in f9 mode classes defined in f9 swf are not redefinable in Haxe code (use extern) flash9 : allow direct access and completion with classes defined in -swf-lib's flash9 : remove imported libraries debug infos when not compiled with -debug all : only display errors with --display if no completion matched all : some completion related errors fixed flash9 : added @:bind support all : fixed StringTools.hex with negative numbers flash9 : fixed Type.typeof(1<<28) was TFloat flash9 : use flash.XML parser for Xml class implementation neko : fixed Array.splice (was not setting null at end of array) neko : rewrote Array class using neko.NativeArray all : core classes implementation are now in std/(platform)/_std all : added @:final support all : added haxe.rtti.Meta flash9 : added flash.desktop.Clipboard* classes (added in flash10) as3 : fixed Date.toString issue in flash.Boot (now use .toStringHX instead) this will only work if .toString called explicitely on Date class all : only allow "using" on Dynamic if first parameter is Dynamic php : haxe.Http now supports Https connections when OpenSSL extension is enabled (issue 143) php : fixed enum constructors sequence (issue 142) php : added error message when using 2 fields with different cases in the same class/enum php : fixed field declaration for properties with getter and setter (issue 124) php : fixed comparison issues between strings (issue 132) php : enhanced FileInput.readLine using native fgets function (issue 103) flash9 : renamed flash.Error to flash.errors.Error php : removed eval() everywhere and simplified _hx_lambda php : fixed return type for Std.string() with integers and floats php : fixed php.Lib.rethrow all : added custom Haxe serialization php : aligned php.Web.parseMultipart signature with neko implementation cpp : Added source location and stack dump for errors in debug mode cpp : Remapped more keywords cpp : Added templated fast iterator code for arrays and FastLists cpp : Added option for tracing GC references in debug mode cpp : Switch the native string implementation from wchar_t to utf8 - for regex speed cpp : Added extra "()" to ensure correct order of operations cpp : Fixed various bugs for unusual (and not so unusual) language constructs cpp : Fixed order of enum generation from index cpp : Added __unsafe_get and __unsafe_set to Array as possible optimizations cpp : Default to mult-thread compiling on windows for cl version >= 14 cpp : Seed Math.random cpp : Use strftime for Dates cpp : Fix socket sellect passing _s cpp : Throw error when match count does not match regex cpp : Improve register capture in GC cpp : Fix Dynamic interger compare cpp : Implement makeVarArgs cpp : Fix toString for nulls in Enums and Arrays cpp : Added initial Android support cpp : Move initializers to entry functions in standard ndlls. cpp : Changes some CFFI register funtions to char*, from wchar_t* cpp : Added some initial support for v8 script target cpp : Use non-recursive GC marking to avoid overflow in big lists cpp : Added __hxcpp_obj_id 2010-01-09: 2.05 js : added js.Scroll js : package names are now checked at runtime to avoid clashes with existing libs js : added --js-namespace to create a namespace for types that are defined in the root all : updated xml output and html doc - add inline, override, dynamic functions support all : added error when comparing enum with arguments all : optimize constant equality for enums flash9 : fixed verify error with inline + null type flash9 : bugfix when overriding/implementing an method with an applied type parameter php : fixed issues with classes that implement Dynamic all : ignore #! line at beginning of the hx file haxelib : added tags, added documentation flash8 : don't use b64 encoding for text ressources php : fixed bug in Hash.exists for null values and Reflect.callMethod js/flash9 : throw exception in Xml.parse when unclosed node all : improve return type progagation in inlined expression (fix some VerifyErrors) all : optimize {const} into const all : added structure / Dynamic subtyping all : fixed List.map2 error when inline + optional args flash9 : encode all ISO constant strings into UTF8 at compilation time all : allow hxml with only -cmd statements spod : moved Manager.addQuote to Connection.addValue flash9 : removed .iterator() from Vector (not implementable) all : fixed haxe.rtti.Generic on interfaces php : fixed issue with Reflect.callMethod php : fixed issue with PHP reserved word used in callbacks all : bugfix with non-constant enums in switches flash9 : fix for interfaces (use namespace) all : "using" now works for identifiers in member methods flash9 : bugfix with switch on some big integers all : bugfix when optimizing (function(x) return x)(x) neko : improved speed of Xml.toString() all : added -D dump (for debugging purposes) neko : added neko.Web.isTora php : added php.db.PDO (php.db.Sqlite is now deprecated) php : fixed bug in Type.getClassFields() that reported duplicated entries php : fixed errror in XML error reporting all : allow sub-types declarations everywhere (pack.Type.Sub) all : added completion for sub-types declarations all : improved completion with lambda function as3 : several generation fixes all : bugfix haxe.rtti.Generic on private class php/js/cpp : sanitize binary expressions to prevent inlining errors spod : remove object from cache when deleted 2009-07-26: 2.04 flash9 : fixed get_full_path error with -D fdb js : fixed Array.remove on IE flash8 : removed extra empty AS3 tag (causing some issue with F8 loadMovie) improved speed of Bytes unserializing (no need for BytesBuffer) flash9 : bugfix, Null was generating dynamic code flash9 : added error message in flash.Vector if used without flash 10 flash9 : fixed some "never" property access issues all : added "never" property access support for all platforms js : small syntax fix with value-blocks js : fixed Type.enumEq with null values js/flash8 : use &0xFF in haxe.io.Bytes.set flash9 : fixed switch on Null verify error flash9 : fixes related to UInt type + error when using Int/UInt comparison as3 : improved Vector support, inline flash.Lib.as as3 : bugfix with skip_constructor as3 : added Enum.__constructs__ (allow Type.getEnumConstructs) as3 : make all constructor parameters optional (allow Type.createEmptyInstance) as3 : bugfix with property access inside setter (stack overflow) all : Enum is now Enum all : added Type.createEnumIndex all : forbid same name for static+instance field (not supported on several platforms) all : renamed haxe.Http.request to "requestUrl" all : renamed neko.zip.Compress/Uncompress.run to "execute" spod : fix very rare issue with relations and transactions compiler : added TClosure - optimize closure creation and ease code generation cpp : added CPP platform all : added 'using' syntax neko : added 'domains' optional param to ThreadRemotingServer to answer policy-file-request php : fixed php.db.Mysql so that getResult is consistent with Neko behavior php : fixed __toString for anonymouse objects php : fixed bug in overridden dynamic functions php : fixed round to be consistent with other platforms php : fixed bug concatenating two dynamic variables php : php.Lib.rethrow now works as expected flash9 : fixed bug with SWC output and recursive types flash8 : fixed inversed arguments in __new__ neko : added neko.net.Socket.setFastSend php: fixed String.charCodeAt php: minor optimization (removed foreach from std code) php: implemented haxe.Stack php: changed exception handler to use Haxe call stack php: changed special vars to use the '\xBB' prefix instead of __ php: fixed use of reserved keywords for var names php: List iterator is now class based (faster) php: fixed behavior of class variables having assigned functions php: fixed php.db.Manager (was uncorrectly removing superclass fields) php: added support for native Iterator and IteratorAggregate interfaces all : added --display classes and --display keywords all : fixed issue with optional parameters in inline functions all : allow implementing interfaces with inline methods all : enable inlining for getter/setter/iterator/resolve/using 2009-03-22: 2.03 optimized Type.enumEq : use index instead of tag comparison for neko/flash9/php bugfix for flash.display.BitmapDataChannel and GraphicsPathCommand (allow inline static) resolve environment variable in -cmd commands added flash.Vector.indexOf and lastIndexOf fixed bug in interfaces that define the method toString (Haxe/PHP) fixed bug in haxe.io.BytesInput.readBytes in Flash9 (was throwing Eof if full buffer can't be readed) fixed implements/extends special classes when they are imported StringBuf now uses an array for JS implementation (around same on FF, faster on IE) fixed assignment of field length in anonym objects (Haxe/PHP) fixed addEventListener typing for flash9 fixed __vector__ generation for AS3 target fix with inline functions : position is now the inserted position and not the original one (better error reporting) added SWC output support fixed issues with unset of values in for loops and executing blocks that return functions (Haxe/PHP) "throw" type is now Unknown instead of Dynamic (prevent type-hole in "if A else if B else throw") added __foreach__ for flash9/as3 fixed f9 verify error with different kind of functions moved eof() from neko.io.FileOutput to FileInput added haxe.rtti.HtmlEditor added neko.db.Manager.setLockMode genAS3 : fixed Error classes issues genAS3 : fixed default basic type value in interfaces flash9 : fixed UInt default parameter verify error flash9 : fixed issue with flash.* string enums verify error compiler : allowed \r line separators for HXML files flash9 : fixed verify error with loop variable beeing a specific class compiler : prevent truncating float dynamic values to int when using numerical operations neko.db.Manager fix : synchronize fields after locking an unlocked cached object compiler : fixed issue with cascading inline+haxe.rtti.Generic optimizer : reduce constant int/float/bool expressions and immediate function calls flash9/as3/php : don't add Boot.skip_constructor test if no side effects in constructor compiler : added --no-opt to disable expr reduction compiler : separated basic and advanced commandline options compiler : fixed printing of sub-function types genHX : fixed generation of classes that extends another class (shouldn't be turned into enums) speedup Array.remove on flash9/js 2008-11-23: 2.02 Std.is(MyInterface, Class) now returns true (Haxe/PHP) php arrays are wrapped into _hx_array instances, fixes issues with references (array cast, access out of bounds ...) removed untested php classes (php.DBase, php.IniHash) added -D use_rtti_doc flash.Lib.getTimer() now returns Int and is inlined fixed php.FileSystem.stat added memory related functions to php.Sys added error when trying to extend Array, String, Date and Xml fixed handling of implements ArrayAccess fixed some minor things in flash10 api switch/for/while/do/try/if are no longer using parse_next (parenthesises requ. instead) fixed Type.typeof and Std.is in case of too much large integers for Flash6-8/JS haxe.xml.Check : treat comments the same as PCDATA spaces haxe.io.BytesData now uses strings instead of arrays for PHP compiler : optimized line calculus from ast position lexer : allow identifiers starting with _[0-9] fixed access to flash.Vector methods : use AS3 namespace (faster) bugfix in inline functions : modifying a parameter can't modify a real local var anymore bugfix in inline functions : handle class type parameters and method type parameters fixed issue with Int default value for Float parameter flash9 : bugfix when using the retval after setting a closure variable added flash.Memory API for flash10 alchemy opcodes access changed #if as3gen to #if as3 when generating as3 code fixed as3 flash.Vector generation fixed haxe.io.BytesOutput for flash9 : set default to little-endian some flash9 fixes related to extern enums updated flash.text.engine package with haxe enums flash9 : use target file path for Boot unique ID instead of random number as3 : fixed bug when anonymous field was a reserved identifier flash9 : added flash.Lib.vectorOfArray and vectorConvert for flash10 added -D check-js-packages to allow several haxe-generated js files in same page 2008-10-04: 2.01 fixed php.Sys added neko.NativeString and neko.NativeArray fixed php.Boot.__string_rec() when invoked from toString fixed null references in class constructors for array arguments fixed Type.enumParameters() and Type.typeOf() for PHP fixed SPOD/MySql for PHP fixed php.net.Socket.setTimeout(), php.io.Process fixed php.Web.setCookie() for expire time fixed php rethrow in catches and added the possibility to catch native exceptions added runttime check for php.io.Socket.shutdown (uses fclose in php 5.1.x) allowed optional Context in remoting connections fixed extern classes for flash < 8 fixed inherited protected/private properties in as3 SWF library fixed haxe.io float/double in Neko (when bigEndian was null) added __FSCommand2__ support optimized haxe.Unserializer (use faster buffer access) use "Dynamic" instead of Dynamic->Void for flash9 IEventDispatcher always use full classes paths for genAS3 prevent different get/set property accesses when implementing an interface fixed assign of dynamicfunction references in PHP Haxe/PHP now generates code for extern classes __init__ added strings literal support in haxe.Template fixed Process arguments and exitCode() in Haxe/PHP fixed hierarchy problem for classes with the name from different packages Haxe/PHP php.db.Mysql now throws an exception when tries to connect to an unexistant DB fixed blocks in if statements for Haxe/PHP added php check on the full hierarchy for colliding names added support for "g" modifier in EReg for PHP PHP now generates __toString for classes that have toString defined implemented php.Lib.getClasses() fixed duplicate fields in Type.getInstanceFields on subclass Enum is no longer defined inside Type but is standalone class fixed Date.getDay on Neko/Windows (use %w instead of %u) fixed memory leak with PHP closures fixed wrong scope in PHP closures fixed Array.reverse() in PHP fixed Reflect.compareMethods in Neko (require Neko 1.8.0) fixed flash7-8 register usage for __init__ and static variables initialization moved StringTools.baseEncode/Decode to haxe.BaseCode fixed binary resources for Flash, JS and PHP outputs fixed compiler bug with inline + optional arguments fixed Type.createInstance and createEmptyInstance with Array for flash6-8 2008-07-28: 2.0 fixed current package bug in inherited constructor type delayed type-parameter constraints check (allow mutual rec extends for SPOD) improved unclosed macro error reporting Haxe/PHP integration renamed NekoSocketConnection to SyncSocketConnection (php support) fixes in genAs3 fix for flash9 : always coerce call return type set all private+protected names from SWF lib to public (allow override+reflect) flash9 : use findprop instead of findpropstrict for 'this' access (allow dynamic) don't allow nullness changes in overrided/implemented prevent typing hole with overriden polymorphic methods added neko.vm.Mutex and neko.vm.Deque (included in neko 1.7.1) added package remapping using --remap 2008-07-17: 2.0-RC1 genneko : remove big array error (fixed in neko 1.7.1) fixed neko.net.ThreadRemotingServer.onXML genswf9 : fixed verify error with Null (was using dynamic access) small patch for jsfl support added .cca for faster string operations on Flash9/Flash/JS bugfix with inlined local variables upgraded flash9 api to flex3/player 9.0.115 override is now mandatory, no more --override dynamic is now a keyword f9dynamic is now dynamic and is mandatory on all platforms public/private/dynamic are inherited by default when overriding a method removed Reflect.empty() : use {} instead changed #else by #elseif, added #else flash9 : optimized Hash,IntHash,StringBuf (use typed value) Reflect.field/setField/callMethod , Type.enumIndex and StringBuf methods are now inlined optimized haxe.Md5 : don't use statics allow up to 8 parameters in Reflect.createInstance flash9 : some minor optimizations in haxe.Serializer added haxe.io package (removed things from neko.io) __resolve becomes resolve (and should be documented) added haxe.Int32 removed neko.Int32 removed neko.io.Input/Output/Eof/Error/Logger/Multiple/StringInput/StringOutput removed neko.net.RemotingServer changed neko apis to use haxe.io and Bytes instead of String buffers fixed big bug in js/flash8 debug stack handling complete rewrite of haxe.remoting package haxe.io.Bytes serialization support (replace deprecated string support) removed === and !== removed Std.bool fixed : Reflect.field(null) in flash9 doesn't throw an error anymore removed Type.toClass and Type.toEnum Dynamic type is now a class and not an enum moved reflection support for core types from Boot to Std fixed Type.getClassName/getEnumName/resolve for core flash9 types renamed haxe.rtti.Type to haxe.rtti.CType (with changes in prefix) added haxe.TimerQueue, added haxe.Timer.delay, remove haxe.Timer.delayed flash9 : bugfix, generated interfaces were empty fixed bug while writing block-vars in flash/js added parameters default value (constants) removed Std.resource, Std.ord, Std.chr added haxe.Resource, allow binary data in resources added Type.createEnum check that local variables get correctly initialized before usage haxe.Stack support for flash9 2008-04-05: 1.19 fixed flash9 Array.toString fixed inline return bug added haxe.rtti.Generic behavior added haxe.FastList bugfix to prevent recursive anonymous fixed some incorrectly reported "recursive inline" errors fixes in genas3 + genswf9 for Dynamic/* in methods {} is now an empty object and not an empty block fixed some verify errors left in flash9 fixed private/protected differences in gen-hx-classes genswf9 : allowed to store a Class in a typed register fixed switch-on-bool (don't use matching) genswf9 : optimized switch on ints some renames in haxe.rtti.Type added flash.utils.TypedDictionary for F9 genswf9 : fixe debug filename with inline code fixed completion for packages starting with 'a' or 'z' added flash9.Lib.as prevent double Movieclip class declaration when linking flash9 lib allow numerical operations on type parameters constraint by Float genswf9 : fixed dynamic inheritance 2008-02-23: 1.18 some optimization and bugfix for as3 codegen bugfix : allow bitmaps and fonts classes for F9 library bugfix : neko.Web.setCookie bugfix : as3 switches in -swf-lib, and enable to "repair" corrupted as3 bytecode fixed --i return value in flash9 fixed some transforms in flash9 added js.Selection simplified js.Dom (more events) added haxe.xml.Fast.innerHTML added Reflect.compare fixed "".split() in Neko (now returns [""] instead of []) bugfix for swf-lib f9 classes ordering added EReg.customReplace added neko.Lib.lazyLoad and improved neko.net.Poll for Neko 1.6.1 prevented static fields in interfaces added neko.Sys.cpuTime() fix for protected as3 classes added support for flash9 XML (in flash.xml package) added neko.vm.Tls for Neko 1.6.1 added --no-inline renamed neko.zip.File to neko.zip.Reader added neko.zip.Writer and neko.zip.CRC32 fixed multilevel Transform.block_vars added js.SWFObject fixes for if/switch with null or Null on Flash9 2008-01-13: 1.17 fixed Int32.compare, added Int32.read and Int32.write fixed type of unitialized registers in flash9 fixed Sqlite transactions (commit and rollback now restart a transaction) several flash9 optimizations flash9 debug support (with -D fdb) set align to TopLeft if not defined for flash9 added neko.vm.Gc fixed Null should not be a value bugfix in serialization format with USE_ENUM_INDEXES added apis in DateTools for time manipulation bugfix in flash9 : strictly typed local vars used in local functions always force swf version and sandbox redefinition added as3hl layer merge as3 classes use flash9 fast switch for enums always use match for enums (no switch even if constant) fixed DateTools.format %I and %l in Flash/JS securized Hash for JS and Flash compiletime F9 class generation for F8 swflib optimized for loops (Array and IntIter) added #line support more f9 Null support for "if" and array declarations more neko.Web.setCookie parameters added "inline" for methods and static vars fixed % type in flash9 2007-10-31: 1.16 use _sans font for default flash traces (better Linux support) fixed haxe.remoting.Connection compilation for Flash<8 added fix to prevent 64K identifiers limit on Flash<9 ensure order of anonymous fields initialization fixed haxe.remoting.Connection.urlConnect in JS use amortized O(1) for Neko Array implementation ndlls libraries should now use .neko() instead of __a allowed 'u' utf8 for regexp (needs Neko 1.6.1 regexp.ndll on windows) onclick and onsubmit JS events returns Bool fixed inherited constructor of extern class was always private fixed Ereg.split without 'g' flag on JS/Flash9 fixed haxe.Stack in JS without -debug added support for -D no-swf-compress fixed ByteArray.readObject fixed implements Dynamic in Flash9 removed neko.io.FileInput.eof, fixed neko.io.Input.readLine fixed haxe.Template for Flash9 added neko.Sys.command optional array of arguments removed haxe.Proxy added flash.XMLRequest fixed Type.enumParameters for Neko guaranteed order of Type.getEnumConstructs same as code used index-based dispatch for enums added Type.enumIndex fixed enum.toString for Flash and JS support for -Dnetwork-sandbox trim -cp and -resource various genas3 fixes 2007-08-29: 1.15 fixed bug with Enum.construct when Enum have type parameters change with "untyped" : arguments types are checked (because of opt select) haxedoc : fixed type parameters display fix for JS and Flash9 XML parser : allow newlines in attributes disable Flash9 resources with AS3Gen error on extra anonymous fields error on too much big neko array declaration (neko 1.6 max_stack limit) fixed Flash9 statics slots (FP 9,0,60 compatibility) fixed Flash9 Type.getClassName optional enums arguments on Flash9 are now automatically Null forbid usage of type parameters in static functions fixed Std.int with negative numbers fixed some F9 issues with Haxe-specific Array, Date and Math methods used AS3 namespace for F9 Array and String instance methods fixed F9 with uninitialized integer registers fixed F9 + operator with Dynamic/Null operands added Enum subtyping fix with remoting threadserver and exceptions fixed Flash9 dynamic runtime type field access fixed very tricky typing bug with constructors inheritance fixed some documentation related parser bug fixed stack overflow with static setter fixed package completion bug when -cp points to an not existing dir fix duplicate sandboxes tags with -swf __resolve in Haxe Remoting is now public 2007-07-25: 1.14 fixed no error when invalid "catch" expression remove variance fixed prototype bug in neko when "Main" class is defined fixed flash9 xml iterator methods bugfix in flash9 ByteArray serialization fixed genAS3 conflicting classes and interfaces preserve neko output file extension added flash.Event for Flash9 added --no-output fixed neko.net.Socket peer and host methods added neko.io.Process and neko.vm.Ui added haxe.xml.Proxy some flash6 fixes allowed simplequotes for xml attributes in Flash9 and JS flash9 optimizing compiler new faster neko binary AST added haxe.remoting.NekoSocketConnection and SocketProtocol don't allow for...in iteration with Dynamic or Unknown added flash9 resources fixed precedence of ternary operator ?: 2007-05-18: 1.13 fixed bug with local variable masking package in catch type fixed "Not_found" when enum params differs added "override" for AS3 generator fixed stack overflow in typedefs added haxe.Timer.queue, removed delayedArg (use callback instead) fixed haxe.remoting.SocketConnection (msg invertions might occur) add uniqueness check for switch constants js : HtmlCollection and MetaDom.childNodes are not true Arrays allowed semicolon after typedef declaration fixed in-loop closure usage of "for" variable for Flash and JS added neko.net.ThreadRemotingServer.onXml (to handle crossdomain xml) more accurate stack trace for socket remoting prevent some memory leak in haxe.Timer / JS added flash fullscreen support added cond?a:b syntax support added utf8 buffer api added haxelib "dev" mode renamed Http.asyncRequest to customRequest add classes to Neko module export table fixed parametrized enums for Flash6 fixed bug with completion and interfaces fixed --flash-use-stage in Flash9 2007-03-06: 1.12 added flash lite support with -D flash_lite bugfix for Unknown should Unknown prevent some exceptions in neko.net.ProxyDetect fixed ByteArray serialization added neko.Int32 added -x for fast neko scripting prevent locals from breaking class access (works with imports) fix in function overriding subtyping added haxe.remoting.FlashJsConnection fixed tar support in neko.zip.File ide completion support using --display give access to neko.net.Host ip (as Int32) fixed bug when calling super.UpperCaseMethod() hide additional flash Array methods allow leading comma in anonymous types added haxe.Public interface added AS3 code generator field lookup gives priority to superclass over interfaces improved haxedoc output fixed bug in neko regexp split/replace when empty match at eol fixed bug in flash 6-7-8 resources generation 2007-01-28: 1.11 changed StringBuf.add implementation added haxe.Firebug allowed variable return type for overriden/implemented methods display error position in front of each error line improved error messages when optional arguments not matched added neko.io.Path added neko.net.ProxyDetect bugfix in unify : prevent recursive anonymous objects haxe.Http call "prepare" only if size is known added multiple expressions in "case" serialization : deprecated old string format, use urlEncode/Decode added flash9 bytearray serialization (to binary string, for neko com) fixed Type.typeof on some flash9 instances no more dontUseCache (haxe.Serializer.USE_CACHE, default to false) small genxml/haxedoc improvements added Type.enumEq local function parameters are now inferred in several cases optional RTTI for Spod Object bugfix related to callback in neko code generator more type error stack (now includes type parameters) type system fixes in anonymous subtyping added Iterable, changed Lambda added TAR and GZIP support to neko.io.Zip compute minimal array content type fixes in enum switchs 2007-01-01: 1.10 fix in haxe.remoting.SocketConnection.readAnswer fix in postfix incr/decr and getter/setter added haxe.Http.fileTransfert for Neko fixed haxelib to 1.02 (use multipart file transfert) fixed Array.reverse added flash.Lib.getURL and fscommand for Flash9 fixed some ignored parse errors fixed minor syntax : immediate object access allow extend/implements a typedef fixed Flash9 AMF remoting fixed Flash9 bugs in Date object fixed dynamic Array typing bug allowed typedef private field access added Class base class type AsyncConnection.call callback is now optional fixed if/switch with no else/default compilation moved Reflect.createInstance to Type added Reflect.makeVarArgs haXelib 1.03 : several developers per project + web interface 2006-11-22: 1.09 added neko.vm.Module and neko.vm.Loader haxelib : allowed spaces in "run" arguments allowed Thread comparison fixed bug in SWF6 compilation allowed either Mysql or Mysql5 usage replaced db.Connection.hasFeature by db.Connection.dbName added Socket.custom field moved neko.Thread to neko.vm.Thread define haxe_109 (for api changes) fixes in haxe.remoting.Connection and haxe.Unserializer for F9 added haxe.remoting.Connection.urlConnect for JS allowed private typedef fields added neko.net.ThreadServer, ThreadRemotingServer and Poll removed neko.net.RemotingBuffer relaxed enums switchs (allow value in first case) changed "cast" codegeneration (fix some F9 usages) change in POST data handling in mod_neko (max 256K, except multipart) added neko.Web.getClientHeaders and neko.Web.flush "callback" is now a keyword fixed stack overflow when typedef = Dynamic fixed Reflect.createInstance on F9 Array : slice optional length, fixed neko slice & splice + fixed cast return type 2006-10-29: 1.08 fixed bug in flash -debug fixed Sqlite result .length fixed missing "." in OSX/Linux default classpath fixed haxelib NDLL autoloading on OSX fixed bug in deserialization of "\\\r" sequence added inheritance and fields getter/setter to xml output haxedoc 2.0 fixed neko native enum serialization fixed "all constructors matched" for enums without params fixed returned value semantics in neko (prevent remoting leak) more documentation added haxe.rtti package (classes can implement haxe.rtti.Infos) fixed windows line endings in exclude files under linux/osx fixed small bug in "cast" syntax added "callback" for partial function application added --auto-xml for future haxeFD usage fixed Reflect.isFunction minor bugfix in JS code generator new neko.net package allow recursive remoting proxys (skip instead of error) added neko.Thread and neko.Lock MultiThread classes added neko.net.ServerLoop for multiple clients handling 2006-09-11: 1.07 fixed resources in Neko typedef, override, package and f9dynamic are now keywords slighly changed error format output fixed "undefined" serialization and Type.typeof some fixes in haxelib set default classpath for non windows systems added variance fixed bug in bounded type parameters fixed scope bug in try/catch with Flash9 added remoting over XMLSocket and LocalConnection for Flash9 fixed Std.is(*,null) = false allowed >64K Haxe/neko strings -debug and stack traces support for Flash and JS minor changes in xml output 2006-08-28: 1.06 allowed extern enums use only matching construct when parameters are matched fixed bug preventing & char to be sent between JS and Flash remoting improved flash9 api (more strict) flash9 xml : use JS ReXml parser added neko.io package (Input/Output) moved neko.File and neko.Socket to neko.io package fixed flash optional arguments (when extending flash.MC) fixed neko native serialization problems variable modification does not have side effects in 'for x in a...b' jit disabled by default for neko web server enable flash7-8 libraries usage from flash9 unknown identifier become "class not found" when representing a classpath changed haxe.PosInfos handling added -debug (removed --flash-debug) effective on flash9 and neko only now added Type.typeof improved Serializer speed added Serialization support for Date, Hash, IntHash, List added flash9 and JS IE/Opera class reflection added haxe.xml.Check and haxe.xml.Fast added Xml.parent added haxelib added ArrayAccess interface 2006-08-16: 1.05 moved Md5 to haxe package. some method renamed in neko.FileSystem. added neko.remoting.Server.setLogger fixed bug in haxe.Serializer on neko (was preventing List serialization) fixed bugs in Haxe.Unserializer on neko (invalid enum tag & pbs with UTF8 strings) fixed sqlite escape & quote , added BOOL support allowed direct property access in getter/setter (prevent rec loop) allowed event-driven neko http requests forbidden "name" static in js don't allow variable redeclaration in subclasses added && || and ! in conditional compilation rules metas : removed __construct__ and class.toString. metas : __super__ and __interfaces__ now optional added Type api (seperated from Reflect) flash 9 support 2006-07-25: 1.04 added macros in haxe.Template allowed static variables access from a signature shortcut allowed new Signature when signature is a class fixed : modulo priority is now higher than mult and div fixed bug in haxe.Proxy generation fixed more stack overflows with recursive signatures fixed bug in class <: anonymous subtyping (inherited fields) override is not mandatory by default (need --override) added neko just-in-time fixed bugs in haxe.Serializer and haxe.Unserializer (enum format change) changed "signature" by "typedef" (more comprehensible) restricted objects comparisons fixed bug with js operator priority improved performances for haxe.Serializer and haxe.Unserializer fixed bug in static variable lookup (should look class in the last case) prevented several prints of "not enough arguments". 2006-06-23: 1.03 haxedoc executable now part of the distribution removed selectDB from the neko.db.Connection API added optional parameters with selection removed --no-flash-opt-args changes in SWF packages handling fixed optional leading comma in anonymous object and array values fixed bug in inheritend constructor type parameters fixed bug in type_field with inherited type parameters added haxe.Proxy added code transformations for swf/js block variables fixed very tricky bug with constraint parameters used together with polymorphic methods added selective import (import x.y.Class.InnerType) added optional enum constructor parameters added opened anonymous types (no more Unknown has no field...) fixed "MovieClip extends flash.MovieClip". added Reflect.copy added neko.Random added Date.fromString fixed bug in haxe.Unserializer, slighlty optimized haxe.Serializer added __setfield magic (complete __resolve) added explicit override when overriding methods 2006-06-08: 1.02 fixed stack overflow when recursive class <: recursive signature improved a bit commandline : allow several hxml arguments added {> Class, fields... } types declarations added cast without type (less dangerous than untyped) no stage objects by default, added --flash-use-stage added haxe.remoting.DelayedConnection added -exclude removed classpath from neko debug infos filenames fixed bug in Neko empty Array.pop and Neko EReg.replace "" fixed nodeValue for Neko XML comments, doctype, prolog improved DocView : formating, signatures, files generation added neko.zip package fixed bug in neko.File binary flags fixed problems when downloading large files using haxe.Http under Neko neko.db.Connection and neko.db.ResultSet are now interfaces added neko.db.Sqlite and neko sqlite ndll mod_neko2.ndll for Apache2 in Windows distribution fixed bug in static properties method resolution change js.Dom : use cascading signatures and improved api added haxe.unit Unit test framework 2006-05-25: 1.01 added neko.Utf8 Serializer/Unserializer now support utf8 strings allowed subtyping of prop accesses public/private when implementing an interface removed "eval" from Remoting APIs (only calls - more easy to handle). added flash6 support fixed Std.is on different platforms (interfaces implements interface) added AsyncConnection.amfConnect for flash added SWF overflow checks changed "property" to "var" don't allow monorph unification with Dynamic (more safe) allowed multiple parsing and typing errors review and completed commandline options error on backwards constant integer iterators remoting proxy constructor is now public fixed -swf-header override the swflib background color moved all remoting classes into the haxe.remoting package added haxe.remoting.LocalConnection 2006-05-17: 1.0 fixed small bugs in JS Xml Parser (empty attribute, newlines in attributes) added default Content-Type for haxe.Http in JS haxe.AsyncConnection : onError should not be call if error occur in onData fixed infinite loop if haxe.Unserializer.readDigits reach eof on JS/Flash fixed bugs in neko.Web and neko.Sys (some methods returning "null" instead of null) added neko.Socket.setBlocking for nonblocking sockets fixed bug in js generator when using cascading iterators fixed typing bug when overloading parametrized method fixed bug in js generator when "try" without curly braces. allowed enum catching added remoting proxys allowed neko.Web API commandline emulation outside mod_neko removed subtyping Anon :> Instance added signatures, Iterator is now a signature getter/setter and public/private unification allowed anonymous declaration with interface-style syntax (for signatures) optimized code generated for underscore in enum matches parameters fixed flash/js String.charCodeAt(outside) => null fixed neko charAt(outside) => "" added errors for strings containing \0 in JS and Flash added HAXE_LIBRARY_PATH environment variable support fixed interfaces inheritance : can't extend, can implement (type-sums) fixed fixed >64K resource bug in SWF fixed newline problems with Flash/JS Connection 2006-05-02: RC1 added the Socket class fixed a bug of returned value in neko with 6 or more parameters added "Missing type" error for catchs. added regular expressions (still missing Flash implementation) fixed type printing and parenthesis in type declarations different behavior when elements removed during Array.iteration fixed genswf : local variables used in for...function improved type parameters structure coherency enable usage of Spod without Transaction implemented neko.db.Transaction.isDeadlock slighly relaxed one of the javascript generator constraint added haxe.Template moved Log , PosInfos and ImportAll to haxe package completed private class/interface/enum support removed Array.indexes added __resolve compile-time support when class implement Dynamic added haxe Remoting added "module with different case" error (for windows) added Reflect.resolveClass, Reflect.resolveEnum, Reflect.setPrototype added access to classes by name in genneko added enum.__ename__ fixed Std.is(e,enum) fixed infinite loop in neko EReg split/replace and epsilon matching added neko native serialization support fixed syntax for multiple constraints in type parameter added recursive type parameters contraints (T : C constraints) updated Xml handling 2006-04-17: beta 5 fixed bug : continue in do...while changed typing order for do...while (infer condition after block) fixed JS "catch" generation fixed extending flash.* extern class fixed bug in neko generator w/ closures fixed bug in js generator (return switch need correct "this" context) fixed bug in for x in a...b : invalid local variables overridding added properties fixed bug in js generator : while...switch...break new List implementation can use static function __init__ on every platform bug fixes in Reflect.fields added Hash.remove, changed Hash/JS implementation added flash __delete__ support added neko.db.Object, Manager, Transaction fixed neko class.__interfaces__ added "assigning a value to itself" error added automatic PosInfos when is last parameter added polymorphic methods added check_flash_args support 2006-04-02: beta 4 fixed javascript events case fixed invalid use of physeq fixed + type inference added -altfmt allowed anonymous <: class subtyping relaxed unifications of expressions in "for" and "while" more methods in List syntax changes : mandatory parenthesis for "for" and "while" allowed any kind of identifier almost everywhere moved tools, flash, js and neko inside "std" no need for 0x in flash header bgcolor added -res fixed type parameter contraint holes Std.is Dynamic always returns true added Enum.toString neko : env locals can be modified in inner functions completed js keywords list in generator added Reflect.typeof prioritize neko.Lib.load static calls fixed bugs in for...in optimization with continue fixed Reflect fields, added documentation, added Class added javascript closures, fixed null closures on flash and Neko added javascript __init__ statics and js.XMLHttpRequest added neko.Stack fixed bug in Std.ord convert neko string to haxe string on catch automaticaly creates empty clips for classes extending flash.MovieClip unify stack : several meaningful unification errors added cast operation and keyword 2006-03-11: beta 3 javascript generator optimized for in interval renaming of locals (name must be unique) added uncaught exceptions handling in Flash fixed Bool.true == true and Bool.false == false on all platforms fixed matching on Bool different from enums removed -fplayer (use -D instead) and added -fheader fixed infinity is Int added "here" special identifier neko Apis : File, FileSystem, Sys added base JS API 2006-02-19: beta 2 renamed neko.db.Result to neko.db.ResultSet added Date support for Mysql results added private fields for static class anonymous types disambigous >=, >>= and >>>= fixed inheritance bug in swf and neko generators improved function parameters type error reporting. allowed variable number of args for flash.* constructors. added Math.random(), Reflect.empty() added flash.XMLSocket and flash.Timer classes completed Std class with conversion functions and others. completed flash.Lib class with flash toplevel functions. fixed bugs in neko webserver 2006-02-04: beta 1 allowed array literals to be dynamic use neko 1.2 commandline and prototypes changed #cond to #if cond for conditional compilation all fields are defined to null by default defined __class__ and other meta accesses for Flash and Neko fixed type hole for compiler-know types (should not resolve using imports) changed packages : neko.* and flash.* (with protection) added Lazy types : type the fields when they are needed with recursion untyped accesses are monomorphs, not dynamics generated __string check that toString() return an object XmlParser and other APIs for Neko fixed escaped chars in Neko generation conservative static initialization order allowed no type parameters for new Class function types carry parameter names anonymous types contain private variables (for private static accesses) added optional name for anonymous types in typer (for static accesses) private classes and enums (partial support) improved error message for invalid number of arguments flash extern classes can take variable number of args. added -swf-lib for importing SWF library added neko.db package 2005-12-23: alpha 5 added -main commandline parameter catches are now working with Neko restricted catch types for type-safety added constructor inheritance + check if superconstructor is called allowed Dynamic-only subtyping on type parameters added method closures to Neko generation added class Reflect added License : libraries are BSD added -xml documentation output allowed class instance :> anonymous subtyping 2005-12-10: alpha 4 forbid break and continue outside loops fixed SWF generation bugs added SWF "extends" support added method closures added some flash lowlevel operations (__xxx__) added Log, LogInfos and trace added Neko generation fixed problems with conditional compilation macros 2005-11-30: alpha 3 added Flash extern classes Boot initialization added "untyped" added conditional compilation added interfaces changed iterators from closures to objects added (XML)Node and XmlParser for Flash 2005-11-25: alpha 2 swf generation (missing iterators) some typing fixes 2005-11-17: alpha 1b fix some bugs changed package tests.lang 2005-11-14: alpha 1 lexer parser typer haxe_3.2.1+dfsg.orig/extra/CONTRIB.txt0000664000175000017500000000513312607337712017312 0ustar andyandy00000000000000Contributor License Agreement : You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the project Haxe : 1) Definitions "Contribution" : any source code, documentation, including any modifications or additions to an existing work that is intentionally submitted by You to the Haxe Foundation for inclusion in, or documentation of, any of the products managed and maintained by the Haxe Foundation. "Submitted" means any form or electronic, verbal or written communication, including but not limited to communication on electronic mailing lists, source code control systems and issue tracking system that are managed by, or on behalf of, the Haxe Foundation for the purpose of improving Haxe. 2) Grant of Copyright License. Subject to the terms and conditions of this Grant, You hereby grant to the Haxe Foundation and to recipients of software distributed by the Haxe Foundation a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works. 3) You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to the Haxe Foundation, or that your employer has executed a separate Corporate Contributor License Grant with the Haxe Foundation. 4) You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions. 5) You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Full Name : Email : Mailing Address : Country : Signature:haxe_3.2.1+dfsg.orig/extra/EnvVarUpdate.nsh0000664000175000017500000002410112607337712020523 0ustar andyandy00000000000000/** * EnvVarUpdate.nsh * : Environmental Variables: append, prepend, and remove entries * * WARNING: If you use StrFunc.nsh header then include it before this file * with all required definitions. This is to avoid conflicts * * Usage: * ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString" * * Credits: * Version 1.0 * * Cal Turney (turnec2) * * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this * function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar, * WriteEnvStr, and un.DeleteEnvStr * * Diego Pedroso (deguix) for StrTok * * Kevin English (kenglish_hi) for StrContains * * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry * (dandaman32) for StrReplace * * Version 1.1 (compatibility with StrFunc.nsh) * * techtonik * * http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries * */ !ifndef ENVVARUPDATE_FUNCTION !define ENVVARUPDATE_FUNCTION !verbose push !verbose 3 !include "LogicLib.nsh" !include "WinMessages.NSH" !include "StrFunc.nsh" ; ---- Fix for conflict if StrFunc.nsh is already includes in main file ----------------------- !macro _IncludeStrFunction StrFuncName !ifndef ${StrFuncName}_INCLUDED ${${StrFuncName}} !endif !ifndef Un${StrFuncName}_INCLUDED ${Un${StrFuncName}} !endif !define un.${StrFuncName} "${Un${StrFuncName}}" !macroend !insertmacro _IncludeStrFunction StrTok !insertmacro _IncludeStrFunction StrStr !insertmacro _IncludeStrFunction StrRep ; ---------------------------------- Macro Definitions ---------------------------------------- !macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString Push "${EnvVarName}" Push "${Action}" Push "${RegLoc}" Push "${PathString}" Call EnvVarUpdate Pop "${ResultVar}" !macroend !define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"' !macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString Push "${EnvVarName}" Push "${Action}" Push "${RegLoc}" Push "${PathString}" Call un.EnvVarUpdate Pop "${ResultVar}" !macroend !define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"' ; ---------------------------------- Macro Definitions end------------------------------------- ;----------------------------------- EnvVarUpdate start---------------------------------------- !define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' !define hkcu_current_user 'HKCU "Environment"' !macro EnvVarUpdate UN Function ${UN}EnvVarUpdate Push $0 Exch 4 Exch $1 Exch 3 Exch $2 Exch 2 Exch $3 Exch Exch $4 Push $5 Push $6 Push $7 Push $8 Push $9 Push $R0 /* After this point: ------------------------- $0 = ResultVar (returned) $1 = EnvVarName (input) $2 = Action (input) $3 = RegLoc (input) $4 = PathString (input) $5 = Orig EnvVar (read from registry) $6 = Len of $0 (temp) $7 = tempstr1 (temp) $8 = Entry counter (temp) $9 = tempstr2 (temp) $R0 = tempChar (temp) */ ; Step 1: Read contents of EnvVarName from RegLoc ; ; Check for empty EnvVarName ${If} $1 == "" SetErrors DetailPrint "ERROR: EnvVarName is blank" Goto EnvVarUpdate_Restore_Vars ${EndIf} ; Check for valid Action ${If} $2 != "A" ${AndIf} $2 != "P" ${AndIf} $2 != "R" SetErrors DetailPrint "ERROR: Invalid Action - must be A, P, or R" Goto EnvVarUpdate_Restore_Vars ${EndIf} ${If} $3 == HKLM ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5 ${ElseIf} $3 == HKCU ReadRegStr $5 ${hkcu_current_user} $1 ; Read EnvVarName from current user into $5 ${Else} SetErrors DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"' Goto EnvVarUpdate_Restore_Vars ${EndIf} ; Check for empty PathString ${If} $4 == "" SetErrors DetailPrint "ERROR: PathString is blank" Goto EnvVarUpdate_Restore_Vars ${EndIf} ; Make sure we've got some work to do ${If} $5 == "" ${AndIf} $2 == "R" SetErrors DetailPrint "$1 is empty - Nothing to remove" Goto EnvVarUpdate_Restore_Vars ${EndIf} ; Step 2: Scrub EnvVar ; StrCpy $0 $5 ; Copy the contents to $0 ; Remove spaces around semicolons (NOTE: spaces before the 1st entry or ; after the last one are not removed here but instead in Step 3) ${If} $0 != "" ; If EnvVar is not empty ... ${Do} ${${UN}StrStr} $7 $0 " ;" ${If} $7 == "" ${ExitDo} ${EndIf} ${${UN}StrRep} $0 $0 " ;" ";" ; Remove ';' ${Loop} ${Do} ${${UN}StrStr} $7 $0 "; " ${If} $7 == "" ${ExitDo} ${EndIf} ${${UN}StrRep} $0 $0 "; " ";" ; Remove ';' ${Loop} ${Do} ${${UN}StrStr} $7 $0 ";;" ${If} $7 == "" ${ExitDo} ${EndIf} ${${UN}StrRep} $0 $0 ";;" ";" ${Loop} ; Remove a leading or trailing semicolon from EnvVar StrCpy $7 $0 1 0 ${If} $7 == ";" StrCpy $0 $0 "" 1 ; Change ';' to '' ${EndIf} StrLen $6 $0 IntOp $6 $6 - 1 StrCpy $7 $0 1 $6 ${If} $7 == ";" StrCpy $0 $0 $6 ; Change ';' to '' ${EndIf} ; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug ${EndIf} /* Step 3. Remove all instances of the target path/string (even if "A" or "P") $6 = bool flag (1 = found and removed PathString) $7 = a string (e.g. path) delimited by semicolon(s) $8 = entry counter starting at 0 $9 = copy of $0 $R0 = tempChar */ ${If} $5 != "" ; If EnvVar is not empty ... StrCpy $9 $0 StrCpy $0 "" StrCpy $8 0 StrCpy $6 0 ${Do} ${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter ${If} $7 == "" ; If we've run out of entries, ${ExitDo} ; were done ${EndIf} ; ; Remove leading and trailing spaces from this entry (critical step for Action=Remove) ${Do} StrCpy $R0 $7 1 ${If} $R0 != " " ${ExitDo} ${EndIf} StrCpy $7 $7 "" 1 ; Remove leading space ${Loop} ${Do} StrCpy $R0 $7 1 -1 ${If} $R0 != " " ${ExitDo} ${EndIf} StrCpy $7 $7 -1 ; Remove trailing space ${Loop} ${If} $7 == $4 ; If string matches, remove it by not appending it StrCpy $6 1 ; Set 'found' flag ${ElseIf} $7 != $4 ; If string does NOT match ${AndIf} $0 == "" ; and the 1st string being added to $0, StrCpy $0 $7 ; copy it to $0 without a prepended semicolon ${ElseIf} $7 != $4 ; If string does NOT match ${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0, StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon ${EndIf} ; IntOp $8 $8 + 1 ; Bump counter ${Loop} ; Check for duplicates until we run out of paths ${EndIf} ; Step 4: Perform the requested Action ; ${If} $2 != "R" ; If Append or Prepend ${If} $6 == 1 ; And if we found the target DetailPrint "Target is already present in $1. It will be removed and" ${EndIf} ${If} $0 == "" ; If EnvVar is (now) empty StrCpy $0 $4 ; just copy PathString to EnvVar ${If} $6 == 0 ; If found flag is either 0 ${OrIf} $6 == "" ; or blank (if EnvVarName is empty) DetailPrint "$1 was empty and has been updated with the target" ${EndIf} ${ElseIf} $2 == "A" ; If Append (and EnvVar is not empty), StrCpy $0 $0;$4 ; append PathString ${If} $6 == 1 DetailPrint "appended to $1" ${Else} DetailPrint "Target was appended to $1" ${EndIf} ${Else} ; If Prepend (and EnvVar is not empty), StrCpy $0 $4;$0 ; prepend PathString ${If} $6 == 1 DetailPrint "prepended to $1" ${Else} DetailPrint "Target was prepended to $1" ${EndIf} ${EndIf} ${Else} ; If Action = Remove ${If} $6 == 1 ; and we found the target DetailPrint "Target was found and removed from $1" ${Else} DetailPrint "Target was NOT found in $1 (nothing to remove)" ${EndIf} ${If} $0 == "" DetailPrint "$1 is now empty" ${EndIf} ${EndIf} ; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change ; ClearErrors ${If} $3 == HKLM WriteRegExpandStr ${hklm_all_users} $1 $0 ; Write it in all users section ${ElseIf} $3 == HKCU WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section ${EndIf} IfErrors 0 +4 MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3" DetailPrint "Could not write updated $1 to $3" Goto EnvVarUpdate_Restore_Vars ; "Export" our change SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 EnvVarUpdate_Restore_Vars: ; ; Restore the user's variables and return ResultVar Pop $R0 Pop $9 Pop $8 Pop $7 Pop $6 Pop $5 Pop $4 Pop $3 Pop $2 Pop $1 Push $0 ; Push my $0 (ResultVar) Exch Pop $0 ; Restore his $0 FunctionEnd !macroend ; EnvVarUpdate UN !insertmacro EnvVarUpdate "" !insertmacro EnvVarUpdate "un." ;----------------------------------- EnvVarUpdate end---------------------------------------- !verbose pop !endif haxe_3.2.1+dfsg.orig/extra/ImportAll.hx0000664000175000017500000000733412607337712017722 0ustar andyandy00000000000000/* * Copyright (c) 2005, The Haxe Project Contributors * 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. * * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT 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 HAXE PROJECT 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 haxe.macro.Context; class ImportAll { public static function run( ?pack ) { if( pack == null ) { pack = ""; haxe.macro.Compiler.define("doc_gen"); } switch( pack ) { case "php": if( !Context.defined("php") ) return; case "neko": if( !Context.defined("neko") ) return; case "js": if( !Context.defined("js") ) return; case "cpp": if( !Context.defined("cpp") ) return; case "flash": if( !Context.defined("flash9") ) return; case "sys": if( !Context.defined("neko") && !Context.defined("php") && !Context.defined("cpp") ) return; case "java": if( !Context.defined("java") ) return; case "cs": if( !Context.defined("cs") ) return; case "python": if( !Context.defined("python") ) return; case "tools": return; case "build-tool": return; } for( p in Context.getClassPath() ) { if( p == "/" ) continue; // skip if we have a classpath to haxe if( pack.length == 0 && sys.FileSystem.exists(p+"std") ) continue; var p = p + pack.split(".").join("/"); if( StringTools.endsWith(p,"/") ) p = p.substr(0,-1); if( !sys.FileSystem.exists(p) || !sys.FileSystem.isDirectory(p) ) continue; for( file in sys.FileSystem.readDirectory(p) ) { if( file == ".svn" || file == "_std" ) continue; var full = (pack == "") ? file : pack + "." + file; if( StringTools.endsWith(file, ".hx") ) { var cl = full.substr(0, full.length - 3); switch( cl ) { case "ImportAll", "neko.db.MacroManager": continue; case "haxe.TimerQueue": if( Context.defined("neko") || Context.defined("php") || Context.defined("cpp") ) continue; case "Sys": if( !(Context.defined("neko") || Context.defined("php") || Context.defined("cpp")) ) continue; case "haxe.web.Request": if( !(Context.defined("neko") || Context.defined("php") || Context.defined("js")) ) continue; case "haxe.macro.ExampleJSGenerator","haxe.macro.Context", "haxe.macro.Compiler": if( !Context.defined("neko") ) continue; case "haxe.remoting.SocketWrapper": if( !Context.defined("flash") ) continue; case "haxe.remoting.SyncSocketConnection": if( !(Context.defined("neko") || Context.defined("php") || Context.defined("cpp")) ) continue; case "sys.db.Sqlite" | "sys.db.Mysql" | "cs.db.AdoNet": continue; } Context.getModule(cl); } else if( sys.FileSystem.isDirectory(p + "/" + file) ) run(full); } } } } haxe_3.2.1+dfsg.orig/extra/LICENSE.txt0000664000175000017500000011763712607337712017311 0ustar andyandy00000000000000Haxe Licenses ------------- For details about Haxe Licenses, please read http://haxe.org/doc/license The MIT Licence : -------------------------- Copyright (C)2005-2012 Haxe Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The Haxe compiler GPL License : ------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS The Neko LGPL License : ----------------------- GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS haxe_3.2.1+dfsg.orig/extra/all.hxml0000664000175000017500000000066712607337712017122 0ustar andyandy00000000000000--no-output --macro ImportAll.run() -D doc-gen --each -neko all.n -xml neko.xml --next -js all.js -xml js.xml --next -swf all9.swf -xml flash9.xml -swf-version 11.4 --next -php all_php -xml php.xml --next -cpp all_cpp -xml cpp.xml -D xmldoc -D HXCPP_MULTI_THREADED --next -java all_java -xml java.xml -D xmldoc --next -cs all_cs -D unsafe -xml cs.xml -D xmldoc --next -python all_python -xml python.xml --next -xml cross.xml haxe_3.2.1+dfsg.orig/extra/all.hxproj0000664000175000017500000000321512607337712017454 0ustar andyandy00000000000000 haxe all.hxml haxe_3.2.1+dfsg.orig/extra/clean-whitespace0000775000175000017500000000027612607337712020616 0ustar andyandy00000000000000#!/bin/sh # # Remove trailing whitespace from Haxe files # Exclude generated js.html.* for now find -path ./std/js/html -prune -o -name '*.hx' -print0 | xargs -0 perl -pi -e "s/[ \t]+$//" haxe_3.2.1+dfsg.orig/extra/extract.hxml0000664000175000017500000000016712607337712020017 0ustar andyandy00000000000000-debug -swf-lib library.swf -swf test.swf -swf-version 15 --macro patchTypes("../extra/extract.patch") --gen-hx-classeshaxe_3.2.1+dfsg.orig/extra/extract.patch0000664000175000017500000014730412607337712020153 0ustar andyandy00000000000000// types patches configuration for playerglobal.swc flash.display.DisplayObject.filters : Array; -flash.accessibility.Accessibility.new @:require(flash10_1) flash.accessibility.ISearchableText @:require(flash10_1) flash.accessibility.ISimpleTextSelection @:require(flash10_1) flash.automation.ActionGenerator @:require(flash10_1) flash.automation.AutomationAction @:require(flash10_1) flash.automation.Configuration @:require(flash10_1) flash.automation.KeyboardAutomationAction @:require(flash10_1) flash.automation.MouseAutomationAction @:require(flash10_1) flash.automation.StageCapture @:require(flash10_1) flash.automation.StageCaptureEvent -flash.desktop.Clipboard.new flash.desktop.Clipboard.formats : Array; flash.desktop.Clipboard.$format : ClipboardFormats; flash.desktop.Clipboard.$transferMode : ClipboardTransferMode; enum flash.desktop.ClipboardFormats; enum flash.desktop.ClipboardTransferMode; enum flash.display.PixelSnapping; enum flash.display.BlendMode; @:require(flash10) flash.desktop.Clipboard @:require(flash10) flash.desktop.ClipboardFormats @:require(flash10) flash.desktop.ClipboardTransferMode flash.display.Bitmap.pixelSnapping : PixelSnapping; flash.display.Bitmap.$pixelSnapping : PixelSnapping; flash.display.BitmapData.$blendMode : BlendMode; flash.display.BitmapData.$redArray : Array; flash.display.BitmapData.$greenArray : Array; flash.display.BitmapData.$blueArray : Array; flash.display.BitmapData.$alphaArray : Array; flash.display.BitmapData.$offsets : Array; @:require(flash10) flash.display.BitmapData.setVector @:require(flash10) flash.display.BitmapData.getVector @:require(flash10) flash.display.BitmapData.histogram @:require(flash10_1) flash.display.Loader.uncaughtErrorEvents; @:require(flash10_1) flash.display.LoaderInfo.isURLInaccessible; @:require(flash10_1) flash.display.LoaderInfo.uncaughtErrorEvents; @:require(flash10_1) flash.display.ColorCorrection @:require(flash10_1) flash.display.ColorCorrectionSupport @:require(flash10_1) flash.display.FocusDirection @:require(flash10_1) flash.display.NativeMenu @:require(flash10_1) flash.display.NativeMenuItem @:require(flash10) flash.display.DisplayObject.blendShader @:require(flash10) flash.display.DisplayObject.rotationX @:require(flash10) flash.display.DisplayObject.rotationY @:require(flash10) flash.display.DisplayObject.rotationZ @:require(flash10) flash.display.DisplayObject.scaleZ @:require(flash10) flash.display.DisplayObject.z @:require(flash10) flash.display.DisplayObject.globalToLocal3D @:require(flash10) flash.display.DisplayObject.local3DToGlobal -flash.display.DisplayObject.new flash.display.DisplayObject.blendMode : BlendMode; flash.display.DisplayObject.opaqueBackground : Null; flash.display.DisplayObjectContainer.getObjectsUnderPoint : Array; @:require(flash10_1) flash.display.Sprite.startTouchDrag; @:require(flash10_1) flash.display.Sprite.stopTouchDrag; @:require(flash10_1) flash.display.Stage.wmodeGPU; enum flash.display.GradientType; enum flash.display.CapsStyle; enum flash.display.JointStyle; enum flash.display.GraphicsPathWinding; enum flash.display.TriangleCulling; enum flash.display.InterpolationMethod; enum flash.display.LineScaleMode; enum flash.display.ShaderParameterType; enum flash.display.ShaderPrecision; enum flash.display.SpreadMethod; enum flash.display.StageAlign; enum flash.display.StageDisplayState; enum flash.display.StageQuality; enum flash.display.StageScaleMode; -flash.display.SWFVersion.new flash.display.Graphics.$type : GradientType; flash.display.Graphics.$colors : Array; flash.display.Graphics.$spreadMethod : SpreadMethod; flash.display.Graphics.$interpolationMethod : InterpolationMethod; flash.display.Graphics.$scaleMode : LineScaleMode; flash.display.Graphics.$caps : CapsStyle; flash.display.Graphics.$joints : JointStyle; flash.display.Graphics.$winding : GraphicsPathWinding; flash.display.Graphics.$culling : TriangleCulling; @:require(flash10) flash.display.Graphics.beginShaderFill @:require(flash10) flash.display.Graphics.copyFrom @:require(flash10) flash.display.Graphics.drawGraphicsData @:require(flash10) flash.display.Graphics.drawPath @:require(flash10) flash.display.Graphics.drawTriangles @:require(flash10) flash.display.Graphics.lineBitmapStyle @:require(flash10) flash.display.Graphics.lineShaderStyle flash.display.GraphicsGradientFill.type : GradientType; flash.display.GraphicsGradientFill.colors : Array; flash.display.GraphicsGradientFill.spreadMethod : SpreadMethod; flash.display.GraphicsGradientFill.interpolationMethod : InterpolationMethod; flash.display.GraphicsGradientFill.alphas : Array; flash.display.GraphicsGradientFill.ratios : Array; flash.display.GraphicsGradientFill.$type : GradientType; flash.display.GraphicsGradientFill.$colors : Array; flash.display.GraphicsGradientFill.$spreadMethod : SpreadMethod; flash.display.GraphicsGradientFill.$interpolationMethod : InterpolationMethod; flash.display.GraphicsGradientFill.$alphas : Array; flash.display.GraphicsGradientFill.$ratios : Array; flash.display.GraphicsGradientFill.$matrix : flash.geom.Matrix; flash.display.GraphicsPath.winding : GraphicsPathWinding; flash.display.GraphicsPath.$winding : GraphicsPathWinding; flash.display.GraphicsStroke.scaleMode : LineScaleMode; flash.display.GraphicsStroke.caps : CapsStyle; flash.display.GraphicsStroke.joints : JointStyle; flash.display.GraphicsStroke.$scaleMode : LineScaleMode; flash.display.GraphicsStroke.$caps : CapsStyle; flash.display.GraphicsStroke.$joints : JointStyle; flash.display.GraphicsTrianglePath.culling : TriangleCulling; flash.display.GraphicsTrianglePath.$culling : TriangleCulling; @:require(flash10) flash.display.Loader.unloadAndStop enum flash.display.ActionScriptVersion; enum flash.display.ColorCorrection; enum flash.display.ColorCorrectionSupport; -flash.display.LoaderInfo.new flash.display.LoaderInfo.parameters : Dynamic; flash.display.LoaderInfo.actionScriptVersion : ActionScriptVersion; -flash.display.MorphShape.new @:require(flash10) flash.display.MovieClip.currentFrameLabel flash.display.MovieClip.currentLabels : Array; flash.display.MovieClip.scenes : Array; flash.display.Scene.labels : Array; flash.display.Scene.$labels : Array; @:require(flash10) flash.display.Shader; flash.display.Shader.precisionHint : ShaderPrecision; -flash.display.ShaderParameter.new flash.display.ShaderParameter.type : ShaderParameterType; -flash.display.Stage.new flash.display.Stage.align : StageAlign; flash.display.Stage.quality : StageQuality; flash.display.Stage.scaleMode : StageScaleMode; flash.display.Stage.colorCorrection : ColorCorrection; flash.display.Stage.colorCorrectionSupport : ColorCorrectionSupport; flash.display.Stage.displayState : StageDisplayState; flash.display.Stage.displayState : StageDisplayState; @:require(flash10) flash.display.Stage.colorCorrection @:require(flash10) flash.display.Stage.colorCorrectionSupport @:require(flash10_1) flash.errors.DRMManagerError @:require(flash10_1) flash.events.AccelerometerEvent @:require(flash10_1) flash.events.DRMAuthenticateEvent @:require(flash10_1) flash.events.DRMAuthenticationCompleteEvent @:require(flash10_1) flash.events.DRMAuthenticationErrorEvent @:require(flash10_1) flash.events.DRMCustomProperties @:require(flash10_1) flash.events.DRMErrorEvent @:require(flash10_1) flash.events.DRMStatusEvent @:require(flash10_1) flash.events.GeolocationEvent @:require(flash10_1) flash.events.GestureEvent @:require(flash10_1) flash.events.GesturePhase @:require(flash10_1) flash.events.PressAndTapGestureEvent @:require(flash10_1) flash.events.TouchEvent @:require(flash10_1) flash.events.TransformGestureEvent @:require(flash10_1) flash.events.UncaughtErrorEvent; @:require(flash10_1) flash.events.UncaughtErrorEvents; @:require(flash10) static flash.events.Event.CLEAR; @:require(flash10) static flash.events.Event.COPY; @:require(flash10) static flash.events.Event.CUT; @:require(flash10) static flash.events.Event.EXIT_FRAME; @:require(flash10) static flash.events.Event.FRAME_CONSTRUCTED; @:require(flash10) static flash.events.Event.PASTE; @:require(flash10) static flash.events.Event.SELECT_ALL; @:require(flash10) flash.events.ContextMenuEvent.isMouseTargetInaccessible @:require(flash10) flash.events.FocusEvent.isRelatedObjectInaccessible @:require(flash10) flash.events.MouseEvent.isRelatedObjectInaccessible flash.events.IEventDispatcher.$listener : Dynamic -> Void; flash.events.EventDispatcher.$listener : Dynamic -> Void; enum flash.events.EventPhase; enum flash.events.GesturePhase; flash.events.Event.eventPhase : EventPhase; flash.events.KeyboardEvent.keyLocation : flash.ui.KeyLocation; flash.events.KeyboardEvent.$keyLocationValue : flash.ui.KeyLocation; flash.events.KeyboardEvent.$keyLocation : flash.ui.KeyLocation; @:require(flash10_1) flash.events.ErrorEvent.errorID; @:require(flash10_1) flash.events.HTTPStatusEvent.responseHeaders; @:require(flash10_1) flash.events.HTTPStatusEvent.responseURL; @:require(flash10_1) static flash.events.HTTPStatusEvent.HTTP_RESPONSE_STATUS; @:require(flash10_1) flash.events.IMEEvent.imeClient; @:require(flash10_1) static flash.events.IMEEvent.IME_START_COMPOSITION; -flash.events.WeakFunctionClosure.new -flash.external.ExternalInterface.new enum flash.filters.BitmapFilterType; enum flash.filters.DisplacementMapFilterMode; flash.filters.BevelFilter.type : BitmapFilterType; flash.filters.BevelFilter.$type : BitmapFilterType; flash.filters.DisplacementMapFilter.mode : DisplacementMapFilterMode; flash.filters.DisplacementMapFilter.$mode : DisplacementMapFilterMode; flash.filters.GradientGlowFilter.type : BitmapFilterType; flash.filters.GradientGlowFilter.$type : BitmapFilterType; enum flash.geom.Orientation3D; flash.geom.Matrix3D.$orientationStyle : Orientation3D; @:require(flash10) flash.geom.Matrix3D; @:require(flash10) flash.geom.Utils3D; @:require(flash10) flash.geom.Vector3D; @:require(flash10) flash.geom.PerspectiveProjection; @:require(flash10) flash.geom.Transform.matrix3D; @:require(flash10) flash.geom.Transform.perspectiveProjection; @:require(flash10) flash.geom.Transform.getRelativeMatrix3D; -flash.geom.Utils3D.new @:require(flash10_1) static flash.media.Camera.isSupported; @:require(flash10_1) static flash.media.Camera._scanHardware; enum flash.media.SoundCodec; flash.media.Microphone.codec : SoundCodec; @:require(flash10) flash.media.Microphone.codec; @:require(flash10) flash.media.Microphone.encodeQuality; @:require(flash10) flash.media.Microphone.framesPerPacket; @:require(flash10_1) flash.media.Microphone.enableVAD; @:require(flash10_1) flash.media.Microphone.noiseSuppressionLevel; @:require(flash10_1) static flash.media.Microphone.isSupported; @:require(flash10) flash.media.Sound.extract; @:require(flash10_1) flash.media.Sound.isURLInaccessible; @:require(flash10) flash.net.FileReference.data; @:require(flash10) flash.net.FileReference.load; @:require(flash10) flash.net.FileReference.save; -flash.media.SoundMixer.new @:require(flash10_1) flash.net.LocalConnection.isPerUser; @:require(flash10_1) static flash.net.LocalConnection.isSupported; flash.net.FileReference.$typeFilter : Array; flash.net.FileReferenceList.fileList : Array; flash.net.FileReferenceList.$typeFilter : Array; @:require(flash10_1) flash.net.GroupSpecifier; @:require(flash10_1) flash.net.NetGroup; @:require(flash10_1) flash.net.NetGroupInfo; @:require(flash10_1) flash.net.NetStreamMulticastInfo; @:require(flash10) flash.net.NetConnection.farID; @:require(flash10) flash.net.NetConnection.farNonce; @:require(flash10) flash.net.NetConnection.maxPeerConnections; @:require(flash10) flash.net.NetConnection.nearID; @:require(flash10) flash.net.NetConnection.nearNonce; @:require(flash10) flash.net.NetConnection.protocol; @:require(flash10) flash.net.NetConnection.unconnectedPeerStreams; @:require(flash10) flash.net.NetStream.farID; @:require(flash10) flash.net.NetStream.farNonce; @:require(flash10) flash.net.NetStream.info; @:require(flash10) flash.net.NetStream.maxPauseBufferTime; @:require(flash10) flash.net.NetStream.nearNonce; @:require(flash10) flash.net.NetStream.peerStreams; @:require(flash10) flash.net.NetStream.onPeerConnect; @:require(flash10) flash.net.NetStream.play2; @:require(flash10) static flash.net.NetStream.CONNECT_TO_FMS; @:require(flash10) static flash.net.NetStream.DIRECT_CONNECTIONS; @:require(flash10_1) flash.net.NetStream.audioReliable; @:require(flash10_1) flash.net.NetStream.audioSampleAccess; @:require(flash10_1) flash.net.NetStream.backBufferLength; @:require(flash10_1) flash.net.NetStream.backBufferTime; @:require(flash10_1) flash.net.NetStream.bufferTimeMax; @:require(flash10_1) flash.net.NetStream.dataReliable; @:require(flash10_1) flash.net.NetStream.inBufferSeek; @:require(flash10_1) flash.net.NetStream.multicastAvailabilitySendToAll; @:require(flash10_1) flash.net.NetStream.multicastAvailabilityUpdatePeriod; @:require(flash10_1) flash.net.NetStream.multicastFetchPeriod; @:require(flash10_1) flash.net.NetStream.multicastInfo; @:require(flash10_1) flash.net.NetStream.multicastPushNeighborLimit; @:require(flash10_1) flash.net.NetStream.multicastRelayMarginDuration; @:require(flash10_1) flash.net.NetStream.multicastWindowDuration; @:require(flash10_1) flash.net.NetStream.videoReliable; @:require(flash10_1) flash.net.NetStream.videoSampleAccess; @:require(flash10_1) flash.net.NetStream.appendBytes; @:require(flash10_1) flash.net.NetStream.appendBytesAction; @:require(flash10_1) flash.net.NetStream.attach; @:require(flash10_1) flash.net.NetStream.step; @:require(flash10_1) flash.net.NetStreamInfo.videoLossRate; @:require(flash10_1) flash.net.NetStreamPlayOptions.offset; @:require(flash10_1) static flash.net.URLRequestMethod.DELETE; @:require(flash10_1) static flash.net.URLRequestMethod.HEAD; @:require(flash10_1) static flash.net.URLRequestMethod.OPTIONS; @:require(flash10_1) static flash.net.URLRequestMethod.PUT; @:require(flash10) flash.net.Socket.timeout; @:require(flash10) flash.net.XMLSocket.timeout; -flash.net.ObjectEncoding.new -flash.net.URLRequestMethod.new enum flash.net.URLLoaderDataFormat; flash.net.Socket.endian : flash.utils.Endian; flash.net.URLLoader.dataFormat : URLLoaderDataFormat; flash.net.URLRequest.requestHeaders : Array; flash.net.URLStream.endian : flash.utils.Endian; enum flash.printing.PrintJobOrientation; flash.printing.PrintJob.orientation : PrintJobOrientation; @:require(flash10_1) static flash.printing.PrintJob.isSupported; -flash.sampler.DeleteObjectSample.new -flash.sampler.NewObjectSample.new -flash.sampler.Sample.new flash.sampler.Sample.stack : Array; -flash.sampler.StackFrame.new @:require(flash10_1) flash.sampler.NewObjectSample.size; @:require(flash10_1) flash.sampler.StackFrame.scriptID; -flash.system.Capabilities.new -flash.system.IME.new -flash.system.FSCommand.new enum flash.system.IMEConversionMode; static flash.system.IME.conversionMode : IMEConversionMode @:require(flash10) flash.system.ApplicationDomain.domainMemory; @:require(flash10) static flash.system.ApplicationDomain.MIN_DOMAIN_MEMORY_LENGTH; @:require(flash10) static flash.system.Capabilities.isEmbeddedInAcrobat; @:require(flash10) static flash.system.Capabilities.maxLevelIDC; @:require(flash10_1) static flash.system.Capabilities.cpuArchitecture; @:require(flash10_1) static flash.system.Capabilities.supports32BitProcesses; @:require(flash10_1) static flash.system.Capabilities.supports64BitProcesses; @:require(flash10_1) static flash.system.Capabilities.touchscreenType; static flash.system.Capabilities.touchscreenType : TouchscreenType; enum flash.system.TouchscreenType; @:require(flash10_1) static flash.system.IME.isSupported; @:require(flash10_1) static flash.system.IME.compositionAbandoned; @:require(flash10_1) static flash.system.IME.compositionSelectionChanged; @:require(flash10) flash.system.JPEGLoaderContext; @:require(flash10_1) flash.system.LoaderContext.allowCodeImport; @:require(flash10_1) flash.system.LoaderContext.allowLoadBytesCodeExecution; @:require(flash10_1) static flash.system.Security.APPLICATION; @:require(flash10_1) static flash.system.Security.duplicateSandboxBridgeInputArguments; @:require(flash10_1) static flash.system.Security.duplicateSandboxBridgeOutputArgument; @:require(flash10_1) static flash.system.System.currentTime; @:require(flash10_1) static flash.system.System.freeMemory; @:require(flash10_1) static flash.system.System.preciseStartupTime; @:require(flash10_1) static flash.system.System.privateMemory; @:require(flash10_1) static flash.system.System.totalMemoryNumber; @:require(flash10_1) static flash.system.System.disposeXML; @:require(flash10_1) static flash.system.System.nativeConstructionOnly; enum flash.system.SecurityPanel; -flash.system.Security.new flash.system.Security.$panel : SecurityPanel -flash.system.SecurityDomain.new -flash.system.System.new flash.system.SystemUpdater.$typer : SystemAdapterType; enum flash.text.AntiAliasType; enum flash.text.GridFitType; enum flash.text.FontStyle; enum flash.text.FontType; enum flash.text.TextDisplayMode; enum flash.text.TextFieldType; enum flash.text.TextFieldAutoSize; enum flash.text.TextFormatAlign; enum flash.text.TextFormatDisplay; enum flash.text.TextColorType; flash.text.Font.fontStyle : FontStyle; flash.text.Font.fontType : FontType; static flash.text.Font.enumerateFonts : Array; flash.text.TextField.autoSize : TextFieldAutoSize; flash.text.TextField.antiAliasType : AntiAliasType; flash.text.TextField.gridFitType : GridFitType; flash.text.TextField.type : TextFieldType; flash.text.TextFormat.align : TextFormatAlign; flash.text.TextFormat.blockIndent : Null flash.text.TextFormat.bold : Null; flash.text.TextFormat.bullet : Null; flash.text.TextFormat.color : Null; flash.text.TextFormat.display : TextFormatDisplay; flash.text.TextFormat.indent : Null; flash.text.TextFormat.italic : Null; flash.text.TextFormat.kerning : Null; flash.text.TextFormat.leading : Null; flash.text.TextFormat.leftMargin : Null; flash.text.TextFormat.letterSpacing : Null; flash.text.TextFormat.rightMargin : Null; flash.text.TextFormat.size : Null; flash.text.TextFormat.tabStops : Array; flash.text.TextFormat.underline : Null; flash.text.TextFormat.$size : Null; flash.text.TextFormat.$color : Null; flash.text.TextFormat.$bold : Null; flash.text.TextFormat.$italic : Null; flash.text.TextFormat.$underline : Null; flash.text.TextFormat.$align : TextFormatAlign; flash.text.TextFormat.$leftMargin : Null; flash.text.TextFormat.$rightMargin : Null; flash.text.TextFormat.$indent : Null; flash.text.TextFormat.$leading : Null; @:require(flash10) static flash.text.TextField.isFontCompatible; -flash.text.TextRenderer.new static flash.text.TextRenderer.antiAliasType : AntiAliasType; static flash.text.TextRenderer.displayMode : TextDisplayMode; flash.text.TextRenderer.$fontStyle : FontStyle; flash.text.TextRenderer.$colorType : TextColorType; @:require(flash10_1) static flash.text.engine.FontDescription.isDeviceFontCompatible; @:require(flash10_1) flash.text.engine.SpaceJustifier.maximumSpacing; @:require(flash10_1) flash.text.engine.SpaceJustifier.minimumSpacing; @:require(flash10_1) flash.text.engine.SpaceJustifier.optimumSpacing; @:require(flash10_1) flash.text.engine.TextBlock.recreateTextLine; @:require(flash10_1) flash.text.engine.TextBlock.releaseLineCreationData; @:require(flash10_1) flash.text.engine.TextLine.hasTabs; flash.text.engine.ContentElement.textRotation : TextRotation; flash.text.engine.ContentElement.$textRotation : TextRotation; flash.text.engine.EastAsianJustifier.justificationStyle : JustificationStyle; flash.text.engine.EastAsianJustifier.$justificationStyle : JustificationStyle; flash.text.engine.EastAsianJustifier.$lineJustification : LineJustification; enum flash.text.engine.BreakOpportunity; enum flash.text.engine.CFFHinting; enum flash.text.engine.DigitCase; enum flash.text.engine.DigitWidth; enum flash.text.engine.FontLookup; enum flash.text.engine.FontPosture; enum flash.text.engine.FontWeight; enum flash.text.engine.JustificationStyle; enum flash.text.engine.Kerning; enum flash.text.engine.LigatureLevel; enum flash.text.engine.LineJustification; enum flash.text.engine.RenderingMode; enum flash.text.engine.TabAlignment; enum flash.text.engine.TextBaseline; enum flash.text.engine.TextLineCreationResult; enum flash.text.engine.TextLineValidity; enum flash.text.engine.TextRotation; enum flash.text.engine.TypographicCase; flash.text.engine.ElementFormat.alignmentBaseline : TextBaseline; flash.text.engine.ElementFormat.breakOpportunity : BreakOpportunity; flash.text.engine.ElementFormat.digitCase : DigitCase; flash.text.engine.ElementFormat.digitWidth : DigitWidth; flash.text.engine.ElementFormat.dominantBaseline : TextBaseline; flash.text.engine.ElementFormat.kerning : Kerning; flash.text.engine.ElementFormat.ligatureLevel : LigatureLevel; flash.text.engine.ElementFormat.textRotation : TextRotation; flash.text.engine.ElementFormat.typographicCase : TypographicCase; flash.text.engine.ElementFormat.$alignmentBaseline : TextBaseline; flash.text.engine.ElementFormat.$breakOpportunity : BreakOpportunity; flash.text.engine.ElementFormat.$digitCase : DigitCase; flash.text.engine.ElementFormat.$digitWidth : DigitWidth; flash.text.engine.ElementFormat.$dominantBaseline : TextBaseline; flash.text.engine.ElementFormat.$kerning : Kerning; flash.text.engine.ElementFormat.$ligatureLevel : LigatureLevel; flash.text.engine.ElementFormat.$textRotation : TextRotation; flash.text.engine.ElementFormat.$typographicCase : TypographicCase; flash.text.engine.FontDescription.cffHinting : CFFHinting; flash.text.engine.FontDescription.fontLookup : FontLookup; flash.text.engine.FontDescription.fontPosture : FontPosture; flash.text.engine.FontDescription.fontWeight : FontWeight; flash.text.engine.FontDescription.renderingMode : RenderingMode; flash.text.engine.FontDescription.$cffHinting : CFFHinting; flash.text.engine.FontDescription.$fontLookup : FontLookup; flash.text.engine.FontDescription.$fontPosture : FontPosture; flash.text.engine.FontDescription.$fontWeight : FontWeight; flash.text.engine.FontDescription.$renderingMode : RenderingMode; flash.text.engine.GraphicElement.$textRotation : TextRotation; flash.text.engine.GroupElement.$textRotation : TextRotation; flash.text.engine.SpaceJustifier.$lineJustification : LineJustification; flash.text.engine.TabStop.alignment : TabAlignment; flash.text.engine.TabStop.$alignment : TabAlignment; flash.text.engine.TextBlock.baselineZero : TextBaseline; flash.text.engine.TextBlock.lineRotation : TextRotation; flash.text.engine.TextBlock.textLineCreationResult : TextLineCreationResult; flash.text.engine.TextBlock.$baselineZero : TextBaseline; flash.text.engine.TextBlock.$lineRotation : TextRotation; flash.text.engine.TextBlock.$textLineCreationResult : TextLineCreationResult; flash.text.engine.TextElement.$textRotation : TextRotation; flash.text.engine.TextJustifier.lineJustification : LineJustification; flash.text.engine.TextJustifier.$lineJustification : LineJustification; flash.text.engine.TextLine.baseline : TextBaseline; -flash.trace.Trace.new -static flash.xml.XMLList.length -static flash.xml.XML.length -flash.text.engine.TextElement.text -flash.ui.Keyboard.new -flash.ui.Mouse.new enum flash.ui.MultitouchInputMode; -flash.ui.Multitouch.new flash.ui.Multitouch.inputMode : MultitouchInputMode; @:require(flash10) flash.ui.ContextMenu.clipboardItems; @:require(flash10) flash.ui.ContextMenu.clipboardMenu; @:require(flash10) flash.ui.ContextMenu.link; @:require(flash10_1) static flash.ui.ContextMenu.isSupported; @:require(flash10) static flash.ui.Mouse.cursor; static flash.ui.Mouse.cursor : Dynamic; @:require(flash10_1) static flash.ui.Keyboard.A; @:require(flash10_1) static flash.ui.Keyboard.B; @:require(flash10_1) static flash.ui.Keyboard.C; @:require(flash10_1) static flash.ui.Keyboard.D; @:require(flash10_1) static flash.ui.Keyboard.E; @:require(flash10_1) static flash.ui.Keyboard.F; @:require(flash10_1) static flash.ui.Keyboard.G; @:require(flash10_1) static flash.ui.Keyboard.H; @:require(flash10_1) static flash.ui.Keyboard.I; @:require(flash10_1) static flash.ui.Keyboard.J; @:require(flash10_1) static flash.ui.Keyboard.K; @:require(flash10_1) static flash.ui.Keyboard.L; @:require(flash10_1) static flash.ui.Keyboard.M; @:require(flash10_1) static flash.ui.Keyboard.N; @:require(flash10_1) static flash.ui.Keyboard.O; @:require(flash10_1) static flash.ui.Keyboard.P; @:require(flash10_1) static flash.ui.Keyboard.Q; @:require(flash10_1) static flash.ui.Keyboard.R; @:require(flash10_1) static flash.ui.Keyboard.S; @:require(flash10_1) static flash.ui.Keyboard.T; @:require(flash10_1) static flash.ui.Keyboard.U; @:require(flash10_1) static flash.ui.Keyboard.V; @:require(flash10_1) static flash.ui.Keyboard.W; @:require(flash10_1) static flash.ui.Keyboard.X; @:require(flash10_1) static flash.ui.Keyboard.Y; @:require(flash10_1) static flash.ui.Keyboard.Z; @:require(flash10_1) static flash.ui.Keyboard.ALTERNATE; @:require(flash10_1) static flash.ui.Keyboard.BACKQUOTE; @:require(flash10_1) static flash.ui.Keyboard.BACKSLASH; @:require(flash10_1) static flash.ui.Keyboard.COMMA; @:require(flash10_1) static flash.ui.Keyboard.COMMAND; @:require(flash10_1) static flash.ui.Keyboard.CharCodeStrings; @:require(flash10_1) static flash.ui.Keyboard.EQUAL; @:require(flash10_1) static flash.ui.Keyboard.LEFTBRACKET; @:require(flash10_1) static flash.ui.Keyboard.MINUS; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_0; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_1; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_2; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_3; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_4; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_5; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_6; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_7; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_8; @:require(flash10_1) static flash.ui.Keyboard.NUMBER_9; @:require(flash10_1) static flash.ui.Keyboard.NUMPAD; @:require(flash10_1) static flash.ui.Keyboard.PERIOD; @:require(flash10_1) static flash.ui.Keyboard.QUOTE; @:require(flash10_1) static flash.ui.Keyboard.RIGHTBRACKET; @:require(flash10_1) static flash.ui.Keyboard.SEMICOLON; @:require(flash10_1) static flash.ui.Keyboard.SLASH; @:require(flash10_1) static flash.ui.Keyboard.hasVirtualKeyboard; @:require(flash10_1) static flash.ui.Keyboard.physicalKeyboardType; enum flash.ui.KeyboardType; enum flash.ui.KeyLocation; static flash.ui.Keyboard.physicalKeyboardType : KeyboardType; @:require(flash10_1) flash.ui.Multitouch; static flash.ui.Multitouch.inputMode : MultitouchInputMode; @:require(flash10_1) flash.ui.MultitouchInputMode; @:require(flash10_1) static flash.ui.Keyboard.STRING_BEGIN; @:require(flash10_1) static flash.ui.Keyboard.STRING_BREAK; @:require(flash10_1) static flash.ui.Keyboard.STRING_CLEARDISPLAY; @:require(flash10_1) static flash.ui.Keyboard.STRING_CLEARLINE; @:require(flash10_1) static flash.ui.Keyboard.STRING_DELETE; @:require(flash10_1) static flash.ui.Keyboard.STRING_DELETECHAR; @:require(flash10_1) static flash.ui.Keyboard.STRING_DELETELINE; @:require(flash10_1) static flash.ui.Keyboard.STRING_DOWNARROW; @:require(flash10_1) static flash.ui.Keyboard.STRING_END; @:require(flash10_1) static flash.ui.Keyboard.STRING_EXECUTE; @:require(flash10_1) static flash.ui.Keyboard.STRING_F1; @:require(flash10_1) static flash.ui.Keyboard.STRING_F10; @:require(flash10_1) static flash.ui.Keyboard.STRING_F11; @:require(flash10_1) static flash.ui.Keyboard.STRING_F12; @:require(flash10_1) static flash.ui.Keyboard.STRING_F13; @:require(flash10_1) static flash.ui.Keyboard.STRING_F14; @:require(flash10_1) static flash.ui.Keyboard.STRING_F15; @:require(flash10_1) static flash.ui.Keyboard.STRING_F16; @:require(flash10_1) static flash.ui.Keyboard.STRING_F17; @:require(flash10_1) static flash.ui.Keyboard.STRING_F18; @:require(flash10_1) static flash.ui.Keyboard.STRING_F19; @:require(flash10_1) static flash.ui.Keyboard.STRING_F2; @:require(flash10_1) static flash.ui.Keyboard.STRING_F20; @:require(flash10_1) static flash.ui.Keyboard.STRING_F21; @:require(flash10_1) static flash.ui.Keyboard.STRING_F22; @:require(flash10_1) static flash.ui.Keyboard.STRING_F23; @:require(flash10_1) static flash.ui.Keyboard.STRING_F24; @:require(flash10_1) static flash.ui.Keyboard.STRING_F25; @:require(flash10_1) static flash.ui.Keyboard.STRING_F26; @:require(flash10_1) static flash.ui.Keyboard.STRING_F27; @:require(flash10_1) static flash.ui.Keyboard.STRING_F28; @:require(flash10_1) static flash.ui.Keyboard.STRING_F29; @:require(flash10_1) static flash.ui.Keyboard.STRING_F3; @:require(flash10_1) static flash.ui.Keyboard.STRING_F30; @:require(flash10_1) static flash.ui.Keyboard.STRING_F31; @:require(flash10_1) static flash.ui.Keyboard.STRING_F32; @:require(flash10_1) static flash.ui.Keyboard.STRING_F33; @:require(flash10_1) static flash.ui.Keyboard.STRING_F34; @:require(flash10_1) static flash.ui.Keyboard.STRING_F35; @:require(flash10_1) static flash.ui.Keyboard.STRING_F4; @:require(flash10_1) static flash.ui.Keyboard.STRING_F5; @:require(flash10_1) static flash.ui.Keyboard.STRING_F6; @:require(flash10_1) static flash.ui.Keyboard.STRING_F7; @:require(flash10_1) static flash.ui.Keyboard.STRING_F8; @:require(flash10_1) static flash.ui.Keyboard.STRING_F9; @:require(flash10_1) static flash.ui.Keyboard.STRING_FIND; @:require(flash10_1) static flash.ui.Keyboard.STRING_HELP; @:require(flash10_1) static flash.ui.Keyboard.STRING_HOME; @:require(flash10_1) static flash.ui.Keyboard.STRING_INSERT; @:require(flash10_1) static flash.ui.Keyboard.STRING_INSERTCHAR; @:require(flash10_1) static flash.ui.Keyboard.STRING_INSERTLINE; @:require(flash10_1) static flash.ui.Keyboard.STRING_LEFTARROW; @:require(flash10_1) static flash.ui.Keyboard.STRING_MENU; @:require(flash10_1) static flash.ui.Keyboard.STRING_MODESWITCH; @:require(flash10_1) static flash.ui.Keyboard.STRING_NEXT; @:require(flash10_1) static flash.ui.Keyboard.STRING_PAGEDOWN; @:require(flash10_1) static flash.ui.Keyboard.STRING_PAGEUP; @:require(flash10_1) static flash.ui.Keyboard.STRING_PAUSE; @:require(flash10_1) static flash.ui.Keyboard.STRING_PREV; @:require(flash10_1) static flash.ui.Keyboard.STRING_PRINT; @:require(flash10_1) static flash.ui.Keyboard.STRING_PRINTSCREEN; @:require(flash10_1) static flash.ui.Keyboard.STRING_REDO; @:require(flash10_1) static flash.ui.Keyboard.STRING_RESET; @:require(flash10_1) static flash.ui.Keyboard.STRING_RIGHTARROW; @:require(flash10_1) static flash.ui.Keyboard.STRING_SCROLLLOCK; @:require(flash10_1) static flash.ui.Keyboard.STRING_SELECT; @:require(flash10_1) static flash.ui.Keyboard.STRING_STOP; @:require(flash10_1) static flash.ui.Keyboard.STRING_SYSREQ; @:require(flash10_1) static flash.ui.Keyboard.STRING_SYSTEM; @:require(flash10_1) static flash.ui.Keyboard.STRING_UNDO; @:require(flash10_1) static flash.ui.Keyboard.STRING_UPARROW; @:require(flash10_1) static flash.ui.Keyboard.STRING_USER; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_BEGIN; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_BREAK; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_CLEARDISPLAY; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_CLEARLINE; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_DELETE; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_DELETECHAR; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_DELETELINE; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_DOWNARROW; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_END; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_EXECUTE; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F1; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F10; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F11; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F12; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F13; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F14; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F15; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F16; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F17; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F18; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F19; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F2; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F20; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F21; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F22; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F23; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F24; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F25; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F26; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F27; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F28; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F29; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F3; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F30; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F31; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F32; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F33; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F34; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F35; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F4; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F5; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F6; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F7; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F8; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_F9; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_FIND; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_HELP; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_HOME; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_INSERT; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_INSERTCHAR; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_INSERTLINE; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_LEFTARROW; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_MENU; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_MODESWITCH; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_NEXT; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_PAGEDOWN; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_PAGEUP; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_PAUSE; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_PREV; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_PRINT; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_PRINTSCREEN; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_REDO; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_RESET; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_RIGHTARROW; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_SCROLLLOCK; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_SELECT; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_STOP; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_SYSREQ; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_SYSTEM; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_UNDO; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_UPARROW; @:require(flash10_1) static flash.ui.Keyboard.KEYNAME_USER; @:require(flash10_1) static flash.ui.Mouse.supportsCursor; enum flash.utils.Endian; @:native("RegExp") flash.utils.RegExp; -static flash.utils.RegExp.length; flash.utils.ObjectInput.endian : Endian; flash.utils.ObjectOutput.endian : Endian; flash.utils.ByteArray.endian : Endian; flash.utils.IDataInput.endian : Endian; flash.utils.IDataOutput.endian : Endian; @:require(flash10) flash.utils.ByteArray.clear; @:require(flash10) flash.utils.ByteArray.deflate; @:require(flash10) flash.utils.ByteArray.inflate; @:require(flash10) flash.utils.SetIntervalTimer.clearArrayEntry; -flash.utils.Namespace.toString -flash.utils.Namespace.valueOf -static flash.utils.Namespace.length -flash.utils.QName.toString -flash.utils.QName.valueOf -static flash.utils.QName.length enum flash.xml.XMLNodeType; flash.xml.XMLNode.nodeType : XMLNodeType; flash.xml.XMLNode.$type : XMLNodeType; flash.xml.XML.namespace : flash.utils.Namespace; flash.xml.XML.parent : XML; flash.xml.XMLList.namespace : flash.utils.Namespace; flash.xml.XMLList.parent : XML; flash.xml.XMLTag.type : XMLNodeType; enum flash.system.SystemUpdaterType; @:require(flash10_1) flash.system.SystemUpdater; flash.system.SystemUpdater.$type : SystemUpdaterType; @:require(flash10_1) flash.sensors.Accelerometer; @:require(flash10_1) flash.sensors.Geolocation; @:require(flash10_1) flash.globalization.Collator; @:require(flash10_1) flash.globalization.CurrencyFormatter; @:require(flash10_1) flash.globalization.DateTimeFormatter; @:require(flash10_1) flash.globalization.LocaleID; @:require(flash10_1) flash.globalization.StringTools; @:require(flash10_1) flash.globalization.NumberFormatter; @:require(flash10_1) flash.globalization.NumberParseResult; enum flash.globalization.CollatorMode; enum flash.globalization.DateTimeNameContext; enum flash.globalization.DateTimeNameStyle; enum flash.globalization.DateTimeStyle; enum flash.globalization.LastOperationStatus; enum flash.globalization.NationalDigitsType; flash.globalization.Collator.lastOperationStatus : LastOperationStatus; flash.globalization.Collator.$initialMode : CollatorMode; flash.globalization.CurrencyFormatter.lastOperationStatus : LastOperationStatus; flash.globalization.DateTimeFormatter.lastOperationStatus : LastOperationStatus; flash.globalization.DateTimeFormatter.$dateStyle : DateTimeStyle; flash.globalization.DateTimeFormatter.$nameStyle : DateTimeNameStyle; flash.globalization.DateTimeFormatter.$timeStyle : DateTimeStyle; flash.globalization.DateTimeFormatter.$context : DateTimeNameContext; flash.globalization.DateTimeFormatter.getDateStyle : DateTimeStyle; flash.globalization.DateTimeFormatter.getTimeStyle : DateTimeStyle; flash.globalization.DateTimeFormatter.getDateTimePattern : DateTimeStyle; flash.globalization.LocaleID.lastOperationStatus : LastOperationStatus; flash.globalization.NumberFormatter.lastOperationStatus : LastOperationStatus; flash.globalization.NumberFormatter.digitsType : NationalDigitsType; flash.globalization.StringTools.lastOperationStatus : LastOperationStatus; // FP 10.2 @:require(flash10_2) flash.ui.MouseCursorData; @:require(flash10_2) flash.events.StageVideoEvent; @:require(flash10_2) flash.events.VideoEvent; @:require(flash10_2) flash.media.MicrophoneEnhancedMode; @:require(flash10_2) flash.media.MicrophoneEnhancedOptions; @:require(flash10_2) flash.media.StageVideo; @:require(flash10_2) flash.display.Stage.color; @:require(flash10_2) flash.display.Stage.stageVideos; @:require(flash10_2) flash.media.Microphone.enhancedOptions; @:require(flash10_2) static flash.media.Microphone.getEnhancedMicrophone; @:require(flash10_2) flash.system.Capabilities.allowsFullScreen; @:require(flash10_2) static flash.ui.Keyboard.AUDIO; @:require(flash10_2) static flash.ui.Keyboard.BACK; @:require(flash10_2) static flash.ui.Keyboard.BLUE; @:require(flash10_2) static flash.ui.Keyboard.CHANNEL_DOWN; @:require(flash10_2) static flash.ui.Keyboard.CHANNEL_UP; @:require(flash10_2) static flash.ui.Keyboard.DVR; @:require(flash10_2) static flash.ui.Keyboard.EXIT; @:require(flash10_2) static flash.ui.Keyboard.FAST_FORWARD; @:require(flash10_2) static flash.ui.Keyboard.GREEN; @:require(flash10_2) static flash.ui.Keyboard.GUIDE; @:require(flash10_2) static flash.ui.Keyboard.HELP; @:require(flash10_2) static flash.ui.Keyboard.INFO; @:require(flash10_2) static flash.ui.Keyboard.INPUT; @:require(flash10_2) static flash.ui.Keyboard.LAST; @:require(flash10_2) static flash.ui.Keyboard.LIVE; @:require(flash10_2) static flash.ui.Keyboard.MASTER_SHELL; @:require(flash10_2) static flash.ui.Keyboard.MENU; @:require(flash10_2) static flash.ui.Keyboard.NEXT; @:require(flash10_2) static flash.ui.Keyboard.PAUSE; @:require(flash10_2) static flash.ui.Keyboard.PLAY; @:require(flash10_2) static flash.ui.Keyboard.PREVIOUS; @:require(flash10_2) static flash.ui.Keyboard.RECORD; @:require(flash10_2) static flash.ui.Keyboard.RED; @:require(flash10_2) static flash.ui.Keyboard.REWIND; @:require(flash10_2) static flash.ui.Keyboard.SEARCH; @:require(flash10_2) static flash.ui.Keyboard.SETUP; @:require(flash10_2) static flash.ui.Keyboard.SKIP_BACKWARD; @:require(flash10_2) static flash.ui.Keyboard.SKIP_FORWARD; @:require(flash10_2) static flash.ui.Keyboard.STOP; @:require(flash10_2) static flash.ui.Keyboard.SUBTITLE; @:require(flash10_2) static flash.ui.Keyboard.VOD; @:require(flash10_2) static flash.ui.Keyboard.YELLOW; @:require(flash10_2) static flash.ui.Mouse.registerCursor; enum flash.media.MicrophoneEnhancedMode; flash.media.MicrophoneEnhancedOptions.mode : MicrophoneEnhancedMode; enum flash.display.FocusDirection; // FLASH 11 FEATURES -flash.automation.Configuration.new @:require(flash11) flash.display.DisplayObjectContainer.removeChildren; @:require(flash11) flash.display.Graphics.cubicCurveTo; @:require(flash11) flash.display.GraphicsPath.cubicCurveTo; @:require(flash11) flash.display.InteractiveObject.needsSoftKeyboard; @:require(flash11) flash.display.InteractiveObject.softKeyboardInputAreaOfInterest; @:require(flash11) flash.display.InteractiveObject.requestSoftKeyboard; @:require(flash11) flash.display.MovieClip.isPlaying; @:require(flash11) flash.display.Stage.displayContextInfo; @:require(flash11) flash.display.Stage.softKeyboardRect; @:require(flash11) flash.display.Stage.stage3Ds; @:require(flash11) flash.display.Stage3D; -flash.display.Stage.constructor; -flash.display.Stage.hasOwnProperty; -flash.display.Stage.isPrototypeOf; -flash.display.Stage.propertyIsEnumerable; -flash.display.Stage.setPropertyIsEnumerable; -flash.display.Stage.toLocaleString; -flash.display.Stage.valueOf; enum flash.display3D.Context3DBlendFactor; enum flash.display3D.; @:require(flash11) static flash.events.Event.CONTEXT3D_CREATE; @:require(flash11) static flash.events.Event.TEXT_INTERACTION_MODE_CHANGE; @:require(flash11) static flash.events.StageVideoEvent.RENDER_STATUS_AVAILABLE; @:require(flash11) static flash.events.StageVideoEvent.STAGE_VIDEO_STATE; @:require(flash11) flash.geom.Matrix3D.copyColumnFrom; @:require(flash11) flash.geom.Matrix3D.copyColumnTo; @:require(flash11) flash.geom.Matrix3D.copyFrom; @:require(flash11) flash.geom.Matrix3D.copyRawDataFrom; @:require(flash11) flash.geom.Matrix3D.copyRawDataTo; @:require(flash11) flash.geom.Matrix3D.copyRowFrom; @:require(flash11) flash.geom.Matrix3D.copyRowTo; @:require(flash11) flash.geom.Matrix3D.copyToMatrix3D; @:require(flash11) flash.geom.Matrix.copyColumnFrom; @:require(flash11) flash.geom.Matrix.copyColumnTo; @:require(flash11) flash.geom.Matrix.copyFrom; @:require(flash11) flash.geom.Matrix.copyRowFrom; @:require(flash11) flash.geom.Matrix.copyRowTo; @:require(flash11) flash.geom.Matrix.setTo; @:require(flash11) flash.geom.Point.copyFrom; @:require(flash11) flash.geom.Point.setTo; @:require(flash11) flash.geom.Rectangle.copyFrom; @:require(flash11) flash.geom.Rectangle.setTo; @:require(flash11) flash.geom.Vector3D.copyFrom; @:require(flash11) flash.geom.Vector3D.setTo; @:require(flash11) flash.media.Sound.loadCompressedDataFromByteArray; @:require(flash11) flash.media.Sound.loadPCMFromByteArray; @:require(flash11) flash.net.Socket.bytesPending; -flash.display3D.Context3DClearMask.new; enum flash.display3D.Context3DCompareMode; enum flash.display3D.Context3DProgramType; enum flash.display3D.Context3DRenderMode; enum flash.display3D.Context3DStencilAction; enum flash.display3D.Context3DTextureFormat; enum flash.display3D.Context3DTriangleFace; enum flash.display3D.Context3DVertexBufferFormat; -flash.display.Stage3D.new; -flash.display3D.Context3D.new; -flash.display3D.IndexBuffer3D.new; -flash.display3D.Program3D.new; -flash.display3D.VertexBuffer3D.new; -flash.display3D.textures.CubeTexture.new; -flash.display3D.textures.TextureBase.new; -flash.display3D.textures.Texture.new; flash.display3D.Context3D.$sourceFactor : Context3DBlendFactor; flash.display3D.Context3D.$destinationFactor : Context3DBlendFactor; flash.display3D.Context3D.$format : Context3DTextureFormat; flash.display3D.Context3D.$triangleFaceToCull : Context3DTriangleFace; flash.display3D.Context3D.$triangleFace : Context3DTriangleFace; flash.display3D.Context3D.$passCompareMode : Context3DCompareMode; flash.display3D.Context3D.$compareMode : Context3DCompareMode; flash.display3D.Context3D.$programType : Context3DProgramType; flash.display3D.Context3D.$actionOnBothPass : Context3DStencilAction; flash.display3D.Context3D.$actionOnDepthFail : Context3DStencilAction; flash.display3D.Context3D.$actionOnDepthPassStencilFail : Context3DStencilAction; flash.display3D.Context3D.$setVertexBufferAt__format : Context3DVertexBufferFormat; @:require(flash11) flash.net.NetStream.useHardwareDecoder; @:require(flash11) flash.net.NetStream.videoStreamSettings; @:require(flash11) flash.net.SecureSocket; @:require(flash11) flash.net.NetMonitor; @:require(flash11) static flash.system.Capabilities.hasMultiChannelAudio; @:require(flash11) flash.system.LoaderContext.imageDecodingPolicy; @:require(flash11) flash.system.LoaderContext.parameters; @:require(flash11) flash.system.LoaderContext.requestedContentParent; enum flash.system.ImageDecodingPolicy; flash.system.LoaderContext.imageDecodingPolicy : ImageDecodingPolicy; @:require(flash11) static flash.system.Security.pageDomain; @:require(flash11) static flash.system.System.processCPUUsage; @:require(flash11) static flash.system.System.pauseForGCIfCollectionImminent; @:require(flash11) static flash.ui.Mouse.supportsNativeCursor; @:require(flash11) static flash.ui.Mouse.unregisterCursor; -flash.ui.MouseCursor.new; @:require(flash11) flash.utils.CompressionAlgorithm; enum flash.utils.CompressionAlgorithm; @:require(flash11) flash.xml.XML.toJSON; @:require(flash11) flash.xml.XMLList.toJSON; flash.utils.ByteArray.$algorithm : CompressionAlgorithm; @:require(flash11) flash.text.TextField.textInteractionMode; enum flash.text.TextInteractionMode; flash.text.TextField.textInteractionMode : TextInteractionMode; // 11.2 enum flash.display.BitmapCompressColorSpace; @:require(flash11_2) flash.display.BitmapData.compress; @:require(flash11_2) flash.media.Camera.position; @:require(flash11_2) flash.net.NetStream.dispose; @:require(flash11_2) flash.display.StageWorker; @:require(flash11_2) flash.display.Worker; @:require(flash11_8) flash.events.GameInputEvent; @:require(flash11_2) flash.events.ThrottleEvent; flash.events.ThrottleEvent.$type : ThrottleType; enum flash.events.ThrottleType; @:require(flash11_8) flash.ui.GameInput; @:require(flash11_8) flash.ui.GameInputDevice; -flash.ui.GameInput.new; @:require(flash11_2) flash.utils.Telemetry; enum flash.ui.GameInputFinger; enum flash.ui.GameInputHand; enum flash.ui.GameInputControlType; flash.ui.GameInputControl.finger : flash.ui.GameInputFinger; flash.ui.GameInputControl.hand : flash.ui.GameInputHand; flash.ui.GameInputControl.type : flash.ui.GameInputControlType; // 11.2 @:require(flash11_2) flash.display3D.Context3D.setProgramConstantsFromByteArray @:require(flash11_2) flash.display.Stage.mouseLock; @:require(flash11_2) flash.events.MouseEvent.movementX; @:require(flash11_2) flash.events.MouseEvent.movementY; @:require(flash11_2) static flash.events.MouseEvent.CONTEXT_MENU; @:require(flash11_2) static flash.events.MouseEvent.MIDDLE_CLICK; @:require(flash11_2) static flash.events.MouseEvent.MIDDLE_MOUSE_DOWN; @:require(flash11_2) static flash.events.MouseEvent.MIDDLE_MOUSE_UP; @:require(flash11_2) static flash.events.MouseEvent.RIGHT_CLICK; @:require(flash11_2) static flash.events.MouseEvent.RIGHT_MOUSE_DOWN; @:require(flash11_2) static flash.events.MouseEvent.RIGHT_MOUSE_UP; // 11.3 @:require(flash11_3) flash.display.BitmapData.drawWithQuality flash.display.BitmapData.$quality : StageQuality; enum flash.display.BitmapEncodingColorSpace; flash.display.JPEGXREncoderOptions.$colorSpace : BitmapEncodingColorSpace; flash.display.JPEGXREncoderOptions.colorSpace : BitmapEncodingColorSpace; @:require(flash11_3) flash.display.BitmapData.encode @:require(flash11_3) flash.display.Stage.allowsFullScreenInteractive @:require(flash11_3) static flash.events.Event.FRAME_LABEL; @:require(flash11_3) static flash.events.Event.SUSPEND; @:require(flash11_3) static flash.events.FullScreenEvent.FULL_SCREEN_INTERACTIVE_ACCEPTED; @:require(flash11_3) flash.events.FullScreenEvent.interactive; @:require(flash11_3) static flash.events.MouseEvent.RELEASE_OUTSIDE; @:require(flash11_3) flash.net.NetStream.useJitterBuffer; @:require(flash11_3) flash.system.ApplicationDomain.getQualifiedDefinitionNames; @:require(flash11_3) flash.system.SecurityDomain.domainID; @:require(flash11_3) flash.system.ApplicationInstaller; @:require(flash11_3) flash.system.AuthorizedFeatures; @:require(flash11_3) flash.system.AuthorizedFeaturesLoader; @:require(flash11_3) static flash.events.Event.TEXTURE_READY; // 11.4 @:require(flash11_4) flash.display.BitmapData.copyPixelsToByteArray; @:require(flash11_4) flash.concurrent.Mutex; @:require(flash11_4) flash.concurrent.Condition; enum flash.display3D.Context3DProfile; flash.display.Stage3D.$profile : flash.display3D.Context3DProfile; @:require(flash11_4) flash.display.LoaderInfo.childSandboxBridge; @:require(flash11_4) flash.display.LoaderInfo.parentSandboxBridge; @:require(flash11_4) flash.display.Stage.contentsScaleFactor; @:require(flash11_4) flash.media.Camera.copyToByteArray; @:require(flash11_4) flash.media.Camera.copyToVector; @:require(flash11_4) flash.media.Camera.drawToBitmapData; @:require(flash11_4) flash.media.StageVideo.attachCamera; @:require(flash11_4) flash.net.URLStream.diskCacheEnabled; @:require(flash11_4) flash.net.URLStream.length; @:require(flash11_4) flash.net.URLStream.position; @:require(flash11_4) flash.net.URLStream.stop; @:require(flash11_4) flash.system.AuthorizedFeatures.enableDiskCache; @:require(flash11_4) flash.system.AuthorizedFeatures.isFeatureEnabled; @:require(flash11_4) flash.system.AuthorizedFeatures.isNegativeToken; @:require(flash11_4) flash.system.AuthorizedFeaturesLoader.makeGlobal; @:require(flash11_4) flash.utils.ByteArray.shareable; @:require(flash11_4) flash.utils.ByteArray.atomicCompareAndSwapIntAt; @:require(flash11_4) flash.utils.ByteArray.atomicCompareAndSwapLength; //not supported @:require(flash11_4) flash.utils.CompressionAlgorithm.LZMA; @:require(flash11_4) flash.system.Worker; @:require(flash11_4) flash.system.WorkerDomain; @:require(flash11_4) flash.system.MessageChannel; -flash.system.Worker.new; -flash.system.MessageChannel.new; flash.system.Worker.state : WorkerState; flash.system.MessageChannel.state : MessageChannelState; enum flash.system.WorkerState; // --- 11.6 API enum flash.display3D.Context3DMipFilter enum flash.display3D.Context3DTextureFilter enum flash.display3D.Context3DWrapMode enum flash.system.ApplicationInstallerMode @:require(flash11_6) flash.display3D.Context3D.setSamplerStateAt flash.display3D.Context3D.$wrap : Context3DWrapMode; flash.display3D.Context3D.$filter : Context3DTextureFilter; flash.display3D.Context3D.$mipfilter : Context3DMipFilter; -flash.display.DisplayObject.metaData @:require(flash11_6) flash.display.Graphics.readGraphicsData @:require(flash11_7) flash.media.StageVideo.attachAVStream; @:require(flash11_7) static flash.net.SharedObject.preventBackup; @:require(flash11_7) flash.system.AuthorizedFeatures.enableHLSPlayback; @:require(flash11_7) flash.system.AuthorizedFeaturesLoader.loadAuthorizedFeaturesFromData; @:require(flash11_8) flash.display.DisplayObjectContainer.stopAllMovieClips @:require(flash11_8) flash.display3D.Context3D.createRectangleTexture @:require(flash12) flash.display.Stage3D.requestContext3DMatchingProfiles @:require(flash12) flash.display3D.Context3D.profile flash.display3D.Context3D.$bufferUsage : Context3DBufferUsage enum flash.display3D.Context3DBufferUsage @:native("flash.profiler.Telemetry") flash.utils.Telemetry @:require(flash12) flash.display3D.Context3DBufferUsage haxe_3.2.1+dfsg.orig/extra/haxeserver.bat0000664000175000017500000000007312607337712020313 0ustar andyandy00000000000000@echo off nekotools server -p 2000 -h localhost -d .\ pausehaxe_3.2.1+dfsg.orig/extra/images/Banner.bmp0000664000175000017500000006407212607337712020632 0ustar andyandy00000000000000BM:h–(–9¤d  ØØ3f™Ìÿ3333f3™3Ì3ÿff3fff™fÌfÿ™™3™f™™™Ì™ÿÌÌ3ÌfÌ™ÌÌÌÿÿÿ3ÿfÿ™ÿÌÿÿ3333f3™3Ì3ÿ3333333f33™33Ì33ÿ3f3f33ff3f™3fÌ3fÿ3™3™33™f3™™3™Ì3™ÿ3Ì3Ì33Ìf3Ì™3ÌÌ3Ìÿ3ÿ3ÿ33ÿf3ÿ™3ÿÌ3ÿÿff3fff™fÌfÿf3f33f3ff3™f3Ìf3ÿffff3fffff™ffÌffÿf™f™3f™ff™™f™Ìf™ÿfÌfÌ3fÌffÌ™fÌÌfÌÿfÿfÿ3fÿffÿ™fÿÌfÿÿ™™3™f™™™Ì™ÿ™3™33™3f™3™™3Ì™3ÿ™f™f3™ff™f™™fÌ™fÿ™™™™3™™f™™™™™Ì™™ÿ™Ì™Ì3™Ìf™Ì™™ÌÌ™Ìÿ™ÿ™ÿ3™ÿf™ÿ™™ÿÌ™ÿÿÌÌ3ÌfÌ™ÌÌÌÿÌ3Ì33Ì3fÌ3™Ì3ÌÌ3ÿÌfÌf3ÌffÌf™ÌfÌÌfÿ̙̙3Ì™fÌ™™Ì™ÌÌ™ÿÌÌÌÌ3ÌÌfÌÌ™ÌÌÌÌÌÿÌÿÌÿ3ÌÿfÌÿ™ÌÿÌÌÿÿÿÿ3ÿfÿ™ÿÌÿÿÿ3ÿ33ÿ3fÿ3™ÿ3Ìÿ3ÿÿfÿf3ÿffÿf™ÿfÌÿfÿÿ™ÿ™3ÿ™fÿ™™ÿ™Ìÿ™ÿÿÌÿÌ3ÿÌfÿÌ™ÿÌÌÿÌÿÿÿÿÿ3ÿÿfÿÿ™ÿÿÌÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÓÓÓ§§§®®®ßßßþþþÄÄÄ™™™µµµÏÏÏ™™™ªªªüüüåååþþþ³³³™™™¨¨¨§§§™™™ÌÌÌÿÿÿãããµµµ§§§™™™ÝÝݧ§§™™™§§§§§§™™™§§§ÁÁÁåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÓÓÓCCCCCCÝÝÝÿÿÿÀÀÀCCCCCCöööEEECCC§§§ååååååVVVCCCfff………CCCCCCØØØÿÿÿCCCCCCHHHúúúCCCCCCCCCCCCCCCCCC|||ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÒÒÒCCCRRRñññþþþCCCaaaåååTTTCCCXXX___\\\DDDHHHÊÊʳ³³CCCEEE¶¶¶‡‡‡CCCJJJÉÉÉÑÑÑCCCCCCJJJMMMMMMMMM€€€ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿ¾¾¾CCCCCCÂÂÂöööÂÂÂCCCCCCÿÿÿ¼¼¼CCCCCCqqqcccCCCEEEøøøÿÿÿÔÔÔCCCCCCCCCCCCwwwåååÿÿÿCCCCCC‹‹‹îîîÖÖÖîîîóóóåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÒÒÒBBBBBBBBBBBBBBBBBBBBBþþþüüüNNNCCC¯¯¯~~~CCCdddÿÿÿÿÿÿÿÿÿ•••CCCCCCIIIùùùþþþþþþBBBBBBBBBBBBBBBBBBÛÛÛÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþÑÑÑBBBBBBBBBBBBBBBBBBBBBýýýýýýˆˆˆBBBbbbOOOBBBÐÐÐþþþþþþþþþŠŠŠBBBBBBFFFóóóýýýýýýBBBBBBXXXwwwwwwwwwÛÛÛþþþþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿþþþäääþþþýýý½½½BBBBBBÃÃÃùùùÁÁÁBBBBBBüüüâââïïïBBBBBBBBBBBBãããþþþþþþÇÇÇBBBBBBDDDBBBkkkâââüüüBBBBBB‚‚‚ÙÙÙÃÃÃÚÚÚïïïãããþþþþþþäääÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýýýýÐÐÐBBBAAAÚÚÚûûû½½½AAAAAAúúúûûûûûûFFFBBBBBB~~~üüüýýýöööDDDBBBcccâââAAAAAA¸¸¸úúúAAAAAAAAAAAAAAABBB{{{üüüýýýþþþþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýüüüüüüää䤤¤òòò÷÷÷¹¹¹œœœªªªøøøøøøøøø¨¨¨ŸŸŸîîîúúúùùù¸¸¸¡¡¡åååæææÆÆÆàààœœœœœœœœœœœœ¶¶¶ûûûüüüýýýýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞþþþýýýâââüüüûûûàààùùùøøøÝÝÝööööööÜÜÜööööööÜÜÜ÷÷÷÷÷÷ÞÞÞøøøùùùßßßùùùùùùßßßøøøøøøÞÞÞ÷÷÷÷÷÷ÜÜÜööööööÜÜÜööö÷÷÷ÝÝÝøøøùùùàààûûûüüüãããýýýþþþåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýüüüûûûúúúøøø÷÷÷öööõõõõõõôôôôôôóóóôôôôôôôôôõõõõõõööö÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷ööööööõõõõõõôôôôôôôôôôôôôôôôôôõõõõõõ÷÷÷øøøùùùúúúûûûüüüýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýüüüûûûúúúøøøíñöÏÝôÏÜóÍÛòÌÚñÌÚñÌÙðËÙðÖàðñññòòòóóóóóóôôôôôôõõõõõõõõõõõõôôôôôôóóóòòòòòòÛçðËàñËàñËàñÌàñÍáòÎãóÎãôÛèõøøøùùùûûûüüüýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿþþþÞÞÞýýýûûûàààùùù÷÷÷´Ôá ú™ùˆ÷ tô!mó!nó!oó!oóA‚ð¸ÍñîîîÖÖÖððððððØØØññññññØØØððððððÖÖÖíîîÇö+™õ”÷”÷•÷”÷÷€õ uô{«öÜÜÜ÷÷÷úúúáááüüüýýýäääÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýýýýûûûúúúøøøööö¼íö­û¦ú¦ú¦ú§úŸù…ö!qó!mó!oó-vóÈØñíííîîîîîîîîîîîîîîîîîîííí”Éö%—÷”÷–÷÷ õ qô!oô!oó!oó!oóc’ôõõõöööùùùúúúüüüýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüûûûùùùøøøõõõºñõÊý¦ú¦ú¦ú¦ú¦ú¦ú§ú¨úšù…ö tô;€óÂÑììììììììììçêìšÉð$–ö÷õ tô!mó!oó!oó!oó!oó!oó!oó!póc‹óôôôöööøøøúúúûûûýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿþþþÝÝÝüüüúúúßßß÷÷÷ôôô¥Ýáæÿ¥ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¨ú¥úšù;—󼨸šÇù&„ó tô!oó!nó!oó!oó!oó!oó!oó!oó!oó!oó!oó!oób‰óÚÚÚõõõøøøßßßûûûýýýäääþþþÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúøøøöööóóó¸ñôñÿ¥ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú§ú™øö!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó!kób‰óòòòôôô÷÷÷ùùùûûûüüüþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúøøøöööóóó·ðóóÿ±ü¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú§ú—ø”÷•÷ö!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó!dób‰óòòòôôô÷÷÷ùùùûûûüüüýýýþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿþþþÝÝÝüüüúúúØØØöööóóó¤ÝàóÿÈý¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú—ø”÷”÷”÷•÷€ö!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó"]òb‰óØØØôôô÷÷÷ßßßûûûüüüäääþþþÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúøøøöööóóó·ðóòÿàþ¥ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú¦ú˜ø”÷”÷”÷”÷”÷•÷€ö!oó!oó!oó!oó!oó!oó!oó!oó!oó!oó"Yòb‰óñññôôô÷÷÷ùùùûûûýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúùùù÷÷÷óóóÊðòñþðÿ§û¦ú¦ú¦ú¦ú¦ú¦ú¦ú§ú—ø”÷”÷”÷”÷”÷”÷”÷•÷ö!oó!oó!oó!oó!oó!oó!oó!oó!kó"Xñr”òòòòôôô÷÷÷ùùùûûûýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿþþþÞÞÞüüüúúúÙÙÙ÷÷÷ôôôÓØØ¢ðôõÿ­û¦ú¦ú¦ú¦ú¦ú¦ú§ú–ø”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷ö!oó!oó!oó!oó!oó!oó!oó!dó!XñÖÝîÙÙÙôôôøøøàààûûûýýýäääÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýûûûùùù÷÷÷ôôôòòòéîïòþÆý¦ú¦ú¦ú¦ú¦ú¦ú˜ø”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷€ö!oó!oó!oó!oó!oó!oó"]òq“óïïðóóóõõõøøøúúúûûûýýýþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýûûûúúúøøøõõõóóóðððŠîóáþ¦ú¦ú¦ú¦ú§ú˜ø”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷€ö!oó!oó!oó!oó!pó"XðÖÜîñññóóóöööùùùúúúüüüýýýþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝýýýüüüÚÚÚøøøõõõÒÒÒðððîîîôý¢ú¦ú¦ú§ú–ø”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷ö!oó!oó!oó!mó`„ëïïïñññÛÛÛöööùùùáááüüüþþþäääÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþüüüúúúùùùöööóóóñññîîîöú©û¦ú¦ú—ø”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷€ö!nó!oó"fòÝâïïïïòòòôôô÷÷÷ùùùûûûüüüþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþüüüûûûùùùöööôôôñññïïïìììÂû¦ú˜ø”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷ö!oóW‚òìììðððòòòõõõ÷÷÷úúúûûûüüüþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝþþþüüüÛÛÛùùùöööÕÕÕòòòïïïÔÔÔ£êó—ø”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷öçèìÔÔÔðððòòòÜÜÜ÷÷÷úúúáááýýýþþþåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþüüüûûûùùùöööôôôòòòïïïìììyìø¢ú”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷‰öáäììììðððòòòõõõ÷÷÷úúúûûûýýýþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþüüüûûûùùùöööôôôñññïïïêìì Êþ¹ý¡ú”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷ˆö ‚õAuòìììïïïòòòõõõ÷÷÷úúúûûûüüüþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞüüüüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝýýýüüüÙÙÙùùùöööÔÔÔñññîîîbçí¸ý¸ý¹ý¡ú”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷‡ö ‚õ ‚õ!só¼ÄÝïïïòòòÛÛÛöööùùùáááüüüþþþäääÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúøøøõõõóóóðððéíí ôÿµý¸ý¸ý¹ý¡ú”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷…ö ‚õ ‚õ ‚õ õU~ôîîîñññôôôöööùùùûûûüüüþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýûûûúúúøøøõõõòòòðððuïöáÿ¸ý¸ý¸ý¸ý¹ý¡ú”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷‡ö ‚õ ‚õ ‚õ ‚õ ƒõ"XñÈÒíñññóóóöööùùùúúúüüüýýýþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿþþþÝÝÝýýýûûûØØØ÷÷÷ôôôÒÒÒãîïòÿ Íþ¸ý¸ý¸ý¸ý¸ý¹ý¢ú”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷”÷‡ö ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ!còZƒóðððÙÙÙõõõøøøàààûûûýýýäääÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúùùù÷÷÷óóóïðñ†òøôÿ¼þ¸ý¸ý¸ý¸ý¸ý¸ý¹ý¡ú”÷”÷”÷”÷”÷”÷”÷”÷”÷•÷†ö ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ pô"Yñèéîòòòôôôøøøùùùûûûýýýþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúøøø÷÷÷óóóÛïðòÿðÿ¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¹ý¢ú”÷”÷”÷”÷”÷”÷”÷”÷†ö ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ }õ"XñŸ·öòòòôôô÷÷÷ùùùûûûýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿþþþÜÜÜüüüúúú×××öööóóó¡ØÛòÿáÿ¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¹ý¢ú”÷”÷”÷”÷”÷”÷‡ö ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ"Zòb‰óØØØôôô÷÷÷ßßßûûûýýýäääþþþÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúøøøöööóóó·ðóóÿ Ïþ¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¹ý£ú”÷”÷”÷•÷‡ö ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ƒõ!bòb‰óñññôôô÷÷÷ùùùûûûüüüþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúøøøöööóóó·ðóóÿ¾þ¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¹ý¡ú”÷•÷…ö ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ!oôb‰óòòòôôô÷÷÷ùùùûûûüüüýýýþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿþþþÜÜÜüüüúúú×××÷÷÷óóó ØÛñÿ·ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¹ý£ù†ö õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ }õb‰óÙÙÙôôô÷÷÷ßßßûûûýýýäääþþþÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüúúúùùù÷÷÷ôôô¹òõçÿ·ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý¸ý»þÁþXÓúÊåí®Þð7ºúùˆö!€õ õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ‚õ ƒõb‰óóóóõõõøøøúúúûûûýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþýýýüüüûûûùùùøøøõõõºòõ Îþ¸ý¸ý¸ý¸ý¸ý¸ý·ýºþÂþ ÉÿËÿRØûÓèíìììììììììììì½åï%Ñþ Éÿ ¼ýù ƒö €õ ‚õ ‚õ ‚õ ‚õ ‚õ ƒõc‹óôôôöööøøøúúúûûûýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿþþþÛÛÛýýýûûûÙÙÙøøøööö£ØÝ»ý¸ý¸ý¸þ¹þÀÿ ÉÿÌÿÌÿ Ìÿ9ÔýÌÓÕîîîîîîÖÖÖïïïïïïÖÖÖîîîîîî³ÔÝÌýËÿÍÿÍÿ »ý•øƒõ ö ‚õ ‚õb”ôÜÜÜ÷÷÷ùùùàààüüüýýýäääþþþÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýûûûúúúùùù÷÷÷¾ìö¹ý½ýÂþ Æþ Êÿ Ëÿ ËÿÍÿFØþ¨ãóíîïðððñññññññññòòòñññññññññðððïïï¶æòNÕúÍÿ Ëÿ Ìÿ Éþ¼üªú—÷ Šöb¤ööööøøøúúúûûûüüüýýýþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýüüüûûûúúúùùù÷÷÷öööõõõóóóóóóòòòòòòòòòòòòòòòòòòóóóôôôôôôõõõõõõõõõõõõõõõõõõôôôóóóóóóòòòòòòòòòòòòòòòóóóóóóôôôõõõ÷÷÷øøøùùùûûûüüüýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÜÜÜþþþýýýÛÛÛûûûúúúØØØøøø÷÷÷ÖÖÖõõõôôôÕÕÕôôôôôôÓÓÓõõõõõõÜÜÜ÷÷÷÷÷÷ÝÝÝ÷÷÷÷÷÷ÝÝÝ÷÷÷öööÜÜÜõõõõõõÛÛÛôôôôôôÛÛÛõõõõõõÜÜÜ÷÷÷øøøßßßúúúüüüâââýýýþþþäääÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýýýýüüüûûûúúúùùùøøø÷÷÷÷÷÷÷÷÷ööööööööö÷÷÷÷÷÷øøøøøøùùùùùùùùùùùùùùùùùùùùùøøøøøø÷÷÷÷÷÷öööööööööööö÷÷÷÷÷÷øøøùùùúúúúúúûûûüüüýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþýýýýýýüüüüüüûûûúúúúúúùùùùùùùùùùùùùùùùùùúúúúúúûûûûûûûûûûûûüüüüüüûûûûûûûûûúúúúúúúúúùùùùùùùùùùùùùùùúúúúúúûûûûûûüüüüüüýýýþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿþþþÝÝÝþþþýýýÛÛÛüüüüüüÚÚÚûûûûûûÛÛÛûûûûûûÛÛÛûûûüüüâââüüüýýýãããýýýýýýãããüüüüüüâââüüüûûûáááûûûûûûáááûûûûûûáááüüüüüüãããýýýþþþäääþþþÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿçççÿÿÿÿÿÿêêêÿÿÿÿÿÿíííÿÿÿÿÿÿðððÿÿÿÿÿÿôôôÿÿÿÿÿÿ÷÷÷ÿÿÿÿÿÿúúúÿÿÿÿÿÿýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþþþþýýýýýýýýýüüüüüüüüüüüüüüüüüüüüüýýýýýýýýýýýýþþþþþþþþþþþþþþþýýýýýýýýýýýýüüüüüüüüüüüüüüüüüüüüüüüüýýýýýýýýýþþþþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿhaxe_3.2.1+dfsg.orig/extra/images/Wizard.bmp0000664000175000017500000045741612607337712020675 0ustar andyandy00000000000000BM_–(¤:x[  ØØ3f™Ìÿ3333f3™3Ì3ÿff3fff™fÌfÿ™™3™f™™™Ì™ÿÌÌ3ÌfÌ™ÌÌÌÿÿÿ3ÿfÿ™ÿÌÿÿ3333f3™3Ì3ÿ3333333f33™33Ì33ÿ3f3f33ff3f™3fÌ3fÿ3™3™33™f3™™3™Ì3™ÿ3Ì3Ì33Ìf3Ì™3ÌÌ3Ìÿ3ÿ3ÿ33ÿf3ÿ™3ÿÌ3ÿÿff3fff™fÌfÿf3f33f3ff3™f3Ìf3ÿffff3fffff™ffÌffÿf™f™3f™ff™™f™Ìf™ÿfÌfÌ3fÌffÌ™fÌÌfÌÿfÿfÿ3fÿffÿ™fÿÌfÿÿ™™3™f™™™Ì™ÿ™3™33™3f™3™™3Ì™3ÿ™f™f3™ff™f™™fÌ™fÿ™™™™3™™f™™™™™Ì™™ÿ™Ì™Ì3™Ìf™Ì™™ÌÌ™Ìÿ™ÿ™ÿ3™ÿf™ÿ™™ÿÌ™ÿÿÌÌ3ÌfÌ™ÌÌÌÿÌ3Ì33Ì3fÌ3™Ì3ÌÌ3ÿÌfÌf3ÌffÌf™ÌfÌÌfÿ̙̙3Ì™fÌ™™Ì™ÌÌ™ÿÌÌÌÌ3ÌÌfÌÌ™ÌÌÌÌÌÿÌÿÌÿ3ÌÿfÌÿ™ÌÿÌÌÿÿÿÿ3ÿfÿ™ÿÌÿÿÿ3ÿ33ÿ3fÿ3™ÿ3Ìÿ3ÿÿfÿf3ÿffÿf™ÿfÌÿfÿÿ™ÿ™3ÿ™fÿ™™ÿ™Ìÿ™ÿÿÌÿÌ3ÿÌfÿÌ™ÿÌÌÿÌÿÿÿÿÿ3ÿÿfÿÿ™ÿÿÌÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿáááÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿáááÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáááÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáááÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿáááÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿâââÿÿÿÿÿÿááâÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿßßßÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ]]]QQQQQQQQQPPP}}}ÿÿÿÿÿÿÿÿÿÿÿÿ÷÷÷eeeQQQRRRQQQRRRvvvýýýsssOOORRRSSSRRRaaaöööÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýýýtttSSSPPPMMMPPPNNNIIIQQQNNNPPPOOOQQQ¨¨¨ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿžžžNNNPPPRRRQQQTTTIIIÆÆÆÈÈÈRRRSSSQQQQQQQQQPPPQQQQQQQQQQQQQQQQQQQQQQQQ\\\ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿHHHAAAAAA@@@@@@mmmÿÿÿÿÿÿÿÿÿÿÿÿ÷÷÷RRRAAABBBAAABBBcccÿÿÿ²²²>>>BBBDDDBBB;;;ÊÊÊÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿæææ@@@???IIIBBBDDDvvv»»»AAACCCDDDBBBGGGAAAãããÿÿÿÿÿÿÿÿÿäää>>>CCCCCCBBB???BBB………ÿÿÿµµµCCCCCC@@@@@@AAA@@@CCCCCCCCCCCCCCCCCCCCCCCCLLLÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßQQQCCCDDDFFFDDDjjjÿÿÿÿÿÿåååÿÿÿøøøQQQ@@@CCCDDDGGGkkkåååìììJJJAAA@@@BBBCCCÔÔÔ¿¿¿ÇÇÇÏÏÏ···œœœ@@@FFF???EEEAAA¼¼¼ÿÿÿmmmEEE???CCC@@@GGGyyyÿÿÿÿÿÿååå‚‚‚===EEEAAAFFFDDDPPPòòòååå¼¼¼EEE???DDDGGG@@@???BBBBBBBBBBBBBBBBBBBBBBBBPPPÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNNN@@@CCCCCCCCCoooÿÿÿÿÿÿÿÿÿÿÿÿõõõVVVBBBCCCDDDEEEhhhÿÿÿÿÿÿvvvBBBCCC@@@DDDAAA<<>>BBBÁÁÁÿÿÿÿÿÿ»»»EEEDDDCCCAAADDDHHHCCCCCCCCCCCCCCCCCCCCCCCCGGGÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿMMM@@@BBB@@@EEEuuuÿÿÿÿÿÿÿÿÿÿÿÿ÷÷÷\\\FFFDDDCCCCCCfffÿÿÿÿÿÿ¾¾¾DDDDDDBBBDDDLLL???@@@>>>>>>FFFCCCEEEAAAAAACCC‚‚‚ÿÿÿÿÿÿÿÿÿÁÁÁEEEFFFEEECCCBBBbbbñññaaaIIIEEEDDD???AAAˆˆˆÿÿÿÿÿÿÿÿÿ»»»CCCEEECCCAAADDDOOO```__________________^^^lllÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßMMMAAACCC@@@EEEnnnÿÿÿÿÿÿåååÿÿÿôôôXXXEEEDDDBBBCCCiiiåååÿÿÿñññPPPBBBEEECCCFFF???FFFGGGGGG@@@CCCBBB>>>DDDFFF²²²ÿÿÿÿÿÿåååÿÿÿ~~~GGGEEE===DDDEEE]]]GGGJJJAAAAAABBBQQQÜÜÜÿÿÿÿÿÿååå¼¼¼@@@BBBCCCEEE@@@©©©þþþãããýýýýýýãããýýýýýýãããúúúÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿMMMBBBEEEBBBCCCuuuÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿVVV@@@BBBCCCDDDkkkÿÿÿÿÿÿÿÿÿDDDDDDBBBBBBHHHkkkpppmmmOOOFFFCCC@@@EEEUUUïïïÿÿÿÿÿÿÿÿÿÿÿÿìììNNNGGG???EEEFFFGGGIIIDDDCCC@@@EEEÃÃÃÿÿÿÿÿÿÿÿÿÿÿÿ¼¼¼@@@BBBCCCEEE@@@©©©ýýýýýýýýýýýýýýýýýýýýýýýýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSSSEEECCCAAABBBZZZžžž¡¡¡žžž™™™LLLCCCCCCBBBCCCkkkÿÿÿÿÿÿÿÿÿÑÑÑCCC@@@CCCAAAHHHçççÿÿÿÿÿÿggg???@@@DDDBBBÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÆÆÆ@@@FFFGGGCCCCCCBBBCCCBBBFFFÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ»»»CCCEEECCCAAADDDOOO_____________________```ßßßÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÝÝÝÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞUUUEEE@@@BBBBBBEEEBBBHHHBBB??????EEEEEECCCBBBBBBiiiåååÿÿÿÿÿÿÝÝÝXXX@@@BBBAAAGGG•••ÿÿÿàààLLLDDD@@@EEEAAAÒÒÒåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååBBBEEECCC???@@@CCC???VVVôôôÿÿÿåååÿÿÿÿÿÿååå»»»EEEDDDCCCAAADDDHHHCCCCCCCCCCCCCCCCCCCCCCCCÛÛÛÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿMMM???>>>EEE@@@@@@@@@@@@EEEBBBEEE???AAAAAABBBDDDgggþþþþþþþþþþþþ§§§DDD@@@BBBDDDmmmÿÿÿ©©©BBBDDDEEEDDDmmmÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿùùùYYY@@@EEEEEEDDD???HHHËËËþþþþþþþþþþþþþþþþþþ»»»DDD>>>CCCFFF???>>>AAAAAAAAAAAAAAAAAAAAAAAAÚÚÚÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþþþþNNN@@@???FFFAAACCCEEEEEEIIIFFFEEE>>>@@@???AAAAAAhhhþþþþþþþþþþþþÖÖÖ@@@EEEDDD>>>MMMíí퀀€CCCGGG@@@@@@¢¢¢ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðððYYYAAABBBFFFAAA@@@HHH¿¿¿þþþþþþþþþþþþþþþþþþ¶¶¶AAAAAACCCDDDAAACCCAAAAAAAAAAAAAAAAAAAAAAAA×××þþþþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿßßßÿÿÿÿÿÿÞÞÞÿÿÿþþþÝÝÝþþþþþþÝÝÝOOOBBB@@@DDDBBBBBB:::<<<<<<<<<<<>>BBBBBB@@@LLLêêêþþþäääþþþþþþããã¹¹¹BBBAAA@@@CCCAAAkkk•••‡‡‡““““““ˆˆˆ““““““‰‰‰çççþþþäääþþþþþþäääÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþþþþþþþþþþþþþþþþLLLAAACCCCCCBBBiiiÝÝÝÛÛÛÕÕÕÙÙÙÒÒÒOOOAAA@@@AAA???hhhýýýýýýýýýýýýýýý³³³CCCBBBDDD???EEECCCCCCBBBEEEuuuþþþþþþþþþþþþþþþþþþþþþþþþµµµCCCBBBCCC<<>>CCCAAA´´´ýýýýýýýýýýýýýýýýýýýýýþþþþþþþþþþþþþþþþþþþþþþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþþþþþþþþþþþþþþþþþþþýýýLLLAAAEEEAAABBBsssýýýüüüüüüüüüûûûUUUCCCCCCDDDCCCgggüüüýýýýýýýýýýýýòòòRRR>>>DDD@@@CCCBBBAAAAAA@@@···þþþþþþþþþþþþþþþþþþþþþÜÜÜFFF===IIIBBB???KKKBBBBBBAAA???FFF¨¨¨ýýýýýýüüüüüü¼¼¼CCC@@@@@@DDD???’’’ÔÔÔÓÓÓÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÚÚÚýýýþþþþþþþþþþþþþþþþþþþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞüüüÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞÿÿÿÿÿÿÞÞÞþþþþþþÜÜÜþþþþþþÝÝÝýýýýýýÜÜÜRRRDDDDDD???CCCkkküüüüüüÚÚÚüüüñññVVVEEECCCCCCAAAgggâââüüüüüüâââüüüüüü{{{AAAAAADDDAAABBB>>>AAAKKKÒÒÒýýýþþþäääþþþþþþäääþþþhhhBBB@@@DDDCCCGGG¿¿¿tttEEE===DDDCCCEEEÎÎÎüüüüüüââ⸸¸DDD@@@DDDEEE>>>888DDDCCCCCCCCCCCCCCCCCCCCCPPPýýýãããýýýþþþäääþþþþþþäääþþþþþþåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿæææÿÿÿÿÿÿéééÿÿÿÿÿÿìììÿÿÿÿÿÿïïïÿÿÿÿÿÿóóóÿÿÿÿÿÿöööÿÿÿÿÿÿùùùÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüüüüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþþþþþþþþþþþþþýýýýýýýýýýýýýýýRRRDDDCCC@@@CCCqqqûûûûûûûûûûûûïïïSSS???===???>>>hhhûûûûûûûûûûûûüüüüüüÂÂÂCCC@@@DDDCCCFFF>>>AAAýýýýýýýýýýýýýýýýýýýýý   CCCBBBEEE@@@FFFoooüüüØØØ>>>BBBGGG>>>DDDmmmûûûûûûûûû¶¶¶CCC@@@EEECCC???HHH@@@@@@AAAAAAAAAAAAAAAAAAKKKýýýýýýýýýýýýýýýþþþþþþþþþþþþþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿüüüÿÿÿÿÿÿÿÿÿÿÿÿþþþþþþþþþþþþþþþþþþýýýýýýýýýýýýüüüüüüOOOAAACCCBBBAAAlllûûûûûûûûûúúúïïïVVVCCCCCCFFFEEEgggúúúûûûûûûûûûûûûûûûøøøWWWBBBAAACCCDDD???@@@ÆÆÆüüüüüüüüüýýýýýýýýýÕÕÕ<<>>ÏÏÏüüüüüüCCC@@@@@@???BBB¤¤¤ûûûúúú···AAABBBCCC???BBBFFFCCCCCCCCCCCCCCCCCCDDDDDDLLLüüüüüüýýýýýýýýýýýýþþþþþþþþþþþþþþþþþþÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿãããÿÿÿÿÿÿåååÿÿÿÿÿÿåååÿÿÿÿÿÿÞÞÞÿÿÿüüüÞÞÞÿÿÿÿÿÿÝÝÝþþþþþþÝÝÝþþþþþþÝÝÝýýýýýýÜÜÜüüüüüüÛÛÛDDD@@@AAACCCBBB^^^úúúúúúÚÚÚúúúôôôJJJCCCBBBCCCAAA^^^àààúúúúúúàààúúúúúúààà“““DDD===@@@???AAATTTòòòâââüüüüüüâââüüüãããIIIDDD???BBBBBBAAAsssûûûûûûáááæææ@@@===<<C Haxe Toolkit Installer Template/UX ‚IRaIRõPK>C)Haxe Toolkit Installer Template/.DS_StoreUX ‚IRaIRõí™ÏjÛ@Æge·‘û'èêCKÏNdCRèÁ’[A†šÒJ–‰De­°¤:EuëJÞ¦}…>A¾MWÒ¤uÇ!¤$ÌϬ¿µv4æ™]­ ¬“º@T(U{ Q±AA} “çpè¯Þ-ÎEAÄ ÃJQÏY÷ ‚¸ÃäóGm£NKe8® VgÎÑP9juZ*Ã8µŠª¢j¨µ:-'-†›†ßÌp‡Â4TŽÚ¾”e‚¸Sä{÷§°6ÂàŸý»‰ü¼ !IJgËcŒÁD0WFõƒÃê‹aTdRNޝ’k(º]7Mú?ý¿ŠŒWÈåþ·\‘7ã±R¼¯‚‡¹Ö¡)cõ¢­Ëèq9pdÜ7' ü8Ñõ¦Tª÷µšúhÏ]1îˆ4tãW–'Æ–ï{ôºè'v’Æ{TŒ¼´ÏÁ~Oˆ@ö÷1zÏwïö$Ëž n4[“Ï67õo5·&“šªÖ´êÚ³;=;û8ùô¹¼à§(<žû%]äì½5 @9ý¯Êª d …7o¾ ¦tÞ4õUøzù*,q6W…Š<šB2ã÷û5ø­g™¡› n¶Ìe—=÷;½Àð—¿&æ¬ÑúO·˜r5ƒz¾ÿß>ÿù?A·VíZÝüy x†|­å²½==–ß°™? éF€ ‚ ‚ ‚ ‚ ®ŸßPKdè 0PK >C __MACOSX/UX ™IR™IRõPK >C)__MACOSX/Haxe Toolkit Installer Template/UX ™IR™IRõPK>C4__MACOSX/Haxe Toolkit Installer Template/._.DS_StoreUX ‚IRaIRõc`cg`b`ðMLVðVˆP€'±ƒøA L…VPK¾CŠ *RPK Y:C=Haxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/UX ™IRYÉCRõPKY:CPHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/01haxe-contents.xmlUX ‚IRYÉCRõí]sã6¶®ÿJ*÷“LÒ39ÙU{v•¬¶:–­ˆ²»kßtÁ$$!¦$ÝV~ýÁHJêÎÎáû*ÉÉìäÂU¾Ð€ø\XXÿY>mÿ–Ú¢ÖE]}V•:ý×ç_}ñÕןÿ×n>+þõùN½è¿½úâï_üýo¶zùü3û¯Ï?¨B§OŸ¶ý×çU­6›Ï?+=óÍ·ÿçÿøÿê}þå}¥]õeüÙ—KgÐi]}yíKúlmmþdêÏæ…Gó\»/?®`ÿ¯Ïk×èÏ?ó%mL®»†Œ¯G·¯§ÉõKý?·âÕ«¯¾ýöó/[$³éÿ«Áí/Ûøë÷ Uü鵪vê1×_ìê}>´Ý¾ø÷ó}™¿J}¹iÉ‘sêÕˆQšêª‚¸+?0ÎXEZí噪êy­ª­ƒª¸1Ðï =tŽ,m>¸úá[©"³{¨E®®ÍÐ^2:Ïæ~¢oµ»±ö©)¡š~Ûìµ3)UJÿ™Ïû-žèÇfëëÚ9Ñ?6Øz{b“ƦOØznjý~Ó”½ûðõÎi•ȵŸvàµÎ±µüV«§•ÞÀSå'3tÛ}éÐ]l–7Õ"H¾¥ÿž‰ª±Ž@Mì»&‡Bí 6­§Eƒm=<¨\lÓ•ÞBÀÆ»¡'³?–†îÐ+­rù9<'U8-Í£ÉM}XÙè”ÁèSR¤½÷’Šª-ørüþRjWM«y¢•Kƒ@³Ö/ƒ{®e4^¸Dç^">àØõMm÷áÛ÷»üøµ.á`ÔW6‚ZÛnGÅÆl‡Ôwúðh•Ë.ª~a›J_TBR«­«²n¶ÀOÁ鳟«ð(#«²ßÓÆ¹á¼ÌàŠœãý×dºzªíàc,7e~P¸n©™u~ıUÝÃk§Šj£ÝÂfƒ‡üø™¦*s5|?”ÞORgÊúÁßáÝìañÕÂ>lj^™z¯0©7"p1¶¹uI©R¦^”+ïTQhìÂé©—W2SlÙ–çºÈùg”*«¤>€2ehâØúuÌl·glÒ”¥uØ&2‰øîQÔ<é·–Z™”Ýg6mª‰a>}æÔ^ߨGpz¼v*3~Ç\Jð¶äT¹3)¶ÇtPœ”33ür|†O‹Œf»¦ Xª»+œ‚~ÙûkÍ¿5…,cŠOv*ÓŽþîÄæ†ïö¤vö‰›akgT±Í5Üñóó]û®”EŠºíæëÔX7Šðy÷åðQÑ“ð8Íéé=¿`ˆEä”ßìž5±áº´ymºÞY¬ŸßXSÔøõf9}}Éœ>œÇÚ±ø»Õ¥ x·º  7þ`KR•kX$¸±²ȼØXðêãÊßòÀc-H“" CÔ­’)¼ÐECbóZcZ—¥yÑyR¨²DƒåíE³×ãÌœ$õwpŒØÁ3&"ðæ±yQ6Ø6¹7{CˆÔR‰ØVSس°ìÖò^Ì4ð• _RQãsÕÔ5ZU)jibc÷ ¬A]¯&83ÊÍ–PÂ´× ÿ?óiß7 Ö9ÛçúÖº'tf¿1z€ND7yŽî‡X+?Vt¼š ×5Õú¥'LO…øÌ‹J ö²/`œkåªÂÞ¬Ž¸?2”Ã'B_ÀÂÈ}Ýéz¼} £á­ß+á}²/`å;SˆóI­‹Ôäœ9!óÆéKú°+"(É"Ú…6C5H} ~yû®šÍÆßE/hÉ[ë€d­\ˆí©:öx5thu;HP5+s ÃÂÀ0WªÂ5ħ`xwö¸vκ¡:rÛFÞɦaÊ<½1Ex ØÕb¡ :œÞÍ'žUŽSó<×[•ß•:>h%¾b“ùcž`ïpf¡÷Öpnå—“&0í'µßê 4>‚¬Í^Û†˜¯‰N/ôŸêEµôéîY»Mn?ø¡¨Õ ÎÉaŒS÷EX•~ý¤3_ÍqÈoXfƒuìq·’—ÏÁ»Ušê\;.uЛiÿ˜ö,S'«C‘†$ØQЈz†aý>i6ºª¥ †_v7"°©8ÒßL÷ÉS§;œoeÑûà°¨5jµ5õÎc&¥z뼿÷Ë… ׿JQäÌó匛ª¶{ÒŒÅóýlRýÚÙ¦äqZÃó5/t­2v>°³Ÿl.IˆÖCùUÞy»Üòéñýoé¬És~k]àìkµ×AçH Úæ¶]B\Á¦9§ Þ¹×ëõ’tóK&Ã|1%j¼#'zg¸…“ÁZ ÇnuÍ Œê ]X/‰1äYvÜ5µ_)á.®+‚_ 6*²µ*éùÏמ(92¹±:“ï ^4™±,AmúèjÕÛ²aCÙh[ˆŽÄ=-Ì9tÊz´ÑøÆ>z˜•hªmAŒüèÁFÆfć.)ñÑÕÊDoEVÓYbš‰xš‚Â{ Én•ÐÕcN¥OðŒýôv˜=êõ×ßüãFDG˜bŒ¥„ ·ÔömK×µßg@o‰É+ÜNÛ¤^4ßYpŽØ´Ø©"Õ¸{Ú§EPͶÝ;Á¸òEÐ&æÑ°hEψ_˜ôö!'“Õu¿‚¶WÓà>&íJƒe Vh/D›¨Úáo27ôÚ8ʲµ=y;m¿ÛÏÞ‘ KñŸyÖ&çÕb#GÁ>çÏÇðûo´2#±DA€—Y¡mÖäz|Hs¹?TÞóEˆ8òèOQ9Å£Ñ~@K¸_ÝLì‡"÷»9b¢‰Æ›Þb¿N剿¢RW5ÙÍ»2ˆeÓ¢1rbØÄÈ2­åÅ!¾ËAm˜y…Pj Ö[Ùñä©ÀWï°E•:5ƒ>?_ÞYñVü[P7:Kös­ TX·ºæI|gë X–ìÀ•Nµ8Ö¡á‘/óö<ðg­¿6m±ã²+'a¢&œÂÄýëø2bÄ%ª§Feé›{u¨uE89ôÅ0#É…ï'?dUÍ!§s8+ H¼/$º?wa:@uqUÚv’ƒØôIæÎ_•pwíS0D\#ä_¢½^T ¼Ž{JD:ÂOÅó+‰@3GìZ3mnaBö0±xêA9#±°|·¸ÁƲ=Jg ‘x^3–òsÔ9·ƒ(éŽ=¾9ÁßXK!7ô&UL%1X£/!v®M´XüÆ™ÀòÍ2ˆ86„°8xÿ·ÖVCߨD§» –ÕÄžöîŸÿûÄË£~N7¦ÚéìhrWœ´øÜ¢œªNÝ0!úh°Š·ñPÕz°n¡ì¸‰Ý+F;Ò}€ê‹ €å@ÑKX'~.3­‚á…8q ŽUÕh°m}èõ¨izkê]B8ËÏ*xÎ^|åu”£–Ö¶ÇÍSô÷b!ÖáA–P,¼j–'þâ/ñ -ô9Š¿*u–¬D¬æ]*Xß¶¹/3[뜒¸9¦htªà‚³D˜†ˆƒAhÒô'€Lò¡û¿—G¹QøÃþ8YPO_ºØšBlÞ•—³ŸîBl¦@—Âx6»Ž0†E õ4Æ6s±‘£îzk20œØÔßáG•QÅ›¦ªqe[û}Ämæ;h¢«à† _ô,KßcþªæÐ0ŠÂ-m»í ÷V›íÕ}†oÌÔ‰^qØŽ~§„C 4¾Ó®@WÈÙA s—xhg õ7¢¼ñ­Å£ìH Wn¬ÕcˆCŒ“Úbó\¼$VlmÀM´œ(ˆ9'Ù›ž¼a>N ±? H“ ®ˆ…¿„•Þ“Ú$*z ¼²Dz*K4ÙTc¥—dƒ7>|Šˆ‹+QRqÎì‡Jâym£ŽyTûÃ㱩uˆWÝ[äâ’&0»ˆo&…Cÿ‡HvÔßJ=ÑÄŠ=ÙFMƒ·Ö°‡¼ÔÌ2äp”„êOü£©"$¥#†‡²;²íÈÀt3–¸n÷û%!t…Ý.ÕÄá°jðn’èžÕŽÈLRûˆ5#¾7C“M„ºÀo+‘»jLî]"¤‚ Žeô¹ .*ÒÚûös”TíÀüjÃøùÕí’8væ¥YT7ܱרƯó0¦ ¸§¤c4šË‘·“Ç=Šáä55%mˆÚÒ¡¦aÇ)ÜR °&ºàá }0è¿è‚‡$îA}mˆWaØ_ÚßпÞ]`–[°7vêeèëÉûiÑìg¹Ú•‹ûß¿—îïá¯y]×CÇJ^‚j²ãÞ¯µo¢ª‡öÅô¥tkû¤Ñ‡®X‰ÐˆTÕÔXåb² ”¤îPÖvh·g¹v¯0ͦÇŒáXU.«YdÿD°¯à.Ά®…÷¯åL5iÌ)2—w`@w²ˆTµó7®u¶¿fWl”†W“Bvž¾èGžñ òFóÕœŒuÑ H©NÞ‡è¦ÿnýž­4+ù•ÊC„šµÓØ&!NhðÌxß®´±F>Ÿ¬Pl—&`Í ñlS¸Mp Ô†V$ +Ù‰‰víàúÊN€g!²î|î⨈IèLSO|óˆ0CEˆ˜  þ÷8«Ã9غ PägS»Á~O¤3ƒ_m‰÷Z4#{Üy ¶õëûMns7³²ß«Ô ¥Û üz_Í0¤°¸ë”Èí8d Ð~ö½K–Œ>á°Â!`ßP_("ë¾4¨+nLSõBUÖrøé3¶âõËeÀôþ²p‚ÃNp¸*2ä¦ezâȉãÀ#jÒzÂÇ´¦\Ë}›ŽW² „ùÊÕü/å.H®•øbÄœ ±Š-±Hä˜^™•Ea†Û°ë í¶<”¹©©ÚƒÃû3A†‡$œŠiϪ.r“Å+–) C I|Ýî¹— u(§ÍuA1w›„Îm7±\àN¯»*5y.bÜ„¥LKB8ív¥Õ¾UÏ:Ù©’¨ZÐ5"WEég|;`Îè+åà„ebtÊÕUi i˱²_˜„£Wzcÿw|Â^å £÷•ÍÔ÷­(*DÌaÈ3ᜠ»(º C‰Æù²TN ül_c)aÆ“Ñz”0&;%—GDŒ1’W¨ÿƒo }°R²~[€W˜¤Ø!˜.5SaQYð²Aî Év™ÈÀ cÌØ6°â8¸ cH’ÈÔ¬t ¿x4ÊÁE F}—ÎTª™jç{É\ÂßéÃF²]ÂV LóJÄ7¦º¥?%)Ι½é}LQš©Q|‡J’C,0ý¾ŠïÆ-Ï4˜ ÆáÉ>jÕ¹÷ÅSa?L“©ú„LSÕvïÊr,JeTz ÏÆ¾Õ¶jø†¿X €ÕT¿°%Sbµ•œëM­LN‰p1²v›F_=_XîüôIrR¶ˆ.óÇ }jšËë(A}bž)ŒžÜLpÕš9µ¥aØNor·8I<9VéæÇþ¦6}I5îíîaÂãn!®@°Lî9yž £I¬Ÿ»ÅÂìq¿Í=îaâ-Z¨¼Ù‚JØž¢šÉÅJ `]‹¾%DæÁ÷q_@ð[æIôÓƒt[ïWXœf`Oìbv¬–Ë?&Ätÿ¨3ªÞ¢FCG„‹\vüì" nS (õÈ7VÜZ¹-(ƒŒ„{Ÿ”’0¯¹©6±8bâA€¡9îÕ×ø&ÀoþA€¤vVQŠ“û4 ’Óe3Ôã('ÂFFç(<ò=NL¸X¸ni±ÑõÞLXc OÔ#F}ßÿ:¼>9'¨údë A|(z ߨ„„…ï@QÇšDÄÕ#F÷jÄ©Â,ç>ÂèGnðEîýhcûwOIÁU*ìÙ¡eàãüµ¶9“FËs%U@¢Ë‰õÖx#¹ö;9sÒ 'Ö% êûÓ‚È5õ†y½^ÜŒò|lsæÚ'4‹úß² Žáø*²f“ u› C7ž­-"oM½ÃÕÄ¢8y„ó²·¹÷«ž˜ó"ÓØÛ š¦ÀÿÏ€#A&þs@®ÔÅ䊉bÍ0A9®ðI~_n@oµÎ4ayñ äÉc·Ì3œõdšÓ÷“ù ˆX(ªœ믾Áöޒ¾ũ7êYEÃ/E ¢«9Ø?àÓΓ[MäܨGMG7Ú×H‰7sŠ2ÅÅQIKUÉÔµPίxja„'÷Vo‰Æú;µÚ$@ø0?å. áHXÚÔ÷v‡ QJ™­`qeæBィÛGJÂ7nT•ßÎ[ie†3€K4¸Üõ¸oô×Q ´Ôò,ÝÒÔí#&qïî`¾Ú»ÇJ;4þA¯tjAÛ=I¯šÍrðq(Pb¾{ݪg³Åƒß£Ø.»‚qÑù[Ÿj"^=d6†8OOÁ±† Oñ¥v{rYS‹$^~˜%}ÇšRøKûkgJ¢ˆ~Š ·)Òï¿(ñ}d¶ô²)IAFøpï#mlÅ!ÊßþÊóÙÁ›Š}wI`Wô%÷„kw&8fÚ±„µÙ› !‚gmôc›ˆ‡=12­î’Z³ŒË›g$W·£Äù£Ý¼¨j×Pñð¶âúEÖYxœ¾olM}ðJµnŒðI„+°Á©ñ`†V‡Óû?‡[=5“V¯¯ðЮNªlE‡Ãˆð'a#B¯«yê{±ÈL†ZQž‚xƒC„ÊïDâ>wG^|#ÌÝa#ëUô:ñ|QÓC ¸Ú ì÷þ^B*+þ‡2¨IûiYIqG‹Ø•¡5HÀ]uãå8õ" pŸHæ˜ àJ—¨Þ åªÒߎñS§ÁüŽQL}bç:¼AíËÎHÜe9Ø¿R-©ØywS WNAÆù!*󈈧 ¼ F˜êßRQ—ǤÔ:ݽö²ÎŒÏ~Fâ_èøH7'0/óšl¼¨Á¶D ‚OèQ‚ˆ‹WÜeágæ§EƒqR=$Ÿ”Lõã/üô!š6, NÂæìû0‚¼1IŸ' ]uO­ì|!‰ŽAö,Z¶4/ç±¶'Ü¥õþ*‡'ÕG,mQ'Æ%¨%BË[Má÷²Žïí“BDw!~\È}xŠã ñ%8ôsò…€á"„c¸/óÀçÁ)\¨syý:?”»‰Þ\‚_Š1Jp ^3¢.Le¼PgtÍÙ•µ¹ƒ¢v¬dh`¼;~îo h( Ž½ÑÅÌÁpŽâÑ[ü¶Ù?’Ž(]óÒéð¨<ªJ½\IÇSåÀšÛŒû"…ö‘د¿`y´~î|}ã/ 0JÅž1.åÎ $YG¸ˆ7¨r=Äó)Äq° ÄÐåM¤ªöÌ\X„ N¡J7×þ *Œl™ìãµ%[ákëÌO^Qù¯TÌEŸrü ïÐ ?¤+„n ¼±naŸù‘Œ0Ñâš­wSàO…K›¶œXМs.}'|•_" ¶ñÜ¢O†0áí±7`Þ®’ÓR$µ¥4dPOyㆅ]þýþºÏ%Œ¤fÈÃþÑRñ$15˜I]¿ÔdPœåX94°­Ï©ÏZ›š› ý{!GÁ“–\]“5k{_˜–›÷«9âõž{·ˉ&ƒX É[»Ù4ß 2 ëmÑB.¬±¢i#¯sn× 0¹ã Kƒ+î¹(°m¦!vƒ6ÓgØ¢a{A¡ÚÏ)~žànT=5ƒœ‚øÙÁ8iö:8X‚C;¶I1=F ˆa ïŽàúƧŒÏÜ%îïk§õ[•£N1÷s¼ª{ÃÅ㎠È%‘+`ã\íK4ñ¡Í™CÆ*7™© œÉþÁdšÊÅø`MF™ ÐÛ_øñ¹Ym*OxÎGÜժ˙ª3Ù§“Wë1XBð #ßC[šI/óØlãÝXãÙ1-f"Úaíè²Þµ]Ówë‹Ê£ÂT¶v¶4`”bq©Äú5–‰âÆVšñù»›&½1Z¦_îQ-”ç“ö…}¢y]Øù"ºž–û(+êEýö¿øð *¦ìÍ3g11¦¥ÚŒ³Ÿ@–N§F<¢£Y,i¡+Çß'ÃÅ— MøÉ`ú†ïDoõcbÓ'ÐÿâíN3A"?]ÞC7’TÏF” önqs]×%èöåŒOÏËàÿœ—s_úݳ_õ$~ýz!æ'pÈßٳʼóÊu\DƒÀ@±·‰üæhмÀ.±ï’›uŸU^öo~ħě“@®u^‚½rc°¬×I*AÆÀW&rzòvFœœ² ]¶¨µÌ0Ÿ:<8 =qÚúɼ\¡ Йr¤.ü 9Â…¨ÐõÀoŸ„˜›7Ö–‰ÄLÛðÔz¿Þ9­²XÆÀ cUr%•B¡*ˆëÛ¹DW¶ß_]òíËArøù!Æ>ï8pD¯¬ôÞJ• qõtá~]ù«ˆÅ¤ùçýÀy2¹»ÃaWÅ Kø¹ö_ ¾Oy ˜e34IrDˆÆ-šL-' ­[çàK™an0P?™¡»k§?ÂtySa§ã}‘‚É·÷ßÛ€Ûc¹ÚðaRîÞˆ7¸6ç£y¿œÜ U4æ9²äJUš#'W½˜ j½Å$ ÿed8Orí]^//h°<„£àñTŸÜÁ½“+p1z(é‚ÀÀ-äî‘×ÖÅûmý…}‹jüÿ ÁI•“W¥„¸¹‡ÇQnÒ›-“;p‰.ŽÈU³!¨µµàA]†&1}L[8à;S î±~d†Ÿ"‹ “Ǥdr,¼“/t1ñÂB¥ÎäǼ‹u€×çaÒ¯ÉH¬.Ìi€ù®aD ñ{˜ÁJq¤CÎj‚Ãïï§3‹W:ǵð!ÄI(¹2Û9¸G ‚Z½^™BJÔD‚Ä}«NàÌoB€ÆÉBˆUFMýý(£g$Ü #f¹Bµ>øl‚Î1x‚ÝX/“Lb·5{¸ºˆÝÃÜ­~²ýûØ'ð7žÂ6.1p0³$Ù«ýyn~Aqsþó_ü©_dÿñO¿Èö6û/ÿ§ÿóKùïĘb>žÞ&Ó/ê—_X©é¹êlèsCÔ¦¾ ~+‰ÚìÁ¿OË¡Ï6ï‡7:Þá·aº’ЃþËÓæ¬!ÙÐãs"ðˆÚŒ‰²ç`是]|€zº‘r_o¾[Õ+¬ïÏàÞ šçÁÌpýñ©ø6¸øÁÂ[’—{"ë@Lwô†z‘éáK<Ô‡q{¤mÍù>¸šx¤ þy84¡š©ª>¦Ö\Qx_üëá£M›°ÅÜZí n«k3x1è¼ k~cíSƒì™¾•ê&%Êè?°1zl¶A;?¸­YÒàß‹QÒðIÌ„ÿ¼5ÜAvÉæ…|ngé3È‘ÕúV«'¶€ãËØß Ÿ„Ñúføizb{ïméà'ÐßNŠüm¸°¦áàÏ(ö}ó‰FÔ€¤ø{Èp }ÿ^BßUÌŠ†ƒÃ®ˆó_oa ÔVv´Œ\¿tïùƒB"o`÷¦¨ÃÃ+¸¾§/€Ð-ÂhK†®«H!+ë¨ý„ø3¹á§¶Þm˜ùØ1€m°"x[7y5¬B ¼Bp£#qe$ä׳øÈ"Õ¤þF …K&ãA–üÄ$<ù§ÚœUÐùÕQƒ;üÔlª²P]LŸÍB†Ë±Å³q¶ˆv½Ã©£iîðÎk¿È€}Èý‰þl°•4xç§…&PÏĨ8þ|”—eŽÐI¤ P>ƒ¿gòbCHÈ2!í=¢Ð{?@0&¯¢wÎl 2»ñZ°Ò ›Ô{ëÌàáxlÛTåb&¹1u’C’%x˺+CBÀb ß=–¹ª%’Ã|‚œæ°./Þý6X…RTµkdɃ+d¡ëÍ®B dkZ* ûRk …ýä¨Co bFˆÝqÞJR™cT€¡2ÁJo‡êöήquPØùF¬Qðà b·¿íªÁGæÙ×€º© DG@hõ#?ú¿Êl“«j÷ëëÿzyýe=4®´ÃÞ^·ÇÔß\7£‚\fMnêÃà Û ƒ\ÚN¹ù¾ŒÑ³(‚Ÿ•â%êRÄqHBœ'Z¹t'÷¦h€ Fš-ÔIÀ¬Ã›ÚƪÀõدuk…F}U#ôBê%…Ù6œïôáÑJÎ0¾ê…m*}ŸÔ!Sz£oQX ç·Tr¦¶Hç|=Ãe·Ì ]9üQñè5§«§zpÈIÌ™[/ÅÈÊíÑ.éð[ÛñCöÎá{ôyÌ.É>‘~X|µðw~d"^™zxèžGC²×6cXDtú! ñN…F4Бí„p®Í’¼µûõ]…¤ÐVè7¶ÎÁZ½È¤)KëM"&š=À/gœDËS¦€.è3›6UÔaŸbvÞ¨Gh2tÉI@aÇcå.놑8ýfz5éài‘‘d÷¡$¾ÄÔ§˜ßöª@véSú­)À»rGÇ8šä÷&67lWû›ƒ}bfÓÚ%>[`gÏÏwá;øE²-`âÔT¡/ >Àóî‹Ám¿çÀ‘™“ÓxN©Ø9Lã°Â–6:*GE@¿‘§<ô y³œ¾æçÐÑ7Öqð»Õe•¿[ÑÕK¶³$U°¾ û¨îS2aû :œ‚Ô'â*üȼÐECAsPGm^tžª,±­}y{Á,õ0=K’Ôß‘ßïÐg‰€Ûa„PÃ…H½±ˆ B“ºÓó$(g} #±š‚v媩k¬šRôÞð&í1©¤ƒŠýý+ä (£Üla…G+ò'5¦eì÷5ycvìv¿‡SogøÝ»äÆMžc;Ò¾Õ ¯&Ãõ9ò\Mž wß™J1}`s­œä³¦`¿ù+‡|/LÓB0pkõN¢’®Üûz<& `?:©u‘šœQÃÆÎj\R@›È€( ]N3LKÓó1?AÌÛ·⭿ €ƒ²sÄz¡ÅÖNˆ©c/}C7ºÏ1¸I¯†GibøË¿!žøÐNìaíœuC»qä¶¼$MBÔdzcŠ˜S %W‹6JNïf0‚þþYå(3Ïs½Uykñ‚wȼx–Uþ †É;”ˆQ(r×ÁP—§ヘ1Úž—‰N/šÂŸè…«ôéîY»Mn?Àð¡¨Õ JÉqŠ2÷EXu1œ ¯æ(â7"³A:ó¸ É;àà](Mu® W,à±fz–!G¹êP¤áÓ`òA”!¢ ÁI¿÷™®j)§—Ý=Gk*†ƒÃ6=5H·²‡hXPTT 0³ZŒšzç!“}tŽû\Äõ\ÿ Q³Ì—2nªÚî)C OOô³Iõkg›’mÀi8Íֺеʸñçf9ÕPê÷¢kP~%A7‘@.w˜ix‡DÛ8ó~þj] äkµ.H0¨mÞ¦ÃÑ 499Åн^¯—ÜôšóC?_LáÚî¨éÜ™¡\°9B¡[]3¼Çâ5žÖKNx·x’ôèY÷QÞ8àí¡Q‘­UIÎr¶æDɡnjΙì ÃASSvS³÷”];ÀÚØxô¬L®¢M%܆¾‚$&e""/Èœd„Î윭%{9ɪF¹,Âsç4ç9 ã9ëö䪼/RÕlw5µF>…‰šfbÞ¹ns[a°`OÞ– öx‰|ÝÙãσÂf°²µ¯nΖ¡—Ö+ÅÍa­ro>Åcø›Ó) .­«¼q„ê<·n¡jg^µû³Í™p0_òÒ`¿ zùgyPg>ñ·59Ìì¸ú×9µ†qÜtìhªêÞB ÷EÜj;ÔÇ=L¦~ßE$Ó0azµ¸s¦óÃÀ^Hü>Sê`_åµ`cÑð€yø`Î:䈪M^A=ñܨáWŽmnE ЏƒH|ФCÐ×ËàŸâk¸¶ìR¹.{¦7 !˜š;öÖßåûDáÚïu,Êݨªî^¢HŒÐâ­!GãÛP“Ê'fkê ‘ópääj)lR/8ï,ÔóGhZìT‘jÔ©éÓÛZÛ@Îá÷¸ÛWÄüç!‘T-·ñ=À ó‚Ý b$Ç£*ìb-ªAŽB»–@é„^ÇȘÁÚ¨rx¼åÌ Q–ek{òŽØ~ ²¿ž½¥Â¶Ê?ó¬ ‹¶«E€Š´p?B_A»”‰Ôgp…Ø9}|HsMDÛòˆñèOB9CÅïÍ~ÀøûÕÍÄ~(r¿_Qcô ]´Ñ-ôkTâ*áÈþÜ•/ŽŒ‘ˆ¸?“C¡ö&mm p¤U Ì+ŽêíÃXîÆ@÷ãæSêÔl ö{i}\¼ëxO=M¼Š¼^²ºcu(÷uØJ§Zœ±0ùíH—y»»ó¨Ã¥$¸Wü) ߇ޝÒ_kzfT–¾¡!©)lPß‚pä¾wü U5[€œ/¸|~†ÉÔ EDX"¥-@W:yF×HžNïüõuÖ=ÅBÌXN…[êyØû´gDƒ} <½’„Ðq„®Ñ G–V= /oÏ<(gÄ÷¸w‹4MàJgŠzxh½¥üs×ìÂI¶#ï2à×UÁþÅ ½Ý”ÑùH¦²è{ÅšÕb…×h4϶¿$‰bD˜ }ÞZ }Çýè&ØøÂ»Õ»þýï/9úùÛ˜j§³ÛÁÍíøÿ8©þТœsNÍâQ÷hR‰¶ >^öB×Äî.÷„þG9–ççpPr€uâG1Ó*xž]Ã'ÚX•Q]Úu‡žŽš·¦Þ%°£ô,!žìÅOZGùgi}ßCÁÖSì×1R¸h0ÀA•`¬º“åþâ-ñï`î9ˆ¾¿tÖ–¯Ö\*PgŽÀ}™)Ðå”CEƒR£w„ñ#wÄ€ ÂDuy™n”…>j“ñ@¤‹­)†Ö½òòðÓ]ˆ×Ø”Ïf×QZE ¨ëÆ «Èæ,VcÌ­ 0oMvšú[ô¨2ªxÓT5ªÐj¿ ¾EÍ|·LtÜ3ÁÐvžÄ3yÈ_Ÿ¦N¨¥­@Wm¡Þj³ÝaÅ\ Ÿ&ÑŸ ÆÚ±îÔ\˜1ÂwÚØ*¸1Û Ú oΑꬩ¾D”%·Œ"0™µ°V!f 8Kj‹Ìf±¢—H mAÀr,f0؇g—PTzîÿ(AÆ~_§ ]ºF,áWz †·iññ»ÇÎAW¼íÏT‰ˆ!ÛÅðãá˜k×bN| ' CT"L¢”Ù=õÅûÖF]mŸÌ&D"@îr™È ’Z„-“‚!ÎC§'; iC¥Žhâ Š­žk#W›eØ^j|{™ÿFB’'þ¶Ì°D·À’ÍBˆÉv,@¶³ _uû=‘ÂZx£_5hçH”Äj74¾ûñââ;eèF!Öwè–Ú Íä}½ADJ2úa–“P¸öc }äö Ê\öÞÜ #Õ: EþEO¢¶6 9ó2'¦cíÈkL“ÖyœØ+»´ÀQ)%îÜèïÇ«°8DG ´¨ ȵ¨l(( ‘ù ¿–¡êŠC §;튰“o­3õY¯TÌi‘]ãñ¾s^t'9B_£aœÓSPe¯©ù 9þ&¹»Ežïü>Sé`#€ Ã)&7÷ 2M¿_èüupúeÊÒQ {Vyp$‡$¹g×вê8 Æ+}Ùuš~·¸Až?7›6 nÁS µž'n1y¸%Ь_‹›àU…ô­gÖj &í,_Èh÷íÀqRÚýYrÔuæ¿}ú86˜-  ;&íw-ù].3XÖ*4ŸS?žA¥’éÌËÝÈCØ_!.:ìOiâO%âîáC¡ï0lÁµƒ¿‰‚ܧyίVBàcz¶Üî%÷;û¹ô³ç·Øø˜0ïó¿F†4oGsÁ<%Á$iò‡™ÏavaÇ/ÔT 0-¢ßŰWŠc^vö­Šy7Â8âmt:öNÜ}µî.“c•‹Ù"dœºCYÛŒ²\»Wˆ^NL,Æ`¬—BU,²bûÖWà ¾£%s‚åE½Ryˆs°vé¤iÑìTÞhì‚Ro›$תÚaý.êŠ;Ôî Ôopª¾dQ¡ô:Ëd´) G(e]ƒãøÍ?€ß›¡[IL¦‚ª¸ƒ§$úûXJ¡¤…¡>VØOíù5œþ|u€ß°œ©qÍ­ê—Ô› Ún,b¹Wþ5ø ½/ æPS¼ˆÒ]á¸ÇÄô%x–½IÂñF䛾”èÏÑ/‚åÀð%˜+àBÆÔ1‡«ö>~9jl…M—~¥,mU´Ì齜NG‹uIaF™*±~_áD?6[G_T©šðeÞ#(ÕõDçê 3ª‰rœ‚gò8÷¦¢Xrø) 4òZ9tÆÄ›$UUD}…µM!£°JÖÂô+R®½'o‹lÐÕõ`“Bp—•t8ØK$ò¤}Ôù›ZH,†@ø“s\Dm,Äåk`Ï®u…º_ BøTb [€]Uµ©DÀ¹—€ øÐÜ×›oŸÐ{¹Kd=ê«þDZŒwR0̤KƒMD€ýµÿÚŸL9ðk§fqtí/¤{ÈÒÏKg²ªç~qC£ ¾¤ â)9ëÌXd^Ôó¾jü ž‡4¬uPÓÐ ¶½NW¹Wþ™l‡P Ó1&¦Bø­M“â§ÃÀUƒèqªÃÐá–×Jøùh°ân†Å.ž…ßx CÆŒUì·À™4üíøÚBGúÖsúð÷Û)p«8к-(Dó©TÃ1¥ÂS"Ë_¿ÀïÛóéªAtâ(ôÒnm 3ì¸çL‡j ú 0xcT ÏðZ²ÚÉt±"ô°÷,1dzÖòûÁr²r_}ƒ½Ç ¿xé8Û„~úÉYÿrV?¬~C{ÖΙ šÐ8ñévè]9û»ŽýéeoØÕƒïÞ£ÇJ¼uk8Ò¨HwÖá‘*F…Ù£n='@ï@ÐE"Ôi" ÇÈiÅP~¯ƒßO¨£‘`íø¹’t?C§“—æ~vƒî?!£ÞGJŒ™13•:&§aÚŒ¿«´É“$†e˜™L­¯ÁpÂÈ Ð˜Î3pLûB’'ŠW2;ÑU.85†WÆ àY4ŠÑ6ðßB»-Ë&enj¢æàùð sáqebðûªóp¶h¥2UAd!©ÈÚ]”ÚPJ7.än³‘OíR³æº«R‚Õ/eš PB¼µ« ®ò­zÖÉN•pµ®‡_eŽtÒ·èbÇÏØ+åÀÀõbŒÊÔSi ÇIJðÄ1WzcGtb^ååÿ•ÍÄw­&¸=âÜXϪb¹ÎQ —aè07Máú€y„yÆÏð5Jx<­G nJ²SraÐhìÉk…Ý (Á÷aw ÆVpNx Ç ]h4¼²¢²¶Ž†ê/.ºým¹ƒK$‰LÁJ׫ëŠ$‰’^0…Aß3•j¼Êù^"ßâÜwú°‘`üFÁ/TMü²•YÔü™ót­LN[1Î[›]!^XæôŒìIr®€.‚ì {r˜œƒzbž ˆœÄx€ ™9µ%QPI?¹[œ$«tÒccꟓ1u‘ñˆ¸$ ¹Gïb¿F^#w‹…Ù£Á”N(øñínÙ “7[H‘Ù3D·õ€Õá~mŸ4úŠ xx­b9ì­Ïcd+ïWH1Àùañ}¨%ÄÞI:Ý?ꌨ³¨±hN`‚D„]=¨ß3Û\‰ƒÀ%¨õ} ÖÊm!á5ö$Ì+a”®©´§=B‹Uõ«¯ÑM1`ßüÆ(í¦%÷X£¦Æf¨õÆQš͹ÏAp¤{ž\‘`½ÒV£+â•ížð{tJ!â»ìW¡uÉŽOÔ%Û‰¡ß3è$(†8š({å#Död„‰nÓ…!²©›*^jË»E°föï~‚½Tˆz¾%ÐÌñh:ÍŽêtô%‘Oäm ¿"H’bü´Jì%pÐ÷!–ÅöšxÅ»^/nFy>¶9~õ–ë}Î5µÍWLÕj²¡þw£röFcóG@r‹¢JVQP<‚ÙïZ„ÚÇáDÊó"ÓÈÛ…ÑÿÍOÔfföŸQ¥.&WxH0œ e…Nåûr뼈x«u¦a‹‚‡˜ø•ÛÏ`ÎétNÞBŠ\ô÷ J/0DÓÄG‚Á꯾Aiá÷Hñ@™7êYEC%€¬ãÝZ oûèóÜVf%7êQ‡ÊöµÇúÍœ`LñDPDŠE$¿\(çW31ùÃãr«ÿÃb"ZÂx— Ÿ\4ÎãÀrp`¾o´;\JÁh‰‰*c’tÐfOâË3c~Yp|ø¶Äb?Ê}‹ù6$0Kì[!ð3ÜMÝ>âÁ·Ýe«¼{¬´{Æær‹®tj!Û2Iƒ“ÍrèÑ$0b†‹½ݪgIþ íD ±¯üŽC/á¼*¸eÝâ9^=¤<>ÅÆ4};…—ÚíMÈ F,„xÁìg"à/ÊdìxÅ&¸àñKp~uoü¢Cwˆe؞˦¤D¡ÃÝ‹²ñç™mÿÜàwC`¾“$h"ö‚yBµ;ÅìȯÍóéD“?ø±Lü–NËVH¬ÉEeÂ3Ž©×böÑ÷j^Tµkˆˆt[q¢jŽ$82ß7¶&>t¥Z—6ðDAUCá÷ŒZ ´oµ$½Ÿk¸I³fõú Måêt ÊSô$¸p}BÁväÚ™§¾ïŠÌd˜eß)†65D<ñUƒïUPÔµ3¢Ì2’’ïò?B/htàQQ²¦ïý]Rü%ÓóÓ’’&¤¡cŽ l~ <"hÌs;ÑUPß] M—“œùäÀáGFÀVºÄnë-U•¶ú¤r ê”:­¡n ½I|Zç*ºÁ,¢Î8Ô=5Øam ùÖXn…ÅèˆùŠà˜§nPUdp„S ÜÜ"Jôi©ˆK\Rjî^{ e¯ <åÐ/ l|BŽ1û K5[”LÛ5Bø„å!ÊšxM]R zî}Z5'ÃðI à`T? ¦sÁ:qžu(c‡†üžºÅH?'=oϬìt¹ÈÝ^v#R*,+•q¯ì'Ôeuþ Í'ÐG$iÿ%fØ›{KÀÛHÄÀ—¤Šíá“"D[Ê}\Ä}x¢bŠñð3²`ár‚B¨÷êB7ôçÁ‰Hˆ`^yý:?”»‰Þð0OŠó(” KŒõM:¨ŒØp:#kÍ®¬Í5½#%îsÚÑ’¶ ÍÒ‘7ºØBA¨ÏA4z] ß6ûGª¹$k]:žUGUé/z+él¢PÚaptÈìý๯¦AëÉÌâ}³/ÄHÄ1.eÎ Ê" ݘh$˜r:ÄX)Ä­¬uªï:U‹ZÆÍ}C9ÇWéïâ´M{dÊ øTø .±iî§ ‹‹ò|l³PuI„*ya1N#¶³éUNþͦažÇ(,þÑ´§ © ³© ƒòß01›MSùI²ÝÕ”sƒQ•¹JHÙ+†"ü\­C+(ÞÙ’UYΦ³Ü2XôÛ!´FðŠ_³ áT2›¾VMUU\å 5¿I;ìÙ4Äú¤AÑ“S°uåÎo ["pÈlz·ÙT”ô4ØXÐó?ñÂ_“‹¾–_ÆIiù¬ #¡x®qM.Þü”c9em¹>¶UâwžL¹Lâ4›Ç‹À63õÚJ, +‹8˰^Ý1,OÆl­<Ë9ˆ·tâa«ƒï¡üàµÙ¬Å±Ó’ …€­%FF“ðÂûÎË^¤óãÕQl“RA’,|‘§.ð7¦ÐÊñý(<é &£Y(yëdB*Â]OØù(U™`G.žwË…6”¢f©@ãIê[„J $+-1réè9ñŽÜ 20k¹õL3ß¡{Öµ7†kói\ãO HöÖÖ»‹Û‹¹¤5ß7*%ëE}Òò«´äò¾ù¨(ªU²/×–jED¯­3?yñCå¿J!|Äèƒv¾/ú„®²àv¨…}fÇ.¢p[kJÂMãM> -m~Ø2ºTsJ8¹ìUA̾UÎ T°U6#Û÷ÁÜç!d7òÊÚÿ1𤶄F „(/¼ @ʾZ?7«äƒ©SB4JûGKø“Kr(ݧ~©éøïs'/²õ}¡ôEkS3#ß¿ 1 89ÙGÆ5u_sfš÷…©Ñ,–÷«9óžyÕÝG‰NA8mÄ[»Ù2P0lê­¨BƱ"Ý*#­sf/ (µ‹ Ib+æ9%mžn_Îe .hÛ&ÌBû£5EÏÔ §gÆPP©S Ýô:åÌ^÷;¨KÈÃÃ6)¢7¿‡Y ´‚«sâV¼«óÚiýV嘓Åý­æÞ0±„ƒ! GC Ð8WûRg0Ëùð·¹;ˆƒTå&3õ!©1'É“i"oÛƒ5a¼úA?n§ÀMc*r,;ê¦ÓePÔ™llÓÉ«õâƒ?õ&زxº‹Çfo¥ÍžX1€ÐiéD—õ®í ›¾[·P|J¦²µ³¥âµŠóô#:°¯‘Øù7¶Ò¸gØÝ4éM¨2ýrix<´/ÊíÌsðBÅÐõ®„ ÇHQÕé—°«ÅGOHéc·X&Ù8[á1¼ _œã0°t:5â ÀA¹[þF.x°·OÏ(xCy«›>A–ýowwú‡½5Y?ÍȽA&<Ó»ÅÍu]—xÐs1ˆF%ªÛ½˜¢º-Äÿ-ÛožŠ6ˆ‚Œáð9Û‚~Ë+Uø+Ÿ¶K£7Uõ_ÿPK8šŽš÷C'½PKY:CGHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/01haxe.xmlUX ‚IRYÉCRõ•TQÚ0 þ+Uµ×6ìÆB$6®Ú¤=œÛÓ¤)S2BÒÅ)ûõsK(9 ¤í¥©ýÙŸ¿Øny½«l¬¡œ¦ƒ|0L“¦QëiZ<Ÿ†Å»Ç¬OŠìm1˜d“b4Êf“óñìýh\ÌŸRÁKk6ª\­ÁxµQà„uU¾•GèKkõNùî=å9ä,Šæp¨¬-8àìbò5`éTí;ƒ½²j‹>S½Ô:ñ§¦©±R&¸ƒßr0küÖ:õG¶ äÁ…³ûdoézÞ5 ö ©{‘Ê{vö”Ù'›åÉçs*8Ößá!³x¤[\Iû KûŠ¿AÇ´Zu©}ÂÒ ¾Ñ²B:¬ÖöeqÚ¯¬VåevHjY@kYîd o„{*ãÁ©©õ,†§²¢/ÀYkv¾sß0o›ð¼–~{#$œsj`I¤§g Ë~M}<À’Ü"vp‡·–Žæ9Âp#O¯øž¦ˆ]ál…V7>VÂ.¨k}Fâ‚ò0x4!ü<Ô¨’ˆ«yÞµÿ¦‹ZÝñ]í^g¶Vî9‹âEouž§æ¶;¤4dZ¡ƒ®üÊ{M»ÔÃm$m`¿/Þt@kõÞ9ÌMy@UÚ²{h-obóÅÏn=#]•³óßGüPK õ;ÿì†PKY:CPHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/02neko-contents.xmlUX ‚IRYÉCRõ•”QOƒ0…ÿJÓwÚÁâÆÃºÄLâ–˜Å}&DJ‹ôªÌ_oqÓ,&.í[ÎwϹ··]õmZ!(4ÄôP²0¢ëUE”  ZDlÆf6#%ZÐ\AÑRR j0¯*JzË,âåÒžPPþh`0ü(ã÷ƒ~ ßæ#­eÛ Ù)‹J ÿkÐ ZåÒ%¶TÕHøIÂnÒ,E=Àÿ!æó0Ž)?›íõþ6I]å*ä[y¡ú±Å³¹°g×Ú“:ëtéI¼wN¯Nlž¾s•{ºF‹ð×én·IöiâÌv‘M&S¥”®&eï.÷¤æUúW^ÈÔŒ¶ðw^1:É –>+‚ö=W‹j{¯áØi6~–^zƒL¹6ýi7Ûµüô.øùÿ¶þPKŠ/îPKY:CGHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/02neko.xmlUX ‚IRYÉCRõ•TMÚ0ý+QÔkâ@»HÆR€]µR+A÷T©ò†!¸1vj;,ô×w’˜à•@j/¶Þ¼ù|ž„ÖUi`ÙŠyO“|ö0[M§Ïùb3Zhµ%£b ʉô)Ó=?Awl´–•p©‚J'ã4K± %7=‚±B+Ö’%H·` #j×òÕÚºD(블‘;×0•VF ün„¼q{mÄÞ Ù;?}ˆÇs¦˜‘ïË‘w® ¨È‹Ñ¿ p–|ÁÆ#ßyôµC†²DÛNqM:TØèùkˆo]è°ÑŒî$/-^ZJý¾>Þ´Å7¡*‹ÝÏÖ¼¨x k§ ø9…r`—(= iF±, PÒÂÎÖëfS¯P#Î/ÜíÓ¾­À>×]wÚPd•%þ8óå”q¿Òƒê\7k[ Y‹ÌX «ÁdÑÃf¸ý¬àaߢR·ájÏŽ¸2§–0½~1=X(‰y_ƒ RÎ!˜ì ßPcR2åØjë. Ì 0¸j˜}*5ÛŠý~ìkû®æ¬°Zv-s{ýí¶¯¶å*\ãÇ¡Iç\Ö¡ÊÄoÊ||ÓeL÷`àSxþQâ§ŸûÄ7á¿<ðóSñ "þÀ×Ö“š9 —ȇ^û¾SŸQ€óN¤’çPK"›gyñœ PKY:CG__MACOSX/Haxe Toolkit Installer Template/._Haxe Toolkit Installer.pmdocUX ™IRYÉCRõc`cg`b`ðMLVðVˆP€'±ƒøA È@€+PK%í!Ÿ(RPK >C/Haxe Toolkit Installer Template/haxe-3.0.0-osx/UX ‚IRgIRõPK>C8Haxe Toolkit Installer Template/haxe-3.0.0-osx/.DS_StoreUX ‚IRjIRõí˜=OÃ0E¯C†ˆ.½2„‚øVU6„;”V‚‚5©`ÌOçÙ¾…H HL©Úw$ç$~þJ€™¬çg€P Ù„› ¦YË&¶ñ€ËÓµä¾aŸë¯Äsñ£”û”üç8ÁiL¥”­$wüG¯Wìµ7>ìÇREQv“TŒ††¢([H˜íé&Ù0žÑy«Ž¥íé&Ù°\FçtA[ÚÑžn’9i> {Þ^Œ¥íÿõÊŠ²7$Ù°þ_ü~þWe‡1ùôf:Á÷ CXk¤»Mp5Gw¥Ÿ…Gø‰;ÚÓM²ne(¾PK§N¼PK >C8__MACOSX/Haxe Toolkit Installer Template/haxe-3.0.0-osx/UX ™IR™IRõPK>CC__MACOSX/Haxe Toolkit Installer Template/haxe-3.0.0-osx/._.DS_StoreUX ‚IRjIRõc`cg`b`ðMLVðVˆP€'±ƒøA L…VPK¾CŠ *RPK j>C:Haxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/UX ‚IR˜ IRõPK ú>CIHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/UX ‚IRÈ IRõPKú>CQHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/.currentUX ‚IRÈ IRõ3Ö3Ô3Ð-JÖ3PK€Ãþ PK ú>CTHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/UX ‚IRÈ IRõPKú>C`Haxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/haxelib.jsonUX ™IRÈ IRõMAOÃ0 …ÏôWX9C ì¶‚Iã†&ê&^H“)vÇ$Ä' cp´ßç÷ž?›3p"µ5â¼ë_wDgiN^A‘Dv˶-„Žihhe¼3¸:Ü­êJpà<¿¨ÊÄDjSTKl’Û‰‹¡=GþEï)ñ‘Xè+}y‘Œ^T%‘'d Qjè­;Ç<Ç“º_»ÁIìßÆÒ¾Ó7Öæ›Îxd^¡ŒH<•¸_?=Â6¦ EÃzBïa›3X×tƒ$×ÏÓÏ=š÷k¹< †=© oȹÿ¦ùj¾PKȈuÒéfPK ú>CZHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/UX ‚IRÈ IRõPK ú>CbHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/UX ‚IRÈ IRõPKú>CoHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/ConvertXml.hxUX ‚IRÈ IRõ•UKOÛ@>Ç¿bk!a‹ÈÐk".¥íµ¤ÒÃÆžM–nÖÖ>€å¿wö?€C/‰væ›Ùù¾™Yw´þK×@LÛ ]mè ¾Zf|ÛµÊw®.u+—YV ª5¹hå(s¿Ùk6ëìJðšhC þ1+kÃ[Iê*¸DÜâÖ(.×%Aüìô”Ü‚!¶#f¤F­0äòö×&Q¶6Vž¨"x-9÷Q³\Ò-ä ’çs´Jä¤?b õ`èZãñ÷Ÿpl@׊w®¸kÔÑrVUŸ£YªA¶f˜9!•5­gî@6 kÎüºGëÕòT¯©Òà™ÞÿüA¨lˆFòîìGž/[4Q¨ªsð Z¹ŒÞNµPD ®b\is±á¢)<ÂiT9mБÕLôê!Q )*éÖQØ)Èií¬U¤m„Ë)Ñî;¤Ÿ¹©7Á_¹Ÿ»]Îܳõ$¿ Ø‚4 o}v……—Ác¨ë(êM¡X×䪳zÂ}µOyé‹í­•/FÃ^Nå&9“2J­(Ø4|9 *a‡¬LV¤˜Ü:šÚQÆç?3ºiÕ}67bq~>äà0ïQM¢ôHÎHq@"Ô QBóü€¼&Ü„á>|ç€5GZý2Í}]ó~¸$¾iöÙ£_A· ð9‘þ!Áhgúà½êivר˜ñ…,¾îðr^ÏqÒ±sžçáùrRè•SžIø‹eAe½ªhÓù냗$¢}[n¬£ïöˆ¹%J*0'öW—‡rb~Já%IéçIñAjF…gèÖµ4m Õ§ ½YÙ¡É †ŒJòÍ Kâuj’8ä„䄤)˜´Ç};*í…âlW¼Ÿ=„úNF–!óÉ1æ=b¸öGžÑ±úÖFÜñƒ< Ø}pÆ–£{´ûlÿPK|ÑøÅéPKú>CiHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Data.hxUX ‚IRÈ IRõ½YësÛ6ÿ,ÿާ–jšvÒ¹g×¹‘%:f+KINšëôjˆ-&¡!)+jÆ÷·ß.|è»ùpÔ6€ÅîoØ]€§?ÀЋu=ÌrhvZoÎÎþqòæìõ¸a_8\‹e°< Rñ§ó(Ëp¢ f<åÓ5<¤,Éy`C˜r"ÆÒnC.€%kXð4à bš³(‰’`ÄÊG¹DœÏS&Â|ÅRŽô°,~Ä%Â_Îy’K F1Ï ™Ï8Xc½ÃjÙÄ EœÅ%@ËfVQ>ËRžåiä‰üx³Gó(7ŠJÒ$ñ]f¨ ¡µa.‚(¤ß\ê·XNã(›ÙDÄ}ºÌq2£IŸ'¸‹x¡B§"…ŒÇ11‰P©t‰Ñ–J£ 7׿’¢W31'ZbT¨„æ —i‚‚¹Ü4Ÿ”û‰û9Í÷PıX‘޾H‚ˆTËε'¸Î¦â‘Kµ”ó‘#j…<²(=­—²C¦\›…GÒZ¬¢YJ0²ã!Bg,D*ånjì7.Œדí‘ Þ†£Á{¯ëvÁjqlÙðÁ›Ü î&€£vò×Ðî„_½~×÷·áÈa0"nÞí°ç¹8íõ;½»®×W¸µ?˜@Ï»õ&Èw2257Ï¿[wÔ¹ÁaûÊëy“Òk×Þ¤Oœ¯#hð=šx»^{ûÑp0vD9÷½þõ¹·nâ `œ÷=`|ÓîõH±kß¡# ÁðãÈ{w3›A¯ëâä•‹øÚW=WICí:½¶wkC·}Û~çÊ]d$•$J>ܸ4KRÛø¯3ñ}Ò§3èOF8´QÝѤØýÁ»6´GÞKGBÖÅMÉ·ö]ň,_w’ÐønìÖuÝv9Ži•žœ|z°`þgöÀ1*Eœ93L*q4½8ˆæ@cç¯háŒ8 xº=ï&yº®Oÿ‚‡ãâ`™QhñÔ%â}qp¯<à!Üe<õ’Pdp _,…„Í9œkú 5.ãx×<Ÿ³(Þœ\¤‚NW†óí4eëŸÕêÛ‹ƒ§Rð{<¹ï²1nÉØ%×sJuYe¾Â{¨¼@¯€gþæÜŠO³h†X%<ÝœÔÙk Þ2}Túm®èéÒ6U;¼ÕD9{ ‚fʶÛPLÛû…zìRy{tðc¬:C–ÏöÐw¶£%?òXPÊÞRn¿Úzç‚'O|Jœšâë–Þö`xR†“ˆ¡Ër†6;hÈZäCFUÌðËñ%XúÐ9ŸðàX»(»íU ¿ÌãÝtÝA§Bеy?éÈÅ4éaúHä²pŸþäœí&fñbÆ’åIÿ{úŸßÛ'ÿf'üóOçäãÃSÜS!îy·?Æ´x ¿[ï†=˶zê×Õ¸‹?‡’=þ)ßú£¾«…;zïvÿì·o5Ò‰±ˆñ&ºp™Èž2òfý¸A‹‚µ…Mxe4pæ,÷gM¢kA Wù,+°¼ä‘ÅQ –âZ.OuLtˆ°‘ò+ºdïd‹8Ê›–cµœO"Jš®…4Oû±-“ýèvp¶ ÎÎsœÉo}ÜÚÄÓ4­ÇäA ·Ž­ëXŽG”έoK‹…©òŠeœbp‡9²¼Õ¢B‘6!¤V(ÔœtC¥8x¶²ØÝ5CÇhaÓ‰h™ q¹îÈÞ%mžÙ•¹˜'˜NäqÒ#²Z5Qÿk÷:”ˆŽ-l¾°o~FÛK^Wø»Õ,Œ»Cß—j«N«C£­*´Î2AVͰåäB±i¶ªqˆ•ñyð2cï€ÍòŒûŸqò ±IeTr']èF8 (o]Iß«bÝ¡¾ßV³Ñ˜¢Ÿ /’¨r³BU=½2“ƒE°ò-!Õ­ ¹¹QÚNºù4 C[Z㙃&i:¦í4j$mhlir(ä™S°W˜p-c²÷TŸ(´ !s6ÎÊRV‘upTņãMæ”!÷À-‡¡Ži¾å2A“´É 7hkI; yÀýá× O÷¥Ž.Ô$ÃnZ4²i“®hµîS ®WìFõK¦Ì?rÓT¤äiÊÒ5vžŠÅ|Èãîi×=ð0Jä-H©èHHªý˜ö%óBaO¬xÚAëª8”0zl> ˜a/ðe6ë%Ê6|ZðN^× lRëð«‘ódÑ/¼¶ÀÆEbŒ ‘Ñ Oà]LµŽG -¦’÷UËþ§²gk‹­˜ë^hVäò"Ï«|N2k]‡üÛ–ÊhëÔˆ‹bù 3<Ýœø¹–Pݪíß5*¬áPY‡Ê2KÀzsÎîq|ï˜â°”•ø|‘¯µŸè¥’AÆçt“ñÅoF,Éõb–EdVþØ Šÿ;¨—Ÿ•Ú ÃŽ2æž Ù”KÀXYù3‰q»òaÏTÙÙ‚ûZIun[€k¤3±Dc"âúÉzîFE­7ÐSõÞåõ™+ 5‰—@KÏ‹ÞÒ±G3\Z:6×É'ÝùS7 øË:o:OäÙ’ýòé©|qI¼†<Â.ãÞ´j÷òŠj×X`ÃjÆ1pè¡3KŽÈ]8”Q$?†L×JŒM_µ!AKÄ1EP˜Š9Æuø±lÎeS ¨­þ΂½K#aS‘}”ßb6bPóèQŸ™ ¥fXÉ¢6EvJ<§=ËÔGy±×}L¡‹”?ò$'vH?W¨c*ÇQ²¤€FT!¬8z>Qp’ hK$¿a<¤l õ¤… àÒ2s–Ó fœTœQ»iÌ’ÏÚ£ú!M§tnÓýÕ%uû-øGàde W¯6Ø{YÒmÅó^øJ^ÆTÛ^$6C!Kîyí]x³îÊ+SnŠ®$Õs;,šU89fuðEZÔqGa§¢N¿>>¯ÚþìDX%(‘ú„´Öì)°$p ¬ÿM°ÔÅ7 J¡¯ÚUsÕÑýª¯•›•¦Šõ™Â´P@õµ@±ÔšAU5K5  RLš¤x¼ÅV¹x¶=/0>U^¾e(óÄ}©¯¨Ë4V ;BMÄ6Ê—p³•i´ ä¸ŸE…¨ÎªnÜM£np1ýoÕx»Œv朩Wàëx¥ì^+LUàæåßpÓcÍé‡ꓲkÙb^\àñ]ò9«¤à_öFB1³m¥÷4XËG#ÑåÓ¿þ˦Ùò‹‡þËV•S~ð _r\~$ÐUg+ß.6f$Uù¡¤ønMżòA¤ø[®èOôKc©|¡¡gkŸ7è”Pä«g°§ÿPK?ÖA% { PKú>CwHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/dbconfig.json.exampleUX ‚IRÈ IRõ«VàåâT*-N-RR°RPJI 1uÀ¢‰ÅÅPÑ"š‘_\ÍÉONÌó )‰%‰I‰Å©`ɌĊԜÌ$%^®ZPKü‰{FcPKú>CmHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/haxelib.cssUX ‚IRÈ IRõVQsÛ(~®“¼Üu"Ù±­¸µŸ2ws£ƒ’h0€j»ûï· !¥tÒ‹'±€ÝåÛo¿]eµþˆŒÕ]i;MÑÇõju–ä†~®>´X×L #ÚœV&„‰zXYzµæ¬GTRa©†ÍJ ›U¸eüfVÓsW6Ô¢Ö<<,Lf¨fU°4ì»çM^( ›g\~«µìÝÇüê4ÿ㡱V×ë_i.u½fmíësý¥ÅLä5«þDš*Šmv=­þ]åœÖ¸¼eBZVR—ÍYjBµ»P]‘‘œôøúúSsP8y‡%ÄR¸¦‘þáÎÊø4a¨ða.ŒØV‡¢óËJÉ¥ŽYž~….kå¬?Î4&¬3(B[å-Ã+ÇœVŽÑŠKlã2z.Fï åûÍ/›€S¬{ÿpDgiäeu㽤ðÂÇïÌ0K‰·üµ+›QQ„–Rcˤà ¤ >>6ò;Õ#ȉÐI5gƒióqwmÇsp×·i×fö¦àzh9«øn2®ÂîXŸ‹$ð¶ü’¼X¢Ø£<-^èwFïŸý½}@êáÌa/ÉÀï ãÆ·Ë´=6Ÿ‹ÏŸ^OoïUrlÌd ý¹Û¼Ëô0ûÇ„`Ó@¯>¾¼¼Ìøßn–æÒöþ%RôŸ4ßVIm[I`^û `’ bÂÎ9õÍvœ ­Âêg]/˜ K‡Ã!^B’öšb˜w“Ë&’|Üï÷I;ïµí»§LhëÿPK¼šu˜Ð PKú>CiHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Main.hxUX ‚IRÈ IRõ½}ûWÛH–ðÏðWTôeÇrÛØ¤{fήÓt–é°›H÷ä ÙnaË Ä–<’ a2Ù¿}ï³² Ì|>}‚¤ªºUuëÖ}WyøÝ¦ùÎì‹»2»º®M¼×ý~{ûO[ßo?ûÞ¼N¾¤æU±Ì'I9ÔÄÊ'i9Ϫ >˜¬2×i™^Þ™«2ÉëtÒ7Ó2MM15ã뤼Jû¦.L’ß™EZVР¸¬“,Ïò+“ ¨1ô‹•ëk€TÓú6)S¨?1IUã,fRŒ—ó4¯i fšÍÒÊÄõuj¢3iuû ºš¤ÉÌd¹Áb-5·Y}],kS¦U]fcÓ‡JãÙr‚#ÑâY6Ïj(A ”TwYÁTp´}3/&Ùÿ¦4¿Åòr–U×}3Éú岆~§9´BX0¡aQš*ÍH I»1öiÒÐÑ‘[ º¨ëÛëbŽu kº,sè8¥f“ÐGý~JÇ5~AèÓb6+nqŽã"Ÿd8µj$«xåÉeq“Ò´xñó¢†QóPpEn¥¥¨ºN`—© :Ï[‰7³‡QÕ@,Æ¢(©ßæŒ:Ž×æìøÕù¯»§æðÌœœÿr¸°o¢Ý3xúæ×Ãó×ÇïÎ Ô8Ý=:oŽ_™Ý£÷æ?öûæà/'§ggæø¡¾=ysxŸöÞ¼Û?<úÙ¼„¦GÇçæÍáÛÃs€{~L} ´Ãƒ3„÷öàtï5¼î¾<|sxþžVíÕáùB~u|jvÍÉîéùáÞ»7»§æäÝéÉñÙ b ½:…ŽÞ cøf~söz÷Íì Áí¾ƒiœâ@ÍÞñÉûÓß_Ÿ›×ÇoöàãËßîË7ÜÌnïÍîáÛ¾Ùß}»ûóµ:@4I¬ÉÃ4¿¾>À¯Øë.ü¿w~x|„óÙ;>:?…×>L÷ôܶþõðì ovOÏ`À4ÇÓcè± Ž 4=:`@ˆùp  ¾¿;;F´°û ža{¿>.òps‘Œ?'W)Pe1«×ÀTfÙåóÍÍlŽÄaðÃ`\Þ-êbðvò§çÁ÷ïÂ׬œ$õuøñoÙbpš&“´´ßƒ®ûIآꮼ&rvWÕé<ø ÐýMªÁñ醻¬p'Á&ϯÎ>|KóåÜìæÕmZš¯›ïSø¸qTÀ?»³ÛäÞ¾mnŽgÀÍÌYV§'eñåΤ_ê4ŸTÜC™ÎakåW*û18¶Ù]d?l ê]'«B00ôãe½6öussã&)MaF¢ç\0^–Pt˜ëû<ù¼ÃÖ…éÌ«Y‘À·Í bqc`89ñN“§·qÑÅùn ›fÇà”7òŽÙÆG²cÎ3à“x›/â.À46, Ë»:­âœAaãގɱu6iX;ð¾ÖÒ…o°`ƒ ¿Ž¡j/âÖe„`7ÒY•¶TF=€•ã¨wVOX€%ß=ÛÞlw‡PØíEÿÒ0ßÜl3–e6IÝ´oKX—Ði<æÿŽ‚'ôìñ ª¸ê/ú3†‡ÈGzpµÜ/é¹Lk`ÿ¦|¨£ñ¬¨Ò˜ÁWKàçùòœÆï½`ç5,VsÍ̄֩)pýƒX4CjÒ…¿Ï¶¿ÿ#VŠkzýJ¹Q†Ð*üÖq«í·9âÄË|1Kë(3êy€â>êaG½¨Âu&€½è?_«îEþðº.Êt)ž3šˆîÌœ[­ìºÃ|eßæþ¶Ë¼mG%²«E첺¨õ½}‡™¬O•¼–ÁÀ²çú†e·Ñ;VÞÁ&M¸^IDëÈnŒ®N dªLÍJpãÇ®âËå´CìÏÒÜõó9è'¬äõùÙïós“mH%“óúMˆd"TR’%¸+!½!@.ê®é™è_€ ˜ncÝß‚ºJk[¡j868‰_@b£xNç¿ÀV)¦,â΃gƒí­r<ø¡ƒ¼F»'‡÷¶ƒÁ4›œœí¾=€úƒ(,<;8xP†Ó¾.*¤&¬F²cP”WQŸðA¬ü_·ñe’!ã¨`YÎð9Ë'é—ANŸ’Eƒ"moä w0O>°ÛQÏÿ˜åE ­¾=ºm¿)Xà®ÎnY&w?òLRTÌç n¢‘yzó_MžÌqksµ>*ýÞÛž)²‰Ùú‰þöa‡à¼^‚´4ßhLóÍ‹ÛyŸñ›Êßç>-áNcÒ¡ÑÂÒÁà#î”J:ЬJƒåÝ‘L&{\aaf³­ zêýfs•ݤ9X—eR‚Ýú1~çwT˜§%(ø‰¹þ2Ÿ‘u­À£àø§oè@HÀ=-0¨5M@®€X.ÀB›¤P.OHžÖÂj† ÃÀ0zÔf©Îrµ)Ø>ÓFó3øä@ˆÊc²«®@=éó4ä‡&‚‡7LÃk1Q¥ˆKø@À¿d”å–`ai †,’ÌzHI9¾&`ø KãVvžÔãk2vÍmQNV'•åÓ‚¨fZhk|.ç‰ØLysz-‹R¥%âþ<ƒª¶`ö }$ìò#4FÂoo †X«žð€¥$rK2r#f@mÔ˯Érá­Š’Èç6qA0êëµëF.,` û(Bc^þ2ÇÍ(/ q [ eýö îÕ±AËivÅðà`‘4a÷À#Ç%…øÚãRÐ3Y÷ïÜr‰´ ÿâ¢,Ùµ*Î8›fv·Þ‘ –ÀEaÑÖC›ãÑC=6BU‹jÍÖï€Izeð¯·jð–Ίzl HœtLâ’ò:¨WDRWDO@w>úÈNªõ»a‘yTËëu]/ø3·B3#Ïj b™À'_4¸RVŸEº€4¾P£á0­Åð€0è#ïÉ^øæ×„¨"­†ô € öÛxr¹ „øs™È'+äâиÄÉïyžÒÔ°¡¼ÅÞ0ºØÕŠ‘FD“|î› PŠn'¢m¡™†²rêÛÐßOª½&êVøÀß{½¡N†@AE¤«f_ÐËo õ—Ë) à ôyÙ¯If_¥õÞuRÆLRÜzcœT)(z}ó쇑¹µóós÷}<2 êv°ÛoH·×Èâº\2mnˆ)ƒÔy¡Â-ê}ÿæ4VOUO²<î’®û&ËÓUë7©>Çæ¯Ë´¢72uìZQà°¥ucî†ù0ùh^æ6ñš®Í;Ê£‘‘‘’«B¿ß¹ïìÈЂÄ¨[CpåM õVÚ9^Ôñÿ½ÜÓ·õ…B§¤;¥¢†¸ãcRU9\óØ*œÜŠÕMjˆºæTLü÷ÛÊÊ-+`Ž2'¡ r•¿fü6É¡Bip«ªÒ[Li ³ï··ÿŒîõšîu^IgÞabK¢ü Ãÿh>䑪>† ö¬JÍßãÆ`×ùbuØ®GÌ­èÛ€ðÓïêþL¿dµsdx¶r1+س'éåò Mûî9ëÑž¨… É4€òÕ…f ½>nÛ*'!9oÑ¢ÕÖá`‡o¡ÿzžËZêÝËÏß OTæ 0N¥-™ó ÀÛç`Ý8ÿ=ü¯˜$ÅÅðbØ}ø/xúØëÆ£Û[ÿ/.†/âÁwݧCnˆ³RHkŒ±ƒ® ìû²¸5Ña~“ÌÀ òd!+z¦õ°A/êD Ë—K;F€¦“øû®ëË}ý¡kžHßðeûj`/W)w±ßl@®þ(¥ô‹¦¦ßím·&vUØ6øƒyâ• ‡åWÐibxÝ®'>Ѽ‡oÎà¸øÓd9«y•xU¶¶ž7¨HÙ™¡óIë""v¨ÌGŠìúûöµ£M…M‚J¢ÖŠŸ´RŠ> ôl±¼mŒ*ß6¾™1‘‚A>°`Áöïú`¨›øý¿ãBÿV¦U1#ÉU²ì é êyT»þ)Ø@CÀ‚"€69™¥Höi^-KP”¯Êî ØØP˜–8ú±Ý0ŽRþåA8œb àªyUo´ÕòÖæ f\c[—©ØLž²æA]ð¸&êô/QIåˆJn2¨EGó="CŠlW bÌ µëŽò[R}ÍØä§j꾦,Œ~°æ=Ìa ³fX§{ÒLXG·зŽ"d»ªø+ýFõ9´-0j·J…Û Ì9LŒb®Úµã†æG!àŸ(Š˜UÉ%ZEÂ*74f¹Â76òôs1üs%®§Ú„GЬ¤bµ)U¦± ŸÁ³à·»V¦ú.ÿœÃâëÖCÑ5ŸP;·CQh ‡f þ3{ÇoßîíŸÑ[ó¿ÍMã¤ÛñžpC««ÀÑ{¦ W‚quýjûi5ÖjxöË~M/±o-¾åW¿ÆŽ“k ›û5Žoó´Ôò_üR1´x¸8qüJ§)1Ê74°¶Tµ )ì±í†–ç…u • fbîÒºëiY7¸Ê>¼ Ûͽ!°Æøèi]7$c°•«-3-½Å^²XÑå~¥ëךÚ.› z8Y·Ô>LAâ5Ëß&ÙLËÓ9¼„K(dÛD/°8LGx½–ì}œ.§ dE{]¬`L}V‚5ŒÈi!ñr’sKªåµ[@ÀêÖó€rìº:ܺà«[E¦«ðJ¾¸:hòºò4€‘Åô­ª•¾wµöÐUνJj<£&Ç• a¢:*T˜GÊRŸT3Ò£¤ÿ·“?Ú5.&iŒ_ºêZ”þÄûXÖ§I÷J+ ‹›¸c§ GË$¦½{ŽA²)’ ŒÒ£]Ï¡"lckü-[@ú“û¿³EŒN ½QŠ¿Å­ëoŠ›aNµ<$¶*© ôÖñç= aÆU ¶4(ÑÕ@<`À „ðwvž©ÄÆFkV„ÅÔÈŠ: gsƒI!¢^9êu2ˆ“i «HmõiDg¶ˆTé9Ø ,Z8<Ì“7Éür’€ÂTÅM(ìaî;D%J¤*?Ë™ê(½}G ˆ[ðT¨`büOº$͚Ƀӌ@#SÛ¡)x_¬>ŠNé0»)ðw£§±ôvµBÑ °ãoe!ÍÈ8”{Uƒ=Ѷ=¸E !€(GëQ}i±Á³2±µél§8~F,Ü?>5qÜhöue]…©ö¥¨ ÚÕunÆô‚z-«ï”+O„+ixõ<Ó^7˜§sL´¿®µò'*+I¯D}ìq±Ü‰Q ä{B ÃE.Á¾±˜ëÅ*Ì Ñ:|ÛõN²Ã¹ªVÔ³)n*Y8ÚÖ‘gÞ0>Š3ÉxÔÊÉ &UV›²¹*Å$ÚŽ6ƒìªø[`#НL6%Á |‡Åêh ªxnO4ÚÑ‹‰fO§¤|Â%%b^å°ð”pê\;Nêôsc‘f]ìí¨h¸=v/‹²«Géô¯Ë£"VL6aëô6Ã8&PdM5¨l¢$ åŒNbKú¨#²J)ùQ,ID8ЍkñGã§ØÆBÛzdßуByHÎgO»àzPäeY OVA£ZaxÖésóMëí³<$–Áßptçe’WÓ´ÞHaã~6éã¸\ªÊ½±ÿŠ€ _<õè ЫGÅðŸ(x× 9É­NrÆ¢x±ÁœJëäsjªbÎ&et|GÂ-üŸdµëéĵÅÙø=ÎU÷l{›¼u0 Ih¥h AÚh&ÎëÑÆ¼ºRâ0Ä€Ð{;Ì@›ëŒ<1ÐÐåaþä°å‘6¢G±2›QàÙ†â¥Ä[óÝ€`ÀÖl¸MÕAìØ+æ&à–"(_•Å|w6{ b?®a¹±Ž WrÀü‰LHò×5гj_Àu„é¼d¤€ÞØ¡7­`jCË…(…³ËGÊ—®ç$¨‘¸I™Á{Ó£¹©½»âMàa¡"¹:*üšp†—®Çš@ͰÿIq(#@Ç7Ô&ÁìtË•q¨h@ÌE8ZR¡ë,g!£ å·»Šä‚ç˜VHž/¦ú‡ìAþÕJa/V£Å® x¦ØÙ(}ú^CÉÚ’9Çj[ö¥¸ïIùUó<Ø=^XutÂŽÔó¾yẑþÕ36èÐm+BóÝgV€ë8A~_‹lzgà':ùhä:w˜³rÕÿHÊd8*k6Ušû\¡n*3«ºLèæn*2‚ `2`é^{ºŠ<6Pû\EBt&ž›Pû³;c$²J$8‘~w4ÓZ­;`æ50dxX¯Z–§¨ú`“Aµ˜3Ž8—ÓV¸¬Î•ìD ¿M?jÆØW¶PJ?$œo?Y'¾‰‰{Ro–A"¸ÙªÎcÕW¡Þ€²`eÛoa>^×Ûõ”Û˜ÞQK ‰üI¶;ÛIÐ ¡ŠÎfyåîÈ: êêÃöG¿­ò‹G‚&¦š.‚ò¬+mŸi[&BÖE©ƒyøxS†Ã"Í‹cçTW´å°z•ÖX°KBl$Ãî+EŒ¼A~ó=¹j‰¼Mò»p$ëdi ¥BJzEvš2 5i'†43àt½.jMhôÙNâiWãÚÓU©"^ÛÞ¼x•¥¢"RlM_ M¹¼¥Ó¬VtYÍ|JêBGÝæÍç϶gý%5 ªÐÑ« ,ÁŠZñ>ë1*ͳʅ„,¾µ¯­-mÏÑ! ã ?Þ»·]íq/;(VÎnbñHŒaD5‘ ê¶®›êM{dWáp•©åËù¥ºF“WE1áºçÇûÇ#ŠÒÜ¢å1›%‹*euQ¸dÆÝ“CƒùO/Œ9¬;J(2eêè 8i–·Y•œû¦H&ê“PƒˆrÅþº®¤WúLèÒñ VÑ=snÛÙ`½t¶e]ßô<¡¥NH}äP”F³º›ÀkMÄ„ <]?öU¥n £çp#²z9hCeø.û˜zç6/᫆g,§\æáZ‘ŸTKÃRÏa"TJ-;±~êÜ×ûu ΋OÄAÇ´Œ>#È\ -í±ŸËÃV£ÀËÌÊx|~·Ž·IÝÁ¤ß¿ÿ}åëÅ…|“w g¬I³ã¹¹30`e+ÊZûp1¼¸ø8¼°y`ÇÐD‘û$¡ éÝ,¼+‰xeš¼Íâ@ÕÈV‰mïqà'¼ï‚êÖËÖÖz 1ösV{ xÏÞíÄr”@¥dåò‡5`‡(èÉ’Òk¬]NüuwGàÀ:&Ùtj¶¶PYÚÂu!P˽uÇ žn4R!—;Püö4%ßçu’_¥äX‰EÙ‹A0ƒùIn8à¬Be=‘/¬ƒOr¿—› ø¬pßÁ`±Ç­-Øîl,5?*´‘!—¡îèìgÞ,Öf™×Åç­h’ˆU L»2$œš¯ø‡”ï-’·ÈL +G\~A#¹|ÎúÕØ{(f\|® Ìbî±!ü t3üÜH ¥OOœ°rŸ&ÞÉõUL D xÍUy¯²üa/á26VÛËÛTsÖ¹Hép×·Ÿð¹v<+×—÷™ƒ}c‘ÄðÂ|y'ðO’TóÏÈÓ¶ ÇËOÖ‹Püé=oàšŒèŽdDw¬æö¤9¡®Çϱ)Þ¢J7«.Œc×xwO£S¼^L:¶%@ì/—Ùl{á¿… ÈÓÕt@»Ó7:[x–ž:ÈL9>aâþ[à·ñ,ƒ%£’9ØT9¸Áõ­|ÝÚÊ‹­‚®aí| ܳBï&^¹WLÄùB÷¨³¶Î Ä Þï’–MÞÅtófHæ›`3@fsÈ>fmÎ;9»SR8jZšù&™"nY$`ÓîØ&æeoå©»Rã‘nØG,oHœ0@èÞã—U4Òj£‰,û-¬£uLÁ:!ªñ}+ªù6 Óv¸]ɦ£¯+c”è{#;ö÷u`7v–9Í/ÑrJDÁÈÃï4ýü»& Úu{„÷Y+HÓͯž÷'pZt˜N(§Q·ˆ ‰í"ßÚ¢«Ë‚­qš^"EØlF_ÀtNB§ñ;ñŧwRòžíÌ»öC'ײ}?Ú„Êöm(àÝ¥–;æÃG•õ”@_Q¿^ÜG0Oï\ä°ù,L¼§„ï R~e0ø9ÐÁ;[¥&n+& <¹–Ö]ƒÍ½œÕ¶†­ñÂDOáCdW‚~, ~ëK¶ˆÕºÖ–ô©C{$ÿ޾tþדáe–«ë‹œV·Ó£‘uÔ1n¯cÚ(†.c}úï£WN¬Š´#IÒbG5z\õx'iYÿ—\r‚þDòì³sÖ]_ ÌEnLC)¾/2PíÜå*!x4K¼xyŠë2 ÆŠ—ÓÆ´ÛœIêX¡Óf>rhí4sÄôëãL?? ëùÂØ³º•UïÖôñ.*r#plÄ©8.œiK+ÁÁ•plã?º8dåÎ’ßwÀå^”$S±•ä'R~²1‚•ó&í±l/£»îD)€íEìO¬½dJ6V5>^½à0rÔÂhäW:xVšåAÆßj:¨N°e7nk&±î@l[²¨ÍŽä+ÃÄØ‡—£\^Ѹº‚T2ÝZ.Õ­5“ŽI‹Ê¥Âñþ™Ü+ê6roo·Yon·zõjQÔŒ<9B‡ušWÏËš’ðc™pï›Í³‡vÖɇíýäó}ìÐjf÷êH¥4H_ƒä­àv‘Ë1løÿ\òbO³|%Ùj^ É•ó2‚z]O¢psÝvs×*S2bíj]ò‚M·Èm}äùd6‹ÚÔdÙ칯b³[î®b¹Ò{Óíá<Yõç? Ƚzxø"Æ;ñ"6hòV€çí®¶¢Ñت«a¶TrÅ-,‰«6¯m¿ó¤å–“Å/¡!À ¥±Ð}?¼Òä•'¿ø`¬÷@q¿–cÜÍjŸÏØf _m¾ª¦1ˆ.½j\f æç.\Ñó<ÜP7>¾øÇ"²*ÝÀIÖg(ÒØÍ1 )ŸÐW˜Vãd‘î–W1¹F²¶KJò÷Ù0Þ*¿Bý®=Ì©q2†N‰ØTaÌòDî±õ,üyìOž;Q§—ôàßf/tßÛãîK^½Ï ¼p®‘‘.¿•sÓûxÈG4 ~¤Ñw‹÷I.íÒ¨:´ç†nu¡Ã½è¹7Ó¯T>ÂúxçÆHê£ØzqØéú¾”JQjþH þ Æãx”üBŠ¢–~¨¿yGù¨†ØüþÄÎün…Õ ÛMÆfõÀ¶âq„¶¢Ÿ.¦×¶òÓö§ÛZå:-dË/¹“Æ ‘»';YÖסÞÇÕèxͬ¸Êò(¨{—ˆ»f„0‘š«ðJÍÈ_ðò4—ü˜)þ¡Œù SüCïØ¼¯ôD¬p¤F¸ }¾}ä†ù áPŽ^´289=þË{–Bøë îªê”¯®¥ïö~dØÔL®@}WÎì-°···ƒ«¢¸±[-Z—K¹Ù\hï‡;¦t&ªuWÔ… õù®×³´Ì’Yö7¼pd5•wÞsŸ|Àm¢9Ò þc–æá]d¢x¤Q¼Ë«p-Ç ú_›xº²¿ÝO;ú¿`ÜšïŒ%r'j©P§g&á¯@ZQŽñ‚öZô»¢§›¸EF |2¤½¥íÀæüÝëêwæâ˜/÷Àýjç÷#¡´-n-7{«V©:ZPmÏbl È‹-” ®ìµXÖwt}…UXí]!FÅ`ßäk–gP—Îú=ÕšV·”_j¹ÿ?÷Ì£§_T©%ÙÅýR|êEÞo7b®¦Ð_I¿—gÜì¹üôÿPKDhŸê¾)…PKú>CjHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Paths.hxUX ‚IRÈ IRõuQKÃ0…Ÿ;è¸Ì‡)ÃôÝჶ¦µløT’ön‹Ii²Mÿ»éV×{îù‡Ô¬Ø°5‚ÕZR±O”‚Oü?($3æÌV¾ýg,³¢€k gY²ˆó”Ò îÁ]½+±‚ÏY-Zɸ7š ( å?A•nAF#z¶Bƒ`*½•%p¡¤PºYy«•üj—}Å,î°95ª·\vÅÂeäê(Üh²DNÖhÃ}y}ãóÊ“‹pô˜‡ôeš<¹ˆ6h Ã’Z­Äš¼­†½Ø4™Å'¨ûRòqÊžçy”¤'È~Ô=ùÎ:ûç•A;σ#fq"}M2š¾ ýüPK–š÷ÚöPKú>ClHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Rebuild.hxUX ‚IRÈ IRõ}RÑŠS1}n¡ÿ0.…Ü‹5úÜZ¥he_ÔÅ*+,‹¤IÚ†ÍM.ÉÜm‹ôßÍ䦻ć<äœ3““9Ó ù ¶Ð{ùN´5ëÙh8š¦õ!#ÿd¬^#êfvÏo‚—:Æ\!­ˆ¾éug¬‚ß£á ¢@#aÓ9‰Æ;«d£¦+ Æm'ð¾‰Ûr90–¶qºAßöÄ»:·˜ TDÂ|®³¶†þw÷3âE€6]ÞCqEoM²¬ž[´\ ~ðJW5¼˜Ã›ˆà.ø=°e>À˜|1x -¨tc>N¡¸º >MèëŠÃòÐj‰ZA)€u‡ 4öàØG–z:O„mîÒ`èý­Æ¥{¬®®?—7‹ï×WõÓì6)d a|.y]¶»¾' ž¢b¡OšÂ+Ò„Þå°WN?øt¥®(X¯`EüKZ£²'šæFüÅ.òÏ=JšûúÒ½‘ÅTµöÏVÈGŠƒRø¼Ç\i›†F@E‚ÿñ¬k•@Íw‡Æ²^H£lÓ M.~db'iç6]QRPð•ž~<:ÑY2ÿ»|…*íX^(]Ÿ OPK¯,í—PKú>CiHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Repo.hxUX ‚IRÈ IRõ½ksÛ¸ñs2“ÿón.T¬2¹ët¦uÎQ,ùÌ©,i$9~ÉÀ$$!¡H–eûrúïÝ]|èaßµf›\,öýøúÕ‹çì»Èò‡B.WšùŸÞ¼ùËŸ~zóãOìŠß v™•i̵ÌRD%ô‰(ÖR)1©ØJâö- žjwÙ¢‚e ­x±]¦3ÆÓ–‹BÁ†ìVs™ÊtÉ8ÑŠ€5bëRÙBßñBÀ†˜q¥²Hr Éâ,*×"Õ$[ÈD(æë•`ÞÌîð:]"ÌbÁ&S†ën™ÝI½ÊJÍ ¡t!#¤Ó¤()c”Å-'r-u¥,‘ »($\*Ðåí²uËþ¤b^Þ&R­º,–Hþ¶ÔTŒD »ˆèô:+˜I‚T$è@z×RvIoà”£µ5ñ¾[ekÄ%J•V`²EY¤ÀZо8ç/"ÒAò‹,I²;T3ÊÒX¢vê¬ræ0øm¶¤š‰‚4Ó ¹‘ý’×·KjÅA[amì¥1ohW $JC\HpIžÄzWë åjÀfãËù‡ÞtÀ›LÇïÃþ Ï¼Þ Þ½.ûίÆ7sÓÞhþ‰/Yoô‰ý#õ»lðq2Ìfl<%ráõdŽ.†7ýpô {{Gã9†×áÏÇÄÔ’ 3$x=˜^\Ákï]8 矌÷.Ãùi_ާ¬Ç&½é<¼¸ö¦lr3Œg£¤Gáèr œ׃Ñ<Îcƒ÷ðÂfW½áÙ½Þ h2EYÙÅxòiþr5gWãaÀw°÷n80ì@Á‹a/¼î²~ïº÷Ë€v’ÑQ¤ìÃÕÁÈ·?óp|¢óPVU%)n÷Óx·ÿ4Z;e(X%Ø>õº?bÕ–ÒŽÔïS/ÐëÜk °xcÛtñÀpþ…ƒŽÀ0òØG’]]”-/†Fî?€µAÛ©_D þ~çʸ*(¿ÊÜÒ§Á^ƒ)ï!J訰ï‡oD4ˆ’L ð§9Œ áÔÖGæ>4¶5©ÑD$o{šAªÅÈ‘Z­bÍÞþWÁÕýæ"ëÄDÖñ:O4³‚°0¼†È](1IT©¦ÚÓ±ç¦ÿ\üƒSC•ýé×ú¿ÙXW>UZÑÛ¶iq¨ÎÙ¯och4]pÅ0Ƨ@ÁaÒŸŠEbNkUÑ$ô{J¨!ìJPK=$óú53ǸªJÉ‘ˆE| ÚZsæ¶ZÞÎV¹kƒ-žn­1¼6|§"·îS·fßݲOݲ}wËv³æ@«š¶Pb[ ØqŠ˜h²ÚÔÌnzfzAMÕÄËò Öfµ­‚é2ýÝb©-K˜©+f4#c!àË ²ÏMâ¶­}‰íoÎð ÐÜ>VÁb³æôÅ*÷¥‚Ý8¥ðÄÚ¼n´†ð^v,®uwd°°X…n!ú¾6t¡¹Ðàµjç¬dxmy ¿škF#{³Ld6Ñœ\ÓŽpv#xüL|Édê{g^#¡ÊœNŒ¶™Q¸:Íê°§ ØJ (Žuœì¤YuIp²“´Šnpc. 4_a™T©„E§§ó•:´IfÎè¼VͧÉCe;“tOív]CP8ïÿ“ùÆÚÍzý˜%ªP<¿˜Î1LÃ5Á£¥ã‰Ú±_<V½òaëÇ¶ÒæiÇÙbƒ"šwºèƒº¬JGËÒºt°0íU¦¦"[7PAv$Yö• ¨F!Rín.éGàúôѸã9rsôøH¿©¦y@îB¦R¾f¹9P•Pòvf·>)UCI5e¶ ×ÃælÕÏ"œ¬êÙÈ¢œìtXœýÂ5\só©µ >®“ ®uÀå–}X3S­o¨Ûž?0÷Í~§‹¬êm4e¸WäVdÙÁ› ëˆ{Jš±ªHSw’†ÓûFDEx@ŸOÌe=뻟»Ÿ;gv¹ÚCΩ·™}Þ"ájåuÍ߿ ßð;Â__ø†»¥¿ÁšÁ¸†0âå9üÎWø›®ã½3Œ³ô¥vßÀœñËtý åˆÅ‚—‰>3†0—2÷U>ظ®Ñü0y2S“ü¶6´jºu& Óï¯ —*,!ƒ´\‡i,îÛ}“Ö.84ü]¸r„|’¿f(>UãvÑÆ·9X08Yœ5Îfè.v>¡B½I%KåŸÓw[¹LÑŒR‡¦›6x©gàÎŽ ýhÀNÈà7¥ bŽ ,ì]X·¸FðÀ´NdD¼î芾À3ó)&ÈÖȶE¦ï xŠl)L[W1vóÖƒ¶ÅÎÑ‚o[ÕóNQº°ð6v»ÇÙijÅy§Mpê18Ê~We| }ÈMSnÖcÇ„;exccÓ2±¼7{•µøK†Æ5V6¯nI¦­%|ut(èª%z­XˆÖõ¢´—Gåz`õÙý÷Ùx¾ºK“ŒÇˆ÷ÆÁ8Í#Œ"€3^ëR¾ÚvØÅ›fD@ã €í/;CËž?! Ž|¬À41î%ètè ­k_Óä™Òaª4O’ý¯C]V±¨®Ož¸¦ûŸ} ù[çÄ*ü*“íæl+[]¤îÏ$!‘ÜýJ÷[fÁFî¹ãfC¹^7áÛX'@µnc¸^7€zÝrÂvq(š÷ЊXµa7ö}åHŠó¶æ§§Ò Â|¡¥Ûƒ§×\V_§Ñ¢((á«1È|,‡”nƨGú²mêÑ‘Ë-Bs4¿Ñª°·YÛõ(<-óÆ•“ÙsÒ²ÕþÕ"¢VoûoPKð§Ù…š Ó$PKú>CkHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/SemVer.hxUX ‚IRÈ IRõTÛŽÓ0}N¥þìTmµM¹!Jµ,H UÝÕvá…‹ä¦nkHíÊvR»|;c;·v+ /ŽgΟ9gGÒïdMA ‘©hC~ÐŒ-’n§ÛÉãk˜ë¥ÝQžoáZÒ‚Ñ=üêv¼‹éõ» Ly¯ßÞÚõæ2ñº{îvÒŒ(sºýH¥…ïòEÆR(ˆ„-ù&düžëä(Îx÷;¢Ó͉‚“Ïò,{Yj{u3Ë·†,mÈ*ç©f‚§ûÀ 8wê&%Có†\¡íÉÓ¦"[c×VÒ„ ‹ ›µ [V Ûµ.W‚¤ðÔ&‹@³½½h1×?^ÆîÅ©5vHª‘ÅïY±QÏŠ‹zVŒod+*1gcàèYÙ¬gjûX<ô¡_ ‰ÖTÏÈ–a¤ÅT쩼$ w–«Mfä×|6YóE-¾²1Û™ä’ÍU³J]…T{ù=ú|z4|ñ¥~޾Àd» ¹[PMîdM.œ„“Þ(q&–ÔÇ^ŠUé¥*½DOÝT7 ë^ÕÙØ4ççNΨCoÂÊœ¹òŠ.൪è2xF6€3„ƒ“'ÿ†<=Q{fæðù¬úÒø¤(|kC}Ù[9c(¦ªëßÊÈãø;8ˆ`*`\Al—#L z#ÅüœKšŠ5g?鲚 Ðd ½Â¯jîÿÚÌóãfþS@Ñr«>É­¡]h†@(Åö0\h 8š[BA¥2Ó£ìÈøÉht{õæ*ÆÓ,_RPbKáÃÍVÂÜÉ•”§ÿžPK•^ØYPKú>CiHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Site.hxUX ‚IRÈ IRõÅY{oâVÿ;ù·^¥˜‰c2#­T‘f*È„-¤ÓÙnUs7ÆöÚ×$é(ß}ç>ü dšÕJ])3Ø÷ž÷9÷<®[oŽÙÖ“Ç4Xo³»Íwçç?{wþö»ö8»Šóhé‰ ŽIÀžnƒ,à 2¶á)_<²uêE‚/¶J9gñŠù/]s‡‰˜yÑ#Kxš!^/ˆ‚hÍ<"åƒ/‹ (eñJÜ{)ü’yYû’lûù–GBÊÀVAÈ3f‹ gÖLcXM‡¨Õ’{! "FÛf—Ýbç‚¥<ià@~˜/I³Û@E%i’ŒèæT!i¶—ÁŠ~¹Ô/Éam¶ ˆú"XÌhÑç°ˆjÅ)Ëx‘ H¥K©4%d\¡Í%Yßoâ-Á¡B%˜k•§s‰¶Œa>É÷wî Z!ê«8 ã{ÒÑ£e@ªemíÅ9ö½E¼ãR-åü(Z‰BIJOë­lãA‡׿ó@ZË«h–’™@<pF§’ï¾Æ®‘ãºÏfã«ù§Î´Ï36™Žôú=fufx·öi0¿ßÎ ¦Ñü3_±Îè3ûq0ê9¬ÿódÚŸÍØxJÔ7“á åÁ¨;¼í FÙ ŽÆs6Ü æ ;KžšÚ ?#z7ýi÷¯ƒá`þYzíj0å«ñ”uؤ3º·ÃΔMn§“ñ¬!z <Œ®¦`Ô¿éæ.cõ ›]w†CâFä:·PcJ‚²îxòy:øx=g×ãa¯Å}È×ù0ì+nЮ;ì nÖëÜt>ö%Ö„¤’©ÄdŸ®û´J\;øëÎãéÓæS¼:Pw:/°? f}‡u¦ƒ–:NÇ`BÖÒXÒꨯ‘åë½ßÎú5‰zýÎg„_…''·ŽÏ¿óÖQ‡™»AR ƒÅÅñq°¥à`´àÞó…Û ²ÄþæÂìDü.v‡[]øÄË…ì1s— ÷Mm!ˆÝ+d‰b­Æ×‚÷J ’{*Dàvç ¯¯ÿ‡ð2Ol2b|œgtÂjŒË%zŸ=f‚oÍêÐÛ.–ðüIŽ‘8ìËñQF©ÇÇ©Žd‚B²yb7Ù—§V+^dqÈ?~–æá/XÙì›:W—? /eöüfò[o0m²&àŽö`ü”#Óö‚¹#N à‹¯Óœöÿ šø¢.ŠDf79ÿ•]^2K*m1¥Ð‘6al’‘°­-#ãEü_‘¥vS,¥=>áßÎKe™`—,ÊÃðB/eÁroeñ(°.Ù¹ªÕšv&80³¶LUȼ ²A: Éq+d6 @”3žqž…Œï‚P*Ål”?p?Þ"ä%vÓ ¢%¯ìFßh’Âgo¥éÑn⥿ÉCàIØÆÁvâ*‘·åÚ*Òt‰4íÖ‚½¤‚3±TÄ0V{¡@´Y*ÁêÞ§ˆ@ãrvʬ–…ÿ‰ž]±M‚EšOŒ‡gŠœØ¤ñ=KN-ªÌó}ž b[òÉ)t@ûà9Iœ9ÆH«lzɰ¦(¯ i®à£´_ÇTdå”A"?@@+2ãš‹ ÞzÀÓ‘CN‘ß(çQú˜´_:iòcC+K¸¦p–Ѻ1ˆv^3ý3HØ™,{10œê`ÛÐæ.áØ¦Â0’å1µÏÅ_ó"0Rwª rü‚—%u7KÂ@Ø ãòK«Ñt“¨YÚ÷ó½9/$¦ .k±¹hµNÈ[Ç*=ã`†Â=ËÅê»=çÎÐ%EkéYíQ}luVbj_™Ø–Ø~güy: EØß¬SH841ÈÚÌ:•òbQÉMÜ?œ2м%¡÷(©ãýyžE\Íù0°Y·­ÔPòU\'Í ànŒvâÁ¶Cm\BÃOÃÝ ¡Lɳݳ‚¸±ËS!Qßz~“é‰Ý2¾ÂØ#‹#FÍ­–éì}ï¼Í©ÃvƆš™r1)y< ß}.\/×ÉÚ#kƒ¦4]Ü!ö®éŠxÆ·;žÚòQùREØ“©/Ô¨Â¸ì ¼,ó,¨ý;GmXÂ7²yZÿ Û²ôƒ¸ë0^x(¼ò¹·&#àÌz³ßž7‰§ôAže¸l]Á˜-w1[ò8¹ µ%ºH•™LâReŒc²Š—z[”*GVì¦ Ÿ`™ÍÛ¯Ÿ¦qªM=çãÞ¸ ÷=¢g¾§^;—l íöX„Ž:eœ0Mdz$Â’ ÈBÔ2Ñ9ZÑÖnÀ;G3®ÆGag…¸ÍÖµàL9T=¹Ûp”dò¥ÍÜ\56bö3ßK8‘ T÷¤ãPº‹ˆÐAQ¼… .¥±Éxî@o¢8'PDKä( ¢­C´YK§I¹5¹%ŸNe$ËD¡º[/rêbvÅ«ýEe±¶úy*:DÙ¨Œ]É5* ­Ûè.BÊ*ÄiX§„~j5¬j4Úi0£_ÒF£àˆÙÄ•NEwZÔNÝ$Æ ‹G­ò™Èm™HJ ½Ôß@C#&QE%|jîYu-}Ѥ·‡MšÃ¤·À{­=óרS ò'Æ$cɼÍr©|®U„z|ÇÃ8©I¦í ÉEûIÙ•.Û"”dšé² àgVƒÁ_4ÚÜÆ.U“‘ê™ ›F<¾˜µ4 íßRŃN&qÚL£j]Z ë‡÷½Áh‘áRJ³7¿¼ö(¡á´ŸÁΛºÞín°]MtüÛ€S…É´Áe²,võåp_5vyAIè”9%]Û¯ÞÔ0¿z½[aÿ -D·8r_—Ä1£ß3ÉøŸHö\úIW^2Òí‚9ñÅ £Y©RŒ#þ\³šº¼¦.ÿšºú²é¯Sö/Ò•Â!?¶|û^ˆ2Ä£ßng.¢ù»2‹å)“ß­SõºaAÌÁºFm©ôYvPi zpÊ$o¤Ku¢PûÞáH•W/Š81®xíÞSÀ‡cÓÖ0tÄʳN•é, Ù+à ºÔü’g~$²Ã’è ×CJV¯äºæ·=§Fä×JëEë“Ð̵+}C±åõÇóë‘2>M“[½1{àÛ=”,iSGà âDÅ/ ÍÔÕW¶£»Ñ]åî³ù&¥»Nu‰¬} u,_$pjý°»D}¤JTX‰7N+WJÁà[OØ´à®Òx«3>Úg¬4ÁãÄsØ g' vò™\·OnÚ'3vòÇ«Ì˜ä ¢ %¹W`x¹ØÈH2ªÈËœW[¤Ñ/•{Ôõ-î¬ù¬yÈ2]¯÷+Ý}@¥™R·²åçBõÕÍ3:tI´¸0–_`Ug,/ƒmFM”™O›•ûVVå&&Ð"ã)º~ȽÈ|ì¤ÖI!|S¶0££9’Ÿl¹írÝ|<ÿPKÛ±'h‚ Ç#PKú>ClHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/SiteApi.hxUX ‚IRÈ IRõ}TQoâ8~>~ŨO°Êµ½J÷Ò=ÀëB%¡½>šÄï†8²MÙjµÿýf ´PèIHÁãù¾o¾Û7_zðFº{5jU;èw··þ~wûÇLÅ ½i+á”n1“’SiÖÊZ €²PK#¯°2¢u² `i¤½„²f%pDû 4zá„jU»AT%êR²«‘Éê¥Û #1¿a­.•@J¨t¹YËÖù`©i¡ïj Wùq5ˆ ¥*)P-Ðöa¶ÊÕzãÀHëŒ*‰&À¤²ÙTTÉa»QkåF=ƒo‰%ÞE+Tmk]©%}¥÷×m²u•"öÅÆaÐR°”-¢ˆ ÝhV6 ‘(4àM¿×xÓ(ÔQsݾ]^z[ë5åÑ›%l×rcZ–VilŸ×ý&KGb_ê¦Ñ[òXê¶RdÍÞï§Xà¾Xèémí†ßj‡UïJ¡‰tï“ÞoÙZ ‡…Ü·Å•ï–8rf¨ ëð<(F§×ýèøúPÇ”AžLЧ0cÀsH³ä‘Ù®Â×W<ñbšÌ ÀŒ,Œ‹gH&ÆÏðǰӌå9$±ñYq†a¢ù˜Ç0Dhœñ/·H¼æž³œøf,MqyÄ‹g?µ /bbž$„†YÁGó(Ì gi’3,bŒÌ1' ±‹‹kưG\@> £ˆÔˆ.œ£Œ …Q’>güaZÀ4‰Æ ƒC†õ…ÈíÔÐÝ( ù,€q8 ˜G%HäMRæ®Lxš2Š’jˆ¿QÁ“˜üŒ’¸Èp Ý¬xC?ñœf<Ç‚½Ç,Aê.‚σИ툨ó§ÂZÏsvRј…2æ„?Χ!ßô:Q~+‰§R7öºÆG¥Q‹¯½žZÓá8 _…´‡¯‰Y –/²Ñ;óíHžœžÒCkHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/SiteDb.hxUX ‚IRÈ IRõ­WmoÛÈþ,ÿŠ©‘ƒ©TG§úEvŒÈe³•E¤ãEq È•µŠäqÉ(jÎÿ½Ïì’2å‹àPÀ€ÅÙ™gÞggOßÑ[çÅ®”늬qÿý»wÿùý»¿½§ëè« i^gITÉ<'3/D¹‘J@RÑZ”b¹£‡2Ê*‘ hU AùŠâuT>ˆU9EÙŽ Q*äË*’™Ì(b¨z™¹ZIå«j•ü EJ屌IIבUÚZÉT(²ªµ ã ‘8î ª¥$3âãö”¶²ZçuE¥PU)c†€)Në„-iS¹‘Uë¨FÐ!QŒ[+¸ÂÖh“'rÅÿ…ö¯¨—©Të%’Ñ—u¢bb,2H1:ÍKR"MDÂíô“í4ܪ —V½]çæe ½Kת.3(Z,É>­÷WWLaôUž¦ù–}Œó,‘ìš6Y q-ó/B»e’Ÿå¬6¦pFЧL7GjÁ‡¥hÂåRG+êxV²ªB=H$£ÈK­÷¹ÇvkǵC7 ïF¾Cn@ ßûäNœ |èÎ ¯½ÛÀáæá=ySÍïéŸî|2 ç_ ß ò|Fso3×Ùg·w~E—{!ÍÜ7nèi šëŒwãøãk|Ž.Ý™Þë¬MÝpÎÈSϧ-F~èŽog#Ÿ·þ 1òÜO}(rnœyhC1hä|Â×£ÙŒµ1Üènøl(½Å½ï^]‡tíÍ&ˆ—ì]Σ Þg#÷f@“ÑÍèÊÑR€´“Ìi̤»k‡©¬u„¿qèzsögìÍCŸ¸ë‡{é;7p4òÝk}J8ºò4DçŽâÈ&,ü}8MœÑ ˆËwù9ɧGEŽª2O•½ÆPIåòìèHn¸8Hí”,í·gÏá®jO<¶QµV,R+.o–¹=Ålè’ø;Ø©Jl -N1SèV‰’Ä×Jd‰"ÏtË·££žn㘾D%É„†¸ÉÙ5‹6‚éèñìáðhU§é+ÇbÉô…³‚mz::zlí\”¹¶íÿlj"T\ÊBOÒïslÅRÉê%ùfª½„žo³4vÉÍ*ú@ïÀðqXŠTÏU ç¢ìSGDSÀÎy9äý‚ˆÿÜ ÕÏôóOæû’G=ÅÃ;nÙWu¦'=¾æÎ±h›—ÉÐXN} Ì0³Ï¿!ŒÚÞŽ\ë=^ ܽë-;“‰­–°úÐ×c,O~zÿ~:aÚ ÃÏ*šÔáÚD ¿´•ˆÊxm½a|;•Ÿ…Å2}úýwzÓIIç¨ß\zí¢Vk‹Œ‘ ´-“ÖÖ–¢sþHÚ2Hán`£ñ…Šz)2Ú—»9­¾öôô4ô&Þk¯È‘ä`áMP¡U¼æ EÕ…nÄg>UeÛëÆ~"ÊËÝPÛeWù,ߊr)?´«¨3­„)leÎ c§™Iûú÷|ÌGº¼§™wçøƒ÷O°eD©}ãÞ¾gÂèáOõK¹NAwj°‰îA ¶é¶6¾V|U^À*eQÖ´D§ê ¶©E^-ê¬2MÙ5ÁŠ#UÑM±8ûj—â·{ŒuÜÄ (ÌìÛyh½ícm2P&ˆ+ß»]pÙË}4 ÓÄ Ææ^¤cú+e} «:E6ž‡¶i´ïŸbçxýš—&bÏdöýS¦íÁÇa†ñ-Sq¨T|‘èaØèdõæ<øe/ ùâ ¡ÎëÍ~ÚûBƒ«Ï² g×z<@FT¸¯¥}!àô—Ì´Z“Ù*‡~p[}t‹Ðaß[Ñ)¢–shLî%CµxbèÈ ô/•þ¥cc~§º¿á ¾L¾fyÔ½èô”Ôo)_ IŽ%ë ­#,§{"°À U¸´pâ|ÃË»ú±+ãùawóoÓ``^ù¨<î‘N×}ûãüyi€ýÌž Ìs㬙^¯ÌÑå®)b‹Š§Š~Ué›¶>| Bóç<©ÅßÇ¡L,¼AÊAÛLM_NPo©Žÿ:³wЄ,|ÐLøî½ûƒíú4TÅdÉ›øèÔ-Á<γLèAE{»è—5)¿<²•|¨K“ß%/n€8 K¼±”ÚéË'Úé×C*0_I<îùª¹Í`ÁâB—+²&—¿`¯ºW¶øŠé‹××g½›ÊÚŽ¡¯—ö?ðò²‹¨ÄÕõ$†þ…71àûú6ë \A$Ða#‹LÝ™cX`h¯3¼aP²<ëÐØ\<’ä…Ù)šu£)5•e´;o¸Ï';L_\çß ÏɳfÝÓMvh¸¾›Q~@Û—QKñ?û…fÓYeT¿ é_Bž¯ãR XÛ¨nÌÚÒëÅúŽÎؿǗ÷4ä6«‹}öì8ÍU—} [žƒqÕ>!¦›ÇÄS)R»ìdù––XP±c1ŠSপ~Ùó*È¥ïX÷ãÑÿPK™5 Y:PKú>CmHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Template.hxUX ‚IRÈ IRõ¥TMkÜ0=;ÿ0 …H:ôjwsI)ôÐ44!—REïšh-#É›]šýïÕ—åµréÅËÎ×›yóFãÏl…`¤:_³Šæ©<=9=i6Tœ)¯tþ£3lËì÷F5íê;ë|LkxÀM'˜AÀÁ¶Ò!8YÿœždÚ0ÓpØ2uƒ¢ºa|°€_ •$´Cë¾å®…ï¼fßaqã?Ù·lÓðkê‹g®¬5¸‚6(_¡ñq·ÖæÓ|ᬩœð9îm4q™4VÊŽÜ÷]¯Z* ÞM›0¾µ¶×–ãWçЈ†~aq Fõø; ÜG¡éU{4¿«Ð]‹ICµ÷U‰,⬗!±lÑ",(1Ú~ýÒ¾½ºÎdMä0dÆ™FxðN‹`ÌÒv´%2ÑÎÃYà/øêü? ¯¯0µ_ØÉ–¼íÂRó³{i÷ñkܸáï”ìP™=‘q:š°PhºÍ²[Ùâà9„ß kÖ Sõ6T^3ÉKea]ϼÐë0ߊmyVømÒÇí qâ}/[ZÀ¶<²:ÜÚ^ˆ=ËìGnQ©¦BèT³u•úÙ°g¼cfM°x”M¯!©EÐA9Û/Ù)èÞ²žÉ.¸¼º2ÒŠ»FÂÅwÕY-˘҆ gDœuá{u»ïòÎpžŸƒ'dPz Q䌧=*Ìí®d´eéæ:5k%_BTÞÕ©FÛäé±rìÔÒÌÆNkCêç’Þ ÄŠ| ¡q”DÖÀ=±+…èL²@BíÂi Oi”OÚ_Ú›B-ÅÉô¢'ëš+‰ËÖØçu¦§©œb;QU£¨Ò äŸ1nvî³O¦oªÖF¼¯Û)Ð iîø`¸µž/—¼W [³\΄‡+Sb´¿ÙÝtq+!Ÿ¬ªÿóÎõðPK¥!Ð0ÁPKv¹B,Haxe Toolkit Installer Template/haxelogo.pngUX ™IR/7 QõÝ»‡SSÛ6¯W±aCE@@ºtD•zïé¡#] DEA@@¡J ½÷^TšH B¤B/ $ï9¹¿™ï?øÞ™73 Ã9묶Ÿõ¬µwaZJ´/@ Z¨²¼òÏr vî,p+›Ìü:ï®lì ÜŸN=¿—â\¤ñ‚ª+ÐLŸa8-ų?ù&r•¦ç‡ÅOø™ pG}—ìÎú>g÷‹¹wþzgQ6g킼Ãð“I"tÜ8gÊžY"f¯ë[µÇ#hj°nTÚ¯ˆrRç2Žoјªwqî5¶­šv \Ñu™ãô¶2 ãB±+\çô»v9;Ñðy‡´Áú//ŠýÃ$±—´—ð/`®uéÒVZ0îs äÿùOÆKDLJ6[öÅDÛÇm´ñwñÓ† ¥²•é‚ûUôb›vägä¥Çébý§…çÑæ©y¦3ˆcÕwRHä-ñöF¡õu¢[²²…ÛJ¹’ úY/7³h›±NîWÖ …aC›$ÒººuÞ/&Fx[[@ðóÝÄ>7·Mú :™$24°™+*º¶D·B+㌜!Ã)eX9õ*ÓÓ»“ÉsÚ8\ëÿ~¥)â¹èȧ…9é´HkU. “©×W¤9V,~ð·ÍØRžÒåðànV)¾ì²H ß>è=iuë£Oûz¹#Ïär(æ(ê¯OÏÔ‹Ã 2ïWË)ˆ:«d{£ÆW²§_ëRžPÀW¯J\åVÌYYÆ6¥Åƒ_)*8›üª“CŠžÊ„-ÒÐŽ5ÁË6Xº¥™tµ÷Ö‹~ú««|ÂSoJóˆu×È‹YÕçíªøÕÚ?óîÇKäk©6«eà l0ÙÞ´âñög]<_ñ(3¯·,3ûXÑë´´;o£¸9&Oz2)qrtg gÈŽµøNy ÛTâj)ø¹A¬Èþ4™~é¯GÏÖ¸ ‹ð´ä±H±¯J\§æÒé‰8 Ë[ó®.|y¸ böðÞZçÀA¨†v½‚Žt äÆ.áÁ/Šoê°¿òF[&ÑHð%ÊÞíÆ”0qi›„¯Ê>³ný0Z+;¹ê²YO+ÃÕ8,ÚspÔBxe•‘å& Fò¹o¡ylC´j£ªŽ“ ΘYSñA™@·ö^ïïÐþÖšL bÎáN|*ÙÔ…Ìi¿8§¯QÛ’ò™:LáZpôûXŒ,'/‹¶|"YØãÉöúÆÜ7…•„¹ƒ'+ü2öVµ¾ÿ.ŸódªK@µûŒìRXl"Á ÷ï øsü#”t¤4Ï‘^éµ-g;¿—“ɦ±µk±‹xàØ±äy”>q‘œ˜mêäÚ©4f#P%q§7os$+(ñì xFÛfáNùcU¤ÊË\Pñ`ýL/)g¼Ë~¾š½M!·–±!Ï~¼M6‚ÕM¯N:'5z'kçýñCJ±žîÚ/ka%Ù†å|b²Iªåíh‰m¢OXŽ(bÖ¬§ˆRlÇ™Ç$ðëÒ_ùÓ7t8ý£Ëze&¸ÂØ`/çaBZØoiÓÓÀ7D«4Ö”GM{³3¤Ê ´MöŽëÒ{/{U ›p¥J¡ä„Ðl¿OA:FÖÚÍ[›æ ˆú…¼ÕíS©H1™ UG‹Ù€âAÄACÕÚ¯ššJ·ç—aa>Ü<•r=Cã36ªVÓ­Ëï\±zDœr7“EÎ$Í_†<1Ò½3䞤1ÜP³%ˆj† Ž8Í@ËØK:Œ%`¦”´wW~  }zWSîRX[(HA­Ì‹*ð<ô‰îcÑ Ø&7#¿» "šØ0ÛG¿ec½Ú²â‰J¼ã½[=¿_ˆúìçeáQô3û…Ùýý›Fç}!;…ÇyäñÅWÍ_ýÛmr c *qP˜YfË”“d€)AØ?͹·—Ÿmkd;“þ½ùàîÜü$SK"–ÏÁ©JZ½=±1e¡â:Pw}Ù\“¥ß#.Ä;}SJoüo~«-3°üÅmlˆFÎ8­á0š¿Rôò{_P‚¦sP¡\‚’û¹Ò…2óOßvÅýÚ·{Õ\ü’"Ö’4^¯Š"àߤ;¾âÐm|j•TnØð##g>ç#Òdã`íÅÊÅ}Môh§Ìnx%ß_B|h´ŠA Ç—Rít5ÂÇèE¹ÀGu=½cëAK¼¿ª¶î7N¾¢‚§ª¢Fw>¨ðý3³{ hxßdIiqܶ®¶êvx%:C¯²å¬ÿ{ ¥ÓäfœîÚîäýñ”þ&ÍBõMXÛçÇÀº3«Åú£b§8§»„|,rìü›Áö›0Âb1pÕ.æÚ’‘“;lO¦ó)Ê…Of+-NÕlrq˜r‘â²ôT®ÒåL@oÿö²v£KLÔ̵}Cbè1¹fE­C7K ÒÒAòÝ쥈ªÚròד2¸u'îœùpì§¾Ïgz^%ÔÅ£Ää þ_:ÀßP|ºãŠ2‘ÞdùÙ QÓ³¾,z’OârîOCèÉÖxî‚•Íy§<]¶´ *Ö Ë—óÓ#Öò݉ø~|²ý;•üûG1ò ÕqH¬2­¼tJtƒn…~~^ðe`öždºš§¢¢i¼œVyÕ)·[­þ4D$%M'ôrõýÐΗãwÙÊrÚâ3ó“jõ*¡ÃÉw럾se2EgGŠ4qã¯õ,‘ϧº’æc•¾ *‰&N/~5*‚õ»³ÖåèTê… îÚ™òqÜIÃóòWøäÖØ(\`ÞWc$|:Lî=¥XÇeNÙ¨qNPˆ†ú÷®Ó¿ÓÌE^gu ›Ç”LÉûŸfò ó¡ŸÐ;ZPæ^°¯Wþ)½#­Ï ápûÅéßOFLrŸÞ§5v%ÂãœQæûðÀ1 â/2þà¿¢âŸÝ÷1Auý©Gã‚û£d‚²†]¿Õ«ÚÑ'ö÷ƒÿ&šoˆ•€°ÍpóP/Xçñ¸dÕð­ol %sÔpOPo—Rnt.P[ÍÐ変’3ìØKŽjÞ>•N¨WÊÓîê®ì\Á¬N¨ÎõÉõ Ü›ù°û !ì\?Êì¸Æß¶£€é‰Æô:”Z;Pÿ¯ü]Ž#QãŽÚÀz­—A÷?d Òd1Ð4w×;1ÿ~¡­<¥¼,sw‡\Xá¾ã“ª0Ëb¯ýúã¡ÃQÒ¾Ùeç6™«·[3í†mŒj>*„aRÚŠ1(×»@о|ÌÚ˱¶ž…y =b$Ð_§ÓÓ_Z)üÀ‚pyÚB+á9ùŠ æ›z©}²MãòÂTlì¤àý2óÌ4œæ 0^'y'”½8÷ðgI¿j’©þÏYß·ÇW/lS&Ói) —Ñ­œÐFq ,=|æV:Û7tóC'2Ýe=pž™5Û5-ŽÛWžröËô·LB´HC0¸ËVxIJKȇƒÆ_ÙgdªA(Ì´I#ªLPt—²Ne¥ú•ѳÅòÏ^‚ëuV_¹Ù5xwH£y"¨FÝ“Ln&ùºÈ{0f+ÓQ>àÂÑeAuñÖ½gÃlÑ`xà‚“ïŽ†{u*h`V²¸©:⾘Q5¡†'ÿOXíýs`o|ojÊ'òîìGŸ¹–\Î3S‚a9Tåö©hZµÌg@73‡å9ðbĉ Ëv$>*—ë‘ýÔ¡PUÓ¬–ù¶˜\2Úož÷ᢆÿ)¯ÏBÙ_ eÁw¡!Þq¼`ºô”T=bÙÓm®þwýœõø× ï…\¬æÆØžÛÉw±a 3‹t*թϨ” $ä&>•'un Í÷÷¨ÚŽú@ˆR#(¬øYÍ+¦]ÎJ˜f“kŽÔºª:HÕg¾ÍØ÷“ †gþ&ÈüæÁD,²Ö‰…î“o7’C9SǶLŸÖ$¹ŸwÒ B!ƒï€t ÷ ‰«½³5êªã_À¨eÒ(b÷˜ª§\OtÜt¦óv² Çqƒ†Kÿ-'°l_rlnÎÛ×Ù%ªßÁwx«Á²k64_rD… ŤƮA)Ynù‚3ì=Ip:%Òû­4î™%a†JGÇ$v@ËSÌ…F%—1uÃN©è»X%’ÓVkšŸÅ¡û ˈYôON híip¥ë^ïÞ÷,7{ó•G8_Î.¿3“Z}X¿‚ÙßýbV«¸ë>þN†kd¦@®`ª˜¢ïWXŒÍE\ÉîDQkПFC+úS?—LË gÎÚ¨mÇóy‰Ü`>^LÜ»W“¸á½áº<ýÁü_Èë¯Õ5Ùî~›)f,Gú ÈòR‹'¬¢ä"rÁÅÂt/!Ëâàºñuvù¦A†XÐô« ÝZÓÒ30».ô$¨ ³Î L¨7E»P ãMÚ¿±.•]O¢Å@Óh‘ì‘‹Èa"¦D“ ­„2·W e4þSÓT’¢©ÍjLúPjôç¡… ¾‰ìÈ&Ú€ó@Ç^Þ¿L«Òˆü:a¡{Ç*• VWº¾•Kà³µ)urØLžo¸•¬º,Íæ`Éš?z³Ìþ5cþGu:›ÅÓ°A‡Söq÷OÊ­=)¬û7¾=8 yÍüEO;»é–×B.ßÌ —€}¹J¨Ú~Ëu±1mª¥Öúš'x†ŸÛÄTkCÆApƒû¬yÀç®v85qlw K¢døÐ¥ñÓûòi”ÊŽÐÁØÂ­,æ’€fo »!áI™Áý÷W$¦…¾Uù6þ§Ù”Ä…š1ìã–àMFn><èl¢wfSýAvYÒ¥±pmœ¶?xj Ÿ ™n»ÔVÇÂi¶‚’ÜYõ'ž”é|˜ƒ+én0>7µd<1;ºŸä¿¦b-/õá€á_VÃr—™±­ÝÖX*-‡’1ÙöKÞ©û?j@!Õ·x”XúÁÛuÂÏè‡x¡¯Uÿ@^7Üíõ®ãLïvî&ßaBmƒÝ3z Ë$ø¤K·T#ÄëÉùU\ÂîØ«“JsÓ'ÊÕÁ~mò4žmå­'‘'ÈáѦδw2µƒb<7"Ót¤†.Ïd-)hÓpáD–œ ëC‘þÈ—f£& e¢„gk`.û;ÏŸ«„%ôá‡~ûó“é^ˆù?Uêm7n>%¹û°ä·R\âúaäùu e{ß}&K~CV››$ç@DÎÜ×5nñl}îV0#û! ^Vã'!eV7Àj8Dç’>oËj±L3¹IåÆèhz(.iÄvj>2y`þÁ§ïÁœM¿l‹¥«Zµ´áÎKY˜cÿ“ïgA ä?oY“CñyÖÿ–ôî ~êÜûõY&±OYNŒÞÿXQ¶ñ[8<3Vp„~Ékrfî>¦¿±>cÅ 1°ÕÂ;‡râ¢`¡ïu`ÙÆ£_Ôñÿ˜–—J–ži)¶¾€}´¶Ó¹{-Àä<ØJ2ÑŠ6ÄÃbz5’mà;¸Òƒî€{pÊ4}JÍÚMkgèU«Ï‰T¸/~£¶±9€D7)ßÖ®AþŽÂ>›ø=ÃP"ºŸvOõû,&ÎXÝÅUomÜ è©…í7p’Tº'öñVÖà¶@À¼ÙwÕmÛ ãfuJú΃òÚÚ kUÍ-í5³ö4ò¹çµBï2 J÷ ¡©´Ò+;/Nþ–;¯Á6`ÈVcßµï%;Ò£Lü2W´—•ÀLÔ…"ppu@¡]øß¢¦ˆ{Õòiñ)†$*Ù{í•6qv&Ï n Eq‡dTº5ìŽÈ#ÇF[Û¬Oƒ&‹Íê|áyfH¿·Å؛«xxˆßtŠ£Ž_h«D§|—Pa ¶&ƒ´µy”†Åœ³‰>ìç•$6l…ÕÖ‡äýöº´u2qæ´ó 0Ê›öÓŒñNÝ\m¦wÔÖFï BOýžÙ\oÞsñß]àl“ÏœJDe§7ˬÎ}ð)vnæQe%<;£Z÷¶ðmBŽ!=úBd°S±!þáúæ€ñ˜=7usJ‚CðUs¨ö” /b(Á×›·©P ‘†?£J~>œÞ²A¿ÕXc‚S­ÆpÏM‡ZP¸«–­÷§ ]jé ÚÄ;‰j±ôòêš\šÕ˜Ìù–ìHzÄBÒÏ2 ™(IUÕ¥}öÆnÃÅÖxuWlÑÑ}‚¼Ô­›}é)5^,Áuí'IåÜWÙ¾j° -ò€õå•ERŸT˜Ï¨J³éÍyéK¤÷„Y÷“<}ä0å@-4¼ßþ],'×–a;®¡~ïð»2?4CÑÈÖoˆ>rúh´†4×JÙÀ{€ßJÕ˜Ù9i¸ÎM$^qo²ÖíŽL—hp•'\­TÞWU%7Ø.Ø$6(‹9òAƱ‰s!—rànŸsÌ ö-¤vµŠ,jíIi«}$Bñ`æÆjmm`’ùJ óàW8tÕâ@¿4Š” ’;=1Ò9?_)‘fÃáJ%]‰ÕN¹”æ”+ÇJÜPPcÛ³ÑÌg 䧨âN`¶˜ß óAsd1?d ÀjÛ=ö :›ËíµroxÁ"­ÓºS^ö-Sóä½êOòR«l3ùÂd9¥r•‰ÔÚ» bjU6D­‚}Z:nÊG‡‡¿ó;x[‰â‹¿ÐÖ= Þfä Áî}Ì–5 h†¢èðùk~¾è«).Ьd¶-4Œz¢ŸÑÄå]„©L€+Iw7EO %ýpíáIº.äü{­º}Uÿ'&†þèÿnÃ;þ¦¯’‰_Dt©]^K:ãg% zÉïŠB„ÔÜ8OâeꃊƒŽ‘¼ ”¯Ã2òÕ¡ù–,:–ã^`.·jpçiâüàõV…j Ëü´Ü.~£lÂKG½uÙ:Éèe>jØLS%rí0ƒ , îûYÈÅØÊãÕð`¥ Ä7,~ÐÐù Ïü~ŒT)’é¿g×tø |_q™Øæî”r*4cX²¤>è J UZD[p÷{m¨¹1498Z‰÷´G³ÍhÉŽY zÐPõAÇì ¬ÊÄ)!?9¾­(ÿp¨ŽL±GI‘ðË‹ë¿àå£ï-gGW;72uH­rc¹x1x»¯Ìc4ˆŠ!öü ‹Ø]ÙWlž/r{¯ò#à œº&¼S\;§+^JÑ»øÇs¶¶þf¨oO×lqƒJ͘EÌÉzkòNx¶×æ¦C.H¤ƒ·»¼²#QáAÅÞã˜Ø)Gi,ôÎÏ.t ÏÑ6yÀ¯ Zl•ƒ?_ãDÌ©ÝÈññ·rñl`ÙŠJŽòÞrHU#qò†¯["›tÔb@Ñ .-PÎ÷GaGfh¿îJ…€É³‹tø¥ý¡[R|P¡iÑøúXNBnó-ÛsìxZ܆¯¥\®Œâá²6+GŠMœ¯Æ¥~žÔ­ñu]·É‰uï¦\©rLZœ *ûÍ7yÇöç®~J‚€lNe«ùvºªà!¬KíHÂÿ<3·'ôÊr‚á®sÌ5·ð¨¿¹ÅJµk5ôÅ>›RÄRÛFªÖkòyc¼#rKHÁÇ£Ë\ÿIàż·û™÷Ñ‘ñxý„~”ávèeÁ°Gw”Rør„*$Ë<ðÝÉÏoRÄ™¾l*éH…+Ö@‡i„±6þ oELj €$°„Æ**’^ä„¿þ}­m§AÛW¯A—lwzºÇÈl€vtñ›9jÚà°¤µî¾7ˆPì%ÌÛ¾•ýˆ¶õÓ.)ñsK×ùï%_xBi<ÑÝÿÔæm¿BõÑàvC¥(‚ì;·_I™É!6tH<lkLqÝæ;h­(ý+ô)»0Œ”±‡pƾ4£UV„ø zû”ø¿ñRØ<ŽýŸ–¥”i ÿî\þÉë ¯5×”èLxºsZvëJ`Q¤¹{+¥œêÍÖ“¬d÷*T¦¤8Mƒ©TÎéÿT§{­ʃ¸×ä=ù\pHB ~UÙŽ{àÓÝ…w¾ F‡¦Í~;#°’n±2Ÿ$½½p"­ÖlÍ•eŽŠÛfR“ô#d‡jVÙRÐ'3îë'¥ê——tù=Ú>øf!0'fY¤7ªAÓ^¤ïnû'L?€ßö㪴®sZå6ܼbáT‡ÔP+ûö¸¨õ'Åýò6sÞZ†¾l+;xÿØÝüˆžêÔ^ ŸQšK…[¸>Æ ˆ¶“ýz æÎ‚Ô!=¤ÄU’º2eYîÍý6Ê›“„=¹ž÷>ÐYM£‰k¨ˆ-«ªüI¦X¡:j£aýýåZ˜ùƒƒPöÁ“2In¹Ò ‚J ˜Kü¨G’ŽÌ ILŽ|›Ô`ª§m uSÒí„å¦xAeP¬ºBoro…Õb_Tn’œÜLC¹$€QGÙw¼ˆÝŽ™:í¬z˜Áe¨˜;ÐïÓàþ(½l²ûió%Ȩ`.;±èÐ"Úk»!ÐŒ!ô;«S…ïâÐÕÞñ6I—ÊÝ W69fÖ¤±ÞÁÛ§=2&8å².;†žDbWA.s̯F7lÁ‰¼u•°Ç„w]síÄê?¸ ‚#¼V*œoÙJ±Ò ßp›62ŒŽó¤b·xõamÞcîl zÚ©Ûkã(Ô¦)]°miÝ`áØÒ¨>ÕËS´´{»ƒ©ÅzíìB•ecF¹¦ŒØjÚG»Ü½N¨©ùe”žÖÎÕ4«YÙIY4‚V2`2G±æÑàýΈ¯”ölÌ> èÚøUŸ*žà”‹<>iÍ.Zô[¹ÆÚ7†ð» (Ô·]ðl¶‘ô;3§–ä-½ÁH”Ì“¥Þèß^´ë‡nf:¼¾Õ+œ—]Brï{ïÿ`I=1¾ã¯¬Ók&ÌUrAÀZ™ÆûÒø£´ÇO*COð*`ã|ázJ°L…ȳS¯rît‰)“ëe …°È‰/IˇOöL»†°O|YŸýóãûîrsé)W4&-ä3 ˜ñß;™öA¤ÏÒ~ÄŸ‘©ý²à±GßXþ Li!â[™ÙŽ"¦Ç(Lýåë›glqÐÜYóKßµ‡¹c¢øDŠ\[C+ËÃ=]ìpm¬êe“ý!3bDÄ‹\IÄSƒ'ež¿CMÅ%ºý@ì¾Á§]DÝFp@ kà»5­ 8AöðC(G.«£‚f ïô7{ä>H^¨¡}ýs©F;yçñô@cÕfT«Hcjòݓإ[?á’zbÆÕFú#g—zØK+5¼¤ÅÁ^ XžO?ü»Ÿ—ÚW†—0U.ö •E«4:²Ò–-*¥È(‡LÚëÕÊõ³àQÙÅ8ΣŽ~´¸ó7€ß¥e$;Ê#D~™Wh¦JmÃÝýÌ AuV¼ý?Í 1x³Á;ÿÃ%U5ß°=×Â-¼ÖüÊÚmvÐKÌtÌì>J0£bÖz7w‹Pä„3Èú…«ºœ3aû¯Šˆ·`'ä´ )qWê@n¾‡­ ñ·•+Çã_ã?9À´§UA‚³ƒ/6ûƒ©ýÃX§‹©|*@ÒûÜg¡`¸öƇEjuÑÇv¸2brF‘«*Iä½,×ìDlAG¥Z,‰»yã ï]l®¦ÐÔIä8«Ùb¸°ó·¼GvMß]ÐÞKlVŠY²IG7•©ïÜ1œ'ò&‘:gÔnçûĨ‚;¢ ‚Ã¥xÃý?+R>Ô0­êÕžiªDÓ8 [ö¹hI”&ÑÃDà¶“¶u=_Kó.ïR·~Öõ†Y¬†ä5lº ¿Ð»çÕš“YTºÆŠ:Ä¡*柼‡ÓCî&0¤¥š[‡ï‹Ä{t®Ô¯á鑽Á>ï+à}Ý£E¼S?ìŒfSÿÄIçeHH˜ÖWé…¼~¬µtQÍò=Ìíõ„A­m.ãuÏ¡ÊFbÀ½§öÙ—ôËMÒÅ£Ç 8éFÃaÙTÿ9,åkëË•õ‹5Ÿüå ù•ÍQÙÏÐ{*·ÃØY«ð,£=&°ø,MqÜ–=ð†G¿üÊ•êò^ÊóéêÖ—qEx¸|ªöéú{¹q7Íz¬[ô­àŸ_fâE\¦Ä-C‹3“\ozólCÁÕHÿàÑ¢ŽëøË±â‰7Š ¦ØíÚu"¶WU¹S6Ï\La î¦>šÒa˜˜ý!1áöBG•G ûæplys7E¥NÙ1µ}LÑœ\U°M·ÚÏ9<ûÐE÷h¼ûÒAhí÷Iß¿¥ÛGù©8øMSß°ý¤Øqá µ^K#¾Ó§º!'Zµ×gaýI]â·4¦T{z¼Öc}RÍ&T“×’Ì®'‘Ùå|…\™ÐÂIu€¦š2±ïoB)¹kˆ‡ó¤Vˆôø‘OŽhí(‡‚tOfKéÇø|l­y`ˆÆ^­:–¦Ù Ñ¿›H}+ ¨CÎ¥DͲ"'h¦€1TW:í—´Nð]«-Ûï©­Ž/¥ ͤ‚´‡ÞpOÚ¯M7Ìwž áŸ³Ž¼šE5Gãz)½ær·¦XX«ñþâî4iªø`ÎgïR(6qS\ ’±rú‡ª­Z,Ú­$"Î( Ú¯[<ûWÞßðƒB¦„J£Çµº}”Âþ×*ÖŒêápMØÎÚ†¿š'…ÿkìýúTjîÌÚ¹XŸ*3ŸäWòÅN|2¢¼È07OIe$YèwDÁÿ@qš·ßö“Áùö¡K‘‡âíŒôVZ¥È±O<ëd¡ëáž»¯³¯ùý}˜Ä‰Sª4®ïGÐ7:ü0\ï¦ñ+m³£Ï¬Þîé3Hk`”Pµ…@ê?þ;¾¡›˜„^7²©¡ô0ºDdKè­äFp4[ÍŽ±È>Ê2–eu:ÃBŠJµ…FGÍ–墉ï SwÓ$¬@‰é]Üj’ŸEDl—?úK¤]\¡ájñd ñ nØ0nßß+„›þœZLVÖ01iüCK}%ÃøÛt÷0’ž¢Op‰Ü¹«¹½ á§”þ¼]É—<¿ÆcS;òlT÷e¼kÂe{ǰm2kY*ÛöÔW¨~â?@ç[’³nh¬v{V¯ø‚ï¹\}„e\m‹ð{õË¢‹/üeWT)ýœBĺsô¾ìHIýd©Ô"‘øía›en(§y] ì´ÿ|†…wz]µZꆋÈG£hMì>ÚͰF)>òl7‡û8LøüéïnÙ+â,Ø€ge&³MÞÏK5Gç€5²I6côÃÊúî¥kÖÈ$V¬‡+Ë4_©˜–ô×åbÍ6+í&vf¾HyRºÁä˜@¾©m”g5/ÌiYp (ÿ×5gaýÖª\lÛ¼«fKó“<ÇÏuY}2ô"k"¤º'{íÄ·œ&nâØV#s²µŒo¹°táâËÿ«þ¤dä´d>ª$•Œ¤¾-uƒM6±hRBÍ¿8Æ]Ë|öÛ oLü¡^äņ d$Ã7œN~“Û×Õ«œ2 ¹ZšvœX®ðRŠÏ4~óå• ›ÁšñŽ”'àmAî‚c¬L ƒ­ÅlÓùL¦¾“ÀÍÞ`eB\`}Άe€©_Qo+ðjЫ¿Š»#3º§x®+ì$ (_„ mÇÇݶ”£¡XSYGµ C[¿¿ÙJÚÊ•×|…¸P̾ˆ¥Ô± ÌcàÕþÈ–Äw9¢×¹¾_²´2ã\ŒA­!?)Ws¬Þ¸21:,(Af˜ì‡” |­£¾kd«÷øH(AúîÑ*ckKµfÈO4‹I¯ © Åö¹R<õ±HÿÊ]`ê?t¶!çnK!_¾"¼V±|Tó@&ñàåZ À+Ò·hVïU#z|ÖªxôqßéˌщT}×¾íÄM,zþÇ1÷–è|ªxT·3u¨øXl4¦~‹+Ô$aa€l9|¹£L14§×¨ÀPØuÎ…I"I%ÿ=g r@:Â…¨><£ÀV–Ÿù¶´ÄÊ’ÄïÑÖr+Çý7åÈäÂÔ'Qmô?°+Š2‚œJÀ4®NhæØÈùQ7Ñ©R\²*ËQ[ᎅ5.ëEîݾŒ»†¬ß¹Hca7`¤« #õr#;Ìeu}ªª”æ/jK~œT¿°šO¸7%Ä:$^Îg¯èì¶ÿ@šš¦rà–Ò _>›sÑGPrH<·&¥ñÑ,~!Òvï&˜ÃËÊ^录i”DÜ®xëÃc=ô)ºÊTBDàr¨.êþæÑïØ`äMØ*1G!û»»{ ÿçYZ•L\æ“ùǖÄš’UJ!^ë…[AæÉ~ïšißJ“±>{_)Æ£_ÛbÉþ-ÑEWkâ­ÛJ5b€ŽúöÌà—YØ‘+áYd^Y éfÉõ }û Gg¢^dŠ~7+òšÌÓ µ •Õ"0¶•:&ŠªÀÐŒˆC0ôë"Bl†gW:]‚Bh}«ÚЦ‹‡\¹¤ ÔðWò²>ÿÀ.’ýÑ,4¬zéÜ­~ýL˜Œ(1”vP£È*` çbP<Ó»ñå™\ ‡¹æn>•X”ÜÝžPÓËPD=ÍÍùÌшY¿B¿™• ‰åÛäN’Ö”5Mš}t¾¬ éðM¶ŸÌ«þ²¦5mhäõRÃϧ´¾ã”Óî[ïwçÛÂ…–#FçyIÚ®Öà E®5<0;üÿ:ßÊøYä! '"ã¥Ã!ò¤×íX£ pñµº={㬿_L^õ6°¨¦ÝA]ÞÝ- ¡ˆWÔ¯6@ew1¾œúï…²cwrá0¥n5º}¨ÏÝ[ªeÅ”ü7¦éÂ…ýÁÖ v -ñ…&ü ¦³«ñîë¿m£›WÆãÞU^† $‡‡:g­U}+iþoÿ§ÀÿO½!Ê•¶[Ÿu¬˜À¿¡ ò¥Ï_¼ý?PK1ÏÕ“.d2PKl¹B-Haxe Toolkit Installer Template/haxelogo3.pngUX ™IR7 QõÍšƒsœ]Æcll7¶Û¶í4¶µ±mÛlØØhÒ¨±667h’†Mòåý/¾3ó<ÏÌbν7~×uf6FUY@€€€@‘“•Tÿ|¾üw!À}Þ£ÁúBŸDY=÷Ï÷Wÿ» Åéò|>_„÷S’‚ß‚%€ÀUªX€ ƒ“ÓôY¿ìú‚ôŽ__W¶{ì²ÊkSäô·´£6³°P9¿Î†ì Z æÃˆ¯O„Ü *’ÙV‘`"„Xd»( OË-\yG¼R×+Cû¤ŽL˜b^•/›™’%(l¹u\·kjÕ^lÛœ$õÕQm´0O¥R7ò$}ë2jy0¾®zë]¿àúü,0Ùx“`t ·toÃ)-­D©fyvâ$/Ø®¯™ÂßL7“ ƒ•äc‡xbpñfˆ=:ÁB:dydÏšù™Aß”óœ»óþ|Ü·MsÑêÊþòä~o´?4=¡/`&,HÐBõZJ ¸4Ì¿q?H„µ–DmW/`~o$#…AEA›wÄÎçƒö[Ú±×Ü#b+iàh\A⇙Tº-#“ª çpø[i¤.Zï-6I¿;üÔ¤H5-R€š£À<¥ß§J ½4ß¼7]È¡;Ã{pÒÞ(ó­Õ@빞±"¯>ÎýŠC—î0”müK&ŠÚ>¯’DÎêPŸn]Hwµ zº˜:; ¾œw·±$ï®tc"ø¦’ŽÙ =)ûÎ÷{€òCß¾\ýËL3iì±9ùÑÌU EÖÇ|®ýw²óC/}ØVz2?m€­l¾•K:…¤Ø×ÓvÌC¸\(Tÿ™±FøwQT¯s¾ )ã%­Ómvò¾@(:ë ~¢ÒÔ)xíœç=ÁYe½HøÐ~¢­ŽTx¢ØšL5Õúlëå4Wz!-»i—(˜.ž0A#–8š IõLWÏÂÓ ‚ÇT-ÌØ–*E«Nk4f41ž»YnKQ_|˜ðã7W›_¬±Ð«vzQŸ®þô1“w6èû%ˆ# Ú 45À5à.ƒ»Ì' X«+[("DSÖ¬µc ï¬ñ]Pb0¾£ê9 ÷J²òÊþ”Ú†YéÍÕ9àvã¹VV@¬cžúŠÛSyˆÓbê*œŠfã+‚,³‰þ’Flj@þîñ‘Â*¡z»%}¡H p¼aw3ùvçàÖ”v‡ô&ß½üëà„òìñ„*éû—æ×c'¨ÖbÙµ¤ì7™kB¨›=f6u®Ù&MˆxµìáË!®æ!ÿ ïr$](²Õ:Ö[î"u4?q øÜó¯bs¯XhýKšUZ1¸¯x˹l Ä6Ç,w%žgêáݯÃÐ5á·öï»âÒ§ffl Ö5iI@¨€ùt]{Ò\é«I¸)x^s ódöïσ U3c¿>ù1ÒÅÃ,± ÂtsáµdóÄ窰 ‹ÓåSꌒWž*¨Àè?Ó~½zíMÛÓJ"V»B_>UiªAa FwL^ñÝýèzÀ$ünøY'Hç´°ÖÉ€‚Þ'œOà–†‰#ùiã€ÆÄ¦Ãf­ ýqžˆ |³ž9¢.üF¦¡«ÊǪqêH~8¨à,è=Ô`É)æú­WCðH*³5lÌPA2Q§¡“…ÛÙÜžÙ y:˜`ÍÓˆN'˜¹Ì9ãâäXInŠ9|µ05XzãáMšAÆëÐSýà7·¦Ɉjò‘_=oCëÕV-?¬° ˜K~Œ.Ã}2Â8â6íùÕ{âa¸ÑA%±¦¬jK´ÍÊÎú²Æg¸ž¥çè‘c ÏP7!ä 9ÙûÜÂéb Iד¾¤æçÙÞA"]‰¦&ȇJ_ÊŬ7_Ѥt±.7ý&¾‘6—Áf‡˜?!þÆ¥åéð«dÇîä$äú³% xßE—„«Š6#frq0Q©ªxäo”¦âR³¢N; ?p}8\XsJë?âëâlí8Ëäíô»‰áHt륌€ ÑB:œ¹²&vú™©F)¹Vv­{SŸ·C¸éT|K¥ç)Ý^é@Rê?€ãÃÑMtĽAœâ +T-‰ƒR’ 4c8FxeiYÕ÷éo_np¿=A$¥ˆô<>¢¨ðP$ª‚cW™½ß·Ã¨áôR”Ø>àÜŠÒå_Ý¿Ð^Ú²§®'lÀˆ²µA»É‰MþRüg3°X:®àx˜ª¯rÉcüX§XAAÑý^r'_Ш|Vá×âá^{§ðÒo¦Ù†IÆdo:!®³‘:î‰à([,•¾_ëØK‡vBòÚìøÃú¾§V°CûèùÎð8†Ñ©‰êÕLgGt’SE9êWNþq†øŠb I/úÅž?³ wßNm•w¬cï²'¸&Lè²mɆ]ÃNT µI38ÅÆ'q|0|…sÿ¤K£GÂÖÓi]„S=HÐÊH€Å¥L=—<ø7ÚAâÁÑ’é1˜FG ~ðâ£gfŒ2PÕkæÔ~é×·Q¾8¶Uä#Oîÿt»`w Ösšž?$ºÛ€^äµ,¬EŠð.üâ«<,`;zwE輕ªG=Ä%œ”¤f0¶›[#ñ%1h¢ìƒF/°ÐN>·î\hžgªJÃMÊÜ•(Cå?xkí._#Š)y?¬)5T1WXb#A_Úb¯eDKÁ»pø'Ì·¸:ØÃXÈ¢mg(íSÀ yÉ„©•p¸+ÚþBÃ$îF¶šrR¸«« Ò¨`¶¯¹ÅE­sH]ÎkR=Íé¿—HoлgD\ÂÙ¨ c~¥¸dI!Øž“R?ùgCÂÉ(HP,´WTãpral©jÆ¢w¦©+*¨+nDo§D=>B]Ïž€jÛtŸòR®òÒ3Ïó»°ÔÉmÀ§oOœä?4í¨Júµ׋ô+Ë á–éÊ<ªrÕ/…ˆ{Mp+Æ¥cò$>ƒ™qiÞ’kÃ/ßUÊ/Ôïñca ªªS åS |¨-¹/o~ÿ;Ý”ù;ÒD=ºtÉç*“=è׃ç.ÅŸíÂ?*üùÕ|«ÿÜýÀÁop9o¹â."‰6fwkrüÛøëjå×Á#¹?°Rºìâ|HÑ~6¡.·qü v?Ç*¼…̵ž|xÂ#GEH„,3>¿Á­:é3>xÿìu Õ ñÉæ&åØ3ö’7íxáúR;4”ÂL_.ø‡Ó0? rPýŠ˜ßzù<Ìñ i+(¤,;ßðŠd¢”ßÝ^¡€F¾¶ïÄÛA5O";Ïpã(‰?÷ú CÔ2ËK¢ë rt€}ID;SsøPûxÅÃñ ZòG„ \/ ß,(ŒÆGì“@y£„3‡4 hÿSml±ìþ‰ð­ì~m!‡-=_]YÃn^*×>)ÎÿòüVGnq×)UUëYðбYúÅLôñšÖdŸ[&en‹y~®n>r$ÏcƒÇ® +qi‘pŒ®*vN,¦ïÈ(ã¦N° -µa&$¤å_ca£‘YqêuD¢êyºl3’Zä­Ê_æb|y+CZÑ„Hð#‘mãnû4kqLMm\H{¨ª<7g·hõžÅj²»&h1‘×p{c +à"zƇ=3R×9ïBÑgN2s«BT@,G–Q\t4Ý(Øì¬4yç`ÒU=tÙk†ð¯äŽþüo—ä÷½Ü[a¦Ì_è‘GÞüÆÃk:ÑÍ0"û.@è‡'Bb©ì¡Þ½¹jDÄ‘n„j3yGZßH‡\É}­¾ ˜¤è¿#jx†#}¿o¹ë$ÎüRS©)Ã6ÏFÉ»)Km«à°¨•@(ÄRÙ8ä*Ì'Œ‹&øW%)¯6c&ÉÊ´›ÙËÚ(NrÚæê1;…ó [Nž{¼qø®“ÓÐÛP61)ƒ3¥ÙH:’]Ó½À0{5ÑÏï 2qýü*.ËŠ*„©®DÎòçØ'FN7íà›ÔåÄÜw³iM#W­™«æýù iYL#tbY.zLÛ]f­·áIõ[ún«Î@.˜øÏ@´µ„Ò—¸Ž †VKó—u óƒ¡bNîîóc–R?ÍC?Qž÷CÀâÈ\¤l)8ÁYé:¬?±€#ˆ9`.¶\¿Tf> ¢KŠ9V%9„V Q3Kþ± Xê\æ*¼%D®z ÷åóSGJŽ?2RúÉ^™‰;íeÎé(·n~Æ(¶C ÷cœ4ûÁ£lIχŸ§|;5ñyj³X5p(_^nŽï`£tãÔÐ$€ÉŽDÿpOt´˜º©úêyÊPØÊXð/='¡€~ 1gq8ÎF! È†N½'A¹-78_4‰£¬—Áä[º“. Â 5ÍÜt ˆí¨>{ x0ÓLó¼´—%¿ÖY¸¶‹\*^ÀˆmR`˜àÛèòrëìÇÝ86˜ÖeÉÚ Ù«&¬”»8מ®vå6\¸£®-2žh®Õ¾a;H<ì׿X'v•Õoý£YýÛw2—8ªŠa”õ•}Æww˜¿JÜ•ìµç7É…·ÂŸvþއ€ë…†Ë”j‰ Iûr±µÊ’1Iqmá©=È`¹ðÄ:x†ß¶Æ–h–-Q…’æÿãs«E˜x´öm™yÁoÒpÖMpÞF´œßgüÑ¢4Ióî$M܈ÈpÔë5Ò¤ðï.?q°-LX-Ëí»¡&x4þ´ã„ëªÍ-{¯an¸Oµl«¡ï^×q¸“~ß1ú®(B[¿%r)ñÈèãá\¸òuЬx¢üÐØCcÏZ!pxTÒ¯»0·<Žª6g)ÕÉÍ•¾uñäŸ;»fÛ¥Pø¼Tú²–Oû‚ƒª©.ÊÀñ‘ó½ù®í/¸¹ ütƺ6‘i£Cæ3q Œ‰XVÔ¥>^Ob |&8r㣊Ÿã¯MbQÍÓjF«n¹$¿rðDÚ‰7’îãíŽnö7"«NÙÛþO>!͸3çÄøü˜£ØõÖÏ[} Ââ²b(ûÝÈþðµÙ©R/Ë[ÂÙØØØM¬AW$7ÈÒ÷s}+7ŽzÉb­êÔ¥è óÈꪠ¥fÊH}íŽòè†vï¨ ã)ûãÜQk%»+J*­(ÆSÍDm‘WµòŒ +þLa…Ä/@L}Xº«þ/Óg‰ÝoÏÅëuèFø?z7«ÏšuâÌöKÖÅ7|Nrü¿9]œôä;ë¶ ]w|ˆ½h¢Ë6~¨=_&±¶,‘Ç/,0ãn*µ*HûZxæE½¨cIr‚›UnGŸtý5pœóœõʪ‹§®S ÃF\"*·Þ~îžVWœƒ‡ßL,ºø~.²M»„í}PÜ,úîLFt‰j=Üów¦˜Å™êŽn¬$x`{èåµ=¸]L«B¼?}@ØEµÔ·¾‘¾ÅÓ¾D¢¯´¼yîf…D䃯X8_S® ÎPûÌ,c;ô|ˆ6šÅÔÔçç°ëδú|ƒ*·µ r¶|Žîªg¦QÞêP¸æ-ÍU³)wœ^k´È¯×Ct†b4 Ïšgs„š•>H­Xñ×§iÞe¥Å‹à}ÉUsKën÷iÃhÐAȦõ&O>=ë$ñ¼É»pŽ9‹iýp>T V­\|ÆÞýÁÄ…D½Ï m T98±¾»¡ÓBLc/ë³}^Þà§¿ÝéÚÚ¤°CuHGÓòaßÝ> Gûl tU%œŒí¹ˆkÆXD¶i«UƒH=±,£˜ÍÚ!.e±@7«+4ÇF#Ê×HÒ¼GÉ3'Íö-Õš›×Áo:È{¢±^ñÍ­’÷8Îm)j½Ž£<Ó~èæÒ‰\õºþ›Ÿ+›S„–ëy>¿!C毄ç©V™uö7½hг-+Bf€tCŠeN’Ôs ÉŸöVf¡íȰÄz˜2Œ‘D·ÕÚ6O9šŽõñ»õåœ/ß]¹à=5øyïóg9bÖêý%²-Peð÷ËÐÉšºó`fOÁuÝwr»éoQ)¤ß“Qÿï2vE?äåüB"‚Û¨c+Ù?‡÷6ØlůìNÒgrŠ^ž™woØ7]ŒøêtX5ÔíSŒW§Ì­ ‰3Mt§0­Œ¥:Ûé—Pª Úœ$ÚÖÇ­^6„Ït…§yÂxG½_u¤Ú”éÒ8ƒ£tëÄ" Ç‚ÿpvÊí½Îhõ:öÃnûÃ{±Ý7¬YÜ#-çtEÙE]%¨¶ Ê‚ ’*ehY§—!¨—ùaknwƒäîS ~ðÌÊ€-þkÓ·cúS&%ÇEȱ•¦rì§fÿ7/üƒF‹õ¡ ó~ìO‹ Ç+Фs:9¾KL;÷ž¾æŸ ‡M&ØDrÇ®{y‹,ƒuÚZ÷ Õž nÕ‚œ¼©#©VÕmb! dZ~ú'«Á:GR©¦7V—Å{ï͆Å8¸ ÄË"Á9å¯!tRŒŸ*˜z"›uk7Ì à<ôr½Œýð½ê_ò` ¦†ƒŸ—Ì¡Õêã ŸoN¸ÈŠ«¸ƒ!Ò…;g¦B,´Í íÔþ88Îj 5'؂Թ¡ýµ6;3¹ñMÁÖ‹w@°`ÕVó°lcI™-V.W¿4oýÝ.´/¾‰¨ z&aÙ£DsrãÁ©–§£ßêÇ„Spz¤=~TYwÅ]æB­…ÞE 3B:ÖHwÊ]F]®ÄŸÞ ÖÜ‘ÞVppr±ja縎F66:S M— ñ†Ö«ih,ËÂä/ôí;¾º?43§Lñk-̨(® ^¾"ÜXC´½^W<Üž‘°Å[ÉôŽ:þ ~*‚ LüΦ Ú°Çr˜4Ò5þãuÇôW]-Á j¾¾T0k–]å]73ÍÌÚwû%NSDð$F˜Ó8ÙÆx©x¿#DeÑYÇE€Zgæà&¶#Oåa˜†þt‰Ù×]Í{ïñckµSdâ}Å4ÌeKyÈçËØ*FÍW•@'ü¯¼É}[DÇ8Î#!¿5æb¸-Jƒ”hAzw;ÿ*yD*>åýù”xËXŠV 3‹Ö‡ü N) ðg‚-*9GvÈ'u¨ƒxÊà (]Qä´Ùv%>§4úŠ–}>ÏÒgNø|H+4•yƒUì E߬¸b8)*÷¨Þô%u“q;2ÌS]¼ˆªõz+òi2Ž@þáœcz;ßEÂe!{ê{ŠŠµÖ+6¡@^æ÷ú‘P p{Q¸·Ã”! • ½5Eؽ{½løk…¹«:¶¼6‰HðÂÈ àÞ±}Pëwã_óŒ^ïõ³¾›g‹u^~9qt9x¡Ó¤M¿™ËH!&ßMó¥÷Ñ©ÜÓ,âá°„‹óŸx¬~S¹ì,Y÷-y]X“e˜†ˆ7Ïi¡Ðéƒ:Áq.;¬lP«BÏZÔ}€2Jö¾ÿÔ$-X 6ý…º óÙ£KSBó2œ¬x¢žÁÞÑÂ…Fí.¾+ ´¯ Ź_9f„C÷^ÄçFŒö²k…*¡ð%¿@ª¦4=ßžì­3«Ücü=Ö¿z"ЬÄà¿ò`›4@˜À™¶¤Ž„íÆÈoÆö0Uý ;úÿ­JYº¹y…€ ÿ÷_] ¯ä#Êß×*n>ŽU…ш4R#Ó3Žðßúò™`ð@uÆÒê;Ìžr½TÕ¢(hÃÏ@®¦ì˜0„<íŸ×™hâÕÀf?*þ#õ¼È\€ÒZí²µôIª}#”lŽL«ài|&môJ0ÉJe|w+³ úÅAîGS@R1~m¥C†*ïÍK9•o^dÀ ÝY1tÈ÷ à·Ë:KcÓ´™$m‘é\ùOãÄ ¼»1ÂKî&S¬†Ä”Éì5+Ï<ƒ ª!É…lÜÂ3«D·0šŠ úä­oÕ²WÊø¿'c¹ØÌ¾”ìí¢*¯þ˺ÄâðâjðºqhÑ¡_…Ü —=H·ô;ÕKÉ—Rš:D®p+ꚇôÓ¿._P>ÄiB8ž…E:p$¥h>öÓ”Ù:¾E ß[}½d…W úëM;†ÍÒìùÒ„ÝrÙuÝþ(P5ÔßfÄEU4Ü®¥9͵jZÏg í`œªlf4èŸï¶ÈZJ²ŽòúÅ•j.¤'WZo*Qø&Y½(&›Wø…qaU|åK‡šåºé{‰Ý²r³R&ŠBUÓ/<•8úò=N‘”Ú‚*šÐ/Nûë Íæ`Œ{u9bÞ²ƒÀŠv¯£(™¢£¤5yÈõRgÕóÖŠŠ–ȯ ‡f‚E®uFÊù÷È}2ú}ÎLÍ8æo£íjZ‘Ðó2Ž3-³³‡™úböFô2cñh‹C%&s±êS‡óxZ6ô,=bÐ}(¿¢êj†£o‚:Ã2~sö(ŠéÈa„ãw2]Þìb; T—Ì•ï!N!wbL >•¥¬[B_)Ap~•ÚÚùîïà#¤™$6f¦ýz˜|ÓÄñê#8æ j ÷û®aÒ¾cÙ:õÁb*=‘]1„÷¿:ŠG5—Á€²XK\s4.Lîé&•Q…ÌúJбüXðøÙ§Psw)óVøNS è6£ŠºÍþEâMéô‰ˆ‹£Üõ¬k¿Q î­—œ±J„¯—@‹cK ùëU.ü¡Aý]D½*""ª.­P=3aLyZ¢µÙ-ž˜-à`Ü¡Ý6÷m4úòµÖ>øQ‹4€K‹ô"Cè†ÝMrul·æg!êÖeËЂ;2r¥4x)~+\­>W>÷¥¾ã‚ìù˜~›;•E7fÉHüþ}è0HM€ó-HÓº¼ŒªýžôSg®WH³>¸QŸÆ ^/5Ôî{§ð[¦7ÔikÍðspsÙġЛÇ0±¡®!Tq§m2õe"OýÈÑ–e#4³j ácíû2¸G ¹‡i0¶OWä Ê|zœYÈÅe]",}Û$à-n›i5–™R¿“æ>Hî`Æåzý.ýѼk0Â-KöRí‹q>Åñ¸@\íÿÓžr#ô3ÕxK*™Tßoô¾á|Ú_ýSp8ÜOëLNcúÏÈÈá]ñáåfÅROÂoJC Ì]æL#ö+µwtù·tDïòSd"ÛFÀéɇOZÚ‘ö϶®ÒÁYIíw½ÏFƒ T(×ÇÄήòïWâj¢ÅuÆ++Íõ8¡ù ~²žEþ×à‘œ ÓÆäG>!Nsü±þúŽÒЫÿꚌˆhÓhkÀè#u9wß¡øÄ Wù²F܆A7 y*¬ûºG=ø‘©òs½jÞÒ¯rÜcTø¬­9·EüY8+šò`2{L#·FHUN£ú™é®urÒngùµ†®¯jD›Ðÿ~ÕE᪠Šë"ú|É|”ÎµÕæ¶$?3wëáêÑÑoqô†ÜYêSã›G¾YàÙ -[ÀvÞÇÎ:ª €ÍTç1ðß ê‹{r>1#XŠía^åùÏæ3ìË Òî^m‰ à/H,Œ‘çVÖ»»:œ²LcèΫ÷ÙÈVaÅpûÒµ_ØM.x› Æû1Yfâj¥}ñLð h#¬Ç‚ºî>¾ØØù]ºî§2¦Dm\ ÂUú\Ä™EZ#9ö õè?ÛmF»ñÜÏ|NDæUQ¥êí—€7*gT'q.õ!ÈÂ'î–Ò!­óe¤¤RuóV'¹ =@7“¡‰2^¤,²»Ð#1Àýíé;gÛ€Á Éä˜l"}[ðœR0Ë‘‡vé¿çB§) ¯.ý¹Œ™+áÆª!|IÁ— ³²b¦.?|»ÉŸ²}býÒQÒ/Š»Mš2ñ‡ŒšhèB¬'œf³\… ^+ûÆU’óšsBºùD I \ÉÓðØåâP½(>Nïù:Ô|² *¿ö".ud”ż›÷=äúÙ‘T5{U/¤ÐTf¦ùÂ]f§‰ã¢®þ|y«}X€RG†u…x‚oùq¼ Þ­Åœ,ˆl d…jåÇ®¶«‰uPDÖl`E–ìˆ8[XòÌLm{ú O¸?8*r@©×ið§B3âò±ì^ù± ¥Â¢Ó“Y]à’+Ü©´*böD$>E=›æºµ¨¼ÂϰÂÁC.~žÓ>8  rŠ÷=‘W©c%ä~ÆÁHâ:½0OÇ òàêfµnßf †îÕTçêé¶ç Än—5ñbÚšÇ;>¼M>ÙÐÉ~gá-ÒS:™Üý…&‰å;8 ¢Pþ»¼Z+N~©õdÓL#€?#xXéc¾ïöu4ÄNm•ÂÙŽ¤›±¦=ð4اÔĬºàqtÃ{Öˆ~ +€D¢Wx§"µ@DcC¬ÍÃZ£VŒK‰M¢i¶Ð3RNGkÕû8›1Ûöȹú⥰ä/ÎHwn«&_Ío—ÔK)1¥´<éœÑ ºX3îÈÒÜ‹òFŸRg¯wÂ`c†â}§ƒÂ¬Ôà†zBû¾ãªLl|‰GÊ|à*_ õmMê[ÆÃeÏV&ÔÖç YÚO°©#žÖÄl¯ÒÿQrç0‡ ïS­H\ ºÊÔî¡•<Œ ïØýKiCyµµ$üßÑ ÄPR*8Xß; nâ€sú¿Ùß´?ÏÍÍ¿6ÚÏÂéœÒG1¨»E®$ É2 ^S÷ƒcéà,v,R¯ÉF7"ñ´«ÍyE&÷^é0ûHù WõÉ¥©;+b¶uæ2˜ó*‹§†ÿ¾$jô: .h-{Q/¶[ž””Z`/a0ö¯iû«á·pOaZ)•^É|RÑÆ$c»¾®ï9/ îýK”fË·ÑYsŸ£ÐŸÞ~qæî1,ÿòúÊ}bÊY¡gÅU`éݯK±f°gùgf ÇC/©[ö¦da#-…bT eG&é² _W?„È g.‡è³Ó6írw&˜[ÿ~Å´jŽ<Ηʛ tèª:ÂßÝy¦¼º3 ”„&…kÙ`D§€÷—¾û ,¸â~byÝãýí¡ *'`m ¹þD1.^qþ2‚äøõE¿tsûÍ_ZLŠ{ ÿhÿ¡2Ñá¤Ç´5Ãþ܅¢7B‰ ´gV&Ìèµ×%&WÞX#BÛêÔÓ>û­©“ —zÈ8öJGêq”|¡^üò'w*([ù(*1§©—•ÓpŒn›…g8úWÈ6ªZ=²£*w‰XŠ"Ü“e–#iö+AF÷ÉëaèÒì†DÔZ–;ÏT >`[EO‘ÐÀj¦ƒãèÌ*ß1ØŽú£ãÆM.$Þ¢ó+@!TÕ^; `ų÷6›{ˆKE[ù½Ðû$l©I~=ÕW<Ó/ð…ö¡y^§g'}îörüÎЈp="qk|פËgèæ”£’Š\»ç”ŽÄ€:éʃ['®VÝCx®×ƒ =~s=]É a T|Ù-oSs[6ú<̺ œQê}£‡Ÿ{íëùÐÍò`óSúÚp c~éjHÄ~LHSñËQXH ‘¯DrŽ%,³ãPNåWҔߖwÃIêãª0Ëœ»8‘6Ÿse‚ÇzÿÞîô\;àßDôW…êësóxÛ‚Òy‰õpéÿÍ­E¡Ãß{­°Ž&Ÿ"ðÛx‹Dycc˜µù$tcÓ–cŒ |»vw9ê:1FÚ–S:ìjJ ïÎîµKþ¸ph¿)7Õn£uÁ:L£/(~Æ[‡'mVº£ë‡•HS^0ËpÄáÔ$Úïéz ÔìÉyß,~ÒœJ÷û.›êô/º.—ß4ưCÎn†íUû1°x»€¥9=à÷G!ŸÄtÅó’÷_ËpG·Ü–tȆc êC yÙǶ¹„úTèÀ7MFÚon÷œ²ˆ­¶¸FJâ@a[…bïÈö4égN gVÎÇWˆJx ⛃!èô$cÿÑ‹”ž¯c¼öõö¤y±òQxÂHþ ¯kKÞ"p½ à ×Ä-Bþõ”»n¦oëâgjÚŒô¸a˜(…´F՘ͲIÑàɯ*÷J„ëšY¥–éoÑ Gܸ¿‘LLE%ç%3Ûa/eg¹–suu8Jµd‹CÍÔc±Rˆ·R××Á&¬¤A*Ò7@€éÂí|W¹«Eî-p¥Ëìù Ò†4¯ÔÇܖ4]T÷³PÖÛ®'×éS{Id½a¯:Ss¸_X{MA^ÜhcßPƒ¢û^–j!fꉫaŒx«‚igh|œ·`žÌa¬€‰@œä¨gY»Áí k£šnaµ†[©–„¾3òÌFÃENʳ =Ø‚>®´ëZ`ûû†|oRæD…ÓØÛ[ÔôgN§NÀ£È¼ÏçQTC@„óÙx¸áùƨFO¤é¦hãW¥0T/œõ°;<–B0µäõ¼ª¶j_±c˜W¹ ^+Ò:NýE¶á°¬±}€Ú ¬jXrâ˜9÷?I¼AyÙŸ½˜¾–qòÉÂfË K–‹?¦Äª§BÛ©]”¨ÐË€l9ä!Váãï(ðº-y=ƒ¬¤ ¤÷dŠ<©™;Uõ<›£9«ÂE·Eza™¨¬ªÀGwz\èaRG!vj_ÞΛãϘw`a{ î ŒžïéCÇbpèÏxÅÓXlTæ8ÏLdÒYDÍš`;Å_æA=³‡M=¼*“TÈ ”ݵ§êf9’={h¬•íèLJWÙ?¼äÌësÛË¿ÑÛÉHÖcV‹‰º1 ù@mv_i¶ª1ä›÷ÛùgØj>t˜]šÄZ™«_‹ÜfïYÇÓù:g+ôIh}þÞäVÒL)ùFß—?*Bb;ҼȽœí,ªøªRßx”ÓûÒҹȩS`$(H¦Ú\9+ÂÐMXÎöØ{ïòm‘% ëD ”é”bÞ-‡‘¼š1™5óá’Y–ó,„™ŠÅF56±ä)PòÍE •õ×Ô|]qƒL7Úé"¬"‚;“}éI3‹2¨s‚nÁÊòÜìÏn  ¢®÷ïXß1ßκŸE/¿¯……÷/ p8GÜÕ ñ†0A xøäœLmÓ‹G—#üÔOvUJâÂ)ù%×Á„µžÊø ïÛgÈÙÎþ#ûÌ‹àëÇ{Hã:;ö'9â/*ššpÊižs«”­ÁÊ\Ér–l÷jÊkµ£¤‹_Qí_a`ãmá3œèÛÐ yªº0ce–Î"ÒŸ°_{C­;Rg!°ŽÞ<]y‘Ö9áíÀk£ ÈɩÔÍÊÃÉ»H@ø3ÞÖlÕ0õ%É™K¹Vrr#/r˜¬ä@ÝcÖñfR ”©Ã¦*’%HG¸Ù9o5üÚ&£uµKס´ïÎꫜiƒŽÏl©8!‡kp6k¯Ÿ|¡¯ñEøM.>,ßþ>ª&s •9Cûn¬ìŒù™BlÜÙ*ˆsTz‚YÆPI«îÿÞ =4Ÿ¼£fÁ÷Ä.¸ý–êuéâ–W÷„•2ô°óÖ)!¶’+9N\†Õ÷ìv°›Ö¾¼õvA 3|cŸ¦"ïîŽä;bÉNÀkå:šáB¾‘ÖœÃ}bÝýÂDà×àzXømþŽL;zçü°ñwC¼|Ün»ýÛLiW1‚„Öš¤Ô‡ç#r3ËccP!„Ù¤ÂÀÙBim¥´n%of‰S›bñp±ŒØT$Ê ˜ CèÌp íN«ðúÒ~Áý6ýÞø=ÓAíRvªu†º(aÆã£vMö¼{±àUs0£í:úž„zÓQÌÊò9¯ Câã!¦¡³•GewÝþ‡Ó;÷¶ôBs;Aq {°ÚëÂÜ8±“' Qxýˆ>7 ÞhŸ#ÀO¿,KEó€DÐõÌ㺛Ï`!à¡Ë]}A Š)çjÓéÎlãªg!5ÆÃ—‰Ó\÷nâ-±ÎQ3`PÐê<¥'FQ³×<“ýolÑpsR«¯æöZQ–Ð0×A³'Á2ŸÈÛÉ‹8Œ,ö÷ªÚ\§ ³yùE<5øý?ìâö"Zäù“qöGàÿ¿¦ÔðPöòŽ:¦ñ[U^»å¡tyÑ}­²ö…¯cבLê²åî»`Ãíôxf–!PSVürÇ7ž¾Á0ºÓÚ .¤ã‹w2^k¨ÛÏî§U¶µ—ÑìÁû¯Y+Ã…ö/çxj ‰Æó_Ênµ)©å-,V²9éåÛgc[6 -éQÓmR©Dry¬¬siŠóÁc)Ð%YºÖ6ýïNc¤¹ÖéªÏCXzïn°Q¿Ë¥½€1² ò&ðtê¿Jz7™&³ˆt÷³9K±ðÙªOyµR‡M$»iîBˆAôOEêZy®çqRï“P¡«Ð0¨)añÄÜÅWi‘Ͱ*7Ü¡ìø){(&,)—‘¥,9>O¶,½/|àn÷[ Äš_ýk ËŸ3†cÇ¢’·mz1ÄO¹HýžÍó·lƒìøØÙ ~E 9½4.ÛPBû[Ñá÷‡Ã%5ûÜyF@å^aNø'õëå¹9s{a«bL Ä÷C„Ë\– ƒ“ñ; Iª²›ß5¼rù_JøX(¹çÓ^ƒÀΆ‹jbàä_’Ó^ïX+¬‡^ÛOÌB3 5Í9’æzå3Œ(ÿ^]UC'Ng©ÅÑ0†m›gÂj-üd{b"¾·erƒÕsüÔwGù¼ù›´ŸgüqDO𖚉´ë—ʱ4Þ?™Ê–!©×5ÍôÇf"fcKaL¿¿^€@À2{}Ç%®AŽSc¬ö—@ù ´m‰#³ë!Úá¼óÇ,’ \ #5a½¥æ¤€Â´­©µ×¢{¬³½ÿ‹ÕŒóô)”'ójœ^ ñ¹ä¤”%ÄMCÿPKãæÇ¾U;Y<PK >C/Haxe Toolkit Installer Template/neko-2.0.0-osx/UX ‚IRkIRõPK>C8Haxe Toolkit Installer Template/neko-2.0.0-osx/.DS_StoreUX ‚IR’IRõí˜;Â0Dg K4.)Ýpn`EÉ ¸W ÷Ñ!Ú²RP%‚y’õVŠiOØð¸_€ Á3>’Ø„®6Î!„Bˆ}c®tÜvBˆ2Ÿ…®tsŸ:vc2]èJ7·±_ #èLºÒÍÍCË>Œ+Š1…X¡ëW¯,Äßppåùû?a5ÿ !~‹ãuð˯vëê†õK@🅧nl¡+Ýܺ±OPKjˆm²PK >C8__MACOSX/Haxe Toolkit Installer Template/neko-2.0.0-osx/UX ™IR™IRõPK>CC__MACOSX/Haxe Toolkit Installer Template/neko-2.0.0-osx/._.DS_StoreUX ‚IR’IRõc`cg`b`ðMLVðVˆP€'±ƒøA L…VPK¾CŠ *RPK>C9__MACOSX/Haxe Toolkit Installer Template/._neko-2.0.0-osxUX ‚IRkIRõc`cg`b`ðMLVðVˆP€'ñ ñï1CB‚ LŽ@솦„!.šœŸ«—XP“ªWXšX”˜W’™—ÊP¨o```hmj˜h``l”f힟Ÿž“SadàœQ”Ÿ›jíh`blbnéªkjääªkbaâªkélä¨ëâìldäèdâdädÌPK#"ü¿‘ÞPK >C$Haxe Toolkit Installer Template/out/UX ‚IR’IRõPK>C-Haxe Toolkit Installer Template/out/.DS_StoreUX ‚IR“IRõí˜;Â0Dg K4.)Ýpn`EÉ ¸W ÷Ñ!Ú²RP%‚y’õVŠiOØð¸_€ Á3>’Ø„®6Î!„Bˆ}c®tÜvBˆ2Ÿ…®tsŸ:vc2]èJ7·±_ #èLºÒÍÍCË>Œ+Š1…X¡ëW¯,Äßppåùû?a5ÿ !~‹ãuð˯vëê†õK@🅧nl¡+Ýܺ±OPKjˆm²PK >C-__MACOSX/Haxe Toolkit Installer Template/out/UX ™IR™IRõPK>C8__MACOSX/Haxe Toolkit Installer Template/out/._.DS_StoreUX ‚IR“IRõc`cg`b`ðMLVðVˆP€'±ƒøA L…VPK¾CŠ *RPK Ö>C(Haxe Toolkit Installer Template/scripts/UX ‚IR$IRõPKÖ>C;Haxe Toolkit Installer Template/scripts/haxe-postinstall.shUX ‚IR$IRõ}O» B1 ÝóÇë&”Žü WqðöA m/´Wñó uÒP—óÈIr<è5UÝ#µýèmÀxyA¸Í .§•r…êšá Gù‰›Ù8Vî™™ÈRÀÊaùös³àvÆ}% C1__MACOSX/Haxe Toolkit Installer Template/scripts/UX ™IR™IRõPKÖ>CF__MACOSX/Haxe Toolkit Installer Template/scripts/._haxe-postinstall.shUX ‚IR$IRõc`cg`b`ðMLVðVˆP€'q%ƒø«ˆŽ!!AP&HÇ æGSˆOÎÏÕK,(ÈIÕ I­(qÍKÎOÉÌKJ––¤éZX›š[Z˜PKpÀ]«PKq>C:Haxe Toolkit Installer Template/scripts/haxe-preinstall.shUX ‚IR†IRõSVÔOÊÌÓ/Îà*ÊUÐ-JSÐ/-.ÒÏÉLÒÏH¬HÕ/.IÁ.‘’Ÿ PK4’Žp);PKq>CE__MACOSX/Haxe Toolkit Installer Template/scripts/._haxe-preinstall.shUX ‚IR†IRõc`cg`b`ðMLVðVˆP€'q%ƒø«ˆŽ!!AP&HÇ æGSˆOÎÏÕK,(ÈIÕ I­(qÍKÎOÉÌKJ––¤éZX›š[Z˜PKpÀ]«PKܹB;Haxe Toolkit Installer Template/scripts/neko-postinstall.shUX ‚IR04 QõSVÔOÊÌÓ/Îà*ÊUÐ/-.sóR³ó1’1Drs0„JòósŠá¢9™I ’ÐK©²¸¸ròt‹² )0f9.eÉènÂ¥07í¸”‚ÝŒÍØ4 x‡/PK‹´ÓJ\UPKܹBF__MACOSX/Haxe Toolkit Installer Template/scripts/._neko-postinstall.shUX ‚IR04 Qõc`cg`b`ðMLVðVˆP€'q%ƒø«ˆŽ!!AP&HÇ æGSˆOÎÏÕK,(ÈIÕ I­(qÍKÎOÉÌKJ––¤éZX›š[Z˜PKpÀ]«PKì¸B:Haxe Toolkit Installer Template/scripts/neko-preinstall.shUX ‚IRí QõSVÔOÊÌÓ/Îà*ÊUÐ-JSÐ/-.ÒÏÉLÒÏKÍÎçPK%=p×!PK >C @íAHaxe Toolkit Installer Template/UX‚IRaIRPK>Cdè 0) @¤NHaxe Toolkit Installer Template/.DS_StoreUX‚IRaIRPK >C @ýAÕ__MACOSX/UX™IR™IRPK >C) @ýA __MACOSX/Haxe Toolkit Installer Template/UX™IR™IRPK>C¾CŠ *R4 @¤c__MACOSX/Haxe Toolkit Installer Template/._.DS_StoreUX‚IRaIRPK Y:C= @íAÿHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/UX™IRYÉCRPKY:C8šŽš÷C'½P @¤jHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/01haxe-contents.xmlUX‚IRYÉCRPKY:C õ;ÿì†G @¤ïHHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/01haxe.xmlUX‚IRYÉCRPKY:CŠ/îP @¤`KHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/02neko-contents.xmlUX‚IRYÉCRPKY:C™§Ò•ÛPG @¤MHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/02neko.xmlUX‚IRYÉCRPKY:C"›gyñœ F @¤}OHaxe Toolkit Installer Template/Haxe Toolkit Installer.pmdoc/index.xmlUX‚IRYÉCRPKY:C%í!Ÿ(RG @¤òR__MACOSX/Haxe Toolkit Installer Template/._Haxe Toolkit Installer.pmdocUX™IRYÉCRPK >C/ @íAŸSHaxe Toolkit Installer Template/haxe-3.0.0-osx/UX‚IRgIRPK>C§N¼8 @¤üSHaxe Toolkit Installer Template/haxe-3.0.0-osx/.DS_StoreUX‚IRjIRPK >C8 @ýAŽU__MACOSX/Haxe Toolkit Installer Template/haxe-3.0.0-osx/UX™IR™IRPK>C¾CŠ *RC @¤ôU__MACOSX/Haxe Toolkit Installer Template/haxe-3.0.0-osx/._.DS_StoreUX‚IRjIRPK j>C: @íAŸVHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/UX‚IR˜ IRPK ú>CI @íAWHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/UX‚IRÈ IRPKú>C€Ãþ Q @¤~WHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/.currentUX‚IRÈ IRPK ú>CT @íAXHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/UX‚IRÈ IRPKú>CȈuÒéf` @¤›XHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/haxelib.jsonUX™IRÈ IRPK ú>CZ @íA"ZHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/UX‚IRÈ IRPK ú>Cb @íAªZHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/UX‚IRÈ IRPKú>C|ÑøÅéo @¤:[Haxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/ConvertXml.hxUX‚IRÈ IRPKú>C?ÖA% { i @¤¬^Haxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Data.hxUX‚IRÈ IRPKú>Cü‰{Fcw @¤xjHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/dbconfig.json.exampleUX‚IRÈ IRPKú>C¼šu˜Ð m @¤skHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/haxelib.cssUX‚IRÈ IRPKú>CDhŸê¾)…i @¤¶oHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Main.hxUX‚IRÈ IRPKú>C–š÷Úöj @¤šHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Paths.hxUX‚IRÈ IRPKú>C¯,í—l @¤Ñ›Haxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Rebuild.hxUX‚IRÈ IRPKú>Cð§Ù…š Ó$i @¤hžHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Repo.hxUX‚IRÈ IRPKú>C•^ØYk @¤©«Haxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/SemVer.hxUX‚IRÈ IRPKú>CÛ±'h‚ Ç#i @¤«®Haxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Site.hxUX‚IRÈ IRPKú>C#‡i‰‘\l @¤Ô¼Haxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/SiteApi.hxUX‚IRÈ IRPKú>C™5 Y:k @¤ÁHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/SiteDb.hxUX‚IRÈ IRPKú>C¥!Ð0Ám @¤ÉHaxe Toolkit Installer Template/haxe-3.0.0-osx/lib-client/haxelib_client/3,1,0-rc,3/tools/haxelib/Template.hxUX‚IRÈ IRPKv¹B1ÏÕ“.d2, @¤}ÌHaxe Toolkit Installer Template/haxelogo.pngUX™IR/7 QPKl¹BãæÇ¾U;Y<- @¤zûHaxe Toolkit Installer Template/haxelogo3.pngUX™IR7 QPK >C/ @íA:7Haxe Toolkit Installer Template/neko-2.0.0-osx/UX‚IRkIRPK>Cjˆm²8 @¤—7Haxe Toolkit Installer Template/neko-2.0.0-osx/.DS_StoreUX‚IR’IRPK >C8 @ýA¿8__MACOSX/Haxe Toolkit Installer Template/neko-2.0.0-osx/UX™IR™IRPK>C¾CŠ *RC @¤%9__MACOSX/Haxe Toolkit Installer Template/neko-2.0.0-osx/._.DS_StoreUX‚IR’IRPK>C#"ü¿‘Þ9 @¤Ð9__MACOSX/Haxe Toolkit Installer Template/._neko-2.0.0-osxUX‚IRkIRPK >C$ @íAØ:Haxe Toolkit Installer Template/out/UX‚IR’IRPK>Cjˆm²- @¤*;Haxe Toolkit Installer Template/out/.DS_StoreUX‚IR“IRPK >C- @ýAG<__MACOSX/Haxe Toolkit Installer Template/out/UX™IR™IRPK>C¾CŠ *R8 @¤¢<__MACOSX/Haxe Toolkit Installer Template/out/._.DS_StoreUX‚IR“IRPK Ö>C( @íAB=Haxe Toolkit Installer Template/scripts/UX‚IR$IRPKÖ>C¤*c‡”; @ÿ˜=Haxe Toolkit Installer Template/scripts/haxe-postinstall.shUX‚IR$IRPK >C1 @ýA˜>__MACOSX/Haxe Toolkit Installer Template/scripts/UX™IR™IRPKÖ>CpÀ]«F @¶÷>__MACOSX/Haxe Toolkit Installer Template/scripts/._haxe-postinstall.shUX‚IR$IRPKq>C4’Žp);: @ÿØ?Haxe Toolkit Installer Template/scripts/haxe-preinstall.shUX‚IR†IRPKq>CpÀ]«E @¶y@__MACOSX/Haxe Toolkit Installer Template/scripts/._haxe-preinstall.shUX‚IR†IRPKܹB‹´ÓJ\U; @ÿYAHaxe Toolkit Installer Template/scripts/neko-postinstall.shUX‚IR04 QPKܹBpÀ]«F @¶.B__MACOSX/Haxe Toolkit Installer Template/scripts/._neko-postinstall.shUX‚IR04 QPKì¸B%=p×!: @ÿCHaxe Toolkit Installer Template/scripts/neko-preinstall.shUX‚IRí QPK887¨Chaxe_3.2.1+dfsg.orig/extra/release-checklist.txt0000664000175000017500000000202312607337712021574 0ustar andyandy00000000000000# Preparing related projects - Check that haxelib is working - Make sure to update the haxelib submodule - Check that the run-time haxelibs are ready for release: hxcpp, hxjava, hxcs # Building the binaries and installers - Make sure CHANGES.txt has a proper date set! - Make sure `version` in main.ml has the correct value. - Merge development branch into master. - Wait for Travis to greenlight master. - Tag master as MAJOR.MINOR.PATCH. - Wait for builds.haxe.org to build master. - Get https://github.com/waneck/hxbuilds/tree/master/release-helper - Run it with the fileName corresponding to the latest master file name on builds.haxe.org. # Making the release - Push the generated binaries and installers to haxe.org. - Copy relevant changelog part to CHANGES.md. - Write announcement post. - Copy announcement post to RELEASE.md. - Update versions.json # Announcing the release - Update Github README page. - Regenerate and upload API documentation. - Update http://haxe.org/file/CHANGES.txt - Post announcement post to haxelang. haxe_3.2.1+dfsg.orig/extra/release.neko0000664000175000017500000000413412607337712017747 0ustar andyandy00000000000000version = $loader.args[0]; if( version == null ) $throw(" argument required"); sys = $loader.loadprim("std@sys_string",0)(); binext = ""; curdir = "./"; ext = switch( sys ) { "Windows" => { curdir = ".\\"; binext = ".exe"; "-win" } "Mac" => "-osx" "Linux" => "-linux" "BSD" => "-bsd" default => $throw("Unknown system") } rights = 493; // octal 755 _mkdir = $loader.loadprim("std@sys_create_dir",2); mkdir = function(d) { _mkdir(d,rights); } chdir = $loader.loadprim("std@set_cwd",1); _cmd = $loader.loadprim("std@sys_command",1); cmd = function(c) { if( _cmd(c) != 0 ) $throw("Command '"+c+"' failed"); } dir = "haxe-"+version+ext; cmd("rm -rf "+dir); mkdir(dir); mkdir(dir+"/doc"); if( sys == "Windows" ) { cmd("cp ../haxe.exe ../haxesetup.exe haxeserver.bat "+dir); // copy if available (means we build on recent OCaml/MSVC) try cmd("cp C:/Windows/System32/msvcr100.dll "+dir) catch e {}; } else cmd("cp ../haxe "+dir); cmd("cp -pR CHANGES.txt LICENSE.txt ../std "+dir); if( sys == "Windows" ) cmd("chmod -R 777 "+dir); cmd("haxe all.hxml"); chdir(dir+"/std/tools"); // BUILD TOOLS chdir("haxedoc"); cmd("haxe haxedoc.hxml"); cmd(curdir+"haxedoc -v \"../../../../neko.xml;neko\" \"../../../../js.xml;js\" \"../../../../flash9.xml;flash\" \"../../../../php.xml;php\" \"../../../../cpp.xml;cpp\""); cmd("mv index.html content ../../../doc"); cmd("mv haxedoc"+binext+" ../../.."); chdir(".."); chdir("haxelib"); cmd("haxe haxelib.hxml"); cmd("mv haxelib"+binext+" ../../.."); chdir(".."); // CLEANUP chdir(".."); cmd("rm -rf .svn */.svn */*/.svn */*/*/.svn */*/*/*/.svn"); cmd("rm -rf all.n all.js *.swf *.xml"); chdir("tools"); chdir("haxedoc"); cmd("rm -rf haxedoc.n index.html content haxedoc"+binext); chdir(".."); chdir("haxelib"); cmd("rm -rf *.bat *.zip *.db *.n tmp files"); chdir(".."); chdir("hxinst"); cmd("rm -rf *.n *.zip *.dmg *.app hxinst-win.exe hxinst-linux hxinst-osx"); chdir(".."); chdir(".."); cmd("rm -rf mt mtwin"); chdir("../.."); // PACKAGE if( sys == "Windows" ) cmd("7z a -tzip "+dir+".zip "+dir); else cmd("tar -czf "+dir+".tar.gz "+dir); cmd("rm -rf "+dir); haxe_3.2.1+dfsg.orig/extra/setup.cpp0000664000175000017500000000506212607337712017316 0ustar andyandy00000000000000/* * Haxe Setup * Copyright (c)2006 Nicolas Cannasse * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // this is a small program that do basic Haxe setup on Windows #include static void Set( HKEY k, const char *name, DWORD t, const char *data ) { RegSetValueEx(k,name,0,t,(const BYTE*)data,(DWORD)strlen(data)+1); } int WINAPI WinMain( HINSTANCE inst, HINSTANCE prev, LPSTR lpCmdLine, int nCmdShow ) { char path[MAX_PATH]; *path = '"'; GetModuleFileName(NULL,path+1,MAX_PATH); // register .hxml extension char *s = strrchr(path,'\\') + 1; strcpy(s,"haxe.exe\" -prompt \"%1\""); HKEY k; RegCreateKey(HKEY_CLASSES_ROOT,".hxml\\shell\\Compile\\command",&k); RegSetValueEx(k,NULL,0,REG_SZ,(const BYTE*)path,(DWORD)(strlen(path)+1)); *s = 0; // add %HAXEPATH% to PATH and set HAXEPATH to current path DWORD ktype; DWORD ksize = 16000; char *kdata = new char[16000]; memset(kdata,0,ksize); RegOpenKey(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",&k); RegQueryValueEx(k,"PATH",NULL,&ktype,(LPBYTE)kdata,&ksize); if( strstr(kdata,"%HAXEPATH%") == NULL ) { char *s = kdata + strlen(kdata); strcpy(s,";%HAXEPATH%"); Set(k,"PATH",REG_EXPAND_SZ,kdata); } if( strstr(kdata,"%NEKO_INSTPATH%") == NULL ) { char *s = kdata + strlen(kdata); strcpy(s,";%NEKO_INSTPATH%"); Set(k,"PATH",REG_EXPAND_SZ,kdata); } Set(k,"HAXEPATH",REG_SZ,path + 1); s[-1] = 0; strcpy(strrchr(path,'\\'),"\\neko"); Set(k,"NEKO_INSTPATH",REG_SZ,path+1); RegCloseKey(k); // inform running apps of env changes (W2K/NT systems only ?) DWORD unused; SendMessageTimeout(HWND_BROADCAST,WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_ABORTIFHUNG, 5000, &unused ); // delete kdata; // // register // if( strcmp(lpCmdLine,"-silent") != 0 ) // MessageBox(NULL,"Setup completed, you can start using Haxe now","haxesetup",MB_OK | MB_ICONINFORMATION); return 0; } haxe_3.2.1+dfsg.orig/extra/setup.sln0000664000175000017500000000155612607337712017334 0ustar andyandy00000000000000Microsoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "setup", "setup.vcproj", "{6E869222-35FF-4BC0-B5AA-E63BCB8803A6}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {6E869222-35FF-4BC0-B5AA-E63BCB8803A6}.Debug.ActiveCfg = Debug|Win32 {6E869222-35FF-4BC0-B5AA-E63BCB8803A6}.Debug.Build.0 = Debug|Win32 {6E869222-35FF-4BC0-B5AA-E63BCB8803A6}.Release.ActiveCfg = Release|Win32 {6E869222-35FF-4BC0-B5AA-E63BCB8803A6}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal haxe_3.2.1+dfsg.orig/extra/setup.vcproj0000664000175000017500000000547612607337712020050 0ustar andyandy00000000000000 haxe_3.2.1+dfsg.orig/filters.ml0000664000175000017500000011203312607337712016326 0ustar andyandy00000000000000open Ast open Common open Type open Typecore (* PASS 1 begin *) let rec verify_ast e = match e.eexpr with | TField(_) -> () | TTypeExpr(TClassDecl {cl_kind = KAbstractImpl a}) when not (Meta.has Meta.RuntimeValue a.a_meta) -> error "Cannot use abstract as value" e.epos | _ -> Type.iter verify_ast e (* Wraps implicit blocks in TIf, TFor, TWhile, TFunction and TTry with real ones *) let rec blockify_ast e = match e.eexpr with | TIf(e1,e2,eo) -> {e with eexpr = TIf(blockify_ast e1,mk_block (blockify_ast e2),match eo with None -> None | Some e -> Some (mk_block (blockify_ast e)))} | TFor(v,e1,e2) -> {e with eexpr = TFor(v,blockify_ast e1,mk_block (blockify_ast e2))} | TWhile(e1,e2,flag) -> {e with eexpr = TWhile(blockify_ast e1,mk_block (blockify_ast e2),flag)} | TFunction tf -> {e with eexpr = TFunction {tf with tf_expr = mk_block (blockify_ast tf.tf_expr)}} | TTry(e1,cl) -> {e with eexpr = TTry(mk_block (blockify_ast e1),List.map (fun (v,e) -> v,mk_block (blockify_ast e)) cl)} | TSwitch(e1,cases,def) -> let e1 = blockify_ast e1 in let cases = List.map (fun (el,e) -> el,mk_block (blockify_ast e) ) cases in let def = match def with None -> None | Some e -> Some (mk_block (blockify_ast e)) in {e with eexpr = TSwitch(e1,cases,def)} | _ -> Type.map_expr blockify_ast e (* Pushes complex right-hand side expression inwards. return { exprs; value; } -> { exprs; return value; } x = { exprs; value; } -> { exprs; x = value; } var x = { exprs; value; } -> { var x; exprs; x = value; } *) let promote_complex_rhs com e = let rec is_complex e = match e.eexpr with | TBlock _ | TSwitch _ | TIf _ | TTry _ | TCast(_,Some _) -> true | TBinop(_,e1,e2) -> is_complex e1 || is_complex e2 | TParenthesis e | TMeta(_,e) | TCast(e, None) | TField(e,_) -> is_complex e | _ -> false in let rec loop f e = match e.eexpr with | TBlock(el) -> begin match List.rev el with | elast :: el -> {e with eexpr = TBlock(block (List.rev ((loop f elast) :: el)))} | [] -> e end | TSwitch(es,cases,edef) -> {e with eexpr = TSwitch(es,List.map (fun (el,e) -> List.map find el,loop f e) cases,match edef with None -> None | Some e -> Some (loop f e)); } | TIf(eif,ethen,eelse) -> {e with eexpr = TIf(find eif, loop f ethen, match eelse with None -> None | Some e -> Some (loop f e)); } | TTry(e1,el) -> {e with eexpr = TTry(loop f e1, List.map (fun (el,e) -> el,loop f e) el); } | TParenthesis e1 when not (Common.defined com Define.As3) -> {e with eexpr = TParenthesis(loop f e1)} | TMeta(m,e1) -> { e with eexpr = TMeta(m,loop f e1)} | TReturn _ | TThrow _ -> find e | TContinue | TBreak -> e | _ -> f (find e) and block el = let r = ref [] in List.iter (fun e -> match e.eexpr with | TVar(v,eo) -> begin match eo with | Some e when is_complex e -> let e = find e in r := (loop (fun e -> mk (TBinop(OpAssign,mk (TLocal v) v.v_type e.epos,e)) v.v_type e.epos) e) :: ((mk (TVar (v,None)) com.basic.tvoid e.epos)) :: !r | Some e -> r := (mk (TVar (v,Some (find e))) com.basic.tvoid e.epos) :: !r | None -> r := (mk (TVar (v,None)) com.basic.tvoid e.epos) :: !r end | TReturn (Some e1) when (match follow e1.etype with TAbstract({a_path=[],"Void"},_) -> true | _ -> false) -> r := ({e with eexpr = TReturn None}) :: e1 :: !r | _ -> r := (find e) :: !r ) el; List.rev !r and find e = match e.eexpr with | TReturn (Some e1) -> loop (fun er -> {e with eexpr = TReturn (Some er)}) e1 | TBinop(OpAssign | OpAssignOp _ as op, ({eexpr = TLocal _ | TField _ | TArray _} as e1), e2) -> loop (fun er -> {e with eexpr = TBinop(op, e1, er)}) e2 | TBlock(el) -> {e with eexpr = TBlock (block el)} | _ -> Type.map_expr find e in find e (* Adds final returns to functions as required by some platforms *) let rec add_final_return e = let rec loop e t = let def_return p = let c = (match follow t with | TAbstract ({ a_path = [],"Int" },_) -> TInt 0l | TAbstract ({ a_path = [],"Float" },_) -> TFloat "0." | TAbstract ({ a_path = [],"Bool" },_) -> TBool false | _ -> TNull ) in { eexpr = TReturn (Some { eexpr = TConst c; epos = p; etype = t }); etype = t; epos = p } in match e.eexpr with | TBlock el -> (match List.rev el with | [] -> e | elast :: el -> match loop elast t with | { eexpr = TBlock el2 } -> { e with eexpr = TBlock ((List.rev el) @ el2) } | elast -> { e with eexpr = TBlock (List.rev (elast :: el)) }) | TReturn _ -> e | _ -> { e with eexpr = TBlock [e;def_return e.epos] } in let e = Type.map_expr add_final_return e in match e.eexpr with | TFunction f -> let f = (match follow f.tf_type with | TAbstract ({ a_path = [],"Void" },[]) -> f | t -> { f with tf_expr = loop f.tf_expr t } ) in { e with eexpr = TFunction f } | _ -> e let rec wrap_js_exceptions com e = let rec is_error t = match follow t with | TInst ({cl_path = (["js"],"Error")},_) -> true | TInst ({cl_super = Some (csup,tl)}, _) -> is_error (TInst (csup,tl)) | _ -> false in let rec loop e = match e.eexpr with | TThrow eerr when not (is_error eerr.etype) -> let terr = List.find (fun mt -> match mt with TClassDecl {cl_path = ["js";"_Boot"],"HaxeError"} -> true | _ -> false) com.types in let cerr = match terr with TClassDecl c -> c | _ -> assert false in let ewrap = { eerr with eexpr = TNew (cerr,[],[eerr]) } in { e with eexpr = TThrow ewrap } | _ -> Type.map_expr loop e in loop e (* -------------------------------------------------------------------------- *) (* CHECK LOCAL VARS INIT *) let check_local_vars_init e = let intersect vl1 vl2 = PMap.mapi (fun v t -> t && PMap.find v vl2) vl1 in let join vars cvars = List.iter (fun v -> vars := intersect !vars v) cvars in let restore vars old_vars declared = (* restore variables declared in this block to their previous state *) vars := List.fold_left (fun acc v -> try PMap.add v (PMap.find v old_vars) acc with Not_found -> PMap.remove v acc ) !vars declared; in let declared = ref [] in let rec loop vars e = match e.eexpr with | TLocal v -> let init = (try PMap.find v.v_id !vars with Not_found -> true) in if not init then begin if v.v_name = "this" then error "Missing this = value" e.epos else error ("Local variable " ^ v.v_name ^ " used without being initialized") e.epos end | TVar (v,eo) -> begin match eo with | None -> declared := v.v_id :: !declared; vars := PMap.add v.v_id false !vars | Some e -> loop vars e end | TBlock el -> let old = !declared in let old_vars = !vars in declared := []; List.iter (loop vars) el; restore vars old_vars (List.rev !declared); declared := old; | TBinop (OpAssign,{ eexpr = TLocal v },e) when PMap.mem v.v_id !vars -> loop vars e; vars := PMap.add v.v_id true !vars | TIf (e1,e2,eo) -> loop vars e1; let vbase = !vars in loop vars e2; (match eo with | None -> vars := vbase (* ignore else false cases (they are added by the side-effect handler) *) | Some {eexpr = TConst (TBool(false))} -> () | Some e -> let v1 = !vars in vars := vbase; loop vars e; vars := intersect !vars v1) | TWhile (cond,e,flag) -> (match flag with | NormalWhile when (match cond.eexpr with TParenthesis {eexpr = TConst (TBool true)} -> false | _ -> true) -> loop vars cond; let old = !vars in loop vars e; vars := old; | _ -> loop vars e; loop vars cond) | TTry (e,catches) -> let cvars = List.map (fun (v,e) -> let old = !vars in loop vars e; let v = !vars in vars := old; v ) catches in loop vars e; join vars cvars; | TSwitch (e,cases,def) -> loop vars e; let cvars = List.map (fun (ec,e) -> let old = !vars in List.iter (loop vars) ec; vars := old; loop vars e; let v = !vars in vars := old; v ) cases in (match def with | None when (match e.eexpr with TMeta((Meta.Exhaustive,_,_),_) | TParenthesis({eexpr = TMeta((Meta.Exhaustive,_,_),_)}) -> true | _ -> false) -> (match cvars with | cv :: cvars -> PMap.iter (fun i b -> if b then vars := PMap.add i b !vars) cv; join vars cvars | [] -> ()) | None -> () | Some e -> loop vars e; join vars cvars) (* mark all reachable vars as initialized, since we don't exit the block *) | TBreak | TContinue | TReturn None -> vars := PMap.map (fun _ -> true) !vars | TThrow e | TReturn (Some e) -> loop vars e; vars := PMap.map (fun _ -> true) !vars | _ -> Type.iter (loop vars) e in loop (ref PMap.empty) e; e (* -------------------------------------------------------------------------- *) (* BLOCK VARIABLES CAPTURE *) (* For some platforms, it will simply mark the variables which are used in closures using the v_capture flag so it can be processed in a more optimized For Flash/JS platforms, it will ensure that variables used in loop sub-functions have an unique scope. It transforms the following expression : for( x in array ) funs.push(function() return x++); Into the following : for( _x in array ) { var x = [_x]; funs.push(function(x) { function() return x[0]++; }(x)); } *) type usage = | Block of ((usage -> unit) -> unit) | Loop of ((usage -> unit) -> unit) | Function of ((usage -> unit) -> unit) | Declare of tvar | Use of tvar | Assign of tvar let rec local_usage f e = match e.eexpr with | TBinop ((OpAssign | OpAssignOp _), { eexpr = TLocal v }, e2) -> local_usage f e2; f (Assign v) | TUnop ((Increment | Decrement), _, { eexpr = TLocal v }) -> f (Assign v) | TLocal v -> f (Use v) | TVar (v,eo) -> (match eo with None -> () | Some e -> local_usage f e); f (Declare v); | TFunction tf -> let cc f = List.iter (fun (v,_) -> f (Declare v)) tf.tf_args; local_usage f tf.tf_expr; in f (Function cc) | TBlock l -> f (Block (fun f -> List.iter (local_usage f) l)) | TFor (v,it,e) -> local_usage f it; f (Loop (fun f -> f (Declare v); local_usage f e; )) | TWhile _ -> f (Loop (fun f -> iter (local_usage f) e )) | TTry (e,catchs) -> local_usage f e; List.iter (fun (v,e) -> f (Block (fun f -> f (Declare v); local_usage f e; )) ) catchs; | _ -> iter (local_usage f) e let captured_vars com e = let t = com.basic in let impl = match com.platform with (* optimized version for C#/Java - use native arrays *) | Cs | Java -> let cnativearray = match (List.find (fun md -> match md with | TClassDecl ({ cl_path = ["cs"|"java"],"NativeArray" }) -> true | _ -> false ) com.types) with TClassDecl cl -> cl | _ -> assert false in object method captured_type t = TInst (cnativearray,[t]) method mk_ref v ve p = match ve with | None -> let eone = mk (TConst (TInt (Int32.of_int 1))) t.tint p in let t = match v.v_type with TInst (_, [t]) -> t | _ -> assert false in mk (TNew (cnativearray,[t],[eone])) v.v_type p | Some e -> { (Optimizer.mk_untyped_call "__array__" p [e]) with etype = v.v_type } method mk_ref_access e v = mk (TArray ({ e with etype = v.v_type }, mk (TConst (TInt 0l)) t.tint e.epos)) e.etype e.epos method mk_init av v pos = let elocal = mk (TLocal v) v.v_type pos in let earray = { (Optimizer.mk_untyped_call "__array__" pos [elocal]) with etype = av.v_type } in mk (TVar (av,Some earray)) t.tvoid pos end (* default implementation - use haxe array *) | _ -> object method captured_type = t.tarray method mk_ref v ve p = mk (TArrayDecl (match ve with None -> [] | Some e -> [e])) v.v_type p method mk_ref_access e v = mk (TArray ({ e with etype = v.v_type }, mk (TConst (TInt 0l)) t.tint e.epos)) e.etype e.epos method mk_init av v pos = mk (TVar (av,Some (mk (TArrayDecl [mk (TLocal v) v.v_type pos]) av.v_type pos))) t.tvoid pos end in let mk_var v used = let v2 = alloc_var v.v_name (PMap.find v.v_id used) in v2.v_meta <- v.v_meta; v2 in let rec wrap used e = match e.eexpr with | TVar (v,ve) -> let v,ve = if PMap.mem v.v_id used then v, Some (impl#mk_ref v (Option.map (wrap used) ve) e.epos) else v, (match ve with None -> None | Some e -> Some (wrap used e)) in { e with eexpr = TVar (v,ve) } | TLocal v when PMap.mem v.v_id used -> impl#mk_ref_access e v | TFor (v,it,expr) when PMap.mem v.v_id used -> let vtmp = mk_var v used in let it = wrap used it in let expr = wrap used expr in mk (TFor (vtmp,it,Type.concat (impl#mk_init v vtmp e.epos) expr)) e.etype e.epos | TTry (expr,catchs) -> let catchs = List.map (fun (v,e) -> let e = wrap used e in try let vtmp = mk_var v used in vtmp, Type.concat (impl#mk_init v vtmp e.epos) e with Not_found -> v, e ) catchs in mk (TTry (wrap used expr,catchs)) e.etype e.epos | TFunction f -> (* list variables that are marked as used, but also used in that function and which are not declared inside it ! *) let fused = ref PMap.empty in let tmp_used = ref used in let rec browse = function | Block f | Loop f | Function f -> f browse | Use v | Assign v -> if PMap.mem v.v_id !tmp_used then fused := PMap.add v.v_id v !fused; | Declare v -> tmp_used := PMap.remove v.v_id !tmp_used in local_usage browse e; let vars = PMap.fold (fun v acc -> v :: acc) !fused [] in (* in case the variable has been marked as used in a parallel scope... *) let fexpr = ref (wrap used f.tf_expr) in let fargs = List.map (fun (v,o) -> if PMap.mem v.v_id used then let vtmp = mk_var v used in fexpr := Type.concat (impl#mk_init v vtmp e.epos) !fexpr; vtmp, o else v, o ) f.tf_args in let e = { e with eexpr = TFunction { f with tf_args = fargs; tf_expr = !fexpr } } in (* Create a new function scope to make sure that the captured loop variable will not be overwritten in next loop iteration *) if com.config.pf_capture_policy = CPLoopVars then mk (TCall ( Codegen.mk_parent (mk (TFunction { tf_args = List.map (fun v -> v, None) vars; tf_type = e.etype; tf_expr = mk_block (mk (TReturn (Some e)) e.etype e.epos); }) (TFun (List.map (fun v -> v.v_name,false,v.v_type) vars,e.etype)) e.epos), List.map (fun v -> mk (TLocal v) v.v_type e.epos) vars) ) e.etype e.epos else e | _ -> map_expr (wrap used) e and do_wrap used e = if PMap.is_empty used then e else let used = PMap.map (fun v -> let vt = v.v_type in v.v_type <- impl#captured_type vt; v.v_capture <- true; vt ) used in wrap used e and out_loop e = match e.eexpr with | TFor _ | TWhile _ -> (* collect variables that are declared in loop but used in subfunctions *) let vars = ref PMap.empty in let used = ref PMap.empty in let depth = ref 0 in let rec collect_vars in_loop = function | Block f -> let old = !vars in f (collect_vars in_loop); vars := old; | Loop f -> let old = !vars in f (collect_vars true); vars := old; | Function f -> incr depth; f (collect_vars false); decr depth; | Declare v -> if in_loop then vars := PMap.add v.v_id !depth !vars; | Use v | Assign v -> try let d = PMap.find v.v_id !vars in if d <> !depth then used := PMap.add v.v_id v !used; with Not_found -> () in local_usage (collect_vars false) e; do_wrap !used e | _ -> map_expr out_loop e and all_vars e = let vars = ref PMap.empty in let used = ref PMap.empty in let assigned = ref PMap.empty in let depth = ref 0 in let rec collect_vars = function | Block f -> let old = !vars in f collect_vars; vars := old; | Loop f -> let old = !vars in f collect_vars; vars := old; | Function f -> incr depth; f collect_vars; decr depth; | Declare v -> vars := PMap.add v.v_id !depth !vars; | Use v -> (try let d = PMap.find v.v_id !vars in if d <> !depth then used := PMap.add v.v_id v !used; with Not_found -> ()) | Assign v -> (try let d = PMap.find v.v_id !vars in (* different depth - needs wrap *) if d <> !depth then begin used := PMap.add v.v_id v !used; assigned := PMap.add v.v_id v !assigned; end (* same depth but assigned after being used on a different depth - needs wrap *) else if PMap.mem v.v_id !used then assigned := PMap.add v.v_id v !assigned; with Not_found -> ()) in local_usage collect_vars e; (* mark all capture variables - also used in rename_local_vars at later stage *) PMap.iter (fun _ v -> v.v_capture <- true) !used; !assigned in let captured = all_vars e in match com.config.pf_capture_policy with | CPNone -> e | CPWrapRef -> do_wrap captured e | CPLoopVars -> out_loop e (* -------------------------------------------------------------------------- *) (* RENAME LOCAL VARS *) let rename_local_vars ctx e = let cfg = ctx.com.config in let all_scope = (not cfg.pf_captured_scope) || (not cfg.pf_locals_scope) in let vars = ref PMap.empty in let all_vars = ref PMap.empty in let vtemp = alloc_var "~" t_dynamic in let rebuild_vars = ref false in let rebuild m = PMap.fold (fun v acc -> PMap.add v.v_name v acc) m PMap.empty in let save() = let old = !vars in if cfg.pf_unique_locals || not cfg.pf_locals_scope then (fun() -> ()) else (fun() -> vars := if !rebuild_vars then rebuild old else old) in let rename vars v = let count = ref 1 in while PMap.mem (v.v_name ^ string_of_int !count) vars do incr count; done; v.v_name <- v.v_name ^ string_of_int !count; in let declare v p = (match follow v.v_type with | TAbstract ({a_path = [],"Void"},_) -> error "Arguments and variables of type Void are not allowed" p | _ -> ()); (* chop escape char for all local variables generated *) if is_gen_local v then v.v_name <- "_g" ^ String.sub v.v_name 1 (String.length v.v_name - 1); let look_vars = (if not cfg.pf_captured_scope && v.v_capture then !all_vars else !vars) in (try let v2 = PMap.find v.v_name look_vars in (* block_vars will create some wrapper-functions that are declaring the same variable twice. In that case do not perform a rename since we are sure it's actually the same variable *) if v == v2 then raise Not_found; rename look_vars v; with Not_found -> ()); vars := PMap.add v.v_name v !vars; if all_scope then all_vars := PMap.add v.v_name v !all_vars; in (* This is quite a rare case, when a local variable would otherwise prevent accessing a type because it masks the type value or the package name. *) let check t = match (t_infos t).mt_path with | [], name | name :: _, _ -> let vars = if cfg.pf_locals_scope then vars else all_vars in (try let v = PMap.find name !vars in if v == vtemp then raise Not_found; (* ignore *) rename (!vars) v; rebuild_vars := true; vars := PMap.add v.v_name v !vars with Not_found -> ()); vars := PMap.add name vtemp !vars in let check_type t = match follow t with | TInst (c,_) -> check (TClassDecl c) | TEnum (e,_) -> check (TEnumDecl e) | TType (t,_) -> check (TTypeDecl t) | TAbstract (a,_) -> check (TAbstractDecl a) | TMono _ | TLazy _ | TAnon _ | TDynamic _ | TFun _ -> () in let rec loop e = match e.eexpr with | TVar (v,eo) -> if not cfg.pf_locals_scope then declare v e.epos; (match eo with None -> () | Some e -> loop e); if cfg.pf_locals_scope then declare v e.epos; | TFunction tf -> let old = save() in List.iter (fun (v,_) -> declare v e.epos) tf.tf_args; loop tf.tf_expr; old() | TBlock el -> let old = save() in (* we have to look ahead for vars on these targets (issue #3344) *) begin match ctx.com.platform with | Js -> let rec check_var e = match e.eexpr with | TVar (v,eo) -> (match eo with None -> () | Some e -> loop e); declare v e.epos | TBlock _ -> () | _ -> Type.iter check_var e in List.iter check_var el | _ -> () end; List.iter loop el; old() | TFor (v,it,e1) -> loop it; let old = save() in declare v e.epos; loop e1; old() | TTry (e,catchs) -> loop e; List.iter (fun (v,e) -> let old = save() in declare v e.epos; check_type v.v_type; loop e; old() ) catchs; | TTypeExpr t -> check t | TNew (c,_,_) -> Type.iter loop e; check (TClassDecl c); | TCast (e,Some t) -> loop e; check t; | TConst TSuper -> check_type e.etype | _ -> Type.iter loop e in declare (alloc_var "this" t_dynamic) Ast.null_pos; (* force renaming of 'this' vars in abstract *) begin match ctx.curclass.cl_path with | s :: _,_ | [],s -> declare (alloc_var s t_dynamic) Ast.null_pos end; loop e; e let check_unification ctx e t = begin match e.eexpr,t with | TLocal v,TType({t_path = ["cs"],("Ref" | "Out")},_) -> (* TODO: this smells of hack, but we have to deal with it somehow *) v.v_capture <- true | _ -> () end; e (* PASS 1 end *) (* Saves a class state so it can be restored later, e.g. after DCE or native path rewrite *) let save_class_state ctx t = match t with | TClassDecl c -> let mk_field_restore f = let rec mk_overload_restore f = f.cf_name,f.cf_kind,f.cf_expr,f.cf_type,f.cf_meta,f.cf_params in ( f,mk_overload_restore f, List.map (fun f -> f,mk_overload_restore f) f.cf_overloads ) in let restore_field (f,res,overloads) = let restore_field (f,(name,kind,expr,t,meta,params)) = f.cf_name <- name; f.cf_kind <- kind; f.cf_expr <- expr; f.cf_type <- t; f.cf_meta <- meta; f.cf_params <- params; f in let f = restore_field (f,res) in f.cf_overloads <- List.map restore_field overloads; f in let mk_pmap lst = List.fold_left (fun pmap f -> PMap.add f.cf_name f pmap) PMap.empty lst in let meta = c.cl_meta and path = c.cl_path and ext = c.cl_extern and over = c.cl_overrides in let sup = c.cl_super and impl = c.cl_implements in let csr = Option.map (mk_field_restore) c.cl_constructor in let ofr = List.map (mk_field_restore) c.cl_ordered_fields in let osr = List.map (mk_field_restore) c.cl_ordered_statics in let init = c.cl_init in c.cl_restore <- (fun() -> c.cl_super <- sup; c.cl_implements <- impl; c.cl_meta <- meta; c.cl_extern <- ext; c.cl_path <- path; c.cl_init <- init; c.cl_ordered_fields <- List.map restore_field ofr; c.cl_ordered_statics <- List.map restore_field osr; c.cl_fields <- mk_pmap c.cl_ordered_fields; c.cl_statics <- mk_pmap c.cl_ordered_statics; c.cl_constructor <- Option.map restore_field csr; c.cl_overrides <- over; ) | _ -> () (* PASS 2 begin *) let rec is_removable_class c = match c.cl_kind with | KGeneric -> (Meta.has Meta.Remove c.cl_meta || (match c.cl_super with | Some (c,_) -> is_removable_class c | _ -> false) || List.exists (fun (_,t) -> match follow t with | TInst(c,_) -> Codegen.has_ctor_constraint c | _ -> false ) c.cl_params) | KTypeParameter _ -> (* this shouldn't happen, have to investigate (see #4092) *) true | _ -> false let remove_generic_base ctx t = match t with | TClassDecl c when is_removable_class c -> c.cl_extern <- true | _ -> () (* Removes extern and macro fields, also checks for Void fields *) let remove_extern_fields ctx t = match t with | TClassDecl c -> if not (Common.defined ctx.com Define.DocGen) then begin c.cl_ordered_fields <- List.filter (fun f -> let b = Codegen.is_removable_field ctx f in if b then c.cl_fields <- PMap.remove f.cf_name c.cl_fields; not b ) c.cl_ordered_fields; c.cl_ordered_statics <- List.filter (fun f -> let b = Codegen.is_removable_field ctx f in if b then c.cl_statics <- PMap.remove f.cf_name c.cl_statics; not b ) c.cl_ordered_statics; end | _ -> () (* PASS 2 end *) (* PASS 3 begin *) (* Checks if a private class' path clashes with another path *) let check_private_path ctx t = match t with | TClassDecl c when c.cl_private -> let rpath = (fst c.cl_module.m_path,"_" ^ snd c.cl_module.m_path) in if Hashtbl.mem ctx.g.types_module rpath then error ("This private class name will clash with " ^ s_type_path rpath) c.cl_pos; | _ -> () (* Rewrites class or enum paths if @:native metadata is set *) let apply_native_paths ctx t = let get_native_name meta = let rec get_native meta = match meta with | [] -> raise Not_found | (Meta.Native,[v],p as meta) :: _ -> meta | _ :: meta -> get_native meta in let (_,e,mp) = get_native meta in match e with | [Ast.EConst (Ast.String name),p] -> name,p | [] -> raise Not_found | _ -> error "String expected" mp in let get_real_name meta name = let name',p = get_native_name meta in (Meta.RealPath,[Ast.EConst (Ast.String (name)), p], p), name' in let get_real_path meta path = let name,p = get_native_name meta in (Meta.RealPath,[Ast.EConst (Ast.String (s_type_path path)), p], p), parse_path name in try (match t with | TClassDecl c -> let did_change = ref false in let field cf = try let meta,name = get_real_name cf.cf_meta cf.cf_name in cf.cf_name <- name; cf.cf_meta <- meta :: cf.cf_meta; List.iter (fun cf -> cf.cf_name <- name) cf.cf_overloads; did_change := true with Not_found -> () in let fields cfs old_map = did_change := false; List.iter field cfs; if !did_change then List.fold_left (fun map f -> PMap.add f.cf_name f map) PMap.empty cfs else old_map in c.cl_fields <- fields c.cl_ordered_fields c.cl_fields; c.cl_statics <- fields c.cl_ordered_statics c.cl_statics; let meta,path = get_real_path c.cl_meta c.cl_path in c.cl_meta <- meta :: c.cl_meta; c.cl_path <- path; | TEnumDecl e -> let meta,path = get_real_path e.e_meta e.e_path in e.e_meta <- meta :: e.e_meta; e.e_path <- path; | TAbstractDecl a -> let meta,path = get_real_path a.a_meta a.a_path in a.a_meta <- meta :: a.a_meta; a.a_path <- path; | _ -> ()) with Not_found -> () (* Adds the __rtti field if required *) let add_rtti ctx t = let rec has_rtti c = Meta.has Meta.Rtti c.cl_meta || match c.cl_super with None -> false | Some (csup,_) -> has_rtti csup in match t with | TClassDecl c when has_rtti c && not (PMap.mem "__rtti" c.cl_statics) -> let f = mk_field "__rtti" ctx.t.tstring c.cl_pos in let str = Genxml.gen_type_string ctx.com t in f.cf_expr <- Some (mk (TConst (TString str)) f.cf_type c.cl_pos); c.cl_ordered_statics <- f :: c.cl_ordered_statics; c.cl_statics <- PMap.add f.cf_name f c.cl_statics; | _ -> () (* Adds member field initializations as assignments to the constructor *) let add_field_inits ctx t = let is_as3 = Common.defined ctx.com Define.As3 && not ctx.in_macro in let apply c = let ethis = mk (TConst TThis) (TInst (c,List.map snd c.cl_params)) c.cl_pos in (* TODO: we have to find a variable name which is not used in any of the functions *) let v = alloc_var "_g" ethis.etype in let need_this = ref false in let inits,fields = List.fold_left (fun (inits,fields) cf -> match cf.cf_kind,cf.cf_expr with | Var _, Some _ -> if is_as3 then (inits, cf :: fields) else (cf :: inits, cf :: fields) | Method MethDynamic, Some e when is_as3 -> (* TODO : this would have a better place in genSWF9 I think - NC *) (* we move the initialization of dynamic functions to the constructor and also solve the 'this' problem along the way *) let rec use_this v e = match e.eexpr with | TConst TThis -> need_this := true; mk (TLocal v) v.v_type e.epos | _ -> Type.map_expr (use_this v) e in let e = Type.map_expr (use_this v) e in let cf2 = {cf with cf_expr = Some e} in (* if the method is an override, we have to remove the class field to not get invalid overrides *) let fields = if List.memq cf c.cl_overrides then begin c.cl_fields <- PMap.remove cf.cf_name c.cl_fields; fields end else cf2 :: fields in (cf2 :: inits, fields) | _ -> (inits, cf :: fields) ) ([],[]) c.cl_ordered_fields in c.cl_ordered_fields <- (List.rev fields); match inits with | [] -> () | _ -> let el = List.map (fun cf -> match cf.cf_expr with | None -> assert false | Some e -> let lhs = mk (TField(ethis,FInstance (c,List.map snd c.cl_params,cf))) cf.cf_type e.epos in cf.cf_expr <- None; let eassign = mk (TBinop(OpAssign,lhs,e)) e.etype e.epos in if is_as3 then begin let echeck = mk (TBinop(OpEq,lhs,(mk (TConst TNull) lhs.etype e.epos))) ctx.com.basic.tbool e.epos in mk (TIf(echeck,eassign,None)) eassign.etype e.epos end else eassign; ) inits in let el = if !need_this then (mk (TVar((v, Some ethis))) ethis.etype ethis.epos) :: el else el in match c.cl_constructor with | None -> let ct = TFun([],ctx.com.basic.tvoid) in let ce = mk (TFunction { tf_args = []; tf_type = ctx.com.basic.tvoid; tf_expr = mk (TBlock el) ctx.com.basic.tvoid c.cl_pos; }) ct c.cl_pos in let ctor = mk_field "new" ct c.cl_pos in ctor.cf_kind <- Method MethNormal; c.cl_constructor <- Some { ctor with cf_expr = Some ce }; | Some cf -> match cf.cf_expr with | Some { eexpr = TFunction f } -> let bl = match f.tf_expr with {eexpr = TBlock b } -> b | x -> [x] in let ce = mk (TFunction {f with tf_expr = mk (TBlock (el @ bl)) ctx.com.basic.tvoid c.cl_pos }) cf.cf_type cf.cf_pos in c.cl_constructor <- Some {cf with cf_expr = Some ce } | _ -> assert false in match t with | TClassDecl c -> apply c | _ -> () (* Adds the __meta__ field if required *) let add_meta_field ctx t = match t with | TClassDecl c -> (match Codegen.build_metadata ctx.com t with | None -> () | Some e -> let f = mk_field "__meta__" t_dynamic c.cl_pos in f.cf_expr <- Some e; c.cl_ordered_statics <- f :: c.cl_ordered_statics; c.cl_statics <- PMap.add f.cf_name f c.cl_statics) | _ -> () (* Removes interfaces tagged with @:remove metadata *) let check_remove_metadata ctx t = match t with | TClassDecl c -> c.cl_implements <- List.filter (fun (c,_) -> not (Meta.has Meta.Remove c.cl_meta)) c.cl_implements; | _ -> () (* Checks for Void class fields *) let check_void_field ctx t = match t with | TClassDecl c -> let check f = match follow f.cf_type with TAbstract({a_path=[],"Void"},_) -> error "Fields of type Void are not allowed" f.cf_pos | _ -> (); in List.iter check c.cl_ordered_fields; List.iter check c.cl_ordered_statics; | _ -> () (* Interfaces have no 'super', but can extend many other interfaces. This makes the first extended (implemented) interface the super for efficiency reasons (you can get one for 'free') and leaves the remaining ones as 'implemented' *) let promote_first_interface_to_super ctx t = match t with | TClassDecl c when c.cl_interface -> begin match c.cl_implements with | ({ cl_path = ["cpp";"rtti"],_ },_ ) :: _ -> () | first_interface :: remaining -> c.cl_super <- Some first_interface; c.cl_implements <- remaining | _ -> () end | _ -> () let commit_features ctx t = let m = (t_infos t).mt_module in Hashtbl.iter (fun k v -> Common.add_feature ctx.com k; ) m.m_extra.m_features let check_reserved_type_paths ctx t = let check path pos = if List.mem path ctx.com.config.pf_reserved_type_paths then ctx.com.warning ("Type path " ^ (s_type_path path) ^ " is reserved on this target") pos in match t with | TClassDecl c when not c.cl_extern -> check c.cl_path c.cl_pos | TEnumDecl e when not e.e_extern -> check e.e_path e.e_pos | _ -> () (* PASS 3 end *) let run_expression_filters ctx filters t = let run e = List.fold_left (fun e f -> f e) e filters in match t with | TClassDecl c when is_removable_class c -> () | TClassDecl c -> ctx.curclass <- c; let rec process_field f = (match f.cf_expr with | Some e when not (Codegen.is_removable_field ctx f) -> Codegen.AbstractCast.cast_stack := f :: !Codegen.AbstractCast.cast_stack; f.cf_expr <- Some (run e); Codegen.AbstractCast.cast_stack := List.tl !Codegen.AbstractCast.cast_stack; | _ -> ()); List.iter process_field f.cf_overloads in List.iter process_field c.cl_ordered_fields; List.iter process_field c.cl_ordered_statics; (match c.cl_constructor with | None -> () | Some f -> process_field f); (match c.cl_init with | None -> () | Some e -> c.cl_init <- Some (run e)); | TEnumDecl _ -> () | TTypeDecl _ -> () | TAbstractDecl _ -> () let pp_counter = ref 1 let is_cached t = let m = (t_infos t).mt_module.m_extra in if m.m_processed = 0 then m.m_processed <- !pp_counter; m.m_processed <> !pp_counter let apply_filters_once ctx filters t = if not (is_cached t) then run_expression_filters ctx filters t let next_compilation() = incr pp_counter let iter_expressions fl mt = match mt with | TClassDecl c -> let field cf = match cf.cf_expr with | None -> () | Some e -> List.iter (fun f -> f e) fl in List.iter field c.cl_ordered_statics; List.iter field c.cl_ordered_fields; (match c.cl_constructor with None -> () | Some cf -> field cf) | _ -> () let run com tctx main = begin match com.display with | DMUsage | DMPosition -> Codegen.detect_usage com; | _ -> () end; if not (Common.defined com Define.NoDeprecationWarnings) then Codegen.DeprecationCheck.run com; let use_static_analyzer = Common.defined com Define.Analyzer in (* this part will be a bit messy until we make the analyzer the default *) let new_types = List.filter (fun t -> not (is_cached t)) com.types in if use_static_analyzer then begin (* PASS 1: general expression filters *) let filters = [ Codegen.UnificationCallback.run (check_unification tctx); Codegen.AbstractCast.handle_abstract_casts tctx; Optimizer.inline_constructors tctx; Optimizer.reduce_expression tctx; blockify_ast; captured_vars com; ] in List.iter (run_expression_filters tctx filters) new_types; Analyzer.Run.run_on_types tctx new_types; List.iter (iter_expressions [verify_ast]) new_types; let filters = [ Optimizer.sanitize com; if com.config.pf_add_final_return then add_final_return else (fun e -> e); if com.platform = Js then wrap_js_exceptions com else (fun e -> e); rename_local_vars tctx; ] in List.iter (run_expression_filters tctx filters) new_types; end else begin (* PASS 1: general expression filters *) let filters = [ Codegen.UnificationCallback.run (check_unification tctx); Codegen.AbstractCast.handle_abstract_casts tctx; blockify_ast; check_local_vars_init; ( if (Common.defined com Define.NoSimplify) || (Common.defined com Define.Cppia) || ( match com.platform with Cpp -> false | _ -> true ) then fun e -> e else fun e -> let save = save_locals tctx in let timer = timer "analyzer-simplify-apply" in let e = try snd (Analyzer.Simplifier.apply com e) with Exit -> e in timer(); save(); e ); if com.foptimize then (fun e -> Optimizer.reduce_expression tctx (Optimizer.inline_constructors tctx e)) else Optimizer.sanitize com; captured_vars com; promote_complex_rhs com; if com.config.pf_add_final_return then add_final_return else (fun e -> e); if com.platform = Js then wrap_js_exceptions com else (fun e -> e); rename_local_vars tctx; ] in List.iter (run_expression_filters tctx filters) new_types; List.iter (iter_expressions [verify_ast]) new_types; end; next_compilation(); List.iter (fun f -> f()) (List.rev com.filters); (* macros onGenerate etc. *) List.iter (save_class_state tctx) new_types; List.iter (fun t -> remove_generic_base tctx t; remove_extern_fields tctx t; ) com.types; (* update cache dependencies before DCE is run *) Codegen.update_cache_dependencies com; (* check @:remove metadata before DCE so it is ignored there (issue #2923) *) List.iter (check_remove_metadata tctx) com.types; (* DCE *) let dce_mode = if Common.defined com Define.As3 then "no" else (try Common.defined_value com Define.Dce with _ -> "no") in begin match dce_mode with | "full" -> Dce.run com main (not (Common.defined com Define.Interp)) | "std" -> Dce.run com main false | "no" -> Dce.fix_accessors com | _ -> failwith ("Unknown DCE mode " ^ dce_mode) end; (* always filter empty abstract implementation classes (issue #1885) *) List.iter (fun mt -> match mt with | TClassDecl({cl_kind = KAbstractImpl _} as c) when c.cl_ordered_statics = [] && c.cl_ordered_fields = [] && not (Meta.has Meta.Used c.cl_meta) -> c.cl_extern <- true | TClassDecl({cl_kind = KAbstractImpl a} as c) when Meta.has Meta.Enum a.a_meta -> let is_runtime_field cf = not (Meta.has Meta.Enum cf.cf_meta) in (* also filter abstract implementation classes that have only @:enum fields (issue #2858) *) if not (List.exists is_runtime_field c.cl_ordered_statics) then c.cl_extern <- true | _ -> () ) com.types; (* PASS 3: type filters *) let type_filters = [ check_private_path; apply_native_paths; add_rtti; (match com.platform with | Java | Cs -> (fun _ _ -> ()) | _ -> add_field_inits); add_meta_field; check_void_field; (match com.platform with | Cpp -> promote_first_interface_to_super | _ -> (fun _ _ -> ()) ); commit_features; (if com.config.pf_reserved_type_paths <> [] then check_reserved_type_paths else (fun _ _ -> ())); ] in List.iter (fun t -> List.iter (fun f -> f tctx t) type_filters) com.types haxe_3.2.1+dfsg.orig/genas3.ml0000664000175000017500000010565312607337712016050 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Type open Common type context_infos = { com : Common.context; } type context = { inf : context_infos; ch : out_channel; buf : Buffer.t; path : path; mutable get_sets : (string * bool,string) Hashtbl.t; mutable curclass : tclass; mutable tabs : string; mutable in_value : tvar option; mutable in_static : bool; mutable handle_break : bool; mutable imports : (string,string list list) Hashtbl.t; mutable gen_uid : int; mutable local_types : t list; mutable constructor_block : bool; mutable block_inits : (unit -> unit) option; } let follow = Abstract.follow_with_abstracts let is_var_field f = match f with | FStatic (_,f) | FInstance (_,_,f) -> (match f.cf_kind with Var _ | Method MethDynamic -> true | _ -> false) | _ -> false let is_special_compare e1 e2 = match e1.eexpr, e2.eexpr with | TConst TNull, _ | _ , TConst TNull -> None | _ -> match follow e1.etype, follow e2.etype with | TInst ({ cl_path = ["flash"],"NativeXml" } as c,_) , _ | _ , TInst ({ cl_path = ["flash"],"NativeXml" } as c,_) -> Some c | _ -> None let protect name = match name with | "Error" | "Namespace" -> "_" ^ name | _ -> name let s_path ctx stat path p = match path with | ([],name) -> (match name with | "Int" -> "int" | "Float" -> "Number" | "Dynamic" -> "Object" | "Bool" -> "Boolean" | "Enum" -> "Class" | "EnumValue" -> "enum" | _ -> name) | (["flash"],"FlashXml__") -> "Xml" | (["flash";"errors"],"Error") -> "Error" | (["flash"],"Vector") -> "Vector" | (["flash";"xml"],"XML") -> "XML" | (["flash";"xml"],"XMLList") -> "XMLList" | ["flash";"utils"],"QName" -> "QName" | ["flash";"utils"],"Namespace" -> "Namespace" | (["haxe"],"Int32") when not stat -> "int" | (pack,name) -> let name = protect name in let packs = (try Hashtbl.find ctx.imports name with Not_found -> []) in if not (List.mem pack packs) then Hashtbl.replace ctx.imports name (pack :: packs); Ast.s_type_path (pack,name) let reserved = let h = Hashtbl.create 0 in List.iter (fun l -> Hashtbl.add h l ()) (* these ones are defined in order to prevent recursion in some Std functions *) ["is";"as";"int";"uint";"const";"getTimer";"typeof";"parseInt";"parseFloat"; (* AS3 keywords which are not Haxe ones *) "finally";"with";"final";"internal";"native";"namespace";"include";"delete"; (* some globals give some errors with Flex SDK as well *) "print";"trace"; (* we don't include get+set since they are not 'real' keywords, but they can't be used as method names *) "function";"class";"var";"if";"else";"while";"do";"for";"break";"continue";"return";"extends";"implements"; "import";"switch";"case";"default";"static";"public";"private";"try";"catch";"new";"this";"throw";"interface"; "override";"package";"null";"true";"false";"void" ]; h (* "each", "label" : removed (actually allowed in locals and fields accesses) *) let s_ident n = if Hashtbl.mem reserved n then "_" ^ n else n let valid_as3_ident s = try for i = 0 to String.length s - 1 do match String.unsafe_get s i with | 'a'..'z' | 'A'..'Z' | '$' | '_' -> () | '0'..'9' when i > 0 -> () | _ -> raise Exit done; true with Exit -> false let anon_field s = let s = s_ident s in if not (valid_as3_ident s) then "\"" ^ s ^ "\"" else s let rec create_dir acc = function | [] -> () | d :: l -> let dir = String.concat "/" (List.rev (d :: acc)) in if not (Sys.file_exists dir) then Unix.mkdir dir 0o755; create_dir (d :: acc) l let init infos path = let dir = infos.com.file :: fst path in create_dir [] dir; let ch = open_out (String.concat "/" dir ^ "/" ^ snd path ^ ".as") in let imports = Hashtbl.create 0 in Hashtbl.add imports (snd path) [fst path]; { inf = infos; tabs = ""; ch = ch; path = path; buf = Buffer.create (1 lsl 14); in_value = None; in_static = false; handle_break = false; imports = imports; curclass = null_class; gen_uid = 0; local_types = []; get_sets = Hashtbl.create 0; constructor_block = false; block_inits = None; } let close ctx = begin match ctx.inf.com.main_class with | Some tp when tp = ctx.curclass.cl_path -> output_string ctx.ch "// Compile __main__.as instead\n"; | _ -> () end; output_string ctx.ch (Printf.sprintf "package %s {\n" (String.concat "." (fst ctx.path))); Hashtbl.iter (fun name paths -> List.iter (fun pack -> let path = pack, name in if path <> ctx.path then output_string ctx.ch ("\timport " ^ Ast.s_type_path path ^ ";\n"); ) paths ) ctx.imports; output_string ctx.ch (Buffer.contents ctx.buf); close_out ctx.ch let gen_local ctx l = ctx.gen_uid <- ctx.gen_uid + 1; if ctx.gen_uid = 1 then l else l ^ string_of_int ctx.gen_uid let spr ctx s = Buffer.add_string ctx.buf s let print ctx = Printf.kprintf (fun s -> Buffer.add_string ctx.buf s) let unsupported p = error "This expression cannot be generated to AS3" p let newline ctx = let rec loop p = match Buffer.nth ctx.buf p with | '}' | '{' | ':' | ';' -> print ctx "\n%s" ctx.tabs | '\n' | '\t' -> loop (p - 1) | _ -> print ctx ";\n%s" ctx.tabs in loop (Buffer.length ctx.buf - 1) let block_newline ctx = match Buffer.nth ctx.buf (Buffer.length ctx.buf - 1) with | '}' -> print ctx ";\n%s" ctx.tabs | _ -> newline ctx let rec concat ctx s f = function | [] -> () | [x] -> f x | x :: l -> f x; spr ctx s; concat ctx s f l let open_block ctx = let oldt = ctx.tabs in ctx.tabs <- "\t" ^ ctx.tabs; (fun() -> ctx.tabs <- oldt) let parent e = match e.eexpr with | TParenthesis _ -> e | _ -> mk (TParenthesis e) e.etype e.epos let default_value tstr = match tstr with | "int" | "uint" -> "0" | "Number" -> "NaN" | "Boolean" -> "false" | _ -> "null" let rec type_str ctx t p = match t with | TEnum _ | TInst _ when List.memq t ctx.local_types -> "*" | TAbstract (a,pl) when not (Ast.Meta.has Ast.Meta.CoreType a.a_meta) -> type_str ctx (Abstract.get_underlying_type a pl) p | TAbstract (a,_) -> (match a.a_path with | [], "Void" -> "void" | [], "UInt" -> "uint" | [], "Int" -> "int" | [], "Float" -> "Number" | [], "Bool" -> "Boolean" | _ -> s_path ctx true a.a_path p) | TEnum (e,_) -> if e.e_extern then (match e.e_path with | [], "Void" -> "void" | [], "Bool" -> "Boolean" | _ -> let rec loop = function | [] -> "Object" | (Ast.Meta.FakeEnum,[Ast.EConst (Ast.Ident n),_],_) :: _ -> (match n with | "Int" -> "int" | "UInt" -> "uint" | _ -> n) | _ :: l -> loop l in loop e.e_meta ) else s_path ctx true e.e_path p | TInst ({ cl_path = ["flash"],"Vector" },[pt]) -> (match pt with | TInst({cl_kind = KTypeParameter _},_) -> "*" | _ -> "Vector.<" ^ type_str ctx pt p ^ ">") | TInst (c,_) -> (match c.cl_kind with | KNormal | KGeneric | KGenericInstance _ | KAbstractImpl _ -> s_path ctx false c.cl_path p | KTypeParameter _ | KExtension _ | KExpr _ | KMacroType | KGenericBuild _ -> "*") | TFun _ -> "Function" | TMono r -> (match !r with None -> "*" | Some t -> type_str ctx t p) | TAnon _ | TDynamic _ -> "*" | TType (t,args) -> (match t.t_path with | [], "UInt" -> "uint" | [] , "Null" -> (match args with | [t] -> (match follow t with | TAbstract ({ a_path = [],"UInt" },_) | TAbstract ({ a_path = [],"Int" },_) | TAbstract ({ a_path = [],"Float" },_) | TAbstract ({ a_path = [],"Bool" },_) | TInst ({ cl_path = [],"Int" },_) | TInst ({ cl_path = [],"Float" },_) | TEnum ({ e_path = [],"Bool" },_) -> "*" | _ -> type_str ctx t p) | _ -> assert false); | _ -> type_str ctx (apply_params t.t_params args t.t_type) p) | TLazy f -> type_str ctx ((!f)()) p let rec iter_switch_break in_switch e = match e.eexpr with | TFunction _ | TWhile _ | TFor _ -> () | TSwitch _ when not in_switch -> iter_switch_break true e | TBreak when in_switch -> raise Exit | _ -> iter (iter_switch_break in_switch) e let handle_break ctx e = let old_handle = ctx.handle_break in try iter_switch_break false e; ctx.handle_break <- false; (fun() -> ctx.handle_break <- old_handle) with Exit -> spr ctx "try {"; let b = open_block ctx in newline ctx; ctx.handle_break <- true; (fun() -> b(); ctx.handle_break <- old_handle; newline ctx; spr ctx "} catch( e : * ) { if( e != \"__break__\" ) throw e; }"; ) let this ctx = if ctx.in_value <> None then "$this" else "this" let generate_resources infos = if Hashtbl.length infos.com.resources <> 0 then begin let dir = (infos.com.file :: ["__res"]) in create_dir [] dir; let add_resource name data = let name = Base64.str_encode name in let ch = open_out_bin (String.concat "/" (dir @ [name])) in output_string ch data; close_out ch in Hashtbl.iter (fun name data -> add_resource name data) infos.com.resources; let ctx = init infos ([],"__resources__") in spr ctx "\timport flash.utils.Dictionary;\n"; spr ctx "\tpublic class __resources__ {\n"; spr ctx "\t\tpublic static var list:Dictionary;\n"; let inits = ref [] in let k = ref 0 in Hashtbl.iter (fun name _ -> let varname = ("v" ^ (string_of_int !k)) in k := !k + 1; print ctx "\t\t[Embed(source = \"__res/%s\", mimeType = \"application/octet-stream\")]\n" (Base64.str_encode name); print ctx "\t\tpublic static var %s:Class;\n" varname; inits := ("list[\"" ^ Ast.s_escape name ^ "\"] = " ^ varname ^ ";") :: !inits; ) infos.com.resources; spr ctx "\t\tstatic public function __init__():void {\n"; spr ctx "\t\t\tlist = new Dictionary();\n"; List.iter (fun init -> print ctx "\t\t\t%s\n" init ) !inits; spr ctx "\t\t}\n"; spr ctx "\t}\n"; spr ctx "}"; close ctx; end let gen_constant ctx p = function | TInt i -> print ctx "%ld" i | TFloat s -> spr ctx s | TString s -> print ctx "\"%s\"" (Ast.s_escape s) | TBool b -> spr ctx (if b then "true" else "false") | TNull -> spr ctx "null" | TThis -> spr ctx (this ctx) | TSuper -> spr ctx "super" let gen_function_header ctx name f params p = let old = ctx.in_value in let old_t = ctx.local_types in let old_bi = ctx.block_inits in ctx.in_value <- None; ctx.local_types <- List.map snd params @ ctx.local_types; let init () = List.iter (fun (v,o) -> match o with | Some c when is_nullable v.v_type && c <> TNull -> newline ctx; print ctx "if(%s==null) %s=" v.v_name v.v_name; gen_constant ctx p c; | _ -> () ) f.tf_args; ctx.block_inits <- None; in ctx.block_inits <- Some init; print ctx "function%s(" (match name with None -> "" | Some (n,meta) -> let rec loop = function | [] -> n | (Ast.Meta.Getter,[Ast.EConst (Ast.Ident i),_],_) :: _ -> "get " ^ i | (Ast.Meta.Setter,[Ast.EConst (Ast.Ident i),_],_) :: _ -> "set " ^ i | _ :: l -> loop l in " " ^ loop meta ); concat ctx "," (fun (v,c) -> match v.v_name with | "__arguments__" -> print ctx "...__arguments__" | _ -> let tstr = type_str ctx v.v_type p in print ctx "%s : %s" (s_ident v.v_name) tstr; match c with | None -> if ctx.constructor_block then print ctx " = %s" (default_value tstr); | Some c -> spr ctx " = "; gen_constant ctx p c ) f.tf_args; print ctx ") : %s " (type_str ctx f.tf_type p); (fun () -> ctx.in_value <- old; ctx.local_types <- old_t; ctx.block_inits <- old_bi; ) let rec gen_call ctx e el r = match e.eexpr , el with | TCall (x,_) , el -> spr ctx "("; gen_value ctx e; spr ctx ")"; spr ctx "("; concat ctx "," (gen_value ctx) el; spr ctx ")"; | TLocal { v_name = "__is__" } , [e1;e2] -> gen_value ctx e1; spr ctx " is "; gen_value ctx e2; | TLocal { v_name = "__in__" } , [e1;e2] -> spr ctx "("; gen_value ctx e1; spr ctx " in "; gen_value ctx e2; spr ctx ")" | TLocal { v_name = "__as__" }, [e1;e2] -> gen_value ctx e1; spr ctx " as "; gen_value ctx e2; | TLocal { v_name = "__int__" }, [e] -> spr ctx "int("; gen_value ctx e; spr ctx ")"; | TLocal { v_name = "__float__" }, [e] -> spr ctx "Number("; gen_value ctx e; spr ctx ")"; | TLocal { v_name = "__typeof__" }, [e] -> spr ctx "typeof "; gen_value ctx e; | TLocal { v_name = "__keys__" }, [e] -> let ret = (match ctx.in_value with None -> assert false | Some r -> r) in print ctx "%s = new Array()" ret.v_name; newline ctx; let tmp = gen_local ctx "$k" in print ctx "for(var %s : String in " tmp; gen_value ctx e; print ctx ") %s.push(%s)" ret.v_name tmp; | TLocal { v_name = "__hkeys__" }, [e] -> let ret = (match ctx.in_value with None -> assert false | Some r -> r) in print ctx "%s = new Array()" ret.v_name; newline ctx; let tmp = gen_local ctx "$k" in print ctx "for(var %s : String in " tmp; gen_value ctx e; print ctx ") %s.push(%s.substr(1))" ret.v_name tmp; | TLocal { v_name = "__foreach__" }, [e] -> let ret = (match ctx.in_value with None -> assert false | Some r -> r) in print ctx "%s = new Array()" ret.v_name; newline ctx; let tmp = gen_local ctx "$k" in print ctx "for each(var %s : * in " tmp; gen_value ctx e; print ctx ") %s.push(%s)" ret.v_name tmp; | TLocal { v_name = "__new__" }, e :: args -> spr ctx "new "; gen_value ctx e; spr ctx "("; concat ctx "," (gen_value ctx) args; spr ctx ")"; | TLocal { v_name = "__delete__" }, [e;f] -> spr ctx "delete("; gen_value ctx e; spr ctx "["; gen_value ctx f; spr ctx "]"; spr ctx ")"; | TLocal { v_name = "__unprotect__" }, [e] -> gen_value ctx e | TLocal { v_name = "__vector__" }, [e] -> spr ctx (type_str ctx r e.epos); spr ctx "("; gen_value ctx e; spr ctx ")" | TField (_, FStatic( { cl_path = (["flash"],"Lib") }, { cf_name = "as" })), [e1;e2] -> gen_value ctx e1; spr ctx " as "; gen_value ctx e2 | TField (_, FStatic ({ cl_path = (["flash"],"Vector") }, cf)), args -> (match cf.cf_name, args with | "ofArray", [e] | "convert", [e] -> (match follow r with | TInst ({ cl_path = (["flash"],"Vector") },[t]) -> print ctx "Vector.<%s>(" (type_str ctx t e.epos); gen_value ctx e; print ctx ")"; | _ -> assert false) | _ -> assert false) | TField(e1, (FAnon {cf_name = s} | FDynamic s)),[ef] when s = "map" || s = "filter" -> spr ctx (s_path ctx true (["flash";],"Boot") e.epos); gen_field_access ctx t_dynamic (s ^ "Dynamic"); spr ctx "("; concat ctx "," (gen_value ctx) [e1;ef]; spr ctx ")" | TField (ee,f), args when is_var_field f -> spr ctx "("; gen_value ctx e; spr ctx ")"; spr ctx "("; concat ctx "," (gen_value ctx) el; spr ctx ")" | _ -> gen_value ctx e; spr ctx "("; concat ctx "," (gen_value ctx) el; spr ctx ")" and gen_value_op ctx e = match e.eexpr with | TBinop (op,_,_) when op = Ast.OpAnd || op = Ast.OpOr || op = Ast.OpXor -> spr ctx "("; gen_value ctx e; spr ctx ")"; | _ -> gen_value ctx e and gen_field_access ctx t s = let field c = match fst c.cl_path, snd c.cl_path, s with | [], "Math", "NaN" | [], "Math", "NEGATIVE_INFINITY" | [], "Math", "POSITIVE_INFINITY" | [], "Math", "isFinite" | [], "Math", "isNaN" | [], "Date", "now" | [], "Date", "fromTime" | [], "Date", "fromString" -> print ctx "[\"%s\"]" s | [], "String", "charCodeAt" -> spr ctx "[\"charCodeAtHX\"]" | [], "Array", "map" -> spr ctx "[\"mapHX\"]" | [], "Array", "filter" -> spr ctx "[\"filterHX\"]" | [], "Date", "toString" -> print ctx "[\"toStringHX\"]" | [], "String", "cca" -> print ctx ".charCodeAt" | ["flash";"xml"], "XML", "namespace" -> print ctx ".namespace" | _ -> print ctx ".%s" (s_ident s) in match follow t with | TInst (c,_) -> field c | TAnon a -> (match !(a.a_status) with | Statics c -> field c | _ -> print ctx ".%s" (s_ident s)) | _ -> print ctx ".%s" (s_ident s) and gen_expr ctx e = match e.eexpr with | TConst c -> gen_constant ctx e.epos c | TLocal v -> spr ctx (s_ident v.v_name) | TArray ({ eexpr = TLocal { v_name = "__global__" } },{ eexpr = TConst (TString s) }) -> let path = Ast.parse_path s in spr ctx (s_path ctx false path e.epos) | TArray (e1,e2) -> gen_value ctx e1; spr ctx "["; gen_value ctx e2; spr ctx "]"; | TBinop (Ast.OpEq,e1,e2) when (match is_special_compare e1 e2 with Some c -> true | None -> false) -> let c = match is_special_compare e1 e2 with Some c -> c | None -> assert false in gen_expr ctx (mk (TCall (mk (TField (mk (TTypeExpr (TClassDecl c)) t_dynamic e.epos,FDynamic "compare")) t_dynamic e.epos,[e1;e2])) ctx.inf.com.basic.tbool e.epos); (* what is this used for? *) (* | TBinop (op,{ eexpr = TField (e1,s) },e2) -> gen_value_op ctx e1; gen_field_access ctx e1.etype s; print ctx " %s " (Ast.s_binop op); gen_value_op ctx e2; *) (* assignments to variable or dynamic methods fields on interfaces are generated as class["field"] = value *) | TBinop (op,{eexpr = TField (ei, FInstance({cl_interface = true},_,{cf_kind = (Method MethDynamic | Var _); cf_name = s}))},e2) -> gen_value ctx ei; print ctx "[\"%s\"]" s; print ctx " %s " (Ast.s_binop op); gen_value_op ctx e2; | TBinop (op,e1,e2) -> gen_value_op ctx e1; print ctx " %s " (Ast.s_binop op); gen_value_op ctx e2; (* variable fields and dynamic methods on interfaces are generated as (class["field"] as class) *) | TField (ei, FInstance({cl_interface = true},_,{cf_kind = (Method MethDynamic | Var _); cf_name = s})) -> spr ctx "("; gen_value ctx ei; print ctx "[\"%s\"]" s; print ctx " as %s)" (type_str ctx e.etype e.epos); | TField({eexpr = TArrayDecl _} as e1,s) -> spr ctx "("; gen_expr ctx e1; spr ctx ")"; gen_field_access ctx e1.etype (field_name s) | TEnumParameter (e,_,i) -> gen_value ctx e; print ctx ".params[%i]" i; | TField (e,s) -> gen_value ctx e; gen_field_access ctx e.etype (field_name s) | TTypeExpr t -> spr ctx (s_path ctx true (t_path t) e.epos) | TParenthesis e -> spr ctx "("; gen_value ctx e; spr ctx ")"; | TMeta (_,e) -> gen_expr ctx e | TReturn eo -> if ctx.in_value <> None then unsupported e.epos; (match eo with | None -> spr ctx "return" | Some e when (match follow e.etype with TEnum({ e_path = [],"Void" },[]) | TAbstract ({ a_path = [],"Void" },[]) -> true | _ -> false) -> print ctx "{"; let bend = open_block ctx in newline ctx; gen_value ctx e; newline ctx; spr ctx "return"; bend(); newline ctx; print ctx "}"; | Some e -> spr ctx "return "; gen_value ctx e); | TBreak -> if ctx.in_value <> None then unsupported e.epos; if ctx.handle_break then spr ctx "throw \"__break__\"" else spr ctx "break" | TContinue -> if ctx.in_value <> None then unsupported e.epos; spr ctx "continue" | TBlock el -> print ctx "{"; let bend = open_block ctx in let cb = (if not ctx.constructor_block then (fun () -> ()) else if not (Codegen.constructor_side_effects e) then begin ctx.constructor_block <- false; (fun () -> ()) end else begin ctx.constructor_block <- false; print ctx " if( !%s.skip_constructor ) {" (s_path ctx true (["flash"],"Boot") e.epos); (fun() -> print ctx "}") end) in (match ctx.block_inits with None -> () | Some i -> i()); List.iter (fun e -> gen_block_element ctx e) el; bend(); newline ctx; cb(); print ctx "}"; | TFunction f -> let h = gen_function_header ctx None f [] e.epos in let old = ctx.in_static in ctx.in_static <- true; gen_expr ctx f.tf_expr; ctx.in_static <- old; h(); | TCall (v,el) -> gen_call ctx v el e.etype | TArrayDecl el -> spr ctx "["; concat ctx "," (gen_value ctx) el; spr ctx "]" | TThrow e -> spr ctx "throw "; gen_value ctx e; | TVar (v,eo) -> spr ctx "var "; print ctx "%s : %s" (s_ident v.v_name) (type_str ctx v.v_type e.epos); begin match eo with | None -> () | Some e -> spr ctx " = "; gen_value ctx e end | TNew (c,params,el) -> (match c.cl_path, params with | (["flash"],"Vector"), [pt] -> print ctx "new Vector.<%s>(" (type_str ctx pt e.epos) | _ -> print ctx "new %s(" (s_path ctx true c.cl_path e.epos)); concat ctx "," (gen_value ctx) el; spr ctx ")" | TIf (cond,e,eelse) -> spr ctx "if"; gen_value ctx (parent cond); spr ctx " "; gen_expr ctx e; (match eelse with | None -> () | Some e -> newline ctx; spr ctx "else "; gen_expr ctx e); | TUnop (op,Ast.Prefix,e) -> spr ctx (Ast.s_unop op); gen_value ctx e | TUnop (op,Ast.Postfix,e) -> gen_value ctx e; spr ctx (Ast.s_unop op) | TWhile (cond,e,Ast.NormalWhile) -> let handle_break = handle_break ctx e in spr ctx "while"; gen_value ctx (parent cond); spr ctx " "; gen_expr ctx e; handle_break(); | TWhile (cond,e,Ast.DoWhile) -> let handle_break = handle_break ctx e in spr ctx "do "; gen_expr ctx e; spr ctx " while"; gen_value ctx (parent cond); handle_break(); | TObjectDecl fields -> spr ctx "{ "; concat ctx ", " (fun (f,e) -> print ctx "%s : " (anon_field f); gen_value ctx e) fields; spr ctx "}" | TFor (v,it,e) -> let handle_break = handle_break ctx e in let tmp = gen_local ctx "$it" in print ctx "{ var %s : * = " tmp; gen_value ctx it; newline ctx; print ctx "while( %s.hasNext() ) { var %s : %s = %s.next()" tmp (s_ident v.v_name) (type_str ctx v.v_type e.epos) tmp; newline ctx; gen_expr ctx e; newline ctx; spr ctx "}}"; handle_break(); | TTry (e,catchs) -> spr ctx "try "; gen_expr ctx e; List.iter (fun (v,e) -> newline ctx; print ctx "catch( %s : %s )" (s_ident v.v_name) (type_str ctx v.v_type e.epos); gen_expr ctx e; ) catchs; | TSwitch (e,cases,def) -> spr ctx "switch"; gen_value ctx (parent e); spr ctx " {"; newline ctx; List.iter (fun (el,e2) -> List.iter (fun e -> spr ctx "case "; gen_value ctx e; spr ctx ":"; ) el; gen_block ctx e2; print ctx "break"; newline ctx; ) cases; (match def with | None -> () | Some e -> spr ctx "default:"; gen_block ctx e; print ctx "break"; newline ctx; ); spr ctx "}" | TCast (e1,None) -> let s = type_str ctx e.etype e.epos in if s = "*" then gen_expr ctx e1 else begin spr ctx "(("; gen_value ctx e1; print ctx ") as %s)" s end | TCast (e1,Some t) -> gen_expr ctx (Codegen.default_cast ctx.inf.com e1 t e.etype e.epos) and gen_block_element ctx e = match e.eexpr with | TObjectDecl fl -> List.iter (fun (_,e) -> gen_block_element ctx e) fl | _ -> block_newline ctx; gen_expr ctx e and gen_block ctx e = newline ctx; match e.eexpr with | TBlock [] -> () | _ -> gen_expr ctx e; newline ctx and gen_value ctx e = let assign e = mk (TBinop (Ast.OpAssign, mk (TLocal (match ctx.in_value with None -> assert false | Some r -> r)) t_dynamic e.epos, e )) e.etype e.epos in let block e = mk (TBlock [e]) e.etype e.epos in let value block = let old = ctx.in_value in let t = type_str ctx e.etype e.epos in let r = alloc_var (gen_local ctx "$r") e.etype in ctx.in_value <- Some r; if ctx.in_static then print ctx "function() : %s " t else print ctx "(function($this:%s) : %s " (snd ctx.path) t; let b = if block then begin spr ctx "{"; let b = open_block ctx in newline ctx; print ctx "var %s : %s" r.v_name t; newline ctx; b end else (fun() -> ()) in (fun() -> if block then begin newline ctx; print ctx "return %s" r.v_name; b(); newline ctx; spr ctx "}"; end; ctx.in_value <- old; if ctx.in_static then print ctx "()" else print ctx "(%s))" (this ctx) ) in match e.eexpr with | TCall ({ eexpr = TLocal { v_name = "__keys__" } },_) | TCall ({ eexpr = TLocal { v_name = "__hkeys__" } },_) -> let v = value true in gen_expr ctx e; v() | TConst _ | TLocal _ | TArray _ | TBinop _ | TField _ | TEnumParameter _ | TTypeExpr _ | TParenthesis _ | TObjectDecl _ | TArrayDecl _ | TCall _ | TNew _ | TUnop _ | TFunction _ -> gen_expr ctx e | TMeta (_,e1) -> gen_value ctx e1 | TCast (e1,None) -> let s = type_str ctx e.etype e1.epos in begin match s with | "*" -> gen_value ctx e1 | "Function" | "Array" | "String" -> spr ctx "(("; gen_value ctx e1; print ctx ") as %s)" s; | _ -> print ctx "%s(" s; gen_value ctx e1; spr ctx ")"; end | TCast (e1,Some t) -> gen_value ctx (Codegen.default_cast ctx.inf.com e1 t e.etype e.epos) | TReturn _ | TBreak | TContinue -> unsupported e.epos | TVar _ | TFor _ | TWhile _ | TThrow _ -> (* value is discarded anyway *) let v = value true in gen_expr ctx e; v() | TBlock [] -> spr ctx "null" | TBlock [e] -> gen_value ctx e | TBlock el -> let v = value true in let rec loop = function | [] -> spr ctx "return null"; | [e] -> gen_expr ctx (assign e); | e :: l -> gen_expr ctx e; newline ctx; loop l in loop el; v(); | TIf (cond,e,eo) -> spr ctx "("; gen_value ctx cond; spr ctx "?"; gen_value ctx e; spr ctx ":"; (match eo with | None -> spr ctx "null" | Some e -> gen_value ctx e); spr ctx ")" | TSwitch (cond,cases,def) -> let v = value true in gen_expr ctx (mk (TSwitch (cond, List.map (fun (e1,e2) -> (e1,assign e2)) cases, match def with None -> None | Some e -> Some (assign e) )) e.etype e.epos); v() | TTry (b,catchs) -> let v = value true in gen_expr ctx (mk (TTry (block (assign b), List.map (fun (v,e) -> v, block (assign e)) catchs )) e.etype e.epos); v() let final m = if Ast.Meta.has Ast.Meta.Final m then "final " else "" let generate_field ctx static f = newline ctx; ctx.in_static <- static; ctx.gen_uid <- 0; List.iter (fun(m,pl,_) -> match m,pl with | Ast.Meta.Meta, [Ast.ECall ((Ast.EConst (Ast.Ident n),_),args),_] -> let mk_arg (a,p) = match a with | Ast.EConst (Ast.String s) -> (None, s) | Ast.EBinop (Ast.OpAssign,(Ast.EConst (Ast.Ident n),_),(Ast.EConst (Ast.String s),_)) -> (Some n, s) | _ -> error "Invalid meta definition" p in print ctx "[%s" n; (match args with | [] -> () | _ -> print ctx "("; concat ctx "," (fun a -> match mk_arg a with | None, s -> gen_constant ctx (snd a) (TString s) | Some s, e -> print ctx "%s=" s; gen_constant ctx (snd a) (TString e) ) args; print ctx ")"); print ctx "]"; | _ -> () ) f.cf_meta; let public = f.cf_public || Hashtbl.mem ctx.get_sets (f.cf_name,static) || (f.cf_name = "main" && static) || f.cf_name = "resolve" || Ast.Meta.has Ast.Meta.Public f.cf_meta (* consider all abstract methods public to avoid issues with inlined private access *) || (match ctx.curclass.cl_kind with KAbstractImpl _ -> true | _ -> false) in let rights = (if static then "static " else "") ^ (if public then "public" else "protected") in let p = ctx.curclass.cl_pos in match f.cf_expr, f.cf_kind with | Some { eexpr = TFunction fd }, Method (MethNormal | MethInline) -> print ctx "%s%s " rights (if static then "" else final f.cf_meta); let rec loop c = match c.cl_super with | None -> () | Some (c,_) -> if PMap.mem f.cf_name c.cl_fields then spr ctx "override " else loop c in if not static then loop ctx.curclass; let h = gen_function_header ctx (Some (s_ident f.cf_name, f.cf_meta)) fd f.cf_params p in gen_expr ctx fd.tf_expr; h(); newline ctx | _ -> let is_getset = (match f.cf_kind with Var { v_read = AccCall } | Var { v_write = AccCall } -> true | _ -> false) in if ctx.curclass.cl_interface then match follow f.cf_type with | TFun (args,r) when (match f.cf_kind with Method MethDynamic | Var _ -> false | _ -> true) -> let rec loop = function | [] -> f.cf_name | (Ast.Meta.Getter,[Ast.EConst (Ast.String name),_],_) :: _ -> "get " ^ name | (Ast.Meta.Setter,[Ast.EConst (Ast.String name),_],_) :: _ -> "set " ^ name | _ :: l -> loop l in print ctx "function %s(" (loop f.cf_meta); concat ctx "," (fun (arg,o,t) -> let tstr = type_str ctx t p in print ctx "%s : %s" arg tstr; if o then print ctx " = %s" (default_value tstr); ) args; print ctx ") : %s " (type_str ctx r p); | _ -> () else let gen_init () = match f.cf_expr with | None -> () | Some e -> print ctx " = "; gen_value ctx e in if is_getset then begin let t = type_str ctx f.cf_type p in let id = s_ident f.cf_name in let v = (match f.cf_kind with Var v -> v | _ -> assert false) in (match v.v_read with | AccNormal | AccNo | AccNever -> print ctx "%s function get %s() : %s { return $%s; }" rights id t id; newline ctx | AccCall -> print ctx "%s function get %s() : %s { return %s(); }" rights id t ("get_" ^ f.cf_name); newline ctx | _ -> ()); (match v.v_write with | AccNormal | AccNo | AccNever -> print ctx "%s function set %s( __v : %s ) : void { $%s = __v; }" rights id t id; newline ctx | AccCall -> print ctx "%s function set %s( __v : %s ) : void { %s(__v); }" rights id t ("set_" ^ f.cf_name); newline ctx | _ -> ()); print ctx "%sprotected var $%s : %s" (if static then "static " else "") (s_ident f.cf_name) (type_str ctx f.cf_type p); gen_init() end else begin print ctx "%s var %s : %s" rights (s_ident f.cf_name) (type_str ctx f.cf_type p); gen_init() end let rec define_getset ctx stat c = let def f name = Hashtbl.add ctx.get_sets (name,stat) f.cf_name in let field f = match f.cf_kind with | Method _ -> () | Var v -> (match v.v_read with AccCall -> def f ("get_" ^ f.cf_name) | _ -> ()); (match v.v_write with AccCall -> def f ("set_" ^ f.cf_name) | _ -> ()) in List.iter field (if stat then c.cl_ordered_statics else c.cl_ordered_fields); match c.cl_super with | Some (c,_) when not stat -> define_getset ctx stat c | _ -> () let generate_class ctx c = ctx.curclass <- c; define_getset ctx true c; define_getset ctx false c; ctx.local_types <- List.map snd c.cl_params; let pack = open_block ctx in print ctx "\tpublic %s%s%s %s " (final c.cl_meta) (match c.cl_dynamic with None -> "" | Some _ -> if c.cl_interface then "" else "dynamic ") (if c.cl_interface then "interface" else "class") (snd c.cl_path); (match c.cl_super with | None -> () | Some (csup,_) -> print ctx "extends %s " (s_path ctx true csup.cl_path c.cl_pos)); (match c.cl_implements with | [] -> () | l -> spr ctx (if c.cl_interface then "extends " else "implements "); concat ctx ", " (fun (i,_) -> print ctx "%s" (s_path ctx true i.cl_path c.cl_pos)) l); spr ctx "{"; let cl = open_block ctx in (match c.cl_constructor with | None -> () | Some f -> let f = { f with cf_name = snd c.cl_path; cf_public = true; cf_kind = Method MethNormal; } in ctx.constructor_block <- true; generate_field ctx false f; ); List.iter (generate_field ctx false) c.cl_ordered_fields; List.iter (generate_field ctx true) c.cl_ordered_statics; cl(); newline ctx; print ctx "}"; pack(); newline ctx; print ctx "}"; newline ctx let generate_main ctx inits = ctx.curclass <- { null_class with cl_path = [],"__main__" }; let pack = open_block ctx in print ctx "\timport flash.Lib"; newline ctx; print ctx "public class __main__ extends %s {" (s_path ctx true (["flash"],"Boot") Ast.null_pos); let cl = open_block ctx in newline ctx; spr ctx "public function __main__() {"; let fl = open_block ctx in newline ctx; spr ctx "super()"; newline ctx; spr ctx "flash.Lib.current = this"; List.iter (fun e -> newline ctx; gen_expr ctx e) inits; fl(); newline ctx; print ctx "}"; cl(); newline ctx; print ctx "}"; pack(); newline ctx; print ctx "}"; newline ctx let generate_enum ctx e = ctx.local_types <- List.map snd e.e_params; let pack = open_block ctx in let ename = snd e.e_path in print ctx "\tpublic final class %s extends enum {" ename; let cl = open_block ctx in newline ctx; print ctx "public static const __isenum : Boolean = true"; newline ctx; print ctx "public function %s( t : String, index : int, p : Array = null ) : void { this.tag = t; this.index = index; this.params = p; }" ename; PMap.iter (fun _ c -> newline ctx; match c.ef_type with | TFun (args,_) -> print ctx "public static function %s(" c.ef_name; concat ctx ", " (fun (a,o,t) -> print ctx "%s : %s" (s_ident a) (type_str ctx t c.ef_pos); if o then spr ctx " = null"; ) args; print ctx ") : %s {" ename; print ctx " return new %s(\"%s\",%d,[" ename c.ef_name c.ef_index; concat ctx "," (fun (a,_,_) -> spr ctx (s_ident a)) args; print ctx "]); }"; | _ -> print ctx "public static var %s : %s = new %s(\"%s\",%d)" c.ef_name ename ename c.ef_name c.ef_index; ) e.e_constrs; newline ctx; (match Codegen.build_metadata ctx.inf.com (TEnumDecl e) with | None -> () | Some e -> print ctx "public static var __meta__ : * = "; gen_expr ctx e; newline ctx); print ctx "public static var __constructs__ : Array = [%s];" (String.concat "," (List.map (fun s -> "\"" ^ Ast.s_escape s ^ "\"") e.e_names)); cl(); newline ctx; print ctx "}"; pack(); newline ctx; print ctx "}"; newline ctx let generate_base_enum ctx = let pack = open_block ctx in spr ctx "\timport flash.Boot"; newline ctx; spr ctx "public class enum {"; let cl = open_block ctx in newline ctx; spr ctx "public var tag : String"; newline ctx; spr ctx "public var index : int"; newline ctx; spr ctx "public var params : Array"; newline ctx; spr ctx "public function toString() : String { return flash.Boot.enum_to_string(this); }"; cl(); newline ctx; print ctx "}"; pack(); newline ctx; print ctx "}"; newline ctx let generate com = let infos = { com = com; } in generate_resources infos; let ctx = init infos ([],"enum") in generate_base_enum ctx; close ctx; let inits = ref [] in List.iter (fun t -> match t with | TClassDecl c -> let c = (match c.cl_path with | ["flash"],"FlashXml__" -> { c with cl_path = [],"Xml" } | (pack,name) -> { c with cl_path = (pack,protect name) } ) in (match c.cl_init with | None -> () | Some e -> inits := e :: !inits); if c.cl_extern then () else let ctx = init infos c.cl_path in generate_class ctx c; close ctx | TEnumDecl e -> let pack,name = e.e_path in let e = { e with e_path = (pack,protect name) } in if e.e_extern then () else let ctx = init infos e.e_path in generate_enum ctx e; close ctx | TTypeDecl _ | TAbstractDecl _ -> () ) com.types; (match com.main with | None -> () | Some e -> inits := e :: !inits); let ctx = init infos ([],"__main__") in generate_main ctx (List.rev !inits); close ctx haxe_3.2.1+dfsg.orig/gencommon.ml0000664000175000017500000147101012607337712016644 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) (* Gen Common API This module intends to be a common set of utilities common to all targets. It's intended to provide a set of tools to be able to make targets in Haxe more easily, and to allow the programmer to have more control of how the target language will handle the program. For example, as of now, the hxcpp target, while greatly done, relies heavily on cpp's own operator overloading, and implicit conversions, which make it very hard to deliver a similar solution for languages that lack these features. So this little framework is here so you can manipulate the Haxe AST and start bringing the AST closer to how it's intenteded to be in your host language. Rules Design goals Naming convention Weaknesses and TODO's *) open Unix open Ast open Type open Common open Option open Printf open ExtString let debug_type_ctor = function | TMono _ -> "TMono" | TEnum _ -> "TEnum" | TInst _ -> "TInst" | TType _ -> "TType" | TFun _ -> "TFun" | TAnon _ -> "TAnon" | TDynamic _ -> "TDynamic" | TLazy _ -> "TLazy" | TAbstract _ -> "TAbstract" let debug_type = (s_type (print_context())) let debug_expr = s_expr debug_type let rec like_float t = match follow t with | TAbstract({ a_path = ([], "Float") },[]) | TAbstract({ a_path = ([], "Int") },[]) -> true | TAbstract({ a_path = (["cs"], "Pointer") },_) -> false | TAbstract(a, _) -> List.exists (fun t -> like_float t) a.a_from || List.exists (fun t -> like_float t) a.a_to | _ -> false let rec like_int t = match follow t with | TAbstract({ a_path = ([], "Int") },[]) -> true | TAbstract({ a_path = (["cs"], "Pointer") },_) -> false | TAbstract(a, _) -> List.exists (fun t -> like_int t) a.a_from || List.exists (fun t -> like_int t) a.a_to | _ -> false let rec like_i64 t = match follow t with | TInst({ cl_path = (["cs"], "Int64") },[]) | TAbstract({ a_path = (["cs"], "Int64") },[]) | TInst({ cl_path = (["cs"], "UInt64") },[]) | TInst({ cl_path = (["java"], "Int64") },[]) | TAbstract({ a_path = (["java"], "Int64") },[]) | TInst({ cl_path = (["haxe"], "Int64") },[]) | TAbstract({ a_path = (["haxe"], "Int64") },[]) -> true | TAbstract(a, _) -> List.exists (fun t -> like_i64 t) a.a_from || List.exists (fun t -> like_i64 t) a.a_to | _ -> false let follow_once t = match t with | TMono r -> (match !r with | Some t -> t | _ -> t_dynamic (* avoid infinite loop / should be the same in this context *)) | TLazy f -> !f() | TType (t,tl) -> apply_params t.t_params tl t.t_type | _ -> t let t_empty = TAnon({ a_fields = PMap.empty; a_status = ref (Closed) }) let tmp_count = ref 0 let reset_temps () = tmp_count := 0 (* the undefined is a special var that works like null, but can have special meaning *) let v_undefined = alloc_var "__undefined__" t_dynamic let undefined pos = { eexpr = TLocal(v_undefined); etype = t_dynamic; epos = pos } module ExprHashtblHelper = struct type hash_texpr_t = { hepos : pos; heexpr : int; hetype : int; } let mk_heexpr = function | TConst _ -> 0 | TLocal _ -> 1 | TArray _ -> 3 | TBinop _ -> 4 | TField _ -> 5 | TTypeExpr _ -> 7 | TParenthesis _ -> 8 | TObjectDecl _ -> 9 | TArrayDecl _ -> 10 | TCall _ -> 11 | TNew _ -> 12 | TUnop _ -> 13 | TFunction _ -> 14 | TVar _ -> 15 | TBlock _ -> 16 | TFor _ -> 17 | TIf _ -> 18 | TWhile _ -> 19 | TSwitch _ -> 20 (* | TPatMatch _ -> 21 *) | TTry _ -> 22 | TReturn _ -> 23 | TBreak -> 24 | TContinue -> 25 | TThrow _ -> 26 | TCast _ -> 27 | TMeta _ -> 28 | TEnumParameter _ -> 29 let mk_heetype = function | TMono _ -> 0 | TEnum _ -> 1 | TInst _ -> 2 | TType _ -> 3 | TFun _ -> 4 | TAnon _ -> 5 | TDynamic _ -> 6 | TLazy _ -> 7 | TAbstract _ -> 8 let mk_type e = { hepos = e.epos; heexpr = mk_heexpr e.eexpr; hetype = mk_heetype e.etype; } end;; let path_of_md_def md_def = match md_def.m_types with | [TClassDecl c] -> c.cl_path | _ -> md_def.m_path open ExprHashtblHelper;; (* Expression Hashtbl. This shouldn't be kept indefinately as it's not a weak Hashtbl. *) module ExprHashtbl = Hashtbl.Make( struct type t = Type.texpr let equal = (==) let hash t = Hashtbl.hash (mk_type t) end );; (* ******************************************* *) (* Gen Common This is the key module for generation of Java and C# sources In order for both modules to share as much code as possible, some rules were devised: - every feature has its own submodule, and may contain the following methods: - configure sets all the configuration variables for the module to run. If a module has this method, it *should* be called once before running any filter - run_filter -> runs the filter immediately on the context - add_filter -> adds the filter to an expr->expr list. Most filter modules will provide this option so the filter function can only run once. - most submodules will have side-effects so the order of operations will matter. When running configure / add_filter this might be taken care of with the rule-based dispatch system working underneath, but still there might be some incompatibilities. There will be an effort to document it. The modules can hint on the order by suffixing their functions with _first or _last. - any of those methods might have different parameters, that configure how the filter will run. For example, a simple filter that maps switch() expressions to if () .. else if... might receive a function that filters what content should be mapped - Other targets can use those filters on their own code. In order to do that, a simple configuration step is needed: you need to initialize a generator_ctx type with Gencommon.new_gen (context:Common.context) with a generator_ctx context you will be able to add filters to your code, and execute them with Gencommon.run_filters (gen_context:Gencommon.generator_ctx) After running the filters, you can run your own generator normally. (* , or you can run Gencommon.generate_modules (gen_context:Gencommon.generator_ctx) (extension:string) (module_gen:module_type list->bool) where module_gen will take a whole module (can be *) *) (* ******************************************* *) (* common helpers *) (* ******************************************* *) let assertions = false (* when assertions == true, many assertions will be made to guarantee the quality of the data input *) let debug_mode = ref false let trace s = if !debug_mode then print_endline s else () let timer name = if !debug_mode then Common.timer name else fun () -> () let is_string t = match follow t with | TInst({ cl_path = ([], "String") }, []) -> true | _ -> false (* helper function for creating Anon types of class / enum modules *) let anon_of_classtype cl = TAnon { a_fields = cl.cl_statics; a_status = ref (Statics cl) } let anon_of_enum e = TAnon { a_fields = PMap.empty; a_status = ref (EnumStatics e) } let anon_of_abstract a = TAnon { a_fields = PMap.empty; a_status = ref (AbstractStatics a) } let anon_of_mt mt = match mt with | TClassDecl cl -> anon_of_classtype cl | TEnumDecl e -> anon_of_enum e | TAbstractDecl a -> anon_of_abstract a | _ -> assert false let anon_class t = match follow t with | TAnon anon -> (match !(anon.a_status) with | Statics (cl) -> Some(TClassDecl(cl)) | EnumStatics (e) -> Some(TEnumDecl(e)) | AbstractStatics (a) -> Some(TAbstractDecl(a)) | _ -> None) | _ -> None let path_s path = match path with | ([], s) -> s | (p, s) -> (String.concat "." (fst path)) ^ "." ^ (snd path) let rec t_to_md t = match t with | TInst (cl,_) -> TClassDecl cl | TEnum (e,_) -> TEnumDecl e | TType (t,_) -> TTypeDecl t | TAbstract (a,_) -> TAbstractDecl a | TAnon anon -> (match !(anon.a_status) with | EnumStatics e -> TEnumDecl e | Statics cl -> TClassDecl cl | AbstractStatics a -> TAbstractDecl a | _ -> assert false) | TLazy f -> t_to_md (!f()) | TMono r -> (match !r with | Some t -> t_to_md t | None -> assert false) | _ -> assert false let get_cl mt = match mt with | TClassDecl cl -> cl | _ -> failwith ("Unexpected module type of '" ^ path_s (t_path mt) ^ "'") let get_abstract mt = match mt with | TAbstractDecl a -> a | _ -> failwith ("Unexpected module type of '" ^ path_s (t_path mt) ^ "'") let get_tdef mt = match mt with | TTypeDecl t -> t | _ -> assert false let mk_mt_access mt pos = { eexpr = TTypeExpr(mt); etype = anon_of_mt mt; epos = pos } let is_void t = match follow t with | TAbstract ({ a_path = ([], "Void") },[]) -> true | _ -> false let mk_local var pos = { eexpr = TLocal(var); etype = var.v_type; epos = pos } (* this function is used by CastDetection module *) let get_fun t = match follow t with | TFun(r1,r2) -> (r1,r2) | _ -> (trace (s_type (print_context()) (follow t) )); assert false let mk_cast t e = { eexpr = TCast(e, None); etype = t; epos = e.epos } let mk_classtype_access cl pos = { eexpr = TTypeExpr(TClassDecl(cl)); etype = anon_of_classtype cl; epos = pos } let mk_static_field_access_infer cl field pos params = try let cf = (PMap.find field cl.cl_statics) in { eexpr = TField(mk_classtype_access cl pos, FStatic(cl, cf)); etype = (if params = [] then cf.cf_type else apply_params cf.cf_params params cf.cf_type); epos = pos } with | Not_found -> failwith ("Cannot find field " ^ field ^ " in type " ^ (path_s cl.cl_path)) let mk_static_field_access cl field fieldt pos = { (mk_static_field_access_infer cl field pos []) with etype = fieldt } (* stolen from Hugh's sources ;-) *) (* this used to be a class, but there was something in there that crashed ocaml native compiler in windows *) module SourceWriter = struct type source_writer = { sw_buf : Buffer.t; mutable sw_has_content : bool; mutable sw_indent : string; mutable sw_indents : string list; } let new_source_writer () = { sw_buf = Buffer.create 0; sw_has_content = false; sw_indent = ""; sw_indents = []; } let add_writer w_write w_read = Buffer.add_buffer w_read.sw_buf w_write.sw_buf let contents w = Buffer.contents w.sw_buf let len w = Buffer.length w.sw_buf let write w x = (if not w.sw_has_content then begin w.sw_has_content <- true; Buffer.add_string w.sw_buf w.sw_indent; Buffer.add_string w.sw_buf x; end else Buffer.add_string w.sw_buf x); let len = (String.length x)-1 in if len >= 0 && String.get x len = '\n' then begin w.sw_has_content <- false end else w.sw_has_content <- true let push_indent w = w.sw_indents <- "\t"::w.sw_indents; w.sw_indent <- String.concat "" w.sw_indents let pop_indent w = match w.sw_indents with | h::tail -> w.sw_indents <- tail; w.sw_indent <- String.concat "" w.sw_indents | [] -> w.sw_indent <- "/*?*/" let newline w = write w "\n" let begin_block w = (if w.sw_has_content then newline w); write w "{"; push_indent w; newline w let end_block w = pop_indent w; (if w.sw_has_content then newline w); write w "}"; newline w let print w = (if not w.sw_has_content then begin w.sw_has_content <- true; Buffer.add_string w.sw_buf w.sw_indent end); bprintf w.sw_buf; end;; (* rule_dispatcher's priority *) type priority = | PFirst | PLast | PZero | PCustom of float exception DuplicateName of string exception NoRulesApplied let indent = ref [] (* the rule dispatcher is the primary way to deal with distributed "plugins" *) (* we will define rules that will form a distributed / extensible match system *) class ['tp, 'ret] rule_dispatcher name ignore_not_found = object(self) val tbl = Hashtbl.create 16 val mutable keys = [] val names = Hashtbl.create 16 val mutable temp = 0 method add ?(name : string option) (* name helps debugging *) ?(priority : priority = PZero) (rule : 'tp->'ret option) = let p = match priority with | PFirst -> infinity | PLast -> neg_infinity | PZero -> 0.0 | PCustom i -> i in let q = if not( Hashtbl.mem tbl p ) then begin let q = Stack.create() in Hashtbl.add tbl p q; keys <- p :: keys; keys <- List.sort (fun x y -> - (compare x y)) keys; q end else Hashtbl.find tbl p in let name = match name with | None -> temp <- temp + 1; "$_" ^ (string_of_int temp) | Some s -> s in (if Hashtbl.mem names name then raise (DuplicateName(name))); Hashtbl.add names name q; Stack.push (name, rule) q method describe = Hashtbl.iter (fun s _ -> (trace s)) names; method remove (name : string) = if Hashtbl.mem names name then begin let q = Hashtbl.find names name in let q_temp = Stack.create () in Stack.iter (function | (n, _) when n = name -> () | _ as r -> Stack.push r q_temp ) q; Stack.clear q; Stack.iter (fun r -> Stack.push r q) q_temp; Hashtbl.remove names name; true end else false method run_f tp = get (self#run tp) method did_run tp = is_some (self#run tp) method get_list = let ret = ref [] in List.iter (fun key -> let q = Hashtbl.find tbl key in Stack.iter (fun (_, rule) -> ret := rule :: !ret) q ) keys; List.rev !ret method run_from (priority:float) (tp:'tp) : 'ret option = let ok = ref ignore_not_found in let ret = ref None in indent := "\t" :: !indent; (try begin List.iter (fun key -> if key < priority then begin let q = Hashtbl.find tbl key in Stack.iter (fun (n, rule) -> let t = if !debug_mode then Common.timer ("rule dispatcher rule: " ^ n) else fun () -> () in let r = rule(tp) in t(); if is_some r then begin ret := r; raise Exit end ) q end ) keys end with Exit -> ok := true); (match !indent with | [] -> () | h::t -> indent := t); (if not (!ok) then raise NoRulesApplied); !ret method run (tp:'tp) : 'ret option = self#run_from infinity tp end;; (* this is a special case where tp = tret and you stack their output as the next's input *) class ['tp] rule_map_dispatcher name = object(self) inherit ['tp, 'tp] rule_dispatcher name true as super method run_f tp = get (self#run tp) method run_from (priority:float) (tp:'tp) : 'ret option = let cur = ref tp in (try begin List.iter (fun key -> if key < priority then begin let q = Hashtbl.find tbl key in Stack.iter (fun (n, rule) -> trace ("running rule " ^ n); let t = if !debug_mode then Common.timer ("rule map dispatcher rule: " ^ n) else fun () -> () in let r = rule(!cur) in t(); if is_some r then begin cur := get r end ) q end ) keys end with Exit -> ()); Some (!cur) end;; type generator_ctx = { (* these are the basic context fields. If another target is using this context, *) (* this is all you need to care about *) mutable gcon : Common.context; gclasses : gen_classes; gtools : gen_tools; (* configurable function that receives a desired name and makes it "internal", doing the best to ensure that it will not be called from outside. To avoid name clashes between internal names, user must specify two strings: a "namespace" and the name itself *) mutable gmk_internal_name : string->string->string; (* module filters run before module filters and they should generate valid haxe syntax as a result. Module filters shouldn't go through the expressions as it adds an unnecessary burden to the GC, and it can all be done in a single step with gexpr_filters and proper priority selection. As a convention, Module filters should end their name with Modf, so they aren't mistaken with expression filters *) gmodule_filters : (module_type) rule_map_dispatcher; (* expression filters are the most common filters to be applied. They should also generate only valid haxe expressions, so e.g. calls to non-existant methods should be avoided, although there are some ways around them (like gspecial_methods) *) gexpr_filters : (texpr) rule_map_dispatcher; (* syntax filters are also expression filters but they no longer require that the resulting expressions be valid haxe expressions. They then have no guarantee that either the input expressions or the output one follow the same rules as normal haxe code. *) gsyntax_filters : (texpr) rule_map_dispatcher; (* these are more advanced features, but they would require a rewrite of targets *) (* they are just helpers to ditribute functions like "follow" or "type to string" *) (* so adding a module will already take care of correctly following a certain type of *) (* variable, for example *) (* follows the type through typedefs, lazy typing, etc. *) (* it's the place to put specific rules to handle typedefs, like *) (* other basic types like UInt *) gfollow : (t, t) rule_dispatcher; gtypes : (path, module_type) Hashtbl.t; mutable gtypes_list : module_type list; mutable gmodules : Type.module_def list; (* cast detection helpers / settings *) (* this is a cache for all field access types *) greal_field_types : (path * string, (tclass_field (* does the cf exist *) * t (*cf's type in relation to current class type params *) * t * tclass (* declared class *) ) option) Hashtbl.t; (* this function allows any code to handle casts as if it were inside the cast_detect module *) mutable ghandle_cast : t->t->texpr->texpr; (* when an unsafe cast is made, we can warn the user *) mutable gon_unsafe_cast : t->t->pos->unit; (* does this type needs to be boxed? Normally always false, unless special type handling must be made *) mutable gneeds_box : t->bool; (* does this 'special type' needs cast to this other type? *) (* this is here so we can implement custom behavior for "opaque" typedefs *) mutable gspecial_needs_cast : t->t->bool; (* sometimes we may want to support unrelated conversions on cast detection *) (* for example, haxe.lang.Null -> T on C# *) (* every time an unrelated conversion is found, each to/from path is searched on this hashtbl *) (* if found, the function will be executed with from_type, to_type. If returns true, it means that *) (* it is a supported conversion, and the unsafe cast routine changes to a simple cast *) gsupported_conversions : (path, t->t->bool) Hashtbl.t; (* API for filters *) (* add type can be called at any time, and will add a new module_def that may or may not be filtered *) (* module_type -> should_filter *) mutable gadd_type : module_type -> bool -> unit; (* during expr filters, add_to_module will be available so module_types can be added to current module_def. we must pass the priority argument so the filters can be resumed *) mutable gadd_to_module : module_type -> float -> unit; (* during expr filters, shows the current class path *) mutable gcurrent_path : path; (* current class *) mutable gcurrent_class : tclass option; (* current class field, if any *) mutable gcurrent_classfield : tclass_field option; (* events *) (* is executed once every new classfield *) mutable gon_classfield_start : (unit -> unit) list; (* is executed once every new module type *) mutable gon_new_module_type : (unit -> unit) list; (* after module filters ended *) mutable gafter_mod_filters_ended : (unit -> unit) list; (* after expression filters ended *) mutable gafter_expr_filters_ended : (unit -> unit) list; (* after all filters are run *) mutable gafter_filters_ended : (unit -> unit) list; mutable gbase_class_fields : (string, tclass_field) PMap.t; (* real type is the type as it is read by the target. *) (* This function is here because most targets don't have *) (* a 1:1 translation between haxe types and its native types *) (* But types aren't changed to this representation as we might lose *) (* some valuable type information in the process *) mutable greal_type : t -> t; (* the same as greal_type but for type parameters. *) mutable greal_type_param : module_type -> tparams -> tparams; (* is the type a value type? This may be used in some optimizations where reference types and value types are handled differently. At first the default is very good to use, and if tweaks are needed, it's best to be done by adding @:struct meta to the value types * mutable gis_value_type : t -> bool;*) (* misc configuration *) (* Should the target allow type parameter dynamic conversion, or should we add a cast to those cases as well? *) mutable gallow_tp_dynamic_conversion : bool; (* Does the target support type parameter constraints? If not, they will be ignored when detecting casts *) mutable guse_tp_constraints : bool; (* internal apis *) (* param_func_call : used by TypeParams and CastDetection *) mutable gparam_func_call : texpr->texpr->tparams->texpr list->texpr; (* does it already have a type parameter cast handler? This is used by CastDetect to know if it should handle type parameter casts *) mutable ghas_tparam_cast_handler : bool; (* type parameter casts - special cases *) (* function cast_from, cast_to -> texpr *) gtparam_cast : (path, (texpr->t->texpr)) Hashtbl.t; (* special vars are used for adding special behavior to *) gspecial_vars : (string, bool) Hashtbl.t; } and gen_classes = { cl_reflect : tclass; cl_type : tclass; cl_dyn : tclass; t_iterator : tdef; mutable nativearray_len : texpr -> pos -> texpr; mutable nativearray_type : Type.t -> Type.t; mutable nativearray : Type.t -> Type.t; } (* add here all reflection transformation additions *) and gen_tools = { (* (klass : texpr, t : t) : texpr *) mutable r_create_empty : texpr->t->texpr; (* Reflect.fields(). The bool is if we are iterating in a read-only manner. If it is read-only we might not need to allocate a new array *) mutable r_fields : bool->texpr->texpr; (* (first argument = return type. should be void in most cases) Reflect.setField(obj, field, val) *) mutable r_set_field : t->texpr->texpr->texpr->texpr; (* Reflect.field. bool indicates if is safe (no error throwing) or unsafe; t is the expected return type true = safe *) mutable r_field : bool->t->texpr->texpr->texpr; (* these are now the functions that will later be used when creating the reflection classes *) (* on the default implementation (at OverloadingCtors), it will be new SomeClass(EmptyInstance) *) mutable rf_create_empty : tclass->tparams->pos->texpr; } let get_type types path = List.find (fun md -> match md with | TClassDecl cl when cl.cl_path = path -> true | TEnumDecl e when e.e_path = path -> true | TTypeDecl t when t.t_path = path -> true | TAbstractDecl a when a.a_path = path -> true | _ -> false ) types let new_ctx con = let types = Hashtbl.create (List.length con.types) in List.iter (fun mt -> match mt with | TClassDecl cl -> Hashtbl.add types cl.cl_path mt | TEnumDecl e -> Hashtbl.add types e.e_path mt | TTypeDecl t -> Hashtbl.add types t.t_path mt | TAbstractDecl a -> Hashtbl.add types a.a_path mt ) con.types; let cl_dyn = match get_type con.types ([], "Dynamic") with | TClassDecl c -> c | TAbstractDecl a -> mk_class a.a_module ([], "Dynamic") a.a_pos | _ -> assert false in let rec gen = { gcon = con; gclasses = { cl_reflect = get_cl (get_type con.types ([], "Reflect")); cl_type = get_cl (get_type con.types ([], "Type")); cl_dyn = cl_dyn; t_iterator = get_tdef (get_type con.types ([], "Iterator")); nativearray = (fun _ -> assert false); nativearray_type = (fun _ -> assert false); nativearray_len = (fun _ -> assert false); }; gtools = { r_create_empty = (fun eclass t -> let fieldcall = mk_static_field_access_infer gen.gclasses.cl_type "createEmptyInstance" eclass.epos [t] in { eexpr = TCall(fieldcall, [eclass]); etype = t; epos = eclass.epos } ); r_fields = (fun is_used_only_by_iteration expr -> let fieldcall = mk_static_field_access_infer gen.gclasses.cl_reflect "fields" expr.epos [] in { eexpr = TCall(fieldcall, [expr]); etype = gen.gcon.basic.tarray gen.gcon.basic.tstring; epos = expr.epos } ); (* Reflect.setField(obj, field, val). t by now is ignored. FIXME : fix this implementation *) r_set_field = (fun t obj field v -> let fieldcall = mk_static_field_access_infer gen.gclasses.cl_reflect "setField" v.epos [] in { eexpr = TCall(fieldcall, [obj; field; v]); etype = t_dynamic; epos = v.epos } ); (* Reflect.field. bool indicates if is safe (no error throwing) or unsafe. true = safe *) r_field = (fun is_safe t obj field -> let fieldcall = mk_static_field_access_infer gen.gclasses.cl_reflect "field" obj.epos [] in (* FIXME: should we see if needs to cast? *) mk_cast t { eexpr = TCall(fieldcall, [obj; field]); etype = t_dynamic; epos = obj.epos } ); rf_create_empty = (fun cl p pos -> gen.gtools.r_create_empty { eexpr = TTypeExpr(TClassDecl cl); epos = pos; etype = t_dynamic } (TInst(cl,p)) ); (* TODO: Maybe implement using normal reflection? Type.createEmpty(MyClass) *) }; gmk_internal_name = (fun ns s -> sprintf "__%s_%s" ns s); gexpr_filters = new rule_map_dispatcher "gexpr_filters"; gmodule_filters = new rule_map_dispatcher "gmodule_filters"; gsyntax_filters = new rule_map_dispatcher "gsyntax_filters"; gfollow = new rule_dispatcher "gfollow" false; gtypes = types; gtypes_list = con.types; gmodules = con.modules; greal_field_types = Hashtbl.create 0; ghandle_cast = (fun to_t from_t e -> mk_cast to_t e); gon_unsafe_cast = (fun t t2 pos -> (gen.gcon.warning ("Type " ^ (debug_type t2) ^ " is being cast to the unrelated type " ^ (s_type (print_context()) t)) pos)); gneeds_box = (fun t -> false); gspecial_needs_cast = (fun to_t from_t -> true); gsupported_conversions = Hashtbl.create 0; gadd_type = (fun md should_filter -> if should_filter then begin gen.gtypes_list <- md :: gen.gtypes_list; gen.gmodules <- { m_id = alloc_mid(); m_path = (t_path md); m_types = [md]; m_extra = module_extra "" "" 0. MFake } :: gen.gmodules; Hashtbl.add gen.gtypes (t_path md) md; end else gen.gafter_filters_ended <- (fun () -> gen.gtypes_list <- md :: gen.gtypes_list; gen.gmodules <- { m_id = alloc_mid(); m_path = (t_path md); m_types = [md]; m_extra = module_extra "" "" 0. MFake } :: gen.gmodules; Hashtbl.add gen.gtypes (t_path md) md; ) :: gen.gafter_filters_ended; ); gadd_to_module = (fun md pr -> failwith "module added outside expr filters"); gcurrent_path = ([],""); gcurrent_class = None; gcurrent_classfield = None; gon_classfield_start = []; gon_new_module_type = []; gafter_mod_filters_ended = []; gafter_expr_filters_ended = []; gafter_filters_ended = []; gbase_class_fields = PMap.empty; greal_type = (fun t -> t); greal_type_param = (fun _ t -> t); gallow_tp_dynamic_conversion = false; guse_tp_constraints = false; (* as a default, ignore the params *) gparam_func_call = (fun ecall efield params elist -> { ecall with eexpr = TCall(efield, elist) }); ghas_tparam_cast_handler = false; gtparam_cast = Hashtbl.create 0; gspecial_vars = Hashtbl.create 0; } in (*gen.gtools.r_create_empty <- gen.gtools.r_get_class <- gen.gtools.r_fields <- *) gen let init_ctx gen = (* ultimately add a follow once handler as the last follow handler *) let follow_f = gen.gfollow#run in let follow t = match t with | TMono r -> (match !r with | Some t -> follow_f t | _ -> Some t) | TLazy f -> follow_f (!f()) | TType (t,tl) -> follow_f (apply_params t.t_params tl t.t_type) | _ -> Some t in gen.gfollow#add ~name:"final" ~priority:PLast follow (* run_follow (gen:generator_ctx) (t:t) *) let run_follow gen = gen.gfollow#run_f let reorder_modules gen = let modules = Hashtbl.create 20 in List.iter (fun md -> Hashtbl.add modules ( (t_infos md).mt_module ).m_path md ) gen.gtypes_list; gen.gmodules <- []; let processed = Hashtbl.create 20 in Hashtbl.iter (fun md_path md -> if not (Hashtbl.mem processed md_path) then begin Hashtbl.add processed md_path true; gen.gmodules <- { m_id = alloc_mid(); m_path = md_path; m_types = List.rev ( Hashtbl.find_all modules md_path ); m_extra = (t_infos md).mt_module.m_extra } :: gen.gmodules end ) modules let run_filters_from gen t filters = match t with | TClassDecl c -> trace (snd c.cl_path); gen.gcurrent_path <- c.cl_path; gen.gcurrent_class <- Some(c); List.iter (fun fn -> fn()) gen.gon_new_module_type; gen.gcurrent_classfield <- None; let rec process_field f = reset_temps(); gen.gcurrent_classfield <- Some(f); List.iter (fun fn -> fn()) gen.gon_classfield_start; trace f.cf_name; (match f.cf_expr with | None -> () | Some e -> f.cf_expr <- Some (List.fold_left (fun e f -> f e) e filters)); List.iter process_field f.cf_overloads; in List.iter process_field c.cl_ordered_fields; List.iter process_field c.cl_ordered_statics; (match c.cl_constructor with | None -> () | Some f -> process_field f); gen.gcurrent_classfield <- None; (match c.cl_init with | None -> () | Some e -> c.cl_init <- Some (List.fold_left (fun e f -> f e) e filters)); | TEnumDecl _ -> () | TTypeDecl _ -> () | TAbstractDecl _ -> () let run_filters gen = let last_error = gen.gcon.error in let has_errors = ref false in gen.gcon.error <- (fun msg pos -> has_errors := true; last_error msg pos); (* first of all, we have to make sure that the filters won't trigger a major Gc collection *) let t = Common.timer "gencommon_filters" in (if Common.defined gen.gcon Define.GencommonDebug then debug_mode := true else debug_mode := false); let run_filters filter = let rec loop acc mds = match mds with | [] -> acc | md :: tl -> let filters = [ filter#run_f ] in let added_types = ref [] in gen.gadd_to_module <- (fun md_type priority -> gen.gtypes_list <- md_type :: gen.gtypes_list; added_types := (md_type, priority) :: !added_types ); run_filters_from gen md filters; let added_types = List.map (fun (t,p) -> run_filters_from gen t [ fun e -> get (filter#run_from p e) ]; if Hashtbl.mem gen.gtypes (t_path t) then begin let rec loop i = let p = t_path t in let new_p = (fst p, snd p ^ "_" ^ (string_of_int i)) in if Hashtbl.mem gen.gtypes new_p then loop (i+1) else match t with | TClassDecl cl -> cl.cl_path <- new_p | TEnumDecl e -> e.e_path <- new_p | TTypeDecl _ | TAbstractDecl _ -> () in loop 0 end; Hashtbl.add gen.gtypes (t_path t) t; t ) !added_types in loop (added_types @ (md :: acc)) tl in List.rev (loop [] gen.gtypes_list) in let run_mod_filter filter = let last_add_to_module = gen.gadd_to_module in let added_types = ref [] in gen.gadd_to_module <- (fun md_type priority -> Hashtbl.add gen.gtypes (t_path md_type) md_type; added_types := (md_type, priority) :: !added_types ); let rec loop processed not_processed = match not_processed with | hd :: tl -> (match hd with | TClassDecl c -> gen.gcurrent_class <- Some c | _ -> gen.gcurrent_class <- None); let new_hd = filter#run_f hd in let added_types_new = !added_types in added_types := []; let added_types = List.map (fun (t,p) -> get (filter#run_from p t) ) added_types_new in loop ( added_types @ (new_hd :: processed) ) tl | [] -> processed in let filtered = loop [] gen.gtypes_list in gen.gadd_to_module <- last_add_to_module; gen.gtypes_list <- List.rev (filtered) in run_mod_filter gen.gmodule_filters; List.iter (fun fn -> fn()) gen.gafter_mod_filters_ended; let last_add_to_module = gen.gadd_to_module in gen.gtypes_list <- run_filters gen.gexpr_filters; gen.gadd_to_module <- last_add_to_module; List.iter (fun fn -> fn()) gen.gafter_expr_filters_ended; (* Codegen.post_process gen.gtypes_list [gen.gexpr_filters#run_f]; *) gen.gtypes_list <- run_filters gen.gsyntax_filters; List.iter (fun fn -> fn()) gen.gafter_filters_ended; reorder_modules gen; t(); if !has_errors then raise (Abort("Compilation aborted with errors",null_pos)) (* ******************************************* *) (* basic generation module that source code compilation implementations can use *) (* ******************************************* *) let write_file gen w source_dir path extension out_files = let t = timer "write file" in let s_path = source_dir ^ "/" ^ (snd path) ^ "." ^ (extension) in (* create the folders if they don't exist *) mkdir_from_path s_path; let contents = SourceWriter.contents w in let should_write = if not (Common.defined gen.gcon Define.ReplaceFiles) && Sys.file_exists s_path then begin let in_file = open_in s_path in let old_contents = Std.input_all in_file in close_in in_file; contents <> old_contents end else true in if should_write then begin let f = open_out_bin s_path in output_string f contents; close_out f end; out_files := (unique_full_path s_path) :: !out_files; t() let clean_files path excludes verbose = let rec iter_files pack dir path = try let file = Unix.readdir dir in if file <> "." && file <> ".." then begin let filepath = path ^ "/" ^ file in if (Unix.stat filepath).st_kind = S_DIR then let pack = pack @ [file] in iter_files (pack) (Unix.opendir filepath) filepath; try Unix.rmdir filepath with Unix.Unix_error (ENOTEMPTY,_,_) -> (); else if not (String.ends_with filepath ".meta") && not (List.mem (unique_full_path filepath) excludes) then begin if verbose then print_endline ("Removing " ^ filepath); Sys.remove filepath end end; iter_files pack dir path with | End_of_file | Unix.Unix_error _ -> Unix.closedir dir in iter_files [] (Unix.opendir path) path let dump_descriptor gen name path_s module_s = let w = SourceWriter.new_source_writer () in (* dump called path *) SourceWriter.write w (Sys.getcwd()); SourceWriter.newline w; (* dump all defines. deprecated *) SourceWriter.write w "begin defines"; SourceWriter.newline w; PMap.iter (fun name _ -> SourceWriter.write w name; SourceWriter.newline w ) gen.gcon.defines; SourceWriter.write w "end defines"; SourceWriter.newline w; (* dump all defines with their values; keeping the old defines for compatibility *) SourceWriter.write w "begin defines_data"; SourceWriter.newline w; PMap.iter (fun name v -> SourceWriter.write w name; SourceWriter.write w "="; SourceWriter.write w v; SourceWriter.newline w ) gen.gcon.defines; SourceWriter.write w "end defines_data"; SourceWriter.newline w; (* dump all generated types *) SourceWriter.write w "begin modules"; SourceWriter.newline w; let main_paths = Hashtbl.create 0 in List.iter (fun md_def -> SourceWriter.write w "M "; SourceWriter.write w (path_s (path_of_md_def md_def)); SourceWriter.newline w; List.iter (fun m -> match m with | TClassDecl cl when not cl.cl_extern -> SourceWriter.write w "C "; let s = module_s m in Hashtbl.add main_paths cl.cl_path s; SourceWriter.write w (s); SourceWriter.newline w | TEnumDecl e when not e.e_extern -> SourceWriter.write w "E "; SourceWriter.write w (module_s m); SourceWriter.newline w | _ -> () (* still no typedef or abstract is generated *) ) md_def.m_types ) gen.gmodules; SourceWriter.write w "end modules"; SourceWriter.newline w; (* dump all resources *) (match gen.gcon.main_class with | Some path -> SourceWriter.write w "begin main"; SourceWriter.newline w; (try SourceWriter.write w (Hashtbl.find main_paths path) with | Not_found -> SourceWriter.write w (path_s path)); SourceWriter.newline w; SourceWriter.write w "end main"; SourceWriter.newline w | _ -> () ); SourceWriter.write w "begin resources"; SourceWriter.newline w; Hashtbl.iter (fun name _ -> SourceWriter.write w name; SourceWriter.newline w ) gen.gcon.resources; SourceWriter.write w "end resources"; SourceWriter.newline w; SourceWriter.write w "begin libs"; SourceWriter.newline w; let path file ext = if Sys.file_exists file then file else try Common.find_file gen.gcon file with | Not_found -> try Common.find_file gen.gcon (file ^ ext) with | Not_found -> file in if Common.platform gen.gcon Java then List.iter (fun (s,std,_,_,_) -> if not std then begin SourceWriter.write w (path s ".jar"); SourceWriter.newline w; end ) gen.gcon.java_libs else if Common.platform gen.gcon Cs then List.iter (fun (s,std,_,_) -> if not std then begin SourceWriter.write w (path s ".dll"); SourceWriter.newline w; end ) gen.gcon.net_libs; SourceWriter.write w "end libs"; SourceWriter.newline w; let args = gen.gcon.c_args in if args <> [] then begin SourceWriter.write w "begin opts"; SourceWriter.newline w; List.iter (fun opt -> SourceWriter.write w opt; SourceWriter.newline w) (List.rev args); SourceWriter.write w "end opts"; SourceWriter.newline w; end; let contents = SourceWriter.contents w in let f = open_out (gen.gcon.file ^ "/" ^ name) in output_string f contents; close_out f let path_regex = Str.regexp "[/\\]+" let normalize path = let rec normalize acc m = match m with | [] -> List.rev acc | Str.Text "." :: Str.Delim _ :: tl when acc = [] -> normalize [] tl | Str.Text ".." :: Str.Delim _ :: tl -> (match acc with | [] -> raise Exit | _ :: acc -> normalize acc tl) | Str.Text t :: Str.Delim _ :: tl -> normalize (t :: acc) tl | Str.Delim _ :: tl -> normalize ("" :: acc) tl | Str.Text t :: [] -> List.rev (t :: acc) | Str.Text _ :: Str.Text _ :: _ -> assert false in String.concat "/" (normalize [] (Str.full_split path_regex path)) let is_relative cwd rel = try let rel = normalize rel in Filename.is_relative rel || (String.starts_with rel cwd || String.starts_with (Common.unique_full_path rel) cwd) with | Exit -> String.starts_with rel cwd || String.starts_with (Common.unique_full_path rel) cwd (* helper function to create the source structure. Will send each module_def to the function passed. If received true, it means that module_gen has generated this content, so the file must be saved. See that it will write a whole module *) let generate_modules gen extension source_dir (module_gen : SourceWriter.source_writer->module_def->bool) out_files = List.iter (fun md_def -> let source_dir = gen.gcon.file ^ "/" ^ source_dir ^ "/" ^ (String.concat "/" (fst (path_of_md_def md_def))) in let w = SourceWriter.new_source_writer () in (*let should_write = List.fold_left (fun should md -> module_gen w md or should) false md_def.m_types in*) let should_write = module_gen w md_def in if should_write then begin let path = path_of_md_def md_def in write_file gen w source_dir path extension out_files end ) gen.gmodules let generate_modules_t gen extension source_dir change_path (module_gen : SourceWriter.source_writer->module_type->bool) out_files = let source_dir = gen.gcon.file ^ "/" ^ source_dir in List.iter (fun md -> let w = SourceWriter.new_source_writer () in (*let should_write = List.fold_left (fun should md -> module_gen w md or should) false md_def.m_types in*) let should_write = module_gen w md in if should_write then begin let path = change_path (t_path md) in write_file gen w (source_dir ^ "/" ^ (String.concat "/" (fst path))) path extension out_files; end ) gen.gtypes_list (* various helper functions *) let mk_paren e = match e.eexpr with | TParenthesis _ -> e | _ -> { e with eexpr=TParenthesis(e) } (* private *) let get_real_fun gen t = match follow t with | TFun(args,t) -> TFun(List.map (fun (n,o,t) -> n,o,gen.greal_type t) args, gen.greal_type t) | _ -> t let mk_int gen i pos = { eexpr = TConst(TInt ( Int32.of_int i)); etype = gen.gcon.basic.tint; epos = pos } let mk_return e = { eexpr = TReturn (Some e); etype = e.etype; epos = e.epos } let mk_temp gen name t = incr tmp_count; let name = gen.gmk_internal_name "temp" (name ^ (string_of_int !tmp_count)) in alloc_var name t let v_nativearray = alloc_var "__array__" t_dynamic let mk_nativearray_decl gen t el pos = { eexpr = TCall(mk_local v_nativearray pos, el); etype = gen.gclasses.nativearray t; epos = pos; } let ensure_local gen block name e = match e.eexpr with | TLocal _ -> e | _ -> let var = mk_temp gen name e.etype in block := { e with eexpr = TVar(var, Some e); etype = gen.gcon.basic.tvoid; } :: !block; { e with eexpr = TLocal var } let follow_module follow_func md = match md with | TClassDecl _ | TEnumDecl _ | TAbstractDecl _ -> md | TTypeDecl tdecl -> match (follow_func (TType(tdecl, List.map snd tdecl.t_params))) with | TInst(cl,_) -> TClassDecl cl | TEnum(e,_) -> TEnumDecl e | TType(t,_) -> TTypeDecl t | TAbstract(a,_) -> TAbstractDecl a | _ -> assert false (* hxgen means if the type was generated by haxe. If a type was generated by haxe, it means it will contain special constructs for speedy reflection, for example @see SetHXGen module *) let rec is_hxgen md = match md with | TClassDecl cl -> Meta.has Meta.HxGen cl.cl_meta | TEnumDecl e -> Meta.has Meta.HxGen e.e_meta | TTypeDecl t -> Meta.has Meta.HxGen t.t_meta || ( match follow t.t_type with | TInst(cl,_) -> is_hxgen (TClassDecl cl) | TEnum(e,_) -> is_hxgen (TEnumDecl e) | _ -> false ) | TAbstractDecl a -> Meta.has Meta.HxGen a.a_meta let is_hxgen_t t = match t with | TInst (cl, _) -> Meta.has Meta.HxGen cl.cl_meta | TEnum (e, _) -> Meta.has Meta.HxGen e.e_meta | TAbstract (a, _) -> Meta.has Meta.HxGen a.a_meta | TType (t, _) -> Meta.has Meta.HxGen t.t_meta | _ -> false let mt_to_t_dyn md = match md with | TClassDecl cl -> TInst(cl, List.map (fun _ -> t_dynamic) cl.cl_params) | TEnumDecl e -> TEnum(e, List.map (fun _ -> t_dynamic) e.e_params) | TAbstractDecl a -> TAbstract(a, List.map (fun _ -> t_dynamic) a.a_params) | TTypeDecl t -> TType(t, List.map (fun _ -> t_dynamic) t.t_params) let mt_to_t mt params = match mt with | TClassDecl (cl) -> TInst(cl, params) | TEnumDecl (e) -> TEnum(e, params) | TAbstractDecl a -> TAbstract(a, params) | _ -> assert false let t_to_mt t = match follow t with | TInst(cl, _) -> TClassDecl(cl) | TEnum(e, _) -> TEnumDecl(e) | TAbstract(a, _) -> TAbstractDecl a | _ -> assert false let rec get_last_ctor cl = Option.map_default (fun (super,_) -> if is_some super.cl_constructor then Some(get super.cl_constructor) else get_last_ctor super) None cl.cl_super let add_constructor cl cf = match cl.cl_constructor with | None -> cl.cl_constructor <- Some cf | Some ctor -> if ctor != cf && not (List.memq cf ctor.cf_overloads) then ctor.cf_overloads <- cf :: ctor.cf_overloads (* replace open TMonos with TDynamic *) let rec replace_mono t = match t with | TMono t -> (match !t with | None -> t := Some t_dynamic | Some _ -> ()) | TEnum (_,p) | TInst (_,p) | TType (_,p) | TAbstract (_,p) -> List.iter replace_mono p | TFun (args,ret) -> List.iter (fun (_,_,t) -> replace_mono t) args; replace_mono ret | TAnon _ | TDynamic _ -> () | TLazy f -> replace_mono (!f()) (* helper *) let mk_class_field name t public pos kind params = { cf_name = name; cf_type = t; cf_public = public; cf_pos = pos; cf_doc = None; cf_meta = [ Meta.CompilerGenerated, [], Ast.null_pos ]; (* annotate that this class field was generated by the compiler *) cf_kind = kind; cf_params = params; cf_expr = None; cf_overloads = []; } (* this helper just duplicates the type parameter class, which is assumed that cl is. *) (* This is so we can use class parameters on function parameters, without running the risk of name clash *) (* between both *) let map_param cl = let ret = mk_class cl.cl_module (fst cl.cl_path, snd cl.cl_path ^ "_c") cl.cl_pos in ret.cl_implements <- cl.cl_implements; ret.cl_kind <- cl.cl_kind; ret let get_cl_t t = match follow t with | TInst (cl,_) -> cl | _ -> assert false let mk_class m path pos = let cl = Type.mk_class m path pos in cl.cl_meta <- [ Meta.CompilerGenerated, [], Ast.null_pos ]; cl type tfield_access = | FClassField of tclass * tparams * tclass (* declared class *) * tclass_field * bool (* is static? *) * t (* the actual cf type, in relation to the class type params *) * t (* declared type *) | FEnumField of tenum * tenum_field * bool (* is parameterized enum ? *) | FAnonField of tclass_field | FDynamicField of t | FNotFound let is_var f = match f.cf_kind with | Var _ -> true | _ -> false let find_first_declared_field gen orig_cl ?get_vmtype ?exact_field field = let get_vmtype = match get_vmtype with None -> (fun t -> t) | Some f -> f in let chosen = ref None in let is_overload = ref false in let rec loop_cl depth c tl tlch = (try let ret = PMap.find field c.cl_fields in if Meta.has Meta.Overload ret.cf_meta then is_overload := true; match !chosen, exact_field with | Some(d,f,_,_,_), _ when depth <= d || (is_var ret && not (is_var f)) -> () | _, None -> chosen := Some(depth,ret,c,tl,tlch) | _, Some f2 -> List.iter (fun f -> let declared_t = apply_params c.cl_params tl f.cf_type in if Typeload.same_overload_args ~get_vmtype declared_t f2.cf_type f f2 then chosen := Some(depth,f,c,tl,tlch) ) (ret :: ret.cf_overloads) with | Not_found -> ()); (match c.cl_super with | Some (sup,stl) -> let tl = List.map (apply_params c.cl_params tl) stl in let stl = gen.greal_type_param (TClassDecl sup) stl in let tlch = List.map (apply_params c.cl_params tlch) stl in loop_cl (depth+1) sup tl tlch | None -> ()); if c.cl_interface then List.iter (fun (sup,stl) -> let tl = List.map (apply_params c.cl_params tl) stl in let stl = gen.greal_type_param (TClassDecl sup) stl in let tlch = List.map (apply_params c.cl_params tlch) stl in loop_cl (depth+1) sup tl tlch ) c.cl_implements in loop_cl 0 orig_cl (List.map snd orig_cl.cl_params) (List.map snd orig_cl.cl_params); match !chosen with | None -> None | Some(_,f,c,tl,tlch) -> if !is_overload && not (Meta.has Meta.Overload f.cf_meta) then f.cf_meta <- (Meta.Overload,[],f.cf_pos) :: f.cf_meta; let declared_t = apply_params c.cl_params tl f.cf_type in let params_t = apply_params c.cl_params tlch f.cf_type in let actual_t = match follow params_t with | TFun(args,ret) -> TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret) | _ -> gen.greal_type params_t in Some(f,actual_t,declared_t,params_t,c,tl,tlch) let field_access gen (t:t) (field:string) : (tfield_access) = (* t can be either an haxe-type as a real-type; 'follow' should be applied here since we can generalize that a TType will be accessible as its underlying type. *) (* let pointers to values be accessed as the underlying values *) let t = match gen.greal_type t with | TAbstract({ a_path = ["cs"],"Pointer" },[t]) -> gen.greal_type t | _ -> t in match follow t with | TInst(cl, params) -> let orig_cl = cl in let orig_params = params in let rec not_found cl params = match cl.cl_dynamic with | Some t -> let t = apply_params cl.cl_params params t in FDynamicField t | None -> match cl.cl_super with | None -> FNotFound | Some (super,p) -> not_found super p in let not_found () = try let cf = PMap.find field gen.gbase_class_fields in FClassField (orig_cl, orig_params, gen.gclasses.cl_dyn, cf, false, cf.cf_type, cf.cf_type) with | Not_found -> not_found cl params in (* this is a hack for C#'s different generic types with same path *) let hashtbl_field = (String.concat "" (List.map (fun _ -> "]") cl.cl_params)) ^ field in let types = try Hashtbl.find gen.greal_field_types (orig_cl.cl_path, hashtbl_field) with | Not_found -> let ret = find_first_declared_field gen cl field in let ret = match ret with | None -> None | Some(cf,t,dt,_,cl,_,_) -> Some(cf,t,dt,cl) in if ret <> None then Hashtbl.add gen.greal_field_types (orig_cl.cl_path, hashtbl_field) ret; ret in (match types with | None -> not_found() | Some (cf, actual_t, declared_t, declared_cl) -> FClassField(orig_cl, orig_params, declared_cl, cf, false, actual_t, declared_t)) | TEnum _ | TAbstract _ -> (* enums have no field *) FNotFound | TAnon anon -> (try match !(anon.a_status) with | Statics cl -> let cf = PMap.find field cl.cl_statics in FClassField(cl, List.map (fun _ -> t_dynamic) cl.cl_params, cl, cf, true, cf.cf_type, cf.cf_type) | EnumStatics e -> let f = PMap.find field e.e_constrs in let is_param = match follow f.ef_type with | TFun _ -> true | _ -> false in FEnumField(e, f, is_param) | _ when PMap.mem field gen.gbase_class_fields -> let cf = PMap.find field gen.gbase_class_fields in FClassField(gen.gclasses.cl_dyn, [t_dynamic], gen.gclasses.cl_dyn, cf, false, cf.cf_type, cf.cf_type) | _ -> FAnonField(PMap.find field anon.a_fields) with | Not_found -> FNotFound) | _ when PMap.mem field gen.gbase_class_fields -> let cf = PMap.find field gen.gbase_class_fields in FClassField(gen.gclasses.cl_dyn, [t_dynamic], gen.gclasses.cl_dyn, cf, false, cf.cf_type, cf.cf_type) | TDynamic t -> FDynamicField t | TMono _ -> FDynamicField t_dynamic | _ -> FNotFound let field_access_esp gen t field = match field with | FStatic(cl,cf) | FInstance(cl,_,cf) when Meta.has Meta.Extern cf.cf_meta -> let static = match field with | FStatic _ -> true | _ -> false in let p = match follow (run_follow gen t) with | TInst(_,p) -> p | _ -> List.map snd cl.cl_params in FClassField(cl,p,cl,cf,static,cf.cf_type,cf.cf_type) | _ -> field_access gen t (field_name field) let mk_field_access gen expr field pos = match field_access gen expr.etype field with | FClassField(c,p,dc,cf,false,at,_) -> { eexpr = TField(expr, FInstance(dc,p,cf)); etype = apply_params c.cl_params p at; epos = pos } | FClassField(c,p,dc,cf,true,at,_) -> { eexpr = TField(expr, FStatic(dc,cf)); etype = at; epos = pos } | FAnonField cf -> { eexpr = TField(expr, FAnon cf); etype = cf.cf_type; epos = pos } | FDynamicField t -> { eexpr = TField(expr, FDynamic field); etype = t; epos = pos } | FNotFound -> { eexpr = TField(expr, FDynamic field); etype = t_dynamic; epos = pos } | FEnumField _ -> assert false let mk_iterator_access gen t expr = let pos = expr.epos in let itf = mk_field_access gen expr "iterator" pos in { eexpr = TCall(itf, []); epos = pos; etype = snd (get_fun itf.etype) } (* ******************************************* *) (* Module dependency resolution *) (* ******************************************* *) type t_dependency = | DAfter of float | DBefore of float exception ImpossibleDependency of string let max_dep = 10000.0 let min_dep = - (10000.0) let solve_deps name (deps:t_dependency list) = let vmin = min_dep -. 1.0 in let vmax = max_dep +. 1.0 in let rec loop dep vmin vmax = match dep with | [] -> (if vmin >= vmax then raise (ImpossibleDependency name)); (vmin +. vmax) /. 2.0 | head :: tail -> match head with | DBefore f -> loop tail (max vmin f) vmax | DAfter f -> loop tail vmin (min vmax f) in loop deps vmin vmax (* type resolution *) exception TypeNotFound of path let get_type gen path = try Hashtbl.find gen.gtypes path with | Not_found -> raise (TypeNotFound path) (* ******************************************* *) (* follow all module *) (* ******************************************* *) (* this module will follow each and every type using the rules defined in gen.gfollow. This is a minor helper module, so we don't end up having to follow the same time multiple times in the many filter iterations because of this, it will be one of the first modules to run. *) module FollowAll = struct let follow gen e = let follow_func = gen.gfollow#run_f in Some (Type.map_expr_type (fun e->e) (follow_func) (fun tvar-> tvar.v_type <- (follow_func tvar.v_type); tvar) e) let priority = max_dep (* will add an expression filter as the first filter *) let configure gen = gen.gexpr_filters#add ~name:"follow_all" ~priority:(PCustom(priority)) (follow gen) end;; (* ******************************************* *) (* set hxgen module *) (* ******************************************* *) (* goes through all module types and sets the :hxgen meta on all which then is_hxgen_func returns true. There is a default is_hxgen_func implementation also *) module SetHXGen = struct (* basically, everything that is extern is assumed to not be hxgen, unless meta :hxgen is set, and everything that is not extern is assumed to be hxgen, unless meta :nativegen is set *) let rec default_hxgen_func md = match md with | TClassDecl { cl_kind = KAbstractImpl a } -> default_hxgen_func (TAbstractDecl a) | TClassDecl cl -> let rec is_hxgen_class (c,_) = if c.cl_extern then begin if Meta.has Meta.HxGen c.cl_meta then true else Option.map_default (is_hxgen_class) false c.cl_super || List.exists is_hxgen_class c.cl_implements end else begin if Meta.has Meta.NativeChildren c.cl_meta || Meta.has Meta.NativeGen c.cl_meta then Option.map_default (is_hxgen_class) false c.cl_super || List.exists is_hxgen_class c.cl_implements else let rec has_nativec (c,p) = if is_hxgen_class (c,p) then false else (Meta.has Meta.NativeChildren c.cl_meta && not (Option.map_default is_hxgen_class false c.cl_super || List.exists is_hxgen_class c.cl_implements)) || Option.map_default has_nativec false c.cl_super in if Option.map_default has_nativec false c.cl_super && not (List.exists is_hxgen_class c.cl_implements) then false else true end in is_hxgen_class (cl,[]) | TEnumDecl e -> if e.e_extern then Meta.has Meta.HxGen e.e_meta else not (Meta.has Meta.NativeGen e.e_meta) | TAbstractDecl a when Meta.has Meta.CoreType a.a_meta -> not (Meta.has Meta.NativeGen a.a_meta) | TAbstractDecl a -> (match follow a.a_this with | TInst _ | TEnum _ | TAbstract _ -> default_hxgen_func (t_to_md (follow a.a_this)) | _ -> not (Meta.has Meta.NativeGen a.a_meta)) | TTypeDecl t -> (* TODO see when would we use this *) false (* by now the only option is to run it eagerly, because it must be one of the first filters to run, since many others depend of it *) let run_filter gen is_hxgen_func = let filter md = let meta = if is_hxgen_func md then Meta.HxGen else Meta.NativeGen in begin match md with | TClassDecl cl -> cl.cl_meta <- (meta, [], cl.cl_pos) :: cl.cl_meta | TEnumDecl e -> e.e_meta <- (meta, [], e.e_pos) :: e.e_meta | TTypeDecl t -> t.t_meta <- (meta, [], t.t_pos) :: t.t_meta | TAbstractDecl a -> a.a_meta <- (meta, [], a.a_pos) :: a.a_meta end in List.iter filter gen.gtypes_list end;; (* ******************************************* *) (* overloading reflection constructors *) (* ******************************************* *) (* this module works on languages that support function overloading and enable function hiding via static functions. it takes the constructor body out of the constructor and adds it to a special ctor static function. The static function will receive the same parameters as the constructor, plus the special "me" var, which will replace "this" Then it always adds two constructors to the function: one that receives a special class, indicating that it should be constructed without any parameters, and one that receives its normal constructor. Both will only include a super() call to the superclasses' emtpy constructor. This enables two things: empty construction without the need of incompatibility with the platform's native construction method the ability to call super() constructor in any place in the constructor This will insert itself in the default reflection-related module filter *) module OverloadingConstructor = struct let priority = 0.0 let name = "overloading_constructor" let set_new_create_empty gen empty_ctor_expr = let old = gen.gtools.rf_create_empty in gen.gtools.rf_create_empty <- (fun cl params pos -> if is_hxgen (TClassDecl cl) then { eexpr = TNew(cl,params,[empty_ctor_expr]); etype = TInst(cl,params); epos = pos } else old cl params pos ) let rec cur_ctor c tl = match c.cl_constructor with | Some ctor -> ctor, c, tl | None -> match c.cl_super with | None -> raise Not_found | Some (sup,stl) -> cur_ctor sup (List.map (apply_params c.cl_params tl) stl) let rec prev_ctor c tl = match c.cl_super with | None -> raise Not_found | Some (sup,stl) -> let stl = List.map (apply_params c.cl_params tl) stl in match sup.cl_constructor with | None -> prev_ctor sup stl | Some ctor -> ctor, sup, stl (* replaces super() call with last static constructor call *) let replace_super_call gen name c tl with_params me p = let rec loop_super c tl = match c.cl_super with | None -> raise Not_found | Some(sup,stl) -> let stl = List.map (apply_params c.cl_params tl) stl in try let static_ctor_name = name ^ "_" ^ (String.concat "_" (fst sup.cl_path)) ^ "_" ^ (snd sup.cl_path) in sup, stl, PMap.find static_ctor_name sup.cl_statics with | Not_found -> loop_super sup stl in let sup, stl, cf = loop_super c tl in let with_params = { eexpr = TLocal me; etype = me.v_type; epos = p } :: with_params in let cf = match cf.cf_overloads with (* | [] -> cf *) | _ -> try (* choose best super function *) List.iter (fun e -> replace_mono e.etype) with_params; List.find (fun cf -> replace_mono cf.cf_type; let args, _ = get_fun (apply_params cf.cf_params stl cf.cf_type) in try List.for_all2 (fun (_,_,t) e -> try let e_etype = run_follow gen e.etype in let t = run_follow gen t in unify e_etype t; true with | Unify_error _ -> false) args with_params with | Invalid_argument("List.for_all2") -> false ) (cf :: cf.cf_overloads) with | Not_found -> gen.gcon.error "No suitable overload for the super call arguments was found" p; cf in { eexpr = TCall({ eexpr = TField( mk_classtype_access sup p, FStatic(sup,cf)); etype = apply_params cf.cf_params stl cf.cf_type; epos = p}, with_params); etype = gen.gcon.basic.tvoid; epos = p; } (* will create a static counterpart of 'ctor', and replace its contents to a call to the static version*) let create_static_ctor gen ~empty_ctor_expr cl name ctor = match Meta.has Meta.SkipCtor ctor.cf_meta with | true -> () | false when is_none ctor.cf_expr -> () | false -> let static_ctor_name = name ^ "_" ^ (String.concat "_" (fst cl.cl_path)) ^ "_" ^ (snd cl.cl_path) in (* create the static constructor *) let basic = gen.gcon.basic in let ctor_types = List.map (fun (s,t) -> (s, TInst(map_param (get_cl_t t), []))) cl.cl_params in let me = mk_temp gen "me" (TInst(cl, List.map snd ctor_types)) in me.v_capture <- true; let fn_args, _ = get_fun ctor.cf_type in let ctor_params = List.map snd ctor_types in let fn_type = TFun((me.v_name,false, me.v_type) :: List.map (fun (n,o,t) -> (n,o,apply_params cl.cl_params ctor_params t)) fn_args, basic.tvoid) in let cur_tf_args = match ctor.cf_expr with | Some { eexpr = TFunction(tf) } -> tf.tf_args | _ -> assert false in let changed_tf_args = List.map (fun (v,_) -> (v,None)) cur_tf_args in let local_map = Hashtbl.create (List.length cur_tf_args) in let static_tf_args = (me, None) :: List.map (fun (v,b) -> let new_v = alloc_var v.v_name (apply_params cl.cl_params ctor_params v.v_type) in new_v.v_capture <- v.v_capture; Hashtbl.add local_map v.v_id new_v; (new_v, b) ) cur_tf_args in let static_ctor = mk_class_field static_ctor_name fn_type false ctor.cf_pos (Method MethNormal) ctor_types in (* change ctor contents to reference the 'me' var instead of 'this' *) let actual_super_call = ref None in let rec map_expr ~is_first e = match e.eexpr with | TCall (({ eexpr = TConst TSuper } as tsuper), params) -> (try let params = List.map (fun e -> map_expr ~is_first:false e) params in actual_super_call := Some { e with eexpr = TCall(tsuper, [empty_ctor_expr]) }; replace_super_call gen name cl ctor_params params me e.epos with | Not_found -> (* last static function was not found *) actual_super_call := Some e; if not is_first then gen.gcon.error "Super call must be the first call when extending native types" e.epos; { e with eexpr = TBlock([]) }) | TFunction tf when is_first -> do_map ~is_first:true e | TConst TThis -> mk_local me e.epos | TBlock (fst :: bl) -> let fst = map_expr ~is_first:is_first fst in { e with eexpr = TBlock(fst :: List.map (fun e -> map_expr ~is_first:false e) bl); etype = apply_params cl.cl_params ctor_params e.etype } | _ -> do_map e and do_map ?(is_first=false) e = let do_t = apply_params cl.cl_params ctor_params in let do_v v = try Hashtbl.find local_map v.v_id with | Not_found -> v.v_type <- do_t v.v_type; v in Type.map_expr_type (map_expr ~is_first:is_first) do_t do_v e in let expr = do_map ~is_first:true (get ctor.cf_expr) in let expr = match expr.eexpr with | TFunction(tf) -> { expr with etype = fn_type; eexpr = TFunction({ tf with tf_args = static_tf_args }) } | _ -> assert false in static_ctor.cf_expr <- Some expr; (* add to the statics *) (try let stat = PMap.find static_ctor_name cl.cl_statics in stat.cf_overloads <- static_ctor :: stat.cf_overloads with | Not_found -> cl.cl_ordered_statics <- static_ctor :: cl.cl_ordered_statics; cl.cl_statics <- PMap.add static_ctor_name static_ctor cl.cl_statics); (* change current super call *) match ctor.cf_expr with | Some({ eexpr = TFunction(tf) } as e) -> let block_contents, p = match !actual_super_call with | None -> [], ctor.cf_pos | Some super -> [super], super.epos in let block_contents = block_contents @ [{ eexpr = TCall( { eexpr = TField( mk_classtype_access cl p, FStatic(cl, static_ctor)); etype = apply_params static_ctor.cf_params (List.map snd cl.cl_params) static_ctor.cf_type; epos = p }, [{ eexpr = TConst TThis; etype = TInst(cl, List.map snd cl.cl_params); epos = p }] @ List.map (fun (v,_) -> mk_local v p) cur_tf_args ); etype = basic.tvoid; epos = p }] in ctor.cf_expr <- Some { e with eexpr = TFunction({ tf with tf_expr = { tf.tf_expr with eexpr = TBlock block_contents }; tf_args = changed_tf_args }) } | _ -> assert false (* makes constructors that only call super() for the 'ctor' argument *) let clone_ctors gen ctor sup stl cl = let basic = gen.gcon.basic in let rec clone cf = let ncf = mk_class_field "new" (apply_params sup.cl_params stl cf.cf_type) cf.cf_public cf.cf_pos cf.cf_kind cf.cf_params in let args, ret = get_fun ncf.cf_type in (* single expression: call to super() *) let tf_args = List.map (fun (name,_,t) -> (* the constructor will have no optional arguments, as presumably this will be handled by the underlying expr *) alloc_var name t, None ) args in let super_call = { eexpr = TCall( { eexpr = TConst TSuper; etype = TInst(cl, List.map snd cl.cl_params); epos = ctor.cf_pos }, List.map (fun (v,_) -> mk_local v ctor.cf_pos) tf_args); etype = basic.tvoid; epos = ctor.cf_pos; } in ncf.cf_expr <- Some { eexpr = TFunction { tf_args = tf_args; tf_type = basic.tvoid; tf_expr = mk_block super_call; }; etype = ncf.cf_type; epos = ctor.cf_pos; }; ncf in (* take off createEmpty *) let all = List.filter (fun cf -> replace_mono cf.cf_type; not (Meta.has Meta.SkipCtor cf.cf_meta)) (ctor :: ctor.cf_overloads) in let clones = List.map clone all in match clones with | [] -> (* raise Not_found *) assert false (* should never happen *) | cf :: [] -> cf | cf :: overl -> cf.cf_meta <- (Meta.Overload,[],cf.cf_pos) :: cf.cf_meta; cf.cf_overloads <- overl; cf let rec descends_from_native_or_skipctor cl = not (is_hxgen (TClassDecl cl)) || Meta.has Meta.SkipCtor cl.cl_meta || match cl.cl_super with | None -> false | Some(c,_) -> descends_from_native_or_skipctor c let ensure_super_is_first gen cf = let rec loop e = match e.eexpr with | TBlock (b :: block) -> loop b | TBlock [] | TCall({ eexpr = TConst TSuper },_) -> () | _ -> gen.gcon.error "Types that derive from a native class must have its super() call as the first statement in the constructor" cf.cf_pos in match cf.cf_expr with | None -> () | Some e -> Type.iter loop e (* major restructring made at r6493 *) let configure ~(empty_ctor_type : t) ~(empty_ctor_expr : texpr) ~supports_ctor_inheritance gen = set_new_create_empty gen empty_ctor_expr; let basic = gen.gcon.basic in let should_change cl = not cl.cl_interface && (not cl.cl_extern || is_hxgen (TClassDecl cl)) && (match cl.cl_kind with KAbstractImpl _ -> false | _ -> true) in let static_ctor_name = gen.gmk_internal_name "hx" "ctor" in let msize = List.length gen.gtypes_list in let processed, empty_ctors = Hashtbl.create msize, Hashtbl.create msize in let rec get_last_empty cl = try Hashtbl.find empty_ctors cl.cl_path with | Not_found -> match cl.cl_super with | None -> raise Not_found | Some (sup,_) -> get_last_empty sup in let rec change cl = match Hashtbl.mem processed cl.cl_path with | true -> () | false -> Hashtbl.add processed cl.cl_path true; (* make sure we've processed the super types *) (match cl.cl_super with | Some (super,_) when should_change super && not (Hashtbl.mem processed super.cl_path) -> change super | _ -> ()); (* implement static hx_ctor and reimplement constructors *) (try let ctor = match cl.cl_constructor with | Some ctor -> ctor | None -> try let sctor, sup, stl = prev_ctor cl (List.map snd cl.cl_params) in (* we have a previous constructor. if we support inheritance, exit *) if supports_ctor_inheritance then raise Exit; (* we'll make constructors that will only call super() *) let ctor = clone_ctors gen sctor sup stl cl in cl.cl_constructor <- Some ctor; ctor with | Not_found -> (* create default constructor *) let ctor = mk_class_field "new" (TFun([], basic.tvoid)) false cl.cl_pos (Method MethNormal) [] in ctor.cf_expr <- Some { eexpr = TFunction { tf_args = []; tf_type = basic.tvoid; tf_expr = { eexpr = TBlock[]; etype = basic.tvoid; epos = cl.cl_pos }; }; etype = ctor.cf_type; epos = ctor.cf_pos; }; cl.cl_constructor <- Some ctor; ctor in (* now that we made sure we have a constructor, exit if native gen *) if not (is_hxgen (TClassDecl cl)) || Meta.has Meta.SkipCtor cl.cl_meta then begin if descends_from_native_or_skipctor cl && is_some cl.cl_super then List.iter (fun cf -> ensure_super_is_first gen cf) (ctor :: ctor.cf_overloads); raise Exit end; (* if cl descends from a native class, we cannot use the static constructor strategy *) if descends_from_native_or_skipctor cl && is_some cl.cl_super then List.iter (fun cf -> ensure_super_is_first gen cf) (ctor :: ctor.cf_overloads) else (* now that we have a current ctor, create the static counterparts *) List.iter (fun cf -> create_static_ctor gen ~empty_ctor_expr:empty_ctor_expr cl static_ctor_name cf ) (ctor :: ctor.cf_overloads) with | Exit ->()); (* implement empty ctor *) (try (* now that we made sure we have a constructor, exit if native gen *) if not (is_hxgen (TClassDecl cl)) then raise Exit; (* get first *) let empty_type = TFun(["empty",false,empty_ctor_type],basic.tvoid) in let super = match cl.cl_super with | None -> (* implement empty *) [] | Some (sup,_) -> try ignore (get_last_empty sup); if supports_ctor_inheritance && is_none cl.cl_constructor then raise Exit; [{ eexpr = TCall( { eexpr = TConst TSuper; etype = TInst(cl, List.map snd cl.cl_params); epos = cl.cl_pos }, [ empty_ctor_expr ]); etype = basic.tvoid; epos = cl.cl_pos }] with | Not_found -> try (* super type is native: find super constructor with least arguments *) let sctor, sup, stl = prev_ctor cl (List.map snd cl.cl_params) in let rec loop remaining (best,n) = match remaining with | [] -> best | cf :: r -> let args,_ = get_fun cf.cf_type in if (List.length args) < n then loop r (cf,List.length args) else loop r (best,n) in let args,_ = get_fun sctor.cf_type in let best = loop sctor.cf_overloads (sctor, List.length args) in let args,_ = get_fun (apply_params sup.cl_params stl best.cf_type) in [{ eexpr = TCall( { eexpr = TConst TSuper; etype = TInst(sup, stl); epos = cl.cl_pos }, List.map (fun (n,o,t) -> null t cl.cl_pos) args); etype = basic.tvoid; epos = cl.cl_pos }] with | Not_found -> (* extends native type, but no ctor found *) [] in let ctor = mk_class_field "new" empty_type false cl.cl_pos (Method MethNormal) [] in ctor.cf_expr <- Some { eexpr = TFunction { tf_type = basic.tvoid; tf_args = [alloc_var "empty" empty_ctor_type, None]; tf_expr = { eexpr = TBlock super; etype = basic.tvoid; epos = cl.cl_pos } }; etype = empty_type; epos = cl.cl_pos; }; ctor.cf_meta <- [Meta.SkipCtor, [], ctor.cf_pos]; Hashtbl.add empty_ctors cl.cl_path ctor; match cl.cl_constructor with | None -> cl.cl_constructor <- Some ctor | Some c -> c.cf_overloads <- ctor :: c.cf_overloads with | Exit -> ()); in let module_filter md = match md with | TClassDecl cl when should_change cl && not (Hashtbl.mem processed cl.cl_path) -> change cl; None | _ -> None in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) module_filter end;; (* ******************************************* *) (* init function module *) (* ******************************************* *) (* This module will take proper care of the init function, by taking off all expressions from static vars and putting them in order in the init function. It will also initialize dynamic functions, both by putting them in the constructor and in the init function depends on: (syntax) must run before ExprStatement module (ok) must run before OverloadingCtor module so the constructor can be in the correct place (syntax) must run before FunctionToClass module *) module InitFunction = struct let name = "init_funcs" let priority = solve_deps name [DBefore OverloadingConstructor.priority] let ensure_simple_expr gen e = let rec iter e = match e.eexpr with | TConst _ | TLocal _ | TArray _ | TBinop _ | TField _ | TTypeExpr _ | TParenthesis _ | TCast _ | TCall _ | TNew _ | TUnop _ -> Type.iter iter e | _ -> print_endline (debug_expr e); gen.gcon.error "Expression is too complex for a readonly variable initialization" e.epos in iter e let configure gen should_handle_dynamic_functions readonly_support = let handle_override_dynfun acc e this field = let add_expr = ref None in let v = mk_temp gen ("super_" ^ field) e.etype in v.v_capture <- true; let rec loop e = match e.eexpr with | TField({ eexpr = TConst(TSuper) }, f) -> let n = field_name f in (if n <> field then assert false); let local = mk_local v e.epos in (match !add_expr with | None -> add_expr := Some { e with eexpr = TVar(v, Some this) } | Some _ -> ()); local | TConst TSuper -> assert false | _ -> Type.map_expr loop e in let e = loop e in match !add_expr with | None -> e :: acc | Some add_expr -> add_expr :: e :: acc in let handle_class cl = let init = match cl.cl_init with | None -> [] | Some i -> [i] in let init = List.fold_left (fun acc cf -> match cf.cf_kind, should_handle_dynamic_functions with | (Var v, _) when Meta.has Meta.ReadOnly cf.cf_meta && readonly_support -> if v.v_write <> AccNever && not (Meta.has Meta.CoreApi cl.cl_meta) then gen.gcon.warning "@:readOnly variable declared without `never` setter modifier" cf.cf_pos; (match cf.cf_expr with | None -> gen.gcon.warning "Uninitialized readonly variable" cf.cf_pos; acc | Some e -> ensure_simple_expr gen e; acc) | (Var _, _) | (Method (MethDynamic), true) when not (Type.is_extern_field cf) -> (match cf.cf_expr with | Some e -> (match cf.cf_params with | [] -> let var = { eexpr = TField(mk_classtype_access cl cf.cf_pos, FStatic(cl,cf)); etype = cf.cf_type; epos = cf.cf_pos } in let ret = ({ eexpr = TBinop(Ast.OpAssign, var, e); etype = cf.cf_type; epos = cf.cf_pos; }) in cf.cf_expr <- None; ret :: acc | _ -> let params = List.map (fun _ -> t_dynamic) cf.cf_params in let fn = apply_params cf.cf_params params in let var = { eexpr = TField(mk_classtype_access cl cf.cf_pos, FStatic(cl,cf)); etype = fn cf.cf_type; epos = cf.cf_pos } in let rec change_expr e = Type.map_expr_type (change_expr) fn (fun v -> v.v_type <- fn v.v_type; v) e in let ret = ({ eexpr = TBinop(Ast.OpAssign, var, change_expr e); etype = fn cf.cf_type; epos = cf.cf_pos; }) in cf.cf_expr <- None; ret :: acc ) | None -> acc) | _ -> acc ) init cl.cl_ordered_statics in let init = List.rev init in (match init with | [] -> cl.cl_init <- None | _ -> cl.cl_init <- Some { eexpr = TBlock(init); epos = cl.cl_pos; etype = gen.gcon.basic.tvoid; }); (* FIXME: find a way to tell OverloadingCtors to execute this code even with empty constructors *) if should_handle_dynamic_functions then begin let vars, funs = List.fold_left (fun (acc_vars,acc_funs) cf -> match cf.cf_kind with | Var v when Meta.has Meta.ReadOnly cf.cf_meta && readonly_support -> if v.v_write <> AccNever && not (Meta.has Meta.CoreApi cl.cl_meta) then gen.gcon.warning "@:readOnly variable declared without `never` setter modifier" cf.cf_pos; (match cf.cf_expr with | None -> (acc_vars,acc_funs) | Some e -> ensure_simple_expr gen e; (acc_vars,acc_funs)) | Var _ | Method(MethDynamic) -> let is_var = match cf.cf_kind with | Var _ -> true | _ -> false in (match cf.cf_expr, cf.cf_params with | Some e, [] -> let var = { eexpr = TField({ eexpr = TConst(TThis); epos = cf.cf_pos; etype = TInst(cl, List.map snd cl.cl_params); }, FInstance(cl, List.map snd cl.cl_params, cf)); etype = cf.cf_type; epos = cf.cf_pos } in let ret = ({ eexpr = TBinop(Ast.OpAssign, var, e); etype = cf.cf_type; epos = cf.cf_pos; }) in cf.cf_expr <- None; let is_override = List.memq cf cl.cl_overrides in if is_override then begin cl.cl_ordered_fields <- List.filter (fun f -> f.cf_name <> cf.cf_name) cl.cl_ordered_fields; cl.cl_fields <- PMap.remove cf.cf_name cl.cl_fields; acc_vars, handle_override_dynfun acc_funs ret var cf.cf_name end else if is_var then ret :: acc_vars, acc_funs else acc_vars, ret :: acc_funs | Some e, _ -> let params = List.map (fun _ -> t_dynamic) cf.cf_params in let fn = apply_params cf.cf_params params in let var = { eexpr = TField({ eexpr = TConst(TThis); epos = cf.cf_pos; etype = TInst(cl, List.map snd cl.cl_params); }, FInstance(cl, List.map snd cl.cl_params, cf)); etype = cf.cf_type; epos = cf.cf_pos } in let rec change_expr e = Type.map_expr_type (change_expr) fn (fun v -> v.v_type <- fn v.v_type; v) e in let ret = ({ eexpr = TBinop(Ast.OpAssign, var, change_expr e); etype = fn cf.cf_type; epos = cf.cf_pos; }) in cf.cf_expr <- None; let is_override = List.memq cf cl.cl_overrides in if is_override then begin cl.cl_ordered_fields <- List.filter (fun f -> f.cf_name <> cf.cf_name) cl.cl_ordered_fields; cl.cl_fields <- PMap.remove cf.cf_name cl.cl_fields; acc_vars, handle_override_dynfun acc_funs ret var cf.cf_name end else if is_var then ret :: acc_vars, acc_funs else acc_vars, ret :: acc_funs | None, _ -> acc_vars,acc_funs) | _ -> acc_vars,acc_funs ) ([],[]) cl.cl_ordered_fields in (* let vars = List.rev vars in *) (* let funs = List.rev funs in *) (* see if there is any *) (match vars, funs with | [], [] -> () | _ -> (* if there is, we need to find the constructor *) let ctors = match cl.cl_constructor with | Some ctor -> ctor | None -> try let sctor, sup, stl = OverloadingConstructor.prev_ctor cl (List.map snd cl.cl_params) in let ctor = OverloadingConstructor.clone_ctors gen sctor sup stl cl in cl.cl_constructor <- Some ctor; ctor with | Not_found -> let basic = gen.gcon.basic in let ctor = mk_class_field "new" (TFun([], basic.tvoid)) false cl.cl_pos (Method MethNormal) [] in ctor.cf_expr <- Some { eexpr = TFunction { tf_args = []; tf_type = basic.tvoid; tf_expr = { eexpr = TBlock[]; etype = basic.tvoid; epos = cl.cl_pos }; }; etype = ctor.cf_type; epos = ctor.cf_pos; }; cl.cl_constructor <- Some ctor; ctor in let process ctor = let func = match ctor.cf_expr with | Some({eexpr = TFunction(tf)} as e) -> let rec add_fn e = match e.eexpr with | TBlock(hd :: tl) -> (match hd.eexpr with | TCall({ eexpr = TConst TSuper }, _) -> if not (OverloadingConstructor.descends_from_native_or_skipctor cl) then { e with eexpr = TBlock(vars @ (hd :: (funs @ tl))) } else { e with eexpr = TBlock(hd :: (vars @ funs @ tl)) } | TBlock(_) -> { e with eexpr = TBlock( (add_fn hd) :: tl ) } | _ -> { e with eexpr = TBlock( vars @ funs @ (hd :: tl) ) }) | _ -> Type.concat { e with eexpr = TBlock(vars @ funs) } e in let tf_expr = add_fn (mk_block tf.tf_expr) in { e with eexpr = TFunction({ tf with tf_expr = tf_expr }) } | _ -> assert false in ctor.cf_expr <- Some(func) in List.iter process (ctors :: ctors.cf_overloads) ) end in let mod_filter = function | TClassDecl cl -> (if not cl.cl_extern then handle_class cl); None | _ -> None in gen.gmodule_filters#add ~name:"init_funcs" ~priority:(PCustom priority) mod_filter end;; (* ******************************************* *) (* Dynamic Binop/Unop handler *) (* ******************************************* *) (* On some languages there is limited support for operations on dynamic variables, so those operations must be changed. There are 5 types of binary operators: 1 - can take any variable and returns a bool (== and !=) 2 - can take either a string, or a number and returns either a bool or the underlying type ( >, < for bool and + for returning its type) 3 - take numbers and return a number ( *, /, ...) 4 - take ints and return an int (bit manipulation) 5 - take a bool and returns a bool ( &&, || ...) On the default implementation, type 1 and the plus function will be handled with a function call; Type 2 will be handled with the parameter "compare_handler", which will do something like Reflect.compare(x1, x2); Types 3, 4 and 5 will perform a cast to double, int and bool, which will then be handled normally by the platform Unary operators are the most difficult to handle correctly. With unary operators, there are 2 types: 1 - can take a number, changes and returns the result (++, --, ~) 2 - can take a number (-) or bool (!), and returns the result The first case is much trickier, because it doesn't seem a good idea to change any variable to double just because it is dynamic, but this is how we will handle right now. something like that: var x:Dynamic = 10; x++; will be: object x = 10; x = ((IConvertible)x).ToDouble(null) + 1; depends on: (syntax) must run before expression/statment normalization because it may generate complex expressions must run before OverloadingCtor due to later priority conflicts. Since ExpressionUnwrap is only defined afterwards, we will set this value with absolute values *) module DynamicOperators = struct let name = "dyn_ops" let priority = 0.0 let priority_as_synf = 100.0 (*solve_deps name [DBefore ExpressionUnwrap.priority]*) let abstract_implementation gen ?(handle_strings = true) (should_change:texpr->bool) (equals_handler:texpr->texpr->texpr) (dyn_plus_handler:texpr->texpr->texpr->texpr) (compare_handler:texpr->texpr->texpr) = let get_etype_one e = if like_int e.etype then (gen.gcon.basic.tint, { eexpr = TConst(TInt(Int32.one)); etype = gen.gcon.basic.tint; epos = e.epos }) else (gen.gcon.basic.tfloat, { eexpr = TConst(TFloat("1.0")); etype = gen.gcon.basic.tfloat; epos = e.epos }) in let basic = gen.gcon.basic in let rec run e = match e.eexpr with | TBinop (OpAssignOp op, e1, e2) when should_change e -> (* e1 will never contain another TBinop *) (match e1.eexpr with | TLocal _ -> mk_paren { e with eexpr = TBinop(OpAssign, e1, run { e with eexpr = TBinop(op, e1, e2) }) } | TField _ | TArray _ -> let eleft, rest = match e1.eexpr with | TField(ef, f) -> let v = mk_temp gen "dynop" ef.etype in { e1 with eexpr = TField(mk_local v ef.epos, f) }, [ { eexpr = TVar(v,Some (run ef)); etype = basic.tvoid; epos = ef.epos } ] | TArray(e1a, e2a) -> let v = mk_temp gen "dynop" e1a.etype in let v2 = mk_temp gen "dynopi" e2a.etype in { e1 with eexpr = TArray(mk_local v e1a.epos, mk_local v2 e2a.epos) }, [ { eexpr = TVar(v,Some (run e1a)); etype = basic.tvoid; epos = e1.epos }; { eexpr = TVar(v2, Some (run e2a)); etype = basic.tvoid; epos = e1.epos } ] | _ -> assert false in { e with eexpr = TBlock (rest @ [ { e with eexpr = TBinop(OpAssign, eleft, run { e with eexpr = TBinop(op, eleft, e2) }) } ]); } | _ -> assert false ) | TBinop (OpAssign, e1, e2) | TBinop (OpInterval, e1, e2) -> Type.map_expr run e | TBinop (op, e1, e2) when should_change e-> (match op with | OpEq -> (* type 1 *) equals_handler (run e1) (run e2) | OpNotEq -> (* != -> !equals() *) mk_paren { eexpr = TUnop(Ast.Not, Prefix, (equals_handler (run e1) (run e2))); etype = gen.gcon.basic.tbool; epos = e.epos } | OpAdd -> if handle_strings && (is_string e.etype || is_string e1.etype || is_string e2.etype) then { e with eexpr = TBinop(op, mk_cast gen.gcon.basic.tstring (run e1), mk_cast gen.gcon.basic.tstring (run e2)) } else dyn_plus_handler e (run e1) (run e2) | OpGt | OpGte | OpLt | OpLte -> (* type 2 *) { eexpr = TBinop(op, compare_handler (run e1) (run e2), { eexpr = TConst(TInt(Int32.zero)); etype = gen.gcon.basic.tint; epos = e.epos} ); etype = gen.gcon.basic.tbool; epos = e.epos } | OpMult | OpDiv | OpSub | OpMod -> (* always cast everything to double *) let etype, _ = get_etype_one e in { e with eexpr = TBinop(op, mk_cast etype (run e1), mk_cast etype (run e2)) } | OpBoolAnd | OpBoolOr -> { e with eexpr = TBinop(op, mk_cast gen.gcon.basic.tbool (run e1), mk_cast gen.gcon.basic.tbool (run e2)) } | OpAnd | OpOr | OpXor | OpShl | OpShr | OpUShr -> { e with eexpr = TBinop(op, mk_cast gen.gcon.basic.tint (run e1), mk_cast gen.gcon.basic.tint (run e2)) } | OpAssign | OpAssignOp _ | OpInterval | OpArrow -> assert false) | TUnop (Increment as op, flag, e1) | TUnop (Decrement as op, flag, e1) when should_change e -> (* some naming definitions: * ret => the returning variable * _g => the get body * getvar => the get variable expr This will work like this: - if e1 is a TField, set _g = get body, getvar = (get body).varname - if Prefix, return getvar = getvar + 1.0 - if Postfix, set ret = getvar; getvar = getvar + 1.0; ret; *) let etype, one = get_etype_one e in let op = (match op with Increment -> OpAdd | Decrement -> OpSub | _ -> assert false) in let var, getvar = match e1.eexpr with | TField(fexpr, field) -> let tmp = mk_temp gen "getvar" fexpr.etype in let var = { eexpr = TVar(tmp, Some(run fexpr)); etype = gen.gcon.basic.tvoid; epos = e.epos } in (Some var, { eexpr = TField( { fexpr with eexpr = TLocal(tmp) }, field); etype = etype; epos = e1.epos }) | _ -> (None, e1) in (match flag with | Prefix -> let block = (match var with | Some e -> [e] | None -> []) @ [ mk_cast etype { e with eexpr = TBinop(OpAssign, getvar,{ eexpr = TBinop(op, mk_cast etype getvar, one); etype = etype; epos = e.epos }); etype = getvar.etype; } ] in { eexpr = TBlock(block); etype = etype; epos = e.epos } | Postfix -> let ret = mk_temp gen "ret" etype in let vars = (match var with Some e -> [e] | None -> []) @ [{ eexpr = TVar(ret, Some (mk_cast etype getvar)); etype = gen.gcon.basic.tvoid; epos = e.epos }] in let retlocal = { eexpr = TLocal(ret); etype = etype; epos = e.epos } in let block = vars @ [ { e with eexpr = TBinop(OpAssign, getvar, { eexpr = TBinop(op, retlocal, one); etype = getvar.etype; epos = e.epos }) }; retlocal ] in { eexpr = TBlock(block); etype = etype; epos = e.epos } ) | TUnop (op, flag, e1) when should_change e -> let etype = match op with | Not -> gen.gcon.basic.tbool | _ -> gen.gcon.basic.tint in mk_paren { eexpr = TUnop(op, flag, mk_cast etype (run e1)); etype = etype; epos = e.epos } | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:"dyn_ops" ~priority:(PCustom priority) map let configure_as_synf gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:"dyn_ops" ~priority:(PCustom priority_as_synf) map end;; (* ******************************************* *) (* Dynamic Field Access *) (* ******************************************* *) (* This module will filter every dynamic field access in haxe. On platforms that do not support dynamic access, it is with this that you should replace dynamic calls with x.field / Reflect.setField calls, and guess what - this is the default implemenation! Actually there is a problem with Reflect.setField because it returns void, which is a bad thing for us, so even in the default implementation, the function call should be specified to a Reflect.setField version that returns the value that was set (TODO: should it be separated?) As a plus, the default implementation adds something that doesn't hurt anybody, it looks for TAnon with Statics / EnumStatics field accesses and transforms them into real static calls. This means it will take this var m = Math; for (i in 0...1000) m.cos(10); which is an optimization in dynamic platforms, but performs horribly on strongly typed platforms and transform into: var m = Math; for (i in 0...1000) Math.cos(10); (addendum:) configure_generate_classes will already take care of generating the reflection-enabled class fields and calling abstract_implementation with the right arguments. Also depends on: (ok) must run AFTER Binop/Unop handler - so Unops / Binops are already unrolled *) module DynamicFieldAccess = struct let name = "dynamic_field_access" let priority = solve_deps name [DAfter DynamicOperators.priority] let priority_as_synf = solve_deps name [DAfter DynamicOperators.priority_as_synf] (* is_dynamic (expr) (field_access_expr) (field) : a function that indicates if the field access should be changed change_expr (expr) (field_access_expr) (field) (setting expr) (is_unsafe) : changes the expression call_expr (expr) (field_access_expr) (field) (call_params) : changes a call expression *) let abstract_implementation gen (is_dynamic:texpr->texpr->Type.tfield_access->bool) (change_expr:texpr->texpr->string->texpr option->bool->texpr) (call_expr:texpr->texpr->string->texpr list->texpr) = let rec run e = match e.eexpr with (* class types *) | TField(fexpr, f) when is_some (anon_class fexpr.etype) -> let decl = get (anon_class fexpr.etype) in let name = field_name f in (try match decl with | TClassDecl cl -> let cf = PMap.find name cl.cl_statics in { e with eexpr = TField({ fexpr with eexpr = TTypeExpr decl }, FStatic(cl, cf)) } | TEnumDecl en -> let ef = PMap.find name en.e_constrs in { e with eexpr = TField({ fexpr with eexpr = TTypeExpr decl }, FEnum(en, ef)) } | TAbstractDecl _ -> (* abstracts don't have TFields *) assert false | TTypeDecl _ -> (* anon_class doesn't return TTypeDecl *) assert false with | Not_found -> match f with | FStatic(cl,cf) when Meta.has Meta.Extern cf.cf_meta -> { e with eexpr = TField({ fexpr with eexpr = TTypeExpr decl }, FStatic(cl, cf)) } | _ -> change_expr e { fexpr with eexpr = TTypeExpr decl } (field_name f) None true ) | TField(fexpr, f) when is_dynamic e fexpr (f) -> change_expr e (run fexpr) (field_name f) None true | TCall( { eexpr = TField(_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "field" })) } , [obj; { eexpr = TConst(TString(field)) }] ) -> let t = match gen.greal_type obj.etype with | TDynamic _ | TAnon _ | TMono _ -> t_dynamic | t -> t in change_expr (mk_field_access gen { obj with etype = t } field obj.epos) (run obj) field None false | TCall( { eexpr = TField(_, FStatic({ cl_path = ([], "Reflect") }, { cf_name = "setField" } )) }, [obj; { eexpr = TConst(TString(field)) }; evalue] ) -> change_expr (mk_field_access gen obj field obj.epos) (run obj) field (Some (run evalue)) false | TBinop(OpAssign, ({eexpr = TField(fexpr, f)}), evalue) when is_dynamic e fexpr (f) -> change_expr e (run fexpr) (field_name f) (Some (run evalue)) true | TBinop(OpAssign, { eexpr = TField(fexpr, f) }, evalue) -> (match field_access_esp gen fexpr.etype (f) with | FClassField(_,_,_,cf,false,t,_) when (try PMap.find cf.cf_name gen.gbase_class_fields == cf with Not_found -> false) -> change_expr e (run fexpr) (field_name f) (Some (run evalue)) true | _ -> Type.map_expr run e ) (* #if debug *) | TBinop(OpAssignOp op, ({eexpr = TField(fexpr, f)}), evalue) when is_dynamic e fexpr (f) -> assert false (* this case shouldn't happen *) | TUnop(Increment, _, ({eexpr = TField( ( { eexpr=TLocal(local) } as fexpr ), f)})) | TUnop(Decrement, _, ({eexpr = TField( ( { eexpr=TLocal(local) } as fexpr ), f)})) when is_dynamic e fexpr (f) -> assert false (* this case shouldn't happen *) (* #end *) | TCall( ({ eexpr = TField(fexpr, f) }), params ) when is_dynamic e fexpr (f) -> call_expr e (run fexpr) (field_name f) (List.map run params) | _ -> Type.map_expr run e in run (* this function will already configure with the abstract implementation, and also will create the needed class fields to enable reflection on platforms that don't support reflection. this means it will create the following class methods: - getField(field, isStatic) - gets the value of the field. isStatic - setField - - *) let configure_generate_classes gen optimize (runtime_getset_field:texpr->texpr->string->texpr option->texpr) (runtime_call_expr:texpr->texpr->string->texpr list->texpr) = () let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:"dynamic_field_access" ~priority:(PCustom(priority)) map let configure_as_synf gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:"dynamic_field_access" ~priority:(PCustom(priority_as_synf)) map end;; (* ******************************************* *) (* Closure Detection *) (* ******************************************* *) (* Just a small utility filter that detects when a closure must be created. On the default implementation, this means when a function field is being accessed not via reflection and not to be called instantly dependencies: must run after DynamicFieldAccess, so any TAnon { Statics / EnumStatics } will be changed to the corresponding TTypeExpr *) module FilterClosures = struct let name = "filter_closures" let priority = solve_deps name [DAfter DynamicFieldAccess.priority] let traverse gen (should_change:texpr->string->bool) (filter:texpr->texpr->string->bool->texpr) = let rec run e = match e.eexpr with (*(* this is precisely the only case where we won't even ask if we should change, because it is a direct use of TClosure *) | TCall ( {eexpr = TClosure(e1,s)} as clos, args ) -> { e with eexpr = TCall({ clos with eexpr = TClosure(run e1, s) }, List.map run args ) } | TCall ( clos, args ) -> let rec loop clos = match clos.eexpr with | TClosure(e1,s) -> Some (clos, e1, s) | TParenthesis p -> loop p | _ -> None in let clos = loop clos in (match clos with | Some (clos, e1, s) -> { e with eexpr = TCall({ clos with eexpr = TClosure(run e1, s) }, List.map run args ) } | None -> Type.map_expr run e)*) | TCall({ eexpr = TLocal{ v_name = "__delegate__" } } as local, [del]) -> { e with eexpr = TCall(local, [Type.map_expr run del]) } | TCall(({ eexpr = TField(_, _) } as ef), params) -> { e with eexpr = TCall(Type.map_expr run ef, List.map run params) } | TField(ef, FEnum(en, field)) -> (* FIXME replace t_dynamic with actual enum Anon field *) let ef = run ef in (match follow field.ef_type with | TFun _ when should_change ef field.ef_name -> filter e ef field.ef_name true | _ -> { e with eexpr = TField(ef, FEnum(en,field)) } ) | TField(({ eexpr = TTypeExpr _ } as tf), f) -> (match field_access_esp gen tf.etype (f) with | FClassField(_,_,_,cf,_,_,_) -> (match cf.cf_kind with | Method(MethDynamic) | Var _ -> e | _ when should_change tf cf.cf_name -> filter e tf cf.cf_name true | _ -> e ) | _ -> e) | TField(e1, FClosure (Some _, cf)) when should_change e1 cf.cf_name -> (match cf.cf_kind with | Method MethDynamic | Var _ -> Type.map_expr run e | _ -> filter e (run e1) cf.cf_name false) | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* Dynamic TArray Handling *) (* ******************************************* *) (* In some languages you cannot overload the [] operator, so we need to decide what is kept as TArray and what gets mapped. - in order to do this you must ensure that depends on: (syntax) must run before expression/statment normalization because it may generate complex expressions (ok) must run before binop transformations because it may generate some untreated binop ops (ok) must run before dynamic field access is transformed into reflection *) module TArrayTransform = struct let name = "dyn_tarray" let priority = solve_deps name [DBefore DynamicOperators.priority; DBefore DynamicFieldAccess.priority] let priority_as_synf = solve_deps name [DBefore DynamicOperators.priority_as_synf; DBefore DynamicFieldAccess.priority_as_synf] (* should change signature: tarray expr -> binop operation -> should change? *) let default_implementation gen (should_change:texpr->Ast.binop option->bool) (get_fun:string) (set_fun:string) = let basic = gen.gcon.basic in let mk_get e e1 e2 = let efield = mk_field_access gen e1 get_fun e.epos in { e with eexpr = TCall(efield, [e2]) } in let mk_set e e1 e2 evalue = let efield = mk_field_access gen e1 set_fun e.epos in { e with eexpr = TCall(efield, [e2; evalue]) } in let rec run e = match e.eexpr with | TArray(e1, e2) -> (* e1 should always be a var; no need to map there *) if should_change e None then mk_get e (run e1) (run e2) else Type.map_expr run e | TBinop (Ast.OpAssign, ({ eexpr = TArray(e1a,e2a) } as earray), evalue) when should_change earray (Some Ast.OpAssign) -> mk_set e (run e1a) (run e2a) (run evalue) | TBinop (Ast.OpAssignOp op,({ eexpr = TArray(e1a,e2a) } as earray) , evalue) when should_change earray (Some (Ast.OpAssignOp op)) -> (* cache all arguments in vars so they don't get executed twice *) (* let ensure_local gen block name e = *) let block = ref [] in let arr_local = ensure_local gen block "array" (run e1a) in let idx_local = ensure_local gen block "index" (run e2a) in block := (mk_set e arr_local idx_local ( { e with eexpr=TBinop(op, mk_get earray arr_local idx_local, run evalue) } )) :: !block; { e with eexpr = TBlock (List.rev !block) } | TUnop(op, flag, ({ eexpr = TArray(e1a, e2a) } as earray)) -> if should_change earray None && match op with | Not | Neg -> false | _ -> true then begin let block = ref [] in let actual_t = match op with | Ast.Increment | Ast.Decrement -> (match follow earray.etype with | TInst _ | TAbstract _ | TEnum _ -> earray.etype | _ -> basic.tfloat) | Ast.Not -> basic.tbool | _ -> basic.tint in let val_v = mk_temp gen "arrVal" actual_t in let ret_v = mk_temp gen "arrRet" actual_t in let arr_local = ensure_local gen block "arr" (run e1a) in let idx_local = ensure_local gen block "arrIndex" (run e2a) in let val_local = { earray with eexpr = TLocal(val_v) } in let ret_local = { earray with eexpr = TLocal(ret_v) } in (* var idx = 1; var val = x._get(idx); var ret = val++; x._set(idx, val); ret; *) block := { eexpr = TVar(val_v, Some(mk_get earray arr_local idx_local)); (* var val = x._get(idx) *) etype = gen.gcon.basic.tvoid; epos = e2a.epos } :: !block; block := { eexpr = TVar(ret_v, Some { e with eexpr = TUnop(op, flag, val_local) }); (* var ret = val++ *) etype = gen.gcon.basic.tvoid; epos = e2a.epos } :: !block; block := (mk_set e arr_local idx_local val_local) (*x._set(idx,val)*) :: !block; block := ret_local :: !block; { e with eexpr = TBlock (List.rev !block) } end else Type.map_expr run e | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:"dyn_tarray" ~priority:(PCustom priority) map let configure_as_synf gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:"dyn_tarray" ~priority:(PCustom priority_as_synf) map end;; (* ******************************************* *) (* Try / Catch + throw native types handling *) (* ******************************************* *) (* Some languages/vm's do not support throwing any kind of value. For them, only special kinds of objects can be thrown. Because of this, we must wrap some throw statements with an expression, and also we must unwrap it on the catch() phase, and maybe manually test with Std.is() dependencies: must run before dynamic field access (?) TODO review It's a syntax filter, as it alters types (throw wrapper) *) module TryCatchWrapper = struct let priority = solve_deps "try_catch" [DBefore DynamicFieldAccess.priority] (* should_wrap : does the type should be wrapped? This of course works on the reverse way, so it tells us if the type should be unwrapped as well wrap_throw : the wrapper for throw (throw expr->expr inside throw->returning wrapped expression) unwrap_expr : the other way around : given the catch var (maybe will need casting to wrapper_type) , return the unwrap expr rethrow_expr : how to rethrow ane exception in the platform catchall_type : the class used for catchall (e:Dynamic) wrapper_type : the wrapper type, so we can test if exception is of type 'wrapper' catch_map : maps the catch expression to include some intialization code (e.g. setting up Stack.exceptionStack) *) let traverse gen (should_wrap:t->bool) (wrap_throw:texpr->texpr->texpr) (unwrap_expr:tvar->pos->texpr) (rethrow_expr:texpr->texpr) (catchall_type:t) (wrapper_type:t) (catch_map:tvar->texpr->texpr) = let rec run e = match e.eexpr with | TThrow texpr when should_wrap texpr.etype -> wrap_throw e (run texpr) | TTry (ttry, catches) -> let nowrap_catches, must_wrap_catches, catchall = List.fold_left (fun (nowrap_catches, must_wrap_catches, catchall) (v, catch) -> (* first we'll see if the type is Dynamic (catchall) *) match follow v.v_type with | TDynamic _ -> assert (is_none catchall); (nowrap_catches, must_wrap_catches, Some(v,run catch)) (* see if we should unwrap it *) | _ when should_wrap (follow v.v_type) -> (nowrap_catches, (v,run catch) :: must_wrap_catches, catchall) | _ -> ( (v,catch_map v (run catch)) :: nowrap_catches, must_wrap_catches, catchall ) ) ([], [], None) catches in (* temp (?) fix for https://github.com/HaxeFoundation/haxe/issues/4134 *) let must_wrap_catches = List.rev must_wrap_catches in (* 1st catch all nowrap "the easy way" 2nd see if there are any must_wrap or catchall. If there is, do a catchall first with a temp var. then get catchall var (as dynamic) (or create one), and declare it = catchall exception then test if it is of type wrapper_type. If it is, unwrap it then start doing Std.is() tests for each catch type if there is a catchall in the end, end with it. If there isn't, rethrow *) let dyn_catch = match (catchall, must_wrap_catches) with | Some (v,c), _ | _, (v, c) :: _ -> let pos = c.epos in let temp_var = mk_temp gen "catchallException" catchall_type in let temp_local = { eexpr=TLocal(temp_var); etype = temp_var.v_type; epos = pos } in let catchall_var = (*match catchall with | None -> *) mk_temp gen "catchall" t_dynamic (*| Some (v,_) -> v*) in let catchall_decl = { eexpr = TVar(catchall_var, Some(temp_local)); etype=gen.gcon.basic.tvoid; epos = pos } in let catchall_local = { eexpr = TLocal(catchall_var); etype = t_dynamic; epos = pos } in (* if it is of type wrapper_type, unwrap it *) let std_is = mk_static_field_access (get_cl (get_type gen ([],"Std"))) "is" (TFun(["v",false,t_dynamic;"cl",false,mt_to_t (get_type gen ([], "Class")) [t_dynamic]],gen.gcon.basic.tbool)) pos in let mk_std_is t pos = { eexpr = TCall(std_is, [catchall_local; mk_mt_access (t_to_mt t) pos]); etype = gen.gcon.basic.tbool; epos = pos } in let if_is_wrapper_expr = { eexpr = TIf(mk_std_is wrapper_type pos, { eexpr = TBinop(OpAssign, catchall_local, unwrap_expr temp_var pos); etype = t_dynamic; epos = pos } , None); etype = gen.gcon.basic.tvoid; epos = pos } in let rec loop must_wrap_catches = match must_wrap_catches with | (vcatch,catch) :: tl -> { eexpr = TIf(mk_std_is vcatch.v_type catch.epos, { eexpr = TBlock({ eexpr=TVar(vcatch, Some(mk_cast vcatch.v_type catchall_local)); etype=gen.gcon.basic.tvoid; epos=catch.epos } :: [catch] ); etype = catch.etype; epos = catch.epos }, Some (loop tl)); etype = catch.etype; epos = catch.epos } | [] -> match catchall with | Some (v,s) -> Type.concat { eexpr = TVar(v, Some(catchall_local)); etype = gen.gcon.basic.tvoid; epos = pos } s | None -> mk_block (rethrow_expr temp_local) in [ ( temp_var, catch_map temp_var { e with eexpr = TBlock([ catchall_decl; if_is_wrapper_expr; loop must_wrap_catches ]) } ) ] | _ -> [] in { e with eexpr = TTry(run ttry, (List.rev nowrap_catches) @ dyn_catch) } | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:"try_catch" ~priority:(PCustom priority) map end;; let fun_args = List.map (function | (v,s) -> (v.v_name, (match s with | None -> false | Some _ -> true), v.v_type)) (* ******************************************* *) (* Closures To Class *) (* ******************************************* *) (* This is a very important filter. It will take all anonymous functions from the AST, will search for all captured variables, and will create a class that implements an abstract interface for calling functions. This is very important for targets that don't support anonymous functions to work correctly. Also it is possible to implement some strategies to avoid value type boxing, such as NaN tagging or double/object arguments. All this will be abstracted away from this interface. dependencies: must run after dynamic field access, because of conflicting ways to deal with invokeField (module filter) must run after OverloadingCtor so we can also change the dynamic function expressions uses TArray expressions for array. TODO see interaction uses TThrow expressions. *) module ClosuresToClass = struct let name = "closures_to_class" let priority = solve_deps name [ DAfter DynamicFieldAccess.priority ] let priority_as_synf = solve_deps name [ DAfter DynamicFieldAccess.priority_as_synf ] type closures_ctx = { fgen : generator_ctx; mutable func_class : tclass; (* this is what will actually turn the function into class field. The standard implementation by default will already take care of creating the class, and setting the captured variables. It will also return the super arguments to be called *) mutable closure_to_classfield : tfunc->t->pos->tclass_field * (texpr list); (* when a dynamic function call is made, we need to convert it as if it were calling the dynamic function interface. TCall expr -> new TCall expr *) mutable dynamic_fun_call : texpr->texpr; (* called once so the implementation can make one of a time initializations in the base class for all functions *) mutable initialize_base_class : tclass->unit; (* Base classfields are the class fields for the abstract implementation of either the Function implementation, or the invokeField implementation for the classes They will either try to call the right function or will fail with (tclass - subject (so we know the type of this)) -> is_function_base -> additional arguments for each function (at the beginning) -> list of the abstract implementation class fields *) mutable get_base_classfields_for : tclass->bool->(unit->(tvar * tconstant option) list)->tclass_field list; (* This is a more complex version of get_base_classfields_for. It's meant to provide a toolchain so we can easily create classes that extend Function and add more functionality on top of it. arguments: tclass -> subject (so we know the type of this) bool -> is it a function type ( int -> (int->t->tconstant option->texpr) -> ( (tvar * tconstant option) list * texpr) ) int -> current arity of the function whose member will be mapped; -1 for dynamic function. It is guaranteed that dynamic function will be called last t -> the return type of the function (int->t->tconstant option->texpr) -> api to get exprs that unwrap arguments correctly int -> argument wanted to unwrap t -> solicited type tconstant option -> map to this default value if null returns a texpr that tells how the default should return a list with additional arguments (only works if is_function_base = true) and the underlying function expression *) mutable map_base_classfields : tclass->bool->( int -> t -> (tvar list) -> (int->t->tconstant option->texpr) -> ( (tvar * tconstant option) list * texpr) )->tclass_field list; mutable transform_closure : texpr->texpr->string->texpr; } type map_info = { in_unsafe : bool; in_unused : bool; } let null_map_info = { in_unsafe = false; in_unused = false; } (* the default implementation will take 3 transformation functions: * one that will transform closures that are not called immediately (instance.myFunc). normally on this case it's best to have a runtime handler that will take the instance, the function and call its invokeField when invoked * one that will actually handle the anonymous functions themselves. * one that will transform calling a dynamic function. So for example, dynFunc(arg1, arg2) might turn into dynFunc.apply2(arg1, arg2); ( suspended ) * an option to match papplied functions * handling parameterized anonymous function declaration (optional - tparam_anon_decl and tparam_anon_acc) *) let rec cleanup_delegate e = match e.eexpr with | TParenthesis e | TMeta(_,e) | TCast(e,_) -> cleanup_delegate e | _ -> e let funct gen t = match follow (run_follow gen t) with | TFun(args,ret) -> args,ret | _ -> raise Not_found let mk_conversion_fun gen e = let args, ret = funct gen e.etype in let tf_args = List.map (fun (n,o,t) -> alloc_var n t,None) args in let block, local = match e.eexpr with | TLocal v -> v.v_capture <- true; [],e | _ -> let tmp = mk_temp gen "delegate_conv" e.etype in tmp.v_capture <- true; [{ eexpr = TVar(tmp,Some e); etype = gen.gcon.basic.tvoid; epos = e.epos }], mk_local tmp e.epos in let body = { eexpr = TCall(local, List.map (fun (v,_) -> mk_local v e.epos) tf_args); etype = ret; epos = e.epos; } in let body = if not (is_void ret) then { body with eexpr = TReturn( Some body ) } else body in let body = { eexpr = TBlock(block @ [body]); etype = body.etype; epos = body.epos; } in { tf_args = tf_args; tf_expr = body; tf_type = ret; } let traverse gen ?tparam_anon_decl ?tparam_anon_acc (transform_closure:texpr->texpr->string->texpr) (handle_anon_func:texpr->tfunc->map_info->t option->texpr) (dynamic_func_call:texpr->texpr) e = let info = ref null_map_info in let rec run e = match e.eexpr with | TCast({ eexpr = TCall({ eexpr = TLocal{ v_name = "__delegate__" } } as local, [del] ) } as e2, _) -> let e2 = { e2 with etype = e.etype } in let replace_delegate ex = { e with eexpr = TCast({ e2 with eexpr = TCall(local, [ex]) }, None) } in (* found a delegate; let's see if it's a closure or not *) let clean = cleanup_delegate del in (match clean.eexpr with | TField( ef, (FClosure _ as f)) | TField( ef, (FStatic _ as f)) -> (* a closure; let's leave this unchanged for FilterClosures to handle it *) replace_delegate { clean with eexpr = TField( run ef, f ) } | TFunction tf -> (* handle like we'd handle a normal function, but create an unchanged closure field for it *) let ret = handle_anon_func clean { tf with tf_expr = run tf.tf_expr } !info (Some e.etype) in replace_delegate ret | _ -> try let tf = mk_conversion_fun gen del in let ret = handle_anon_func del { tf with tf_expr = run tf.tf_expr } !info (Some e.etype) in replace_delegate ret with Not_found -> gen.gcon.error "This delegate construct is unsupported" e.epos; replace_delegate (run clean)) | TCall(({ eexpr = TLocal{ v_name = "__unsafe__" } } as local), [arg]) -> let old = !info in info := { !info with in_unsafe = true }; let arg2 = run arg in info := old; { e with eexpr = TCall(local,[arg2]) } (* parameterized functions handling *) | TVar(vv, ve) -> (match tparam_anon_decl with | None -> Type.map_expr run e | Some tparam_anon_decl -> (match (vv, ve) with | ({ v_extra = Some( _ :: _, _) } as v), Some ({ eexpr = TFunction tf } as f) | ({ v_extra = Some( _ :: _, _) } as v), Some { eexpr = TArrayDecl([{ eexpr = TFunction tf } as f]) | TCall({ eexpr = TLocal { v_name = "__array__" } }, [{ eexpr = TFunction tf } as f]) } -> (* captured transformation *) ignore(tparam_anon_decl v f { tf with tf_expr = run tf.tf_expr }); { e with eexpr = TBlock([]) } | _ -> Type.map_expr run { e with eexpr = TVar(vv, ve) }) ) | TLocal ({ v_extra = Some( _ :: _, _) } as v) | TArray ({ eexpr = TLocal ({ v_extra = Some( _ :: _, _) } as v) }, _) -> (* captured transformation *) (match tparam_anon_acc with | None -> Type.map_expr run e | Some tparam_anon_acc -> tparam_anon_acc v e) | TCall( { eexpr = TField(_, FEnum _) }, _ ) -> Type.map_expr run e (* if a TClosure is being call immediately, there's no need to convert it to a TClosure *) | TCall(( { eexpr = TField(ecl,f) } as e1), params) -> (* check to see if called field is known and if it is a MethNormal (only MethNormal fields can be called directly) *) (* let name = field_name f in *) (match field_access_esp gen (gen.greal_type ecl.etype) f with | FClassField(_,_,_,cf,_,_,_) -> (match cf.cf_kind with | Method MethNormal | Method MethInline -> { e with eexpr = TCall({ e1 with eexpr = TField(run ecl, f) }, List.map run params) } | _ -> match gen.gfollow#run_f e1.etype with | TFun _ -> dynamic_func_call { e with eexpr = TCall(run e1, List.map run params) } | _ -> let i = ref 0 in let t = TFun(List.map (fun e -> incr i; "arg" ^ (string_of_int !i), false, e.etype) params, e.etype) in dynamic_func_call { e with eexpr = TCall( mk_cast t (run e1), List.map run params ) } ) (* | FNotFound -> { e with eexpr = TCall({ e1 with eexpr = TField(run ecl, f) }, List.map run params) } (* expressions by now may have generated invalid expressions *) *) | _ -> match gen.gfollow#run_f e1.etype with | TFun _ -> dynamic_func_call { e with eexpr = TCall(run e1, List.map run params) } | _ -> let i = ref 0 in let t = TFun(List.map (fun e -> incr i; "arg" ^ (string_of_int !i), false, e.etype) params, e.etype) in dynamic_func_call { e with eexpr = TCall( mk_cast t (run e1), List.map run params ) } ) | TField(ecl, FClosure (_,cf)) -> transform_closure e (run ecl) cf.cf_name | TFunction tf -> handle_anon_func e { tf with tf_expr = run tf.tf_expr } !info None | TCall({ eexpr = TConst(TSuper) }, _) -> Type.map_expr run e | TCall({ eexpr = TLocal(v) }, args) when String.get v.v_name 0 = '_' && Hashtbl.mem gen.gspecial_vars v.v_name -> Type.map_expr run e | TCall(tc,params) -> let i = ref 0 in let may_cast = match gen.gfollow#run_f tc.etype with | TFun _ -> fun e -> e | _ -> let t = TFun(List.map (fun e -> incr i; ("p" ^ (string_of_int !i), false, e.etype) ) params, e.etype) in fun e -> mk_cast t e in dynamic_func_call { e with eexpr = TCall(run (may_cast tc), List.map run params) } | _ -> Type.map_expr run e in (match e.eexpr with | TFunction(tf) -> Type.map_expr run e | _ -> run e) let rec get_type_params acc t = match t with | TInst(( { cl_kind = KTypeParameter _ } as cl), []) -> if List.memq cl acc then acc else cl :: acc | TFun (params,tret) -> List.fold_left get_type_params acc ( tret :: List.map (fun (_,_,t) -> t) params ) | TDynamic t -> (match t with | TDynamic _ -> acc | _ -> get_type_params acc t) | TAbstract (a, pl) when not (Meta.has Meta.CoreType a.a_meta) -> get_type_params acc ( Abstract.get_underlying_type a pl) | TAnon a -> PMap.fold (fun cf acc -> let params = List.map (fun (_,t) -> match follow t with | TInst(c,_) -> c | _ -> assert false) cf.cf_params in List.filter (fun t -> not (List.memq t params)) (get_type_params acc cf.cf_type) ) a.a_fields acc | TType(_, []) | TAbstract (_, []) | TInst(_, []) | TEnum(_, []) -> acc | TType(_, params) | TAbstract(_, params) | TEnum(_, params) | TInst(_, params) -> List.fold_left get_type_params acc params | TMono r -> (match !r with | Some t -> get_type_params acc t | None -> acc) | _ -> get_type_params acc (follow_once t) let get_captured expr = let ret = Hashtbl.create 1 in let ignored = Hashtbl.create 0 in let params = ref [] in let check_params t = params := get_type_params !params t in let rec traverse expr = match expr.eexpr with | TFor (v, _, _) -> Hashtbl.add ignored v.v_id v; check_params v.v_type; Type.iter traverse expr | TFunction(tf) -> List.iter (fun (v,_) -> Hashtbl.add ignored v.v_id v) tf.tf_args; (match follow expr.etype with | TFun(args,ret) -> List.iter (fun (_,_,t) -> check_params t ) args; check_params ret | _ -> ()); Type.iter traverse expr | TVar (v, opt) -> (match v.v_extra with | Some(_ :: _, _) -> () | _ -> check_params v.v_type); Hashtbl.add ignored v.v_id v; ignore(Option.map traverse opt) | TLocal { v_extra = Some( (_ :: _ ),_) } -> () | TLocal(( { v_capture = true } ) as v) -> (if not (Hashtbl.mem ignored v.v_id || Hashtbl.mem ret v.v_id) then begin check_params v.v_type; Hashtbl.replace ret v.v_id expr end); | _ -> Type.iter traverse expr in traverse expr; ret, !params (* OPTIMIZEME: Take off from Codegen the code that wraps captured variables, traverse through all variables, looking for their use (just like local_usage) three possible outcomes for captured variables: - become a function member variable <- best performance. Will not work on functions that can be created more than once (functions inside a loop or functions inside functions) The function will have to be created on top of the block, so its variables can be filled in instead of being declared - single-element array - the most compatible way, though also creates a slight overhead. - we'll have some labels for captured variables: - used in loop *) (* The default implementation will impose a naming convention: invoke(arity)_(o for returning object/d for returning double) when arity < max_arity invoke_dynamic_(o/d) when arity > max_arity This means that it also imposes that the dynamic function return types may only be Dynamic or Float, and all other basic types must be converted to/from it. *) let default_implementation ft parent_func_class (* e.g. new haxe.lang.ClassClosure *) = let gen = ft.fgen in ft.initialize_base_class parent_func_class; let cfs = ft.get_base_classfields_for parent_func_class true (fun () -> []) in List.iter (fun cf -> (if cf.cf_name = "new" then parent_func_class.cl_constructor <- Some cf else parent_func_class.cl_fields <- PMap.add cf.cf_name cf parent_func_class.cl_fields ) ) cfs; parent_func_class.cl_ordered_fields <- (List.filter (fun cf -> cf.cf_name <> "new") cfs) @ parent_func_class.cl_ordered_fields; ft.func_class <- parent_func_class; let handle_anon_func fexpr tfunc mapinfo delegate_type : texpr * (tclass * texpr list) = let gen = ft.fgen in let in_unsafe = mapinfo.in_unsafe || match gen.gcurrent_class, gen.gcurrent_classfield with | Some c, _ when Meta.has Meta.Unsafe c.cl_meta -> true | _, Some cf when Meta.has Meta.Unsafe cf.cf_meta -> true | _ -> false in (* get all captured variables it uses *) let captured_ht, tparams = get_captured fexpr in let captured = Hashtbl.fold (fun _ e acc -> e :: acc) captured_ht [] in let captured = List.sort (fun e1 e2 -> match e1, e2 with | { eexpr = TLocal v1 }, { eexpr = TLocal v2 } -> compare v1.v_name v2.v_name | _ -> assert false) captured in (*let cltypes = List.map (fun cl -> (snd cl.cl_path, TInst(map_param cl, []) )) tparams in*) let cltypes = List.map (fun cl -> (snd cl.cl_path, TInst(cl, []) )) tparams in (* create a new class that extends abstract function class, with a ctor implementation that will setup all captured variables *) let cfield = match ft.fgen.gcurrent_classfield with | None -> "Anon" | Some cf -> cf.cf_name in let cur_line = Lexer.get_error_line fexpr.epos in let path = (fst ft.fgen.gcurrent_path, Printf.sprintf "%s_%s_%d__Fun" (snd ft.fgen.gcurrent_path) cfield cur_line) in let cls = mk_class (get ft.fgen.gcurrent_class).cl_module path tfunc.tf_expr.epos in if in_unsafe then cls.cl_meta <- (Meta.Unsafe,[],Ast.null_pos) :: cls.cl_meta; if Common.defined gen.gcon Define.EraseGenerics then begin cls.cl_meta <- (Meta.HaxeGeneric,[],Ast.null_pos) :: cls.cl_meta end; cls.cl_module <- (get ft.fgen.gcurrent_class).cl_module; cls.cl_params <- cltypes; let mk_this v pos = { (mk_field_access gen { eexpr = TConst TThis; etype = TInst(cls, List.map snd cls.cl_params); epos = pos } v.v_name pos) with etype = v.v_type } in let mk_this_assign v pos = { eexpr = TBinop(OpAssign, mk_this v pos, { eexpr = TLocal(v); etype = v.v_type; epos = pos }); etype = v.v_type; epos = pos } in (* mk_class_field name t public pos kind params *) let ctor_args, ctor_sig, ctor_exprs = List.fold_left (fun (ctor_args, ctor_sig, ctor_exprs) lexpr -> match lexpr.eexpr with | TLocal(v) -> let cf = mk_class_field v.v_name v.v_type false lexpr.epos (Var({ v_read = AccNormal; v_write = AccNormal; })) [] in cls.cl_fields <- PMap.add v.v_name cf cls.cl_fields; cls.cl_ordered_fields <- cf :: cls.cl_ordered_fields; let ctor_v = alloc_var v.v_name v.v_type in ((ctor_v, None) :: ctor_args, (v.v_name, false, v.v_type) :: ctor_sig, (mk_this_assign v cls.cl_pos) :: ctor_exprs) | _ -> assert false ) ([],[],[]) captured in (* change all captured variables to this.capturedVariable *) let rec change_captured e = match e.eexpr with | TLocal( ({ v_capture = true }) as v ) when Hashtbl.mem captured_ht v.v_id -> mk_this v e.epos | _ -> Type.map_expr change_captured e in let func_expr = change_captured tfunc.tf_expr in let invokecf, invoke_field, super_args = match delegate_type with | None -> (* no delegate *) let ifield, sa = ft.closure_to_classfield { tfunc with tf_expr = func_expr } fexpr.etype fexpr.epos in ifield,ifield,sa | Some _ -> let pos = cls.cl_pos in let cf = mk_class_field "Delegate" (TFun(fun_args tfunc.tf_args, tfunc.tf_type)) true pos (Method MethNormal) [] in cf.cf_expr <- Some { fexpr with eexpr = TFunction { tfunc with tf_expr = func_expr }; }; cf.cf_meta <- (Meta.Final,[],pos) :: cf.cf_meta; cls.cl_ordered_fields <- cf :: cls.cl_ordered_fields; cls.cl_fields <- PMap.add cf.cf_name cf cls.cl_fields; (* invoke function body: call Delegate function *) let ibody = { eexpr = TCall({ eexpr = TField({ eexpr = TConst TThis; etype = TInst(cls, List.map snd cls.cl_params); epos = pos; }, FInstance(cls, List.map snd cls.cl_params, cf)); etype = cf.cf_type; epos = pos; }, List.map (fun (v,_) -> mk_local v pos) tfunc.tf_args); etype = tfunc.tf_type; epos = pos } in let ibody = if not (is_void tfunc.tf_type) then { ibody with eexpr = TReturn( Some ibody ) } else ibody in let ifield, sa = ft.closure_to_classfield { tfunc with tf_expr = ibody } fexpr.etype fexpr.epos in cf,ifield,sa in (* create the constructor *) (* todo properly abstract how type var is set *) cls.cl_super <- Some(parent_func_class, []); let pos = cls.cl_pos in let super_call = { eexpr = TCall({ eexpr = TConst(TSuper); etype = TInst(parent_func_class,[]); epos = pos }, super_args); etype = ft.fgen.gcon.basic.tvoid; epos = pos; } in let ctor_type = (TFun(ctor_sig, ft.fgen.gcon.basic.tvoid)) in let ctor = mk_class_field "new" ctor_type true cls.cl_pos (Method(MethNormal)) [] in ctor.cf_expr <- Some( { eexpr = TFunction( { tf_args = ctor_args; tf_type = ft.fgen.gcon.basic.tvoid; tf_expr = { eexpr = TBlock(super_call :: ctor_exprs); etype = ft.fgen.gcon.basic.tvoid; epos = cls.cl_pos } }); etype = ctor_type; epos = cls.cl_pos; }); cls.cl_constructor <- Some(ctor); (* add invoke function to the class *) cls.cl_ordered_fields <- invoke_field :: cls.cl_ordered_fields; cls.cl_fields <- PMap.add invoke_field.cf_name invoke_field cls.cl_fields; cls.cl_overrides <- invoke_field :: cls.cl_overrides; (* add this class to the module with gadd_to_module *) ft.fgen.gadd_to_module (TClassDecl(cls)) priority; (* if there are no captured variables, we can create a cache so subsequent calls don't need to create a new function *) let expr, clscapt = match captured, tparams with | [], [] -> let cache_var = ft.fgen.gmk_internal_name "hx" "current" in let cache_cf = mk_class_field cache_var (TInst(cls,[])) false func_expr.epos (Var({ v_read = AccNormal; v_write = AccNormal })) [] in cls.cl_ordered_statics <- cache_cf :: cls.cl_ordered_statics; cls.cl_statics <- PMap.add cache_var cache_cf cls.cl_statics; (* if (FuncClass.hx_current != null) FuncClass.hx_current; else (FuncClass.hx_current = new FuncClass()); *) (* let mk_static_field_access cl field fieldt pos = *) let hx_current = mk_static_field_access cls cache_var (TInst(cls,[])) func_expr.epos in let pos = func_expr.epos in { fexpr with eexpr = TIf( { eexpr = TBinop(OpNotEq, hx_current, null (TInst(cls,[])) pos); etype = ft.fgen.gcon.basic.tbool; epos = pos; }, hx_current, Some( { eexpr = TBinop(OpAssign, hx_current, { fexpr with eexpr = TNew(cls, [], captured) }); etype = (TInst(cls,[])); epos = pos; })) }, (cls,captured) | _ -> (* change the expression so it will be a new "added class" ( captured variables arguments ) *) { fexpr with eexpr = TNew(cls, List.map (fun cl -> TInst(cl,[])) tparams, List.rev captured) }, (cls,captured) in match delegate_type with | None -> expr,clscapt | Some _ -> { eexpr = TField(expr, FClosure(Some (cls,[]),invokecf)); (* TODO: FClosure change *) etype = invokecf.cf_type; epos = cls.cl_pos }, clscapt in let tvar_to_cdecl = Hashtbl.create 0 in traverse ft.fgen ~tparam_anon_decl:(fun v e fn -> let _, info = handle_anon_func e fn null_map_info None in Hashtbl.add tvar_to_cdecl v.v_id info ) ~tparam_anon_acc:(fun v e -> try let cls, captured = Hashtbl.find tvar_to_cdecl v.v_id in let types = match v.v_extra with | Some(t,_) -> t | _ -> assert false in let monos = List.map (fun _ -> mk_mono()) types in let vt = match follow v.v_type with | TInst(_, [v]) -> v | v -> v in let et = match follow e.etype with | TInst(_, [v]) -> v | v -> v in let original = apply_params types monos vt in unify et original; let monos = List.map (fun t -> apply_params types (List.map (fun _ -> t_dynamic) types) t) monos in let same_cl t1 t2 = match follow t1, follow t2 with | TInst(c,_), TInst(c2,_) -> c == c2 | _ -> false in let passoc = List.map2 (fun (_,t) m -> t,m) types monos in let cltparams = List.map (fun (_,t) -> try snd (List.find (fun (t2,_) -> same_cl t t2) passoc) with | Not_found -> t) cls.cl_params in { e with eexpr = TNew(cls, cltparams, captured) } with | Not_found -> gen.gcon.warning "This expression may be invalid" e.epos; e | Unify_error el -> List.iter (fun el -> gen.gcon.warning (Typecore.unify_error_msg (print_context()) el) e.epos) el; gen.gcon.warning "This expression may be invalid" e.epos; e ) (* (transform_closure:texpr->texpr->string->texpr) (handle_anon_func:texpr->tfunc->texpr) (dynamic_func_call:texpr->texpr->texpr list->texpr) *) ft.transform_closure (fun e f info delegate_type -> fst (handle_anon_func e f info delegate_type)) ft.dynamic_fun_call (* (dynamic_func_call:texpr->texpr->texpr list->texpr) *) let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:name ~priority:(PCustom priority) map let configure_as_synf gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority_as_synf) map (* this submodule will provide the default implementation for the C# and Java targets. it will have two return types: double and dynamic, and *) module DoubleAndDynamicClosureImpl = struct let get_ctx gen max_arity = let basic = gen.gcon.basic in let func_args_i i = let rec loop i (acc) = if i = 0 then (acc) else begin let vfloat = alloc_var (gen.gmk_internal_name "fn" ("float" ^ string_of_int i)) basic.tfloat in let vdyn = alloc_var (gen.gmk_internal_name "fn" ("dyn" ^ string_of_int i)) t_dynamic in loop (i - 1) ((vfloat, None) :: (vdyn, None) :: acc) end in loop i [] in let args_real_to_func args = let arity = List.length args in if arity >= max_arity then [ alloc_var (gen.gmk_internal_name "fn" "dynargs") (basic.tarray t_dynamic), None ] else func_args_i arity in let func_sig_i i = let rec loop i acc = if i = 0 then acc else begin let vfloat = gen.gmk_internal_name "fn" ("float" ^ string_of_int i) in let vdyn = gen.gmk_internal_name "fn" ("dyn" ^ string_of_int i) in loop (i - 1) ( (vfloat,false,basic.tfloat) :: (vdyn,false,t_dynamic) :: acc ) end in loop i [] in let args_real_to_func_sig args = let arity = List.length args in if arity >= max_arity then [gen.gmk_internal_name "fn" "dynargs", false, basic.tarray t_dynamic] else begin func_sig_i arity end in let rettype_real_to_func t = match run_follow gen t with | TType({ t_path = [],"Null" }, _) -> 0,t_dynamic | _ when like_float t && not (like_i64 t) -> (1, basic.tfloat) | _ -> (0, t_dynamic) in let args_real_to_func_call el (pos:Ast.pos) = if List.length el >= max_arity then [{ eexpr = TArrayDecl el; etype = basic.tarray t_dynamic; epos = pos }] else begin List.fold_left (fun acc e -> if like_float (gen.greal_type e.etype) && not (like_i64 (gen.greal_type e.etype)) then ( e :: undefined e.epos :: acc ) else ( null basic.tfloat e.epos :: e :: acc ) ) ([]) (List.rev el) end in let const_type c def = match c with | TString _ -> basic.tstring | TInt _ -> basic.tint | TFloat _ -> basic.tfloat | TBool _ -> basic.tbool | _ -> def in let get_args_func args changed_args pos = let arity = List.length args in let mk_const const elocal t = match const with | None -> mk_cast t elocal | Some const -> { eexpr = TIf( { elocal with eexpr = TBinop(Ast.OpEq, elocal, null elocal.etype elocal.epos); etype = basic.tbool }, { elocal with eexpr = TConst(const); etype = const_type const t }, Some ( mk_cast t elocal ) ); etype = t; epos = elocal.epos } in if arity >= max_arity then begin let varray = match changed_args with | [v,_] -> v | _ -> assert false in let varray_local = mk_local varray pos in let mk_varray i = { eexpr = TArray(varray_local, { eexpr = TConst(TInt(Int32.of_int i)); etype = basic.tint; epos = pos }); etype = t_dynamic; epos = pos } in snd (List.fold_left (fun (count,acc) (v,const) -> (count + 1, { eexpr = TVar(v, Some(mk_const const ( mk_varray count ) v.v_type)); etype = basic.tvoid; epos = pos; } :: acc) ) (0,[]) args) end else begin let _, dyn_args, float_args = List.fold_left (fun (count,fargs, dargs) arg -> if count land 1 = 0 then (count + 1, fargs, arg :: dargs) else (count + 1, arg :: fargs, dargs) ) (1,[],[]) (List.rev changed_args) in let rec loop acc args fargs dargs = match args, fargs, dargs with | [], [], [] -> acc | (v,const) :: args, (vf,_) :: fargs, (vd,_) :: dargs -> let acc = { eexpr = TVar(v, Some( { eexpr = TIf( { eexpr = TBinop(Ast.OpEq, mk_local vd pos, undefined pos); etype = basic.tbool; epos = pos }, mk_cast v.v_type (mk_local vf pos), Some ( mk_const const (mk_local vd pos) v.v_type ) ); etype = v.v_type; epos = pos } )); etype = basic.tvoid; epos = pos } :: acc in loop acc args fargs dargs | _ -> assert false in loop [] args float_args dyn_args end in let closure_to_classfield tfunc old_sig pos = (* change function signature *) let old_args = tfunc.tf_args in let changed_args = args_real_to_func old_args in (* FIXME properly handle int64 cases, which will break here (because of inference to int) UPDATE: the fix will be that Int64 won't be a typedef to Float/Int *) let changed_sig, arity, type_number, changed_sig_ret, is_void, is_dynamic_func = match follow old_sig with | TFun(_sig, ret) -> let type_n, ret_t = rettype_real_to_func ret in let arity = List.length _sig in let is_dynamic_func = arity >= max_arity in let ret_t = if is_dynamic_func then t_dynamic else ret_t in (TFun(args_real_to_func_sig _sig, ret_t), arity, type_n, ret_t, is_void ret, is_dynamic_func) | _ -> (print_endline (s_type (print_context()) (follow old_sig) )); assert false in let tf_expr = if is_void then begin let rec map e = match e.eexpr with | TReturn None -> { e with eexpr = TReturn (Some (null t_dynamic e.epos)) } | _ -> Type.map_expr map e in let e = mk_block (map tfunc.tf_expr) in match e.eexpr with | TBlock(bl) -> { e with eexpr = TBlock(bl @ [{ eexpr = TReturn (Some (null t_dynamic e.epos)); etype = t_dynamic; epos = e.epos }]) } | _ -> assert false end else tfunc.tf_expr in let changed_sig_ret = if is_dynamic_func then t_dynamic else changed_sig_ret in (* get real arguments on top of function body *) let get_args = get_args_func tfunc.tf_args changed_args pos in (* FIXME HACK: in order to be able to run the filters that have already ran for this piece of code, we will cheat and run it as if it was the whole code We could just make ClosuresToClass run before TArrayTransform, but we cannot because of the dependency between ClosuresToClass (after DynamicFieldAccess, and before TArrayTransform) maybe a way to solve this would be to add an "until" field to run_from *) let real_get_args = gen.gexpr_filters#run_f { eexpr = TBlock(get_args); etype = basic.tvoid; epos = pos } in let func_expr = Type.concat real_get_args tf_expr in (* set invoke function *) (* todo properly abstract how naming for invoke is made *) let invoke_name = if is_dynamic_func then "invokeDynamic" else ("invoke" ^ (string_of_int arity) ^ (if type_number = 0 then "_o" else "_f")) in let invoke_name = gen.gmk_internal_name "hx" invoke_name in let invoke_field = mk_class_field invoke_name changed_sig false func_expr.epos (Method(MethNormal)) [] in let invoke_fun = { eexpr = TFunction( { tf_args = changed_args; tf_type = changed_sig_ret; tf_expr = func_expr; }); etype = changed_sig; epos = func_expr.epos; } in invoke_field.cf_expr <- Some(invoke_fun); (invoke_field, [ { eexpr = TConst(TInt( Int32.of_int arity )); etype = gen.gcon.basic.tint; epos = pos }; { eexpr = TConst(TInt( Int32.of_int type_number )); etype = gen.gcon.basic.tint; epos = pos }; ]) in let dynamic_fun_call call_expr = let tc, params = match call_expr.eexpr with | TCall(tc, params) -> (tc, params) | _ -> assert false in let ct = gen.greal_type call_expr.etype in let postfix, ret_t = if like_float ct && not (like_i64 ct) then "_f", gen.gcon.basic.tfloat else "_o", t_dynamic in let params_len = List.length params in let ret_t = if params_len >= max_arity then t_dynamic else ret_t in let invoke_fun = if params_len >= max_arity then "invokeDynamic" else "invoke" ^ (string_of_int params_len) ^ postfix in let invoke_fun = gen.gmk_internal_name "hx" invoke_fun in let fun_t = match follow tc.etype with | TFun(_sig, _) -> TFun(args_real_to_func_sig _sig, ret_t) | _ -> let i = ref 0 in let _sig = List.map (fun p -> let name = "arg" ^ (string_of_int !i) in incr i; (name,false,p.etype) ) params in TFun(args_real_to_func_sig _sig, ret_t) in let may_cast = match follow call_expr.etype with | TAbstract ({ a_path = ([], "Void") },[]) -> (fun e -> e) | _ -> mk_cast call_expr.etype in may_cast { eexpr = TCall( { (mk_field_access gen { tc with etype = gen.greal_type tc.etype } invoke_fun tc.epos) with etype = fun_t }, args_real_to_func_call params call_expr.epos ); etype = ret_t; epos = call_expr.epos } in let iname is_function i is_float = let postfix = if is_float then "_f" else "_o" in gen.gmk_internal_name "hx" ("invoke" ^ (if not is_function then "Field" else "") ^ string_of_int i) ^ postfix in let map_base_classfields cl is_function map_fn = let pos = cl.cl_pos in let this_t = TInst(cl,List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let mk_invoke_i i is_float = let cf = mk_class_field (iname is_function i is_float) (TFun(func_sig_i i, if is_float then basic.tfloat else t_dynamic)) false pos (Method MethNormal) [] in cf in let type_name = gen.gmk_internal_name "fn" "type" in let dynamic_arg = alloc_var (gen.gmk_internal_name "fn" "dynargs") (basic.tarray t_dynamic) in let mk_invoke_complete_i i is_float = (* let arity = i in *) let args = func_args_i i in (* api fn *) (* only cast if needed *) let mk_cast tto efrom = gen.ghandle_cast (gen.greal_type tto) (gen.greal_type efrom.etype) efrom in let api i t const = let vf, _ = List.nth args (i * 2) in let vo, _ = List.nth args (i * 2 + 1) in let needs_cast, is_float = match t, like_float t && not (like_i64 t) with | TAbstract({ a_path = ([], "Float") },[]), _ -> false, true | _, true -> true, true | _ -> false,false in let olocal = mk_local vo pos in let flocal = mk_local vf pos in let get_from_obj e = match const with | None -> mk_cast t e | Some tc -> { eexpr = TIf( { eexpr = TBinop(Ast.OpEq, olocal, null t_dynamic pos); etype = basic.tbool; epos = pos } , { eexpr = TConst(tc); etype = t; epos = pos }, Some (mk_cast t e) ); etype = t; epos = pos; } in { eexpr = TIf( { eexpr = TBinop(Ast.OpEq, olocal, undefined pos); etype = basic.tbool; epos = pos }, (if needs_cast then mk_cast t flocal else flocal), Some ( get_from_obj olocal ) ); etype = t; epos = pos } in (* end of api fn *) let ret = if is_float then basic.tfloat else t_dynamic in let added_args, fn_expr = map_fn i ret (List.map fst args) api in let args = added_args @ args in let t = TFun(fun_args args, ret) in let tfunction = { eexpr = TFunction({ tf_args = args; tf_type = ret; tf_expr = mk_block fn_expr }); etype = t; epos = pos; } in let cf = mk_invoke_i i is_float in cf.cf_expr <- Some tfunction; cf in let rec loop i cfs = if i < 0 then cfs else begin (*let mk_invoke_complete_i i is_float =*) (mk_invoke_complete_i i false) :: (mk_invoke_complete_i i true) :: (loop (i-1) cfs) end in let cfs = loop max_arity [] in let added_s_args, switch = let api i t const = match i with | -1 -> mk_local dynamic_arg pos | _ -> mk_cast t { eexpr = TArray( mk_local dynamic_arg pos, { eexpr = TConst(TInt(Int32.of_int i)); etype = basic.tint; epos = pos }); etype = t; epos = pos; } in map_fn (-1) t_dynamic [dynamic_arg] api in let args = added_s_args @ [dynamic_arg, None] in let dyn_t = TFun(fun_args args, t_dynamic) in let dyn_cf = mk_class_field (gen.gmk_internal_name "hx" "invokeDynamic") dyn_t false pos (Method MethNormal) [] in dyn_cf.cf_expr <- Some { eexpr = TFunction({ tf_args = args; tf_type = t_dynamic; tf_expr = mk_block switch }); etype = dyn_t; epos = pos; }; let additional_cfs = if is_function then begin let new_t = TFun(["arity", false, basic.tint; "type", false, basic.tint],basic.tvoid) in let new_cf = mk_class_field "new" (new_t) true pos (Method MethNormal) [] in let v_arity, v_type = alloc_var "arity" basic.tint, alloc_var "type" basic.tint in let mk_assign v field = { eexpr = TBinop(Ast.OpAssign, mk_this field v.v_type, mk_local v pos); etype = v.v_type; epos = pos } in let arity_name = gen.gmk_internal_name "hx" "arity" in new_cf.cf_expr <- Some { eexpr = TFunction({ tf_args = [v_arity, None; v_type, None]; tf_type = basic.tvoid; tf_expr = { eexpr = TBlock([ mk_assign v_type type_name; mk_assign v_arity arity_name ]); etype = basic.tvoid; epos = pos; } }); etype = new_t; epos = pos; } ; [ new_cf; mk_class_field type_name basic.tint true pos (Var { v_read = AccNormal; v_write = AccNormal }) []; mk_class_field arity_name basic.tint true pos (Var { v_read = AccNormal; v_write = AccNormal }) []; ] end else [] in dyn_cf :: (additional_cfs @ cfs) in (* maybe another param for prefix *) let get_base_classfields_for cl is_function mk_additional_args = let pos = cl.cl_pos in let this_t = TInst(cl,List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let rec mk_dyn_call arity api = let zero = { eexpr = TConst(TFloat("0.0")); etype = basic.tfloat; epos = pos } in let rec loop i acc = if i = 0 then acc else begin let arr = api (i-1) t_dynamic None in loop (i - 1) (zero :: arr :: acc) end in loop arity ([]) in let mk_invoke_switch i (api:(int->t->tconstant option->texpr)) = let t = TFun(func_sig_i i,t_dynamic) in (* case i: return this.invokeX_o(0, 0, 0, 0, 0, ... arg[0], args[1]....); *) ( [{ eexpr = TConst(TInt(Int32.of_int i)); etype = basic.tint; epos = pos }], { eexpr = TReturn(Some( { eexpr = TCall(mk_this (iname is_function i false) t, mk_dyn_call i api); etype = t_dynamic; epos = pos; } )); etype = t_dynamic; epos = pos; } ) in let cl_t = TInst(cl,List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = cl_t; epos = pos } in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let mk_int i = { eexpr = TConst(TInt ( Int32.of_int i)); etype = basic.tint; epos = pos } in let mk_string s = { eexpr = TConst(TString s); etype = basic.tstring; epos = pos } in (* if it is the Function class, the base class fields will be * hx::invokeX_d|o (where X is from 0 to max_arity) (args) { if (this.type == 0|1) return invokeX_o|d(args); else throw "Invalid number of arguments." } hx::invokeDynamic, which will work in the same way new(arity, type) { if (type != 0 && type != 1) throw "Invalid type"; this.arity = arity; this.type = type; } *) let type_name = gen.gmk_internal_name "fn" "type" in let mk_expr i is_float vars = let name = if is_function then "invoke" else "invokeField" in let look_ahead = alloc_var "lookAhead" basic.tbool in let add_args = if not is_function then mk_additional_args() else [] in let vars = if not is_function then (List.map fst add_args) @ (look_ahead :: vars) else vars in let call_expr = let call_t = TFun(List.map (fun v -> (v.v_name, false, v.v_type)) vars, if is_float then t_dynamic else basic.tfloat) in { eexpr = TCall(mk_this (gen.gmk_internal_name "hx" (name ^ (string_of_int i) ^ (if is_float then "_o" else "_f"))) call_t, List.map (fun v -> if v.v_id = look_ahead.v_id then ( { eexpr = TConst(TBool false); etype = basic.tbool; epos = pos } ) else mk_local v pos) vars ); etype = if is_float then t_dynamic else basic.tfloat; epos = pos } in (*let call_expr = if is_float then mk_cast basic.tfloat call_expr else call_expr in*) let if_cond = if is_function then { eexpr=TBinop(Ast.OpNotEq, mk_this type_name basic.tint, mk_int (if is_float then 0 else 1) ); etype = basic.tbool; epos = pos } else mk_local look_ahead pos in let if_expr = if is_function then { eexpr = TIf(if_cond, { eexpr = TThrow(mk_string "Wrong number of arguments"); etype = basic.tstring; epos = pos }, Some( { eexpr = TReturn( Some( call_expr ) ); etype = call_expr.etype; epos = pos } ) ); etype = t_dynamic; epos = pos; } else { eexpr = TIf(if_cond, { eexpr = TReturn( Some( call_expr ) ); etype = call_expr.etype; epos = pos }, Some( { eexpr = TThrow(mk_string "Field not found or wrong number of arguments"); etype = basic.tstring; epos = pos } ) ); etype = t_dynamic; epos = pos; } in let args = if not is_function then (mk_additional_args()) @ [look_ahead, None] else [] in (args, if_expr) in let arities_processed = Hashtbl.create 10 in let max_arity = ref 0 in let rec loop_cases api arity acc = if arity < 0 then acc else loop_cases api (arity - 1) (mk_invoke_switch arity api :: acc) in (* let rec loop goes here *) let map_fn cur_arity fun_ret_type vars (api:(int->t->tconstant option->texpr)) = let is_float = like_float fun_ret_type && not (like_i64 fun_ret_type) in match cur_arity with | -1 -> let dynargs = api (-1) (t_dynamic) None in let switch_cond = mk_field_access gen dynargs "length" pos in let switch_cond = { eexpr = TIf( { eexpr = TBinop(Ast.OpEq, dynargs, null dynargs.etype pos); etype = basic.tbool; epos = pos; }, { eexpr = TConst(TInt(Int32.zero)); etype = basic.tint; epos = pos }, Some switch_cond); etype = basic.tint; epos = pos; } in let switch = { eexpr = TSwitch( switch_cond, loop_cases api !max_arity [], Some({ eexpr = TThrow(mk_string "Too many arguments"); etype = basic.tvoid; epos = pos; }) ); etype = basic.tvoid; epos = pos; } in ( (if not is_function then mk_additional_args () else []), switch ) | _ -> if not (Hashtbl.mem arities_processed cur_arity) then begin Hashtbl.add arities_processed cur_arity true; if cur_arity > !max_arity then max_arity := cur_arity end; mk_expr cur_arity is_float vars in map_base_classfields cl is_function map_fn in let initialize_base_class cl = () in { fgen = gen; func_class = null_class; closure_to_classfield = closure_to_classfield; dynamic_fun_call = dynamic_fun_call; (* called once so the implementation can make one of a time initializations in the base class for all functions *) initialize_base_class = initialize_base_class; (* Base classfields are the class fields for the abstract implementation of either the Function implementation, or the invokeField implementation for the classes They will either try to call the right function or will fail with (tclass - subject (so we know the type of this)) -> is_function_base -> list of the abstract implementation class fields *) get_base_classfields_for = get_base_classfields_for; map_base_classfields = map_base_classfields; (* for now we won't deal with the closures. They can be dealt with the module ReflectionCFs, or a custom implementation *) transform_closure = (fun tclosure texpr str -> tclosure); } end;; end;; (* ******************************************* *) (* Type Parameters *) (* ******************************************* *) (* This module will handle type parameters. There are lots of changes we need to do to correctly support type parameters: traverse will: V Detect when parameterized function calls are made * Detect when a parameterized class instance is being cast to another parameter * Change new<> parameterized function calls * extras: * On languages that support "real" type parameters, a Cast function is provided that will convert from a to the requested type. This cast will call createEmpty with the correct type, and then set each variable to the new form. Some types will be handled specially, namely the Native Array. Other implementations may be delegated to the runtime. * parameterized classes will implement a new interface (with only a Cast<> function added to it), so we can access the type parameter for them. Also any reference to will be replaced by a reference to this interface. (also on TTypeExpr - Std.is()) * Type parameter renaming to avoid name clash * Detect type parameter casting and call Cast<> instead for java: * for specially assigned classes, parameters will be replaced by _d and _i versions of parameterized functions. This will only work for parameterized classes, not functions. dependencies: must run after casts are detected. This will be ensured at CastDetect module. *) module TypeParams = struct let name = "type_params" let priority = max_dep -. 20. let rec deep_follow gen t = match run_follow gen t with | TInst(c,tl) -> TInst(c,List.map (deep_follow gen) tl) | TEnum(e,tl) -> TEnum(e,List.map (deep_follow gen) tl) | TAbstract(a,tl) -> TAbstract(a,List.map (deep_follow gen) tl) | TType(t,tl) -> TType(t,List.map (deep_follow gen) tl) | TFun(args,ret) -> TFun(List.map (fun (n,o,t) -> n,o,deep_follow gen t) args, deep_follow gen ret) | t -> t (* this function will receive the original function argument, the applied function argument and the original function parameters. *) (* from this info, it will infer the applied tparams for the function *) (* this function is used by CastDetection module *) let infer_params gen pos (original_args:((string * bool * t) list * t)) (applied_args:((string * bool * t) list * t)) (params:(string * t) list) calls_parameters_explicitly : tparams = match params with | [] -> [] | _ -> let args_list args = (if not calls_parameters_explicitly then t_dynamic else snd args) :: (List.map (fun (n,o,t) -> t) (fst args)) in let monos = List.map (fun _ -> mk_mono()) params in let original = args_list (get_fun (apply_params params monos (TFun(fst original_args,snd original_args)))) in let applied = args_list applied_args in (try List.iter2 (fun a o -> let o = deep_follow gen o in let a = deep_follow gen a in unify a o (* type_eq EqStrict a o *) ) applied original (* unify applied original *) with | Unify_error el -> (* List.iter (fun el -> gen.gcon.warning (Typecore.unify_error_msg (print_context()) el) pos) el; *) gen.gcon.warning ("This expression may be invalid") pos | Invalid_argument("List.map2") -> gen.gcon.warning ("This expression may be invalid") pos ); List.map (fun t -> match follow t with | TMono _ -> t_empty | t -> t ) monos (* ******************************************* *) (* Real Type Parameters Module *) (* ******************************************* *) (* This submodule is by now specially made for the .NET platform. There might be other targets that will make use of this, but it IS very specific. On the .NET platform, generics are real specialized classes that are JIT compiled. For this reason, we cannot cast from one type parameter to another. Also there is no common type for the type parameters, so for example an instance of type Array will return false for instance is Array . So we need to: 1. create a common interface (without type parameters) (e.g. "Array") which will only contain a __Cast<> function, which will cast from one type into another 2. Implement the __Cast function. This part is a little hard, as we must identify all type parameter-dependent fields contained in the class and convert them. In most cases the conversion will just be to call .__Cast<>() on the instances, or just a simple cast. But when the instance is a @:nativegen type, there will be no .__Cast function, and we will need to deal with this case either at compile-time (added handlers - specially for NativeArray), or at runtime (adding new runtime handlers) 3. traverse the AST looking for casts involving type parameters, and replace them with .__Cast<>() calls. If type is @:nativegen, throw a warning. If really casting from one type parameter to another on a @:nativegen context, throw an error. special literals: it will use the special literal __typehandle__ that the target must implement in order to run this. This literal is a way to get the typehandle of e.g. the type parameters, so we can compare them. In C# it's the equivalent of typeof(T).TypeHandle (TypeHandle compare is faster than System.Type.Equals()) dependencies: (module filter) Interface creation must run AFTER enums are converted into classes, otherwise there is no way to tell parameterized enums to implement an interface Must run AFTER CastDetect. This will be ensured per CastDetect *) module RealTypeParams = struct let name = "real_type_params" let priority = priority let cast_field_name = "cast" let rec has_type_params t = match follow t with | TInst( { cl_kind = KTypeParameter _ }, _) -> true | TAbstract(_, params) | TEnum(_, params) | TInst(_, params) -> List.exists (fun t -> has_type_params t) params | TFun(args,ret) -> List.exists (fun (n,o,t) -> has_type_params t) args || has_type_params ret | _ -> false let rec follow_all_md md = let t = match md with | TClassDecl { cl_kind = KAbstractImpl a } -> TAbstract(a, List.map snd a.a_params) | TClassDecl c -> TInst(c, List.map snd c.cl_params) | TEnumDecl e -> TEnum(e, List.map snd e.e_params) | TTypeDecl t -> TType(t, List.map snd t.t_params) | TAbstractDecl a -> TAbstract(a, List.map snd a.a_params) in Abstract.follow_with_abstracts t let rec is_hxgeneric md = match md with | TClassDecl { cl_kind = KAbstractImpl a } -> is_hxgeneric (TAbstractDecl a) | TClassDecl(cl) -> not (Meta.has Meta.NativeGeneric cl.cl_meta) | TEnumDecl(e) -> not (Meta.has Meta.NativeGeneric e.e_meta) | TAbstractDecl(a) when Meta.has Meta.NativeGeneric a.a_meta -> not (Meta.has Meta.NativeGeneric a.a_meta) | md -> match follow_all_md md with | TInst(cl,_) -> is_hxgeneric (TClassDecl cl) | TEnum(e,_) -> is_hxgeneric (TEnumDecl e) | TAbstract(a,_) -> not (Meta.has Meta.NativeGeneric a.a_meta) | _ -> true let rec set_hxgeneric gen mds isfirst md = let path = t_path md in if List.exists (fun m -> path = t_path m) mds then begin if isfirst then None (* we still can't determine *) else Some true (* if we're in second pass and still can't determine, it's because it can be hxgeneric *) end else begin let has_unresolved = ref false in let is_false v = match v with | Some false -> true | None -> has_unresolved := true; false | Some true -> false in let mds = md :: mds in match md with | TClassDecl(cl) -> (* first see if any meta is present (already processed) *) if Meta.has Meta.NativeGeneric cl.cl_meta then Some false else if Meta.has Meta.HaxeGeneric cl.cl_meta then Some true else if cl.cl_params = [] && is_hxgen md then (cl.cl_meta <- (Meta.HaxeGeneric,[],cl.cl_pos) :: cl.cl_meta; Some true) else if cl.cl_params = [] then (cl.cl_meta <- (Meta.NativeGeneric, [], cl.cl_pos) :: cl.cl_meta; Some false) else if not (is_hxgen md) then (cl.cl_meta <- (Meta.NativeGeneric, [], cl.cl_pos) :: cl.cl_meta; Some false) else begin (* if it's not present, see if any superclass is nativegeneric. nativegeneric is inherited, while hxgeneric can be later changed to nativegeneric *) (* on the first pass, our job is to find any evidence that makes it not be hxgeneric. Otherwise it will be hxgeneric *) match cl.cl_super with | Some (c,_) when is_false (set_hxgeneric gen mds isfirst (TClassDecl c)) -> cl.cl_meta <- (Meta.NativeGeneric, [], cl.cl_pos) :: cl.cl_meta; Some false | _ -> (* see if it's a generic class *) match cl.cl_params with | [] -> (* if it's not, then it will follow hxgen *) if is_hxgen (TClassDecl cl) then cl.cl_meta <- (Meta.HaxeGeneric, [], cl.cl_pos) :: cl.cl_meta else cl.cl_meta <- (Meta.NativeGeneric, [], cl.cl_pos) :: cl.cl_meta; Some true | _ -> (* if it is, loop through all fields + statics and look for non-hxgeneric generic classes that have KTypeParameter as params *) let rec loop cfs = match cfs with | [] -> false | cf :: cfs -> let t = follow (gen.greal_type cf.cf_type) in match t with | TInst( { cl_kind = KTypeParameter _ }, _ ) -> loop cfs | TInst(cl,p) when has_type_params t && is_false (set_hxgeneric gen mds isfirst (TClassDecl cl)) -> if not (Hashtbl.mem gen.gtparam_cast cl.cl_path) then true else loop cfs | TEnum(e,p) when has_type_params t && is_false (set_hxgeneric gen mds isfirst (TEnumDecl e)) -> if not (Hashtbl.mem gen.gtparam_cast e.e_path) then true else loop cfs | _ -> loop cfs (* TAbstracts / Dynamics can't be generic *) in if loop cl.cl_ordered_fields then begin cl.cl_meta <- (Meta.NativeGeneric, [], cl.cl_pos) :: cl.cl_meta; Some false end else if isfirst && !has_unresolved then None else begin cl.cl_meta <- (Meta.HaxeGeneric, [], cl.cl_pos) :: cl.cl_meta; Some true end end | TEnumDecl e -> if Meta.has Meta.NativeGeneric e.e_meta then Some false else if Meta.has Meta.HaxeGeneric e.e_meta then Some true else if not (is_hxgen (TEnumDecl e)) then begin e.e_meta <- (Meta.NativeGeneric, [], e.e_pos) :: e.e_meta; Some false end else begin (* if enum is not generic, then it's hxgeneric *) match e.e_params with | [] -> e.e_meta <- (Meta.HaxeGeneric, [], e.e_pos) :: e.e_meta; Some true | _ -> let rec loop efs = match efs with | [] -> false | ef :: efs -> let t = follow (gen.greal_type ef.ef_type) in match t with | TFun(args, _) -> if List.exists (fun (n,o,t) -> let t = follow t in match t with | TInst( { cl_kind = KTypeParameter _ }, _ ) -> false | TInst(cl,p) when has_type_params t && is_false (set_hxgeneric gen mds isfirst (TClassDecl cl)) -> not (Hashtbl.mem gen.gtparam_cast cl.cl_path) | TEnum(e,p) when has_type_params t && is_false (set_hxgeneric gen mds isfirst (TEnumDecl e)) -> not (Hashtbl.mem gen.gtparam_cast e.e_path) | _ -> false ) args then true else loop efs | _ -> loop efs in let efs = PMap.fold (fun ef acc -> ef :: acc) e.e_constrs [] in if loop efs then begin e.e_meta <- (Meta.NativeGeneric, [], e.e_pos) :: e.e_meta; Some false end else if isfirst && !has_unresolved then None else begin e.e_meta <- (Meta.HaxeGeneric, [], e.e_pos) :: e.e_meta; Some true end end | _ -> assert false end let set_hxgeneric gen md = let ret = match md with | TClassDecl { cl_kind = KAbstractImpl a } -> (match follow_all_md md with | (TInst _ | TEnum _ as t) -> ( let md = match t with | TInst(cl,_) -> TClassDecl cl | TEnum(e,_) -> TEnumDecl e | _ -> assert false in let ret = set_hxgeneric gen [] true md in if ret = None then get (set_hxgeneric gen [] false md) else get ret) | TAbstract(a,_) -> true | _ -> true) | _ -> match set_hxgeneric gen [] true md with | None -> get (set_hxgeneric gen [] false md) | Some v -> v in if not ret then begin match md with | TClassDecl c -> let set_hxgeneric (_,param) = match follow param with | TInst(c,_) -> c.cl_meta <- (Meta.NativeGeneric, [], c.cl_pos) :: c.cl_meta | _ -> () in List.iter set_hxgeneric c.cl_params; let rec handle_field cf = List.iter set_hxgeneric cf.cf_params; List.iter handle_field cf.cf_overloads in (match c.cl_kind with | KAbstractImpl a -> List.iter set_hxgeneric a.a_params; | _ -> ()); List.iter handle_field c.cl_ordered_fields; List.iter handle_field c.cl_ordered_statics | _ -> () end; ret let params_has_tparams params = List.fold_left (fun acc t -> acc || has_type_params t) false params (* ******************************************* *) (* RealTypeParamsModf *) (* ******************************************* *) (* This is the module filter of Real Type Parameters. It will traverse through all types and look for hxgeneric classes (only classes). When found, a parameterless interface will be created and associated via the "ifaces" Hashtbl to the original class. Also a "cast" function will be automatically generated which will handle unsafe downcasts to more specific type parameters (necessary for serialization) dependencies: Anything that may create hxgeneric classes must run before it. Should run before ReflectionCFs (this dependency will be added to ReflectionCFs), so the added interfaces also get to be real IHxObject's *) module RealTypeParamsModf = struct let set_only_hxgeneric gen = let rec run md = match md with | TTypeDecl _ | TAbstractDecl _ -> md | _ -> ignore (set_hxgeneric gen md); md in run let name = "real_type_params_modf" let priority = solve_deps name [] let rec get_fields gen cl params_cl params_cf acc = let fields = List.fold_left (fun acc cf -> match follow (gen.greal_type (gen.gfollow#run_f (cf.cf_type))) with | TInst(cli, ((_ :: _) as p)) when (not (is_hxgeneric (TClassDecl cli))) && params_has_tparams p -> (cf, apply_params cl.cl_params params_cl cf.cf_type, apply_params cl.cl_params params_cf cf.cf_type) :: acc | TEnum(e, ((_ :: _) as p)) when not (is_hxgeneric (TEnumDecl e)) && params_has_tparams p -> (cf, apply_params cl.cl_params params_cl cf.cf_type, apply_params cl.cl_params params_cf cf.cf_type) :: acc | _ -> acc ) [] cl.cl_ordered_fields in match cl.cl_super with | Some(cs, tls) -> get_fields gen cs (List.map (apply_params cl.cl_params params_cl) tls) (List.map (apply_params cl.cl_params params_cf) tls) (fields @ acc) | None -> (fields @ acc) (* overrides all needed cast functions from super classes / interfaces to call the new cast function *) let create_stub_casts gen cl cast_cfield = (* go through superclasses and interfaces *) let p = cl.cl_pos in let this = { eexpr = TConst TThis; etype = (TInst(cl, List.map snd cl.cl_params)); epos = p } in let rec loop cls tls level reverse_params = if (level <> 0 || cls.cl_interface) && tls <> [] && is_hxgeneric (TClassDecl cls) then begin let cparams = List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) cls.cl_params in let name = String.concat "_" ((fst cls.cl_path) @ [snd cls.cl_path; cast_field_name]) in if not (PMap.mem name cl.cl_fields) then begin let reverse_params = List.map (apply_params cls.cl_params (List.map snd cparams)) reverse_params in let cfield = mk_class_field name (TFun([], t_dynamic)) false cl.cl_pos (Method MethNormal) cparams in let field = { eexpr = TField(this, FInstance(cl,List.map snd cl.cl_params, cast_cfield)); etype = apply_params cast_cfield.cf_params reverse_params cast_cfield.cf_type; epos = p } in let call = { eexpr = TCall(field, []); etype = t_dynamic; epos = p; } in let call = gen.gparam_func_call call field reverse_params [] in let delay () = cfield.cf_expr <- Some { eexpr = TFunction( { tf_args = []; tf_type = t_dynamic; tf_expr = { eexpr = TReturn( Some call ); etype = t_dynamic; epos = p; } }); etype = cfield.cf_type; epos = p; } in gen.gafter_filters_ended <- delay :: gen.gafter_filters_ended; (* do not let filters alter this expression content *) cl.cl_ordered_fields <- cfield :: cl.cl_ordered_fields; cl.cl_fields <- PMap.add cfield.cf_name cfield cl.cl_fields; if level <> 0 then cl.cl_overrides <- cfield :: cl.cl_overrides end end; let get_reverse super supertl = let kv = List.map2 (fun (_,tparam) applied -> (follow applied, follow tparam)) super.cl_params supertl in List.map (fun t -> try List.assq (follow t) kv with | Not_found -> t ) reverse_params in (match cls.cl_super with | None -> () | Some(super, supertl) -> loop super supertl (level + 1) (get_reverse super supertl)); List.iter (fun (iface, ifacetl) -> loop iface ifacetl level (get_reverse iface ifacetl) ) cls.cl_implements in loop cl (List.map snd cl.cl_params) 0 (List.map snd cl.cl_params) (* Creates a cast classfield, with the desired name Will also look for previous cast() definitions and override them, to reflect the current type and fields FIXME: this function still doesn't support generics that extend generics, and are cast as one of its subclasses. This needs to be taken care, by looking at previous superclasses and whenever a generic class is found, its cast argument must be overriden. the toughest part is to know how to type the current type correctly. *) let create_cast_cfield gen cl name = let basic = gen.gcon.basic in let cparams = List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) cl.cl_params in let cfield = mk_class_field name (TFun([], t_dynamic)) false cl.cl_pos (Method MethNormal) cparams in let params = List.map snd cparams in let fields = get_fields gen cl (List.map snd cl.cl_params) params [] in (* now create the contents of the function *) (* it will look something like: if (typeof(T) == typeof(T2)) return this; var new_me = new CurrentClass(EmptyInstnace); for (field in Reflect.fields(this)) { switch(field) { case "aNativeArray": var newArray = new NativeArray(this.aNativeArray.Length); default: Reflect.setField(new_me, field, Reflect.field(this, field)); } } *) let new_t = TInst(cl, params) in let pos = cl.cl_pos in let new_me_var = alloc_var "new_me" new_t in let local_new_me = { eexpr = TLocal(new_me_var); etype = new_t; epos = pos } in let this = { eexpr = TConst(TThis); etype = (TInst(cl, List.map snd cl.cl_params)); epos = pos } in let field_var = alloc_var "field" gen.gcon.basic.tstring in let local_field = { eexpr = TLocal(field_var); etype = field_var.v_type; epos = pos } in let i_var = alloc_var "i" gen.gcon.basic.tint in let local_i = { eexpr = TLocal(i_var); etype = gen.gcon.basic.tint; epos = pos } in let incr_i = { eexpr = TUnop(Ast.Increment, Ast.Postfix, local_i); etype = basic.tint; epos = pos } in let fields_var = alloc_var "fields" (gen.gcon.basic.tarray gen.gcon.basic.tstring) in let local_fields = { eexpr = TLocal(fields_var); etype = (gen.gcon.basic.tarray gen.gcon.basic.tstring); epos = pos } in let get_path t = match follow t with | TInst(cl,_) -> cl.cl_path | TEnum(e,_) -> e.e_path | TAbstract(a,_) -> a.a_path | TMono _ | TDynamic _ -> ([], "Dynamic") | _ -> assert false in (* this will take all fields that were *) let fields_to_cases fields = List.map (fun (cf, t_cl, t_cf) -> let this_field = { eexpr = TField(this, FInstance(cl, List.map snd cl.cl_params, cf)); etype = t_cl; epos = pos } in let expr = { eexpr = TBinop(OpAssign, { eexpr = TField(local_new_me, FInstance(cl, List.map snd cl.cl_params, cf) ); etype = t_cf; epos = pos }, try (Hashtbl.find gen.gtparam_cast (get_path t_cf)) this_field t_cf with | Not_found -> (* if not found tparam cast, it shouldn't be a valid hxgeneric *) assert false ); etype = t_cf; epos = pos; } in ([{ eexpr = TConst(TString(cf.cf_name)); etype = gen.gcon.basic.tstring; epos = pos }], expr) ) fields in let mk_typehandle = let thandle = alloc_var "__typeof__" t_dynamic in (fun cl -> { eexpr = TCall(mk_local thandle pos, [ mk_classtype_access cl pos ]); etype = t_dynamic; epos = pos }) in let mk_eq cl1 cl2 = { eexpr = TBinop(Ast.OpEq, mk_typehandle cl1, mk_typehandle cl2); etype = basic.tbool; epos = pos } in let rec mk_typehandle_cond thisparams cfparams = match thisparams, cfparams with | TInst(cl_this,[]) :: [], TInst(cl_cf,[]) :: [] -> mk_eq cl_this cl_cf | TInst(cl_this,[]) :: hd, TInst(cl_cf,[]) :: hd2 -> { eexpr = TBinop(Ast.OpBoolAnd, mk_eq cl_this cl_cf, mk_typehandle_cond hd hd2); etype = basic.tbool; epos = pos } | v :: hd, v2 :: hd2 -> (match follow v, follow v2 with | (TInst(cl1,[]) as v), (TInst(cl2,[]) as v2) -> mk_typehandle_cond (v :: hd) (v2 :: hd2) | _ -> assert false ) | _ -> assert false in let fn = { tf_args = []; tf_type = t_dynamic; tf_expr = { eexpr = TBlock([ (* if (typeof(T) == typeof(T2)) return this *) { eexpr = TIf( mk_typehandle_cond (List.map snd cl.cl_params) params, mk_return this, None); etype = basic.tvoid; epos = pos; }; (* var new_me = /*special create empty with tparams construct*/ *) { eexpr = TVar(new_me_var, Some(gen.gtools.rf_create_empty cl params pos)); etype = gen.gcon.basic.tvoid; epos = pos }; (* var fields = Reflect.fields(this); *) { eexpr = TVar(fields_var, Some(gen.gtools.r_fields true this)); etype = gen.gcon.basic.tvoid; epos = pos }; (* var i = 0; *) { eexpr = TVar(i_var, Some(mk_int gen 0 pos)); etype = gen.gcon.basic.tvoid; epos = pos }; { eexpr = TWhile( (* while (i < fields.length) *) { eexpr = TBinop(Ast.OpLt, local_i, mk_field_access gen local_fields "length" pos); etype = gen.gcon.basic.tbool; epos = pos }, { eexpr = TBlock [ (* var field = fields[i++]; *) { eexpr = TVar(field_var, Some { eexpr = TArray (local_fields, incr_i); etype = gen.gcon.basic.tstring; epos = pos }); etype = gen.gcon.basic.tvoid; epos = pos }; ( (* default: Reflect.setField(new_me, field, Reflect.field(this, field)) *) let edef = gen.gtools.r_set_field gen.gcon.basic.tvoid local_new_me local_field (gen.gtools.r_field false gen.gcon.basic.tvoid this local_field) in if fields <> [] then (* switch(field) { ... } *) { eexpr = TSwitch(local_field, fields_to_cases fields, Some(edef)); etype = gen.gcon.basic.tvoid; epos = pos; } else edef; ) ]; etype = gen.gcon.basic.tvoid; epos = pos }, Ast.NormalWhile ); etype = gen.gcon.basic.tvoid; epos = pos; }; (* return new_me *) mk_return local_new_me ]); etype = t_dynamic; epos = pos; }; } in cfield.cf_expr <- Some( { eexpr = TFunction(fn); etype = cfield.cf_type; epos = pos } ); cfield let create_static_cast_cf gen iface cf = let p = iface.cl_pos in let basic = gen.gcon.basic in let cparams = List.map (fun (s,t) -> ("To_" ^ s, TInst (map_param (get_cl_t t), []))) cf.cf_params in let me_type = TInst(iface,[]) in let cfield = mk_class_field "__hx_cast" (TFun(["me",false,me_type], t_dynamic)) false iface.cl_pos (Method MethNormal) (cparams) in let params = List.map snd cparams in let me = alloc_var "me" me_type in let field = { eexpr = TField(mk_local me p, FInstance(iface, List.map snd iface.cl_params, cf)); etype = apply_params cf.cf_params params cf.cf_type; epos = p } in let call = { eexpr = TCall(field, []); etype = t_dynamic; epos = p; } in let call = gen.gparam_func_call call field params [] in (* since object.someCall() isn't allowed on Haxe, we need to directly apply the params and delay this call *) let delay () = cfield.cf_expr <- Some { eexpr = TFunction( { tf_args = [me,None]; tf_type = t_dynamic; tf_expr = { eexpr = TReturn( Some { eexpr = TIf( { eexpr = TBinop(Ast.OpNotEq, mk_local me p, null me.v_type p); etype = basic.tbool; epos = p }, call, Some( null me.v_type p ) ); etype = t_dynamic; epos = p; }); etype = basic.tvoid; epos = p; } }); etype = cfield.cf_type; epos = p; } in cfield, delay let get_cast_name cl = String.concat "_" ((fst cl.cl_path) @ [snd cl.cl_path; cast_field_name]) (* explicitly define it *) let default_implementation gen ifaces base_generic = let add_iface cl = gen.gadd_to_module (TClassDecl cl) (max_dep); in let implement_stub_cast cthis iface tl = let name = get_cast_name iface in if not (PMap.mem name cthis.cl_fields) then begin let cparams = List.map (fun (s,t) -> ("To_" ^ s, TInst(map_param (get_cl_t t), []))) iface.cl_params in let field = mk_class_field name (TFun([],t_dynamic)) false iface.cl_pos (Method MethNormal) cparams in let this = { eexpr = TConst TThis; etype = TInst(cthis, List.map snd cthis.cl_params); epos = cthis.cl_pos } in field.cf_expr <- Some { etype = TFun([],t_dynamic); epos = this.epos; eexpr = TFunction { tf_type = t_dynamic; tf_args = []; tf_expr = mk_block { this with eexpr = TReturn (Some this) } } }; cthis.cl_ordered_fields <- field :: cthis.cl_ordered_fields; cthis.cl_fields <- PMap.add name field cthis.cl_fields end in let rec run md = match md with | TClassDecl ({ cl_params = [] } as cl) -> (* see if we're implementing any generic interface *) let rec check (iface,tl) = if tl <> [] && set_hxgeneric gen (TClassDecl iface) then (* implement cast stub *) implement_stub_cast cl iface tl; List.iter (fun (s,stl) -> check (s, List.map (apply_params iface.cl_params tl) stl)) iface.cl_implements; in List.iter (check) cl.cl_implements; md | TClassDecl ({ cl_params = hd :: tl } as cl) when set_hxgeneric gen md -> let iface = mk_class cl.cl_module cl.cl_path cl.cl_pos in iface.cl_array_access <- Option.map (apply_params (cl.cl_params) (List.map (fun _ -> t_dynamic) cl.cl_params)) cl.cl_array_access; iface.cl_extern <- cl.cl_extern; iface.cl_module <- cl.cl_module; iface.cl_meta <- (Meta.HxGen, [], cl.cl_pos) :: (Meta.Custom "generic_iface", [(EConst(Int(string_of_int(List.length cl.cl_params))), cl.cl_pos)], cl.cl_pos) :: iface.cl_meta; Hashtbl.add ifaces cl.cl_path iface; iface.cl_implements <- (base_generic, []) :: iface.cl_implements; iface.cl_interface <- true; cl.cl_implements <- (iface, []) :: cl.cl_implements; let name = get_cast_name cl in let cast_cf = create_cast_cfield gen cl name in if not cl.cl_interface then create_stub_casts gen cl cast_cf; let rec loop c = match c.cl_super with | None -> () | Some(sup,_) -> try let siface = Hashtbl.find ifaces sup.cl_path in iface.cl_implements <- (siface,[]) :: iface.cl_implements; () with | Not_found -> loop sup in loop cl; (if not cl.cl_interface then cl.cl_ordered_fields <- cast_cf :: cl.cl_ordered_fields); let iface_cf = mk_class_field name cast_cf.cf_type false cast_cf.cf_pos (Method MethNormal) cast_cf.cf_params in let cast_static_cf, delay = create_static_cast_cf gen iface iface_cf in cl.cl_ordered_statics <- cast_static_cf :: cl.cl_ordered_statics; cl.cl_statics <- PMap.add cast_static_cf.cf_name cast_static_cf cl.cl_statics; gen.gafter_filters_ended <- delay :: gen.gafter_filters_ended; (* do not let filters alter this expression content *) iface_cf.cf_type <- cast_cf.cf_type; iface.cl_fields <- PMap.add name iface_cf iface.cl_fields; let fields = List.filter (fun cf -> match cf.cf_kind with | Var _ | Method MethDynamic -> false | _ -> let is_override = List.memq cf cl.cl_overrides in let cf_type = if is_override && not (Meta.has Meta.Overload cf.cf_meta) then match field_access gen (TInst(cl, List.map snd cl.cl_params)) cf.cf_name with | FClassField(_,_,_,_,_,actual_t,_) -> actual_t | _ -> assert false else cf.cf_type in not (has_type_params cf_type)) cl.cl_ordered_fields in let fields = List.map (fun f -> mk_class_field f.cf_name f.cf_type f.cf_public f.cf_pos f.cf_kind f.cf_params) fields in let fields = iface_cf :: fields in iface.cl_ordered_fields <- fields; List.iter (fun f -> iface.cl_fields <- PMap.add f.cf_name f iface.cl_fields) fields; add_iface iface; md | TTypeDecl _ | TAbstractDecl _ -> md | TEnumDecl _ -> ignore (set_hxgeneric gen md); md | _ -> ignore (set_hxgeneric gen md); md in run let configure gen mapping_func = let map e = Some(mapping_func e) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* create a common interface without type parameters and only a __Cast<> function *) let default_implementation gen (dyn_tparam_cast:texpr->t->texpr) ifaces = let change_expr e cl iface params = let field = mk_static_field_access_infer cl "__hx_cast" e.epos params in let elist = [mk_cast (TInst(iface,[])) e] in let call = { eexpr = TCall(field, elist); etype = t_dynamic; epos = e.epos } in gen.gparam_func_call call field params elist in let rec run e = match e.eexpr with | TCast(cast_expr, _) -> (* see if casting to a native generic class *) let t = gen.greal_type e.etype in let unifies = let ctype = gen.greal_type cast_expr.etype in match follow ctype with | TInst(cl,_) -> (try unify ctype t; true with | Unify_error el -> false) | _ -> false in let unifies = unifies && not (PMap.mem "cs_safe_casts" gen.gcon.defines) in (match follow t with | TInst(cl, p1 :: pl) when is_hxgeneric (TClassDecl cl) && not unifies && not (Meta.has Meta.Enum cl.cl_meta) -> let iface = Hashtbl.find ifaces cl.cl_path in mk_cast e.etype (change_expr (Type.map_expr run cast_expr) cl iface (p1 :: pl)) | _ -> Type.map_expr run e ) | _ -> Type.map_expr run e in run let configure gen traverse = gen.ghas_tparam_cast_handler <- true; let map e = Some(traverse e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map let default_config gen (dyn_tparam_cast:texpr->t->texpr) ifaces base_generic = configure gen (default_implementation gen dyn_tparam_cast ifaces); RealTypeParamsModf.configure gen (RealTypeParamsModf.default_implementation gen ifaces base_generic) end;; (* ******************************************* *) (* Rename Type Parameters *) (* ******************************************* *) (* This module should run after everything is already applied, it will look for possible type parameter name clashing and change the classes names to a dependencies: should run after everything is already applied. There's no configure on this module, only 'run'. *) module RenameTypeParameters = struct let name = "rename_type_parameters" let run gen = let i = ref 0 in let found_types = ref PMap.empty in let check_type name on_changed = let rec loop name = incr i; let changed_name = (name ^ (string_of_int !i)) in if PMap.mem changed_name !found_types then loop name else changed_name in if PMap.mem name !found_types then begin let new_name = loop name in found_types := PMap.add new_name true !found_types; on_changed new_name end else found_types := PMap.add name true !found_types in let get_cls t = match follow t with | TInst(cl,_) -> cl | _ -> assert false in let iter_types (nt,t) = let cls = get_cls t in let orig = cls.cl_path in check_type (snd orig) (fun name -> cls.cl_path <- (fst orig, name)) in let save_params save params = List.fold_left (fun save (_,t) -> let cls = get_cls t in (cls.cl_path,t) :: save) save params in List.iter (function | TClassDecl cl -> i := 0; let save = [] in found_types := PMap.empty; let save = save_params save cl.cl_params in List.iter iter_types cl.cl_params; let cur_found_types = !found_types in let save = ref save in List.iter (fun cf -> found_types := cur_found_types; save := save_params !save cf.cf_params; List.iter iter_types cf.cf_params ) (cl.cl_ordered_fields @ cl.cl_ordered_statics); if !save <> [] then begin let save = !save in let res = cl.cl_restore in cl.cl_restore <- (fun () -> res(); List.iter (fun (path,t) -> let cls = get_cls t in cls.cl_path <- path) save ); end | TEnumDecl ( ({ e_params = hd :: tl }) ) -> i := 0; found_types := PMap.empty; List.iter iter_types (hd :: tl) | TAbstractDecl { a_params = hd :: tl } -> i := 0; found_types := PMap.empty; List.iter iter_types (hd :: tl) | _ -> () ) gen.gtypes_list end;; let configure gen (param_func_call:texpr->texpr->tparams->texpr list->texpr) = (*let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:name ~priority:(PCustom priority) map*) gen.gparam_func_call <- param_func_call end;; (**************************************************************************************************************************) (* SYNTAX FILTERS *) (**************************************************************************************************************************) (* ******************************************* *) (* Expression Unwrap *) (* ******************************************* *) (* This is the most important module for source-code based targets. It will follow a convention of what's an expression and what's a statement, and will unwrap statements where expressions are expected, and vice-versa. It should be one of the first syntax filters to be applied. As a consequence, it's applied after all filters that add code to the AST, and by being the first of the syntax filters, it will also have the AST retain most of the meaning of normal Haxe code. So it's easier to detect cases which are side-effects free, for example Any target can make use of this, but there is one requirement: The target must accept null to be set to any kind of variable. For example, var i:Int = null; must be accepted. The best way to deal with this is to (like it's done in C#) make null equal to "default(Type)" dependencies: While it's best for Expression Unwrap to delay its execution as much as possible, since theoretically any filter can return an expression that needs to be unwrapped, it is also desirable for ExpresionUnwrap to have the AST as close as possible as Haxe's, so it can make some correct predictions (for example, so it can more accurately know what can be side-effects-free and what can't). This way, it will run slightly after the Normal priority, so if you don't say that a syntax filter must run before Expression Unwrap, it will run after it. TODO : While statement must become do / while, with the actual block inside an if for the condition, and else for 'break' *) module ExpressionUnwrap = struct let name = "expression_unwrap" (* priority: first syntax filter *) let priority = -10.0 (* We always need to rely on Blocks to be able to unwrap expressions correctly. So the the standard traverse will always be based on blocks. Normal block statements, like for(), while(), if(), ... will be mk_block'ed so there is always a block inside of them. At the block level, we'll define an "add_statement" function, which will allow the current expression to add statements to the block. This statement may or may not contain statements as expressions, so the texpr will be evaluated recursively before being added. - traverse will always evaluate TBlocks - for each texpr in a TBlock list, check shallow type if type is Statement or Both when it has problematic expression (var problematic_expr = count_problematic_expressions), if we can eagerly call unwrap_statement on the whole expression (try_call_unwrap_statement), use the return expression else check expr_type of each underlying type (with expr_stat_map) if it has ExprWithStatement or Statement, call problematic_expression_unwrap in it problematic_expr-- else if problematic_expr == 0, just add the unchanged expression else if NoSideEffects and doesn't have short-circuit, just add the unchanged expression else call problematic_expression_unwrap in it if type is Expression, check if there are statements or Both inside. if there are, problematic_expression_unwrap in it aftewards, use on_expr_as_statement to get it helpers: try_call_unwrap_statement: (returns texpr option) if underlying statement is TBinop(OpAssign/OpAssignOp), or TVar, with the right side being a Statement or a short circuit op, we can call apply_assign. apply_assign: if is TVar, first declare the tvar with default expression = null; will receive the left and right side of the assignment; right-side must be Statement see if right side is a short-circuit operation, call short_circuit_op_unwrap else see eexpr of the right side if it's void, just add the statement with add_statement, and set the right side as null; if not, it will have a block inside. set the left side = to the last expression on each block inside. add_statement for it. short_circuit_op_unwrap: x() && (1 + {var x = 0; x + 1;} == 2) && z() -> var x = x(); var y = false; var z = false; if (x) //for &&, neg for || { var temp = null; { var x = 0; temp = x + 1; } y = (1 + temp) == 2; if (y) { z = z(); } } expects to receive a texpr with TBinop(OpBoolAnd/OpBoolOr) will traverse the AST while there is a TBinop(OpBoolAnd/OpBoolOr) as a right-side expr, and declare new temp vars in the for each found. will collect the return value, a mapped expr with all exprs as TLocal of the temp vars created problematic_expression_unwrap: check expr_kind: if it is NoSideEffects and not short-circuit, leave it there if it is ExprWithStatement and not short-circuit, call Type.map_expr problematic_expression_unwrap if it is Statement or Expression or short-circuit expr, call add_assign for this expression add_assign: see if the type is void. If it is, just add_statement the expression argument, and return a null value else create a new variable, set TVar with Some() with the expression argument, add TVar with add_statement, and return the TLocal of this expression. map_problematic_expr: call expr_stat_map on statement with problematic_expression_unwrap types: type shallow_expr_type = | Statement | Expression | Both (* shallow expression classification. Both means that they can be either Statements as Expressions *) type expr_kind = | NormalExpr | ExprNoSideEffects (* -> short-circuit is considered side-effects *) | ExprWithStatement | Statement evaluates an expression (as in not a statement) type. If it is ExprWithStatement or Statement, it means it contains errors functions: shallow_expr_type (expr:texpr) : shallow_expr_type expr_kind (expr:texpr) : expr_kind deeply evaluates an expression type expr_stat_map (fn:texpr->texpr) (expr:texpr) : texpr it will traverse the AST looking for places where an expression is expected, and map the value according to fn aggregate_expr_type (is_side_effects_free:bool) (children:expr_type list) : expr_type helper function to deal with expr_type aggregation (e.g. an Expression + a Statement as a children, is a ExprWithStatement) check_statement_in_expression (expr:texpr) : texpr option : will check *) type shallow_expr_type = | Statement | Expression of texpr | Both of texpr (* shallow expression classification. Both means that they can be either Statements as Expressions *) type expr_kind = | KNormalExpr | KNoSideEffects (* -> short-circuit is considered side-effects *) | KExprWithStatement | KStatement let rec no_paren e = match e.eexpr with | TParenthesis e -> no_paren e | _ -> e (* must be called in a statement. Will execute fn whenever an expression (not statement) is expected *) let rec expr_stat_map fn (expr:texpr) = match (no_paren expr).eexpr with | TBinop ( (Ast.OpAssign as op), left_e, right_e ) | TBinop ( (Ast.OpAssignOp _ as op), left_e, right_e ) -> { expr with eexpr = TBinop(op, fn left_e, fn right_e) } | TParenthesis _ -> assert false | TCall(left_e, params) -> { expr with eexpr = TCall(fn left_e, List.map fn params) } | TNew(cl, tparams, params) -> { expr with eexpr = TNew(cl, tparams, List.map fn params) } | TVar(v,eopt) -> { expr with eexpr = TVar(v, Option.map fn eopt) } | TFor (v,cond,block) -> { expr with eexpr = TFor(v, fn cond, block) } | TIf(cond,eif,eelse) -> { expr with eexpr = TIf(fn cond, eif, eelse) } | TWhile(cond, block, flag) -> { expr with eexpr = TWhile(fn cond, block, flag) } | TSwitch(cond, el_block_l, default) -> { expr with eexpr = TSwitch( fn cond, List.map (fun (el,block) -> (List.map fn el, block)) el_block_l, default ) } (* | TMatch(cond, enum, cases, default) -> { expr with eexpr = TMatch(fn cond, enum, cases, default) } *) | TReturn(eopt) -> { expr with eexpr = TReturn(Option.map fn eopt) } | TThrow (texpr) -> { expr with eexpr = TThrow(fn texpr) } | TBreak | TContinue | TTry _ | TUnop (Ast.Increment, _, _) | TUnop (Ast.Decrement, _, _) (* unop is a special case because the haxe compiler won't let us generate complex expressions with Increment/Decrement *) | TBlock _ -> expr (* there is no expected expression here. Only statements *) | TMeta(m,e) -> { expr with eexpr = TMeta(m,expr_stat_map fn e) } | _ -> assert false (* we only expect valid statements here. other expressions aren't valid statements *) let is_expr = function | Expression _ -> true | _ -> false let aggregate_expr_type map_fn side_effects_free children = let rec loop acc children = match children with | [] -> acc | hd :: children -> match acc, map_fn hd with | _, KExprWithStatement | _, KStatement | KExprWithStatement, _ | KStatement, _ -> KExprWithStatement | KNormalExpr, KNoSideEffects | KNoSideEffects, KNormalExpr | KNormalExpr, KNormalExpr -> loop KNormalExpr children | KNoSideEffects, KNoSideEffects -> loop KNoSideEffects children in loop (if side_effects_free then KNoSideEffects else KNormalExpr) children (* statements: *) (* Error CS0201: Only assignment, call, increment, *) (* decrement, and new object expressions can be used as a *) (* statement (CS0201). *) let rec shallow_expr_type expr : shallow_expr_type = match expr.eexpr with | TCall _ when not (is_void expr.etype) -> Both expr | TNew _ | TUnop (Ast.Increment, _, _) | TUnop (Ast.Decrement, _, _) | TBinop (Ast.OpAssign, _, _) | TBinop (Ast.OpAssignOp _, _, _) -> Both expr | TIf (cond, eif, Some(eelse)) -> (match aggregate_expr_type expr_kind true [cond;eif;eelse] with | KExprWithStatement -> Statement | _ -> Both expr) | TConst _ | TLocal _ | TArray _ | TBinop _ | TField _ | TEnumParameter _ | TTypeExpr _ | TObjectDecl _ | TArrayDecl _ | TFunction _ | TCast _ | TUnop _ -> Expression (expr) | TParenthesis p | TMeta(_,p) -> shallow_expr_type p | TBlock ([e]) -> shallow_expr_type e | TCall _ | TVar _ | TBlock _ | TFor _ | TWhile _ | TSwitch _ | TTry _ | TReturn _ | TBreak | TContinue | TIf _ | TThrow _ -> Statement and expr_kind expr = match shallow_expr_type expr with | Statement -> KStatement | Both expr | Expression expr -> let aggregate = aggregate_expr_type expr_kind in match expr.eexpr with | TConst _ | TLocal _ | TFunction _ | TTypeExpr _ -> KNoSideEffects | TCall (ecall, params) -> aggregate false (ecall :: params) | TNew (_,_,params) -> aggregate false params | TUnop (Increment,_,e) | TUnop (Decrement,_,e) -> aggregate false [e] | TUnop (_,_,e) -> aggregate true [e] | TBinop (Ast.OpBoolAnd, e1, e2) | TBinop (Ast.OpBoolOr, e1, e2) -> (* TODO: should OpBool never be side-effects free? *) aggregate true [e1;e2] | TBinop (Ast.OpAssign, e1, e2) | TBinop (Ast.OpAssignOp _, e1, e2) -> aggregate false [e1;e2] | TBinop (_, e1, e2) -> aggregate true [e1;e2] | TIf (cond, eif, Some(eelse)) -> (match aggregate true [cond;eif;eelse] with | KExprWithStatement -> KStatement | k -> k) | TArray (e1,e2) -> aggregate true [e1;e2] | TParenthesis e | TMeta(_,e) | TField (e,_) -> aggregate true [e] | TArrayDecl (el) -> aggregate true el | TObjectDecl (sel) -> aggregate true (List.map snd sel) | TCast (e,_) -> aggregate true [e] | _ -> trace (debug_expr expr); assert false (* should have been read as Statement by shallow_expr_type *) let is_side_effects_free e = match expr_kind e with | KNoSideEffects -> true | _ -> false let get_kinds (statement:texpr) = let kinds = ref [] in ignore (expr_stat_map (fun e -> kinds := (expr_kind e) :: !kinds; e ) statement); List.rev !kinds let has_problematic_expressions (kinds:expr_kind list) = let rec loop kinds = match kinds with | [] -> false | KStatement :: _ | KExprWithStatement :: _ -> true | _ :: tl -> loop tl in loop kinds let count_problematic_expressions (statement:texpr) = let count = ref 0 in ignore (expr_stat_map (fun e -> (match expr_kind e with | KStatement | KExprWithStatement -> incr count | _ -> () ); e ) statement); !count let apply_assign_block assign_fun elist = let rec assign acc elist = match elist with | [] -> acc | last :: [] -> (assign_fun last) :: acc | hd :: tl -> assign (hd :: acc) tl in List.rev (assign [] elist) let mk_get_block assign_fun e = match e.eexpr with | TBlock [] -> e | TBlock (el) -> { e with eexpr = TBlock(apply_assign_block assign_fun el) } | _ -> { e with eexpr = TBlock([ assign_fun e ]) } let add_assign gen add_statement expr = match expr.eexpr, follow expr.etype with | _, TAbstract ({ a_path = ([],"Void") },[]) | TThrow _, _ -> add_statement expr; null expr.etype expr.epos | _ -> let var = mk_temp gen "stmt" expr.etype in let tvars = { expr with eexpr = TVar(var,Some(expr)) } in let local = { expr with eexpr = TLocal(var) } in add_statement tvars; local (* requirement: right must be a statement *) let rec apply_assign assign_fun right = match right.eexpr with | TBlock el -> { right with eexpr = TBlock(apply_assign_block assign_fun el) } | TSwitch (cond, elblock_l, default) -> { right with eexpr = TSwitch(cond, List.map (fun (el,block) -> (el, mk_get_block assign_fun block)) elblock_l, Option.map (mk_get_block assign_fun) default) } (* | TMatch (cond, ep, il_vlo_e_l, default) -> { right with eexpr = TMatch(cond, ep, List.map (fun (il,vlo,e) -> (il,vlo,mk_get_block assign_fun e)) il_vlo_e_l, Option.map (mk_get_block assign_fun) default) } *) | TTry (block, catches) -> { right with eexpr = TTry(mk_get_block assign_fun block, List.map (fun (v,block) -> (v,mk_get_block assign_fun block) ) catches) } | TIf (cond,eif,eelse) -> { right with eexpr = TIf(cond, mk_get_block assign_fun eif, Option.map (mk_get_block assign_fun) eelse) } | TThrow _ | TWhile _ | TFor _ | TReturn _ | TBreak | TContinue -> right | TParenthesis p | TMeta(_,p) -> apply_assign assign_fun p | TVar _ -> right | _ -> match follow right.etype with | TAbstract ({ a_path = ([], "Void") },[]) -> right | _ -> trace (debug_expr right); assert false (* a statement is required *) let short_circuit_op_unwrap gen add_statement expr :texpr = let do_not expr = { expr with eexpr = TUnop(Ast.Not, Ast.Prefix, expr) } in (* loop will always return its own TBlock, and the mapped expression *) let rec loop acc expr = match expr.eexpr with | TBinop ( (Ast.OpBoolAnd as op), left, right) -> let var = mk_temp gen "boolv" right.etype in let tvars = { right with eexpr = TVar(var, Some( { right with eexpr = TConst(TBool false); etype = gen.gcon.basic.tbool } )); etype = gen.gcon.basic.tvoid } in let local = { right with eexpr = TLocal(var) } in let mapped_left, ret_acc = loop ( (local, { right with eexpr = TBinop(Ast.OpAssign, local, right) } ) :: acc) left in add_statement tvars; ({ expr with eexpr = TBinop(op, mapped_left, local) }, ret_acc) (* we only accept OpBoolOr when it's the first to be evaluated *) | TBinop ( (Ast.OpBoolOr as op), left, right) when acc = [] -> let left = match left.eexpr with | TLocal _ | TConst _ -> left | _ -> add_assign gen add_statement left in let var = mk_temp gen "boolv" right.etype in let tvars = { right with eexpr = TVar(var, Some( { right with eexpr = TConst(TBool false); etype = gen.gcon.basic.tbool } )); etype = gen.gcon.basic.tvoid } in let local = { right with eexpr = TLocal(var) } in add_statement tvars; ({ expr with eexpr = TBinop(op, left, local) }, [ do_not left, { right with eexpr = TBinop(Ast.OpAssign, local, right) } ]) | _ when acc = [] -> assert false | _ -> let var = mk_temp gen "boolv" expr.etype in let tvars = { expr with eexpr = TVar(var, Some( { expr with etype = gen.gcon.basic.tbool } )); etype = gen.gcon.basic.tvoid } in let local = { expr with eexpr = TLocal(var) } in let last_local = ref local in let acc = List.map (fun (local, assign) -> let l = !last_local in last_local := local; (l, assign) ) acc in add_statement tvars; (local, acc) in let mapped_expr, local_assign_list = loop [] expr in let rec loop local_assign_list : texpr = match local_assign_list with | [local, assign] -> { eexpr = TIf(local, assign, None); etype = gen.gcon.basic.tvoid; epos = assign.epos } | (local, assign) :: tl -> { eexpr = TIf(local, { eexpr = TBlock ( assign :: [loop tl] ); etype = gen.gcon.basic.tvoid; epos = assign.epos; }, None); etype = gen.gcon.basic.tvoid; epos = assign.epos } | [] -> assert false in add_statement (loop local_assign_list); mapped_expr (* there are two short_circuit fuctions as I'm still testing the best way to do it *) (*let short_circuit_op_unwrap gen add_statement expr :texpr = let block = ref [] in let rec short_circuit_op_unwrap is_first last_block expr = match expr.eexpr with | TBinop ( (Ast.OpBoolAnd as op), left, right) | TBinop ( (Ast.OpBoolOr as op), left, right) -> let var = mk_temp gen "boolv" left.etype in let tvars = { left with eexpr = TVar([var, if is_first then Some(left) else Some( { left with eexpr = TConst(TBool false) } )]); etype = gen.gcon.basic.tvoid } in let local = { left with eexpr = TLocal(var) } in if not is_first then begin last_block := !last_block @ [ { left with eexpr = TBinop(Ast.OpAssign, local, left) } ] end; add_statement tvars; let local_op = match op with | Ast.OpBoolAnd -> local | Ast.OpBoolOr -> { local with eexpr = TUnop(Ast.Not, Ast.Prefix, local) } | _ -> assert false in let new_block = ref [] in let new_right = short_circuit_op_unwrap false new_block right in last_block := !last_block @ [ { expr with eexpr = TIf(local_op, { right with eexpr = TBlock(!new_block) }, None) } ]; { expr with eexpr = TBinop(op, local, new_right) } | _ when is_first -> assert false | _ -> let var = mk_temp gen "boolv" expr.etype in let tvars = { expr with eexpr = TVar([var, Some ( { expr with eexpr = TConst(TBool false) } ) ]); etype = gen.gcon.basic.tvoid } in let local = { expr with eexpr = TLocal(var) } in last_block := !last_block @ [ { expr with eexpr = TBinop(Ast.OpAssign, local, expr) } ]; add_statement tvars; local in let mapped_expr = short_circuit_op_unwrap true block expr in add_statement { eexpr = TBlock(!block); etype = gen.gcon.basic.tvoid; epos = expr.epos }; mapped_expr*) let twhile_with_condition_statement gen add_statement twhile cond e1 flag = (* when a TWhile is found with a problematic condition *) let basic = gen.gcon.basic in let block = if flag = Ast.NormalWhile then { e1 with eexpr = TIf(cond, e1, Some({ e1 with eexpr = TBreak; etype = basic.tvoid })) } else Type.concat e1 { e1 with eexpr = TIf({ eexpr = TUnop(Ast.Not, Ast.Prefix, mk_paren cond); etype = basic.tbool; epos = cond.epos }, { e1 with eexpr = TBreak; etype = basic.tvoid }, None); etype = basic.tvoid } in add_statement { twhile with eexpr = TWhile( { eexpr = TConst(TBool true); etype = basic.tbool; epos = cond.epos }, block, Ast.DoWhile ); } let try_call_unwrap_statement gen problematic_expression_unwrap (add_statement:texpr->unit) (expr:texpr) : texpr option = let check_left left = match expr_kind left with | KExprWithStatement -> problematic_expression_unwrap add_statement left KExprWithStatement | KStatement -> assert false (* doesn't make sense a KStatement as a left side expression *) | _ -> left in let handle_assign op left right = let left = check_left left in Some (apply_assign (fun e -> { e with eexpr = TBinop(op, left, if is_void left.etype then e else gen.ghandle_cast left.etype e.etype e) }) right ) in let handle_return e = Some( apply_assign (fun e -> match e.eexpr with | TThrow _ -> e | _ when is_void e.etype -> { e with eexpr = TBlock([e; { e with eexpr = TReturn None }]) } | _ -> { e with eexpr = TReturn( Some e ) } ) e ) in let is_problematic_if right = match expr_kind right with | KStatement | KExprWithStatement -> true | _ -> false in match expr.eexpr with | TBinop((Ast.OpAssign as op),left,right) | TBinop((Ast.OpAssignOp _ as op),left,right) when shallow_expr_type right = Statement -> handle_assign op left right | TReturn( Some right ) when shallow_expr_type right = Statement -> handle_return right | TBinop((Ast.OpAssign as op),left, ({ eexpr = TBinop(Ast.OpBoolAnd,_,_) } as right) ) | TBinop((Ast.OpAssign as op),left,({ eexpr = TBinop(Ast.OpBoolOr,_,_) } as right)) | TBinop((Ast.OpAssignOp _ as op),left,({ eexpr = TBinop(Ast.OpBoolAnd,_,_) } as right) ) | TBinop((Ast.OpAssignOp _ as op),left,({ eexpr = TBinop(Ast.OpBoolOr,_,_) } as right) ) -> let right = short_circuit_op_unwrap gen add_statement right in Some { expr with eexpr = TBinop(op, check_left left, right) } | TVar(v,Some({ eexpr = TBinop(Ast.OpBoolAnd,_,_) } as right)) | TVar(v,Some({ eexpr = TBinop(Ast.OpBoolOr,_,_) } as right)) -> let right = short_circuit_op_unwrap gen add_statement right in Some { expr with eexpr = TVar(v, Some(right)) } | TVar(v,Some(right)) when shallow_expr_type right = Statement -> add_statement ({ expr with eexpr = TVar(v, Some(null right.etype right.epos)) }); handle_assign Ast.OpAssign { expr with eexpr = TLocal(v); etype = v.v_type } right (* TIf handling *) | TBinop((Ast.OpAssign as op),left, ({ eexpr = TIf _ } as right)) | TBinop((Ast.OpAssignOp _ as op),left,({ eexpr = TIf _ } as right)) when is_problematic_if right -> handle_assign op left right | TVar(v,Some({ eexpr = TIf _ } as right)) when is_problematic_if right -> add_statement ({ expr with eexpr = TVar(v, Some(null right.etype right.epos)) }); handle_assign Ast.OpAssign { expr with eexpr = TLocal(v); etype = v.v_type } right | TWhile(cond, e1, flag) when is_problematic_if cond -> twhile_with_condition_statement gen add_statement expr cond e1 flag; Some (null expr.etype expr.epos) | _ -> None let traverse gen (on_expr_as_statement:texpr->texpr option) = let add_assign = add_assign gen in let problematic_expression_unwrap add_statement expr e_type = let rec problematic_expression_unwrap is_first expr e_type = match e_type, expr.eexpr with | _, TBinop(Ast.OpBoolAnd, _, _) | _, TBinop(Ast.OpBoolOr, _, _) -> add_assign add_statement expr (* add_assign so try_call_unwrap_expr *) | KNoSideEffects, _ -> expr | KStatement, _ | KNormalExpr, _ -> add_assign add_statement expr | KExprWithStatement, TCall _ | KExprWithStatement, TNew _ | KExprWithStatement, TBinop (Ast.OpAssign,_,_) | KExprWithStatement, TBinop (Ast.OpAssignOp _,_,_) | KExprWithStatement, TUnop (Ast.Increment,_,_) (* all of these may have side-effects, so they must also be add_assign'ed . is_first avoids infinite loop *) | KExprWithStatement, TUnop (Ast.Decrement,_,_) when not is_first -> add_assign add_statement expr (* bugfix: Type.map_expr doesn't guarantee the correct order of execution *) | KExprWithStatement, TBinop(op,e1,e2) -> let e1 = problematic_expression_unwrap false e1 (expr_kind e1) in let e2 = problematic_expression_unwrap false e2 (expr_kind e2) in { expr with eexpr = TBinop(op, e1, e2) } | KExprWithStatement, TArray(e1,e2) -> let e1 = problematic_expression_unwrap false e1 (expr_kind e1) in let e2 = problematic_expression_unwrap false e2 (expr_kind e2) in { expr with eexpr = TArray(e1, e2) } (* bugfix: calls should not be transformed into closure calls *) | KExprWithStatement, TCall(( { eexpr = TField (ef_left, f) } as ef ), eargs) -> { expr with eexpr = TCall( { ef with eexpr = TField(problematic_expression_unwrap false ef_left (expr_kind ef_left), f) }, List.map (fun e -> problematic_expression_unwrap false e (expr_kind e)) eargs) } | KExprWithStatement, _ -> Type.map_expr (fun e -> problematic_expression_unwrap false e (expr_kind e)) expr in problematic_expression_unwrap true expr e_type in let rec traverse e = match e.eexpr with | TBlock el -> let new_block = ref [] in let rec process_statement e = let e = no_paren e in match e.eexpr, shallow_expr_type e with | TCall( { eexpr = TLocal v } as elocal, elist ), _ when String.get v.v_name 0 = '_' && Hashtbl.mem gen.gspecial_vars v.v_name -> new_block := { e with eexpr = TCall( elocal, List.map (fun e -> match e.eexpr with | TBlock _ -> traverse e | _ -> e ) elist ) } :: !new_block | _, Statement | _, Both _ -> let e = match e.eexpr with | TReturn (Some ({ eexpr = TThrow _ } as ethrow)) -> ethrow | _ -> e in let kinds = get_kinds e in if has_problematic_expressions kinds then begin match try_call_unwrap_statement gen problematic_expression_unwrap add_statement e with | Some { eexpr = TConst(TNull) } (* no op *) | Some { eexpr = TBlock [] } -> () | Some e -> if has_problematic_expressions (get_kinds e) then begin process_statement e end else new_block := (traverse e) :: !new_block | None -> ( let acc = ref kinds in let new_e = expr_stat_map (fun e -> match !acc with | hd :: tl -> acc := tl; if has_problematic_expressions (hd :: tl) then begin problematic_expression_unwrap add_statement e hd end else e | [] -> assert false ) e in new_block := (traverse new_e) :: !new_block ) end else begin new_block := (traverse e) :: !new_block end | _, Expression e -> match on_expr_as_statement e with | None -> () | Some e -> process_statement e and add_statement expr = process_statement expr in List.iter (process_statement) el; let block = List.rev !new_block in { e with eexpr = TBlock(block) } | TTry (block, catches) -> { e with eexpr = TTry(traverse (mk_block block), List.map (fun (v,block) -> (v, traverse (mk_block block))) catches) } (* | TMatch (cond,ep,il_vol_e_l,default) -> { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) } *) | TSwitch (cond,el_e_l, default) -> { e with eexpr = TSwitch(cond, List.map (fun (el,e) -> (el, traverse (mk_block e))) el_e_l, Option.map (fun e -> traverse (mk_block e)) default) } | TWhile (cond,block,flag) -> {e with eexpr = TWhile(cond,traverse (mk_block block), flag) } | TIf (cond, eif, eelse) -> { e with eexpr = TIf(cond, traverse (mk_block eif), Option.map (fun e -> traverse (mk_block e)) eelse) } | TFor (v,it,block) -> { e with eexpr = TFor(v,it, traverse (mk_block block)) } | TFunction (tfunc) -> { e with eexpr = TFunction({ tfunc with tf_expr = traverse (mk_block tfunc.tf_expr) }) } | _ -> e (* if expression doesn't have a block, we will exit *) in traverse let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* Casts detection v2 *) (* ******************************************* *) (* Will detect implicit casts and add TCast for them. Since everything is already followed by follow_all, typedefs are considered a new type altogether Types shouldn't be cast if: * When an instance is being coerced to a superclass or to an implemented interface * When anything is being coerced to Dynamic edit: As a matter of performance, we will also run the type parameters casts in here. Otherwise the exact same computation would have to be performed twice, with maybe even some loss of information * TAnon / TDynamic will call * Type parameter handling will be abstracted dependencies: Must run before ExpressionUnwrap *) module CastDetect = struct let name = "cast_detect_2" let priority = solve_deps name [DBefore TypeParams.priority; DBefore ExpressionUnwrap.priority] (* ******************************************* *) (* ReturnCast *) (* ******************************************* *) (* Cast detection for return types can't be done at CastDetect time, since we need an unwrapped expression to make sure we catch all return cast detections. So this module is specifically to deal with that, and is configured automatically by CastDetect dependencies: *) module ReturnCast = struct let name = "return_cast" let priority = solve_deps name [DAfter priority; DAfter ExpressionUnwrap.priority] let default_implementation gen = let rec extract_expr e = match e.eexpr with | TParenthesis e | TMeta (_,e) | TCast(e,_) -> extract_expr e | _ -> e in let current_ret_type = ref None in let handle e tto tfrom = gen.ghandle_cast (gen.greal_type tto) (gen.greal_type tfrom) e in let in_value = ref false in let rec run e = let was_in_value = !in_value in in_value := true; match e.eexpr with | TReturn (eopt) -> (* a return must be inside a function *) let ret_type = match !current_ret_type with | Some(s) -> s | None -> gen.gcon.error "Invalid return outside function declaration." e.epos; assert false in (match eopt with | None when not (is_void ret_type) -> { e with eexpr = TReturn( Some(null ret_type e.epos)) } | None -> e | Some eret -> { e with eexpr = TReturn( Some(handle (run eret) ret_type eret.etype ) ) }) | TFunction(tfunc) -> let last_ret = !current_ret_type in current_ret_type := Some(tfunc.tf_type); let ret = Type.map_expr run e in current_ret_type := last_ret; ret | TBlock el -> { e with eexpr = TBlock ( List.map (fun e -> in_value := false; run e) el ) } | TBinop ( (Ast.OpAssign as op),e1,e2) | TBinop ( (Ast.OpAssignOp _ as op),e1,e2) when was_in_value -> let e1 = extract_expr (run e1) in let r = { e with eexpr = TBinop(op, e1, handle (run e2) e1.etype e2.etype); etype = e1.etype } in handle r e.etype e1.etype | TBinop ( (Ast.OpAssign as op),({ eexpr = TField(tf, f) } as e1), e2 ) | TBinop ( (Ast.OpAssignOp _ as op),({ eexpr = TField(tf, f) } as e1), e2 ) -> (match field_access_esp gen (gen.greal_type tf.etype) (f) with | FClassField(cl,params,_,_,is_static,actual_t,_) -> let actual_t = if is_static then actual_t else apply_params cl.cl_params params actual_t in let e1 = extract_expr (run e1) in { e with eexpr = TBinop(op, e1, handle (run e2) actual_t e2.etype); etype = e1.etype } | _ -> let e1 = extract_expr (run e1) in { e with eexpr = TBinop(op, e1, handle (run e2) e1.etype e2.etype); etype = e1.etype } ) | TBinop ( (Ast.OpAssign as op),e1,e2) | TBinop ( (Ast.OpAssignOp _ as op),e1,e2) -> let e1 = extract_expr (run e1) in { e with eexpr = TBinop(op, e1, handle (run e2) e1.etype e2.etype); etype = e1.etype } | _ -> Type.map_expr run e in run let configure gen = let map e = Some(default_implementation gen e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; let get_args t = match follow t with | TFun(args,ret) -> args,ret | _ -> trace (debug_type t); assert false let s_path (pack,n) = (String.concat "." (pack @ [n])) (* Since this function is applied under native-context only, the type paraters will already be changed *) let map_cls gen also_implements fn super = let rec loop c tl = if c == super then fn c tl else (match c.cl_super with | None -> false | Some (cs,tls) -> let tls = gen.greal_type_param (TClassDecl cs) tls in loop cs (List.map (apply_params c.cl_params tl) tls) ) || (if also_implements then List.exists (fun (cs,tls) -> loop cs (List.map (apply_params c.cl_params tl) tls) ) c.cl_implements else false) in loop let follow_dyn t = match follow t with | TMono _ | TLazy _ -> t_dynamic | t -> t (* this has a slight change from the type.ml version, in which it doesn't change a TMono into the other parameter *) let rec type_eq gen param a b = if a == b then () else match follow_dyn (gen.greal_type a) , follow_dyn (gen.greal_type b) with | TEnum (e1,tl1) , TEnum (e2,tl2) -> if e1 != e2 && not (param = EqCoreType && e1.e_path = e2.e_path) then Type.error [cannot_unify a b]; List.iter2 (type_eq gen param) tl1 tl2 | TAbstract (a1,tl1) , TAbstract (a2,tl2) -> if a1 != a2 && not (param = EqCoreType && a1.a_path = a2.a_path) then Type.error [cannot_unify a b]; List.iter2 (type_eq gen param) tl1 tl2 | TInst (c1,tl1) , TInst (c2,tl2) -> if c1 != c2 && not (param = EqCoreType && c1.cl_path = c2.cl_path) && (match c1.cl_kind, c2.cl_kind with KExpr _, KExpr _ -> false | _ -> true) then Type.error [cannot_unify a b]; List.iter2 (type_eq gen param) tl1 tl2 | TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 -> (try type_eq gen param r1 r2; List.iter2 (fun (n,o1,t1) (_,o2,t2) -> if o1 <> o2 then Type.error [Not_matching_optional n]; type_eq gen param t1 t2 ) l1 l2 with Unify_error l -> Type.error (cannot_unify a b :: l)) | TDynamic a , TDynamic b -> type_eq gen param a b | TAnon a1, TAnon a2 -> (try PMap.iter (fun n f1 -> try let f2 = PMap.find n a2.a_fields in if f1.cf_kind <> f2.cf_kind && (param = EqStrict || param = EqCoreType || not (unify_kind f1.cf_kind f2.cf_kind)) then Type.error [invalid_kind n f1.cf_kind f2.cf_kind]; try type_eq gen param f1.cf_type f2.cf_type with Unify_error l -> Type.error (invalid_field n :: l) with Not_found -> if is_closed a2 then Type.error [has_no_field b n]; if not (link (ref None) b f1.cf_type) then Type.error [cannot_unify a b]; a2.a_fields <- PMap.add n f1 a2.a_fields ) a1.a_fields; PMap.iter (fun n f2 -> if not (PMap.mem n a1.a_fields) then begin if is_closed a1 then Type.error [has_no_field a n]; if not (link (ref None) a f2.cf_type) then Type.error [cannot_unify a b]; a1.a_fields <- PMap.add n f2 a1.a_fields end; ) a2.a_fields; with Unify_error l -> Type.error (cannot_unify a b :: l)) | _ , _ -> if b == t_dynamic && (param = EqRightDynamic || param = EqBothDynamic) then () else if a == t_dynamic && param = EqBothDynamic then () else Type.error [cannot_unify a b] let type_iseq gen a b = try type_eq gen EqStrict a b; true with Unify_error _ -> false (* will return true if both arguments are compatible. If it's not the case, a runtime error is very likely *) let is_cl_related gen cl tl super superl = let is_cl_related cl tl super superl = map_cls gen (gen.guse_tp_constraints || (match cl.cl_kind,super.cl_kind with KTypeParameter _, _ | _,KTypeParameter _ -> false | _ -> true)) (fun _ _ -> true) super cl tl in is_cl_related cl tl super superl || is_cl_related super superl cl tl let rec is_unsafe_cast gen to_t from_t = match (follow to_t, follow from_t) with | TInst(cl_to, to_params), TInst(cl_from, from_params) -> not (is_cl_related gen cl_from from_params cl_to to_params) | TEnum(e_to, _), TEnum(e_from, _) -> e_to.e_path <> e_from.e_path | TFun _, TFun _ -> (* functions are never unsafe cast by default. This behavior might be changed *) (* with a later AST pass which will run through TFun to TFun casts *) false | TMono _, _ | _, TMono _ | TDynamic _, _ | _, TDynamic _ -> false | TAnon _, _ | _, TAnon _ -> (* anonymous are never unsafe also. *) (* Though they will generate a cast, so if this cast is unneeded it's better to avoid them by tweaking gen.greal_type *) false | TAbstract _, _ | _, TAbstract _ -> (try unify from_t to_t; false with | Unify_error _ -> try unify to_t from_t; (* still not unsafe *) false with | Unify_error _ -> true) | _ -> true let unifies tfrom tto = try unify tfrom tto; true with | _ -> false let do_unsafe_cast gen from_t to_t e = let t_path t = match t with | TInst(cl, _) -> cl.cl_path | TEnum(e, _) -> e.e_path | TType(t, _) -> t.t_path | TAbstract(a, _) -> a.a_path | TDynamic _ -> ([], "Dynamic") | _ -> raise Not_found in match gen.gfollow#run_f from_t, gen.gfollow#run_f to_t with | TInst({ cl_kind = KTypeParameter tl },_), t2 when List.exists (fun t -> unifies t t2) tl -> mk_cast to_t (mk_cast t_dynamic e) | _ -> let do_default () = gen.gon_unsafe_cast to_t e.etype e.epos; mk_cast to_t (mk_cast t_dynamic e) in (* TODO: there really should be a better way to write that *) try if (Hashtbl.find gen.gsupported_conversions (t_path from_t)) from_t to_t then mk_cast to_t e else do_default() with | Not_found -> try if (Hashtbl.find gen.gsupported_conversions (t_path to_t)) from_t to_t then mk_cast to_t e else do_default() with | Not_found -> do_default() (* ****************************** *) (* cast handler *) (* decides if a cast should be emitted, given a from and a to type *) (* this function is like a mini unify, without e.g. subtyping, which makes sense at the backend level, since most probably Anons and TInst will have a different representation there *) let rec handle_cast gen e real_to_t real_from_t = let do_unsafe_cast () = do_unsafe_cast gen real_from_t real_to_t { e with etype = real_from_t } in let to_t, from_t = real_to_t, real_from_t in let mk_cast t e = match e.eexpr with (* TThrow is always typed as Dynamic, we just need to type it accordingly *) | TThrow _ -> { e with etype = t } | _ -> mk_cast t e in let e = { e with etype = real_from_t } in if try fast_eq real_to_t real_from_t with Invalid_argument("List.for_all2") -> false then e else match real_to_t, real_from_t with (* string is the only type that can be implicitly converted from any other *) | TInst( { cl_path = ([], "String") }, []), _ -> mk_cast to_t e | TInst(cl_to, params_to), TInst(cl_from, params_from) -> let ret = ref None in (* this is a little confusing: we are here mapping classes until we have the same to and from classes, applying the type parameters in each step, so we can compare the type parameters; If a class is found - meaning that the cl_from can be converted without a cast into cl_to, we still need to check their type parameters. *) ignore (map_cls gen (gen.guse_tp_constraints || (match cl_from.cl_kind,cl_to.cl_kind with KTypeParameter _, _ | _,KTypeParameter _ -> false | _ -> true)) (fun _ tl -> try (* type found, checking type parameters *) List.iter2 (type_eq gen EqStrict) tl params_to; ret := Some e; true with | Unify_error _ -> (* type parameters need casting *) if gen.ghas_tparam_cast_handler then begin (* if we are already handling type parameter casts on other part of code (e.g. RealTypeParameters), we'll just make a cast to indicate that this place needs type parameter-involved casting *) ret := Some (mk_cast to_t e); true end else (* if not, we're going to check if we only need a simple cast, or if we need to first cast into the dynamic version of it *) try List.iter2 (type_eq gen EqRightDynamic) tl params_to; ret := Some (mk_cast to_t e); true with | Unify_error _ -> ret := Some (mk_cast to_t (mk_cast (TInst(cl_to, List.map (fun _ -> t_dynamic) params_to)) e)); true ) cl_to cl_from params_from); if is_some !ret then get !ret else if is_cl_related gen cl_from params_from cl_to params_to then mk_cast to_t e else (* potential unsafe cast *) (do_unsafe_cast ()) | TMono _, TMono _ | TMono _, TDynamic _ | TDynamic _, TDynamic _ | TDynamic _, TMono _ -> e | TMono _, _ | TDynamic _, _ | TAnon _, _ when gen.gneeds_box real_from_t -> mk_cast to_t e | TMono _, _ | TDynamic _, _ -> e | _, TMono _ | _, TDynamic _ -> mk_cast to_t e | TAnon (a_to), TAnon (a_from) -> if a_to == a_from then e else if type_iseq gen to_t from_t then (* FIXME apply unify correctly *) e else mk_cast to_t e | _, TAnon(anon) -> (try let p2 = match !(anon.a_status) with | Statics c -> TInst(c,List.map (fun _ -> t_dynamic) c.cl_params) | EnumStatics e -> TEnum(e, List.map (fun _ -> t_dynamic) e.e_params) | AbstractStatics a -> TAbstract(a, List.map (fun _ -> t_dynamic) a.a_params) | _ -> raise Not_found in let tclass = match get_type gen ([],"Class") with | TAbstractDecl(a) -> a | _ -> assert false in handle_cast gen e real_to_t (gen.greal_type (TAbstract(tclass, [p2]))) with | Not_found -> mk_cast to_t e) | TAbstract (a_to, _), TAbstract(a_from, _) when a_to == a_from -> e | TAbstract _, TInst({ cl_kind = KTypeParameter _ }, _) | TInst({ cl_kind = KTypeParameter _ }, _), TAbstract _ -> do_unsafe_cast() | TAbstract _, _ | _, TAbstract _ -> (try unify from_t to_t; mk_cast to_t e with | Unify_error _ -> try unify to_t from_t; mk_cast to_t e with | Unify_error _ -> do_unsafe_cast()) | TEnum(e_to, []), TEnum(e_from, []) -> if e_to == e_from then e else (* potential unsafe cast *) (do_unsafe_cast ()) | TEnum(e_to, params_to), TEnum(e_from, params_from) when e_to.e_path = e_from.e_path -> (try List.iter2 (type_eq gen (if gen.gallow_tp_dynamic_conversion then EqRightDynamic else EqStrict)) params_from params_to; e with | Unify_error _ -> do_unsafe_cast () ) | TEnum(en, params_to), TInst(cl, params_from) | TInst(cl, params_to), TEnum(en, params_from) -> (* this is here for max compatibility with EnumsToClass module *) if en.e_path = cl.cl_path && Meta.has Meta.Class en.e_meta then begin (try List.iter2 (type_eq gen (if gen.gallow_tp_dynamic_conversion then EqRightDynamic else EqStrict)) params_from params_to; e with | Invalid_argument("List.iter2") -> (* this is a hack for RealTypeParams. Since there is no way at this stage to know if the class is the actual EnumsToClass derived from the enum, we need to imply from possible ArgumentErrors (because of RealTypeParams interfaces), that they would only happen if they were a RealTypeParams created interface *) e | Unify_error _ -> do_unsafe_cast () ) end else do_unsafe_cast () | TType(t_to, params_to), TType(t_from, params_from) when t_to == t_from -> if gen.gspecial_needs_cast real_to_t real_from_t then (try List.iter2 (type_eq gen (if gen.gallow_tp_dynamic_conversion then EqRightDynamic else EqStrict)) params_from params_to; e with | Unify_error _ -> do_unsafe_cast () ) else e | TType(t_to, _), TType(t_from,_) -> if gen.gspecial_needs_cast real_to_t real_from_t then mk_cast to_t e else e | TType _, _ when gen.gspecial_needs_cast real_to_t real_from_t -> mk_cast to_t e | _, TType _ when gen.gspecial_needs_cast real_to_t real_from_t -> mk_cast to_t e (*| TType(t_to, _), TType(t_from, _) -> if t_to.t_path = t_from.t_path then e else if is_unsafe_cast gen real_to_t real_from_t then (* is_unsafe_cast will already follow both *) (do_unsafe_cast ()) else mk_cast to_t e*) | TType _, _ | _, TType _ -> if is_unsafe_cast gen real_to_t real_from_t then (* is_unsafe_cast will already follow both *) (do_unsafe_cast ()) else mk_cast to_t e | TAnon anon, _ -> if PMap.is_empty anon.a_fields then e else mk_cast to_t e | TFun(args, ret), TFun(args2, ret2) -> let get_args = List.map (fun (_,_,t) -> t) in (try List.iter2 (type_eq gen (EqBothDynamic)) (ret :: get_args args) (ret2 :: get_args args2); e with | Unify_error _ | Invalid_argument("List.iter2") -> mk_cast to_t e) | _, _ -> do_unsafe_cast () (* end of cast handler *) (* ******************* *) let is_static_overload c name = match c.cl_super with | None -> false | Some (sup,_) -> let rec loop c = (PMap.mem name c.cl_statics) || (match c.cl_super with | None -> false | Some (sup,_) -> loop sup) in loop sup let does_unify a b = try unify a b; true with | Unify_error _ -> false (* this is a workaround for issue #1743, as FInstance() is returning the incorrect classfield *) let rec clean_t t = match follow t with | TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) -> clean_t (Abstract.get_underlying_type a tl) | t -> t let select_overload gen applied_f overloads types params = let rec check_arg arglist elist = match arglist, elist with | [], [] -> true (* it is valid *) | (_,_,TAbstract({ a_path = (["haxe";"extern"],"Rest") }, [t])) :: [], elist -> List.for_all (fun (_,_,et) -> Type.type_iseq (clean_t et) (clean_t t)) elist | (_,_,t) :: arglist, (_,_,et) :: elist when Type.type_iseq (clean_t et) (clean_t t) -> check_arg arglist elist | _ -> false in match follow applied_f with | TFun _ -> replace_mono applied_f; let args, _ = get_fun applied_f in let elist = List.rev args in let rec check_overload overloads = match overloads with | (t, cf) :: overloads -> let cft = apply_params types params t in let cft = monomorphs cf.cf_params cft in let args, _ = get_fun cft in if check_arg (List.rev args) elist then cf,t,false else if overloads = [] then cf,t,true (* no compatible overload was found *) else check_overload overloads | [] -> assert false in check_overload overloads | _ -> match overloads with (* issue #1742 *) | (t,cf) :: [] -> cf,t,true | (t,cf) :: _ -> cf,t,false | _ -> assert false let choose_ctor gen cl tparams etl maybe_empty_t p = let ctor, sup, stl = OverloadingConstructor.cur_ctor cl tparams in (* get returned stl, with Dynamic as t_empty *) let rec get_changed_stl c tl = if c == sup then tl else match c.cl_super with | None -> stl | Some(sup,stl) -> get_changed_stl sup (List.map (apply_params c.cl_params tl) stl) in let ret_tparams = List.map (fun t -> match follow t with | TDynamic _ | TMono _ -> t_empty | _ -> t) tparams in let ret_stl = get_changed_stl cl ret_tparams in let ctors = ctor :: ctor.cf_overloads in List.iter replace_mono etl; (* first filter out or select outright maybe_empty *) let ctors, is_overload = match etl, maybe_empty_t with | [t], Some empty_t -> let count = ref 0 in let is_empty_call = Type.type_iseq t empty_t in let ret = List.filter (fun cf -> match follow cf.cf_type with (* | TFun([_,_,t],_) -> incr count; true *) | TFun([_,_,t],_) -> replace_mono t; incr count; is_empty_call = (Type.type_iseq t empty_t) | _ -> false) ctors in ret, !count > 1 | _ -> let len = List.length etl in let ret = List.filter (fun cf -> List.length (fst (get_fun cf.cf_type)) = len) ctors in ret, (match ret with | _ :: [] -> false | _ -> true) in let rec check_arg arglist elist = match arglist, elist with | [], [] -> true | (_,_,t) :: arglist, et :: elist -> (try let t = run_follow gen t in unify et t; check_arg arglist elist with | Unify_error el -> (* List.iter (fun el -> gen.gcon.warning (Typecore.unify_error_msg (print_context()) el) p) el; *) false) | _ -> false in let rec check_cf cf = let t = apply_params sup.cl_params stl cf.cf_type in replace_mono t; let args, _ = get_fun t in check_arg args etl in match is_overload, ctors with | false, [c] -> false, c, sup, ret_stl | _ -> is_overload, List.find check_cf ctors, sup, ret_stl let change_rest tfun elist = let rec loop acc arglist elist = match arglist, elist with | (_,_,TAbstract({ a_path = (["haxe";"extern"],"Rest") },[t])) :: [], elist -> List.rev (List.map (fun _ -> "rest",false,t) elist @ acc) | (n,o,t) :: arglist, _ :: elist -> loop ((n,o,t) :: acc) arglist elist | _, _ -> List.rev acc in let args,ret = get_fun tfun in TFun(loop [] args elist, ret) (* Type parameter handling It will detect if/what type parameters were used, and call the cast handler It will handle both TCall(TField) and TCall by receiving a texpr option field: e Also it will transform the type parameters with greal_type_param and make handle_impossible_tparam - should cases where the type parameter is impossible to be determined from the called parameters be Dynamic? e.g. static function test():T {} *) (* match e.eexpr with | TCall( ({ eexpr = TField(ef, f) }) as e1, elist ) -> *) let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist calls_parameters_explicitly = (* the ONLY way to know if this call has parameters is to analyze the calling field. *) (* To make matters a little worse, on both C# and Java only in some special cases that type parameters will be used *) (* Namely, when using reflection type parameters are useless, of course. This also includes anonymous types *) (* this will have to be handled by gparam_func_call *) let return_var efield = match e with | None -> efield | Some ecall -> match follow efield.etype with | TFun(_,ret) -> (* closures will be handled by the closure handler. So we will just hint what's the expected type *) (* FIXME: should closures have also its arguments cast correctly? In the current implementation I think not. TO_REVIEW *) handle_cast gen { ecall with eexpr = TCall(efield, elist) } (gen.greal_type ecall.etype) ret | _ -> { ecall with eexpr = TCall(efield, elist) } in let real_type = gen.greal_type ef.etype in (* this part was rewritten at roughly r6477 in order to correctly support overloads *) (match field_access_esp gen real_type (f) with | FClassField (cl, params, _, cf, is_static, actual_t, declared_t) when e <> None && (cf.cf_kind = Method MethNormal || cf.cf_kind = Method MethInline) -> (* C# target changes params with a real_type function *) let params = match follow clean_ef.etype with | TInst(_,params) -> params | _ -> params in let ecall = get e in let ef = ref ef in let is_overload = cf.cf_overloads <> [] || Meta.has Meta.Overload cf.cf_meta || (is_static && is_static_overload cl (field_name f)) in let cf, actual_t, error = match is_overload with | false -> (* since actual_t from FClassField already applies greal_type, we're using the get_overloads helper to get this info *) let t = if cf.cf_params = [] then (* this if statement must be eliminated - it's a workaround for #3516 + infer params. *) actual_t else declared_t in cf,t,false | true -> let (cf, actual_t, error), is_static = match f with | FInstance(c,_,cf) | FClosure(Some (c,_),cf) -> (* get from overloads *) (* FIXME: this is a workaround for issue #1743 . Uncomment this code after it was solved *) (* let t, cf = List.find (fun (t,cf2) -> cf == cf2) (Typeload.get_overloads cl (field_name f)) in *) (* cf, t, false *) select_overload gen e1.etype (Typeload.get_overloads cl (field_name f)) cl.cl_params params, false | FStatic(c,f) -> (* workaround for issue #1743 *) (* f,f.cf_type, false *) select_overload gen e1.etype ((f.cf_type,f) :: List.map (fun f -> f.cf_type,f) f.cf_overloads) [] [], true | _ -> gen.gcon.warning "Overloaded classfield typed as anonymous" ecall.epos; (cf, actual_t, true), true in if not (is_static || error) then match find_first_declared_field gen cl ~exact_field:{ cf with cf_type = actual_t } cf.cf_name with | Some(cf_orig,actual_t,_,_,declared_cl,tl,tlch) -> let rec is_super e = match e.eexpr with | TConst TSuper -> true | TParenthesis p | TMeta(_,p) -> is_super p | _ -> false in if declared_cl != cl && overloads_cast_to_base && not (is_super !ef) then begin let pos = (!ef).epos in ef := { eexpr = TCall( { eexpr = TLocal(alloc_var "__as__" t_dynamic); etype = t_dynamic; epos = pos }, [!ef]); etype = TInst(declared_cl,List.map (apply_params cl.cl_params params) tl); epos = pos } end; { cf_orig with cf_name = cf.cf_name },actual_t,false | None -> gen.gcon.warning "Cannot find matching overload" ecall.epos; cf, actual_t, true else cf,actual_t,error in (* take off Rest param *) let actual_t = change_rest actual_t elist in (* set the real (selected) class field *) let f = match f with | FInstance(c,tl,_) -> FInstance(c,tl,cf) | FClosure(c,_) -> FClosure(c,cf) | FStatic(c,_) -> FStatic(c,cf) | f -> f in let error = error || (match follow actual_t with | TFun _ -> false | _ -> true) in if error then (* if error, ignore arguments *) if is_void ecall.etype then { ecall with eexpr = TCall({ e1 with eexpr = TField(!ef, f) }, elist ) } else mk_cast ecall.etype { ecall with eexpr = TCall({ e1 with eexpr = TField(!ef, f) }, elist ) } else begin (* infer arguments *) (* let called_t = TFun(List.map (fun e -> "arg",false,e.etype) elist, ecall.etype) in *) let called_t = match follow e1.etype with | TFun _ -> e1.etype | _ -> TFun(List.map (fun e -> "arg",false,e.etype) elist, ecall.etype) in (* workaround for issue #1742 *) let called_t = change_rest called_t elist in let fparams = TypeParams.infer_params gen ecall.epos (get_fun (apply_params cl.cl_params params actual_t)) (get_fun called_t) cf.cf_params calls_parameters_explicitly in (* get what the backend actually sees *) (* actual field's function *) let actual_t = get_real_fun gen actual_t in let real_params = gen.greal_type_param (TClassDecl cl) params in let function_t = apply_params cl.cl_params real_params actual_t in let real_fparams = if calls_parameters_explicitly then gen.greal_type_param (TClassDecl cl) fparams else gen.greal_type_param (TClassDecl cl) (TypeParams.infer_params gen ecall.epos (get_fun function_t) (get_fun (get_real_fun gen called_t)) cf.cf_params calls_parameters_explicitly) in let function_t = get_real_fun gen (apply_params cf.cf_params real_fparams function_t) in let args_ft, ret_ft = get_fun function_t in (* applied function *) let applied = elist in (* check types list *) let new_ecall, elist = try let elist = List.map2 (fun applied (_,_,funct) -> match is_overload, applied.eexpr with | true, TConst TNull -> mk_cast (gen.greal_type funct) applied | true, _ -> (* when not (type_iseq gen (gen.greal_type applied.etype) funct) -> *) let ret = handle_cast gen applied (funct) (gen.greal_type applied.etype) in (match ret.eexpr with | TCast _ -> ret | _ -> mk_cast (funct) ret) | _ -> handle_cast gen applied (funct) (gen.greal_type applied.etype) ) applied args_ft in { ecall with eexpr = TCall( { e1 with eexpr = TField(!ef, f) }, elist); }, elist with | Invalid_argument("List.map2") -> gen.gcon.warning ("This expression may be invalid" ) ecall.epos; { ecall with eexpr = TCall({ e1 with eexpr = TField(!ef, f) }, elist) }, elist in let new_ecall = if fparams <> [] then gen.gparam_func_call new_ecall { e1 with eexpr = TField(!ef, f) } fparams elist else new_ecall in let ret = handle_cast gen new_ecall (gen.greal_type ecall.etype) (gen.greal_type ret_ft) in (match gen.gcon.platform, cf.cf_params, ret.eexpr with | _, _, TCast _ -> ret | Java, _ :: _, _ -> (* this is a workaround for a javac openjdk issue with unused type parameters and return type inference *) (* see more at issue #3123 *) mk_cast (gen.greal_type ret_ft) new_ecall | _ -> ret) end | FClassField (cl,params,_,{ cf_kind = (Method MethDynamic | Var _) },_,actual_t,_) -> (* if it's a var, we will just try to apply the class parameters that have been changed with greal_type_param *) let t = apply_params cl.cl_params (gen.greal_type_param (TClassDecl cl) params) (gen.greal_type actual_t) in return_var (handle_cast gen { e1 with eexpr = TField(ef, f) } (gen.greal_type e1.etype) (gen.greal_type t)) | FClassField (cl,params,_,cf,_,actual_t,_) -> return_var (handle_cast gen { e1 with eexpr = TField({ ef with etype = t_dynamic }, f) } e1.etype t_dynamic) (* force dynamic and cast back to needed type *) | FEnumField (en, efield, true) -> let ecall = match e with | None -> trace (field_name f); trace efield.ef_name; gen.gcon.error "This field should be called immediately" ef.epos; assert false | Some ecall -> ecall in (match en.e_params with (* | [] -> let args, ret = get_args (efield.ef_type) in let ef = { ef with eexpr = TTypeExpr( TEnumDecl en ); etype = TEnum(en, []) } in handle_cast gen { ecall with eexpr = TCall({ e1 with eexpr = TField(ef, FEnum(en, efield)) }, List.map2 (fun param (_,_,t) -> handle_cast gen param (gen.greal_type t) (gen.greal_type param.etype)) elist args) } (gen.greal_type ecall.etype) (gen.greal_type ret) *) | _ -> let pt = match e with | None -> real_type | Some _ -> snd (get_fun e1.etype) in let _params = match follow pt with | TEnum(_, p) -> p | _ -> gen.gcon.warning (debug_expr e1) e1.epos; assert false in let args, ret = get_args efield.ef_type in let actual_t = TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret) in (* because of differences on how is handled on the platforms, this is a hack to be able to correctly use class field type parameters with RealTypeParams *) let cf_params = List.map (fun t -> match follow t with | TDynamic _ -> t_empty | _ -> t) _params in let t = apply_params en.e_params (gen.greal_type_param (TEnumDecl en) cf_params) actual_t in let t = apply_params efield.ef_params (List.map (fun _ -> t_dynamic) efield.ef_params) t in let args, ret = get_args t in let elist = List.map2 (fun param (_,_,t) -> handle_cast gen (param) (gen.greal_type t) (gen.greal_type param.etype)) elist args in let e1 = { e1 with eexpr = TField({ ef with eexpr = TTypeExpr( TEnumDecl en ); etype = TEnum(en, _params) }, FEnum(en, efield) ) } in let new_ecall = gen.gparam_func_call ecall e1 _params elist in handle_cast gen new_ecall (gen.greal_type ecall.etype) (gen.greal_type ret) ) | FEnumField _ when is_some e -> assert false | FEnumField (en,efield,_) -> return_var { e1 with eexpr = TField({ ef with eexpr = TTypeExpr( TEnumDecl en ); },FEnum(en,efield)) } (* no target by date will uses this.so this code may not be correct at all *) | FAnonField cf -> let t = gen.greal_type cf.cf_type in return_var (handle_cast gen { e1 with eexpr = TField(ef, f) } (gen.greal_type e1.etype) t) | FNotFound | FDynamicField _ -> if is_some e then return_var { e1 with eexpr = TField(ef, f) } else return_var (handle_cast gen { e1 with eexpr = TField({ ef with etype = t_dynamic }, f) } e1.etype t_dynamic) (* force dynamic and cast back to needed type *) ) (* end of type parameter handling *) (* ****************************** *) (** overloads_cast_to_base argument will cast overloaded function types to the class that declared it. **) (** This is necessary for C#, and if true, will require the target to implement __as__, as a `quicker` form of casting **) let default_implementation gen ?(native_string_cast = true) ?(overloads_cast_to_base = false) maybe_empty_t calls_parameters_explicitly = let handle e t1 t2 = handle_cast gen e (gen.greal_type t1) (gen.greal_type t2) in let in_value = ref false in let rec clean_cast e = match e.eexpr with | TCast(e,_) -> clean_cast e | TParenthesis(e) | TMeta(_,e) -> clean_cast e | _ -> e in let get_abstract_impl t = match t with | TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> Abstract.get_underlying_type a pl | t -> t in let rec is_abstract_to_struct t = match t with | TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> is_abstract_to_struct (Abstract.get_underlying_type a pl) | TInst(c,_) when Meta.has Meta.Struct c.cl_meta -> true | _ -> false in let rec run ?(just_type = false) e = let handle = if not just_type then handle else fun e t1 t2 -> { e with etype = gen.greal_type t2 } in let was_in_value = !in_value in in_value := true; match e.eexpr with | TConst ( TInt _ | TFloat _ | TBool _ as const ) -> (* take off any Null<> that it may have *) let t = follow (run_follow gen e.etype) in (* do not allow constants typed as Single - need to cast them *) let real_t = match const with | TInt _ -> gen.gcon.basic.tint | TFloat _ -> gen.gcon.basic.tfloat | TBool _ -> gen.gcon.basic.tbool | _ -> assert false in handle e t real_t | TCast( { eexpr = TConst TNull }, _ ) -> { e with eexpr = TConst TNull } | TCast( { eexpr = TCall( { eexpr = TLocal { v_name = "__delegate__" } } as local, [del] ) } as e2, _) -> { e with eexpr = TCast({ e2 with eexpr = TCall(local, [Type.map_expr run del]) }, None) } | TBinop ( (Ast.OpAssign | Ast.OpAssignOp _ as op), e1, e2 ) -> let e1 = run ~just_type:true e1 in let e2 = handle (run e2) e1.etype e2.etype in { e with eexpr = TBinop(op, clean_cast e1, e2) } | TBinop ( (Ast.OpShl | Ast.OpShr | Ast.OpUShr as op), e1, e2 ) -> let e1 = run e1 in let e2 = handle (run e2) (gen.gcon.basic.tint) e2.etype in { e with eexpr = TBinop(op, e1, e2) } | TField(ef, f) -> handle_type_parameter gen None e (run ef) ~clean_ef:ef ~overloads_cast_to_base:overloads_cast_to_base f [] calls_parameters_explicitly | TArrayDecl el -> let et = e.etype in let base_type = match follow et with | TInst({ cl_path = ([], "Array") } as cl, bt) -> gen.greal_type_param (TClassDecl cl) bt | _ -> gen.gcon.warning (debug_type et) e.epos; (match gen.gcurrent_class with | Some cl -> print_endline (path_s cl.cl_path) | _ -> ()); assert false in let base_type = List.hd base_type in { e with eexpr = TArrayDecl( List.map (fun e -> handle (run e) base_type e.etype) el ); etype = et } | TCall ({ eexpr = TLocal { v_name = "__array__" } } as arr_local, el) -> let et = e.etype in let base_type = match follow et with | TInst(cl, bt) -> gen.greal_type_param (TClassDecl cl) bt | _ -> assert false in let base_type = List.hd base_type in { e with eexpr = TCall(arr_local, List.map (fun e -> handle (run e) base_type e.etype) el ); etype = et } | TCall( ({ eexpr = TLocal v } as local), params ) when String.get v.v_name 0 = '_' && String.get v.v_name 1 = '_' && Hashtbl.mem gen.gspecial_vars v.v_name -> { e with eexpr = TCall(local, List.map (fun e -> (match e.eexpr with TBlock _ -> in_value := false | _ -> ()); run e) params) } | TCall( ({ eexpr = TField(ef, f) }) as e1, elist ) -> handle_type_parameter gen (Some e) (e1) (run ef) ~clean_ef:ef ~overloads_cast_to_base:overloads_cast_to_base f (List.map run elist) calls_parameters_explicitly (* the TNew and TSuper code was modified at r6497 *) | TCall( { eexpr = TConst TSuper } as ef, eparams ) -> let cl, tparams = match follow ef.etype with | TInst(cl,p) -> cl,p | _ -> assert false in (try let is_overload, cf, sup, stl = choose_ctor gen cl tparams (List.map (fun e -> e.etype) eparams) maybe_empty_t e.epos in let handle e t1 t2 = if is_overload then let ret = handle e t1 t2 in match ret.eexpr with | TCast _ -> ret | _ -> mk_cast (gen.greal_type t1) e else handle e t1 t2 in let stl = gen.greal_type_param (TClassDecl sup) stl in let args, _ = get_fun (apply_params sup.cl_params stl cf.cf_type) in let eparams = List.map2 (fun e (_,_,t) -> handle (run e) t e.etype ) eparams args in { e with eexpr = TCall(ef, eparams) } with | Not_found -> gen.gcon.warning "No overload found for this constructor call" e.epos; { e with eexpr = TCall(ef, List.map run eparams) }) | TCall (ef, eparams) -> (match ef.etype with | TFun(p, ret) -> handle ({ e with eexpr = TCall(run ef, List.map2 (fun param (_,_,t) -> handle (run param) t param.etype) eparams p) }) e.etype ret | _ -> Type.map_expr run e ) (* the TNew and TSuper code was modified at r6497 *) | TNew ({ cl_kind = KTypeParameter _ }, _, _) -> Type.map_expr run e | TNew (cl, tparams, eparams) -> (try let is_overload, cf, sup, stl = choose_ctor gen cl tparams (List.map (fun e -> e.etype) eparams) maybe_empty_t e.epos in let handle e t1 t2 = if is_overload then let ret = handle e t1 t2 in match ret.eexpr with | TCast _ -> ret | _ -> mk_cast (gen.greal_type t1) e else handle e t1 t2 in let stl = gen.greal_type_param (TClassDecl sup) stl in let args, _ = get_fun (apply_params sup.cl_params stl cf.cf_type) in let eparams = List.map2 (fun e (_,_,t) -> handle (run e) t e.etype ) eparams args in { e with eexpr = TNew(cl, tparams, eparams) } with | Not_found -> gen.gcon.warning "No overload found for this constructor call" e.epos; { e with eexpr = TNew(cl, tparams, List.map run eparams) }) | TArray(arr, idx) -> let arr_etype = match follow arr.etype with | (TInst _ as t) -> t | TAbstract (a, pl) when not (Meta.has Meta.CoreType a.a_meta) -> follow (Abstract.get_underlying_type a pl) | t -> t in let idx = match gen.greal_type idx.etype with | TAbstract({ a_path = [],"Int" },_) -> run idx | _ -> match handle (run idx) gen.gcon.basic.tint (gen.greal_type idx.etype) with | ({ eexpr = TCast _ } as idx) -> idx | idx -> mk_cast gen.gcon.basic.tint idx in let e = { e with eexpr = TArray(run arr, idx) } in (* get underlying class (if it's a class *) (match arr_etype with | TInst(cl, params) -> (* see if it implements ArrayAccess *) (match cl.cl_array_access with | None -> e | Some t -> (* if it does, apply current parameters (and change them) *) (* let real_t = apply_params_internal (List.map (gen.greal_type_param (TClassDecl cl))) cl params t in *) let param = apply_params cl.cl_params (gen.greal_type_param (TClassDecl cl) params) t in let real_t = apply_params cl.cl_params params param in (* see if it needs a cast *) handle (e) (gen.greal_type e.etype) (gen.greal_type real_t) ) | _ -> Type.map_expr run e) | TVar (v, eopt) -> { e with eexpr = TVar (v, match eopt with | None -> eopt | Some e -> Some( handle (run e) v.v_type e.etype )) } (* FIXME deal with in_value when using other statements that may not have a TBlock wrapped on them *) | TIf (econd, ethen, Some(eelse)) when was_in_value -> { e with eexpr = TIf (handle (run econd) gen.gcon.basic.tbool econd.etype, handle (run ethen) e.etype ethen.etype, Some( handle (run eelse) e.etype eelse.etype ) ) } | TIf (econd, ethen, eelse) -> { e with eexpr = TIf (handle (run econd) gen.gcon.basic.tbool econd.etype, (in_value := false; run (mk_block ethen)), Option.map (fun e -> in_value := false; run (mk_block e)) eelse) } | TWhile (econd, e1, flag) -> { e with eexpr = TWhile (handle (run econd) gen.gcon.basic.tbool econd.etype, (in_value := false; run (mk_block e1)), flag) } | TSwitch (cond, el_e_l, edef) -> { e with eexpr = TSwitch(run cond, List.map (fun (el,e) -> (List.map run el, (in_value := false; run (mk_block e)))) el_e_l, Option.map (fun e -> in_value := false; run (mk_block e)) edef) } (* | TMatch (cond, en, il_vl_e_l, edef) -> { e with eexpr = TMatch(run cond, en, List.map (fun (il, vl, e) -> (il, vl, run (mk_block e))) il_vl_e_l, Option.map (fun e -> run (mk_block e)) edef) } *) | TFor (v,cond,e1) -> { e with eexpr = TFor(v, run cond, (in_value := false; run (mk_block e1))) } | TTry (e, ve_l) -> { e with eexpr = TTry((in_value := false; run (mk_block e)), List.map (fun (v,e) -> in_value := false; (v, run (mk_block e))) ve_l) } | TBlock el -> let i = ref 0 in let len = List.length el in { e with eexpr = TBlock ( List.map (fun e -> incr i; if !i <> len || not was_in_value then in_value := false; run e ) el ) } | TCast (expr, md) when is_void (follow e.etype) -> run expr | TCast (expr, md) -> let rec get_null e = match e.eexpr with | TConst TNull -> Some e | TParenthesis e | TMeta(_,e) -> get_null e | _ -> None in (match get_null expr with | Some enull -> if gen.gcon.platform = Cs then { enull with etype = gen.greal_type e.etype } else mk_cast (gen.greal_type e.etype) enull | _ when is_abstract_to_struct expr.etype && type_iseq gen e.etype (get_abstract_impl expr.etype) -> run { expr with etype = expr.etype } | _ -> match gen.greal_type e.etype, gen.greal_type expr.etype with | (TInst(c,tl) as tinst1), TAbstract({ a_path = ["cs"],"Pointer" }, [tinst2]) when type_iseq gen tinst1 (gen.greal_type tinst2) -> run expr | _ -> let last_unsafe = gen.gon_unsafe_cast in gen.gon_unsafe_cast <- (fun t t2 pos -> ()); let ret = handle (run expr) e.etype expr.etype in gen.gon_unsafe_cast <- last_unsafe; match ret.eexpr with | TCast _ -> { ret with etype = gen.greal_type e.etype } | _ -> { e with eexpr = TCast(ret,md); etype = gen.greal_type e.etype } ) (*| TCast _ -> (* if there is already a cast, we should skip this cast check *) Type.map_expr run e*) | TFunction f -> in_value := false; Type.map_expr run e | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = gen.ghandle_cast <- (fun tto tfrom expr -> handle_cast gen expr (gen.greal_type tto) (gen.greal_type tfrom)); let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map; ReturnCast.configure gen end;; (* ******************************************* *) (* Reflection-enabling Class fields *) (* ******************************************* *) (* This is the most hardcore codegen part of the code. There's much to improve so this code can be more readable, but at least it's running correctly right now! This will be improved. (TODO) This module will create class fields that enable reflection for targets that have a slow or inexistent reflection abilities. Because of the similarity of strategies between what should have been different modules, they are all unified in this reflection-enabling class fields. They include: * Get(isStatic, throwErrors, isCheck) / Set fields . Remember to allow implements Dynamic also. * Invoke fields(isStatic) -> You need to configure how many invoke_field fields there will be. + invokeDynamic * Has field -> parameter in get field that returns __undefined__ if it doesn't exist. * GetType -> return the current Class<> / Enum<> * Fields(isStatic) -> returns all the fields / static fields. Remember to allow implements Dynamic also * Create(arguments array), CreateEmpty - calls new() or create empty * getInstanceFields / getClassFields -> show even function fields, everything! * deleteField -> only for implements Dynamic for enums: * createEnum -> invokeField for classes * createEnumIndex -> use invokeField as well, and use numbers e.g. "0", "1", "2" .... For this, use "@:alias" metadata * getEnumConstructs -> fields() need to be solved outside: * getEnumName * enumIndex * need to be solved by haxe code: * enumParameters -> for (field in Reflect.fields(enum)) arr.push(Reflect.field(enum, field)) Standard: if a class contains a @:$enum metadata, it's treated as a converted enum to class Optimizations: * if optimize is true, all fields will be hashed by the same hashing function as neko (31 bits int : always positive). Every function that expects a string for the field will expect also an int, for the hash a string (which is nullable for compile-time hashes) + an int. At compile-time, a collision will throw an error (like neko). At runtime, a collision will make a negative int. Negative ints will always resolve to a special Hash<> field which takes a string. * if optimize is true, Reflect.field/setField will be replaced by either the runtime version (with already hashed string), either by the own .Field()/.SetField() HxObject's version, if the type is detected to already be hxgen * TODO: if for() optimization for arrays is disabled, we can replace for(field in Reflect.fields(obj)) to: for (field in ( (Std.is(obj, HxObject) ? ((HxObject)obj).Fields() : Reflect.fields(obj)) )) // no array copying . for further optimization this could be guaranteed to return the already hashed fields. Mappings: * if create Dynamic class is true, TObjectDecl will be mapped to new DynamicClass(fields, [hashedFields], values) * dependencies: There is no big dependency from this target. Though it should be a syntax filter, mainly one of the first so most expression generation has already been done, while the AST has its meaning close to haxe's. Should run before InitFunction so it detects variables containing expressions as "always-execute" expressions, even when using CreateEmpty * Must run before switch() syntax changes *) open ClosuresToClass;; module ReflectionCFs = struct let name = "reflection_cfs" type rcf_ctx = { rcf_gen : generator_ctx; rcf_ft : ClosuresToClass.closures_ctx; rcf_optimize : bool; mutable rcf_float_special_case : bool; mutable rcf_object_iface : tclass; mutable rcf_create_getsetinvoke_fields : bool; (* should we create the get type (get Class)? *) mutable rcf_create_get_type : bool; (* should we handle implements dynamic? *) mutable rcf_handle_impl_dynamic : bool; (* create_dyn_overloading_ctor : when creating the implements dynamic code, we can also create a special constructor for the actual DynamicObject class, which will receive all its fields from the code outside. Note that this will only work on targets that support overloading contrstuctors, as any class that extends our DynamicObject will have an empty super() call *) mutable rcf_create_dyn_ctor : bool; mutable rcf_max_func_arity : int; (* the hash lookup function. can be an inlined expr or simply a function call. its only needed features is that it should return the index of the key if found, and the complement of the index of where it should be inserted if not found (Ints). hash->hash_array->length->returning expression *) mutable rcf_hash_function : texpr->texpr->texpr->texpr; mutable rcf_lookup_function : texpr->texpr; (* hash_array->length->pos->value *) mutable rcf_insert_function : texpr->texpr->texpr->texpr->texpr; (* hash_array->length->pos->value *) mutable rcf_remove_function : texpr->texpr->texpr->texpr; (* class_cl is the real class for Class<> instances. In the current implementation, due to some targets' limitations, (in particular, Java), we have to use an empty object so we can access its virtual mehtods. FIXME find a better way to create Class<> objects in a performant way *) mutable rcf_class_cl : tclass option; (* Also about the Class<> type, should we crate all classes eagerly? If false, it means that we should have a way at runtime to create the class when needed by Type.resolveClass/Enum *) mutable rcf_class_eager_creation : bool; rcf_hash_fields : (int, string) Hashtbl.t; rcf_hash_paths : (path * int, string) Hashtbl.t; (* main expr -> field expr -> field string -> possible hash int (if optimize) -> possible set expr -> should_throw_exceptions -> changed expression Changes a get / set field to the runtime resolution function *) mutable rcf_on_getset_field : texpr->texpr->string->int32 option->texpr option->bool->texpr; mutable rcf_on_call_field : texpr->texpr->string->int32 option->texpr list->texpr; mutable rcf_handle_statics : bool; } let new_ctx gen ft object_iface optimize dynamic_getset_field dynamic_call_field hash_function lookup_function insert_function remove_function handle_statics = { rcf_gen = gen; rcf_ft = ft; rcf_optimize = optimize; rcf_float_special_case = true; rcf_object_iface = object_iface; rcf_create_getsetinvoke_fields = true; rcf_create_get_type = true; rcf_handle_impl_dynamic = true; rcf_create_dyn_ctor = true; rcf_max_func_arity = 10; rcf_hash_function = hash_function; rcf_lookup_function = lookup_function; rcf_insert_function = insert_function; rcf_remove_function = remove_function; rcf_class_cl = None; rcf_class_eager_creation = false; rcf_hash_fields = Hashtbl.create 100; rcf_hash_paths = Hashtbl.create 100; rcf_on_getset_field = dynamic_getset_field; rcf_on_call_field = dynamic_call_field; rcf_handle_statics = handle_statics; } (* methods as a bool option is a little laziness of my part. None means that methods are included with normal fields; Some(true) means collect only methods Some(false) means collect only fields (and MethDynamic fields) *) let collect_fields cl (methods : bool option) (statics : bool option) = let collected = Hashtbl.create 0 in let collect cf acc = if Meta.has Meta.CompilerGenerated cf.cf_meta || Meta.has Meta.SkipReflection cf.cf_meta then acc else match methods, cf.cf_kind with | None, _ when not (Hashtbl.mem collected cf.cf_name) -> Hashtbl.add collected cf.cf_name true; ([cf.cf_name], cf) :: acc | Some true, Method MethDynamic -> acc | Some true, Method _ when not (Hashtbl.mem collected cf.cf_name) -> Hashtbl.add collected cf.cf_name true; ([cf.cf_name], cf) :: acc | Some false, Method MethDynamic | Some false, Var _ when not (Hashtbl.mem collected cf.cf_name) -> Hashtbl.add collected cf.cf_name true; ([cf.cf_name], cf) :: acc | _ -> acc in let collect_cfs cfs acc = let rec loop cfs acc = match cfs with | [] -> acc | hd :: tl -> loop tl (collect hd acc) in loop cfs acc in let rec loop cl acc = let acc = match statics with | None -> collect_cfs cl.cl_ordered_fields (collect_cfs cl.cl_ordered_statics acc) | Some true -> collect_cfs cl.cl_ordered_statics acc | Some false -> collect_cfs cl.cl_ordered_fields acc in match cl.cl_super with | None -> acc | Some(cl,_) -> if not (is_hxgen (TClassDecl cl)) then loop cl acc else acc in loop cl [] let hash f = let h = ref 0 in for i = 0 to String.length f - 1 do h := !h * 223 + int_of_char (String.unsafe_get f i); done; if Sys.word_size = 64 then Int32.to_int (Int32.shift_right (Int32.shift_left (Int32.of_int !h) 1) 1) else !h let hash_field ctx f pos = let h = hash f in (try let f2 = Hashtbl.find ctx.rcf_hash_paths (ctx.rcf_gen.gcurrent_path, h) in if f <> f2 then ctx.rcf_gen.gcon.error ("Field conflict between " ^ f ^ " and " ^ f2) pos with Not_found -> Hashtbl.add ctx.rcf_hash_paths (ctx.rcf_gen.gcurrent_path, h) f; Hashtbl.replace ctx.rcf_hash_fields h f); h (* ( tf_args, switch_var ) *) let field_type_args ctx pos = match ctx.rcf_optimize with | true -> let field_name, field_hash = alloc_var "field" ctx.rcf_gen.gcon.basic.tstring, alloc_var "hash" ctx.rcf_gen.gcon.basic.tint in [field_name, None; field_hash, None], field_hash | false -> let field_name = alloc_var "field" ctx.rcf_gen.gcon.basic.tstring in [field_name, None], field_name let hash_field_i32 ctx pos field_name = let i = hash_field ctx field_name pos in let i = Int32.of_int (i) in if i < Int32.zero then Int32.logor (Int32.logand i (Int32.of_int 0x3FFFFFFF)) (Int32.shift_left Int32.one 30) else i let switch_case ctx pos field_name = match ctx.rcf_optimize with | true -> let i = hash_field_i32 ctx pos field_name in { eexpr = TConst(TInt(i)); etype = ctx.rcf_gen.gcon.basic.tint; epos = pos } | false -> { eexpr = TConst(TString(field_name)); etype = ctx.rcf_gen.gcon.basic.tstring; epos = pos } (* Will implement getField / setField which will follow the following rule: function getField(field, isStatic, throwErrors, isCheck, handleProperty, isFirst):Dynamic { if (isStatic) { switch(field) { case "aStaticField": return ThisClass.aStaticField; case "aDynamicField": return ThisClass.aDynamicField; default: if (isFirst) return getField_d(field, isStatic, throwErrors, handleProperty, false); if(throwErrors) throw "Field not found"; else if (isCheck) return __undefined__ else return null; } } else { switch(field) { case "aNormalField": return this.aNormalField; case "aBoolField": return this.aBoolField; case "aDoubleField": return this.aDoubleField; default: return getField_d(field, isStatic, throwErrors, isCheck); } } } function getField_d(field, isStatic, throwErrors, handleProperty, isFirst):Float { if (isStatic) { switch(field) { case "aDynamicField": return cast ThisClass.aDynamicField; default: if (throwErrors) throw "Field not found"; else return null; } } etc... } function setField(field, value, isStatic):Dynamic {} function setField_d(field, value:Float, isStatic):Float {} *) let call_super ctx fn_args ret_t cf cl this_t pos = { eexpr = TCall({ eexpr = TField({ eexpr = TConst(TSuper); etype = this_t; epos = pos }, FInstance(cl,List.map snd cl.cl_params,cf)); etype = TFun(fun_args fn_args, ret_t); epos = pos; }, List.map (fun (v,_) -> mk_local v pos) fn_args); etype = ret_t; epos = pos; } let mk_string ctx str pos = { eexpr = TConst(TString(str)); etype = ctx.rcf_gen.gcon.basic.tstring; epos = pos } let mk_int ctx i pos = { eexpr = TConst(TInt(Int32.of_int i)); etype = ctx.rcf_gen.gcon.basic.tint; epos = pos } let mk_bool ctx b pos = { eexpr = TConst(TBool(b)); etype = ctx.rcf_gen.gcon.basic.tbool; epos = pos } let mk_throw ctx str pos = { eexpr = TThrow (mk_string ctx str pos); etype = ctx.rcf_gen.gcon.basic.tvoid; epos = pos } let enumerate_dynamic_fields ctx cl when_found = let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let pos = cl.cl_pos in let vtmp = alloc_var "i" basic.tint in let mk_for arr len = let t = if ctx.rcf_optimize then basic.tint else basic.tstring in let convert_str e = if ctx.rcf_optimize then ctx.rcf_lookup_function e else e in let tmpinc = { eexpr = TUnop(Ast.Increment, Ast.Postfix, mk_local vtmp pos); etype = basic.tint; epos = pos } in { eexpr = TBlock [ { eexpr = TBinop(OpAssign, mk_local vtmp pos, mk_int ctx 0 pos); etype = basic.tint; epos = pos }; { eexpr = TWhile ( { eexpr = TBinop(Ast.OpLt, mk_local vtmp pos, len); etype = basic.tbool; epos = pos }, mk_block (when_found (convert_str { eexpr = TArray (arr, tmpinc); etype = t; epos = pos })), Ast.NormalWhile ); etype = basic.tvoid; epos = pos } ]; etype = basic.tvoid; epos = pos; } in let this_t = TInst(cl, List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in { eexpr = TVar (vtmp,None); etype = basic.tvoid; epos = pos } :: if ctx.rcf_optimize then [ mk_for (mk_this (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray basic.tint)) (mk_this (gen.gmk_internal_name "hx" "length") basic.tint); mk_for (mk_this (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray basic.tint)) (mk_this (gen.gmk_internal_name "hx" "length_f") basic.tint); ] else [ mk_for (mk_this (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray basic.tstring)) (mk_this (gen.gmk_internal_name "hx" "length") basic.tint); mk_for (mk_this (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray basic.tstring)) (mk_this (gen.gmk_internal_name "hx" "length_f") basic.tint); ] (* ********************* Dynamic lookup ********************* This is the behavior of standard classes. It will replace the error throwing if a field doesn't exists when looking it up. In order for it to work, an implementation for hash_function must be created. hash_function is the function to be called/inlined that will allow us to lookup the hash into a sorted array of hashes. A binary search or linear search algorithm may be implemented. The only need is that if not found, the NegBits of the place where it should be inserted must be returned. *) let abstract_dyn_lookup_implementation ctx this hash_local may_value is_float pos = let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let a_t = if ctx.rcf_optimize then basic.tint else basic.tstring in let hx_hashes = mk_this (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray a_t) in let hx_hashes_f = mk_this (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray a_t) in let hx_dynamics = mk_this (gen.gmk_internal_name "hx" "dynamics") (gen.gclasses.nativearray t_empty) in let hx_dynamics_f = mk_this (gen.gmk_internal_name "hx" "dynamics_f") (gen.gclasses.nativearray basic.tfloat) in let hx_length = mk_this (gen.gmk_internal_name "hx" "length") (basic.tint) in let hx_length_f = mk_this (gen.gmk_internal_name "hx" "length_f") (basic.tint) in let res = alloc_var "res" basic.tint in let fst_hash, snd_hash, fst_dynamics, snd_dynamics, fst_length, snd_length = if is_float then hx_hashes_f, hx_hashes, hx_dynamics_f, hx_dynamics, hx_length_f, hx_length else hx_hashes, hx_hashes_f, hx_dynamics, hx_dynamics_f, hx_length, hx_length_f in let res_local = mk_local res pos in let gte = { eexpr = TBinop(Ast.OpGte, res_local, { eexpr = TConst(TInt(Int32.zero)); etype = basic.tint; epos = pos }); etype = basic.tbool; epos = pos; } in let mk_tarray arr idx = { eexpr = TArray(arr, idx); etype = gen.gclasses.nativearray_type arr.etype; epos = pos; } in let ret_t = if is_float then basic.tfloat else t_dynamic in match may_value with | None -> (* var res = lookup(this.__hx_hashes/f, hash); if (res < 0) { res = lookup(this.__hx_hashes_f/_, hash); if(res < 0) return null; else return __hx_dynamics_f[res]; } else { return __hx_dynamics[res]; } *) let block = [ { eexpr = TVar(res, Some(ctx.rcf_hash_function hash_local fst_hash fst_length)); etype = basic.tvoid; epos = pos }; { eexpr = TIf(gte, mk_return (mk_tarray fst_dynamics res_local), Some({ eexpr = TBlock( [ { eexpr = TBinop(Ast.OpAssign, res_local, ctx.rcf_hash_function hash_local snd_hash snd_length); etype = basic.tint; epos = pos }; { eexpr = TIf(gte, mk_return (mk_tarray snd_dynamics res_local), None); etype = ret_t; epos = pos } ]); etype = ret_t; epos = pos; })); etype = ret_t; epos = pos } ] in block | Some value_local -> (* //if is not float: //if (isNumber(value_local)) return this.__hx_setField_f(field, getNumber(value_local), false(not static)); var res = lookup(this.__hx_hashes/f, hash); if (res >= 0) { return __hx_dynamics/f[res] = value_local; } else { res = lookup(this.__hx_hashes_f/_, hash); if (res >= 0) { __hx_dynamics_f/_.splice(res,1); __hx_hashes_f/_.splice(res,1); } } __hx_hashses/_f.insert(~res, hash); __hx_dynamics/_f.insert(~res, value_local); return value_local; *) let neg_res = { eexpr = TUnop(Ast.NegBits, Ast.Prefix, res_local); etype = basic.tint; epos = pos } in let res2 = alloc_var "res2" basic.tint in let res2_local = mk_local res2 pos in let gte2 = { eexpr = TBinop(Ast.OpGte, res2_local, { eexpr = TConst(TInt(Int32.zero)); etype = basic.tint; epos = pos }); etype = basic.tbool; epos = pos; } in let block = [ { eexpr = TVar(res, Some(ctx.rcf_hash_function hash_local fst_hash fst_length)); etype = basic.tvoid; epos = pos }; { eexpr = TIf(gte, mk_return { eexpr = TBinop(Ast.OpAssign, mk_tarray fst_dynamics res_local, value_local); etype = value_local.etype; epos = pos }, Some({ eexpr = TBlock([ { eexpr = TVar( res2, Some(ctx.rcf_hash_function hash_local snd_hash snd_length)); etype = basic.tvoid; epos = pos }; { eexpr = TIf(gte2, { eexpr = TBlock([ ctx.rcf_remove_function snd_hash snd_length res2_local; ctx.rcf_remove_function snd_dynamics snd_length res2_local; mk (TUnop(Decrement,Postfix,snd_length)) basic.tint pos ]); etype = t_dynamic; epos = pos }, None); etype = t_dynamic; epos = pos; } ]); etype = t_dynamic; epos = pos })); etype = t_dynamic; epos = pos; }; ctx.rcf_insert_function fst_hash fst_length neg_res hash_local; ctx.rcf_insert_function fst_dynamics fst_length neg_res value_local; mk (TUnop(Increment,Postfix,fst_length)) basic.tint pos; mk_return value_local ] in block let get_delete_field ctx cl is_dynamic = let pos = cl.cl_pos in let this_t = TInst(cl, List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let tf_args, switch_var = field_type_args ctx pos in let local_switch_var = mk_local switch_var pos in let fun_type = TFun(fun_args tf_args,basic.tbool) in let cf = mk_class_field (gen.gmk_internal_name "hx" "deleteField") fun_type false pos (Method MethNormal) [] in let body = if is_dynamic then begin let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let a_t = if ctx.rcf_optimize then basic.tint else basic.tstring in let hx_hashes = mk_this (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray a_t) in let hx_hashes_f = mk_this (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray a_t) in let hx_dynamics = mk_this (gen.gmk_internal_name "hx" "dynamics") (gen.gclasses.nativearray t_empty) in let hx_dynamics_f = mk_this (gen.gmk_internal_name "hx" "dynamics_f") (gen.gclasses.nativearray basic.tfloat) in let hx_length = mk_this (gen.gmk_internal_name "hx" "length") (basic.tint) in let hx_length_f = mk_this (gen.gmk_internal_name "hx" "length_f") (basic.tint) in let res = alloc_var "res" basic.tint in let res_local = mk_local res pos in let gte = { eexpr = TBinop(Ast.OpGte, res_local, { eexpr = TConst(TInt(Int32.zero)); etype = basic.tint; epos = pos }); etype = basic.tbool; epos = pos; } in (* var res = lookup(this.__hx_hashes, hash); if (res >= 0) { __hx_dynamics.splice(res,1); __hx_hashes.splice(res,1); return true; } else { res = lookup(this.__hx_hashes_f, hash); if (res >= 0) { __hx_dynamics_f.splice(res,1); __hx_hashes_f.splice(res,1); return true; } } return false; *) [ { eexpr = TVar(res,Some(ctx.rcf_hash_function local_switch_var hx_hashes hx_length)); etype = basic.tvoid; epos = pos }; { eexpr = TIf(gte, { eexpr = TBlock([ ctx.rcf_remove_function hx_hashes hx_length res_local; ctx.rcf_remove_function hx_dynamics hx_length res_local; mk (TUnop(Decrement,Postfix,hx_length)) basic.tint pos; mk_return { eexpr = TConst(TBool true); etype = basic.tbool; epos = pos } ]); etype = t_dynamic; epos = pos }, Some({ eexpr = TBlock([ { eexpr = TBinop(Ast.OpAssign, res_local, ctx.rcf_hash_function local_switch_var hx_hashes_f hx_length_f); etype = basic.tint; epos = pos }; { eexpr = TIf(gte, { eexpr = TBlock([ ctx.rcf_remove_function hx_hashes_f hx_length_f res_local; ctx.rcf_remove_function hx_dynamics_f hx_length_f res_local; mk (TUnop(Decrement,Postfix,hx_length_f)) basic.tint pos; mk_return { eexpr = TConst(TBool true); etype = basic.tbool; epos = pos } ]); etype = t_dynamic; epos = pos }, None); etype = t_dynamic; epos = pos } ]); etype = t_dynamic; epos = pos })); etype = t_dynamic; epos = pos; }; mk_return { eexpr = TConst(TBool false); etype = basic.tbool; epos = pos } ] end else [ mk_return { eexpr = TConst(TBool false); etype = basic.tbool; epos = pos } ] in (* create function *) let fn = { tf_args = tf_args; tf_type = basic.tbool; tf_expr = { eexpr = TBlock(body); etype = t_dynamic; epos = pos } } in cf.cf_expr <- Some({ eexpr = TFunction(fn); etype = fun_type; epos = pos }); cf let rec is_first_dynamic cl = match cl.cl_super with | Some(cl,_) -> if is_some cl.cl_dynamic then false else is_first_dynamic cl | None -> true let is_override cl = match cl.cl_super with | Some (cl, _) when is_hxgen (TClassDecl cl) -> true | _ -> false let get_args t = match follow t with | TFun(args,ret) -> args,ret | _ -> assert false (* WARNING: this will only work if overloading contructors is possible on target language *) let implement_dynamic_object_ctor ctx cl = let rec is_side_effects_free e = match e.eexpr with | TConst _ | TLocal _ | TFunction _ | TTypeExpr _ -> true | TNew(clnew,[],params) when clnew == cl -> List.for_all is_side_effects_free params | TUnop(Increment,_,_) | TUnop(Decrement,_,_) | TBinop(OpAssign,_,_) | TBinop(OpAssignOp _,_,_) -> false | TUnop(_,_,e) -> is_side_effects_free e | TArray(e1,e2) | TBinop(_,e1,e2) -> is_side_effects_free e1 && is_side_effects_free e2 | TIf(cond,e1,Some e2) -> is_side_effects_free cond && is_side_effects_free e1 && is_side_effects_free e2 | TField(e,_) | TParenthesis e | TMeta(_,e) -> is_side_effects_free e | TArrayDecl el -> List.for_all is_side_effects_free el | TCast(e,_) -> is_side_effects_free e | _ -> false in let pos = cl.cl_pos in let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let hasht = if ctx.rcf_optimize then basic.tint else basic.tstring in let hashes_field = gen.gmk_internal_name "hx" "hashes", gen.gclasses.nativearray hasht in let hashes_f_field = gen.gmk_internal_name "hx" "hashes_f", gen.gclasses.nativearray hasht in let dynamics_field = gen.gmk_internal_name "hx" "dynamics", gen.gclasses.nativearray t_empty in let dynamics_f_field = gen.gmk_internal_name "hx" "dynamics_f", gen.gclasses.nativearray basic.tfloat in let fields = [ hashes_field; dynamics_field; hashes_f_field; dynamics_f_field; ] in let hashes_var = alloc_var (fst hashes_field) (snd hashes_field) in let hashes_f_var = alloc_var (fst hashes_f_field) (snd hashes_f_field) in let tf_args = [ hashes_var, None; alloc_var (fst dynamics_field) (snd dynamics_field), None; hashes_f_var, None; alloc_var (fst dynamics_f_field) (snd dynamics_f_field), None; ] in let this = { eexpr = TConst TThis; etype = TInst(cl, List.map snd cl.cl_params); epos = pos } in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let fun_t = TFun(fun_args tf_args,basic.tvoid) in let ctor = mk_class_field "new" fun_t true pos (Method MethNormal) [] in ctor.cf_expr <- Some( { eexpr = TFunction({ tf_args = tf_args; tf_type = basic.tvoid; tf_expr = { eexpr = TBlock( List.map (fun (v,_) -> { eexpr = TBinop(Ast.OpAssign, mk_this v.v_name v.v_type, mk_local v pos); etype = v.v_type; epos = pos } ) tf_args @ [ mk (TBinop(OpAssign, mk_this (gen.gmk_internal_name "hx" "length") basic.tint, gen.gclasses.nativearray_len (mk_local hashes_var pos) pos)) basic.tint pos; mk (TBinop(OpAssign, mk_this (gen.gmk_internal_name "hx" "length_f") basic.tint, gen.gclasses.nativearray_len (mk_local hashes_f_var pos) pos)) basic.tint pos; ] ); etype = basic.tvoid; epos = pos } }); etype = fun_t; epos = pos }); add_constructor cl ctor; (* default ctor also *) let ctor = mk_class_field "new" (TFun([],basic.tvoid)) false pos (Method MethNormal) [] in ctor.cf_expr <- Some { eexpr = TFunction { tf_type = basic.tvoid; tf_args = []; tf_expr = { eexpr = TBlock(List.map (fun (f,t) -> { eexpr = TBinop(Ast.OpAssign, mk_this f t,{ eexpr = TCall(mk_local v_nativearray pos, []); etype = t; epos = pos; }); etype = t; epos = pos } ) fields); etype = basic.tvoid; epos = pos; } }; etype = ctor.cf_type; epos = pos; }; add_constructor cl ctor; (* and finally we will return a function that transforms a TObjectDecl into a new DynamicObject() call *) let rec loop objdecl acc acc_f = match objdecl with | [] -> acc,acc_f | (name,expr) :: tl -> let real_t = gen.greal_type expr.etype in match follow expr.etype with | TInst ( { cl_path = ["haxe"], "Int64" }, [] ) -> loop tl ((name, gen.ghandle_cast t_dynamic real_t expr) :: acc) acc_f | _ -> if like_float real_t && not (like_i64 real_t) then loop tl acc ((name, gen.ghandle_cast basic.tfloat real_t expr) :: acc_f) else loop tl ((name, gen.ghandle_cast t_dynamic real_t expr) :: acc) acc_f in let may_hash_field s = if ctx.rcf_optimize then begin (* let hash_field ctx f pos = *) { eexpr = TConst(TInt (hash_field_i32 ctx pos s)); etype = basic.tint; epos = pos } end else begin { eexpr = TConst(TString s); etype = basic.tstring; epos = pos } end in let do_objdecl e objdecl = let exprs_before = ref [] in let rec change_exprs decl acc = match decl with | (name,expr) :: tl -> if is_side_effects_free expr then change_exprs tl ((name,expr) :: acc) else begin let var = mk_temp gen "odecl" expr.etype in exprs_before := { eexpr = TVar(var,Some expr); etype = basic.tvoid; epos = expr.epos } :: !exprs_before; change_exprs tl ((name,mk_local var expr.epos) :: acc) end | [] -> acc in let objdecl = change_exprs objdecl [] in let odecl, odecl_f = loop objdecl [] [] in let changed_expr = List.map (fun (s,e) -> (may_hash_field s,e)) in let odecl, odecl_f = changed_expr odecl, changed_expr odecl_f in let sort_fn (e1,_) (e2,_) = match e1.eexpr, e2.eexpr with | TConst(TInt i1), TConst(TInt i2) -> compare i1 i2 | TConst(TString s1), TConst(TString s2) -> compare s1 s2 | _ -> assert false in let odecl, odecl_f = List.sort sort_fn odecl, List.sort sort_fn odecl_f in let ret = { e with eexpr = TNew(cl,[], [ mk_nativearray_decl gen hasht (List.map fst odecl) pos; mk_nativearray_decl gen t_empty (List.map snd odecl) pos; mk_nativearray_decl gen hasht (List.map fst odecl_f) pos; mk_nativearray_decl gen basic.tfloat (List.map snd odecl_f) pos; ]); } in match !exprs_before with | [] -> ret | block -> { eexpr = TBlock(List.rev block @ [ret]); etype = ret.etype; epos = ret.epos; } in do_objdecl let implement_dynamics ctx cl = let pos = cl.cl_pos in let is_override = is_override cl in if is_some cl.cl_dynamic then begin if is_first_dynamic cl then begin (* * add hx_hashes, hx_hashes_f, hx_dynamics, hx_dynamics_f to class * implement hx_deleteField *) let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let hasht = if ctx.rcf_optimize then basic.tint else basic.tstring in let new_fields = [ mk_class_field (gen.gmk_internal_name "hx" "hashes") (gen.gclasses.nativearray hasht) false pos (Var { v_read = AccNormal; v_write = AccNormal }) []; mk_class_field (gen.gmk_internal_name "hx" "dynamics") (gen.gclasses.nativearray t_empty) false pos (Var { v_read = AccNormal; v_write = AccNormal }) []; mk_class_field (gen.gmk_internal_name "hx" "hashes_f") (gen.gclasses.nativearray hasht) false pos (Var { v_read = AccNormal; v_write = AccNormal }) []; mk_class_field (gen.gmk_internal_name "hx" "dynamics_f") (gen.gclasses.nativearray basic.tfloat) false pos (Var { v_read = AccNormal; v_write = AccNormal }) []; ] in (if cl.cl_path <> (["haxe"; "lang"], "DynamicObject") then List.iter (fun cf -> cf.cf_expr <- Some { eexpr = TCall(mk_local v_nativearray pos, []); etype = cf.cf_type; epos = cf.cf_pos }) new_fields ); let delete = get_delete_field ctx cl true in let new_fields = new_fields @ [ mk_class_field (gen.gmk_internal_name "hx" "length") (basic.tint) false pos (Var { v_read = AccNormal; v_write = AccNormal }) []; mk_class_field (gen.gmk_internal_name "hx" "length_f") (basic.tint) false pos (Var { v_read = AccNormal; v_write = AccNormal }) []; delete; ] in List.iter (fun cf -> cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields ) new_fields; (* let rec last_ctor cl = match cl.cl_constructor with | None -> (match cl.cl_super with | None -> None | Some (cl,_) -> last_ctor cl) | Some c -> Some c in *) (* in order for the next to work, we need to execute our script before InitFunction, so the expressions inside the variables are initialized by the constructor *) (* Now we need to add their initialization. This will consist of different parts: Check if there are constructors. If not, create one and add initialization to it (calling super, ok) If there are, add as first statement (or second if there is a super() call in the first) If class has @:dynamicObject meta, also create another new() class with its parameters as constructor arguments *) cl.cl_ordered_fields <- cl.cl_ordered_fields @ new_fields; if is_override then cl.cl_overrides <- delete :: cl.cl_overrides end end else if not is_override then begin let delete = get_delete_field ctx cl false in cl.cl_ordered_fields <- cl.cl_ordered_fields @ [delete]; cl.cl_fields <- PMap.add delete.cf_name delete cl.cl_fields end let implement_create_empty ctx cl = let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let pos = cl.cl_pos in let is_override = is_override cl in let tparams = List.map (fun _ -> t_empty) cl.cl_params in let create = let arr = alloc_var "arr" (basic.tarray t_dynamic) in let tf_args = [ arr, None ] in let t = TFun(fun_args tf_args, t_dynamic) in let cf = mk_class_field (gen.gmk_internal_name "hx" "create") t false pos (Method MethNormal) [] in let i = ref 0 in let arr_local = mk_local arr pos in let ctor = if is_some cl.cl_constructor then cl.cl_constructor else get_last_ctor cl in let params = match ctor with | None -> [] | Some ctor -> List.map (fun (n,_,t) -> let old = !i in incr i; { eexpr = TArray(arr_local, { eexpr = TConst(TInt (Int32.of_int old)); etype = basic.tint; epos = pos } ); etype = t_dynamic; epos = pos } ) ( fst ( get_fun ctor.cf_type ) ) in let expr = mk_return { eexpr = TNew(cl, tparams, params); etype = TInst(cl, tparams); epos = pos } in let fn = { eexpr = TFunction({ tf_args = tf_args; tf_type = t_dynamic; tf_expr = mk_block expr }); etype = t; epos = pos } in cf.cf_expr <- Some fn; cf in let create_empty = let t = TFun([],t_dynamic) in let cf = mk_class_field (gen.gmk_internal_name "hx" "createEmpty") t false pos (Method MethNormal) [] in let fn = { eexpr = TFunction({ tf_args = []; tf_type = t_dynamic; tf_expr = mk_block (mk_return ( gen.gtools.rf_create_empty cl tparams pos )) }); etype = t; epos = pos } in cf.cf_expr <- Some fn; cf in (* if rcf_handle_statics is false, there is no reason to make createEmpty/create not be static *) if ctx.rcf_handle_statics then begin cl.cl_ordered_fields <- cl.cl_ordered_fields @ [create_empty; create]; cl.cl_fields <- PMap.add create_empty.cf_name create_empty cl.cl_fields; cl.cl_fields <- PMap.add create.cf_name create cl.cl_fields; if is_override then begin cl.cl_overrides <- create_empty :: create :: cl.cl_overrides end end else begin cl.cl_ordered_statics <- cl.cl_ordered_statics @ [create_empty; create]; cl.cl_statics <- PMap.add create_empty.cf_name create_empty cl.cl_statics; cl.cl_statics <- PMap.add create.cf_name create cl.cl_statics end (* Implements: __hx_lookupField(field:String, throwErrors:Bool, isCheck:Bool, handleProperties:Bool, isFirst:Bool):Dynamic __hx_lookupField_f(field:String, throwErrors:Bool, handleProperties:Bool, isFirst:Bool):Float __hx_lookupSetField(field:String, value:Dynamic, handleProperties:Bool, isFirst:Bool):Dynamic; __hx_lookupSetField(field:String, value:Float, handleProperties:Bool, isFirst:Bool):Float; *) let implement_final_lookup ctx cl = let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let pos = cl.cl_pos in let is_override = is_override cl in let this = { eexpr = TConst(TThis); etype = TInst(cl, List.map snd cl.cl_params); epos = pos } in (* this function will create the class fields and call callback for each version callback : is_float fields_args switch_var throw_errors_option is_check_option value_option : texpr list *) let create_cfs is_dynamic callback = let create_cf is_float is_set = let name = gen.gmk_internal_name "hx" ( (if is_set then "lookupSetField" else "lookupField") ^ (if is_float then "_f" else "") ) in let field_args, switch_var = field_type_args ctx pos in let ret_t = if is_float then basic.tfloat else t_dynamic in let tf_args, throw_errors_opt = if is_set then field_args, None else let v = alloc_var "throwErrors" basic.tbool in field_args @ [v,None], Some v in let tf_args, is_check_opt = if is_set || is_float then tf_args, None else let v = alloc_var "isCheck" basic.tbool in tf_args @ [v,None], Some v in let tf_args, value_opt = if not is_set then tf_args, None else let v = alloc_var "value" ret_t in field_args @ [v,None], Some v in let fun_t = TFun(fun_args tf_args, ret_t) in let cf = mk_class_field name fun_t false pos (Method MethNormal) [] in let block = callback is_float field_args switch_var throw_errors_opt is_check_opt value_opt in let block = if not is_set then let tl = begin let throw_errors_local = mk_local (get throw_errors_opt) pos in let mk_check_throw msg = { eexpr = TIf(throw_errors_local, mk_throw ctx msg pos, Some (mk_return (null ret_t pos))); etype = ret_t; epos = pos } in let mk_may_check_throw msg = if is_dynamic then mk_return (null ret_t pos) else mk_check_throw msg in if is_float then begin [ mk_may_check_throw "Field not found or incompatible field type."; ] end else begin let is_check_local = mk_local (get is_check_opt) pos in [ { eexpr = TIf(is_check_local, mk_return (undefined pos), Some( mk_may_check_throw "Field not found." )); etype = ret_t; epos = pos; } ] end end in block @ tl else block in cf.cf_expr <- Some( { eexpr = TFunction({ tf_args = tf_args; tf_type = ret_t; tf_expr = { eexpr = TBlock(block); etype = ret_t; epos = pos } }); etype = fun_t; epos = pos } ); cf in let cfs = [ create_cf false false; create_cf true false; create_cf false true; create_cf true true ] in cl.cl_ordered_fields <- cl.cl_ordered_fields @ cfs; List.iter (fun cf -> cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields; if is_override then cl.cl_overrides <- cf :: cl.cl_overrides ) cfs in if is_some cl.cl_dynamic then begin (* let abstract_dyn_lookup_implementation ctx this hash_local may_value is_float pos = *) (* callback : is_float fields_args switch_var throw_errors_option is_check_option value_option : texpr list *) if is_first_dynamic cl then create_cfs true (fun is_float fields_args switch_var _ _ value_opt -> abstract_dyn_lookup_implementation ctx this (mk_local switch_var pos) (Option.map (fun v -> mk_local v pos) value_opt) is_float pos ) end else if not is_override then begin create_cfs false (fun is_float fields_args switch_var _ _ value_opt -> match value_opt with | None -> (* is not set *) [] | Some _ -> (* is set *) if is_float then [ mk_throw ctx "Cannot access field for writing or incompatible type." pos ] else [ mk_throw ctx "Cannot access field for writing." pos ] ) end (* *) let implement_get_set ctx cl = let gen = ctx.rcf_gen in let mk_cfield is_set is_float = let pos = cl.cl_pos in let basic = ctx.rcf_gen.gcon.basic in let tf_args, switch_var = field_type_args ctx pos in let field_args = tf_args in let local_switch_var = { eexpr = TLocal(switch_var); etype = switch_var.v_type; epos = pos } in let is_static = alloc_var "isStatic" basic.tbool in let is_static_local = { eexpr = TLocal(is_static); etype = basic.tbool; epos = pos } in let handle_prop = alloc_var "handleProperties" basic.tbool in let handle_prop_local = mk_local handle_prop pos in let this = { eexpr = TConst TThis; etype = TInst(cl, List.map snd cl.cl_params); epos = pos } in let mk_this_call_raw name fun_t params = { eexpr = TCall( { (mk_field_access gen this name pos) with etype = fun_t; }, params ); etype = snd (get_args fun_t); epos = pos } in let tf_args = if ctx.rcf_handle_statics then tf_args @ [is_static, None] else tf_args in let fun_type = ref (TFun([], basic.tvoid)) in let fun_name = ctx.rcf_gen.gmk_internal_name "hx" ( (if is_set then "setField" else "getField") ^ (if is_float then "_f" else "") ) in let cfield = mk_class_field fun_name !fun_type false pos (Method MethNormal) [] in let maybe_cast e = e in let t = TInst(cl, List.map snd cl.cl_params) in (* if it's not latest hxgen class -> check super *) let mk_do_default args do_default = match cl.cl_super with | None -> fun () -> maybe_cast (do_default ()) | Some (super, sparams) when not (is_hxgen (TClassDecl super)) -> fun () -> maybe_cast (do_default ()) | _ -> fun () -> mk_return { eexpr = TCall( { eexpr = TField({ eexpr = TConst TSuper; etype = t; epos = pos }, FInstance(cl, List.map snd cl.cl_params, cfield)); etype = !fun_type; epos = pos }, (List.map (fun (v,_) -> mk_local v pos) args) ); etype = if is_float then basic.tfloat else t_dynamic; epos = pos; }; in (* if it is set function, there are some different set fields to do *) let do_default, do_default_static , do_field, tf_args = if is_set then begin let value_var = alloc_var "value" (if is_float then basic.tfloat else t_dynamic) in let value_local = { eexpr = TLocal(value_var); etype = value_var.v_type; epos = pos } in let tf_args = tf_args @ [value_var,None; handle_prop, None; ] in let lookup_name = gen.gmk_internal_name "hx" ("lookupSetField" ^ if is_float then "_f" else "") in let do_default = fun () -> mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [value_var,None]),value_var.v_type)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ value_local ] )) in let do_field cf cf_type is_static = let get_field ethis = { eexpr = TField (ethis, if is_static then FStatic (cl, cf) else FInstance(cl, List.map snd cl.cl_params, cf)); etype = cf_type; epos = pos } in let this = if is_static then mk_classtype_access cl pos else { eexpr = TConst(TThis); etype = t; epos = pos } in let value_local = if is_float then match follow cf_type with | TInst({ cl_kind = KTypeParameter _ }, _) -> mk_cast t_dynamic value_local | _ -> value_local else value_local in let ret = { eexpr = TBlock([ { eexpr = TBinop(Ast.OpAssign, get_field this, mk_cast cf_type value_local); etype = cf_type; epos = pos; }; mk_return value_local ]); etype = cf_type; epos = pos; } in match cf.cf_kind with | Var { v_write = AccCall } -> let bl = [ mk_this_call_raw ("set_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) [ value_local ]; mk_return value_local ] in if Type.is_extern_field cf then { eexpr = TBlock bl; etype = value_local.etype; epos = pos } else { eexpr = TIf( handle_prop_local, { eexpr = TBlock bl; etype = value_local.etype; epos = pos }, Some ret); etype = value_local.etype; epos = pos; } | _ -> ret in (mk_do_default tf_args do_default, do_default, do_field, tf_args) end else begin (* (field, isStatic, throwErrors, isCheck):Dynamic *) let throw_errors = alloc_var "throwErrors" basic.tbool in let throw_errors_local = mk_local throw_errors pos in let do_default, tf_args = if not is_float then begin let is_check = alloc_var "isCheck" basic.tbool in let is_check_local = mk_local is_check pos in let tf_args = tf_args @ [ throw_errors,None; ] in (* default: if (isCheck) return __undefined__ else if(throwErrors) throw "Field not found"; else return null; *) let lookup_name = gen.gmk_internal_name "hx" "lookupField" in let do_default = fun () -> mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [throw_errors,None;is_check,None; ]),t_dynamic)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ throw_errors_local; is_check_local; ] )) in (do_default, tf_args @ [ is_check,None; handle_prop,None; ]) end else begin let tf_args = tf_args @ [ throw_errors,None; ] in let lookup_name = gen.gmk_internal_name "hx" "lookupField_f" in let do_default = fun () -> mk_return (mk_this_call_raw lookup_name (TFun(fun_args (field_args @ [throw_errors,None; ]),basic.tfloat)) ( List.map (fun (v,_) -> mk_local v pos) field_args @ [ throw_errors_local; ] )) in (do_default, tf_args @ [ handle_prop,None; ]) end in let get_field cf cf_type ethis cl name = match cf.cf_kind with | Var { v_read = AccCall } when Type.is_extern_field cf -> mk_return (mk_this_call_raw ("get_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) [ ]) | Var { v_read = AccCall } -> { eexpr = TIf( handle_prop_local, mk_return (mk_this_call_raw ("get_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) [ ]), Some { eexpr = TField (ethis, FInstance(cl, List.map snd cl.cl_params, cf)); etype = cf_type; epos = pos } ); etype = cf_type; epos = pos; } | Var _ | Method MethDynamic -> { eexpr = TField (ethis, FInstance(cl,List.map snd cl.cl_params,cf)); etype = cf_type; epos = pos } | _ -> { eexpr = TField (this, FClosure(Some (cl,[]), cf)); etype = cf_type; epos = pos } (* TODO: FClosure change *) in let do_field cf cf_type static = let this = if static then mk_classtype_access cl pos else { eexpr = TConst(TThis); etype = t; epos = pos } in match is_float, follow cf_type with | true, TInst( { cl_kind = KTypeParameter _ }, _ ) -> mk_return (mk_cast basic.tfloat (mk_cast t_dynamic (get_field cf cf_type this cl cf.cf_name))) | _ -> mk_return (maybe_cast (get_field cf cf_type this cl cf.cf_name )) in (mk_do_default tf_args do_default, do_default, do_field, tf_args) end in let get_fields static = let ret = collect_fields cl ( if is_float || is_set then Some (false) else None ) (Some static) in let ret = if is_set then List.filter (fun (_,cf) -> match cf.cf_kind with (* | Var { v_write = AccNever } -> false *) | _ -> not (Meta.has Meta.ReadOnly cf.cf_meta)) ret else List.filter (fun (_,cf) -> match cf.cf_kind with (* | Var { v_read = AccNever } -> false *) | _ -> true) ret in if is_float then List.filter (fun (_,cf) -> (* TODO: maybe really apply_params in cf.cf_type. The benefits would be limited, though *) match follow (ctx.rcf_gen.greal_type (ctx.rcf_gen.gfollow#run_f cf.cf_type)) with | TDynamic _ | TMono _ | TInst ({ cl_kind = KTypeParameter _ }, _) -> true | t when like_float t && not (like_i64 t) -> true | _ -> false ) ret else (* dynamic will always contain all references *) ret in (* now we have do_default, do_field and tf_args *) (* so create the switch expr *) fun_type := TFun(List.map (fun (v,_) -> (v.v_name, false, v.v_type)) tf_args, if is_float then basic.tfloat else t_dynamic ); let has_fields = ref false in let mk_switch static = let fields = get_fields static in let fields = List.filter (fun (_, cf) -> match is_set, cf.cf_kind with | true, Var { v_write = AccCall } -> true | false, Var { v_read = AccCall } -> true | _ -> not (Type.is_extern_field cf)) fields in (if fields <> [] then has_fields := true); let cases = List.map (fun (names, cf) -> (if names = [] then assert false); (List.map (switch_case ctx pos) names, do_field cf cf.cf_type static) ) fields in let default = Some(if static then do_default_static() else do_default()) in { eexpr = TSwitch(local_switch_var, cases, default); etype = basic.tvoid; epos = pos } in let content = if ctx.rcf_handle_statics then mk_block { eexpr = TIf(is_static_local, mk_switch true, Some(mk_switch false)); etype = basic.tvoid; epos = pos } else mk_block (mk_switch false) in let is_override = match cl.cl_super with | Some (cl, _) when is_hxgen (TClassDecl cl) -> true | _ -> false in if !has_fields || (not is_override) then begin let func = { tf_args = tf_args; tf_type = if is_float then basic.tfloat else t_dynamic; tf_expr = content; } in let func = { eexpr = TFunction(func); etype = !fun_type; epos = pos } in cfield.cf_type <- !fun_type; cfield.cf_expr <- Some func; cl.cl_ordered_fields <- cl.cl_ordered_fields @ [cfield]; cl.cl_fields <- PMap.add fun_name cfield cl.cl_fields; (if is_override then cl.cl_overrides <- cfield :: cl.cl_overrides) end else () in (if ctx.rcf_float_special_case then mk_cfield true true); mk_cfield true false; mk_cfield false false; (if ctx.rcf_float_special_case then mk_cfield false true) let mk_field_access_r ctx pos local field is_float is_static throw_errors set_option = let is_set = is_some set_option in let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let fun_name = ctx.rcf_gen.gmk_internal_name "hx" ( (if is_set then "setField" else "getField") ^ (if is_float then "_f" else "") ) in let tf_args, _ = field_type_args ctx pos in let tf_args, args = fun_args tf_args, field in let rett = if is_float then basic.tfloat else t_dynamic in let tf_args, args = if ctx.rcf_handle_statics then tf_args @ [ "isStatic", false, basic.tbool ], args @ [is_static] else tf_args, args in let tf_args, args = if is_set then tf_args @ [ "setVal", false, rett ], args @ [get set_option] else tf_args, args in let tf_args, args = tf_args @ [ "throwErrors",false,basic.tbool ], args @ [throw_errors] in let tf_args, args = if is_set || is_float then tf_args, args else tf_args @ [ "isCheck", false, basic.tbool ], args @ [{ eexpr = TConst(TBool false); etype = basic.tbool; epos = pos }] in let tf_args, args = tf_args @ [ "handleProperties",false,basic.tbool; ], args @ [ mk_bool ctx false pos; ] in { eexpr = TCall( { (mk_field_access gen local fun_name pos) with etype = TFun(tf_args, rett) }, args); etype = rett; epos = pos; } let implement_fields ctx cl = (* implement two kinds of fields get: classFields generic 'fields': receives a parameter isInstance will receive an Array and start pushing the fields into it. //add all common fields if(isInstance) { //add methods } else { super.fields(isInstance, array); } *) let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let pos = cl.cl_pos in (* let rec has_no_dynamic cl = if is_some cl.cl_dynamic then false else match cl.cl_super with | None -> true | Some(cl,_) -> has_no_dynamic cl in *) (* Type.getClassFields() *) if ctx.rcf_handle_statics then begin let name = gen.gmk_internal_name "hx" "classFields" in let v_base_arr = alloc_var "baseArr" (basic.tarray basic.tstring) in let base_arr = mk_local v_base_arr pos in let tf_args = [v_base_arr,None] in let t = TFun(fun_args tf_args, basic.tvoid) in let cf = mk_class_field name t false pos (Method MethNormal) [] in cl.cl_ordered_fields <- cl.cl_ordered_fields @ [cf]; cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields; (if is_override cl then cl.cl_overrides <- cf :: cl.cl_overrides); (* var newarr = ["field1", "field2"] ...; *) let fields = collect_fields cl None (Some true) in let mk_push value = { eexpr = TCall({ (mk_field_access gen base_arr "push" pos) with etype = TFun(["x", false, basic.tstring], basic.tint) }, [value] ); etype = basic.tint; epos = pos } in let new_arr_contents = { eexpr = TBlock( List.map (fun (_,cf) -> mk_push { eexpr = TConst(TString(cf.cf_name)); etype = basic.tstring; epos = pos }) fields ); etype = basic.tvoid; epos = pos } in let expr = new_arr_contents in let fn = { tf_args = tf_args; tf_type = basic.tvoid; tf_expr = mk_block expr } in cf.cf_expr <- Some { eexpr = TFunction(fn); etype = t; epos = pos } end; let fields = (* function __hx_fields(baseArr:Array, isInstanceFields:Bool) { //add all variable fields //then: if (isInstanceFields) { //add all method fields as well } else { super.__hx_fields(baseArr, isInstanceFields); } } *) let name = gen.gmk_internal_name "hx" "getFields" in let v_base_arr, v_is_inst = alloc_var "baseArr" (basic.tarray basic.tstring), alloc_var "isInstanceFields" basic.tbool in let base_arr, is_inst = mk_local v_base_arr pos, mk_local v_is_inst pos in let tf_args = (v_base_arr,None) :: (if ctx.rcf_handle_statics then [v_is_inst, None] else []) in let t = TFun(fun_args tf_args, basic.tvoid) in let cf = mk_class_field name t false pos (Method MethNormal) [] in let mk_push value = { eexpr = TCall({ (mk_field_access gen base_arr "push" pos) with etype = TFun(["x", false, basic.tstring], basic.tint); }, [value] ); etype = basic.tint; epos = pos } in let has_value = ref false in let map_fields = List.map (fun (_,cf) -> match cf.cf_kind with | Var _ | Method MethDynamic when not (List.memq cf cl.cl_overrides) -> has_value := true; mk_push { eexpr = TConst(TString(cf.cf_name)); etype = basic.tstring; epos = pos } | _ -> null basic.tvoid pos ) in (* if it is first_dynamic, then we need to enumerate the dynamic fields *) let if_not_inst = if is_some cl.cl_dynamic && is_first_dynamic cl then begin has_value := true; Some (enumerate_dynamic_fields ctx cl mk_push) end else None in let if_not_inst = if is_override cl then Some( { eexpr = TBlock( (if is_some if_not_inst then get if_not_inst else []) @ [{ eexpr = TCall( { eexpr = TField({ eexpr = TConst TSuper; etype = TInst(cl, List.map snd cl.cl_params); epos = pos }, FInstance(cl, List.map snd cl.cl_params, cf)); etype = t; epos = pos }, base_arr :: (if ctx.rcf_handle_statics then [is_inst] else []) ); etype = basic.tvoid; epos = pos }] ); etype = basic.tvoid; epos = pos } ) else if is_some if_not_inst then Some({ eexpr = TBlock(get if_not_inst); etype = basic.tvoid; epos = pos }) else None in let expr_contents = map_fields (collect_fields cl (Some false) (Some false)) in let expr_contents = if ctx.rcf_handle_statics then expr_contents @ [ { eexpr = TIf(is_inst, { eexpr = TBlock( map_fields (collect_fields cl (Some true) (Some false)) ); etype = basic.tvoid; epos = pos }, if_not_inst ); etype = basic.tvoid; epos = pos } ] else expr_contents @ (if is_some if_not_inst then [ get if_not_inst ] else []) in let expr = { eexpr = TBlock( expr_contents ); etype = basic.tvoid; epos = pos; } in let fn = { tf_args = tf_args; tf_type = basic.tvoid; tf_expr = expr } in (if !has_value || (not (is_override cl)) then begin cl.cl_ordered_fields <- cl.cl_ordered_fields @ [cf]; cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields; (if is_override cl then cl.cl_overrides <- cf :: cl.cl_overrides) end); cf.cf_expr <- Some { eexpr = TFunction(fn); etype = t; epos = pos } in ignore fields let implement_class_methods ctx cl = ctx.rcf_class_cl <- Some cl; let pos = cl.cl_pos in let gen = ctx.rcf_gen in let basic = gen.gcon.basic in (* fields -> redirected to classFields getField -> redirected to getField with isStatic true setField -> isStatic true invokeField -> isStatic true getClass -> null create -> proxy createEmpty -> proxy *) let is_override = is_override cl in let name = "classProxy" in let t = (TInst(ctx.rcf_object_iface,[])) in (* let cf = mk_class_field name t false pos (Var { v_read = AccNormal; v_write = AccNormal }) [] in *) let register_cf cf override = cl.cl_ordered_fields <- cf :: cl.cl_ordered_fields; cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields; if override then cl.cl_overrides <- cf :: cl.cl_overrides in (* register_cf cf false; *) let this_t = TInst(cl, List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let proxy = mk_this name t in (*let ctor = let cls = alloc_var "cls" t in let tf_args = [cls, None] in let t = TFun(fun_args tf_args, basic.tvoid) in let cf = mk_class_field "new" t true pos (Method MethNormal) [] in cf.cf_expr <- Some({ eexpr = TFunction({ tf_args = tf_args; tf_type = basic.tvoid; tf_expr = mk_block { eexpr = TBinop(Ast.OpAssign, proxy, mk_local cls pos); etype = cls.v_type; epos = pos; } }); etype = t; epos = pos; }); cf in register_cf ctor false;*) (* setting it as DynamicObject makes getClass return null *) let get_class = cl.cl_meta <- (Meta.DynamicObject, [], pos) :: cl.cl_meta in ignore get_class; (* fields -> if isInstanceField, redir the method. If not, return classFields *) let fields = let name = gen.gmk_internal_name "hx" "getFields" in let v_base_arr, v_is_inst = alloc_var "baseArr" (basic.tarray basic.tstring), alloc_var "isInstanceFields" basic.tbool in let base_arr, is_inst = mk_local v_base_arr pos, mk_local v_is_inst pos in let tf_args = [ v_base_arr,None; v_is_inst, None ] in let t = TFun(fun_args tf_args, basic.tvoid) in let cf = mk_class_field name t false pos (Method MethNormal) [] in cf.cf_expr <- Some({ eexpr = TFunction({ tf_args = tf_args; tf_type = basic.tvoid; tf_expr = mk_block { eexpr = TIf(is_inst, { eexpr = TCall( { (mk_field_access gen proxy name pos) with etype = t }, [base_arr;is_inst]); etype = basic.tvoid; epos = pos }, Some { eexpr = TCall(mk_this (gen.gmk_internal_name "hx" "classFields") (TFun(["baseArr",false,basic.tarray basic.tstring], basic.tvoid)), [base_arr]); etype = basic.tvoid; epos = pos }); etype = basic.tvoid; epos = pos } }); etype = t; epos = pos; }); cf in register_cf fields (is_override); let do_proxy field tf_args ret is_static_argnum = let field = gen.gmk_internal_name "hx" field in let t = TFun(fun_args tf_args, ret) in let cf = mk_class_field field t false pos (Method MethNormal) [] in let is_void = is_void ret in let may_return e = if is_void then mk_block e else mk_block (mk_return e) in let i = ref 0 in cf.cf_expr <- Some({ eexpr = TFunction({ tf_args = tf_args; tf_type = ret; tf_expr = may_return { eexpr = TCall( { (mk_field_access gen proxy field pos) with etype = t }, List.map (fun (v,_) -> let lasti = !i in incr i; if lasti = is_static_argnum then { eexpr = TConst(TBool true); etype = basic.tbool; epos = pos } else mk_local v pos ) tf_args); etype = ret; epos = pos } }); etype = t; epos = pos; }); cf in (* getClassFields -> redir *) register_cf (do_proxy "classFields" [ alloc_var "baseArr" (basic.tarray basic.tstring), None ] basic.tvoid (-1)) true; (*register_cf (do_proxy "classFields" [ alloc_var "baseArr" (basic.tarray basic.tstring), None ] basic.tvoid (-1)) true;*) let fst_args, _ = field_type_args ctx pos in let fst_args_len = List.length fst_args in (* getField -> redir the method with static = true *) (* setField -> redir the methods with static = true *) (if ctx.rcf_float_special_case then register_cf (do_proxy "getField_f" (fst_args @ [ alloc_var "isStatic" basic.tbool, None; alloc_var "throwErrors" basic.tbool, None ]) basic.tfloat fst_args_len) true; register_cf (do_proxy "setField_f" (fst_args @ [ alloc_var "isStatic" basic.tbool, None; alloc_var "value" basic.tfloat, None ]) basic.tfloat fst_args_len) true ); register_cf (do_proxy "getField" (fst_args @ [ alloc_var "isStatic" basic.tbool, None; alloc_var "throwErrors" basic.tbool, None; alloc_var "isCheck" basic.tbool, None; alloc_var "handleProperties" basic.tbool,None; ]) t_dynamic fst_args_len) true; register_cf (do_proxy "setField" (fst_args @ [ alloc_var "isStatic" basic.tbool, None; alloc_var "value" t_dynamic, None; alloc_var "handleProperties" basic.tbool,None; ]) t_dynamic fst_args_len) true; (* invokeField -> redir the method with static = true *) register_cf (do_proxy "invokeField" (fst_args @ [ alloc_var "isStatic" basic.tbool, None; alloc_var "dynArgs" (basic.tarray t_dynamic), None ]) t_dynamic fst_args_len) true; (* create / createEmpty -> redir the method *) register_cf (do_proxy "create" [ alloc_var "arr" (basic.tarray t_dynamic), None ] t_dynamic (-1)) true; register_cf (do_proxy "createEmpty" [ ] t_dynamic (-1)) true let implement_get_class ctx cl = (* if it is DynamicObject, return null; if it is not, just do the following: if (typehandle(this.class) == typehandle(MyClass)) return (MyClass.__hx_class != null ? MyClass.__hx_class : MyClass.__hx_class = create_empty(MyClass)); return MyClass.__hx_class = haxe.lang.Runtime.getClass(MyClass); implement both on static and non-static contexts. This way we can call without references. *) let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let pos = cl.cl_pos in let tclass = get_cl ( (Hashtbl.find gen.gtypes ([],"Class")) ) in let cls = TInst(tclass, [ TInst(cl, List.map (fun _ -> t_dynamic) cl.cl_params) ]) in let cls_dyn = TInst(tclass, [t_dynamic]) in let expr, static_cfs = if Meta.has Meta.DynamicObject cl.cl_meta then mk_return (null t_dynamic pos), [] else let cache_name = (gen.gmk_internal_name "hx" "class") in let cache = mk_class_field cache_name cls false pos (Var { v_read = AccNormal; v_write = AccNormal }) [] in cl.cl_ordered_statics <- cl.cl_ordered_statics @ [ cache ]; cl.cl_statics <- PMap.add cache_name cache cl.cl_statics; let cache_access = mk_static_field_access cl cache_name cls pos in let create_expr = { eexpr = TNew(get ctx.rcf_class_cl, [], [gen.gtools.rf_create_empty cl (List.map (fun _ -> t_dynamic) cl.cl_params) pos]); etype = cls; epos = pos } in (if ctx.rcf_class_eager_creation then cache.cf_expr <- Some(create_expr)); let expr = if ctx.rcf_class_eager_creation then mk_return cache_access else mk_return { eexpr = TIf( { eexpr = TBinop(Ast.OpNotEq, cache_access, null cls pos); etype = basic.tbool; epos = pos }, cache_access, Some({ eexpr = TBinop(Ast.OpAssign, cache_access, create_expr); etype = cls; epos = pos }) ); etype = cls; epos = pos } in expr, [] in let func = { eexpr = TFunction({ tf_args = []; tf_type = cls_dyn; tf_expr = expr }); etype = TFun([],cls_dyn); epos = pos } in let get_cl_static = mk_class_field (gen.gmk_internal_name "hx" "getClassStatic") (TFun([],cls_dyn)) false pos (Method MethNormal) [] in let get_cl = mk_class_field (gen.gmk_internal_name "hx" "getClass") (TFun([],cls_dyn)) false pos (Method MethNormal) [] in get_cl_static.cf_expr <- Some func; get_cl.cf_expr <- Some func; let all_f = [get_cl] in cl.cl_ordered_fields <- cl.cl_ordered_fields @ all_f; List.iter (fun cf -> cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields) all_f; let all_f = get_cl_static :: static_cfs in cl.cl_ordered_statics <- cl.cl_ordered_statics @ all_f; List.iter (fun cf -> cl.cl_statics <- PMap.add cf.cf_name cf cl.cl_statics) all_f; if is_override cl then cl.cl_overrides <- get_cl :: cl.cl_overrides let implement_invokeField ctx ~slow_invoke cl = (* There are two ways to implement an haxe reflection-enabled class: When we extend a non-hxgen class, and when we extend the base HxObject class. Because of the added boiler plate we'd add every time we extend a non-hxgen class to implement a big IHxObject interface, we'll handle the cases differently when implementing each interface. At the IHxObject interface, there's only invokeDynamic(field, args[]), while at the HxObject class there are the other, more optimized methods, that follow the Function class interface. Since this will only be called by the Closure class, this conversion can be properly dealt with later. TODO: create the faster version. By now only invokeDynamic will be implemented *) let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let pos = cl.cl_pos in let has_method = ref false in let is_override = ref false in let rec extends_hxobject cl = match cl.cl_super with | None -> true | Some (cl,_) when is_hxgen (TClassDecl cl) -> is_override := true; extends_hxobject cl | _ -> false in let field_args, switch_var = field_type_args ctx cl.cl_pos in let field_args_exprs = List.map (fun (v,_) -> mk_local v pos) field_args in let is_static = alloc_var "isStatic" basic.tbool in let dynamic_arg = alloc_var "dynargs" (basic.tarray t_dynamic) in let all_args = field_args @ (if ctx.rcf_handle_statics then [ is_static,None; dynamic_arg,None ] else [ dynamic_arg, None ] ) in let fun_t = TFun(fun_args all_args, t_dynamic) in let this_t = TInst(cl, List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in let apply_object cf = apply_params cf.cf_params (List.map (fun _ -> t_dynamic) cf.cf_params) cf.cf_type in let mk_this_call_raw name fun_t params = { eexpr = TCall( { (mk_field_access gen this name pos) with etype = fun_t }, params ); etype = snd (get_args fun_t); epos = pos } in let mk_this_call cf params = let t = apply_object cf in (* the return type transformation into Dynamic *) (* is meant to avoid return-type casting after functions with *) (* type parameters are properly inferred at TypeParams.infer_params *) (* e.g. function getArray(t:T):Array; after infer_params, *) (* T will be inferred as SomeType, but the returned type will still be typed *) (* as Array *) let args, ret = get_args t in let ret = match follow ret with | TAbstract ({ a_path = ([], "Void") },[]) -> ret | _ -> ret in mk_this_call_raw cf.cf_name (TFun(args, ret)) params in let mk_static_call cf params = let t = apply_object cf in let _, ret = get_fun (follow t) in { eexpr = TCall( mk_static_field_access cl cf.cf_name t pos, params ); etype = ret; epos = pos } in let extends_hxobject = extends_hxobject cl in ignore extends_hxobject; (* creates a dynamicInvoke of the class fields listed here *) (* function dynamicInvoke(field, isStatic, dynargs) { switch(field) { case "a": this.a(dynargs[0], dynargs[1], dynargs[2]...); default: super.dynamicInvoke //or this.getField(field).invokeField(dynargs) } } *) let dyn_fun = mk_class_field (ctx.rcf_gen.gmk_internal_name "hx" "invokeField") fun_t false cl.cl_pos (Method MethNormal) [] in let mk_switch_dyn cfs static old = (* mk_class_field name t public pos kind params = *) let get_case (names,cf) = has_method := true; let i = ref 0 in let dyn_arg_local = mk_local dynamic_arg pos in let cases = List.map (switch_case ctx pos) names in (cases, { eexpr = TReturn(Some ( (if static then mk_static_call else mk_this_call) cf (List.map (fun (name,_,t) -> let ret = { eexpr = TArray(dyn_arg_local, mk_int ctx !i pos); etype = t_dynamic; epos = pos } in incr i; ret ) (fst (get_args (cf.cf_type))) ) )); etype = basic.tvoid; epos = pos } ) in let cfs = List.filter (fun (_,cf) -> match cf.cf_kind with | Method _ -> if List.memq cf cl.cl_overrides then false else true | _ -> true) cfs in let cases = List.map get_case cfs in let cases = match old with | [] -> cases | _ -> let ncases = List.map (fun cf -> switch_case ctx pos cf.cf_name) old in ( ncases, mk_return ((get slow_invoke) this (mk_local (fst (List.hd field_args)) pos) (mk_local dynamic_arg pos)) ) :: cases in let default = if !is_override && not(static) then (* let call_super ctx fn_args ret_t fn_name this_t pos = *) { eexpr = TReturn(Some (call_super ctx all_args t_dynamic dyn_fun cl this_t pos) ); etype = basic.tvoid; epos = pos } (*else if ctx.rcf_create_getsetinvoke_fields then (* we always need to run create_getset before *) let get_field_name = gen.gmk_internal_name "hx" "getField" in { eexpr = TReturn( Some (mk_this_call (PMap.find get_field_name cl.cl_fields) [mk_local dynamic_arg pos] ) ); etype = basic.tvoid; epos = pos }*) else ( (*let field = (gen.gtools.r_field false (TInst(ctx.rcf_ft.func_class,[])) this (mk_local (fst (List.hd all_args)) pos)) in*) (* let mk_field_access ctx pos local field is_float is_static throw_errors set_option = *) let field = mk_field_access_r ctx pos this field_args_exprs false {eexpr = TConst(TBool static); etype = basic.tbool; epos = pos} { eexpr = TConst(TBool true); etype = basic.tbool; epos = pos } None in let field = mk_cast (TInst(ctx.rcf_ft.func_class,[])) field in mk_return { eexpr = TCall( mk_field_access gen field (gen.gmk_internal_name "hx" "invokeDynamic") pos, [mk_local dynamic_arg pos]); etype = t_dynamic; epos = pos } ) in { eexpr = TSwitch(mk_local switch_var pos, cases, Some default); etype = basic.tvoid; epos = pos; } in let contents = let statics = collect_fields cl (Some true) (Some true) in let nonstatics = collect_fields cl (Some true) (Some false) in let old_nonstatics = ref [] in let nonstatics = match slow_invoke with | None -> nonstatics | Some _ -> List.filter (fun (n,cf) -> let is_old = not (PMap.mem cf.cf_name cl.cl_fields) || List.memq cf cl.cl_overrides in (if is_old then old_nonstatics := cf :: !old_nonstatics); not is_old ) nonstatics in if ctx.rcf_handle_statics then { eexpr = TIf(mk_local is_static pos, mk_switch_dyn statics true [], Some(mk_switch_dyn nonstatics false !old_nonstatics)); etype = basic.tvoid; epos = pos; } else mk_switch_dyn nonstatics false !old_nonstatics in dyn_fun.cf_expr <- Some { eexpr = TFunction( { tf_args = all_args; tf_type = t_dynamic; tf_expr = mk_block contents; }); etype = TFun(fun_args all_args, t_dynamic); epos = pos; }; if !is_override && not (!has_method) then () else begin cl.cl_ordered_fields <- cl.cl_ordered_fields @ [dyn_fun]; cl.cl_fields <- PMap.add dyn_fun.cf_name dyn_fun cl.cl_fields; (if !is_override then cl.cl_overrides <- dyn_fun :: cl.cl_overrides) end let implement_varargs_cl ctx cl = let pos = cl.cl_pos in let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let this_t = TInst(cl, List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t ; epos = pos } in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let invokedyn = gen.gmk_internal_name "hx" "invokeDynamic" in let idyn_t = TFun([gen.gmk_internal_name "fn" "dynargs", false, basic.tarray t_dynamic], t_dynamic) in let this_idyn = mk_this invokedyn idyn_t in let map_fn arity ret vars api = let rec loop i acc = if i < 0 then acc else let obj = api i t_dynamic None in loop (i - 1) (obj :: acc) in let call_arg = if arity = (-1) then api (-1) t_dynamic None else if arity = 0 then null (basic.tarray t_empty) pos else { eexpr = TArrayDecl(loop (arity - 1) []); etype = basic.tarray t_empty; epos = pos } in let expr = { eexpr = TCall( this_idyn, [ call_arg ] ); etype = t_dynamic; epos = pos } in let expr = if like_float ret && not (like_int ret) then mk_cast ret expr else expr in [], mk_return expr in let all_cfs = List.filter (fun cf -> cf.cf_name <> "new" && cf.cf_name <> (invokedyn) && match cf.cf_kind with Method _ -> true | _ -> false) (ctx.rcf_ft.map_base_classfields cl true map_fn) in cl.cl_ordered_fields <- cl.cl_ordered_fields @ all_cfs; List.iter (fun cf -> cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields ) all_cfs; List.iter (fun cf -> cl.cl_overrides <- cf :: cl.cl_overrides ) cl.cl_ordered_fields let implement_closure_cl ctx cl = let pos = cl.cl_pos in let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let field_args, _ = field_type_args ctx pos in let obj_arg = alloc_var "target" (TInst(ctx.rcf_object_iface, [])) in let this_t = TInst(cl, List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t ; epos = pos } in let mk_this field t = { (mk_field_access gen this field pos) with etype = t } in let tf_args = field_args @ [obj_arg, None] in let cfs, ctor_body = List.fold_left (fun (acc_cf,acc_expr) (v,_) -> let cf = mk_class_field v.v_name v.v_type false pos (Var { v_read = AccNormal; v_write = AccNormal } ) [] in let expr = { eexpr = TBinop(Ast.OpAssign, mk_this v.v_name v.v_type, mk_local v pos); etype = v.v_type; epos = pos } in (cf :: acc_cf, expr :: acc_expr) ) ([], []) tf_args in let map_fn arity ret vars api = let this_obj = mk_this "target" (TInst(ctx.rcf_object_iface, [])) in let rec loop i acc = if i < 0 then acc else let obj = api i t_dynamic None in loop (i - 1) (obj :: acc) in let call_arg = if arity = (-1) then api (-1) t_dynamic None else if arity = 0 then null (basic.tarray t_empty) pos else { eexpr = TArrayDecl(loop (arity - 1) []); etype = basic.tarray t_empty; epos = pos } in let expr = { eexpr = TCall( mk_field_access gen this_obj (gen.gmk_internal_name "hx" "invokeField") pos, (List.map (fun (v,_) -> mk_this v.v_name v.v_type) field_args) @ (if ctx.rcf_handle_statics then [ { eexpr = TConst(TBool false); etype = basic.tbool; epos = pos }; call_arg ] else [ call_arg ] ) ); etype = t_dynamic; epos = pos } in let expr = if like_float ret && not (like_int ret) then mk_cast ret expr else expr in [], mk_return expr in let all_cfs = List.filter (fun cf -> cf.cf_name <> "new" && match cf.cf_kind with Method _ -> true | _ -> false) (ctx.rcf_ft.map_base_classfields cl true map_fn) in List.iter (fun cf -> cl.cl_overrides <- cf :: cl.cl_overrides ) all_cfs; let all_cfs = cfs @ all_cfs in cl.cl_ordered_fields <- cl.cl_ordered_fields @ all_cfs; List.iter (fun cf -> cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields ) all_cfs; let ctor_t = TFun(fun_args tf_args, basic.tvoid) in let ctor_cf = mk_class_field "new" ctor_t true pos (Method MethNormal) [] in ctor_cf.cf_expr <- Some { eexpr = TFunction({ tf_args = tf_args; tf_type = basic.tvoid; tf_expr = { eexpr = TBlock({ eexpr = TCall({ eexpr = TConst(TSuper); etype = TInst(cl,[]); epos = pos }, [mk_int ctx (-1) pos; mk_int ctx (-1) pos]); etype = basic.tvoid; epos = pos } :: ctor_body); etype = basic.tvoid; epos = pos } }); etype = ctor_t; epos = pos }; cl.cl_constructor <- Some ctor_cf; let closure_fun eclosure e field is_static = let f = { eexpr = TConst(TString field); etype = basic.tstring; epos = eclosure.epos } in let args = if ctx.rcf_optimize then [ f; { eexpr = TConst(TInt (hash_field_i32 ctx eclosure.epos field)); etype = basic.tint; epos = eclosure.epos } ] else [ f ] in let args = args @ [ mk_cast (TInst(ctx.rcf_object_iface, [])) e ] in { eclosure with eexpr = TNew(cl,[],args) } in closure_fun let get_closure_func ctx closure_cl = let gen = ctx.rcf_gen in let basic = gen.gcon.basic in let closure_func eclosure e field is_static = mk_cast eclosure.etype { eclosure with eexpr = TNew(closure_cl, [], [ e; { eexpr = TConst(TString field); etype = basic.tstring; epos = eclosure.epos } ] @ ( if ctx.rcf_optimize then [ { eexpr = TConst(TInt (hash_field_i32 ctx eclosure.epos field)); etype = basic.tint; epos = eclosure.epos } ] else [] )); etype = TInst(closure_cl,[]) } in closure_func (* main expr -> field expr -> field string -> possible set expr -> should_throw_exceptions -> changed expression Changes a get / set * mutable rcf_on_getset_field : texpr->texpr->string->texpr option->bool->texpr;*) let configure_dynamic_field_access ctx is_synf = let gen = ctx.rcf_gen in let is_dynamic expr fexpr field = match (field_access_esp gen (gen.greal_type fexpr.etype) field) with | FEnumField _ | FClassField _ -> false | _ -> true in let configure = if is_synf then DynamicFieldAccess.configure_as_synf else DynamicFieldAccess.configure in let maybe_hash = if ctx.rcf_optimize then fun str pos -> Some (hash_field_i32 ctx pos str) else fun str pos -> None in configure gen (DynamicFieldAccess.abstract_implementation gen is_dynamic (* print_endline *) (fun expr fexpr field set is_unsafe -> let hash = maybe_hash field fexpr.epos in ctx.rcf_on_getset_field expr fexpr field hash set is_unsafe ) (fun ecall fexpr field call_list -> let hash = maybe_hash field fexpr.epos in ctx.rcf_on_call_field ecall fexpr field hash call_list ) ); () let replace_reflection ctx cl = let gen = ctx.rcf_gen in let pos = cl.cl_pos in let this_t = TInst(cl, List.map snd cl.cl_params) in let this = { eexpr = TConst(TThis); etype = this_t; epos = pos } in let last_fields = match cl.cl_super with | None -> PMap.empty | Some (super,_) -> super.cl_fields in let new_fields = ref [] in let process_cf static cf = match cf.cf_kind with | Var _ -> () | _ when Meta.has Meta.ReplaceReflection cf.cf_meta -> let name = if String.get cf.cf_name 0 = '_' then String.sub cf.cf_name 1 (String.length cf.cf_name - 1) else cf.cf_name in let new_name = gen.gmk_internal_name "hx" name in let new_cf = mk_class_field new_name cf.cf_type cf.cf_public cf.cf_pos cf.cf_kind cf.cf_params in let fn_args, ret = get_fun (follow cf.cf_type) in let tf_args = List.map (fun (name,_,t) -> alloc_var name t, None) fn_args in let is_void = is_void ret in let expr = { eexpr = TCall( { eexpr = (if static then TField(mk_classtype_access cl pos, FStatic(cl, cf)) else TField(this, FInstance(cl, List.map snd cl.cl_params, cf))); etype = cf.cf_type; epos = cf.cf_pos; }, List.map (fun (v,_) -> mk_local v cf.cf_pos) tf_args); etype = ret; epos = cf.cf_pos } in let new_f = { tf_args = tf_args; tf_type = ret; tf_expr = { eexpr = TBlock([if is_void then expr else mk_return expr]); etype = ret; epos = pos; } } in new_cf.cf_expr <- Some({ eexpr = TFunction(new_f); etype = cf.cf_type; epos = cf.cf_pos}); new_fields := new_cf :: !new_fields; (if static then cl.cl_statics <- PMap.add new_name new_cf cl.cl_statics else cl.cl_fields <- PMap.add new_name new_cf cl.cl_fields); if not static && PMap.mem new_name last_fields then cl.cl_overrides <- new_cf :: cl.cl_overrides | _ -> () in List.iter (process_cf false) cl.cl_ordered_fields; cl.cl_ordered_fields <- cl.cl_ordered_fields @ !new_fields; new_fields := []; List.iter (process_cf true) cl.cl_ordered_statics; cl.cl_ordered_statics <- cl.cl_ordered_statics @ !new_fields (* ******************************************* *) (* UniversalBaseClass *) (* ******************************************* *) (* Sets the universal base class for hxgen types (HxObject / IHxObject) dependencies: As a rule, it should be one of the last module filters to run so any @:hxgen class created in the process -Should- only run after TypeParams.RealTypeParams.Modf, since *) module UniversalBaseClass = struct let name = "rcf_universal_base_class" let priority = min_dep +. 10. let default_implementation gen baseclass baseinterface basedynamic = (* baseinterface.cl_meta <- (Meta.BaseInterface, [], baseinterface.cl_pos) :: baseinterface.cl_meta; *) let rec run md = (if is_hxgen md then match md with | TClassDecl ( { cl_interface = true } as cl ) when cl.cl_path <> baseclass.cl_path && cl.cl_path <> baseinterface.cl_path && cl.cl_path <> basedynamic.cl_path -> cl.cl_implements <- (baseinterface, []) :: cl.cl_implements | TClassDecl ({ cl_kind = KAbstractImpl _ } as cl) -> (* TODO: probably here is not the best place to add @:final to KAbstractImpl, also: Doesn't it make sense to add @:final to KAbstractImpls on all platforms? *) if not (Meta.has Meta.Final cl.cl_meta) then cl.cl_meta <- (Meta.Final, [], cl.cl_pos) :: cl.cl_meta | TClassDecl ( { cl_super = None } as cl ) when cl.cl_path <> baseclass.cl_path && cl.cl_path <> baseinterface.cl_path && cl.cl_path <> basedynamic.cl_path -> if is_some cl.cl_dynamic then cl.cl_super <- Some (basedynamic,[]) else cl.cl_super <- Some (baseclass,[]) | TClassDecl ( { cl_super = Some(super,_) } as cl ) when cl.cl_path <> baseclass.cl_path && cl.cl_path <> baseinterface.cl_path && not ( is_hxgen (TClassDecl super) ) -> cl.cl_implements <- (baseinterface, []) :: cl.cl_implements | _ -> () ); md in run let configure gen mapping_func = let map e = Some(mapping_func e) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map let default_config gen baseclass baseinterface basedynamic = let impl = (default_implementation gen baseclass baseinterface basedynamic) in configure gen impl end;; (* Priority: must run AFTER UniversalBaseClass *) let priority = solve_deps name [DAfter UniversalBaseClass.priority] let configure ?slow_invoke ctx baseinterface = let gen = ctx.rcf_gen in let run = (fun md -> match md with | TClassDecl cl when is_hxgen md && ( not cl.cl_interface || cl.cl_path = baseinterface.cl_path ) && (match cl.cl_kind with KAbstractImpl _ -> false | _ -> true) -> (if Meta.has Meta.ReplaceReflection cl.cl_meta then replace_reflection ctx cl); (implement_dynamics ctx cl); (if not (PMap.mem (gen.gmk_internal_name "hx" "lookupField") cl.cl_fields) then implement_final_lookup ctx cl); (if not (PMap.mem (gen.gmk_internal_name "hx" "getField") cl.cl_fields) then implement_get_set ctx cl); (if not (PMap.mem (gen.gmk_internal_name "hx" "invokeField") cl.cl_fields) then implement_invokeField ctx ~slow_invoke:slow_invoke cl); (if not (PMap.mem (gen.gmk_internal_name "hx" "classFields") cl.cl_fields) then implement_fields ctx cl); (if ctx.rcf_handle_statics && not (PMap.mem (gen.gmk_internal_name "hx" "getClassStatic") cl.cl_statics) then implement_get_class ctx cl); (if not cl.cl_interface && not (PMap.mem (gen.gmk_internal_name "hx" "create") cl.cl_fields) then implement_create_empty ctx cl); None | _ -> None) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) run end;; (* ******************************************* *) (* Object Declaration Mapper *) (* ******************************************* *) (* A simple Object Declaration Mapper. By default it will be a syntax filter, which only runs after dependencies: *) module ObjectDeclMap = struct let name = "object_decl_map" let priority = solve_deps name [] let traverse gen map_fn = let rec run e = match e.eexpr with | TObjectDecl odecl -> let e = Type.map_expr run e in (match e.eexpr with | TObjectDecl odecl -> map_fn e odecl | _ -> assert false) | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* EnumToClass *) (* ******************************************* *) (* For languages that don't support parameterized enums and/or metadata in enums, we need to transform enums into normal classes. This is done at the first module pass by creating new classes with the same path inside the modules, and removing the actual enum module by setting it as en extern. Later, on the last expression pass, it will transform the TMatch codes into TSwitch. it will introduce a new dependency, though: * The target must create its own strategy to deal with reflection. As it is right now, we will have a base class which the class will extend, create @:$IsEnum metadata for the class, and create @:alias() metadatas for the fields, with their tag order (as a string) as their alias. If you are using ReflectionCFs, then you don't have to worry about that, as it's already generating all information needed by the haxe runtime. so they can be dependencies: The MatchToSwitch part must run after ExprStatementUnwrap as modified expressions might confuse it (not so true anymore) *) module EnumToClass = struct let name = "enum_to_class" let priority = solve_deps name [] type t = { ec_tbl : (path, tclass) Hashtbl.t; } let new_t () = { ec_tbl = Hashtbl.create 10 } (* ******************************************* *) (* EnumToClassModf *) (* ******************************************* *) (* The actual Module Filter that will transform the enum into a class dependencies: Should run before ReflectionCFs, in order to enable proper reflection access. Should run before TypeParams.RealTypeParams.RealTypeParamsModf, since generic enums must be first converted to generic classes It needs that the target platform implements __array__() as a shortcut to declare haxe.ds.Vector *) module EnumToClassModf = struct let name = "enum_to_class_mod" let priority = solve_deps name [DBefore ReflectionCFs.priority; DBefore TypeParams.RealTypeParams.RealTypeParamsModf.priority] let pmap_exists fn pmap = try PMap.iter (fun a b -> if fn a b then raise Exit) pmap; false with | Exit -> true let has_any_meta en = let has_meta meta = List.exists (fun (m,_,_) -> match m with Meta.Custom _ -> true | _ -> false) meta in has_meta en.e_meta || pmap_exists (fun _ ef -> has_meta ef.ef_meta) en.e_constrs let convert gen t base_class base_param_class en should_be_hxgen handle_type_params = let basic = gen.gcon.basic in let pos = en.e_pos in (* create the class *) let cl = mk_class en.e_module en.e_path pos in Hashtbl.add t.ec_tbl en.e_path cl; (match Codegen.build_metadata gen.gcon (TEnumDecl en) with | Some expr -> let cf = mk_class_field "__meta__" expr.etype false expr.epos (Var { v_read = AccNormal; v_write = AccNormal }) [] in cf.cf_expr <- Some expr; cl.cl_statics <- PMap.add "__meta__" cf cl.cl_statics; cl.cl_ordered_statics <- cf :: cl.cl_ordered_statics | _ -> () ); let super, has_params = if Meta.has Meta.FlatEnum en.e_meta then base_class, false else base_param_class, true in cl.cl_super <- Some(super,[]); cl.cl_extern <- en.e_extern; en.e_meta <- (Meta.Class, [], pos) :: en.e_meta; cl.cl_module <- en.e_module; cl.cl_meta <- ( Meta.Enum, [], pos ) :: cl.cl_meta; (match gen.gcon.platform with | Cs when Common.defined gen.gcon Define.CoreApiSerialize -> cl.cl_meta <- ( Meta.Meta, [ (EField( (EConst (Ident "System"), null_pos ), "Serializable" ), null_pos) ], null_pos ) :: cl.cl_meta | _ -> ()); let c_types = if handle_type_params then List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) en.e_params else [] in cl.cl_params <- c_types; let i = ref 0 in let cfs = List.map (fun name -> let ef = PMap.find name en.e_constrs in let pos = ef.ef_pos in let old_i = !i in incr i; let cf = match follow ef.ef_type with | TFun(params,ret) -> let dup_types = if handle_type_params then List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) en.e_params else [] in let ef_type = let fn, types = if handle_type_params then snd, dup_types else (fun _ -> t_dynamic), en.e_params in let t = apply_params en.e_params (List.map fn types) ef.ef_type in apply_params ef.ef_params (List.map fn ef.ef_params) t in let params, ret = get_fun ef_type in let cf_params = if handle_type_params then dup_types @ ef.ef_params else [] in let cf = mk_class_field name ef_type true pos (Method MethNormal) cf_params in cf.cf_meta <- []; let tf_args = List.map (fun (name,opt,t) -> (alloc_var name t, if opt then Some TNull else None) ) params in let arr_decl = mk_nativearray_decl gen t_dynamic (List.map (fun (v,_) -> mk_local v pos) tf_args) pos in let expr = { eexpr = TFunction({ tf_args = tf_args; tf_type = ret; tf_expr = mk_block ( mk_return { eexpr = TNew(cl,List.map snd dup_types, [mk_int gen old_i pos; arr_decl] ); etype = TInst(cl, List.map snd dup_types); epos = pos } ); }); etype = ef_type; epos = pos } in cf.cf_expr <- Some expr; cf | _ -> let actual_t = match follow ef.ef_type with | TEnum(e, p) -> TEnum(e, List.map (fun _ -> t_dynamic) p) | _ -> assert false in let cf = mk_class_field name actual_t true pos (Var { v_read = AccNormal; v_write = AccNever }) [] in let args = if has_params then [mk_int gen old_i pos; null (gen.gclasses.nativearray t_dynamic) pos] else [mk_int gen old_i pos] in cf.cf_meta <- [Meta.ReadOnly,[],pos]; cf.cf_expr <- Some { eexpr = TNew(cl, List.map (fun _ -> t_empty) cl.cl_params, args); etype = TInst(cl, List.map (fun _ -> t_empty) cl.cl_params); epos = pos; }; cf in cl.cl_statics <- PMap.add cf.cf_name cf cl.cl_statics; cf ) en.e_names in let constructs_cf = mk_class_field "__hx_constructs" (gen.gclasses.nativearray basic.tstring) true pos (Var { v_read = AccNormal; v_write = AccNever }) [] in constructs_cf.cf_meta <- [Meta.ReadOnly,[],pos]; constructs_cf.cf_expr <- Some (mk_nativearray_decl gen basic.tstring (List.map (fun s -> { eexpr = TConst(TString s); etype = basic.tstring; epos = pos }) en.e_names) pos); cl.cl_ordered_statics <- constructs_cf :: cfs @ cl.cl_ordered_statics ; cl.cl_statics <- PMap.add "__hx_constructs" constructs_cf cl.cl_statics; let getTag_cf_type = tfun [] basic.tstring in let getTag_cf = mk_class_field "getTag" getTag_cf_type true pos (Method MethNormal) [] in getTag_cf.cf_meta <- [(Meta.Final, [], pos)]; getTag_cf.cf_expr <- Some { eexpr = TFunction { tf_args = []; tf_type = basic.tstring; tf_expr = { eexpr = TReturn (Some ( let e_constructs = mk_static_field_access_infer cl "__hx_constructs" pos [] in let e_this = mk (TConst TThis) (TInst (cl,[])) pos in let e_index = mk_field_access gen e_this "index" pos in { eexpr = TArray(e_constructs,e_index); etype = basic.tstring; epos = pos; } )); epos = pos; etype = basic.tvoid; } }; etype = getTag_cf_type; epos = pos; }; cl.cl_ordered_fields <- getTag_cf :: cl.cl_ordered_fields ; cl.cl_fields <- PMap.add "getTag" getTag_cf cl.cl_fields; cl.cl_overrides <- getTag_cf :: cl.cl_overrides; if should_be_hxgen then cl.cl_meta <- (Meta.HxGen,[],cl.cl_pos) :: cl.cl_meta else cl.cl_meta <- (Meta.NativeGen,[],cl.cl_pos) :: cl.cl_meta; gen.gadd_to_module (TClassDecl cl) (max_dep); TEnumDecl en (* traverse gen - gen context convert_all : bool - should we convert all enums? If set, convert_if_has_meta will be ignored. convert_if_has_meta : bool - should we convert only if it has meta? enum_base_class : tclass - the enum base class. should_be_hxgen : bool - should the created enum be hxgen? *) let traverse gen t convert_all convert_if_has_meta enum_base_class param_enum_class should_be_hxgen handle_tparams = let convert e = convert gen t enum_base_class param_enum_class e should_be_hxgen handle_tparams in let run md = match md with | TEnumDecl e when is_hxgen md -> if convert_all then convert e else if convert_if_has_meta && has_any_meta e then convert e else if not (Meta.has Meta.FlatEnum e.e_meta) then convert e else begin (* take off the :hxgen meta from it, if there's any *) e.e_meta <- List.filter (fun (n,_,_) -> not (n = Meta.HxGen)) e.e_meta; md end | _ -> md in run let configure gen (mapping_func:module_type->module_type) = let map md = Some(mapping_func md) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* EnumToClassExprf *) (* ******************************************* *) (* Enum to class Expression Filter will convert TMatch into TSwitch dependencies: Should run before TArrayTransform, since it generates array access expressions *) module EnumToClassExprf = struct let name = "enum_to_class_exprf" let priority = solve_deps name [DBefore TArrayTransform.priority] let traverse gen t opt_get_native_enum_tag = let rec run e = let get_converted_enum_type et = let en, eparams = match follow (gen.gfollow#run_f et) with | TEnum(en,p) -> en, p | _ -> raise Not_found in let cl = Hashtbl.find t.ec_tbl en.e_path in TInst(cl, eparams) in match e.eexpr with | TCall (({eexpr = TField(_, FStatic({cl_path=[],"Type"},{cf_name="enumIndex"}))} as left), [f]) -> let f = run f in (try mk_field_access gen {f with etype = get_converted_enum_type f.etype} "index" e.epos with Not_found -> { e with eexpr = TCall(left, [f]) }) | TEnumParameter(f, _,i) -> let f = run f in (* check if en was converted to class *) (* if it was, switch on tag field and change cond type *) let f = try { f with etype = get_converted_enum_type f.etype } with Not_found -> f in let cond_array = { (mk_field_access gen f "params" f.epos) with etype = gen.gclasses.nativearray t_dynamic } in { e with eexpr = TArray(cond_array, mk_int gen i cond_array.epos); } | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:name ~priority:(PCustom priority) map end;; let configure gen opt_get_native_enum_tag convert_all convert_if_has_meta enum_base_class param_enum_class should_be_hxgen handle_tparams = let t = new_t () in EnumToClassModf.configure gen (EnumToClassModf.traverse gen t convert_all convert_if_has_meta enum_base_class param_enum_class should_be_hxgen handle_tparams); EnumToClassExprf.configure gen (EnumToClassExprf.traverse gen t opt_get_native_enum_tag) end;; (* ******************************************* *) (* IteratorsInterface *) (* ******************************************* *) (* This module will handle with Iterators, Iterables and TFor() expressions. At first, a module filter will receive a Iterator and Iterable interface, which will be implemented if hasNext(), next() or iterator() fields are detected with the correct type. At this part a custom function will be called which can adequate the class fields so they are compatible with native Iterators as well The expression filter part of this module will look for TFor() expressions, and transform like that: for (anInt in value.iterator()) { } { var s:haxe.lang.Iterator = ExternalFunction.getIterator(value.iterator()); while (s.hasNext()) { var anInt:Int = s.next(); } } dependencies: None. *) module IteratorsInterface = struct let name = "iterators_interface" (* TODO later (* ******************************************* *) (* IteratorsInterfaceModf *) (* ******************************************* *) (* The module filter for Iterators Interface, which will implement the iterator/iterable interface on each class that conforms with the typedefs Iterator<> and Iterable<> It's a very simple module and it will rely on cast detection to work correctly. This is so that when the dependencies: Must run at the Module Filters, so cast detection can detect a cast to the interface and we can *) module IteratorsInterfaceModf = struct let name = "iterators_interface_modf" let conforms_cfs has_next next = try (match follow has_next.cf_type with | TFun([],ret) when (match follow ret with | TAbstract({ a_path = ([], "Bool") }, []) -> () | _ -> raise Not_found) -> () | _ -> raise Not_found); (match follow next.cf_type with | TFun([], ret) -> ret | _ -> raise Not_found ) let conforms_type_iterator t = try match follow t with | TInst(cl,params) -> let has_next = PMap.find "hasNext" cl.cl_fields in let next = PMap.find "next" cl.cl_fields in Some (conforms_cfs has_next next) | TAnon(anon) -> let has_next = PMap.find "hasNext" anon.a_fields in let next = PMap.find "next" anon.a_fields in Some (conforms_cfs has_next next) | _ -> None with | Not_found -> None let conforms_as_iterable cl = try let iterator = PMap.find "iterator" cl.cl_fields in match follow iterator.cf_type with | TFun([], ret) -> conforms_type_iterator ret | _ -> None with | Not_found -> None let conforms_as_iterator cl = try let has_next = PMap.find "hasNext" cl.cl_fields in let next = PMap.find "next" cl.cl_fields in Some (conforms_cfs has_next next) with | Not_found -> None let priority = solve_deps name [] let traverse gen iterator_iface iterable_iface on_found_iterator on_found_iterable = let rec run md = match md with | TClassDecl cl when not cl.cl_extern && is_hxgen cl -> let conforms_iterator = conforms_as_iterator cl in let conforms_iterable = conforms_as_iterable cl in if is_some conforms_iterator then begin let it_t = get conforms_iterator in cl.cl_interfaces <- (iterator_iface, [it_t]); on_found_iterator cl end; if is_some conforms_iterable then begin let it_t = get conforms_iterable in cl.cl_interfaces <- (iterable_iface, [it_t]); on_found_iterable cl end; md | _ -> md in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:name ~priority:(PCustom priority) map end;; *) (* ******************************************* *) (* IteratorsInterfaceExprf *) (* ******************************************* *) (* The expression filter for Iterators. Will look for TFor, transform it into { var iterator = // in expression here while (iterator.hasNext()) { var varName = iterator.next(); } } dependencies: Must run before Dynamic fields access is run *) module IteratorsInterfaceExprf = struct let name = "iterators_interface_exprf" let priority = solve_deps name [DBefore DynamicFieldAccess.priority] let priority_as_synf = solve_deps name [DBefore DynamicFieldAccess.priority_as_synf] let mk_access gen v name pos = let field_t = try match follow v.v_type with | TInst(cl, params) -> let field = PMap.find name cl.cl_fields in apply_params cl.cl_params params field.cf_type | TAnon(anon) -> let field = PMap.find name anon.a_fields in field.cf_type | _ -> t_dynamic with | Not_found -> t_dynamic in { (mk_field_access gen (mk_local v pos) name pos) with etype = field_t } let traverse gen change_in_expr = let basic = gen.gcon.basic in let rec run e = match e.eexpr with | TFor(var, in_expr, block) -> let in_expr = change_in_expr (run in_expr) in let temp = mk_temp gen "iterator" in_expr.etype in let block = [ { eexpr = TVar(temp, Some(in_expr)); etype = basic.tvoid; epos = in_expr.epos }; { eexpr = TWhile( { eexpr = TCall(mk_access gen temp "hasNext" in_expr.epos, []); etype = basic.tbool; epos = in_expr.epos }, Type.concat ({ eexpr = TVar(var, Some({ eexpr = TCall(mk_access gen temp "next" in_expr.epos, []); etype = var.v_type; epos = in_expr.epos })); etype = basic.tvoid; epos = in_expr.epos }) ( run block ), Ast.NormalWhile); etype = basic.tvoid; epos = e.epos } ] in { eexpr = TBlock(block); etype = e.etype; epos = e.epos } | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:name ~priority:(PCustom priority) map let configure_as_synf gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gexpr_filters#add ~name:name ~priority:(PCustom priority_as_synf) map end;; let configure gen change_in_expr = IteratorsInterfaceExprf.configure gen (IteratorsInterfaceExprf.traverse gen change_in_expr) let configure_as_synf gen change_in_expr = IteratorsInterfaceExprf.configure_as_synf gen (IteratorsInterfaceExprf.traverse gen change_in_expr) end;; (* ******************************************* *) (* SwitchToIf *) (* ******************************************* *) (* Just a syntax filter which changes switch expressions to if() else if() else if() ... It can be also an expression filter dependencies: *) module SwitchToIf = struct let name = "switch_to_if" let priority = solve_deps name [] let rec simplify_expr e = match e.eexpr with | TParenthesis e | TMeta(_,e) -> simplify_expr e | _ -> e let traverse gen (should_convert:texpr->bool) (handle_nullables:bool) = let basic = gen.gcon.basic in let rec run e = match e.eexpr with | TSwitch(cond,cases,default) when should_convert e -> let cond_etype, should_cache = match handle_nullables, gen.gfollow#run_f cond.etype with | true, TType({ t_path = ([], "Null") }, [t]) -> let rec take_off_nullable t = match gen.gfollow#run_f t with | TType({ t_path = ([], "Null") }, [t]) -> take_off_nullable t | _ -> t in take_off_nullable t, true | _, _ -> cond.etype, false in if should_cache && not (should_convert { e with eexpr = TSwitch({ cond with etype = cond_etype }, cases, default) }) then begin { e with eexpr = TSwitch(mk_cast cond_etype (run cond), List.map (fun (cs,e) -> (List.map run cs, run e)) cases, Option.map run default) } end else begin let local, fst_block = match cond.eexpr, should_cache with | TLocal _, false -> cond, [] | _ -> let var = mk_temp gen "switch" cond_etype in let cond = run cond in let cond = if should_cache then mk_cast cond_etype cond else cond in mk_local var cond.epos, [ { eexpr = TVar(var,Some(cond)); etype = basic.tvoid; epos = cond.epos } ] in let mk_eq cond = { eexpr = TBinop(Ast.OpEq, local, cond); etype = basic.tbool; epos = cond.epos } in let rec mk_many_cond conds = match conds with | cond :: [] -> mk_eq cond | cond :: tl -> { eexpr = TBinop(Ast.OpBoolOr, mk_eq (run cond), mk_many_cond tl); etype = basic.tbool; epos = cond.epos } | [] -> assert false in let mk_many_cond conds = let ret = mk_many_cond conds in (* this might be considered a hack. But since we're on a syntax filter and the condition is guaranteed to not have run twice, we can really run the expr filters again for it (so to change e.g. OpEq accordingly *) gen.gexpr_filters#run_f ret in let rec loop cases = match cases with | (conds,e) :: [] -> { eexpr = TIf(mk_many_cond conds, run e, Option.map run default); etype = e.etype; epos = e.epos } | (conds,e) :: tl -> { eexpr = TIf(mk_many_cond conds, run e, Some(loop tl)); etype = e.etype; epos = e.epos } | [] -> match default with | None -> raise Exit | Some d -> run d in try { e with eexpr = TBlock(fst_block @ [loop cases]) } with | Exit -> { e with eexpr = TBlock [] } end | TSwitch(cond,cases,default) -> (try match (simplify_expr cond).eexpr with | TCall( { eexpr = TField(_,FStatic({ cl_path = [],"Type" }, { cf_name = "enumIndex" })) }, [enum] ) -> let real_enum = match enum.etype with | TEnum(e,_) -> e | _ -> raise Not_found in if Meta.has Meta.Class real_enum.e_meta then raise Not_found; let enum_expr = mk_mt_access (TEnumDecl(real_enum)) e.epos in let fields = Hashtbl.create (List.length real_enum.e_names) in PMap.iter (fun _ ef -> Hashtbl.add fields ef.ef_index ef) real_enum.e_constrs; let cases = List.map (fun (el,e) -> List.map (fun e -> match e.eexpr with | TConst(TInt i) -> let ef = Hashtbl.find fields (Int32.to_int i) in { e with eexpr = TField(enum_expr, FEnum(real_enum,ef)); etype = TEnum(real_enum,List.map (fun _ -> t_dynamic) real_enum.e_params) } | _ -> raise Not_found) el, run e ) cases in { e with eexpr = TSwitch(enum,cases,Option.map run default) } | _ -> raise Not_found with Not_found -> Type.map_expr run e) | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* Anonymous Class object handling *) (* ******************************************* *) (* (syntax) When we pass a class as an object, in some languages we will need a special construct to be able to access its statics as if they were normal object fields. On C# and Java the way found to do that is by handling statics reflection also by a normal instance. This also happens in hxcpp and neko, so I guess it's a valid practice. So if we want to handle the reflection of the static MyClass, here's roughly how it will be done: var x = MyClass; gets converted into Haxe.Lang.Class x = Haxe.Lang.Runtime.GetType(typeof(MyClass).RuntimeHandle); which will in turn look in its cache but roughly would do: Haxe.Lang.Class x = new Haxe.Lang.Class(new MyClass(EmptyObject.EMPTY)); This module will of course let the caller choose how this will be implemented. It will just identify all uses of class that will require it to be cast as an object. dependencies: *) module ClassInstance = struct let priority = solve_deps "class_instance" [] let traverse gen (change_expr:texpr->module_type->texpr) = let rec run e = match e.eexpr with | TCall( ({ eexpr = TLocal({ v_name = ("__is__" | "__as__" | "__typeof__") } as v) } as local), calls ) when Hashtbl.mem gen.gspecial_vars v.v_name -> { e with eexpr = TCall(local, List.map (fun e -> match e.eexpr with | TTypeExpr _ -> e | _ -> run e) calls) } | TField({ eexpr = TTypeExpr(mt) }, f) -> e | TField(ef, f) -> (match anon_class ef.etype with | None -> Type.map_expr run e | Some t -> { e with eexpr = TField( { ef with eexpr = TTypeExpr(t) }, f) } ) | TTypeExpr(mt) -> change_expr e mt | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:"class_instance" ~priority:(PCustom priority) map end;; (* ******************************************* *) (* HardNullableSynf *) (* ******************************************* *) (* This module will handle Null types for languages that offer a way of dealing with stack-allocated structures or tuples and generics. Essentialy on those targets a Null will be a tuple ( 'a * bool ), where bool is whether the value is null or not. At first (configure-time), we will modify the follow function so it can follow correctly nested Null>, and do not follow Null to its underlying type Then we will run a syntax filter, which will look for casts to Null and replace them by a call to the new Null creation; Also casts from Null to T or direct uses of Null (call, field access, array access, closure) will result in the actual value being accessed For compatibility with the C# target, HardNullable will accept both Null and haxe.lang.Null types dependencies: Needs to be run after all cast detection modules *) module HardNullableSynf = struct let name = "hard_nullable" let priority = solve_deps name [DAfter CastDetect.ReturnCast.priority] let rec is_null_t gen t = match gen.greal_type t with | TType( { t_path = ([], "Null") }, [of_t]) | TInst( { cl_path = (["haxe";"lang"], "Null") }, [of_t]) -> let rec take_off_null t = match is_null_t gen t with | None -> t | Some s -> take_off_null s in Some (take_off_null of_t) | TMono r -> (match !r with | Some t -> is_null_t gen t | None -> None) | TLazy f -> is_null_t gen (!f()) | TType (t, tl) -> is_null_t gen (apply_params t.t_params tl t.t_type) | _ -> None let follow_addon gen t = let rec strip_off_nullable t = let t = gen.gfollow#run_f t in match t with (* haxe.lang.Null> wouldn't be a valid construct, so only follow Null<> *) | TType ( { t_path = ([], "Null") }, [of_t] ) -> strip_off_nullable of_t | _ -> t in match t with | TType( ({ t_path = ([], "Null") } as tdef), [of_t]) -> Some( TType(tdef, [ strip_off_nullable of_t ]) ) | _ -> None let traverse gen unwrap_null wrap_val null_to_dynamic has_value opeq_handler handle_opeq handle_cast = (* let unwrap_null e = *) (* let ret = unwrap_null e in *) (* { ret with eexpr = TParenthesis(ret) } *) (* in *) (* let wrap_val e t b = *) (* let ret = wrap_val e t b in *) (* { ret with eexpr = TParenthesis(ret) } *) (* in *) let is_string t = match gen.greal_type t with | TInst({ cl_path=([],"String") },_) -> true | _ -> false in let handle_unwrap to_t e = let e_null_t = get (is_null_t gen e.etype) in match gen.greal_type to_t with | TDynamic _ | TMono _ | TAnon _ -> (match e_null_t with | TDynamic _ | TMono _ | TAnon _ -> gen.ghandle_cast to_t e_null_t (unwrap_null e) | _ -> null_to_dynamic e ) | _ -> gen.ghandle_cast to_t e_null_t (unwrap_null e) in let handle_wrap e t = match e.eexpr with | TConst(TNull) -> wrap_val e t false | _ -> wrap_val e t true in let is_null_t = is_null_t gen in let cur_block = ref [] in let add_tmp v e p = cur_block := { eexpr = TVar(v,e); etype = gen.gcon.basic.tvoid; epos = p } :: !cur_block in let get_local e = match e.eexpr with | TLocal _ -> e, e | _ -> let v = mk_temp gen "nulltmp" e.etype in add_tmp v (Some (null e.etype e.epos)) e.epos; let local = { e with eexpr = TLocal(v) } in mk_paren { e with eexpr = TBinop(Ast.OpAssign, local, e) }, local in let rec run e = match e.eexpr with | TBlock(bl) -> let lst = !cur_block in cur_block := []; List.iter (fun e -> let e = run e in cur_block := (e :: !cur_block) ) bl; let ret = !cur_block in cur_block := lst; { e with eexpr = TBlock(List.rev ret) } | TCast(v, _) -> let null_et = is_null_t e.etype in let null_vt = is_null_t v.etype in (match null_vt, null_et with | Some(vt), None when is_string e.etype -> let v = run v in { e with eexpr = TCast(null_to_dynamic v,None) } | Some(vt), None -> (match v.eexpr with (* is there an unnecessary cast to Nullable? *) | TCast(v2, _) -> run { v with etype = e.etype } | _ -> handle_unwrap e.etype (run v) ) | None, Some(et) -> handle_wrap (run v) et | Some(vt), Some(et) when handle_cast -> handle_wrap (gen.ghandle_cast et vt (handle_unwrap vt (run v))) et | Some(vt), Some(et) when not (type_iseq (run_follow gen vt) (run_follow gen et)) -> (* check if has value and convert *) let vlocal_fst, vlocal = get_local (run v) in { eexpr = TIf( has_value vlocal_fst, handle_wrap (mk_cast et (unwrap_null vlocal)) et, Some( handle_wrap (null et e.epos) et )); etype = e.etype; epos = e.epos } | _ -> Type.map_expr run e ) | TField(ef, field) when is_some (is_null_t ef.etype) -> let to_t = get (is_null_t ef.etype) in { e with eexpr = TField(handle_unwrap to_t (run ef), field) } | TCall(ecall, params) when is_some (is_null_t ecall.etype) -> let to_t = get (is_null_t ecall.etype) in { e with eexpr = TCall(handle_unwrap to_t (run ecall), List.map run params) } | TArray(earray, p) when is_some (is_null_t earray.etype) -> let to_t = get (is_null_t earray.etype) in { e with eexpr = TArray(handle_unwrap to_t (run earray), p) } | TBinop(op, e1, e2) -> let e1_t = is_null_t e1.etype in let e2_t = is_null_t e2.etype in (match op with | Ast.OpAssign | Ast.OpAssignOp _ -> (match e1_t, e2_t with | Some t1, Some t2 -> (match op with | Ast.OpAssign -> Type.map_expr run e | Ast.OpAssignOp op -> (match e1.eexpr with | TLocal _ -> { e with eexpr = TBinop( Ast.OpAssign, e1, handle_wrap { e with eexpr = TBinop (op, handle_unwrap t1 e1, handle_unwrap t2 (run e2) ) } t1 ) } | _ -> let v, e1, evars = match e1.eexpr with | TField(ef, f) -> let v = mk_temp gen "nullbinop" ef.etype in v, { e1 with eexpr = TField(mk_local v ef.epos, f) }, ef | _ -> let v = mk_temp gen "nullbinop" e1.etype in v, mk_local v e1.epos, e1 in { e with eexpr = TBlock([ { eexpr = TVar(v, Some evars); etype = gen.gcon.basic.tvoid; epos = e.epos }; { e with eexpr = TBinop( Ast.OpAssign, e1, handle_wrap { e with eexpr = TBinop (op, handle_unwrap t1 e1, handle_unwrap t2 (run e2) ) } t1 ) } ]) } ) | _ -> assert false ) | _ -> Type.map_expr run e (* casts are already dealt with normal CastDetection module *) ) | Ast.OpEq | Ast.OpNotEq when not handle_opeq -> Type.map_expr run e | Ast.OpEq | Ast.OpNotEq -> (match e1.eexpr, e2.eexpr with | TConst(TNull), _ when is_some e2_t -> let e = has_value (run e2) in if op = Ast.OpEq then { e with eexpr = TUnop(Ast.Not, Ast.Prefix, e) } else e | _, TConst(TNull) when is_some e1_t -> let e = has_value (run e1) in if op = Ast.OpEq then { e with eexpr = TUnop(Ast.Not, Ast.Prefix, e) } else e | _ when is_some e1_t || is_some e2_t -> let e1, e2 = if not (is_some e1_t) then run e2, handle_wrap (run e1) (get e2_t) else if not (is_some e2_t) then run e1, handle_wrap (run e2) (get e1_t) else run e1, run e2 in let e = opeq_handler e1 e2 in if op = Ast.OpEq then { e with eexpr = TUnop(Ast.Not, Ast.Prefix, e) } else e | _ -> Type.map_expr run e ) | Ast.OpAdd when is_string e1.etype || is_string e2.etype -> let e1 = if is_some e1_t then null_to_dynamic (run e1) else run e1 in let e2 = if is_some e2_t then null_to_dynamic (run e2) else run e2 in let e_t = is_null_t e.etype in if is_some e_t then wrap_val { eexpr = TBinop(op,e1,e2); etype = get e_t; epos = e.epos } (get e_t) true else { e with eexpr = TBinop(op,e1,e2) } | _ -> let e1 = if is_some e1_t then handle_unwrap (get e1_t) (run e1) else run e1 in let e2 = if is_some e2_t then handle_unwrap (get e2_t) (run e2) else run e2 in (* if it is Null, we need to convert the result again to null *) let e_t = (is_null_t e.etype) in if is_some e_t then wrap_val { eexpr = TBinop(op, e1, e2); etype = get e_t; epos = e.epos } (get e_t) true else { e with eexpr = TBinop(op, e1, e2) } ) (*| TUnop( (Ast.Increment as op)*) | _ -> Type.map_expr run e in let run e = match e.eexpr with | TFunction tf -> run { e with eexpr = TFunction { tf with tf_expr = mk_block tf.tf_expr } } | TBlock _ -> run e | _ -> match run (mk_block e) with | { eexpr = TBlock([e]) } -> e | e -> e in run let configure gen (mapping_func:texpr->texpr) = gen.gfollow#add ~name:(name ^ "_follow") (follow_addon gen); let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* ArrayDeclSynf *) (* ******************************************* *) (* A syntax filter that will change array declarations to the actual native array declarations plus the haxe array initialization dependencies: Must run after ObjectDeclMap since it can add TArrayDecl expressions *) module ArrayDeclSynf = struct let name = "array_decl_synf" let priority = solve_deps name [DAfter ObjectDeclMap.priority] let default_implementation gen native_array_cl = let rec run e = match e.eexpr with | TArrayDecl el -> let cl, params = match follow e.etype with | TInst(({ cl_path = ([], "Array") } as cl), ( _ :: _ as params)) -> cl, params | TInst(({ cl_path = ([], "Array") } as cl), []) -> cl, [t_dynamic] | _ -> assert false in let changed_params = gen.greal_type_param (TClassDecl cl) params in { e with eexpr = TNew(cl, changed_params, [ { e with eexpr = TArrayDecl(List.map run el); etype = TInst(native_array_cl, changed_params) } ] ); } | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* SwitchBreakSynf *) (* ******************************************* *) (* In most languages, 'break' is used as a statement also to break from switch statements. This generates an incompatibility with haxe code, as we can use break to break from loops from inside a switch This script will detect 'breaks' inside switch statements, and will offer the opportunity to change both when this pattern is found. Some options are possible: On languages that support goto, 'break' may mean goto " after the loop ". There also can be special labels for loops, so you can write "break label" (javascript, java, d) On languages that do not support goto, a custom solution must be enforced dependencies: Since UnreachableCodeElimination must run before it, and Unreachable should be one of the very last filters to run, we will make a fixed value which runs after UnreachableCodeElimination (meaning: it's the very last filter) *) module SwitchBreakSynf = struct let name = "switch_break_synf" let priority = min_dep -. 150.0 type add_to_block_api = texpr->bool->unit let traverse gen (change_loop:texpr->int->add_to_block_api->texpr) (change_break:texpr->int->add_to_block_api->texpr) = let in_switch = ref false in let cur_block = ref [] in let to_add = ref [] in let did_found = ref (-1) in let api expr before = if before then cur_block := expr :: !cur_block else to_add := expr :: !to_add in let num = ref 0 in let cur_num = ref 0 in let rec run e = match e.eexpr with | TFunction _ -> let old_num = !num in num := 0; let ret = Type.map_expr run e in num := old_num; ret | TFor _ | TWhile _ -> let last_switch = !in_switch in let last_found = !did_found in let last_num = !cur_num in in_switch := false; incr num; cur_num := !num; did_found := -1; let new_e = Type.map_expr run e in (* assuming that no loop will be found in the condition *) let new_e = if !did_found <> -1 then change_loop new_e !did_found api else new_e in did_found := last_found; in_switch := last_switch; cur_num := last_num; new_e | TSwitch _ -> let last_switch = !in_switch in in_switch := true; let new_e = Type.map_expr run e in in_switch := last_switch; new_e | TBlock bl -> let last_block = !cur_block in let last_toadd = !to_add in to_add := []; cur_block := []; List.iter (fun e -> let new_e = run e in cur_block := new_e :: !cur_block; match !to_add with | [] -> () | _ -> cur_block := !to_add @ !cur_block; to_add := [] ) bl; let ret = List.rev !cur_block in cur_block := last_block; to_add := last_toadd; { e with eexpr = TBlock(ret) } | TBreak -> if !in_switch then (did_found := !cur_num; change_break e !cur_num api) else e | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* Unreachable Code Elimination *) (* ******************************************* *) (* In some source code platforms, the code won't compile if there is Unreachable code, so this filter will take off any unreachable code. If the parameter "handle_switch_break" is set to true, it will already add a "break" statement on switch cases when suitable; in order to not confuse with while break, it will be a special expression __sbreak__ If the parameter "handle_not_final_returns" is set to true, it will also add final returns when functions are detected to be lacking of them. (Will respect __fallback__ expressions) If the parameter "java_mode" is set to true, some additional checks following the java unreachable specs (http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.21) will be added dependencies: This must run before SwitchBreakSynf (see SwitchBreakSynf dependecy value) This must be the LAST syntax filter to run. It expects ExpressionUnwrap to have run correctly, since this will only work for source-code based targets *) module UnreachableCodeEliminationSynf = struct let name = "unreachable_synf" let priority = min_dep -. 100.0 type uexpr_kind = | Normal | BreaksLoop | BreaksFunction let aggregate_kind e1 e2 = match e1, e2 with | Normal, _ | _, Normal -> Normal | BreaksLoop, _ | _, BreaksLoop -> BreaksLoop | BreaksFunction, BreaksFunction -> BreaksFunction let aggregate_constant op c1 c2= match op, c1, c2 with | OpEq, Some v1, Some v2 -> Some (TBool (v1 = v2)) | OpNotEq, Some v1, Some v2 -> Some (TBool (v1 <> v2)) | OpBoolOr, Some (TBool v1) , Some (TBool v2) -> Some (TBool (v1 || v2)) | OpBoolAnd, Some (TBool v1) , Some (TBool v2) -> Some (TBool (v1 && v2)) | OpAssign, _, Some v2 -> Some v2 | _ -> None let rec get_constant_expr e = match e.eexpr with | TConst (v) -> Some v | TBinop(op, v1, v2) -> aggregate_constant op (get_constant_expr v1) (get_constant_expr v2) | TParenthesis(e) | TMeta(_,e) -> get_constant_expr e | _ -> None let traverse gen should_warn handle_switch_break handle_not_final_returns java_mode = let basic = gen.gcon.basic in let do_warn = if should_warn then gen.gcon.warning "Unreachable code" else (fun pos -> ()) in let return_loop expr kind = match kind with | Normal | BreaksLoop -> expr, Normal | _ -> expr, kind in let sbreak = alloc_var "__sbreak__" t_dynamic in let mk_sbreak = mk_local sbreak in let rec has_fallback expr = match expr.eexpr with | TBlock(bl) -> (match List.rev bl with | { eexpr = TLocal { v_name = "__fallback__" } } :: _ -> true | ({ eexpr = TBlock(_) } as bl) :: _ -> has_fallback bl | _ -> false) | TLocal { v_name = "__fallback__" } -> true | _ -> false in let handle_case = if handle_switch_break then (fun (expr,kind) -> match kind with | Normal when has_fallback expr -> expr | Normal -> Type.concat expr (mk_sbreak expr.epos) | BreaksLoop | BreaksFunction -> expr ) else fst in let has_break = ref false in let rec process_expr expr = match expr.eexpr with | TReturn _ | TThrow _ -> expr, BreaksFunction | TContinue -> expr, BreaksLoop | TBreak -> has_break := true; expr, BreaksLoop | TCall( { eexpr = TLocal { v_name = "__goto__" } }, _ ) -> expr, BreaksLoop | TBlock bl -> let new_block = ref [] in let is_unreachable = ref false in let ret_kind = ref Normal in List.iter (fun e -> if !is_unreachable then do_warn e.epos else begin let changed_e, kind = process_expr e in new_block := changed_e :: !new_block; match kind with | BreaksLoop | BreaksFunction -> ret_kind := kind; is_unreachable := true | _ -> () end ) bl; { expr with eexpr = TBlock(List.rev !new_block) }, !ret_kind | TFunction tf -> let changed, kind = process_expr tf.tf_expr in let changed = if handle_not_final_returns && not (is_void tf.tf_type) && kind <> BreaksFunction then Type.concat changed { eexpr = TReturn( Some (null tf.tf_type expr.epos) ); etype = basic.tvoid; epos = expr.epos } else changed in { expr with eexpr = TFunction({ tf with tf_expr = changed }) }, Normal | TFor(var, cond, block) -> let last_has_break = !has_break in has_break := false; let changed_block, _ = process_expr block in has_break := last_has_break; let expr = { expr with eexpr = TFor(var, cond, changed_block) } in return_loop expr Normal | TIf(cond, eif, None) -> if java_mode then match get_constant_expr cond with | Some (TBool true) -> process_expr eif | _ -> { expr with eexpr = TIf(cond, fst (process_expr eif), None) }, Normal else { expr with eexpr = TIf(cond, fst (process_expr eif), None) }, Normal | TIf(cond, eif, Some eelse) -> let eif, eif_k = process_expr eif in let eelse, eelse_k = process_expr eelse in let k = aggregate_kind eif_k eelse_k in { expr with eexpr = TIf(cond, eif, Some eelse) }, k | TWhile(cond, block, flag) -> let last_has_break = !has_break in has_break := false; let block, k = process_expr block in if java_mode then match get_constant_expr cond, flag, !has_break with | Some (TBool true), _, false -> has_break := last_has_break; { expr with eexpr = TWhile(cond, block, flag) }, BreaksFunction | Some (TBool false), NormalWhile, _ -> has_break := last_has_break; do_warn expr.epos; null expr.etype expr.epos, Normal | _ -> has_break := last_has_break; return_loop { expr with eexpr = TWhile(cond,block,flag) } Normal else begin has_break := last_has_break; return_loop { expr with eexpr = TWhile(cond,block,flag) } Normal end | TSwitch(cond, el_e_l, None) -> { expr with eexpr = TSwitch(cond, List.map (fun (el, e) -> (el, handle_case (process_expr e))) el_e_l, None) }, Normal | TSwitch(cond, el_e_l, Some def) -> let def, k = process_expr def in let def = handle_case (def, k) in let k = ref k in let ret = { expr with eexpr = TSwitch(cond, List.map (fun (el, e) -> let e, ek = process_expr e in k := aggregate_kind !k ek; (el, handle_case (e, ek)) ) el_e_l, Some def) } in ret, !k (* | TMatch(cond, ep, il_vopt_e_l, None) -> { expr with eexpr = TMatch(cond, ep, List.map (fun (il, vopt, e) -> (il, vopt, handle_case (process_expr e))) il_vopt_e_l, None) }, Normal *) (* | TMatch(cond, ep, il_vopt_e_l, Some def) -> let def, k = process_expr def in let def = handle_case (def, k) in let k = ref k in let ret = { expr with eexpr = TMatch(cond, ep, List.map (fun (il, vopt, e) -> let e, ek = process_expr e in k := aggregate_kind !k ek; (il, vopt, handle_case (e, ek)) ) il_vopt_e_l, Some def) } in ret, !k *) | TTry (e, catches) -> let e, k = process_expr e in let k = ref k in let ret = { expr with eexpr = TTry(e, List.map (fun (v, e) -> let e, ek = process_expr e in k := aggregate_kind !k ek; (v, e) ) catches) } in ret, !k | _ -> expr, Normal in let run e = fst (process_expr e) in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* DefaultArguments *) (* ******************************************* *) (* This Module Filter will go through all defined functions in all modules and change them so they set all default arguments to be of a Nullable type, and adds the unroll from nullable to the not-nullable type in the beginning of the function. dependencies: It must run before OverloadingCtors, since OverloadingCtors will change optional structures behavior *) module DefaultArguments = struct let name = "default_arguments" let priority = solve_deps name [ DBefore OverloadingConstructor.priority ] let gen_check basic t nullable_var const pos = let is_null t = match t with TType({t_path = ([],"Null")}, _) -> true | _ -> false in let needs_cast t1 t2 = match is_null t1, is_null t2 with | true, false | false, true -> true | _ -> false in let const_t = match const with | TString _ -> basic.tstring | TInt _ -> basic.tint | TFloat _ -> basic.tfloat | TNull -> t | TBool _ -> basic.tbool | _ -> assert false in let const = { eexpr = TConst(const); etype = const_t; epos = pos } in let const = if needs_cast t const_t then mk_cast t const else const in let arg = mk_local nullable_var pos in let arg = if needs_cast t nullable_var.v_type then mk_cast t arg else arg in { eexpr = TIf( { eexpr = TBinop(Ast.OpEq, mk_local nullable_var pos, null nullable_var.v_type pos); etype = basic.tbool; epos = pos }, const, Some(arg) ); etype = t; epos = pos; } let add_opt gen block pos (var,opt) = match opt with | None | Some TNull -> (var,opt) | Some (TString str) -> block := Codegen.set_default gen.gcon var (TString str) pos :: !block; (var, opt) | Some const -> let basic = gen.gcon.basic in let nullable_var = mk_temp gen var.v_name (basic.tnull var.v_type) in let orig_name = var.v_name in var.v_name <- nullable_var.v_name; nullable_var.v_name <- orig_name; (* var v = (temp_var == null) ? const : cast temp_var; *) block := { eexpr = TVar(var, Some(gen_check basic var.v_type nullable_var const pos)); etype = basic.tvoid; epos = pos; } :: !block; (nullable_var, opt) let rec change_func gen cf = List.iter (change_func gen) cf.cf_overloads; let is_ctor = cf.cf_name = "new" in let basic = gen.gcon.basic in match cf.cf_kind, follow cf.cf_type with | Var _, _ | Method MethDynamic, _ -> () | _, TFun(args, ret) -> let found = ref false in let args = ref (List.map (fun (n,opt,t) -> (n,opt, if opt then (found := true; basic.tnull t) else t) ) args) in (match !found, cf.cf_expr with | true, Some ({ eexpr = TFunction tf } as texpr) -> let block = ref [] in let tf_args = List.map (add_opt gen block tf.tf_expr.epos) tf.tf_args in let arg_assoc = List.map2 (fun (v,o) (v2,_) -> v,(v2,o) ) tf.tf_args tf_args in let rec extract_super e = match e.eexpr with | TBlock(({ eexpr = TCall({ eexpr = TConst TSuper }, _) } as e2) :: tl) -> e2, tl | TBlock(hd :: tl) -> let e2, tl2 = extract_super hd in e2, tl2 @ tl | _ -> raise Not_found in let block = try if not is_ctor then raise Not_found; (* issue #2570 *) (* check if the class really needs the super as the first statement - just to make sure we don't inadvertently break any existing code *) let rec check cl = if not (is_hxgen (TClassDecl cl)) then () else match cl.cl_super with | None -> raise Not_found | Some (cl,_) -> check cl in (match gen.gcurrent_class with | Some cl -> check cl | _ -> ()); let super, tl = extract_super tf.tf_expr in (match super.eexpr with | TCall({ eexpr = TConst TSuper } as e1, args) -> (* any super argument will be replaced by an inlined version of the check *) let found = ref false in let rec replace_args e = match e.eexpr with | TLocal(v) -> (try let v2,o = List.assq v arg_assoc in let o = match o with | None -> raise Not_found | Some o -> o in found := true; gen_check gen.gcon.basic v.v_type v2 o e.epos with | Not_found -> e) | _ -> Type.map_expr replace_args e in let args = List.map (replace_args) args in { tf.tf_expr with eexpr = TBlock((if !found then { super with eexpr = TCall(e1,args) } else super) :: !block @ tl) } | _ -> assert false) with | Not_found -> Type.concat { tf.tf_expr with eexpr = TBlock(!block); etype = basic.tvoid } tf.tf_expr in args := fun_args tf_args; cf.cf_expr <- Some( {texpr with eexpr = TFunction( { tf with tf_args = tf_args; tf_expr = block } ); etype = TFun(!args, ret) } ); cf.cf_type <- TFun(!args, ret) | _ -> () ); (if !found then cf.cf_type <- TFun(!args, ret)) | _, _ -> assert false let traverse gen = let run md = match md with | TClassDecl cl -> List.iter (change_func gen) cl.cl_ordered_fields; List.iter (change_func gen) cl.cl_ordered_statics; (match cl.cl_constructor with | None -> () | Some cf -> change_func gen cf); md | _ -> md in run let configure gen (mapping_func:module_type->module_type) = let map md = Some(mapping_func md) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* Interface Variables Removal Modf *) (* ******************************************* *) (* This module filter will take care of sanitizing interfaces for targets that do not support variables declaration in interfaces. By now this will mean that if anything is typed as the interface, and a variable access is made, a FNotFound will be returned for the field_access, so the field will be only accessible by reflection. Speed-wise, ideally it would be best to create getProp/setProp functions in this case and change the AST to call them when accessing by interface. (TODO) But right now it will be accessed by reflection. dependencies: *) module InterfaceVarsDeleteModf = struct let name = "interface_vars" let priority = solve_deps name [] let run gen = let run md = match md with | TClassDecl ( { cl_interface = true } as cl ) -> let to_add = ref [] in let fields = List.filter (fun cf -> match cf.cf_kind with | Var _ when gen.gcon.platform = Cs && Meta.has Meta.Event cf.cf_meta -> true | Var vkind when not (Type.is_extern_field cf && Meta.has Meta.Property cf.cf_meta) -> (match vkind.v_read with | AccCall -> let newcf = mk_class_field ("get_" ^ cf.cf_name) (TFun([],cf.cf_type)) true cf.cf_pos (Method MethNormal) [] in to_add := newcf :: !to_add; | _ -> () ); (match vkind.v_write with | AccCall -> let newcf = mk_class_field ("set_" ^ cf.cf_name) (TFun(["val",false,cf.cf_type],cf.cf_type)) true cf.cf_pos (Method MethNormal) [] in to_add := newcf :: !to_add; | _ -> () ); cl.cl_fields <- PMap.remove cf.cf_name cl.cl_fields; false | Method MethDynamic -> (* TODO OPTIMIZATION - add a `_dispatch` method to the interface which will call the dynamic function itself *) cl.cl_fields <- PMap.remove cf.cf_name cl.cl_fields; false | _ -> true ) cl.cl_ordered_fields in cl.cl_ordered_fields <- fields; List.iter (fun cf -> match field_access gen (TInst(cl,List.map snd cl.cl_params)) cf.cf_name with | FNotFound | FDynamicField _ -> cl.cl_ordered_fields <- cf :: cl.cl_ordered_fields; cl.cl_fields <- PMap.add cf.cf_name cf cl.cl_fields | _ -> () ) !to_add; md | _ -> md in run let configure gen = let run = run gen in let map md = Some(run md) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* InterfaceProps *) (* ******************************************* *) (* This module filter will go through all declared properties, and see if they are conforming to a native interface. If they are, it will add Meta.Property to it dependencies: *) module InterfaceProps = struct let name = "interface_props" let priority = solve_deps name [] let run gen = let run md = match md with | TClassDecl ( { cl_interface = false; cl_extern = false } as cl ) -> let vars = List.fold_left (fun acc (iface,_) -> if Meta.has Meta.CsNative iface.cl_meta then List.filter (fun cf -> match cf.cf_kind with | Var { v_read = AccCall } | Var { v_write = AccCall } -> true | _ -> false ) iface.cl_ordered_fields @ acc else acc ) [] cl.cl_implements in let vars = List.map (fun cf -> cf.cf_name) vars in if vars <> [] then List.iter (fun cf -> match cf.cf_kind with | Var { v_read = AccCall } | Var { v_write = AccCall } when List.mem cf.cf_name vars -> cf.cf_meta <- (Meta.Property, [], Ast.null_pos) :: cf.cf_meta | _ -> () ) cl.cl_ordered_fields; md | _ -> md in run let configure gen = let run = run gen in let map md = Some(run md) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* Int Division Synf *) (* ******************************************* *) (* On targets that support int division, this module will force a float division to be performed, so compatibility with current haxe targets is ensured. If catch_int_div is set to true, though, it will look for casts to int or use of Std.int() to optimize this kind of operation. dependencies: since it depends on nothing, but many modules might generate division expressions, it will be one of the last modules to run *) module IntDivisionSynf = struct let name = "int_division_synf" let priority = solve_deps name [ DAfter ExpressionUnwrap.priority; DAfter ObjectDeclMap.priority; DAfter ArrayDeclSynf.priority ] let is_int = like_int let is_exactly_int t = match follow t with | TAbstract ({ a_path=[],"Int" }, []) -> true | _ -> false let default_implementation gen catch_int_div = let basic = gen.gcon.basic in let rec run e = match e.eexpr with | TBinop((Ast.OpDiv as op), e1, e2) when is_int e1.etype && is_int e2.etype -> { e with eexpr = TBinop(op, mk_cast basic.tfloat (run e1), run e2) } | TCall( { eexpr = TField(_, FStatic({ cl_path = ([], "Std") }, { cf_name = "int" })) }, [ ({ eexpr = TBinop((Ast.OpDiv as op), e1, e2) } as ebinop ) ] ) when catch_int_div && is_int e1.etype && is_int e2.etype -> let e = { ebinop with eexpr = TBinop(op, run e1, run e2); etype = basic.tint } in if not (is_exactly_int e1.etype && is_exactly_int e2.etype) then mk_cast basic.tint e else e | TCast( ({ eexpr = TBinop((Ast.OpDiv as op), e1, e2) } as ebinop ), _ ) | TCast( ({ eexpr = TBinop(( (Ast.OpAssignOp Ast.OpDiv) as op), e1, e2) } as ebinop ), _ ) when catch_int_div && is_int e1.etype && is_int e2.etype && is_int e.etype -> let ret = { ebinop with eexpr = TBinop(op, run e1, run e2); etype = e.etype } in if not (is_exactly_int e1.etype && is_exactly_int e2.etype) then mk_cast e.etype ret else e | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* UnnecessaryCastsRemoval *) (* ******************************************* *) (* This module will take care of simplifying unnecessary casts, specially those made by the compiler when inlining. Right now, it will only take care of casts used as a statement, which are always useless; TODO: Take care of more cases, e.g. when the to and from types are the same dependencies: This must run after CastDetection, but before ExpressionUnwrap *) module UnnecessaryCastsRemoval = struct let name = "casts_removal" let priority = solve_deps name [DAfter CastDetect.priority; DBefore ExpressionUnwrap.priority] let rec take_off_cast run e = match e.eexpr with | TCast (c, _) -> take_off_cast run c | _ -> run e let default_implementation gen = let rec traverse e = match e.eexpr with | TBlock bl -> let bl = List.map (fun e -> take_off_cast traverse e ) bl in { e with eexpr = TBlock bl } | TTry (block, catches) -> { e with eexpr = TTry(traverse (mk_block block), List.map (fun (v,block) -> (v, traverse (mk_block block))) catches) } (* | TMatch (cond,ep,il_vol_e_l,default) -> { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) } *) | TSwitch (cond,el_e_l, default) -> { e with eexpr = TSwitch(cond, List.map (fun (el,e) -> (el, traverse (mk_block e))) el_e_l, Option.map (fun e -> traverse (mk_block e)) default) } | TWhile (cond,block,flag) -> {e with eexpr = TWhile(cond,traverse (mk_block block), flag) } | TIf (cond, eif, eelse) -> { e with eexpr = TIf(cond, traverse (mk_block eif), Option.map (fun e -> traverse (mk_block e)) eelse) } | TFor (v,it,block) -> { e with eexpr = TFor(v,it, traverse (mk_block block)) } | TFunction (tfunc) -> { e with eexpr = TFunction({ tfunc with tf_expr = traverse (mk_block tfunc.tf_expr) }) } | _ -> e (* if expression doesn't have a block, we will exit *) in traverse let configure gen = let map e = Some(default_implementation gen e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* OverrideFix *) (* ******************************************* *) (* When DCE is on, sometimes a field is marked as override when it really doesn't override anything. This module filter will take care of this. dependencies: No dependencies *) module OverrideFix = struct let name = "override_fix" let priority = solve_deps name [] let default_implementation gen = let rec run e = match e.eexpr with | _ -> Type.map_expr run e in run let configure gen = let map md = match md with | TClassDecl cl -> cl.cl_overrides <- List.filter (fun s -> let rec loop cl = match cl.cl_super with | Some (cl,_) when PMap.mem s.cf_name cl.cl_fields -> true | Some (cl,_) -> loop cl | None -> false in loop cl ) cl.cl_overrides; Some md | _ -> Some md in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* AbstractImplementationFix *) (* ******************************************* *) (* This module filter will map the compiler created classes from abstract implementations to valid haxe code, as needed by gencommon dependencies: No dependencies *) module AbstractImplementationFix = struct let name = "abstract_implementation_fix" let priority = solve_deps name [] let default_implementation gen = let rec run md = match md with | TClassDecl ({ cl_kind = KAbstractImpl a } as c) -> List.iter (function | ({ cf_name = "_new" } as cf) -> cf.cf_params <- cf.cf_params @ a.a_params | cf when Meta.has Meta.Impl cf.cf_meta -> (match cf.cf_expr with | Some({ eexpr = TFunction({ tf_args = (v, _) :: _ }) }) when Meta.has Meta.This v.v_meta -> cf.cf_params <- cf.cf_params @ a.a_params | _ -> ()) | _ -> () ) c.cl_ordered_statics; Some md | _ -> Some md in run let configure gen = let map = default_implementation gen in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* FixOverrides *) (* ******************************************* *) (* Covariant return types, contravariant function arguments and applied type parameters may change in a way that expected implementations / overrides aren't recognized as such. This filter will fix that. dependencies: FixOverrides expects that the target platform is able to deal with overloaded functions It must run after DefaultArguments, otherwise code added by the default arguments may be invalid *) module FixOverrides = struct let name = "fix_overrides" let priority = solve_deps name [DAfter DefaultArguments.priority] (* if the platform allows explicit interface implementation (C#), specify a explicit_fn_name function (tclass->string->string) Otherwise, it expects the platform to be able to handle covariant return types *) let run ~explicit_fn_name ~get_vmtype gen = let implement_explicitly = is_some explicit_fn_name in let run md = match md with | TClassDecl ( { cl_interface = true; cl_extern = false } as c ) -> (* overrides can be removed from interfaces *) c.cl_ordered_fields <- List.filter (fun f -> try if Meta.has Meta.Overload f.cf_meta then raise Not_found; let f2 = Codegen.find_field gen.gcon c f in if f2 == f then raise Not_found; c.cl_fields <- PMap.remove f.cf_name c.cl_fields; false; with Not_found -> true ) c.cl_ordered_fields; md | TClassDecl({ cl_extern = false } as c) -> let this = { eexpr = TConst TThis; etype = TInst(c,List.map snd c.cl_params); epos = c.cl_pos } in (* look through all interfaces, and try to find a type that applies exactly *) let rec loop_iface (iface:tclass) itl = List.iter (fun (s,stl) -> loop_iface s (List.map (apply_params iface.cl_params itl) stl)) iface.cl_implements; let real_itl = gen.greal_type_param (TClassDecl iface) itl in let rec loop_f f = List.iter loop_f f.cf_overloads; let ftype = apply_params iface.cl_params itl f.cf_type in let real_ftype = get_real_fun gen (apply_params iface.cl_params real_itl f.cf_type) in replace_mono real_ftype; let overloads = Typeload.get_overloads c f.cf_name in try let t2, f2 = match overloads with | (_, cf) :: _ when Meta.has Meta.Overload cf.cf_meta -> (* overloaded function *) (* try to find exact function *) List.find (fun (t,f2) -> Typeload.same_overload_args ~get_vmtype ftype t f f2 ) overloads | _ :: _ -> (match field_access gen (TInst(c, List.map snd c.cl_params)) f.cf_name with | FClassField(_,_,_,f2,false,t,_) -> t,f2 (* if it's not an overload, all functions should have the same signature *) | _ -> raise Not_found) | [] -> raise Not_found in replace_mono t2; (* if we find a function with the exact type of real_ftype, it means this interface has already been taken care of *) if not (type_iseq (get_real_fun gen (apply_params f2.cf_params (List.map snd f.cf_params) t2)) real_ftype) then begin (match f.cf_kind with | Method (MethNormal | MethInline) -> () | _ -> raise Not_found); let t2 = get_real_fun gen t2 in if List.length f.cf_params <> List.length f2.cf_params then raise Not_found; replace_mono t2; match follow (apply_params f2.cf_params (List.map snd f.cf_params) t2), follow real_ftype with | TFun(a1,r1), TFun(a2,r2) when not implement_explicitly && not (type_iseq r1 r2) && Typeload.same_overload_args ~get_vmtype real_ftype t2 f f2 -> (* different return types are the trickiest cases to deal with *) (* check for covariant return type *) let is_covariant = match follow r1, follow r2 with | _, TDynamic _ -> true | r1, r2 -> try unify r1 r2; true with | Unify_error _ -> false in (* we only have to worry about non-covariant issues *) if not is_covariant then begin (* override return type and cast implemented function *) let args, newr = match follow t2, follow (apply_params f.cf_params (List.map snd f2.cf_params) real_ftype) with | TFun(a,_), TFun(_,r) -> a,r | _ -> assert false in f2.cf_type <- TFun(args,newr); (match f2.cf_expr with | Some ({ eexpr = TFunction tf } as e) -> f2.cf_expr <- Some { e with eexpr = TFunction { tf with tf_type = newr } } | _ -> ()) end | TFun(a1,r1), TFun(a2,r2) -> (* just implement a function that will call the main one *) let name, is_explicit = match explicit_fn_name with | Some fn when not (type_iseq r1 r2) && Typeload.same_overload_args ~get_vmtype real_ftype t2 f f2 -> fn iface itl f.cf_name, true | _ -> f.cf_name, false in let p = f2.cf_pos in let newf = mk_class_field name real_ftype true f.cf_pos (Method MethNormal) f.cf_params in let vars = List.map (fun (n,_,t) -> alloc_var n t) a2 in let args = List.map2 (fun v (_,_,t) -> mk_cast t (mk_local v f2.cf_pos)) vars a1 in let field = { eexpr = TField(this, FInstance(c,List.map snd c.cl_params,f2)); etype = TFun(a1,r1); epos = p } in let call = { eexpr = TCall(field, args); etype = r1; epos = p } in (* let call = gen.gparam_func_call call field (List.map snd f.cf_params) args in *) let is_void = is_void r2 in newf.cf_expr <- Some { eexpr = TFunction({ tf_args = List.map (fun v -> v,None) vars; tf_type = r2; tf_expr = (if is_void then call else { eexpr = TReturn (Some (mk_cast r2 call)); etype = r2; epos = p }) }); etype = real_ftype; epos = p; }; (try let fm = PMap.find name c.cl_fields in fm.cf_overloads <- newf :: fm.cf_overloads with | Not_found -> c.cl_fields <- PMap.add name newf c.cl_fields; c.cl_ordered_fields <- newf :: c.cl_ordered_fields) | _ -> assert false end with | Not_found -> () in List.iter (fun f -> match f.cf_kind with | Var _ -> () | _ -> loop_f f) iface.cl_ordered_fields in List.iter (fun (iface,itl) -> loop_iface iface itl) c.cl_implements; (* now go through all overrides, *) let rec check_f f = (* find the first declared field *) let is_overload = Meta.has Meta.Overload f.cf_meta in let decl = if is_overload then find_first_declared_field gen c ~get_vmtype ~exact_field:f f.cf_name else find_first_declared_field gen c ~get_vmtype f.cf_name in match decl with | Some(f2,actual_t,_,t,declared_cl,_,_) when not (Typeload.same_overload_args ~get_vmtype actual_t (get_real_fun gen f.cf_type) f2 f) -> if Meta.has Meta.Overload f.cf_meta then begin (* if it is overload, create another field with the requested type *) let f3 = mk_class_field f.cf_name t f.cf_public f.cf_pos f.cf_kind f.cf_params in let p = f.cf_pos in let old_args, old_ret = get_fun f.cf_type in let args, ret = get_fun t in let tf_args = List.map (fun (n,o,t) -> alloc_var n t, None) args in let f3_mk_return = if is_void ret then (fun e -> e) else (fun e -> mk_return (mk_cast ret e)) in f3.cf_expr <- Some { eexpr = TFunction({ tf_args = tf_args; tf_type = ret; tf_expr = mk_block (f3_mk_return { eexpr = TCall( { eexpr = TField( { eexpr = TConst TThis; etype = TInst(c, List.map snd c.cl_params); epos = p }, FInstance(c,List.map snd c.cl_params,f)); etype = f.cf_type; epos = p }, List.map2 (fun (v,_) (_,_,t) -> mk_cast t (mk_local v p)) tf_args old_args); etype = old_ret; epos = p }) }); etype = t; epos = p; }; gen.gafter_filters_ended <- ((fun () -> f.cf_overloads <- f3 :: f.cf_overloads; ) :: gen.gafter_filters_ended); f3 end else begin match f.cf_expr with | Some({ eexpr = TFunction(tf) } as e) -> (* if it's not overload, just cast the vars *) let actual_args, _ = get_fun (get_real_fun gen actual_t) in let new_args, vardecl = List.fold_left2 (fun (args,vdecl) (v,_) (_,_,t) -> if not (type_iseq (gen.greal_type v.v_type) (gen.greal_type t)) then begin let new_var = mk_temp gen v.v_name t in (new_var,None) :: args, (v, Some(mk_cast v.v_type (mk_local new_var f.cf_pos))) :: vdecl end else (v,None) :: args, vdecl ) ([],[]) tf.tf_args actual_args in if vardecl <> [] then f.cf_expr <- Some({ e with eexpr = TFunction({ tf with tf_args = List.rev new_args; tf_expr = Type.concat { eexpr = TBlock(List.map (fun (v,ve) -> { eexpr = TVar(v,ve); etype = gen.gcon.basic.tvoid; epos = e.epos }) vardecl); etype = gen.gcon.basic.tvoid; epos = e.epos } tf.tf_expr }); }); f | _ -> f end | _ -> f in if not c.cl_extern then c.cl_overrides <- List.map (fun f -> check_f f) c.cl_overrides; md | _ -> md in run let configure ?explicit_fn_name ~get_vmtype gen = let delay () = Hashtbl.clear gen.greal_field_types in gen.gafter_mod_filters_ended <- delay :: gen.gafter_mod_filters_ended; let run = run ~explicit_fn_name ~get_vmtype gen in let map md = Some(run md) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* Normalize *) (* ******************************************* *) (* - Filters out enum constructor type parameters from the AST; See Issue #1796 - Filters out monomorphs - Filters out all non-whitelisted AST metadata dependencies: No dependencies; but it still should be one of the first filters to run, as it will help normalize the AST *) module Normalize = struct let name = "normalize_type" let priority = max_dep let rec filter_param t = match t with | TInst({ cl_kind = KTypeParameter _ } as c,_) when Meta.has Meta.EnumConstructorParam c.cl_meta -> t_dynamic | TMono r -> (match !r with | None -> t_dynamic | Some t -> filter_param t) | TInst(_,[]) | TEnum(_,[]) | TType(_,[]) | TAbstract(_,[]) -> t | TType(t,tl) -> TType(t,List.map filter_param tl) | TInst(c,tl) -> TInst(c,List.map filter_param tl) | TEnum(e,tl) -> TEnum(e,List.map filter_param tl) | TAbstract({ a_path = (["haxe";"extern"],"Rest") } as a,tl) -> TAbstract(a, List.map filter_param tl) | TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) -> filter_param (Abstract.get_underlying_type a tl) | TAbstract(a,tl) -> TAbstract(a, List.map filter_param tl) | TAnon a -> TAnon { a_fields = PMap.map (fun f -> { f with cf_type = filter_param f.cf_type }) a.a_fields; a_status = a.a_status; } | TFun(args,ret) -> TFun(List.map (fun (n,o,t) -> (n,o,filter_param t)) args, filter_param ret) | TDynamic _ -> t | TLazy f -> filter_param (!f()) let default_implementation gen ~metas = let rec run e = match e.eexpr with | TMeta(entry, e) when not (Hashtbl.mem metas entry) -> run e | _ -> map_expr_type (fun e -> run e) filter_param (fun v -> v.v_type <- filter_param v.v_type; v) e in run let default_implementation_module gen ~metas = let rec run md = match md with | TClassDecl cl -> let rec map cf = cf.cf_type <- filter_param cf.cf_type; List.iter map cf.cf_overloads in List.iter map cl.cl_ordered_fields; List.iter map cl.cl_ordered_statics; Option.may map cl.cl_constructor; md | _ -> md in run let configure gen ~metas = let map e = Some(default_implementation gen e ~metas:metas) in gen.gexpr_filters#add ~name:name ~priority:(PCustom priority) map; let map md = Some(default_implementation_module gen ~metas md) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* InterfaceMetas *) (* ******************************************* *) (* Deal with metadata on interfaces by taking it off from interface, and adding a new class with `_HxMeta` suffix dependencies: Must run before InitFunction *) module InterfaceMetas = struct let name = "interface_metas" let priority = solve_deps name [ DBefore InitFunction.priority ] let traverse gen = let run md = match md with | TClassDecl ({ cl_interface = true; cl_ordered_statics = (_ :: _) } as cl) -> cl.cl_ordered_statics <- []; let path = fst cl.cl_path,snd cl.cl_path ^ "_HxMeta" in (match Codegen.build_metadata gen.gcon (TClassDecl cl) with | Some expr -> let ncls = mk_class cl.cl_module path cl.cl_pos in let cf = mk_class_field "__meta__" expr.etype false expr.epos (Var { v_read = AccNormal; v_write = AccNormal }) [] in cf.cf_expr <- Some expr; ncls.cl_statics <- PMap.add "__meta__" cf ncls.cl_statics; ncls.cl_ordered_statics <- cf :: ncls.cl_ordered_statics; gen.gadd_to_module (TClassDecl(ncls)) priority; | _ -> ()) | _ -> () in run let configure gen = let map md = traverse gen md; Some(md) in gen.gmodule_filters#add ~name:name ~priority:(PCustom priority) map end;; (* (* ******************************************* *) (* Example *) (* ******************************************* *) (* description dependencies: *) module Example = struct let name = "example" let priority = solve_deps name [] let default_implementation gen = let rec run e = match e.eexpr with | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; *) haxe_3.2.1+dfsg.orig/gencpp.ml0000664000175000017500000071110712607337712016141 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open Common let unsupported p = error "This expression cannot be generated to Cpp" p (* Generators do not care about non-core-type abstracts, so let us follow them away by default. *) let follow = Abstract.follow_with_abstracts (* Code for generating source files. It manages creating diretories, indents, blocks and only modifying files when the content changes. *) (* A class_path is made from a package (array of strings) and a class name. Join these together, inclding a separator. eg, "/" for includes : pack1/pack2/Name or "::" for namespace "pack1::pack2::Name" *) let join_class_path path separator = let result = match fst path, snd path with | [], s -> s | el, s -> String.concat separator el ^ separator ^ s in if (String.contains result '+') then begin let idx = String.index result '+' in (String.sub result 0 idx) ^ (String.sub result (idx+1) ((String.length result) - idx -1 ) ) end else result;; (* The internal classes are implemented by the core hxcpp system, so the cpp classes should not be generated *) let is_internal_class = function | ([],"Int") | ([],"Void") | ([],"String") | ([], "Null") | ([], "Float") | ([],"Array") | ([], "Class") | ([], "Enum") | ([], "Bool") | ([], "Dynamic") | ([], "ArrayAccess") | (["cpp"], "FastIterator") | (["cpp"],"Pointer") | (["cpp"],"ConstPointer") | (["cpp"],"RawPointer") | (["cpp"],"RawConstPointer") | (["cpp"],"Function") -> true | ([],"Math") | (["haxe";"io"], "Unsigned_char__") -> true | (["cpp"],"Int8") | (["cpp"],"UInt8") | (["cpp"],"Char") | (["cpp"],"Int16") | (["cpp"],"UInt16") | (["cpp"],"Int32") | (["cpp"],"UInt32") | (["cpp"],"Int64") | (["cpp"],"UInt64") | (["cpp"],"Float32") | (["cpp"],"Float64") -> true | _ -> false;; let get_include_prefix common_ctx with_slash = try (Common.defined_value common_ctx Define.IncludePrefix) ^ (if with_slash then "/" else "") with Not_found -> "" ;; let should_prefix_include = function | x when is_internal_class x -> false | ([],"hxMath") -> true | _ -> false;; class source_writer common_ctx write_func close_func = object(this) val indent_str = "\t" val mutable indent = "" val mutable indents = [] val mutable just_finished_block = false method close = close_func(); () method write x = write_func x; just_finished_block <- false method indent_one = this#write indent_str method push_indent = indents <- indent_str::indents; indent <- String.concat "" indents method pop_indent = match indents with | h::tail -> indents <- tail; indent <- String.concat "" indents | [] -> indent <- "/*?*/"; method write_i x = this#write (indent ^ x) method get_indent = indent method begin_block = this#write ("{\n"); this#push_indent method end_block = this#pop_indent; this#write_i "}\n"; just_finished_block <- true method end_block_line = this#pop_indent; this#write_i "}"; just_finished_block <- true method terminate_line = this#write (if just_finished_block then "" else ";\n") method add_include class_path = ( match class_path with | (["@verbatim"],file) -> this#write ("#include \"" ^ file ^ "\"\n"); | _ -> let prefix = if should_prefix_include class_path then "" else get_include_prefix common_ctx true in this#write ("#ifndef INCLUDED_" ^ (join_class_path class_path "_") ^ "\n"); this#write ("#include <" ^ prefix ^ (join_class_path class_path "/") ^ ".h>\n"); this#write ("#endif\n") ) end;; let file_source_writer common_ctx filename = let out_file = open_out filename in new source_writer common_ctx (output_string out_file) (fun ()-> close_out out_file);; let read_whole_file chan = Std.input_all chan;; (* The cached_source_writer will not write to the file if it has not changed, thus allowing the makefile dependencies to work correctly *) let cached_source_writer common_ctx filename = try let in_file = open_in filename in let old_contents = read_whole_file in_file in close_in in_file; let buffer = Buffer.create 0 in let add_buf str = Buffer.add_string buffer str in let close = fun () -> let contents = Buffer.contents buffer in if (not (contents=old_contents) ) then begin let out_file = open_out filename in output_string out_file contents; close_out out_file; end; in new source_writer common_ctx (add_buf) (close); with _ -> file_source_writer common_ctx filename;; let make_class_directories = Common.mkdir_recursive;; let make_base_directory dir = make_class_directories "" ( ( Str.split_delim (Str.regexp "[\\/]+") dir ) );; let new_source_file common_ctx base_dir sub_dir extension class_path = let include_prefix = get_include_prefix common_ctx true in let full_dir = if (sub_dir="include") && (include_prefix<>"") then begin let dir = match fst class_path with | [] -> base_dir ^ "/include/" ^ (get_include_prefix common_ctx false) | path -> base_dir ^ "/include/" ^ include_prefix ^ ( String.concat "/" path ) in make_base_directory dir; dir end else begin make_class_directories base_dir ( sub_dir :: (fst class_path)); base_dir ^ "/" ^ sub_dir ^ "/" ^ ( String.concat "/" (fst class_path) ) end in cached_source_writer common_ctx (full_dir ^ "/" ^ ((snd class_path) ^ extension));; let source_file_extension common_ctx = try "." ^ (Common.defined_value common_ctx Define.FileExtension) with Not_found -> ".cpp" ;; let new_cpp_file common_ctx base_dir = new_source_file common_ctx base_dir "src" (source_file_extension common_ctx);; let new_header_file common_ctx base_dir = new_source_file common_ctx base_dir "include" ".h";; (* CPP code generation context *) type context = { mutable ctx_common : Common.context; mutable ctx_output : string -> unit; mutable ctx_dbgout : string -> unit; mutable ctx_writer : source_writer; mutable ctx_calling : bool; mutable ctx_assigning : bool; mutable ctx_return_from_block : bool; mutable ctx_tcall_expand_args : bool; (* This is for returning from the child nodes of TMatch, TSwitch && TTry *) mutable ctx_return_from_internal_node : bool; mutable ctx_debug_level : int; mutable ctx_real_this_ptr : bool; mutable ctx_real_void : bool; mutable ctx_dynamic_this_ptr : bool; mutable ctx_dump_src_pos : unit -> unit; mutable ctx_static_id_curr : int; mutable ctx_static_id_used : int; mutable ctx_static_id_depth : int; mutable ctx_switch_id : int; mutable ctx_class_name : string; mutable ctx_class_super_name : string; mutable ctx_local_function_args : (string,string) Hashtbl.t; mutable ctx_local_return_block_args : (string,string) Hashtbl.t; mutable ctx_class_member_types : (string,string) Hashtbl.t; mutable ctx_file_info : (string,string) PMap.t ref; mutable ctx_for_extern : bool; } let new_context common_ctx writer debug file_info = { ctx_common = common_ctx; ctx_writer = writer; ctx_output = (writer#write); ctx_dbgout = if debug>1 then (writer#write) else (fun _ -> ()); ctx_calling = false; ctx_assigning = false; ctx_debug_level = debug; ctx_dump_src_pos = (fun() -> ()); ctx_return_from_block = false; ctx_tcall_expand_args = false; ctx_return_from_internal_node = false; ctx_real_this_ptr = true; ctx_real_void = false; ctx_dynamic_this_ptr = false; ctx_static_id_curr = 0; ctx_static_id_used = 0; ctx_static_id_depth = 0; ctx_switch_id = 0; ctx_class_name = ""; ctx_class_super_name = ""; ctx_local_function_args = Hashtbl.create 0; ctx_local_return_block_args = Hashtbl.create 0; ctx_class_member_types = Hashtbl.create 0; ctx_file_info = file_info; ctx_for_extern = false; } let new_extern_context common_ctx writer debug file_info = let ctx = new_context common_ctx writer debug file_info in ctx.ctx_for_extern <- true; ctx ;; (* The internal header files are also defined in the hx/Object.h file, so you do #include them separately. However, Math classes has its own header file (under the hxcpp tree) so these should be included *) let include_class_header = function | ([],"@Main") -> false | ([],"Math") -> true | path -> not ( is_internal_class path ) let is_cpp_class = function | ("cpp"::_ , _) -> true | ( [] , "EReg" ) -> true | ( ["haxe"] , "Log" ) -> true | _ -> false;; let is_scalar typename = match typename with | "int" | "unsigned int" | "signed int" | "char" | "unsigned char" | "short" | "unsigned short" | "float" | "double" | "bool" -> true | _ -> false ;; let is_block exp = match exp.eexpr with | TBlock _ -> true | _ -> false ;; let to_block expression = if is_block expression then expression else (mk_block expression);; (* todo - is this how it's done? *) let hash_keys hash = let key_list = ref [] in Hashtbl.iter (fun key value -> key_list := key :: !key_list ) hash; !key_list;; let pmap_keys pmap = let key_list = ref [] in PMap.iter (fun key _ -> key_list := key :: !key_list ) pmap; !key_list;; let pmap_values pmap = let value_list = ref [] in PMap.iter (fun _ value -> value_list := value :: !value_list ) pmap; !value_list;; (* The Hashtbl structure seems a little odd - but here is a helper function *) let hash_iterate hash visitor = let result = ref [] in Hashtbl.iter (fun key value -> result := (visitor key value) :: !result ) hash; !result (* Convert function names that can't be written in c++ ... *) let keyword_remap name = match name with | "int" | "auto" | "char" | "const" | "delete" | "double" | "Float" | "enum" | "extern" | "float" | "friend" | "goto" | "long" | "operator" | "protected" | "register" | "short" | "signed" | "sizeof" | "template" | "typedef" | "union" | "unsigned" | "void" | "volatile" | "or" | "and" | "xor" | "or_eq" | "not" | "and_eq" | "xor_eq" | "typeof" | "stdin" | "stdout" | "stderr" | "system" | "BIG_ENDIAN" | "LITTLE_ENDIAN" | "assert" | "NULL" | "wchar_t" | "EOF" | "bool" | "const_cast" | "dynamic_cast" | "explicit" | "export" | "mutable" | "namespace" | "reinterpret_cast" | "static_cast" | "typeid" | "typename" | "virtual" | "_Complex" | "INFINITY" | "NAN" | "INT_MIN" | "INT_MAX" | "INT8_MIN" | "INT8_MAX" | "UINT8_MAX" | "INT16_MIN" | "INT16_MAX" | "UINT16_MAX" | "INT32_MIN" | "INT32_MAX" | "UINT32_MAX" | "struct" -> "_" ^ name | "asm" -> "_asm_" | x -> x ;; let remap_class_path class_path = (List.map keyword_remap (fst class_path)) , (snd class_path) ;; let join_class_path_remap path separator = match join_class_path (remap_class_path path) separator with | "Class" -> "hx::Class" | x -> x ;; let get_meta_string meta key = let rec loop = function | [] -> "" | (k,[Ast.EConst (Ast.String name),_],_) :: _ when k=key-> name | _ :: l -> loop l in loop meta ;; let get_meta_string_path meta key = let rec loop = function | [] -> "" | (k,[Ast.EConst (Ast.String name),_], pos) :: _ when k=key-> (try if (String.sub name 0 2) = "./" then begin let base = if (Filename.is_relative pos.pfile) then Filename.concat (Sys.getcwd()) pos.pfile else pos.pfile in Gencommon.normalize (Filename.concat (Filename.dirname base) (String.sub name 2 ((String.length name) -2) )) end else name with Invalid_argument _ -> name) | _ :: l -> loop l in loop meta ;; let get_meta_string_full_filename meta key = let rec loop = function | [] -> "" | (k,_, pos) :: _ when k=key-> if (Filename.is_relative pos.pfile) then Gencommon.normalize (Filename.concat (Sys.getcwd()) pos.pfile) else pos.pfile | _ :: l -> loop l in loop meta ;; let get_meta_string_full_dirname meta key = let name = get_meta_string_full_filename meta key in try Gencommon.normalize (Filename.dirname name) with Invalid_argument _ -> "" ;; let get_field_access_meta field_access key = match field_access with | FInstance(_,_,class_field) | FStatic(_,class_field) -> get_meta_string class_field.cf_meta key | _ -> "" ;; let format_code code = String.concat "\n" (ExtString.String.nsplit code "\r\n") let get_code meta key = let code = get_meta_string meta key in let magic_var = "${GENCPP_SOURCE_DIRECTORY}" in let code = if ExtString.String.exists code magic_var then begin let source_directory = get_meta_string_full_dirname meta key in let _,code = ExtString.String.replace code magic_var source_directory in code end else code in if (code<>"") then format_code code ^ "\n" else code ;; let has_meta_key meta key = List.exists (fun m -> match m with | (k,_,_) when k=key-> true | _ -> false ) meta ;; let type_has_meta_key haxe_type key = match follow haxe_type with | TInst (klass,_) -> has_meta_key klass.cl_meta key | TType (type_def,_) -> has_meta_key type_def.t_meta key | TEnum (enum_def,_) -> has_meta_key enum_def.e_meta key | _ -> false ;; (* let dump_meta meta = List.iter (fun m -> match m with | (k,_,_) -> print_endline ((fst (MetaInfo.to_string k)) ^ "=" ^ (get_meta_string meta k) ) | _ -> () ) meta;; *) let get_class_code class_def key = match class_def.cl_kind with | KAbstractImpl abstract_def -> let value = (get_code abstract_def.a_meta key) in value | _ -> get_code class_def.cl_meta key ;; (* Add include to source code *) let add_include writer class_path = writer#add_include class_path;; (* This gets the class include order correct. In the header files, we forward declare the class types so the header file does not have any undefined variables. In the cpp files, we include all the required header files, providing the actual types for everything. This way there is no problem with circular class references. *) let gen_forward_decl writer class_path = begin let output = writer#write in match class_path with | (["@verbatim"],file) -> writer#write ("#include <" ^ file ^ ">\n"); | _ -> let name = fst (remap_class_path class_path) in output ("HX_DECLARE_CLASS" ^ (string_of_int (List.length name ) ) ^ "("); List.iter (fun package_part -> output (package_part ^ ",") ) name; output ( (snd class_path) ^ ")\n") end;; let real_interfaces = List.filter (function (t,pl) -> match t, pl with | { cl_path = ["cpp";"rtti"],_ },[] -> false | _ -> true );; let rec is_function_expr expr = match expr.eexpr with | TParenthesis expr | TMeta(_,expr) -> is_function_expr expr | TFunction _ -> true | _ -> false;; let is_var_field field = match field.cf_kind with | Var _ -> true | Method MethDynamic -> true | _ -> false ;; let rec has_rtti_interface c interface = List.exists (function (t,pl) -> (snd t.cl_path) = interface && (match fst t.cl_path with | ["cpp";"rtti"] -> true | _ -> false ) ) c.cl_implements || (match c.cl_super with None -> false | Some (c,_) -> has_rtti_interface c interface);; let has_field_integer_lookup class_def = has_rtti_interface class_def "FieldIntegerLookup";; let has_field_integer_numeric_lookup class_def = has_rtti_interface class_def "FieldNumericIntegerLookup";; (* Output required code to place contents in required namespace *) let gen_open_namespace output class_path = List.iter (fun namespace -> output ("namespace " ^ namespace ^ "{\n")) (List.map keyword_remap (fst class_path));; let gen_close_namespace output class_path = List.iter (fun namespace -> output ( "}" ^ " // end namespace " ^ namespace ^"\n")) (fst class_path);; (* The basic types can have default values and are passesby value *) let is_numeric = function | "Int" | "Bool" | "Float" | "::haxe::io::Unsigned_char__" | "unsigned char" -> true | "::cpp::UInt8" | "::cpp::Int8" | "::cpp::Char" | "::cpp::UInt16" | "::cpp::Int16" | "::cpp::UInt32" | "::cpp::Int32" | "::cpp::UInt64" | "::cpp::Int64" | "::cpp::Float32" | "::cpp::Float64" | "int" | "bool" | "double" | "float" -> true | _ -> false let rec remove_parens expression = match expression.eexpr with | TParenthesis e -> remove_parens e | TMeta(_,e) -> remove_parens e | _ -> expression ;; (* let rec remove_parens_cast expression = match expression.eexpr with | TParenthesis e -> remove_parens_cast e | TMeta(_,e) -> remove_parens_cast e | TCast ( e,None) -> remove_parens_cast e | _ -> expression ;; *) let is_interface_type t = match follow t with | TInst (klass,params) -> klass.cl_interface | _ -> false ;; let is_cpp_function_instance haxe_type = match follow haxe_type with | TInst (klass,params) -> (match klass.cl_path with | ["cpp"] , "Function" -> true | _ -> false ) | _ -> false ;; let is_cpp_function_class haxe_type = match follow haxe_type with | TType (klass,params) -> (match klass.t_path with | ["cpp"] , "Function" -> true | _ -> false ) | _ -> false ;; let is_fromStaticFunction_call func = match (remove_parens func).eexpr with | TField (_,FStatic ({cl_path=["cpp"],"Function"},{cf_name="fromStaticFunction"} ) ) -> true | _ -> false ;; let is_addressOf_call func = match (remove_parens func).eexpr with | TField (_,FStatic ({cl_path=["cpp"],"Pointer"},{cf_name="addressOf"} ) ) -> true | _ -> false ;; let is_lvalue var = match (remove_parens var).eexpr with | TLocal _ -> true | TField (_,FStatic(_,field) ) | TField (_,FInstance(_,_,field) ) -> is_var_field field | _ -> false ;; let is_pointer haxe_type includeRaw = match follow haxe_type with | TInst (klass,params) -> (match klass.cl_path with | ["cpp"] , "Pointer" | ["cpp"] , "ConstPointer" | ["cpp"] , "Function" -> true | ["cpp"] , "RawPointer" when includeRaw -> true | ["cpp"] , "RawConstPointer" when includeRaw -> true | _ -> false ) | TType (type_def,params) -> (match type_def.t_path with | ["cpp"] , "Pointer" | ["cpp"] , "ConstPointer" | ["cpp"] , "Function" -> true | ["cpp"] , "RawPointer" when includeRaw -> true | ["cpp"] , "RawConstPointer" when includeRaw -> true | _ -> false ) | _ -> false ;; let is_dynamic_type_param class_kind = match class_kind with | KTypeParameter _ -> true | _ -> false ;; (* Get a string to represent a type. The "suffix" will be nothing or "_obj", depending if we want the name of the pointer class or the pointee (_obj class *) let rec class_string klass suffix params remap = let type_string = type_string_remap remap in let join_class_path_remap = if remap then join_class_path_remap else join_class_path in (match klass.cl_path with (* Array class *) | ([],"Array") when is_dynamic_array_param (List.hd params) -> "cpp::ArrayBase" ^ suffix (* "Dynamic" *) | ([],"Array") -> (snd klass.cl_path) ^ suffix ^ "< " ^ (String.concat "," (List.map array_element_type params) ) ^ " >" (* FastIterator class *) | (["cpp"],"FastIterator") -> "::cpp::FastIterator" ^ suffix ^ "< " ^ (String.concat "," (List.map type_string params) ) ^ " >" | (["cpp"],"Pointer") | (["cpp"],"ConstPointer") -> "::cpp::Pointer< " ^ (String.concat "," (List.map type_string params) ) ^ " >" | (["cpp"],"RawPointer") -> " " ^ (String.concat "," (List.map type_string params) ) ^ " * " | (["cpp"],"RawConstPointer") -> " const " ^ (String.concat "," (List.map type_string params) ) ^ " * " | (["cpp"],"Function") -> "::cpp::Function< " ^ (cpp_function_signature_params params) ^ " >" | _ when is_dynamic_type_param klass.cl_kind -> "Dynamic" | ([],"#Int") -> "/* # */int" | (["haxe";"io"],"Unsigned_char__") -> "unsigned char" | ([],"Class") -> "hx::Class" | ([],"EnumValue") -> "Dynamic" | ([],"Null") -> (match params with | [t] -> (match follow t with | TAbstract ({ a_path = [],"Int" },_) | TAbstract ({ a_path = [],"Float" },_) | TAbstract ({ a_path = [],"Bool" },_) | TInst ({ cl_path = [],"Int" },_) | TInst ({ cl_path = [],"Float" },_) | TEnum ({ e_path = [],"Bool" },_) -> "Dynamic" | t when type_has_meta_key t Meta.NotNull -> "Dynamic" | _ -> "/*NULL*/" ^ (type_string t) ) | _ -> assert false); (* Normal class *) | path when klass.cl_extern && (not (is_internal_class path) )-> (join_class_path_remap klass.cl_path "::") ^ suffix | _ -> "::" ^ (join_class_path_remap klass.cl_path "::") ^ suffix ) and type_string_suff suffix haxe_type remap = let type_string = type_string_remap remap in let join_class_path_remap = if remap then join_class_path_remap else join_class_path in (match haxe_type with | TMono r -> (match !r with None -> "Dynamic" ^ suffix | Some t -> type_string_suff suffix t remap) | TAbstract ({ a_path = ([],"Void") },[]) -> "Void" | TAbstract ({ a_path = ([],"Bool") },[]) -> "bool" | TAbstract ({ a_path = ([],"Float") },[]) -> "Float" | TAbstract ({ a_path = ([],"Int") },[]) -> "int" | TAbstract( { a_path = ([], "EnumValue") }, _ ) -> "Dynamic" | TEnum (enum,params) -> "::" ^ (join_class_path_remap enum.e_path "::") ^ suffix | TInst (klass,params) -> (class_string klass suffix params remap) | TType (type_def,params) -> (match type_def.t_path with | [] , "Null" -> (match params with | [t] -> (match follow t with | TAbstract ({ a_path = [],"Int" },_) | TAbstract ({ a_path = [],"Float" },_) | TAbstract ({ a_path = [],"Bool" },_) | TInst ({ cl_path = [],"Int" },_) | TInst ({ cl_path = [],"Float" },_) | TEnum ({ e_path = [],"Bool" },_) -> "Dynamic" ^ suffix | t when type_has_meta_key t Meta.NotNull -> "Dynamic" ^ suffix | _ -> type_string_suff suffix t remap) | _ -> assert false); | [] , "Array" -> (match params with | [t] when (type_string (follow t) ) = "Dynamic" -> "Dynamic" | [t] -> "Array< " ^ (type_string (follow t) ) ^ " >" | _ -> assert false) | ["cpp"] , "FastIterator" -> (match params with | [t] -> "::cpp::FastIterator< " ^ (type_string (follow t) ) ^ " >" | _ -> assert false) | ["cpp"] , "Pointer" | ["cpp"] , "ConstPointer" -> (match params with | [t] -> "::cpp::Pointer< " ^ (type_string (follow t) ) ^ " >" | _ -> assert false) | ["cpp"] , "RawPointer" -> (match params with | [t] -> " " ^ (type_string (follow t) ) ^ " *" | _ -> assert false) | ["cpp"] , "RawConstPointer" -> (match params with | [t] -> "const " ^ (type_string (follow t) ) ^ " *" | _ -> assert false) | ["cpp"] , "Function" -> "::cpp::Function< " ^ (cpp_function_signature_params params ) ^ " >" | _ -> type_string_suff suffix (apply_params type_def.t_params params type_def.t_type) remap ) | TFun (args,haxe_type) -> "Dynamic" ^ suffix | TAnon a -> "Dynamic" (* (match !(a.a_status) with | Statics c -> type_string_suff suffix (TInst (c,List.map snd c.cl_params)) | EnumStatics e -> type_string_suff suffix (TEnum (e,List.map snd e.e_params)) | _ -> "Dynamic" ^ suffix ) *) | TDynamic haxe_type -> "Dynamic" ^ suffix | TLazy func -> type_string_suff suffix ((!func)()) remap | TAbstract (abs,pl) when abs.a_impl <> None -> type_string_suff suffix (Abstract.get_underlying_type abs pl) remap | TAbstract (abs,pl) -> "::" ^ (join_class_path_remap abs.a_path "::") ^ suffix ) and type_string_remap remap haxe_type = type_string_suff "" haxe_type remap and type_string haxe_type = type_string_suff "" haxe_type true and array_element_type haxe_type = match type_string haxe_type with | x when cant_be_null haxe_type -> x | x when is_interface_type (follow haxe_type) -> x | "::String" -> "::String" | _ -> "::Dynamic" and is_dynamic_array_param haxe_type = if (type_string (follow haxe_type)) = "Dynamic" then true else (match follow haxe_type with | TInst (klass,params) -> (match klass.cl_path with | ([],"Array") | ([],"Class") | (["cpp"],"FastIterator") | (["cpp"],"RawPointer") |(["cpp"],"ConstRawPointer") | (["cpp"],"Pointer") |(["cpp"],"ConstPointer")|(["cpp"],"Function") -> false | _ -> (match klass.cl_kind with KTypeParameter _ -> true | _ -> false) ) | _ -> false ) and cpp_function_signature tfun abi = match follow tfun with | TFun(args,ret) -> (type_string ret) ^ " " ^ abi ^ "( " ^ (gen_tfun_interface_arg_list args) ^ ")" | _ -> "void *" and cpp_function_signature_params params = match params with | [t; abi] -> (match follow abi with | TInst (klass,_) -> cpp_function_signature t (get_meta_string klass.cl_meta Meta.Abi) | _ -> print_endline (type_string abi); assert false ) | _ -> print_endline ("Params:" ^ (String.concat "," (List.map type_string params) )); assert false; and gen_interface_arg_type_name name opt typ = let type_str = (type_string typ) in (* type_str may have already converted Null to Dynamic because of NotNull tag ... *) (if (opt && (cant_be_null typ) && type_str<>"Dynamic" ) then "hx::Null< " ^ type_str ^ " > " else type_str ) ^ " " ^ (keyword_remap name) and gen_tfun_interface_arg_list args = String.concat "," (List.map (fun (name,opt,typ) -> gen_interface_arg_type_name name opt typ) args) and cant_be_null haxe_type = is_numeric (type_string haxe_type) || (type_has_meta_key haxe_type Meta.NotNull ) ;; let is_object type_string = not (is_numeric type_string || type_string="::String"); ;; let is_array haxe_type = match follow haxe_type with | TInst (klass,params) -> (match klass.cl_path with | [] , "Array" -> not (is_dynamic_array_param (List.hd params)) | _ -> false ) | TType (type_def,params) -> (match type_def.t_path with | [] , "Array" -> not (is_dynamic_array_param (List.hd params)) | _ -> false ) | _ -> false ;; let is_array_or_dyn_array haxe_type = match follow haxe_type with | TInst (klass,params) -> (match klass.cl_path with | [] , "Array" -> true | _ -> false ) | TType (type_def,params) -> (match type_def.t_path with | [] , "Array" -> true | _ -> false ) | _ -> false ;; let is_array_implementer haxe_type = match follow haxe_type with | TInst (klass,params) -> (match klass.cl_array_access with | Some _ -> true | _ -> false ) | _ -> false ;; let is_numeric_field field = match field.cf_kind with | Var _ -> is_numeric (type_string field.cf_type) | _ -> false; ;; let is_static_access obj = match (remove_parens obj).eexpr with | TTypeExpr _ -> true | _ -> false ;; let is_native_with_space func = match (remove_parens func).eexpr with | TField(obj,field) when is_static_access obj -> String.contains (get_field_access_meta field Meta.Native) ' ' | _ -> false ;; let rec is_cpp_function_member func = match (remove_parens func).eexpr with | TField(obj,field) when is_cpp_function_instance obj.etype -> true | TCall(obj,_) -> is_cpp_function_member obj | _ -> false ;; (* Get the type and output it to the stream *) let gen_type ctx haxe_type = ctx.ctx_output (type_string haxe_type) ;; let member_type ctx field_object member = let name = (if (is_array field_object.etype) then "::Array" else (type_string field_object.etype)) ^ "." ^ member in try ( Hashtbl.find ctx.ctx_class_member_types name ) with Not_found -> "?";; let is_interface obj = is_interface_type obj.etype;; let should_implement_field x = not (is_extern_field x);; let is_function_member expression = match (follow expression.etype) with | TFun (_,_) -> true | _ -> false;; let is_internal_member member = match member with | "__Field" | "__IField" | "__Run" | "__Is" | "__GetClass" | "__GetType" | "__ToString" | "__s" | "__GetPtr" | "__SetField" | "__length" | "__IsArray" | "__SetThis" | "__Internal" | "__EnumParams" | "__Index" | "__Tag" | "__GetFields" | "toString" | "__HasField" | "__GetRealObject" -> true | _ -> false;; let is_extern_class class_def = class_def.cl_extern || (has_meta_key class_def.cl_meta Meta.Extern) || (match class_def.cl_kind with | KAbstractImpl abstract_def -> (has_meta_key abstract_def.a_meta Meta.Extern) | _ -> false ); ;; let is_native_gen_class class_def = (has_meta_key class_def.cl_meta Meta.NativeGen) || (match class_def.cl_kind with | KAbstractImpl abstract_def -> (has_meta_key abstract_def.a_meta Meta.NativeGen) | _ -> false ); ;; let is_extern_class_instance obj = match follow obj.etype with | TInst (klass,params) -> klass.cl_extern | _ -> false ;; let is_struct_access t = match follow t with | TInst (class_def,_) -> (has_meta_key class_def.cl_meta Meta.StructAccess) | _ -> false ;; let rec is_dynamic_accessor name acc field class_def = ( ( acc ^ "_" ^ field.cf_name) = name ) && ( not (List.exists (fun f -> f.cf_name=name) class_def.cl_ordered_fields) ) && (match class_def.cl_super with None -> true | Some (parent,_) -> is_dynamic_accessor name acc field parent ) ;; let gen_arg_type_name name default_val arg_type prefix = let remap_name = keyword_remap name in let type_str = (type_string arg_type) in match default_val with | Some TNull -> (type_str,remap_name) | Some constant when (cant_be_null arg_type) -> ("hx::Null< " ^ type_str ^ " > ",prefix ^ remap_name) | Some constant -> (type_str,prefix ^ remap_name) | _ -> (type_str,remap_name);; (* Generate prototype text, including allowing default values to be null *) let gen_arg name default_val arg_type prefix = let pair = gen_arg_type_name name default_val arg_type prefix in (fst pair) ^ " " ^ (snd pair);; let rec gen_arg_list arg_list prefix = String.concat "," (List.map (fun (v,o) -> (gen_arg v.v_name o v.v_type prefix) ) arg_list) let rec gen_tfun_arg_list arg_list = match arg_list with | [] -> "" | [(name,o,arg_type)] -> gen_arg name None arg_type "" | (name,o,arg_type) :: remaining -> (gen_arg name None arg_type "") ^ "," ^ (gen_tfun_arg_list remaining) (* Check to see if we are the first object in the parent tree to implement a dynamic interface *) let implement_dynamic_here class_def = let implements_dynamic c = match c.cl_dynamic with None -> false | _ -> true in let rec super_implements_dynamic c = match c.cl_super with | None -> false | Some (csup, _) -> if (implements_dynamic csup) then true else super_implements_dynamic csup; in ( (implements_dynamic class_def) && (not (super_implements_dynamic class_def) ) );; let gen_hash32 seed str = let h = ref (Int32.of_int seed) in let cycle = Int32.of_int 223 in for i = 0 to String.length str - 1 do h := Int32.add (Int32.mul !h cycle) (Int32.of_int (int_of_char (String.unsafe_get str i))); done; !h ;; let gen_hash seed str = Printf.sprintf "0x%08lx" (gen_hash32 seed str) ;; let gen_string_hash str = let h = gen_hash32 0 str in Printf.sprintf "\"\\x%02lx\",\"\\x%02lx\",\"\\x%02lx\",\"\\x%02lx\"" (Int32.shift_right_logical (Int32.shift_left h 24) 24) (Int32.shift_right_logical (Int32.shift_left h 16) 24) (Int32.shift_right_logical (Int32.shift_left h 8) 24) (Int32.shift_right_logical h 24) ;; (* Make string printable for c++ code *) (* Here we know there are no utf8 characters, so use the L"" notation to avoid conversion *) let escape_stringw s l = let b = Buffer.create 0 in Buffer.add_char b 'L'; Buffer.add_char b '"'; let skip = ref 0 in for i = 0 to String.length s - 1 do if (!skip>0) then begin skip := !skip -1; l := !l-1; end else match Char.code (String.unsafe_get s i) with | c when (c>127) -> let encoded = ((c land 0x3F) lsl 6) lor ( Char.code ((String.unsafe_get s (i+1))) land 0x7F) in skip := 1; Buffer.add_string b (Printf.sprintf "\\x%X\"L\"" encoded) | c when (c < 32) -> Buffer.add_string b (Printf.sprintf "\\x%X\"L\"" c) | c -> Buffer.add_char b (Char.chr c) done; Buffer.add_char b '"'; Buffer.contents b;; let special_to_hex s = let l = String.length s in let b = Buffer.create 0 in for i = 0 to l - 1 do match Char.code (String.unsafe_get s i) with | c when (c>127) || (c<32) -> Buffer.add_string b (Printf.sprintf "\\x%02x\"\"" c) | c -> Buffer.add_char b (Char.chr c) done; Buffer.contents b;; let escape_extern s = let l = String.length s in let b = Buffer.create 0 in for i = 0 to l - 1 do match Char.code (String.unsafe_get s i) with | c when (c>127) || (c<32) || (c=34) || (c=92) -> Buffer.add_string b (Printf.sprintf "\\x%02x" c) | c -> Buffer.add_char b (Char.chr c) done; Buffer.contents b;; let has_utf8_chars s = let result = ref false in for i = 0 to String.length s - 1 do result := !result || ( Char.code (String.unsafe_get s i) > 127 ) done; !result;; let escape_command s = let b = Buffer.create 0 in String.iter (fun ch -> if (ch=='"' || ch=='\\' ) then Buffer.add_string b "\\"; Buffer.add_char b ch ) s; Buffer.contents b;; let str s = let rec split s plus = let escaped = Ast.s_escape ~hex:false s in let hexed = (special_to_hex escaped) in if (String.length hexed <= 16000 ) then plus ^ " HX_CSTRING(\"" ^ hexed ^ "\")" else begin let len = String.length s in let half = len lsr 1 in (split (String.sub s 0 half) plus ) ^ (split (String.sub s half (len-half)) "+" ) end in let escaped = Ast.s_escape ~hex:false s in let hexed = (special_to_hex escaped) in if (String.length hexed <= 16000 ) then "HX_HCSTRING(\"" ^ hexed ^ "\"," ^ (gen_string_hash s) ^ ")" else "(" ^ (split s "" ) ^ ")" ;; let const_char_star s = let escaped = Ast.s_escape ~hex:false s in "\"" ^ special_to_hex escaped ^ "\""; ;; (* When we are in a "real" object, we refer to ourselves as "this", but if we are in a local class that is used to generate return values, we use the fake "__this" pointer. If we are in an "Anon" object, then the "this" refers to the anon object (eg List iterator) *) let clear_real_this_ptr ctx dynamic_this = let old_flag = ctx.ctx_real_this_ptr in let old_dynamic = ctx.ctx_dynamic_this_ptr in let old_void = ctx.ctx_real_void in ctx.ctx_real_this_ptr <- false; ctx.ctx_dynamic_this_ptr <- dynamic_this; fun () -> ( ctx.ctx_real_this_ptr <- old_flag; ctx.ctx_dynamic_this_ptr <- old_dynamic; ctx.ctx_real_void <- old_void; ) ;; (* Generate temp variable names *) let next_anon_function_name ctx = ctx.ctx_static_id_curr <- ctx.ctx_static_id_curr + 1; "_Function_" ^ (string_of_int ctx.ctx_static_id_depth) ^"_"^ (string_of_int ctx.ctx_static_id_curr);; let use_anon_function_name ctx = ctx.ctx_static_id_used <- ctx.ctx_static_id_used + 1; "_Function_" ^ (string_of_int ctx.ctx_static_id_depth) ^"_"^ (string_of_int ctx.ctx_static_id_used);; let push_anon_names ctx = let old_used = ctx.ctx_static_id_used in let old_curr = ctx.ctx_static_id_curr in let old_depth = ctx.ctx_static_id_depth in ctx.ctx_static_id_used <- 0; ctx.ctx_static_id_curr <- 0; ctx.ctx_static_id_depth <- ctx.ctx_static_id_depth + 1; ( function () -> ( ctx.ctx_static_id_used <- old_used; ctx.ctx_static_id_curr <- old_curr; ctx.ctx_static_id_depth <- old_depth; ) ) ;; let get_switch_var ctx = ctx.ctx_switch_id <- ctx.ctx_switch_id + 1; "_switch_" ^ (string_of_int ctx.ctx_switch_id) (* If you put on the "-debug" flag, you get extra comments in the source code *) let debug_expression expression type_too = "/* " ^ Type.s_expr_kind expression ^ (if (type_too) then " = " ^ (type_string expression.etype) else "") ^ " */";; (* This is like the Type.iter, but also keeps the "retval" flag up to date *) let rec iter_retval f retval e = match e.eexpr with | TConst _ | TLocal _ | TBreak | TContinue | TTypeExpr _ -> () | TArray (e1,e2) | TBinop (_,e1,e2) -> f true e1; f true e2; | TWhile (e1,e2,_) -> f true e1; f false e2; | TFor (_,e1,e2) -> f true e1; f false e2; | TThrow e | TField (e,_) | TEnumParameter (e,_,_) | TUnop (_,_,e) -> f true e | TParenthesis e | TMeta(_,e) -> f retval e | TBlock expr_list when retval -> let rec return_last = function | [] -> () | expr :: [] -> f true expr | expr :: exprs -> f false expr; return_last exprs in return_last expr_list | TArrayDecl el | TNew (_,_,el) -> List.iter (f true ) el | TBlock el -> List.iter (f false ) el | TObjectDecl fl -> List.iter (fun (_,e) -> f true e) fl | TCall (e,el) -> f true e; List.iter (f true) el | TVar (_,eo) -> (match eo with None -> () | Some e -> f true e) | TFunction fu -> f false fu.tf_expr | TIf (e,e1,e2) -> f true e; f retval e1; (match e2 with None -> () | Some e -> f retval e) | TSwitch (e,cases,def) -> f true e; List.iter (fun (el,e2) -> List.iter (f true) el; f retval e2) cases; (match def with None -> () | Some e -> f retval e) (* | TMatch (e,_,cases,def) -> f true e; List.iter (fun (_,_,e) -> f false e) cases; (match def with None -> () | Some e -> f false e) *) | TTry (e,catches) -> f retval e; List.iter (fun (_,e) -> f false e) catches | TReturn eo -> (match eo with None -> () | Some e -> f true e) | TCast (e,None) -> f retval e | TCast (e,_) -> f true e ;; (* Convert an array to a comma separated list of values *) let array_arg_list inList = let i = ref (0-1) in String.concat "," (List.map (fun _ -> incr i; "inArgs[" ^ (string_of_int !i) ^ "]" ) inList) let list_num l = string_of_int (List.length l);; let only_int_cases cases = match cases with | [] -> false | _ -> not (List.exists (fun (cases,expression) -> List.exists (fun case -> match case.eexpr with TConst (TInt _) -> false | _ -> true ) cases ) cases );; (* See if there is a haxe break statement that will be swollowed by c++ break *) exception BreakFound;; let contains_break expression = try ( let rec check_all expression = Type.iter (fun expr -> match expr.eexpr with | TBreak -> raise BreakFound | TFor _ | TFunction _ | TWhile (_,_,_) -> () | _ -> check_all expr; ) expression in check_all expression; false; ) with BreakFound -> true;; (* Decide is we should look the field up by name *) let dynamic_internal = function | "__Is" -> true | _ -> false let rec is_null expr = match expr.eexpr with | TConst TNull -> true | TParenthesis expr | TMeta (_,expr) -> is_null expr | TCast (e,None) -> is_null e | _ -> false ;; let find_undeclared_variables_ctx ctx undeclared declarations this_suffix allow_this expression = let output = ctx.ctx_output in let rec find_undeclared_variables undeclared declarations this_suffix allow_this expression = match expression.eexpr with | TVar (tvar,optional_init) -> Hashtbl.add declarations (keyword_remap tvar.v_name) (); if (ctx.ctx_debug_level>1) then output ("/* found var " ^ tvar.v_name ^ "*/ "); (match optional_init with | Some expression -> find_undeclared_variables undeclared declarations this_suffix allow_this expression | _ -> ()) | TFunction func -> List.iter ( fun (tvar, opt_val) -> if (ctx.ctx_debug_level>1) then output ("/* found arg " ^ tvar.v_name ^ " = " ^ (type_string tvar.v_type) ^ " */ "); Hashtbl.add declarations (keyword_remap tvar.v_name) () ) func.tf_args; find_undeclared_variables undeclared declarations this_suffix false func.tf_expr | TTry (try_block,catches) -> find_undeclared_variables undeclared declarations this_suffix allow_this try_block; List.iter (fun (tvar,catch_expt) -> let old_decs = Hashtbl.copy declarations in Hashtbl.add declarations (keyword_remap tvar.v_name) (); find_undeclared_variables undeclared declarations this_suffix allow_this catch_expt; Hashtbl.clear declarations; Hashtbl.iter ( Hashtbl.add declarations ) old_decs ) catches; | TLocal tvar -> let name = keyword_remap tvar.v_name in if not (Hashtbl.mem declarations name) then Hashtbl.replace undeclared name (type_string expression.etype) (* | TMatch (condition, enum, cases, default) -> find_undeclared_variables undeclared declarations this_suffix allow_this condition; List.iter (fun (case_ids,params,expression) -> let old_decs = Hashtbl.copy declarations in (match params with | None -> () | Some l -> List.iter (fun (opt_var) -> match opt_var with | Some v -> Hashtbl.add declarations (keyword_remap v.v_name) () | _ -> () ) l ); find_undeclared_variables undeclared declarations this_suffix allow_this expression; Hashtbl.clear declarations; Hashtbl.iter ( Hashtbl.add declarations ) old_decs ) cases; (match default with | None -> () | Some expr -> find_undeclared_variables undeclared declarations this_suffix allow_this expr; ); *) | TFor (tvar, init, loop) -> let old_decs = Hashtbl.copy declarations in Hashtbl.add declarations (keyword_remap tvar.v_name) (); find_undeclared_variables undeclared declarations this_suffix allow_this init; find_undeclared_variables undeclared declarations this_suffix allow_this loop; Hashtbl.clear declarations; Hashtbl.iter ( Hashtbl.add declarations ) old_decs | TConst TSuper | TConst TThis -> if ((not (Hashtbl.mem declarations "this")) && allow_this) then Hashtbl.replace undeclared "this" (type_string_suff this_suffix expression.etype true) | TBlock expr_list -> let old_decs = Hashtbl.copy declarations in List.iter (find_undeclared_variables undeclared declarations this_suffix allow_this ) expr_list; (* what is the best way for this ? *) Hashtbl.clear declarations; Hashtbl.iter ( Hashtbl.add declarations ) old_decs | _ -> Type.iter (find_undeclared_variables undeclared declarations this_suffix allow_this) expression in find_undeclared_variables undeclared declarations this_suffix allow_this expression ;; let rec is_dynamic_in_cpp ctx expr = let expr_type = type_string ( match follow expr.etype with TFun (args,ret) -> ret | _ -> expr.etype) in ctx.ctx_dbgout ( "/* idic: " ^ expr_type ^ " */" ); if ( expr_type="Dynamic" || expr_type="cpp::ArrayBase") then true else begin let result = ( match expr.eexpr with | TEnumParameter( obj, _, index ) -> true (* TODO? *) | TField( obj, field ) -> let name = field_name field in ctx.ctx_dbgout ("/* ?tfield "^name^" */"); if (is_dynamic_member_lookup_in_cpp ctx obj field) then ( ctx.ctx_dbgout "/* tf=dynobj */"; true ) else if (is_dynamic_member_return_in_cpp ctx obj field) then ( ctx.ctx_dbgout "/* tf=dynret */"; true ) else ( ctx.ctx_dbgout "/* tf=notdyn */"; false ) | TConst TThis when ((not ctx.ctx_real_this_ptr) && ctx.ctx_dynamic_this_ptr) -> ctx.ctx_dbgout ("/* dthis */"); true | TArray (obj,index) -> let dyn = is_dynamic_in_cpp ctx obj in ctx.ctx_dbgout ("/* aidr:" ^ (if dyn then "Dyn" else "Not") ^ " */"); dyn; | TTypeExpr _ -> false | TCall(func,args) -> (match follow func.etype with | TFun (args,ret) -> ctx.ctx_dbgout ("/* ret = "^ (type_string ret) ^" */"); is_dynamic_in_cpp ctx func | _ -> ctx.ctx_dbgout "/* not TFun */"; true ); | TParenthesis(expr) | TMeta(_,expr) -> is_dynamic_in_cpp ctx expr | TCast (e,None) -> (type_string expr.etype) = "Dynamic" | TLocal { v_name = "__global__" } -> false | TConst TNull -> true | _ -> ctx.ctx_dbgout "/* other */"; false (* others ? *) ) in ctx.ctx_dbgout (if result then "/* Y */" else "/* N */" ); result end and is_dynamic_member_lookup_in_cpp ctx field_object field = let member = field_name field in ctx.ctx_dbgout ("/*mem."^member^".*/"); if (is_internal_member member) then false else if (is_pointer field_object.etype true) then false else if (match field_object.eexpr with | TTypeExpr _ -> ctx.ctx_dbgout "/*!TTypeExpr*/"; true | _ -> false) then false else if (is_dynamic_in_cpp ctx field_object) then true else if (is_array field_object.etype) then false else ( let tstr = type_string field_object.etype in ctx.ctx_dbgout ("/* ts:"^tstr^"*/"); match tstr with (* Internal classes have no dynamic members *) | "::String" | "Null" | "::hx::Class" | "::Enum" | "::Math" | "::ArrayAccess" -> ctx.ctx_dbgout ("/* ok:" ^ (type_string field_object.etype) ^ " */"); false | "Dynamic" -> true | name -> let full_name = name ^ "." ^ member in ctx.ctx_dbgout ("/* t:" ^ full_name ^ " */"); try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in ctx.ctx_dbgout ("/* =" ^ mem_type ^ "*/"); false ) with Not_found -> not (is_extern_class_instance field_object) ) and is_dynamic_member_return_in_cpp ctx field_object field = let member = field_name field in if (is_array field_object.etype) then false else if (is_pointer field_object.etype true) then false else if (is_internal_member member) then false else match field_object.eexpr with | TTypeExpr t -> let full_name = "::" ^ (join_class_path (t_path t) "::" ) ^ "." ^ member in ctx.ctx_dbgout ("/*static:"^ full_name^"*/"); ( try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in mem_type="Dynamic"||mem_type="cpp::ArrayBase" ) with Not_found -> true ) | _ -> let tstr = type_string field_object.etype in (match tstr with (* Internal classes have no dynamic members *) | "::String" | "Null" | "::hx::Class" | "::Enum" | "::Math" | "::ArrayAccess" -> false | "Dynamic" | "cpp::ArrayBase" -> ctx.ctx_dbgout "/*D*/"; true | name -> let full_name = name ^ "." ^ member in ctx.ctx_dbgout ("/*R:"^full_name^"*/"); try ( let mem_type = (Hashtbl.find ctx.ctx_class_member_types full_name) in mem_type="Dynamic"||mem_type="cpp::ArrayBase" ) with Not_found -> true ) ;; let cast_if_required ctx expr to_type = let expr_type = (type_string expr.etype) in ctx.ctx_dbgout ( "/* cir: " ^ expr_type ^ " */" ); if (is_dynamic_in_cpp ctx expr) then ctx.ctx_output (".Cast< " ^ to_type ^ " >()" ) ;; let is_matching_interface_type t0 t1 = (match (follow t0),(follow t1) with | TInst (k0,_), TInst(k1,_) -> k0==k1 | _ -> false ) ;; let default_value_string = function | TInt i -> Printf.sprintf "%ld" i | TFloat float_as_string -> "((Float)" ^ float_as_string ^ ")" | TString s -> str s | TBool b -> (if b then "true" else "false") | TNull -> "null()" | _ -> "/* Hmmm */" ;; let generate_default_values ctx args prefix = List.iter ( fun (v,o) -> let type_str = type_string v.v_type in let name = (keyword_remap v.v_name) in match o with | Some TNull -> () | Some const -> ctx.ctx_output (type_str ^ " " ^ name ^ " = " ^ prefix ^ name ^ ".Default(" ^ (default_value_string const) ^ ");\n") | _ -> () ) args;; let return_type_string t = match t with | TFun (_,ret) -> type_string ret | _ -> "" ;; let get_return_type field = match follow field.cf_type with | TFun (_,return_type) -> return_type | _ -> raise Not_found ;; let has_default_values args = List.exists ( fun (_,o) -> match o with | Some TNull -> false | Some _ -> true | _ -> false ) args ;; exception PathFound of string;; let strip_file ctx file = (match Common.defined ctx Common.Define.AbsolutePath with | true -> file | false -> let flen = String.length file in (* Not quite right - should probably test is file exists *) try List.iter (fun path -> let plen = String.length path in if (flen>plen && path=(String.sub file 0 plen )) then raise (PathFound (String.sub file plen (flen-plen)) ) ) (ctx.class_path @ ctx.std_path); file; with PathFound tail -> tail) ;; let hx_stack_push ctx output clazz func_name pos = if ctx.ctx_debug_level > 0 then begin let stripped_file = strip_file ctx.ctx_common pos.pfile in let qfile = "\"" ^ (Ast.s_escape stripped_file) ^ "\"" in ctx.ctx_file_info := PMap.add stripped_file pos.pfile !(ctx.ctx_file_info); if (ctx.ctx_debug_level>0) then begin let hash_class_func = gen_hash 0 (clazz^"."^func_name) in let hash_file = gen_hash 0 stripped_file in output ("HX_STACK_FRAME(\"" ^ clazz ^ "\",\"" ^ func_name ^ "\"," ^ hash_class_func ^ ",\"" ^ clazz ^ "." ^ func_name ^ "\"," ^ qfile ^ "," ^ (string_of_int (Lexer.get_error_line pos) ) ^ "," ^ hash_file ^ ")\n") end end ;; (* This is the big one. Once you get inside a function, all code is generated (recursively) as a "expression". "retval" is tracked to determine whether the value on an expression is actually used. eg, if the result of a block (ie, the last expression in the list) is used, then we have to do some funky stuff to generate a local function. Some things that change less often are stored in the context and are extracted at the top for simplicity. *) let gen_expression_tree ctx retval expression_tree set_var tail_code = let writer = ctx.ctx_writer in let output_i = writer#write_i in let output = ctx.ctx_output in let rec define_local_function_ctx func_name func_def = let remap_this = function | "this" -> "__this" | other -> other in let rec define_local_function func_name func_def = let declarations = Hashtbl.create 0 in let undeclared = Hashtbl.create 0 in (* '__global__', '__cpp__' are always defined *) Hashtbl.add declarations "__global__" (); Hashtbl.add declarations "__cpp__" (); Hashtbl.add declarations "__trace" (); (* Add args as defined variables *) List.iter ( fun (arg_var, opt_val) -> if (ctx.ctx_debug_level>1) then output ("/* found arg " ^ arg_var.v_name ^ " = " ^ (type_string arg_var.v_type) ^" */ "); Hashtbl.add declarations (keyword_remap arg_var.v_name) () ) func_def.tf_args; find_undeclared_variables_ctx ctx undeclared declarations "" true func_def.tf_expr; let has_this = Hashtbl.mem undeclared "this" in if (has_this) then Hashtbl.remove undeclared "this"; let typed_vars = hash_iterate undeclared (fun key value -> value ^ "," ^ (keyword_remap key) ) in let func_name_sep = func_name ^ (if List.length typed_vars > 0 then "," else "") in output_i ("HX_BEGIN_LOCAL_FUNC_S" ^ (list_num typed_vars) ^ "(" ^ (if has_this then "hx::LocalThisFunc," else "hx::LocalFunc,") ^ func_name_sep ^ (String.concat "," typed_vars) ^ ")\n" ); output_i ("int __ArgCount() const { return " ^ (string_of_int (List.length func_def.tf_args)) ^"; }\n"); (* actual function, called "run" *) let args_and_types = List.map (fun (v,_) -> (type_string v.v_type) ^ " " ^ (keyword_remap v.v_name) ) func_def.tf_args in let block = is_block func_def.tf_expr in let func_type = type_string func_def.tf_type in output_i (func_type ^ " run(" ^ (gen_arg_list func_def.tf_args "__o_") ^ ")"); let close_defaults = if (has_default_values func_def.tf_args) then begin writer#begin_block; output_i ""; generate_default_values ctx func_def.tf_args "__o_"; output_i ""; true; end else false in let pop_real_this_ptr = clear_real_this_ptr ctx true in writer#begin_block; if (ctx.ctx_debug_level>0) then begin hx_stack_push ctx output_i "*" func_name func_def.tf_expr.epos; if (has_this && ctx.ctx_debug_level>0) then output_i ("HX_STACK_THIS(__this.mPtr)\n"); List.iter (fun (v,_) -> output_i ("HX_STACK_ARG(" ^ (keyword_remap v.v_name) ^ ",\"" ^ v.v_name ^"\")\n") ) func_def.tf_args; end; if (block) then begin output_i ""; gen_expression false func_def.tf_expr; output_i "return null();\n"; end else begin (* Save old values, and equalize for new input ... *) let pop_names = push_anon_names ctx in find_local_functions_and_return_blocks_ctx false func_def.tf_expr; (match func_def.tf_expr.eexpr with | TReturn (Some return_expression) when (func_type<>"Void") -> output_i "return "; gen_expression true return_expression; | TReturn (Some return_expression) -> output_i ""; gen_expression false return_expression; | _ -> output_i ""; gen_expression false (to_block func_def.tf_expr); ); output ";\n"; output_i "return null();\n"; pop_names(); end; writer#end_block; if close_defaults then writer#end_block; pop_real_this_ptr(); let return = if (type_string func_def.tf_type ) = "Void" then "(void)" else "return" in output_i ("HX_END_LOCAL_FUNC" ^ (list_num args_and_types) ^ "(" ^ return ^ ")\n\n"); Hashtbl.replace ctx.ctx_local_function_args func_name (if (ctx.ctx_real_this_ptr) then String.concat "," (hash_keys undeclared) else String.concat "," (List.map remap_this (hash_keys undeclared)) ) in define_local_function func_name func_def and find_local_functions_and_return_blocks_ctx retval expression = let rec find_local_functions_and_return_blocks retval expression = match expression.eexpr with | TBlock _ -> if (retval) then begin define_local_return_block_ctx expression (next_anon_function_name ctx) true; end (* else we are done *) | TTry (_, _) | TSwitch (_, _, _) when retval -> define_local_return_block_ctx expression (next_anon_function_name ctx) true; | TObjectDecl ( ("fileName" , { eexpr = (TConst (TString file)) }) :: ("lineNumber" , { eexpr = (TConst (TInt line)) }) :: ("className" , { eexpr = (TConst (TString class_name)) }) :: ("methodName", { eexpr = (TConst (TString meth)) }) :: [] ) -> () | TObjectDecl decl_list -> let name = next_anon_function_name ctx in define_local_return_block_ctx expression name true; | TFunction func -> let func_name = next_anon_function_name ctx in output "\n"; define_local_function_ctx func_name func | TField (obj,_) | TEnumParameter (obj,_,_) when (is_null obj) -> ( ) | TArray (obj,_) when (is_null obj) -> ( ) | TIf ( _ , _ , _ ) when retval -> (* ? operator style *) iter_retval find_local_functions_and_return_blocks retval expression | TSwitch (_, _, _) when retval -> ( ) (* | TMatch ( cond , _, _, _) *) | TWhile ( cond , _, _ ) | TIf ( cond , _, _ ) | TSwitch ( cond , _, _) -> iter_retval find_local_functions_and_return_blocks true cond | _ -> iter_retval find_local_functions_and_return_blocks retval expression in find_local_functions_and_return_blocks retval expression and define_local_return_block_ctx expression name retval = let check_this = function | "this" when not ctx.ctx_real_this_ptr -> "__this" | x -> x in let rec define_local_return_block expression = let declarations = Hashtbl.create 0 in let undeclared = Hashtbl.create 0 in (* '__global__' is always defined *) Hashtbl.add declarations "__global__" (); Hashtbl.add declarations "__cpp__" (); Hashtbl.add declarations "__trace" (); find_undeclared_variables_ctx ctx undeclared declarations "_obj" true expression; let vars = (hash_keys undeclared) in let args = String.concat "," (List.map check_this (hash_keys undeclared)) in Hashtbl.replace ctx.ctx_local_return_block_args name args; output_i ("struct " ^ name); writer#begin_block; let ret_type = if (not retval) then "Void" else match expression.eexpr with | TObjectDecl _ -> "Dynamic" | _ -> type_string expression.etype in (* TODO - analyse usage *) let pass_by_value name = (String.length name >=5 ) && (String.sub name 0 5 = "_this") in output_i ("inline static " ^ ret_type ^ " Block( "); output (String.concat "," ( (List.map (fun var -> let var_type = Hashtbl.find undeclared var in (* Args passed into inline-block should be references, so they can be changed. Fake 'this' pointers can't be changed, so needn't be references *) match var with | "this" -> "hx::ObjectPtr< " ^ var_type ^ " > __this" | name when (pass_by_value name) -> var_type ^ " " ^ name | name -> var_type ^ " &" ^name ) vars) ) ); output (")"); let return_data = ret_type <> "Void" in writer#begin_block; hx_stack_push ctx output_i "*" "closure" expression.epos; output_i ""; let pop_real_this_ptr = clear_real_this_ptr ctx false in (match expression.eexpr with | TObjectDecl decl_list -> writer#begin_block; output_i "hx::Anon __result = hx::Anon_obj::Create();\n"; let pop_names = push_anon_names ctx in List.iter (function (name,value) -> find_local_functions_and_return_blocks_ctx true value; output_i ( "__result->Add(" ^ (str name) ^ " , "); gen_expression true value; output (if is_function_expr value then ",true" else ",false" ); output (");\n"); ) decl_list; pop_names(); output_i "return __result;\n"; writer#end_block; | TBlock _ -> ctx.ctx_return_from_block <- return_data; ctx.ctx_return_from_internal_node <- false; gen_expression false expression; | TCall(func,args) -> writer#begin_block; let pop_names = push_anon_names ctx in find_local_functions_and_return_blocks_ctx true func; List.iter (find_local_functions_and_return_blocks_ctx true) args; ctx.ctx_tcall_expand_args <- true; gen_expression return_data expression; output ";\n"; pop_names(); writer#end_block; | _ -> ctx.ctx_return_from_block <- false; ctx.ctx_return_from_internal_node <- return_data; gen_expression false (to_block expression); ); output_i "return null();\n"; writer#end_block; pop_real_this_ptr(); writer#end_block_line; output ";\n"; in define_local_return_block expression and gen_expression retval expression = let calling = ctx.ctx_calling in ctx.ctx_calling <- false; let assigning = ctx.ctx_assigning in ctx.ctx_assigning <- false; let return_from_block = ctx.ctx_return_from_block in ctx.ctx_return_from_block <- false; let tcall_expand_args = ctx.ctx_tcall_expand_args in ctx.ctx_tcall_expand_args <- false; let return_from_internal_node = ctx.ctx_return_from_internal_node in ctx.ctx_return_from_internal_node <- false; let dump_src_pos = ctx.ctx_dump_src_pos in ctx.ctx_dump_src_pos <- (fun() -> ()); (* Annotate source code with debug - can get a bit verbose. Mainly for debugging code gen, rather than the run time *) if (ctx.ctx_debug_level>1) then begin (*if calling then output "/* Call */";*) (*if ctx.ctx_real_this_ptr then output "/* this */" else output "/* FAKE __this */";*) output (debug_expression expression (ctx.ctx_debug_level>1) ); end; (* Write comma separated list of variables - useful for function args. *) let rec gen_expression_list expressions = (match expressions with | [] -> () | [single] -> gen_expression true single | first :: remaining -> gen_expression true first; output ","; gen_expression_list remaining ) in let rec gen_bin_op_string expr1 op expr2 = let cast = (match op with | ">>" | "<<" | "&" | "|" | "^" -> "int(" | "&&" | "||" -> "bool(" | "/" -> "Float(" | _ -> "") in if (op <> "=") then output "("; if ( cast <> "") then output cast; gen_expression true expr1; if ( cast <> "") then output ")"; output (" " ^ op ^ " "); if ( cast <> "") then output cast; gen_expression true expr2; if ( cast <> "") then output ")"; if (op <> "=") then output ")"; in let rec is_const_string_term expr = match expr.eexpr with | TConst( TString _ ) -> true | TBinop (OpAdd,e1,e2) -> (is_const_string_term e1) && (is_const_string_term e2 ) | _ -> false in let rec combine_string_terms expr = match expr.eexpr with | TConst( TString s ) -> s | TBinop (OpAdd,e1,e2) -> (combine_string_terms e1) ^ (combine_string_terms e2 ) | _ -> "" in let rec gen_bin_op op expr1 expr2 = match op with | Ast.OpAdd when (is_const_string_term expr1) && (is_const_string_term expr2) -> output (str ((combine_string_terms expr1) ^ (combine_string_terms expr2)) ) | Ast.OpAssign -> ctx.ctx_assigning <- true; gen_bin_op_string expr1 "=" expr2 | Ast.OpUShr -> output "hx::UShr("; gen_expression true expr1; output ","; gen_expression true expr2; output ")"; | Ast.OpMod -> output "hx::Mod("; gen_expression true expr1; output ","; gen_expression true expr2; output ")"; | Ast.OpAssignOp bin_op -> output (match bin_op with | Ast.OpAdd -> "hx::AddEq(" | Ast.OpMult -> "hx::MultEq(" | Ast.OpDiv -> "hx::DivEq(" | Ast.OpSub -> "hx::SubEq(" | Ast.OpAnd -> "hx::AndEq(" | Ast.OpOr -> "hx::OrEq(" | Ast.OpXor -> "hx::XorEq(" | Ast.OpShl -> "hx::ShlEq(" | Ast.OpShr -> "hx::ShrEq(" | Ast.OpUShr -> "hx::UShrEq(" | Ast.OpMod -> "hx::ModEq(" | _ -> error "Unknown OpAssignOp" expression.epos ); ctx.ctx_assigning <- true; gen_expression true expr1; output ","; gen_expression true expr2; output ")" | Ast.OpNotEq -> gen_bin_op_string expr1 "!=" expr2 | Ast.OpEq -> gen_bin_op_string expr1 "==" expr2 | _ -> gen_bin_op_string expr1 (Ast.s_binop op) expr2 in let gen_array_cast cast_name real_type call = output (cast_name ^ "< " ^ real_type ^ " >" ^ call) in let rec check_array_element_cast array_type cast_name call = match follow array_type with | TInst (klass,[element]) -> ( match type_string element with | _ when is_struct_access element -> () | x when cant_be_null element -> () | _ when is_interface_type element -> () | "::String" | "Dynamic" -> () | real_type -> gen_array_cast cast_name real_type call ) | TAbstract (abs,pl) when abs.a_impl <> None -> check_array_element_cast (Abstract.get_underlying_type abs pl) cast_name call | _ -> () in let rec check_array_cast array_type = match follow array_type with | x when is_interface_type x -> () | TInst (klass,[element]) -> let name = type_string element in if ( is_object name && not (is_interface_type element) ) then gen_array_cast ".StaticCast" "Array" "()" else gen_array_cast ".StaticCast" (type_string array_type) "()" | TAbstract (abs,pl) when abs.a_impl <> None -> check_array_cast (Abstract.get_underlying_type abs pl) | _ -> () in let rec gen_tfield field_object field = let member = (field_name field) in let remap_name = keyword_remap member in let already_dynamic = ref false in (match field_object.eexpr with (* static access ... *) | TTypeExpr type_def -> (match get_field_access_meta field Meta.Native with | "" -> let class_name = "::" ^ (join_class_path_remap (t_path type_def) "::" ) in if (class_name="::String") then output ("::String::" ^ remap_name) else output (class_name ^ "_obj::" ^ remap_name); | native -> output native ) (* Special internal access *) | TLocal { v_name = "__global__" } -> output ("::" ^ member ) | TConst TSuper -> output (if ctx.ctx_real_this_ptr then "this" else "__this"); output ("->super::" ^ remap_name) | TConst TThis when ctx.ctx_real_this_ptr -> output ( "this->" ^ remap_name ) | TConst TNull -> output "null()" | _ -> gen_expression true field_object; ctx.ctx_dbgout "/* TField */"; (* toString is the only internal member that can be set... *) let settingInternal = assigning && member="toString" in let isString = (type_string field_object.etype)="::String" in if (is_struct_access field_object.etype) then output ( "." ^ member ) else if (is_internal_member member && not settingInternal) then begin output ( (if isString then "." else "->") ^ member ); end else if (settingInternal || is_dynamic_member_lookup_in_cpp ctx field_object field) then begin if assigning then output ( "->__FieldRef(" ^ (str member) ^ ")" ) else output ( "->__Field(" ^ (str member) ^ ", hx::paccDynamic )" ); already_dynamic := true; end else begin if (isString) then output ( "." ^ remap_name ) else begin cast_if_required ctx field_object (type_string field_object.etype); let remap_name = if (type_string field_object.etype)="cpp::ArrayBase" then match remap_name with | "length" -> remap_name | _ -> "__" ^ remap_name else remap_name in output ( "->" ^ remap_name ); if (calling && (is_array field_object.etype) && remap_name="iterator" ) then check_array_element_cast field_object.etype "Fast" ""; already_dynamic := (match field with | FInstance(_,_,var) when is_var_field var -> true | _ -> false); end; end; ); if ( (not !already_dynamic) && (not calling) && (not assigning) && (is_function_member expression) ) then output "_dyn()"; in let gen_local_block_call () = let func_name = use_anon_function_name ctx in ( try output ( func_name ^ "::Block(" ^ (Hashtbl.find ctx.ctx_local_return_block_args func_name) ^ ")" ) with Not_found -> (*error ("Block function " ^ func_name ^ " not found" ) expression.epos;*) output ("/* Block function " ^ func_name ^ " not found */" ); ) in match expression.eexpr with | TConst TNull when not retval -> output "Dynamic()"; | TCall (func, arg_list) when (match func.eexpr with | TLocal { v_name = "__cpp__" } -> true | _ -> false) -> ( match arg_list with | [{ eexpr = TConst (TString code) }] -> output (format_code code); | ({ eexpr = TConst (TString code) } as ecode) :: tl -> Codegen.interpolate_code ctx.ctx_common (format_code code) tl output (gen_expression true) ecode.epos | _ -> error "__cpp__'s first argument must be a string" func.epos; ) | TCall (func, arg_list) when tcall_expand_args-> let arg_string = ref "" in let idx = ref 0 in List.iter (fun arg -> let a_name = "__a" ^ string_of_int(!idx) in arg_string := !arg_string ^ (if !arg_string<>"" then "," else "") ^ a_name; idx := !idx + 1; output_i ( (type_string arg.etype) ^ " " ^ a_name ^ " = "); gen_expression true arg; output ";\n"; ) arg_list; output_i (if retval then "return " else ""); ctx.ctx_calling <- true; gen_expression true func; output ("(" ^ !arg_string ^ ");\n"); | TCall (func, arg_list) when is_fromStaticFunction_call func -> (match arg_list with | [ {eexpr = TField( _, FStatic(klass,field)) } ] -> let signature = cpp_function_signature field.cf_type "" in let name = keyword_remap field.cf_name in let void_cast = has_meta_key field.cf_meta Meta.Void in output ("::cpp::Function< " ^ signature ^">("); if (void_cast) then output "hx::AnyCast("; output ("&::" ^(join_class_path klass.cl_path "::")^ "_obj::" ^ name ); if (void_cast) then output ")"; output (" )"); | _ -> error "fromStaticFunction must take a static function" expression.epos; ) | TCall (func, [arg]) when is_addressOf_call func && not (is_lvalue arg) -> error "addressOf must take a local or member variable" expression.epos; | TCall (func, arg_list) -> let rec is_variable e = match e.eexpr with | TField _ | TEnumParameter _ -> false | TLocal { v_name = "__global__" } -> false | TParenthesis p | TMeta(_,p) -> is_variable p | _ -> true in let expr_type = type_string expression.etype in let rec is_fixed_override e = (not (is_scalar expr_type)) && match e.eexpr with | TField(obj,FInstance(_,_,field) ) -> let cpp_type = member_type ctx obj field.cf_name in (not (is_scalar cpp_type)) && ( let fixed = (cpp_type<>"?") && (expr_type<>"Dynamic") && (cpp_type<>"Dynamic") && (cpp_type<>expr_type) && (expr_type<>"Void") && (cpp_type<>"cpp::ArrayBase") in if (fixed && (ctx.ctx_debug_level>1) ) then begin output ("/* " ^ (cpp_type) ^ " != " ^ expr_type ^ " -> cast */"); end; fixed ) | TParenthesis p | TMeta(_,p) -> is_fixed_override p | _ -> false in let check_extern_pointer_cast e = match (remove_parens e).eexpr with | TField (_,FInstance(class_def,_,_) ) | TField (_,FStatic(class_def,_) ) when class_def.cl_extern -> (try let return_type = expression.etype in (is_pointer return_type false) && ( output ( (type_string return_type) ^ "(" ); true; ) with Not_found -> false ) | _ -> false in let is_super = (match func.eexpr with | TConst TSuper -> true | _ -> false ) in if (ctx.ctx_debug_level>1) then output ("/* TCALL ret=" ^ expr_type ^ "*/"); let cast_result = (not is_super) && (is_fixed_override func) in if (cast_result) then output ("hx::TCast< " ^ expr_type ^ " >::cast("); let cast_result = cast_result || check_extern_pointer_cast func in (* If a static function has @:native('new abc') c++ new has lower precedence than in haxe so ( ) must be used *) let paren_result = if is_native_with_space func then ( output "("; true ) else false in ctx.ctx_calling <- true; gen_expression true func; output "("; gen_expression_list arg_list; output ")"; if paren_result then output ")"; if (cast_result) then output (")"); if ( (is_variable func) && (not (is_cpp_function_member func) ) && (expr_type<>"Dynamic" && expr_type<>"cpp::ArrayBase" ) && (not is_super) ) then ctx.ctx_output (".Cast< " ^ expr_type ^ " >()" ); let rec cast_array_output func = match func.eexpr with | TField(obj,field) when is_array obj.etype -> (match field_name field with | "pop" | "shift" | "__unsafe_get" | "__unsafe_set" -> check_array_element_cast obj.etype ".StaticCast" "()" | "map" -> check_array_cast expression.etype | _ -> () ) | TParenthesis p | TMeta(_,p) -> cast_array_output p | _ -> () in cast_array_output func; | TBlock expr_list -> if (retval) then gen_local_block_call() else begin writer#begin_block; dump_src_pos(); (* Save old values, and equalize for new input ... *) let pop_names = push_anon_names ctx in let remaining = ref (List.length expr_list) in List.iter (fun expression -> let want_value = (return_from_block && !remaining = 1) in find_local_functions_and_return_blocks_ctx want_value expression; if (ctx.ctx_debug_level>0) then output_i ("HX_STACK_LINE(" ^ (string_of_int (Lexer.get_error_line expression.epos)) ^ ")\n" ); output_i ""; ctx.ctx_return_from_internal_node <- return_from_internal_node; if (want_value) then output "return "; gen_expression want_value expression; decr remaining; writer#terminate_line ) expr_list; writer#end_block; pop_names() end | TTypeExpr type_expr -> let klass = "::" ^ (join_class_path_remap (t_path type_expr) "::" ) in let klass1 = if klass="::Array" then "Array" else klass in output ("hx::ClassOf< " ^ klass1 ^ " >()") | TReturn _ when retval -> unsupported expression.epos | TReturn optional_expr -> output ""; ( match optional_expr with | Some return_expression when ( (type_string expression.etype)="Void") -> output "return null("; gen_expression true return_expression; output ")"; | Some return_expression -> output "return "; gen_expression true return_expression | _ -> output (if ctx.ctx_real_void then "return" else "return null()") ) | TConst const -> (match const with | TInt i when ctx.ctx_for_extern -> output (Printf.sprintf "%ld" i) | TInt i -> output (Printf.sprintf "(int)%ld" i) | TFloat float_as_string -> output ("((Float)" ^ float_as_string ^")") | TString s when ctx.ctx_for_extern -> output ("\"" ^ (escape_extern s) ^ "\"") | TString s -> output (str s) | TBool b -> output (if b then "true" else "false") (*| TNull -> output ("((" ^ (type_string expression.etype) ^ ")null())")*) | TNull -> output (if ctx.ctx_for_extern then "null" else "null()") | TThis -> output (if ctx.ctx_real_this_ptr then "hx::ObjectPtr(this)" else "__this") | TSuper when calling -> output (if ctx.ctx_real_this_ptr then "super::__construct" else ("__this->" ^ ctx.ctx_class_super_name ^ "::__construct") ) | TSuper -> output ("hx::ObjectPtr(" ^ (if ctx.ctx_real_this_ptr then "this" else "__this.mPtr") ^ ")") ) | TLocal v -> output (keyword_remap v.v_name); | TArray (array_expr,_) when (is_null array_expr) -> output "Dynamic()" | TArray (array_expr,index) -> let dynamic = is_dynamic_in_cpp ctx array_expr || (type_string array_expr.etype) = "cpp::ArrayBase" in if ( assigning && (not dynamic) ) then begin if (is_array_implementer array_expr.etype) then begin output "hx::__ArrayImplRef("; gen_expression true array_expr; output ","; gen_expression true index; output ")"; end else begin gen_expression true array_expr; output "["; gen_expression true index; output "]"; end end else if (assigning) then begin (* output (" /*" ^ (type_string array_expr.etype) ^ " */ "); *) output "hx::IndexRef(("; gen_expression true array_expr; output ").mPtr,"; gen_expression true index; output ")"; end else if ( dynamic ) then begin gen_expression true array_expr; output "->__GetItem("; gen_expression true index; output ")"; end else begin gen_expression true array_expr; output "->__get("; gen_expression true index; output ")"; if not (is_pointer array_expr.etype true) then check_array_element_cast array_expr.etype ".StaticCast" "()"; end (* Get precidence matching haxe ? *) | TBinop (op,expr1,expr2) -> gen_bin_op op expr1 expr2 | TField (expr,_) | TEnumParameter (expr,_,_) when (is_null expr) -> output "hx::Throw(HX_CSTRING(\"Invalid field access on null object\"))" | TEnumParameter (expr,ef,i) -> let enum = match follow ef.ef_type with | TEnum(en,_) | TFun(_,TEnum(en,_)) -> en | _ -> assert false in output ( "(::" ^ (join_class_path_remap enum.e_path "::") ^ "("); gen_expression true expr; output ( "))->__Param(" ^ (string_of_int i) ^ ")") | TField (field_object,field) -> gen_tfield field_object field | TParenthesis expr when not retval -> gen_expression retval expr; | TParenthesis expr -> output "("; gen_expression retval expr; output ")" | TMeta (_,expr) -> gen_expression retval expr; | TObjectDecl ( ("fileName" , { eexpr = (TConst (TString file)) }) :: ("lineNumber" , { eexpr = (TConst (TInt line)) }) :: ("className" , { eexpr = (TConst (TString class_name)) }) :: ("methodName", { eexpr = (TConst (TString meth)) }) :: [] ) -> output ("hx::SourceInfo(" ^ (str file) ^ "," ^ (Printf.sprintf "%ld" line) ^ "," ^ (str class_name) ^ "," ^ (str meth) ^ ")" ) | TObjectDecl decl_list -> gen_local_block_call() | TArrayDecl decl_list -> (* gen_type output expression.etype; *) let tstr = (type_string_suff "_obj" expression.etype true) in if tstr="Dynamic" then output "Dynamic( Array_obj::__new()" else output ( (type_string_suff "_obj" expression.etype true) ^ "::__new()"); List.iter ( fun elem -> output ".Add("; gen_expression true elem; output ")" ) decl_list; if tstr="Dynamic" then output ")"; | TNew (klass,params,expressions) -> let is_param_array = match klass.cl_path with | ([],"Array") when is_dynamic_array_param (List.hd params) -> true | _ -> false in if is_param_array then output "Dynamic( Array_obj::__new() )" else begin if (klass.cl_path = ([],"String")) then output "::String(" else output ( ( class_string klass "_obj" params true) ^ "::__new(" ); gen_expression_list expressions; output ")" end | TUnop (Ast.NegBits,Ast.Prefix,expr) -> output "~(int)("; gen_expression true expr; output ")" | TUnop (op,Ast.Prefix,expr) -> ctx.ctx_assigning <- (match op with Ast.Increment | Ast.Decrement -> true | _ ->false); output (Ast.s_unop op); output "("; gen_expression true expr; output ")" | TUnop (op,Ast.Postfix,expr) -> ctx.ctx_assigning <- true; output "("; gen_expression true expr; output ")"; output (Ast.s_unop op) | TFunction func -> let func_name = use_anon_function_name ctx in ( try output ( " Dynamic(new " ^ func_name ^ "(" ^ (Hashtbl.find ctx.ctx_local_function_args func_name) ^ "))" ) with Not_found -> (*error ("function " ^ func_name ^ " not found.") expression.epos; *) output ("function " ^ func_name ^ " not found."); ) | TVar (tvar,optional_init) -> let count = ref 1 in (* TODO: this section can be simplified *) if (retval && !count==1) then (match optional_init with | None -> output "null()" | Some expression -> gen_expression true expression ) else begin let type_name = (type_string tvar.v_type) in output (if type_name="Void" then "Dynamic" else type_name ); let name = (keyword_remap tvar.v_name) in output (" " ^ name ); (match optional_init with | None -> () | Some expression -> output " = "; gen_expression true expression); count := !count -1; if (ctx.ctx_debug_level>0) then output (";\t\tHX_STACK_VAR(" ^name ^",\""^ tvar.v_name ^"\")"); if (!count > 0) then begin output ";\n"; output_i "" end end | TFor (tvar, init, loop) -> output ("for(::cpp::FastIterator_obj< " ^ (type_string tvar.v_type) ^ " > *__it = ::cpp::CreateFastIterator< "^(type_string tvar.v_type) ^ " >("); gen_expression true init; output ("); __it->hasNext(); )"); ctx.ctx_writer#begin_block; output_i ( (type_string tvar.v_type) ^ " " ^ (keyword_remap tvar.v_name) ^ " = __it->next();\n" ); output_i ""; gen_expression false loop; output ";\n"; ctx.ctx_writer#end_block; | TIf (condition, if_expr, optional_else_expr) -> (match optional_else_expr with | Some else_expr -> if (retval) then begin output "( ("; gen_expression true condition; output ") ? "; let type_str = match (type_string expression.etype) with | "Void" -> "Dynamic" | other -> other in output (type_str ^ "("); gen_expression true if_expr; output ") : "; output (type_str ^ "("); gen_expression true else_expr; output ") )"; end else begin output "if ("; gen_expression true condition; output ")"; gen_expression false (to_block if_expr); output_i "else"; gen_expression false (to_block else_expr); end | _ -> output "if ("; gen_expression true condition; output ")"; gen_expression false (to_block if_expr); ) | TWhile (condition, repeat, Ast.NormalWhile ) -> output "while("; gen_expression true condition; output ")"; gen_expression false (to_block repeat) | TWhile (condition, repeat, Ast.DoWhile ) -> output "do"; gen_expression false (to_block repeat); output "while("; gen_expression true condition; output ")" (* These have already been defined in find_local_return_blocks ... *) | TTry (_,_) | TSwitch (_,_,_) when (retval && (not return_from_internal_node) ) -> gen_local_block_call() | TSwitch (condition,cases,optional_default) -> let switch_on_int_constants = (only_int_cases cases) && (not (contains_break expression)) in if (switch_on_int_constants) then begin output "switch( (int)"; gen_expression true condition; output ")"; ctx.ctx_writer#begin_block; List.iter (fun (cases_list,expression) -> output_i ""; List.iter (fun value -> output "case "; gen_expression true value; output ": " ) cases_list; ctx.ctx_return_from_block <- return_from_internal_node; gen_expression false (to_block expression); output_i ";break;\n"; ) cases; (match optional_default with | None -> () | Some default -> output_i "default: "; ctx.ctx_return_from_block <- return_from_internal_node; gen_expression false (to_block default); ); ctx.ctx_writer#end_block; end else begin let tmp_name = get_switch_var ctx in output ( (type_string condition.etype) ^ " " ^ tmp_name ^ " = " ); gen_expression true condition; output ";\n"; let else_str = ref "" in if (List.length cases > 0) then List.iter (fun (cases,expression) -> output_i ( !else_str ^ "if ( "); else_str := "else "; let or_str = ref "" in List.iter (fun value -> output (!or_str ^ " ( " ^ tmp_name ^ "=="); gen_expression true value; output ")"; or_str := " || "; ) cases; output (")"); ctx.ctx_return_from_block <- return_from_internal_node; gen_expression false (to_block expression); ) cases; (match optional_default with | None -> () | Some default -> output_i ( !else_str ^ " "); ctx.ctx_return_from_block <- return_from_internal_node; gen_expression false (to_block default); output ";\n"; ); end | TTry (expression, catch_list) -> output "try\n"; output_i "{\n"; let counter = ref 0 in List.iter (fun (v, e) -> let type_name = type_string v.v_type in output_i ("HX_STACK_CATCHABLE(" ^ type_name ^ ", " ^ string_of_int !counter ^ ");\n"); counter := !counter + 1;) catch_list; output_i(""); (* Move this "inside" the try call ... *) ctx.ctx_return_from_block <-return_from_internal_node; gen_expression false (to_block expression); output_i "}\n"; if (List.length catch_list > 0 ) then begin output_i "catch(Dynamic __e)"; ctx.ctx_writer#begin_block; let seen_dynamic = ref false in let else_str = ref "" in List.iter (fun (v,expression) -> let type_name = type_string v.v_type in if (type_name="Dynamic") then begin seen_dynamic := true; output_i !else_str; end else output_i (!else_str ^ "if (__e.IsClass< " ^ type_name ^ " >() )"); ctx.ctx_writer#begin_block; output_i "HX_STACK_BEGIN_CATCH\n"; output_i (type_name ^ " " ^ v.v_name ^ " = __e;"); (* Move this "inside" the catch call too ... *) ctx.ctx_return_from_block <-return_from_internal_node; gen_expression false (to_block expression); ctx.ctx_writer#end_block; else_str := "else "; ) catch_list; if (not !seen_dynamic) then begin output_i "else {\n"; output_i " HX_STACK_DO_THROW(__e);\n"; output_i "}\n"; end; ctx.ctx_writer#end_block; end; | TBreak -> output "break" | TContinue -> output "continue" | TThrow expression -> output "HX_STACK_DO_THROW("; gen_expression true expression; output ")"; | TCast (cast,None) when (not retval) || (type_string expression.etype) = "Void" -> gen_expression retval cast; | TCast (cast,None) -> let ret_type = type_string expression.etype in let from_type = if is_dynamic_in_cpp ctx cast then "Dynamic" else type_string cast.etype in if (from_type = ret_type) then begin gen_expression true cast end else begin output ("((" ^ ret_type ^ ")("); gen_expression true cast; output "))"; end; | TCast (e1,Some t) -> let class_name = (join_class_path_remap (t_path t) "::" ) in if (class_name="Array") then output ("hx::TCastToArray(" ) else output ("hx::TCast< ::" ^ class_name ^ " >::cast(" ); gen_expression true e1; output ")"; in if (set_var<>"") then begin find_local_functions_and_return_blocks_ctx true expression_tree; output set_var; end; gen_expression retval expression_tree; output tail_code ;; (* let is_dynamic_haxe_method f = match follow f.cf_type with | TFun _ when f.cf_expr = None -> true | _ -> (match f.cf_expr with | Some { eexpr = TFunction fd } when f.cf_set = MethodAccess true -> true | Some { eexpr = TFunction fd } when f.cf_set = NormalAccess -> true | _ -> false);; *) let is_dynamic_haxe_method f = (match f.cf_expr, f.cf_kind with | Some { eexpr = TFunction _ }, (Var _ | Method MethDynamic) -> true | _ -> false);; let is_data_member field = match field.cf_expr with | Some { eexpr = TFunction function_def } -> is_dynamic_haxe_method field | _ -> true;; let is_override class_def field = List.exists (fun f -> f.cf_name = field) class_def.cl_overrides ;; let rec all_virtual_functions clazz = (List.fold_left (fun result elem -> match follow elem.cf_type, elem.cf_kind with | _, Method MethDynamic -> result | TFun (args,return_type), Method _ when not (is_override clazz elem.cf_name ) -> (elem,args,return_type) :: result | _,_ -> result ) [] clazz.cl_ordered_fields) @ (match clazz.cl_super with | Some def -> all_virtual_functions (fst def) | _ -> [] ) ;; let reflective class_def field = not ( (Meta.has Meta.NativeGen class_def.cl_meta) || (Meta.has Meta.Unreflective class_def.cl_meta) || (Meta.has Meta.Unreflective field.cf_meta) || (match field.cf_type with | TInst (klass,_) -> Meta.has Meta.Unreflective klass.cl_meta | _ -> false ) ) ;; let field_arg_count field = match follow field.cf_type, field.cf_kind with | _, Method MethDynamic -> -1 | TFun (args,return_type), Method _ -> List.length args | _,_ -> -1 ;; (* external mem Dynamic & *) let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface field = let output = ctx.ctx_output in ctx.ctx_real_this_ptr <- not is_static; let remap_name = keyword_remap field.cf_name in let decl = get_meta_string field.cf_meta Meta.Decl in let has_decl = decl <> "" in let nativeGen = has_meta_key class_def.cl_meta Meta.NativeGen in if (is_interface) then begin (* Just the dynamic glue - not even that ... *) () end else (match field.cf_expr with (* Function field *) | Some { eexpr = TFunction function_def } -> let return_type = (type_string function_def.tf_type) in let nargs = string_of_int (List.length function_def.tf_args) in let is_void = (type_string function_def.tf_type ) = "Void" in let ret = if is_void then "(void)" else "return " in let output_i = ctx.ctx_writer#write_i in let orig_debug = ctx.ctx_debug_level in let dump_src = if ((Meta.has Meta.NoStack field.cf_meta)||(Meta.has Meta.NoDebug field.cf_meta) || orig_debug<1 || nativeGen) then begin ctx.ctx_debug_level <- 0; (fun()->()) end else begin (fun() -> hx_stack_push ctx output_i dot_name field.cf_name function_def.tf_expr.epos; if (not is_static) then output_i ("HX_STACK_THIS(this)\n"); List.iter (fun (v,_) -> output_i ("HX_STACK_ARG(" ^ (keyword_remap v.v_name) ^ ",\"" ^ v.v_name ^"\")\n") ) function_def.tf_args ) end in if (not (is_dynamic_haxe_method field)) then begin (* The actual function definition *) let real_void = is_void && (has_meta_key field.cf_meta Meta.Void) in let fake_void = is_void && not real_void in output (if real_void then "void" else return_type ); output (" " ^ class_name ^ "::" ^ remap_name ^ "( " ); output (gen_arg_list function_def.tf_args "__o_"); output ")"; ctx.ctx_real_this_ptr <- true; ctx.ctx_real_void <- real_void; ctx.ctx_dynamic_this_ptr <- false; let code = (get_code field.cf_meta Meta.FunctionCode) in let tail_code = (get_code field.cf_meta Meta.FunctionTailCode) in if (has_default_values function_def.tf_args) then begin ctx.ctx_writer#begin_block; generate_default_values ctx function_def.tf_args "__o_"; dump_src(); output code; gen_expression_tree ctx false function_def.tf_expr "" tail_code; if (fake_void) then output "return null();\n"; ctx.ctx_writer#end_block; end else begin let add_block = is_void || (code <> "") || (tail_code <> "") in if (add_block) then ctx.ctx_writer#begin_block; ctx.ctx_dump_src_pos <- dump_src; output code; gen_expression_tree ctx false (to_block function_def.tf_expr) "" tail_code; if (add_block) then begin if (fake_void) then output "return null();\n"; ctx.ctx_writer#end_block; end; end; output "\n\n"; let nonVirtual = has_meta_key field.cf_meta Meta.NonVirtual in let doDynamic = (nonVirtual || not (is_override class_def field.cf_name ) ) && (reflective class_def field ) in (* generate dynamic version too ... *) if ( doDynamic ) then begin if (is_static) then output "STATIC_"; output ("HX_DEFINE_DYNAMIC_FUNC" ^ nargs ^ "(" ^ class_name ^ "," ^ remap_name ^ "," ^ ret ^ ")\n\n"); end; end else begin ctx.ctx_real_this_ptr <- false; ctx.ctx_dynamic_this_ptr <- false; let func_name = "__default_" ^ (remap_name) in output ("HX_BEGIN_DEFAULT_FUNC(" ^ func_name ^ "," ^ class_name ^ ")\n"); output return_type; output (" run(" ^ (gen_arg_list function_def.tf_args "__o_") ^ ")"); ctx.ctx_dump_src_pos <- dump_src; if (is_void) then begin ctx.ctx_writer#begin_block; generate_default_values ctx function_def.tf_args "__o_"; gen_expression_tree ctx false function_def.tf_expr "" ""; output "return null();\n"; ctx.ctx_writer#end_block; end else if (has_default_values function_def.tf_args) then begin ctx.ctx_writer#begin_block; generate_default_values ctx function_def.tf_args "__o_"; gen_expression_tree ctx false function_def.tf_expr "" ""; ctx.ctx_writer#end_block; end else gen_expression_tree ctx false (to_block function_def.tf_expr) "" ""; output ("HX_END_LOCAL_FUNC" ^ nargs ^ "(" ^ ret ^ ")\n"); output ("HX_END_DEFAULT_FUNC\n\n"); if (is_static) then output ( "Dynamic " ^ class_name ^ "::" ^ remap_name ^ ";\n\n"); end; ctx.ctx_debug_level <- orig_debug (* Data field *) | _ when has_decl -> if is_static then begin output ( class_name ^ "::" ^ remap_name ^ "_decl "); output ( " " ^ class_name ^ "::" ^ remap_name ^ ";\n\n"); end | _ -> if is_static && (not (is_extern_field field)) then begin gen_type ctx field.cf_type; output ( " " ^ class_name ^ "::" ^ remap_name ^ ";\n\n"); end ) ;; let gen_field_init ctx field = let output = ctx.ctx_output in let remap_name = keyword_remap field.cf_name in (match field.cf_expr with (* Function field *) | Some { eexpr = TFunction function_def } -> if (is_dynamic_haxe_method field) then begin let func_name = "__default_" ^ (remap_name) in output ( "\t" ^ remap_name ^ " = new " ^ func_name ^ ";\n\n" ); end (* Data field *) | _ -> (match field.cf_expr with | Some expr -> let var_name = ( match remap_name with | "__meta__" -> "\t__mClass->__meta__=" | "__rtti" -> "\t__mClass->__rtti__=" | _ -> "\t" ^ remap_name ^ "= ") in gen_expression_tree ctx true expr var_name ";\n"; | _ -> ( ) ); ) ;; let has_field_init field = match field.cf_expr with (* Function field *) | Some { eexpr = TFunction function_def } -> is_dynamic_haxe_method field (* Data field *) | Some _ -> true | _ -> false ;; let gen_member_def ctx class_def is_static is_interface field = let output = ctx.ctx_output in let remap_name = keyword_remap field.cf_name in let nativeGen = has_meta_key class_def.cl_meta Meta.NativeGen in if (is_interface) then begin match follow field.cf_type, field.cf_kind with | _, Method MethDynamic -> () | TFun (args,return_type), Method _ -> output ( (if (not is_static) then " virtual " else " " ) ^ type_string return_type); output (" " ^ remap_name ^ "( " ); output (gen_tfun_interface_arg_list args); output (if (not is_static) then ")=0;\n" else ");\n"); if reflective class_def field then begin output ("virtual Dynamic " ^ remap_name ^ "_dyn()=0;\n" ); end | _ -> ( ) end else begin let decl = get_meta_string field.cf_meta Meta.Decl in let has_decl = decl <> "" in if (has_decl) then output ( " typedef " ^ decl ^ ";\n" ); output (if is_static then "\t\tstatic " else "\t\t"); (match field.cf_expr with | Some { eexpr = TFunction function_def } -> let nonVirtual = has_meta_key field.cf_meta Meta.NonVirtual in let doDynamic = (nonVirtual || not (is_override class_def field.cf_name ) ) && (reflective class_def field ) in if ( is_dynamic_haxe_method field ) then begin if ( doDynamic ) then begin output ("Dynamic " ^ remap_name ^ ";\n"); output (if is_static then "\t\tstatic " else "\t\t"); output ("inline Dynamic &" ^ remap_name ^ "_dyn() " ^ "{return " ^ remap_name^ "; }\n") end end else begin let return_type = (type_string function_def.tf_type) in if ( not is_static && not nonVirtual ) then output "virtual "; output (if return_type="Void" && (has_meta_key field.cf_meta Meta.Void) then "void" else return_type ); output (" " ^ remap_name ^ "( " ); output (gen_arg_list function_def.tf_args "" ); output ");\n"; if ( doDynamic ) then begin output (if is_static then "\t\tstatic " else "\t\t"); output ("Dynamic " ^ remap_name ^ "_dyn();\n" ) end; end; output "\n"; | _ when has_decl -> output ( remap_name ^ "_decl " ^ remap_name ^ ";\n" ); (* Variable access *) | _ -> (* Variable access *) gen_type ctx field.cf_type; output (" " ^ remap_name ^ ";\n" ); (* Add a "dyn" function for variable to unify variable/function access *) (match follow field.cf_type with | _ when nativeGen -> () | TFun (_,_) -> output (if is_static then "\t\tstatic " else "\t\t"); gen_type ctx field.cf_type; output (" &" ^ remap_name ^ "_dyn() { return " ^ remap_name ^ ";}\n" ) | _ -> (match field.cf_kind with | Var { v_read = AccCall } when (not is_static) && (is_dynamic_accessor ("get_" ^ field.cf_name) "get" field class_def) -> output ("\t\tDynamic get_" ^ field.cf_name ^ ";\n" ) | _ -> () ); (match field.cf_kind with | Var { v_write = AccCall } when (not is_static) && (is_dynamic_accessor ("set_" ^ field.cf_name) "set" field class_def) -> output ("\t\tDynamic set_" ^ field.cf_name ^ ";\n" ) | _ -> () ) ) ); end ;; let path_of_string path = ["@verbatim"], path ;; (* Get a list of all classes referred to by the class/enum definition These are used for "#include"ing the appropriate header files, or for building the dependencies in the Build.xml file *) let find_referenced_types ctx obj super_deps constructor_deps header_only for_depends include_super_args = let types = ref PMap.empty in let rec add_type in_path = if ( not (PMap.mem in_path !types)) then begin types := (PMap.add in_path () !types); try List.iter add_type (Hashtbl.find super_deps in_path); with Not_found -> () end in let add_extern_class klass = let include_file = get_meta_string_path klass.cl_meta (if for_depends then Meta.Depend else Meta.Include) in if (include_file<>"") then add_type ( path_of_string include_file ) else if (not for_depends) && (has_meta_key klass.cl_meta Meta.Include) then add_type klass.cl_path in let add_native_gen_class klass = let include_file = get_meta_string_path klass.cl_meta (if for_depends then Meta.Depend else Meta.Include) in if (include_file<>"") then add_type ( path_of_string include_file ) else if for_depends then add_type klass.cl_path else add_type ( path_of_string ( (join_class_path klass.cl_path "/") ^ ".h") ) in let visited = ref [] in let rec visit_type in_type = if not (List.exists (fun t2 -> Type.fast_eq in_type t2) !visited) then begin visited := in_type :: !visited; begin match follow in_type with | TMono r -> (match !r with None -> () | Some t -> visit_type t) | TEnum (enum,params) -> add_type enum.e_path (* If a class has a template parameter, then we treat it as dynamic - except for the Array, Class, FastIterator or Pointer classes, for which we do a fully typed object *) | TInst (klass,params) -> (match klass.cl_path with | ([],"Array") | ([],"Class") | (["cpp"],"FastIterator") | (["cpp"],"Pointer") | (["cpp"],"ConstPointer") | (["cpp"],"Function") | (["cpp"],"RawPointer") | (["cpp"],"RawConstPointer") -> List.iter visit_type params | _ when is_native_gen_class klass -> add_native_gen_class klass | _ when is_extern_class klass -> add_extern_class klass | _ -> (match klass.cl_kind with KTypeParameter _ -> () | _ -> add_type klass.cl_path); ) | TFun (args,haxe_type) -> visit_type haxe_type; List.iter (fun (_,_,t) -> visit_type t; ) args; | _ -> () end; visited := List.tl !visited; end in let rec visit_params expression = begin let rec visit_expression = fun expression -> (* Expand out TTypeExpr (ie, the name of a class, as used for static access etc ... *) (match expression.eexpr with | TTypeExpr type_def -> ( match type_def with | TClassDecl class_def when is_native_gen_class class_def -> add_native_gen_class class_def | TClassDecl class_def when is_extern_class class_def -> add_extern_class class_def | _ -> add_type (t_path type_def) ) (* Must visit the types, Type.iter will visit the expressions ... *) | TTry (e,catches) -> List.iter (fun (v,_) -> visit_type v.v_type) catches (* Must visit the enum param types, Type.iter will visit the rest ... *) (* | TMatch (_,enum,cases,_) -> add_type (fst enum).e_path; List.iter (fun (case_ids,params,expression) -> (match params with | None -> () | Some l -> List.iter (function None -> () | Some v -> visit_type v.v_type) l ) ) cases; *) (* Must visit type too, Type.iter will visit the expressions ... *) | TNew (klass,params,_) -> begin visit_type (TInst (klass,params)); try let construct_type = Hashtbl.find constructor_deps klass.cl_path in visit_type construct_type.cf_type with Not_found -> (); end (* Must visit type too, Type.iter will visit the expressions ... *) | TVar (v,_) -> visit_type v.v_type (* Must visit enum type too, Type.iter will visit the expressions ... *) | TEnumParameter (_,ef,_) -> visit_type (follow ef.ef_type) (* Must visit args too, Type.iter will visit the expressions ... *) | TFunction func_def -> List.iter (fun (v,_) -> visit_type v.v_type) func_def.tf_args; | TConst TSuper -> (match follow expression.etype with | TInst (klass,params) -> (try let construct_type = Hashtbl.find constructor_deps klass.cl_path in visit_type construct_type.cf_type with Not_found -> () ) | _ -> print_endline ("TSuper : Odd etype ?" ^ ( (type_string expression.etype)) ) ) | _ -> () ); Type.iter visit_expression expression; visit_type (follow expression.etype) in visit_expression expression end in let visit_field field = (* Add the type of the expression ... *) visit_type field.cf_type; if (not header_only) then (match field.cf_expr with | Some expression -> visit_params expression | _ -> ()); in let visit_class class_def = let fields = List.append class_def.cl_ordered_fields class_def.cl_ordered_statics in let fields_and_constructor = List.append fields (match class_def.cl_constructor with | Some expr -> [expr] | _ -> [] ) in List.iter visit_field fields_and_constructor; if (include_super_args) then List.iter visit_field (List.map (fun (a,_,_) -> a ) (all_virtual_functions class_def )); (* Add super & interfaces *) if is_native_gen_class class_def then add_native_gen_class class_def else add_type class_def.cl_path; in let visit_enum enum_def = add_type enum_def.e_path; PMap.iter (fun _ constructor -> (match constructor.ef_type with | TFun (args,_) -> List.iter (fun (_,_,t) -> visit_type t; ) args; | _ -> () ); ) enum_def.e_constrs; if (not header_only) then begin let meta = Codegen.build_metadata ctx (TEnumDecl enum_def) in match meta with Some expr -> visit_params expr | _ -> (); end; in let inc_cmp i1 i2 = String.compare (join_class_path i1 ".") (join_class_path i2 ".") in (* Body of main function *) (match obj with | TClassDecl class_def -> visit_class class_def; (match class_def.cl_init with Some expression -> visit_params expression | _ -> ()) | TEnumDecl enum_def -> visit_enum enum_def | TTypeDecl _ | TAbstractDecl _ -> (* These are expanded *) ()); List.sort inc_cmp (List.filter (fun path -> (include_class_header path) ) (pmap_keys !types)) ;; let generate_main_header output_main = output_main "#include \n\n"; output_main "#include \n\n"; output_main "extern \"C\" void __hxcpp_main();\n\n"; output_main "extern \"C\" void __hxcpp_lib_main();\n\n" ;; let generate_main_footer1 output_main = output_main "void __hxcpp_main() {\n";; let generate_main_footer2 output_main = output_main " }\n\n"; output_main "void __hxcpp_lib_main() {\n"; output_main " HX_TOP_OF_STACK\n"; output_main " hx::Boot();\n"; output_main " __boot_all();\n"; output_main " __hxcpp_main();\n"; output_main " }\n" ;; let generate_main common_ctx member_types super_deps class_def file_info = (* main routine should be a single static function *) let main_expression = (match class_def.cl_ordered_statics with | [{ cf_expr = Some expression }] -> expression; | _ -> assert false ) in ignore(find_referenced_types common_ctx (TClassDecl class_def) super_deps (Hashtbl.create 0) false false false); let depend_referenced = find_referenced_types common_ctx (TClassDecl class_def) super_deps (Hashtbl.create 0) false true false in let generate_startup filename is_main = (*make_class_directories base_dir ( "src" :: []);*) let cpp_file = new_cpp_file common_ctx common_ctx.file ([],filename) in let output_main = (cpp_file#write) in generate_main_header output_main; List.iter ( add_include cpp_file ) depend_referenced; output_main "\n\n"; if is_main then output_main "\n#include \n\n"; generate_main_footer1 output_main; gen_expression_tree (new_context common_ctx cpp_file 1 file_info) false main_expression "" ";\n"; generate_main_footer2 output_main; cpp_file#close; in generate_startup "__main__" true; generate_startup "__lib__" false ;; let generate_dummy_main common_ctx = let generate_startup filename is_main = let main_file = new_cpp_file common_ctx common_ctx.file ([],filename) in let output_main = (main_file#write) in generate_main_header output_main; if is_main then output_main "\n#include \n\n"; generate_main_footer1 output_main; generate_main_footer2 output_main; main_file#close; in generate_startup "__main__" true; generate_startup "__lib__" false ;; let generate_boot common_ctx boot_enums boot_classes nonboot_classes init_classes = (* Write boot class too ... *) let base_dir = common_ctx.file in let boot_file = new_cpp_file common_ctx base_dir ([],"__boot__") in let output_boot = (boot_file#write) in output_boot "#include \n\n"; List.iter ( fun class_path -> boot_file#add_include class_path ) (boot_enums @ boot_classes @ nonboot_classes); output_boot "\nvoid __files__boot();\n"; output_boot "\nvoid __boot_all()\n{\n"; output_boot "__files__boot();\n"; output_boot "hx::RegisterResources( hx::GetResources() );\n"; List.iter ( fun class_path -> output_boot ("::" ^ ( join_class_path_remap class_path "::" ) ^ "_obj::__register();\n") ) (boot_enums @ boot_classes @ nonboot_classes); let dump_boot = List.iter ( fun class_path -> output_boot ("::" ^ ( join_class_path_remap class_path "::" ) ^ "_obj::__boot();\n") ) in dump_boot boot_enums; List.iter ( fun class_path -> output_boot ("::" ^ ( join_class_path_remap class_path "::" ) ^ "_obj::__init__();\n") ) (List.rev init_classes); dump_boot (List.filter (fun path -> is_cpp_class path ) (List.rev boot_classes)); dump_boot (List.filter (fun path -> not (is_cpp_class path) ) (List.rev boot_classes)); output_boot "}\n\n"; boot_file#close;; let generate_files common_ctx file_info = (* Write __files__ class too ... *) let base_dir = common_ctx.file in let files_file = new_cpp_file common_ctx base_dir ([],"__files__") in let output_files = (files_file#write) in let types = common_ctx.types in output_files "#include \n\n"; output_files "namespace hx {\n"; output_files "const char *__hxcpp_all_files[] = {\n"; output_files "#ifdef HXCPP_DEBUGGER\n"; List.iter ( fun file -> output_files ((const_char_star file)^",\n" ) ) ( List.sort String.compare ( pmap_keys !file_info) ); output_files "#endif\n"; output_files " 0 };\n"; output_files "\n"; output_files "const char *__hxcpp_all_files_fullpath[] = {\n"; output_files "#ifdef HXCPP_DEBUGGER\n"; List.iter ( fun file -> output_files ((const_char_star ( Common.get_full_path (try Common.find_file common_ctx file with Not_found -> file) ))^",\n" ) ) ( List.sort String.compare ( pmap_keys !file_info) ); output_files "#endif\n"; output_files " 0 };\n"; output_files "\n"; output_files "const char *__hxcpp_all_classes[] = {\n"; output_files "#ifdef HXCPP_DEBUGGER\n"; List.iter ( fun object_def -> (match object_def with | TClassDecl class_def when is_extern_class class_def -> ( ) | TClassDecl class_def when class_def.cl_interface -> ( ) | TClassDecl class_def -> output_files ((const_char_star (join_class_path class_def.cl_path "." )) ^ ",\n") | _ -> ( ) ) ) types; output_files "#endif\n"; output_files " 0 };\n"; output_files "} // namespace hx\n"; output_files "void __files__boot() { __hxcpp_set_debugger_info(hx::__hxcpp_all_classes, hx::__hxcpp_all_files_fullpath); }\n"; files_file#close;; let begin_header_file output_h def_string = output_h ("#ifndef INCLUDED_" ^ def_string ^ "\n"); output_h ("#define INCLUDED_" ^ def_string ^ "\n\n"); output_h "#ifndef HXCPP_H\n"; output_h "#include \n"; output_h "#endif\n\n";; let end_header_file output_h def_string = output_h ("\n#endif /* INCLUDED_" ^ def_string ^ " */ \n");; let new_placed_cpp_file common_ctx class_path = let base_dir = common_ctx.file in if (Common.defined common_ctx Define.Vcproj ) then begin make_class_directories base_dir ("src"::[]); cached_source_writer common_ctx ( base_dir ^ "/src/" ^ ( String.concat "-" (fst class_path) ) ^ "-" ^ (snd class_path) ^ (source_file_extension common_ctx) ) end else new_cpp_file common_ctx common_ctx.file class_path;; let generate_enum_files common_ctx enum_def super_deps meta file_info = let class_path = enum_def.e_path in let just_class_name = (snd class_path) in let class_name = just_class_name ^ "_obj" in let remap_class_name = ("::" ^ (join_class_path_remap class_path "::") ) in (*let cpp_file = new_cpp_file common_ctx.file class_path in*) let cpp_file = new_placed_cpp_file common_ctx class_path in let output_cpp = (cpp_file#write) in let debug = if (has_meta_key enum_def.e_meta Meta.NoDebug) || ( Common.defined common_ctx Define.NoDebug) then 0 else 1 in let ctx = new_context common_ctx cpp_file debug file_info in if (debug>1) then print_endline ("Found enum definition:" ^ (join_class_path class_path "::" )); output_cpp "#include \n\n"; let referenced = find_referenced_types common_ctx (TEnumDecl enum_def) super_deps (Hashtbl.create 0) false false false in List.iter (add_include cpp_file) referenced; gen_open_namespace output_cpp class_path; output_cpp "\n"; PMap.iter (fun _ constructor -> let name = keyword_remap constructor.ef_name in match constructor.ef_type with | TFun (args,_) -> output_cpp (remap_class_name ^ " " ^ class_name ^ "::" ^ name ^ "(" ^ (gen_tfun_arg_list args) ^")\n"); output_cpp ("\t{ return hx::CreateEnum< " ^ class_name ^ " >(" ^ (str name) ^ "," ^ (string_of_int constructor.ef_index) ^ ",hx::DynamicArray(0," ^ (string_of_int (List.length args)) ^ ")" ); List.iter (fun (arg,_,_) -> output_cpp (".Add(" ^ (keyword_remap arg) ^ ")")) args; output_cpp "); }\n\n" | _ -> output_cpp ( remap_class_name ^ " " ^ class_name ^ "::" ^ name ^ ";\n\n" ) ) enum_def.e_constrs; output_cpp ("HX_DEFINE_CREATE_ENUM(" ^ class_name ^ ")\n\n"); output_cpp ("int " ^ class_name ^ "::__FindIndex(::String inName)\n{\n"); PMap.iter (fun _ constructor -> let name = constructor.ef_name in let idx = string_of_int constructor.ef_index in output_cpp ("\tif (inName==" ^ (str name) ^ ") return " ^ idx ^ ";\n") ) enum_def.e_constrs; output_cpp ("\treturn super::__FindIndex(inName);\n"); output_cpp ("}\n\n"); let constructor_arg_count constructor = (match constructor.ef_type with | TFun(args,_) -> List.length args | _ -> 0 ) in (* Dynamic versions of constructors *) let dump_dynamic_constructor _ constr = let count = constructor_arg_count constr in if (count>0) then begin let nargs = string_of_int count in output_cpp ("STATIC_HX_DEFINE_DYNAMIC_FUNC" ^ nargs ^ "(" ^ class_name ^ "," ^ (keyword_remap constr.ef_name) ^ ",return)\n\n"); end in PMap.iter dump_dynamic_constructor enum_def.e_constrs; output_cpp ("int " ^ class_name ^ "::__FindArgCount(::String inName)\n{\n"); PMap.iter (fun _ constructor -> let name = constructor.ef_name in let count = string_of_int (constructor_arg_count constructor) in output_cpp ("\tif (inName==" ^ (str name) ^ ") return " ^ count ^ ";\n") ) enum_def.e_constrs; output_cpp ("\treturn super::__FindArgCount(inName);\n"); output_cpp ("}\n\n"); (* Dynamic "Get" Field function - string version *) output_cpp ("Dynamic " ^ class_name ^ "::__Field(const ::String &inName,hx::PropertyAccess inCallProp)\n{\n"); let dump_constructor_test _ constr = output_cpp ("\tif (inName==" ^ (str constr.ef_name) ^ ") return " ^ (keyword_remap constr.ef_name) ); if ( (constructor_arg_count constr) > 0 ) then output_cpp "_dyn()"; output_cpp (";\n") in PMap.iter dump_constructor_test enum_def.e_constrs; output_cpp ("\treturn super::__Field(inName,inCallProp);\n}\n\n"); output_cpp "static ::String sStaticFields[] = {\n"; let sorted = List.sort (fun f1 f2 -> (PMap.find f1 enum_def.e_constrs ).ef_index - (PMap.find f2 enum_def.e_constrs ).ef_index ) (pmap_keys enum_def.e_constrs) in List.iter (fun name -> output_cpp ("\t" ^ (str name) ^ ",\n") ) sorted; output_cpp "\t::String(null()) };\n\n"; (* ENUM - Mark static as used by GC *) output_cpp "static void sMarkStatics(HX_MARK_PARAMS) {\n"; PMap.iter (fun _ constructor -> let name = keyword_remap constructor.ef_name in match constructor.ef_type with | TFun (_,_) -> () | _ -> output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ class_name ^ "::" ^ name ^ ",\"" ^ name ^ "\");\n") ) enum_def.e_constrs; output_cpp "};\n\n"; (* ENUM - Visit static as used by GC *) output_cpp "#ifdef HXCPP_VISIT_ALLOCS\n"; output_cpp "static void sVisitStatic(HX_VISIT_PARAMS) {\n"; output_cpp ("\tHX_VISIT_MEMBER_NAME(" ^ class_name ^ "::__mClass,\"__mClass\");\n"); PMap.iter (fun _ constructor -> let name = keyword_remap constructor.ef_name in match constructor.ef_type with | TFun (_,_) -> () | _ -> output_cpp ("\tHX_VISIT_MEMBER_NAME(" ^ class_name ^ "::" ^ name ^ ",\"" ^ name ^ "\");\n") ) enum_def.e_constrs; output_cpp "};\n"; output_cpp "#endif\n\n"; output_cpp "static ::String sMemberFields[] = { ::String(null()) };\n"; output_cpp ("hx::Class " ^ class_name ^ "::__mClass;\n\n"); output_cpp ("Dynamic __Create_" ^ class_name ^ "() { return new " ^ class_name ^ "; }\n\n"); output_cpp ("void " ^ class_name ^ "::__register()\n{\n"); let text_name = str (join_class_path class_path ".") in output_cpp ("\nhx::Static(__mClass) = hx::RegisterClass(" ^ text_name ^ ", hx::TCanCast< " ^ class_name ^ " >,sStaticFields,sMemberFields,\n"); output_cpp ("\t&__Create_" ^ class_name ^ ", &__Create,\n"); output_cpp ("\t&super::__SGetClass(), &Create" ^ class_name ^ ", sMarkStatics\n"); output_cpp("#ifdef HXCPP_VISIT_ALLOCS\n , sVisitStatic\n#endif\n"); output_cpp ("#ifdef HXCPP_SCRIPTABLE\n , 0\n#endif\n"); output_cpp (");\n}\n\n"); output_cpp ("void " ^ class_name ^ "::__boot()\n{\n"); (match meta with | Some expr -> let ctx = new_context common_ctx cpp_file 1 file_info in gen_expression_tree ctx true expr "__mClass->__meta__ = " ";\n"; | _ -> () ); PMap.iter (fun _ constructor -> let name = constructor.ef_name in match constructor.ef_type with | TFun (_,_) -> () | _ -> output_cpp ( "hx::Static(" ^ (keyword_remap name) ^ ") = hx::CreateEnum< " ^ class_name ^ " >(" ^ (str name) ^ "," ^ (string_of_int constructor.ef_index) ^ ");\n" ) ) enum_def.e_constrs; output_cpp ("}\n\n"); output_cpp "\n"; gen_close_namespace output_cpp class_path; cpp_file#close; let h_file = new_header_file common_ctx common_ctx.file class_path in let super = "hx::EnumBase_obj" in let output_h = (h_file#write) in let def_string = join_class_path class_path "_" in ctx.ctx_output <- output_h; begin_header_file output_h def_string; List.iter (gen_forward_decl h_file ) referenced; gen_open_namespace output_h class_path; output_h "\n\n"; output_h ("class " ^ class_name ^ " : public " ^ super ^ "\n"); output_h ("{\n\ttypedef " ^ super ^ " super;\n"); output_h ("\t\ttypedef " ^ class_name ^ " OBJ_;\n"); output_h "\n\tpublic:\n"; output_h ("\t\t" ^ class_name ^ "() {};\n"); output_h ("\t\tHX_DO_ENUM_RTTI;\n"); output_h ("\t\tstatic void __boot();\n"); output_h ("\t\tstatic void __register();\n"); output_h ("\t\t::String GetEnumName( ) const { return " ^ (str (join_class_path class_path ".")) ^ "; }\n" ); output_h ("\t\t::String __ToString() const { return " ^ (str (just_class_name ^ ".") )^ " + tag; }\n\n"); PMap.iter (fun _ constructor -> let name = keyword_remap constructor.ef_name in output_h ( "\t\tstatic " ^ remap_class_name ^ " " ^ name ); match constructor.ef_type with | TFun (args,_) -> output_h ( "(" ^ (gen_tfun_arg_list args) ^");\n"); output_h ( "\t\tstatic Dynamic " ^ name ^ "_dyn();\n"); | _ -> output_h ";\n"; output_h ( "\t\tstatic inline " ^ remap_class_name ^ " " ^ name ^ "_dyn() { return " ^name ^ "; }\n" ); ) enum_def.e_constrs; output_h "};\n\n"; gen_close_namespace output_h class_path; end_header_file output_h def_string; h_file#close; let depend_referenced = find_referenced_types common_ctx (TEnumDecl enum_def) super_deps (Hashtbl.create 0) false true false in depend_referenced;; let list_iteri func in_list = let idx = ref 0 in List.iter (fun elem -> func !idx elem; idx := !idx + 1 ) in_list ;; let has_new_gc_references class_def = match class_def.cl_dynamic with | Some _ -> true | _ -> ( let is_gc_reference field = (should_implement_field field) && (is_data_member field) && match type_string field.cf_type with | "bool" | "int" | "Float" -> false | _ -> true in List.exists is_gc_reference class_def.cl_ordered_fields ) ;; let rec has_gc_references class_def = ( match class_def.cl_super with | Some def when has_gc_references (fst def) -> true | _ -> false ) || has_new_gc_references class_def ;; let rec find_next_super_iteration class_def = match class_def.cl_super with | Some (klass,params) when has_new_gc_references klass -> class_string klass "_obj" params true | Some (klass,_) -> find_next_super_iteration klass | _ -> ""; ;; let has_init_field class_def = match class_def.cl_init with | Some _ -> true | _ -> false;; let is_abstract_impl class_def = match class_def.cl_kind with | KAbstractImpl _ -> true | _ -> false ;; let variable_field field = (match field.cf_expr with | Some { eexpr = TFunction function_def } -> is_dynamic_haxe_method field | _ -> true) ;; let is_readable class_def field = (match field.cf_kind with | Var { v_read = AccNever } when (is_extern_field field) -> false | Var { v_read = AccInline } -> false | Var _ when is_abstract_impl class_def -> false | _ -> true) ;; let is_writable class_def field = (match field.cf_kind with | Var { v_write = AccNever } when (is_extern_field field) -> false | Var { v_read = AccInline } -> false | Var _ when is_abstract_impl class_def -> false | _ -> true) ;; let statics_except_meta class_def = (List.filter (fun static -> static.cf_name <> "__meta__" && static.cf_name <> "__rtti") class_def.cl_ordered_statics);; let has_set_member_field class_def = implement_dynamic_here class_def || ( let reflect_fields = List.filter (reflective class_def) (class_def.cl_ordered_fields) in let reflect_writable = List.filter (is_writable class_def) reflect_fields in List.exists variable_field reflect_writable ) ;; let has_set_static_field class_def = let reflect_fields = List.filter (reflective class_def) (statics_except_meta class_def) in let reflect_writable = List.filter (is_writable class_def) reflect_fields in List.exists variable_field reflect_writable ;; let has_get_fields class_def = implement_dynamic_here class_def || ( let is_data_field field = (match follow field.cf_type with | TFun _ -> false | _ -> true) in List.exists is_data_field class_def.cl_ordered_fields ) ;; let has_get_member_field class_def = implement_dynamic_here class_def || ( let reflect_fields = List.filter (reflective class_def) (class_def.cl_ordered_fields) in List.exists (is_readable class_def) reflect_fields ) ;; let has_get_static_field class_def = let reflect_fields = List.filter (reflective class_def) (statics_except_meta class_def) in List.exists (is_readable class_def) reflect_fields ;; let has_boot_field class_def = List.exists has_field_init (List.filter should_implement_field class_def.cl_ordered_statics); ;; let is_macro meta = Meta.has Meta.Macro meta ;; let access_str a = match a with | AccNormal -> "AccNormal" | AccNo -> "AccNo" | AccNever -> "AccNever" | AccResolve -> "AccResolve" | AccCall -> "AccCall" | AccInline -> "AccInline" | AccRequire(_,_) -> "AccRequire" ;; let generate_class_files common_ctx member_types super_deps constructor_deps class_def file_info inScriptable = let class_path = class_def.cl_path in let nativeGen = has_meta_key class_def.cl_meta Meta.NativeGen in let class_name = (snd class_path) ^ (if nativeGen then "" else "_obj") in let dot_name = join_class_path class_path "." in let smart_class_name = (snd class_path) in (*let cpp_file = new_cpp_file common_ctx.file class_path in*) let cpp_file = new_placed_cpp_file common_ctx class_path in let output_cpp = (cpp_file#write) in let debug = if (has_meta_key class_def.cl_meta Meta.NoDebug) || ( Common.defined common_ctx Define.NoDebug) then 0 else 1 in let scriptable = inScriptable && not class_def.cl_private in let ctx = new_context common_ctx cpp_file debug file_info in ctx.ctx_class_name <- "::" ^ (join_class_path class_def.cl_path "::"); ctx.ctx_class_super_name <- (match class_def.cl_super with | Some (klass, params) -> class_string klass "_obj" params true | _ -> ""); ctx.ctx_class_member_types <- member_types; if (debug>1) then print_endline ("Found class definition:" ^ ctx.ctx_class_name); let ptr_name = "hx::ObjectPtr< " ^ class_name ^ " >" in let constructor_arg_var_list = match class_def.cl_constructor with | Some definition -> (match definition.cf_expr with | Some { eexpr = TFunction function_def } -> List.map (fun (v,o) -> (v.v_name, gen_arg_type_name v.v_name o v.v_type "__o_")) function_def.tf_args; | _ -> (match follow definition.cf_type with | TFun (args,_) -> List.map (fun (a,_,t) -> (a, (type_string t, a)) ) args | _ -> []) ) | _ -> [] in let constructor_type_var_list = List.map snd constructor_arg_var_list in let constructor_var_list = List.map snd constructor_type_var_list in let constructor_type_args = String.concat "," (List.map (fun (t,a) -> t ^ " " ^ a) constructor_type_var_list) in let constructor_args = String.concat "," constructor_var_list in let implement_dynamic = implement_dynamic_here class_def in output_cpp "#include \n\n"; let force_field = scriptable && (has_get_member_field class_def) in let field_integer_dynamic = force_field || (has_field_integer_lookup class_def) in let field_integer_numeric = force_field || (has_field_integer_numeric_lookup class_def) in let all_referenced = find_referenced_types ctx.ctx_common (TClassDecl class_def) super_deps constructor_deps false false scriptable in List.iter ( add_include cpp_file ) all_referenced; (* All interfaces (and sub-interfaces) implemented *) let implemented_hash = Hashtbl.create 0 in List.iter (fun imp -> let rec descend_interface interface = let imp_path = (fst interface).cl_path in let interface_name = "::" ^ (join_class_path_remap imp_path "::" ) in if ( not (Hashtbl.mem implemented_hash interface_name) ) then begin Hashtbl.add implemented_hash interface_name (); List.iter descend_interface (fst interface).cl_implements; end; match (fst interface).cl_super with | Some (interface,params) -> descend_interface (interface,params) | _ -> () in descend_interface imp ) (real_interfaces class_def.cl_implements); let implemented = hash_keys implemented_hash in if (scriptable) then output_cpp "#include \n"; output_cpp ( get_class_code class_def Meta.CppFileCode ); let inc = get_meta_string_path class_def.cl_meta Meta.CppInclude in if (inc<>"") then output_cpp ("#include \"" ^ inc ^ "\"\n"); gen_open_namespace output_cpp class_path; output_cpp "\n"; output_cpp ( get_class_code class_def Meta.CppNamespaceCode ); if (not class_def.cl_interface) && not nativeGen then begin output_cpp ("Void " ^ class_name ^ "::__construct(" ^ constructor_type_args ^ ")\n{\n"); (match class_def.cl_constructor with | Some definition -> (match definition.cf_expr with | Some { eexpr = TFunction function_def } -> if has_meta_key definition.cf_meta Meta.NoDebug then ctx.ctx_debug_level <- 0; if ctx.ctx_debug_level >0 then begin hx_stack_push ctx output_cpp dot_name "new" function_def.tf_expr.epos; output_cpp "HX_STACK_THIS(this)\n"; List.iter (fun (a,(t,o)) -> output_cpp ("HX_STACK_ARG(" ^ (keyword_remap o) ^ ",\"" ^ a ^"\")\n") ) constructor_arg_var_list; end; if (has_default_values function_def.tf_args) then begin generate_default_values ctx function_def.tf_args "__o_"; end; gen_expression_tree ctx false (to_block function_def.tf_expr) "" ";\n"; ctx.ctx_debug_level <- debug; | _ -> () ) | _ -> ()); output_cpp "\treturn null();\n"; output_cpp "}\n\n"; (* Destructor goes in the cpp file so we can "see" the full definition of the member vars *) output_cpp ( "//" ^ class_name ^ "::~" ^ class_name ^ "() { }\n\n"); output_cpp ("Dynamic " ^ class_name ^ "::__CreateEmpty() { return new " ^ class_name ^ "; }\n"); output_cpp (ptr_name ^ " " ^ class_name ^ "::__new(" ^constructor_type_args ^")\n"); let create_result () = output_cpp ("{ " ^ ptr_name ^ " _result_ = new " ^ class_name ^ "();\n"); in create_result (); output_cpp ("\t_result_->__construct(" ^ constructor_args ^ ");\n"); output_cpp ("\treturn _result_;}\n\n"); output_cpp ("Dynamic " ^ class_name ^ "::__Create(hx::DynamicArray inArgs)\n"); create_result (); output_cpp ("\t_result_->__construct(" ^ (array_arg_list constructor_var_list) ^ ");\n"); output_cpp ("\treturn _result_;}\n\n"); if ( (List.length implemented) > 0 ) then begin output_cpp ("hx::Object *" ^ class_name ^ "::__ToInterface(const hx::type_info &inType) {\n"); List.iter (fun interface_name -> output_cpp ("\tif (inType==typeid( " ^ interface_name ^ "_obj)) " ^ "return operator " ^ interface_name ^ "_obj *();\n"); ) implemented; output_cpp ("\treturn super::__ToInterface(inType);\n}\n\n"); List.iter (fun interface_name -> output_cpp (class_name ^ "::operator " ^ interface_name ^ "_obj *()\n\t" ^ "{ return new " ^ interface_name ^ "_delegate_< " ^ class_name ^" >(this); }\n" ); ) implemented; end; end; (match class_def.cl_init with | Some expression -> output_cpp ("void " ^ class_name^ "::__init__() {\n"); hx_stack_push ctx output_cpp dot_name "__init__" expression.epos; gen_expression_tree (new_context common_ctx cpp_file debug file_info) false (to_block expression) "" ""; output_cpp "}\n\n"; | _ -> ()); let statics_except_meta = statics_except_meta class_def in let implemented_fields = List.filter should_implement_field statics_except_meta in let dump_field_name = (fun field -> output_cpp ("\t" ^ (str field.cf_name) ^ ",\n")) in let implemented_instance_fields = List.filter should_implement_field class_def.cl_ordered_fields in List.iter (gen_field ctx class_def class_name smart_class_name dot_name false class_def.cl_interface) class_def.cl_ordered_fields; List.iter (gen_field ctx class_def class_name smart_class_name dot_name true class_def.cl_interface) statics_except_meta; output_cpp "\n"; let override_iteration = (not nativeGen) && (has_new_gc_references class_def) in (* Initialise non-static variables *) if ( (not class_def.cl_interface) && (not nativeGen) ) then begin output_cpp (class_name ^ "::" ^ class_name ^ "()\n{\n"); if (implement_dynamic) then output_cpp "\tHX_INIT_IMPLEMENT_DYNAMIC;\n"; List.iter (fun field -> let remap_name = keyword_remap field.cf_name in match field.cf_expr with | Some { eexpr = TFunction function_def } -> if (is_dynamic_haxe_method field) then output_cpp ("\t" ^ remap_name ^ " = new __default_" ^ remap_name ^ "(this);\n") | _ -> () ) class_def.cl_ordered_fields; output_cpp "}\n\n"; let dump_field_iterator macro field = if (is_data_member field) then begin let remap_name = keyword_remap field.cf_name in output_cpp ("\t" ^ macro ^ "(" ^ remap_name ^ ",\"" ^ field.cf_name^ "\");\n"); (match field.cf_kind with Var { v_read = AccCall } when (is_dynamic_accessor ("get_" ^ field.cf_name) "get" field class_def) -> let name = "get_" ^ field.cf_name in output_cpp ("\t" ^ macro ^ "(" ^ name ^ "," ^ "\"" ^ name ^ "\");\n" ) | _ -> ()); (match field.cf_kind with Var { v_write = AccCall } when (is_dynamic_accessor ("set_" ^ field.cf_name) "set" field class_def) -> let name = "set_" ^ field.cf_name in output_cpp ("\t" ^ macro ^ "(" ^ name ^ "," ^ "\"" ^ name ^ "\");\n" ) | _ -> ()); end in if (override_iteration) then begin let super_needs_iteration = find_next_super_iteration class_def in (* MARK function - explicitly mark all child pointers *) output_cpp ("void " ^ class_name ^ "::__Mark(HX_MARK_PARAMS)\n{\n"); output_cpp ("\tHX_MARK_BEGIN_CLASS(" ^ smart_class_name ^ ");\n"); if (implement_dynamic) then output_cpp "\tHX_MARK_DYNAMIC;\n"; List.iter (dump_field_iterator "HX_MARK_MEMBER_NAME") implemented_instance_fields; (match super_needs_iteration with | "" -> () | super -> output_cpp ("\t" ^ super^"::__Mark(HX_MARK_ARG);\n" ) ); output_cpp "\tHX_MARK_END_CLASS();\n"; output_cpp "}\n\n"; (* Visit function - explicitly visit all child pointers *) output_cpp ("void " ^ class_name ^ "::__Visit(HX_VISIT_PARAMS)\n{\n"); if (implement_dynamic) then output_cpp "\tHX_VISIT_DYNAMIC;\n"; List.iter (dump_field_iterator "HX_VISIT_MEMBER_NAME") implemented_instance_fields; (match super_needs_iteration with | "" -> () | super -> output_cpp ("\t" ^ super ^ "::__Visit(HX_VISIT_ARG);\n") ); output_cpp "}\n\n"; end; let reflect_member_fields = List.filter (reflective class_def) class_def.cl_ordered_fields in let reflect_member_readable = List.filter (is_readable class_def) reflect_member_fields in let reflect_member_writable = List.filter (is_writable class_def) reflect_member_fields in let reflect_write_member_variables = List.filter variable_field reflect_member_writable in let reflect_static_fields = List.filter (reflective class_def) (statics_except_meta) in let reflect_static_readable = List.filter (is_readable class_def) reflect_static_fields in let reflect_static_writable = List.filter (is_writable class_def) reflect_static_fields in let reflect_write_static_variables = List.filter variable_field reflect_static_writable in let dump_quick_field_test fields = if ( (List.length fields) > 0) then begin let len = function (_,l,_) -> l in let sfields = List.sort (fun f1 f2 -> (len f1)-(len f2)) fields in let len_case = ref (-1) in output_cpp "\tswitch(inName.length) {\n"; List.iter (fun (field,l,result) -> if (l <> !len_case) then begin if (!len_case>=0) then output_cpp "\t\tbreak;\n"; output_cpp ("\tcase " ^ (string_of_int l) ^ ":\n"); len_case := l; end; output_cpp ("\t\tif (HX_FIELD_EQ(inName,\"" ^ (Ast.s_escape field) ^ "\") ) { " ^ result ^ " }\n"); ) sfields; output_cpp "\t}\n"; end; in let checkPropCall field = if ( (has_meta_key class_def.cl_meta Meta.NativeProperty) || (has_meta_key field.cf_meta Meta.NativeProperty) || (Common.defined common_ctx Define.ForceNativeProperty) ) then "inCallProp != hx::paccNever" else "inCallProp == hx::paccAlways" in if (has_get_member_field class_def) then begin (* Dynamic "Get" Field function - string version *) output_cpp ("Dynamic " ^ class_name ^ "::__Field(const ::String &inName,hx::PropertyAccess inCallProp)\n{\n"); let get_field_dat = List.map (fun f -> (f.cf_name, String.length f.cf_name, (match f.cf_kind with | Var { v_read = AccCall } when is_extern_field f -> "if (" ^ (checkPropCall f) ^ ") return " ^(keyword_remap ("get_" ^ f.cf_name)) ^ "()" | Var { v_read = AccCall } -> "return " ^ (checkPropCall f) ^ " ? " ^ (keyword_remap ("get_" ^ f.cf_name)) ^ "() : " ^ ((keyword_remap f.cf_name) ^ if (variable_field f) then "" else "_dyn()") | _ -> "return " ^ ((keyword_remap f.cf_name) ^ if (variable_field f) then "" else "_dyn()") ) ^ ";" ) ) in dump_quick_field_test (get_field_dat reflect_member_readable); if (implement_dynamic) then output_cpp "\tHX_CHECK_DYNAMIC_GET_FIELD(inName);\n"; output_cpp ("\treturn super::__Field(inName,inCallProp);\n}\n\n"); (* Dynamic "Get" Field function - int version *) if ( field_integer_numeric || field_integer_dynamic) then begin let dump_static_ids = (fun field -> let remap_name = keyword_remap field.cf_name in output_cpp ("static int __id_" ^ remap_name ^ " = __hxcpp_field_to_id(\"" ^ (field.cf_name) ^ "\");\n"); ) in List.iter dump_static_ids reflect_member_readable; output_cpp "\n\n"; let output_ifield return_type function_name all_fields = output_cpp (return_type ^" " ^ class_name ^ "::" ^ function_name ^ "(int inFieldID)\n{\n"); let dump_field_test = (fun f -> let remap_name = keyword_remap f.cf_name in output_cpp ("\tif (inFieldID==__id_" ^ remap_name ^ ") return " ^ ( if (return_type="Float") then "hx::ToDouble( " else "" ) ^ (match f.cf_kind with | Var { v_read = AccCall } -> (keyword_remap ("get_" ^ f.cf_name)) ^ "()" | _ -> (remap_name ^ if ( variable_field f) then "" else "_dyn()") ) ^ ( if (return_type="Float") then " ) " else "" ) ^ ";\n"); ) in List.iter dump_field_test (List.filter (fun f -> all_fields || (is_numeric_field f)) reflect_member_readable); if (implement_dynamic) then output_cpp "\tHX_CHECK_DYNAMIC_GET_INT_FIELD(inFieldID);\n"; output_cpp ("\treturn super::" ^ function_name ^ "(inFieldID);\n}\n\n"); in if (field_integer_dynamic) then output_ifield "Dynamic" "__IField" true; if (field_integer_numeric) then output_ifield "double" "__INumField" false; end; end; if (has_get_static_field class_def) then begin output_cpp ("bool " ^ class_name ^ "::__GetStatic(const ::String &inName, Dynamic &outValue, hx::PropertyAccess inCallProp)\n{\n"); let get_field_dat = List.map (fun f -> (f.cf_name, String.length f.cf_name, (match f.cf_kind with | Var { v_read = AccCall } when is_extern_field f -> "if (" ^ (checkPropCall f) ^ ") { outValue = " ^(keyword_remap ("get_" ^ f.cf_name)) ^ "(); return true; }" | Var { v_read = AccCall } -> "outValue = " ^ (checkPropCall f) ^ " ? " ^ (keyword_remap ("get_" ^ f.cf_name)) ^ "() : " ^ ((keyword_remap f.cf_name) ^ if (variable_field f) then "" else "_dyn()") ^ "; return true;"; | _ -> "outValue = " ^ ((keyword_remap f.cf_name) ^ (if (variable_field f) then "" else "_dyn()") ^ "; return true; ") ) ) ) in dump_quick_field_test (get_field_dat reflect_static_readable); output_cpp ("\treturn false;\n}\n\n"); end; (* Dynamic "Set" Field function *) if (has_set_member_field class_def) then begin output_cpp ("Dynamic " ^ class_name ^ "::__SetField(const ::String &inName,const Dynamic &inValue,hx::PropertyAccess inCallProp)\n{\n"); let set_field_dat = List.map (fun f -> let default_action = (keyword_remap f.cf_name) ^ "=inValue.Cast< " ^ (type_string f.cf_type) ^ " >();" ^ " return inValue;" in (f.cf_name, String.length f.cf_name, (match f.cf_kind with | Var { v_write = AccCall } -> "if (" ^ (checkPropCall f) ^ ") return " ^ (keyword_remap ("set_" ^ f.cf_name)) ^ "(inValue);" ^ ( if is_extern_field f then "" else default_action ) | _ -> default_action ) ) ) in dump_quick_field_test (set_field_dat reflect_write_member_variables); if (implement_dynamic) then begin output_cpp ("\ttry { return super::__SetField(inName,inValue,inCallProp); }\n"); output_cpp ("\tcatch(Dynamic e) { HX_DYNAMIC_SET_FIELD(inName,inValue); }\n"); output_cpp "\treturn inValue;\n}\n\n"; end else output_cpp ("\treturn super::__SetField(inName,inValue,inCallProp);\n}\n\n"); end; if (has_set_static_field class_def) then begin output_cpp ("bool " ^ class_name ^ "::__SetStatic(const ::String &inName,Dynamic &ioValue,hx::PropertyAccess inCallProp)\n{\n"); let set_field_dat = List.map (fun f -> let default_action = (keyword_remap f.cf_name) ^ "=ioValue.Cast< " ^ (type_string f.cf_type) ^ " >(); return true;" in (f.cf_name, String.length f.cf_name, (match f.cf_kind with | Var { v_write = AccCall } -> "if (" ^ (checkPropCall f) ^ ") ioValue = " ^ (keyword_remap ("set_" ^ f.cf_name)) ^ "(ioValue);" ^ ( if is_extern_field f then "" else " else " ^ default_action ) | _ -> default_action ) ) ) in dump_quick_field_test (set_field_dat reflect_write_static_variables); output_cpp ("\treturn false;\n}\n\n"); end; (* For getting a list of data members (eg, for serialization) *) if (has_get_fields class_def) then begin let append_field = (fun field -> output_cpp ("\toutFields->push(" ^( str field.cf_name )^ ");\n")) in let is_data_field field = (match follow field.cf_type with | TFun _ -> false | _ -> true) in output_cpp ("void " ^ class_name ^ "::__GetFields(Array< ::String> &outFields)\n{\n"); List.iter append_field (List.filter is_data_field class_def.cl_ordered_fields); if (implement_dynamic) then output_cpp "\tHX_APPEND_DYNAMIC_FIELDS(outFields);\n"; output_cpp "\tsuper::__GetFields(outFields);\n"; output_cpp "};\n\n"; end; let storage field = match type_string field.cf_type with | "bool" -> "hx::fsBool" | "int" -> "hx::fsInt" | "Float" -> "hx::fsFloat" | "::String" -> "hx::fsString" | str -> "hx::fsObject" ^ " /*" ^ str ^ "*/ " in let dump_member_storage = (fun field -> output_cpp ("\t{" ^ (storage field) ^ ",(int)offsetof(" ^ class_name ^"," ^ (keyword_remap field.cf_name) ^")," ^ (str field.cf_name) ^ "},\n") ) in let dump_static_storage = (fun field -> output_cpp ("\t{" ^ (storage field) ^ ",(void *) &" ^ class_name ^"::" ^ (keyword_remap field.cf_name) ^"," ^ (str field.cf_name) ^ "},\n") ) in output_cpp "#if HXCPP_SCRIPTABLE\n"; let stored_fields = List.filter is_data_member implemented_instance_fields in if ( (List.length stored_fields) > 0) then begin output_cpp "static hx::StorageInfo sMemberStorageInfo[] = {\n"; List.iter dump_member_storage stored_fields; output_cpp "\t{ hx::fsUnknown, 0, null()}\n};\n"; end else output_cpp "static hx::StorageInfo *sMemberStorageInfo = 0;\n"; let stored_statics = List.filter is_data_member implemented_fields in if ( (List.length stored_statics) > 0) then begin output_cpp "static hx::StaticInfo sStaticStorageInfo[] = {\n"; List.iter dump_static_storage stored_statics; output_cpp "\t{ hx::fsUnknown, 0, null()}\n};\n"; end else output_cpp "static hx::StaticInfo *sStaticStorageInfo = 0;\n"; output_cpp "#endif\n\n"; end; (* cl_interface *) let reflective_members = List.filter (reflective class_def) implemented_instance_fields in let sMemberFields = if List.length reflective_members>0 then begin output_cpp "static ::String sMemberFields[] = {\n"; List.iter dump_field_name reflective_members; output_cpp "\t::String(null()) };\n\n"; "sMemberFields" end else "0 /* sMemberFields */"; in if (not nativeGen) then begin (* Mark static variables as used *) output_cpp "static void sMarkStatics(HX_MARK_PARAMS) {\n"; output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ class_name ^ "::__mClass,\"__mClass\");\n"); List.iter (fun field -> if (is_data_member field) then output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ class_name ^ "::" ^ (keyword_remap field.cf_name) ^ ",\"" ^ field.cf_name ^ "\");\n") ) implemented_fields; output_cpp "};\n\n"; (* Visit static variables *) output_cpp "#ifdef HXCPP_VISIT_ALLOCS\n"; output_cpp "static void sVisitStatics(HX_VISIT_PARAMS) {\n"; output_cpp ("\tHX_VISIT_MEMBER_NAME(" ^ class_name ^ "::__mClass,\"__mClass\");\n"); List.iter (fun field -> if (is_data_member field) then output_cpp ("\tHX_VISIT_MEMBER_NAME(" ^ class_name ^ "::" ^ (keyword_remap field.cf_name) ^ ",\"" ^ field.cf_name ^ "\");\n") ) implemented_fields; output_cpp "};\n\n"; output_cpp "#endif\n\n"; end; let script_type t optional = if optional then "Object" else match type_string t with | "bool" -> "Int" | "int" -> "Int" | "Float" -> "Float" | "::String" -> "String" | "Null" -> "Void" | "Void" -> "Void" | _ -> "Object" in let script_signature t optional = match script_type t optional with | "Bool" -> "b" | "Int" -> "i" | "Float" -> "f" | "String" -> "s" | "Void" -> "v" | _ -> "o" in let script_size_type t optional = match script_type t optional with | "Object" -> "void *" | x -> x in let generate_script_function isStatic field scriptName callName = match follow field.cf_type with | TFun (args,return_type) -> output_cpp ("\nstatic void " ^ scriptName ^ "(hx::CppiaCtx *ctx) {\n"); let ret = script_signature return_type false in if (ret<>"v") then output_cpp ("ctx->return" ^ (script_type return_type false) ^ "("); if isStatic then output_cpp (class_name ^ "::" ^ callName ^ "(") else output_cpp ("((" ^ class_name ^ "*)ctx->getThis())->" ^ callName ^ "("); let (signature,_,_) = List.fold_left (fun (signature,sep,size) (_,opt,t) -> output_cpp (sep ^ "ctx->get" ^ (script_type t opt) ^ "(" ^ size ^ ")"); (signature ^ (script_signature t opt ), ",", (size^"+sizeof(" ^ (script_size_type t opt) ^ ")") ) ) (ret,"","sizeof(void*)") args in output_cpp ")"; if (ret<>"v") then output_cpp (")"); output_cpp (";\n}\n"); signature; | _ -> "" in if (scriptable && not nativeGen) then begin let dump_script_field idx (field,f_args,return_t) = let args = if (class_def.cl_interface) then gen_tfun_interface_arg_list f_args else gen_tfun_arg_list f_args in let names = List.map (fun (n,_,_) -> keyword_remap n) f_args in let return_type = type_string return_t in let ret = if (return_type="Void") then " " else "return " in let name = keyword_remap field.cf_name in let vtable = "__scriptVTable[" ^ (string_of_int (idx+1) ) ^ "] " in let args_varray = (List.fold_left (fun l n -> l ^ ".Add(" ^ n ^ ")") "Array()" names) in output_cpp (" " ^ return_type ^ " " ^ name ^ "( " ^ args ^ " ) { "); output_cpp ("\n\tif (" ^ vtable ^ ") {\n" ); output_cpp ("\t\thx::CppiaCtx *__ctx = hx::CppiaCtx::getCurrent();\n" ); output_cpp ("\t\thx::AutoStack __as(__ctx);\n" ); output_cpp ("\t\t__ctx->pushObject(" ^ (if class_def.cl_interface then "mDelegate.mPtr" else "this" ) ^");\n" ); List.iter (fun (name,opt, t ) -> output_cpp ("\t\t__ctx->push" ^ (script_type t opt) ^ "(" ^ (keyword_remap name) ^ ");\n" ); ) f_args; output_cpp ("\t\t" ^ ret ^ "__ctx->run" ^ (script_type return_t false) ^ "(" ^ vtable ^ ");\n" ); output_cpp ("\t} else " ^ ret ); if (class_def.cl_interface) then begin output_cpp (" mDelegate->__Field(HX_CSTRING(\"" ^ field.cf_name ^ "\"), hx::paccNever)"); if (List.length names <= 5) then output_cpp ("->__run(" ^ (String.concat "," names) ^ ");") else output_cpp ("->__Run(" ^ args_varray ^ ");"); end else output_cpp (class_name ^ "::" ^ name ^ "(" ^ (String.concat "," names)^ ");"); output_cpp ("return null(); }\n"); if (class_def.cl_interface) then begin output_cpp (" Dynamic " ^ name ^ "_dyn() { return mDelegate->__Field(HX_CSTRING(\"" ^ field.cf_name ^ "\"), hx::paccNever); }\n\n"); end in let not_toString = fun (field,args,_) -> field.cf_name<>"toString" || class_def.cl_interface in let functions = List.filter not_toString (all_virtual_functions class_def) in let new_sctipt_functions = List.filter (fun (f,_,_) -> not (is_override class_def f.cf_name) ) functions in let sctipt_name = class_name ^ "__scriptable" in output_cpp ("class " ^ sctipt_name ^ " : public " ^ class_name ^ " {\n" ); output_cpp (" typedef "^sctipt_name ^" __ME;\n"); output_cpp (" typedef "^class_name ^" super;\n"); let has_funky_toString = List.exists (fun f -> f.cf_name="toString") class_def.cl_ordered_statics || List.exists (fun f -> f.cf_name="toString" && field_arg_count f <> 0) class_def.cl_ordered_fields in let super_string = if has_funky_toString then class_name ^ "::super" else class_name in output_cpp (" typedef "^ super_string ^" __superString;\n"); if (class_def.cl_interface) then output_cpp (" HX_DEFINE_SCRIPTABLE_INTERFACE\n") else begin output_cpp (" HX_DEFINE_SCRIPTABLE(HX_ARR_LIST" ^ (string_of_int (List.length constructor_var_list) ) ^ ")\n"); if (not implement_dynamic) then output_cpp "\tHX_DEFINE_SCRIPTABLE_DYNAMIC;\n"; end; list_iteri dump_script_field functions; output_cpp ("};\n\n"); if (List.length new_sctipt_functions) > 0 then begin let sigs = Hashtbl.create 0 in List.iter (fun (f,_,_) -> let s = generate_script_function false f ("__s_" ^f.cf_name) (keyword_remap f.cf_name) in Hashtbl.add sigs f.cf_name s ) new_sctipt_functions; output_cpp "static hx::ScriptNamedFunction __scriptableFunctions[] = {\n"; List.iter (fun (f,_,_) -> let s = try Hashtbl.find sigs f.cf_name with Not_found -> "v" in output_cpp (" hx::ScriptNamedFunction(\"" ^ f.cf_name ^ "\",__s_" ^ f.cf_name ^ ",\"" ^ s ^ "\"),\n" ) ) new_sctipt_functions; output_cpp " hx::ScriptNamedFunction(0,0,0) };\n"; end else output_cpp "static hx::ScriptNamedFunction *__scriptableFunctions = 0;\n"; end; let class_name_text = join_class_path class_path "." in (* Initialise static in boot function ... *) if (not class_def.cl_interface && not nativeGen) then begin (* Remap the specialised "extern" classes back to the generic names *) output_cpp ("hx::Class " ^ class_name ^ "::__mClass;\n\n"); if (scriptable) then begin (match class_def.cl_constructor with | Some field -> let signature = generate_script_function false field "__script_construct_func" "__construct" in output_cpp ("hx::ScriptFunction " ^ class_name ^ "::__script_construct(__script_construct_func,\"" ^ signature ^ "\");\n"); | _ -> output_cpp ("hx::ScriptFunction " ^ class_name ^ "::__script_construct(0,0);\n"); ); end; let reflective_statics = List.filter (reflective class_def) implemented_fields in let sStaticFields = if List.length reflective_statics > 0 then begin output_cpp "static ::String sStaticFields[] = {\n"; List.iter dump_field_name reflective_statics; output_cpp "\t::String(null()) };\n\n"; "sStaticFields"; end else "0 /* sStaticFields */" in output_cpp ("void " ^ class_name ^ "::__register()\n{\n"); output_cpp ("\thx::Static(__mClass) = new hx::Class_obj();\n"); output_cpp ("\t__mClass->mName = " ^ (str class_name_text) ^ ";\n"); output_cpp ("\t__mClass->mSuper = &super::__SGetClass();\n"); output_cpp ("\t__mClass->mConstructEmpty = &__CreateEmpty;\n"); output_cpp ("\t__mClass->mConstructArgs = &__Create;\n"); output_cpp ("\t__mClass->mGetStaticField = &" ^ ( if (has_get_static_field class_def) then class_name ^ "::__GetStatic;\n" else "hx::Class_obj::GetNoStaticField;\n" )); output_cpp ("\t__mClass->mSetStaticField = &" ^ ( if (has_set_static_field class_def) then class_name ^ "::__SetStatic;\n" else "hx::Class_obj::SetNoStaticField;\n" )); output_cpp ("\t__mClass->mMarkFunc = sMarkStatics;\n"); output_cpp ("\t__mClass->mStatics = hx::Class_obj::dupFunctions(" ^ sStaticFields ^ ");\n"); output_cpp ("\t__mClass->mMembers = hx::Class_obj::dupFunctions(" ^ sMemberFields ^ ");\n"); output_cpp ("\t__mClass->mCanCast = hx::TCanCast< " ^ class_name ^ " >;\n"); output_cpp ("#ifdef HXCPP_VISIT_ALLOCS\n\t__mClass->mVisitFunc = sVisitStatics;\n#endif\n"); output_cpp ("#ifdef HXCPP_SCRIPTABLE\n\t__mClass->mMemberStorageInfo = sMemberStorageInfo;\n#endif\n"); output_cpp ("#ifdef HXCPP_SCRIPTABLE\n\t__mClass->mStaticStorageInfo = sStaticStorageInfo;\n#endif\n"); output_cpp ("\thx::RegisterClass(__mClass->mName, __mClass);\n"); if (scriptable) then output_cpp (" HX_SCRIPTABLE_REGISTER_CLASS(\""^class_name_text^"\"," ^ class_name ^ ");\n"); output_cpp ("}\n\n"); end else if not nativeGen then begin output_cpp ("hx::Class " ^ class_name ^ "::__mClass;\n\n"); output_cpp ("void " ^ class_name ^ "::__register()\n{\n"); output_cpp ("\thx::Static(__mClass) = new hx::Class_obj();\n"); output_cpp ("\t__mClass->mName = " ^ (str class_name_text) ^ ";\n"); output_cpp ("\t__mClass->mSuper = &super::__SGetClass();\n"); output_cpp ("\t__mClass->mMarkFunc = sMarkStatics;\n"); (*output_cpp ("\t__mClass->mStatics = hx::Class_obj::dupFunctions(" ^ sStaticFields ^ ");\n");*) output_cpp ("\t__mClass->mMembers = hx::Class_obj::dupFunctions(" ^ sMemberFields ^ ");\n"); output_cpp ("\t__mClass->mCanCast = hx::TCanCast< " ^ class_name ^ " >;\n"); output_cpp ("#ifdef HXCPP_VISIT_ALLOCS\n\t__mClass->mVisitFunc = sVisitStatics;\n#endif\n"); output_cpp ("\thx::RegisterClass(__mClass->mName, __mClass);\n"); if (scriptable) then output_cpp (" HX_SCRIPTABLE_REGISTER_INTERFACE(\""^class_name_text^"\"," ^ class_name ^ ");\n"); output_cpp ("}\n\n"); end; if (has_boot_field class_def) then begin output_cpp ("void " ^ class_name ^ "::__boot()\n{\n"); List.iter (gen_field_init ctx ) (List.filter should_implement_field class_def.cl_ordered_statics); output_cpp ("}\n\n"); end; gen_close_namespace output_cpp class_path; cpp_file#close; let h_file = new_header_file common_ctx common_ctx.file class_path in let super = match class_def.cl_super with | Some (klass,params) -> (class_string klass "_obj" params true) | _ when nativeGen -> "" | _ -> if (class_def.cl_interface) then "hx::Interface" else "hx::Object" in let output_h = (h_file#write) in let def_string = join_class_path class_path "_" in ctx.ctx_output <- output_h; begin_header_file output_h def_string; (* Include the real header file for the super class *) (match class_def.cl_super with | Some super -> let super_path = (fst super).cl_path in h_file#add_include super_path | _ -> () ); (* And any interfaces ... *) List.iter (fun imp-> h_file#add_include (fst imp).cl_path) (real_interfaces class_def.cl_implements); (* Only need to foreward-declare classes that are mentioned in the header file (ie, not the implementation) *) let referenced = find_referenced_types ctx.ctx_common (TClassDecl class_def) super_deps (Hashtbl.create 0) true false scriptable in List.iter ( gen_forward_decl h_file ) referenced; output_h ( get_class_code class_def Meta.HeaderCode ); let inc = get_meta_string_path class_def.cl_meta Meta.HeaderInclude in if (inc<>"") then output_h ("#include \"" ^ inc ^ "\"\n"); gen_open_namespace output_h class_path; output_h "\n\n"; output_h ( get_class_code class_def Meta.HeaderNamespaceCode ); let extern_class = Common.defined common_ctx Define.DllExport in let attribs = "HXCPP_" ^ (if extern_class then "EXTERN_" else "") ^ "CLASS_ATTRIBUTES " in if (super="") then begin output_h ("class " ^ attribs ^ " " ^ class_name); output_h "{\n\tpublic:\n"; end else begin output_h ("class " ^ attribs ^ " " ^ class_name ^ " : public " ^ super ); output_h "{\n\tpublic:\n"; output_h ("\t\ttypedef " ^ super ^ " super;\n"); output_h ("\t\ttypedef " ^ class_name ^ " OBJ_;\n"); end; if (not class_def.cl_interface && not nativeGen) then begin output_h ("\t\t" ^ class_name ^ "();\n"); output_h ("\t\tVoid __construct(" ^ constructor_type_args ^ ");\n"); output_h "\n\tpublic:\n"; let new_arg = if (has_gc_references class_def) then "true" else "false" in output_h ("\t\tinline void *operator new( size_t inSize, bool inContainer=" ^ new_arg ^",const char *inName=" ^ (const_char_star class_name_text )^ ")\n" ); output_h ("\t\t\t{ return hx::Object::operator new(inSize,inContainer,inName); }\n" ); output_h ("\t\tstatic " ^ptr_name^ " __new(" ^constructor_type_args ^");\n"); output_h ("\t\tstatic Dynamic __CreateEmpty();\n"); output_h ("\t\tstatic Dynamic __Create(hx::DynamicArray inArgs);\n"); if (scriptable) then output_h ("\t\tstatic hx::ScriptFunction __script_construct;\n"); output_h ("\t\t//~" ^ class_name ^ "();\n\n"); output_h ("\t\tHX_DO_RTTI_ALL;\n"); if (has_get_member_field class_def) then output_h ("\t\tDynamic __Field(const ::String &inString, hx::PropertyAccess inCallProp);\n"); if (has_get_static_field class_def) then output_h ("\t\tstatic bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);\n"); if (has_set_member_field class_def) then output_h ("\t\tDynamic __SetField(const ::String &inString,const Dynamic &inValue, hx::PropertyAccess inCallProp);\n"); if (has_set_static_field class_def) then output_h ("\t\tstatic bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);\n"); if (has_get_fields class_def) then output_h ("\t\tvoid __GetFields(Array< ::String> &outFields);\n"); if (field_integer_dynamic) then output_h "\t\tDynamic __IField(int inFieldID);\n"; if (field_integer_numeric) then output_h "\t\tdouble __INumField(int inFieldID);\n"; if (implement_dynamic) then output_h ("\t\tHX_DECLARE_IMPLEMENT_DYNAMIC;\n"); output_h ("\t\tstatic void __register();\n"); if (override_iteration) then begin output_h ("\t\tvoid __Mark(HX_MARK_PARAMS);\n"); output_h ("\t\tvoid __Visit(HX_VISIT_PARAMS);\n"); end; if ( (List.length implemented) > 0 ) then begin output_h "\t\thx::Object *__ToInterface(const hx::type_info &inType);\n"; List.iter (fun interface_name -> output_h ("\t\toperator " ^ interface_name ^ "_obj *();\n") ) implemented; end; if (has_init_field class_def) then output_h "\t\tstatic void __init__();\n\n"; output_h ("\t\t::String __ToString() const { return " ^ (str smart_class_name) ^ "; }\n\n"); end else if not nativeGen then begin output_h ("\t\tHX_DO_INTERFACE_RTTI;\n"); end; if (has_boot_field class_def) then output_h ("\t\tstatic void __boot();\n"); (match class_def.cl_array_access with | Some t -> output_h ("\t\ttypedef " ^ (type_string t) ^ " __array_access;\n") | _ -> ()); List.iter (gen_member_def ctx class_def true class_def.cl_interface) (List.filter should_implement_field class_def.cl_ordered_statics); if class_def.cl_interface then begin let dumped = ref PMap.empty in let rec dump_def interface = List.iter (fun field -> try ignore (PMap.find field.cf_name !dumped) with Not_found -> begin dumped := PMap.add field.cf_name true !dumped; gen_member_def ctx interface false true field end ) interface.cl_ordered_fields; List.iter (fun impl -> dump_def (fst impl)) (real_interfaces interface.cl_implements); in (* Dump this class, not its super, but also its implements *) dump_def class_def; List.iter (fun impl -> dump_def (fst impl)) (real_interfaces class_def.cl_implements); end else begin List.iter (gen_member_def ctx class_def false false) (List.filter should_implement_field class_def.cl_ordered_fields); end; output_h ( get_class_code class_def Meta.HeaderClassCode ); output_h "};\n\n"; if (class_def.cl_interface && not nativeGen) then begin output_h ("\n\n"); output_h ("template\n"); output_h ("class " ^ smart_class_name ^ "_delegate_ : public " ^ class_name^"\n"); output_h "{\n\tprotected:\n"; output_h ("\t\tIMPL *mDelegate;\n"); output_h "\tpublic:\n"; output_h ("\t\t" ^ smart_class_name ^ "_delegate_(IMPL *inDelegate) : mDelegate(inDelegate) {}\n"); output_h ("\t\thx::Object *__GetRealObject() { return mDelegate; }\n"); output_h ("\t\tvoid __Visit(HX_VISIT_PARAMS) { HX_VISIT_OBJECT(mDelegate); }\n"); let dumped = ref PMap.empty in let rec dump_delegate interface = List.iter (fun field -> try ignore (PMap.find field.cf_name !dumped) with Not_found -> begin dumped := PMap.add field.cf_name true !dumped; match follow field.cf_type, field.cf_kind with | _, Method MethDynamic -> () | TFun (args,return_type), Method _ -> let remap_name = keyword_remap field.cf_name in output_h ( " " ^ (type_string return_type) ^ " " ^ remap_name ^ "( " ); output_h (gen_tfun_interface_arg_list args); output_h (") { return mDelegate->" ^ remap_name^ "("); output_h (String.concat "," (List.map (fun (name,opt,typ) -> (keyword_remap name)) args)); output_h ");}\n"; if reflective interface field then output_h (" Dynamic " ^ remap_name ^ "_dyn() { return mDelegate->" ^ remap_name ^ "_dyn();}\n"); | _ -> () end ) interface.cl_ordered_fields; match interface.cl_super with | Some super -> dump_delegate (fst super) | _ -> (); List.iter (fun impl -> dump_delegate (fst impl)) (real_interfaces interface.cl_implements); in dump_delegate class_def; List.iter (fun impl -> dump_delegate (fst impl)) (real_interfaces class_def.cl_implements); output_h "};\n\n"; end; gen_close_namespace output_h class_path; end_header_file output_h def_string; h_file#close; let depend_referenced = find_referenced_types ctx.ctx_common (TClassDecl class_def) super_deps constructor_deps false true false in depend_referenced;; let write_resources common_ctx = let idx = ref 0 in Hashtbl.iter (fun _ data -> let id = "__res_" ^ (string_of_int !idx) in let resource_file = new_cpp_file common_ctx common_ctx.file (["resources"],id) in resource_file#write "namespace hx {\n"; resource_file#write_i ("unsigned char " ^ id ^ "[] = {\n"); resource_file#write_i "0xff, 0xff, 0xff, 0xff,\n"; for i = 0 to String.length data - 1 do let code = Char.code (String.unsafe_get data i) in resource_file#write (Printf.sprintf "%d," code); if ( (i mod 10) = 9) then resource_file#write "\n"; done; resource_file#write ("0x00 };\n"); incr idx; resource_file#write ("}\n"); resource_file#close; ) common_ctx.resources; let resource_file = new_cpp_file common_ctx common_ctx.file ([],"__resources__") in resource_file#write "#include \n\n"; resource_file#write "namespace hx { \n\n"; idx := 0; Hashtbl.iter (fun _ data -> let id = "__res_" ^ (string_of_int !idx) in resource_file#write_i ("extern unsigned char " ^ id ^ "[];\n"); incr idx; ) common_ctx.resources; resource_file#write "}\n\n"; idx := 0; resource_file#write "hx::Resource __Resources[] ="; resource_file#begin_block; Hashtbl.iter (fun name data -> let id = "__res_" ^ (string_of_int !idx) in resource_file#write_i ("{ " ^ (str name) ^ "," ^ (string_of_int (String.length data)) ^ "," ^ "hx::" ^ id ^ " + 4 },\n"); incr idx; ) common_ctx.resources; resource_file#write_i "{::String(null()),0,0}"; resource_file#end_block_line; resource_file#write ";\n\n"; resource_file#write "namespace hx { Resource *GetResources() { return __Resources; } } \n\n"; resource_file#close;; let write_build_data common_ctx filename classes main_deps boot_deps build_extra extern_src exe_name = let buildfile = open_out filename in let include_prefix = get_include_prefix common_ctx true in let add_class_to_buildfile class_path deps = let cpp = (join_class_path class_path "/") ^ (source_file_extension common_ctx) in output_string buildfile ( " \n" ); let project_deps = List.filter (fun path -> not (is_internal_class path) ) deps in List.iter (fun path-> output_string buildfile (" file | _ -> "include/" ^ include_prefix ^ (join_class_path path "/") ^ ".h" ) ^ "\"/>\n") ) project_deps; output_string buildfile ( " \n" ) in let add_classdef_to_buildfile (class_path, deps, _) = add_class_to_buildfile class_path deps in output_string buildfile "\n"; output_string buildfile ("\n"); output_string buildfile "\n"; output_string buildfile "\n"; List.iter add_classdef_to_buildfile classes; add_class_to_buildfile ( [] , "__boot__") boot_deps; add_class_to_buildfile ( [] , "__files__") []; add_class_to_buildfile ( [] , "__resources__") []; output_string buildfile "\n"; output_string buildfile "\n"; output_string buildfile "\n"; add_class_to_buildfile ( [] , "__lib__") main_deps; output_string buildfile "\n"; output_string buildfile "\n"; output_string buildfile "\n"; add_class_to_buildfile ( [] , "__main__") main_deps; output_string buildfile "\n"; output_string buildfile "\n"; let idx = ref 0 in Hashtbl.iter (fun _ data -> let id = "__res_" ^ (string_of_int !idx) in output_string buildfile ("\n"); incr idx; ) common_ctx.resources; output_string buildfile "\n"; output_string buildfile "\n"; List.iter (fun src -> output_string buildfile ("\n") ) extern_src; output_string buildfile "\n"; output_string buildfile ("\n"); output_string buildfile "\n"; output_string buildfile build_extra; output_string buildfile "\n"; close_out buildfile;; let write_build_options common_ctx filename defines = let writer = cached_source_writer common_ctx filename in PMap.iter ( fun name value -> match name with | "true" | "sys" | "dce" | "cpp" | "debug" -> () | _ -> writer#write (name ^ "="^(escape_command value)^ "\n" ) ) defines; let cmd = Unix.open_process_in "haxelib path hxcpp" in writer#write ("hxcpp=" ^ (Pervasives.input_line cmd)); Pervasives.ignore (Unix.close_process_in cmd); writer#close;; let create_member_types common_ctx = let result = Hashtbl.create 0 in let add_member class_name interface member = match follow member.cf_type, member.cf_kind with | _, Var _ when interface -> () | _, Method MethDynamic when interface -> () | TFun (_,ret), _ -> (*print_endline (class_name ^ "." ^ member.cf_name ^ "=" ^ (type_string ret) );*) Hashtbl.add result (class_name ^ "." ^ member.cf_name) (type_string ret) | _,_ when not interface -> Hashtbl.add result (class_name ^ "." ^ member.cf_name) (type_string member.cf_type) | _ -> () in List.iter (fun object_def -> (match object_def with | TClassDecl class_def -> let class_name = "::" ^ (join_class_path class_def.cl_path "::") in let rec add_all_fields class_def = if class_def.cl_interface then List.iter (fun impl -> add_all_fields (fst impl) ) class_def.cl_implements; (match class_def.cl_super with Some super -> add_all_fields (fst super) | _->();); List.iter (add_member class_name class_def.cl_interface) class_def.cl_ordered_fields; List.iter (add_member class_name class_def.cl_interface) class_def.cl_ordered_statics in add_all_fields class_def | _ -> ( ) ) ) common_ctx.types; result;; (* Builds inheritance tree, so header files can include parents defs. *) let create_super_dependencies common_ctx = let result = Hashtbl.create 0 in List.iter (fun object_def -> (match object_def with | TClassDecl class_def when not class_def.cl_extern -> let deps = ref [] in (match class_def.cl_super with Some super -> if not (fst super).cl_extern then deps := ((fst super).cl_path) :: !deps | _ ->() ); List.iter (fun imp -> if not (fst imp).cl_extern then deps := (fst imp).cl_path :: !deps) (real_interfaces class_def.cl_implements); Hashtbl.add result class_def.cl_path !deps; | TEnumDecl enum_def when not enum_def.e_extern -> Hashtbl.add result enum_def.e_path []; | _ -> () ); ) common_ctx.types; result;; let create_constructor_dependencies common_ctx = let result = Hashtbl.create 0 in List.iter (fun object_def -> (match object_def with | TClassDecl class_def when not class_def.cl_extern -> (match class_def.cl_constructor with | Some func_def -> Hashtbl.add result class_def.cl_path func_def | _ -> () ) | _ -> () ); ) common_ctx.types; result;; (* Exports can now be done with macros and a class list let rec s_type t = let result = match t with | TMono r -> (match !r with | None -> "Dynamic" | Some t -> s_type t) | TEnum (e,tl) -> Ast.s_type_path e.e_path ^ s_type_params tl | TInst (c,tl) -> Ast.s_type_path c.cl_path ^ s_type_params tl | TType (t,tl) -> Ast.s_type_path t.t_path ^ s_type_params tl | TAbstract (abs,pl) when abs.a_impl <> None -> s_type (Abstract.get_underlying_type abs pl); | TAbstract (a,tl) -> Ast.s_type_path a.a_path ^ s_type_params tl | TFun ([],t) -> "Void -> " ^ s_fun t false | TFun (l,t) -> String.concat " -> " (List.map (fun (s,b,t) -> (if b then "?" else "") ^ (""(*if s = "" then "" else s ^ " : "*)) ^ s_fun t true ) l) ^ " -> " ^ s_fun t false | TAnon a -> let fl = PMap.fold (fun f acc -> ((if Meta.has Meta.Optional f.cf_meta then " ?" else " ") ^ f.cf_name ^ " : " ^ s_type f.cf_type) :: acc) a.a_fields [] in "{" ^ (if not (is_closed a) then "+" else "") ^ String.concat "," fl ^ " }" | TDynamic t2 -> "Dynamic" ^ s_type_params (if t == t2 then [] else [t2]) | TLazy f -> s_type (!f()) in if result="Array" then "haxe.io.BytesData" else result and s_fun t void = match follow t with | TFun _ -> "(" ^ s_type t ^ ")" | TAbstract ({ a_path = ([],"Void") },[]) when void -> "(" ^ s_type t ^ ")" | TMono r -> (match !r with | None -> s_type t | Some t -> s_fun t void) | TLazy f -> s_fun (!f()) void | _ -> (s_type t) and s_type_params = function | [] -> "" | l -> "< " ^ String.concat ", " (List.map s_type l) ^ " >" ;; let gen_extern_class common_ctx class_def file_info = let file = new_source_file common_ctx common_ctx.file "extern" ".hx" class_def.cl_path in let path = class_def.cl_path in let rec remove_all_prefix class_def field t = let path = class_def.cl_path in let filterPath = fst path @ [snd path] in let rec remove_prefix t = match t with | TInst ({cl_path=[f],suffix } as cval ,tl) when f=field -> TInst ( { cval with cl_path = ([],suffix) }, List.map remove_prefix tl) | TInst ({cl_path=cpath,suffix } as cval ,tl) when cpath=filterPath -> TInst ( { cval with cl_path = ([],suffix) }, List.map remove_prefix tl) | TInst (cval,tl) -> TInst ( cval, List.map remove_prefix tl) (*| TInst ({cl_path=prefix} as cval ,tl) -> TInst ( { cval with cl_path = ([],snd cval.cl_path) }, List.map (remove_prefix field) tl)*) | t -> Type.map remove_prefix t in let t = remove_prefix t in let superred = (match class_def.cl_super with | Some (super,_) -> remove_all_prefix super field t | _ -> t ) in List.fold_left ( fun t (impl,_) -> remove_all_prefix impl field t ) superred class_def.cl_implements; (* remove_prefix t *) in let params = function [] -> "" | l -> "< " ^ (String.concat "," (List.map (fun (n,t) -> n) l) ^ " >") in let output = file#write in let print_field stat f = let s_type t = s_type (remove_all_prefix class_def f.cf_name t) in let args = function TFun (args,_) -> String.concat "," (List.map (fun (name,opt,t) -> (if opt then "?" else "") ^ name ^":"^ (s_type t)) args) | _ -> "" in let ret = function TFun (_,ret) -> s_type ret | _ -> "Dynamic" in let override = if (is_override class_def f.cf_name ) then "override " else "" in output ("\t" ^ (if stat then "static " else "") ^ (if f.cf_public then "public " else "") ); let s_access mode op name = match mode with | AccNormal -> "default" | AccNo -> "null" | AccNever -> "never" | AccResolve -> "resolve" | AccCall -> op ^ "_" ^ name | AccInline -> "default" | AccRequire (n,_) -> "require " ^ n in (match f.cf_kind, f.cf_name with | Var { v_read = AccInline; v_write = AccNever },_ -> (match f.cf_expr with Some expr -> output ("inline var " ^ f.cf_name ^ ":" ^ (s_type f.cf_type) ^ "=" ); let ctx = (new_extern_context common_ctx file 1 file_info) in gen_expression ctx true expr; | _ -> () ) | Var { v_read = AccNormal; v_write = AccNormal },_ -> output ("var " ^ f.cf_name ^ ":" ^ (s_type f.cf_type)) | Var v,_ -> output ("var " ^ f.cf_name ^ "(" ^ (s_access v.v_read "get" f.cf_name) ^ "," ^ (s_access v.v_write "set" f.cf_name) ^ "):" ^ (s_type f.cf_type)) | Method _, "new" -> output ("function new(" ^ (args f.cf_type) ^ "):Void") | Method MethDynamic, _ -> output ("dynamic function " ^ f.cf_name ^ (params f.cf_params) ^ "(" ^ (args f.cf_type) ^ "):" ^ (ret f.cf_type) ) | Method _, _ -> output (override ^ "function " ^ f.cf_name ^ (params f.cf_params) ^ "(" ^ (args f.cf_type) ^ "):" ^ (ret f.cf_type) ) ); output ";\n\n"; in let s_type t = s_type (remove_all_prefix class_def "*" t) in let c = class_def in output ( "package " ^ (String.concat "." (fst path)) ^ ";\n" ); output ( "@:include extern " ^ (if c.cl_private then "private " else "") ^ (if c.cl_interface then "interface" else "class") ^ " " ^ (snd path) ^ (params c.cl_params) ); (match c.cl_super with None -> () | Some (c,pl) -> output (" extends " ^ (s_type (TInst (c,pl))))); List.iter (fun (c,pl) -> output ( " implements " ^ (s_type (TInst (c,pl))))) (real_interfaces c.cl_implements); (match c.cl_dynamic with None -> () | Some t -> output (" implements Dynamic< " ^ (s_type t) ^ " >")); (match c.cl_array_access with None -> () | Some t -> output (" implements ArrayAccess< " ^ (s_type t) ^ " >")); output "{\n"; (match c.cl_constructor with | None -> () | Some f -> print_field false f); let is_public f = f.cf_public in List.iter (print_field false) (List.filter is_public c.cl_ordered_fields); List.iter (print_field true) (List.filter is_public c.cl_ordered_statics); output "}"; output "\n"; file#close ;; let gen_extern_enum common_ctx enum_def file_info = let path = enum_def.e_path in let file = new_source_file common_ctx common_ctx.file "extern" ".hx" path in let output = file#write in let params = function [] -> "" | l -> "< " ^ (String.concat "," (List.map (fun (n,t) -> n) l) ^ " >") in output ( "package " ^ (String.concat "." (fst path)) ^ ";\n" ); output ( "@:include extern " ^ (if enum_def.e_private then "private " else "") ^ " enum " ^ (snd path) ^ (params enum_def.e_params) ); output " {\n"; let sorted_items = List.sort (fun f1 f2 -> (f1.ef_index - f2.ef_index ) ) (pmap_values enum_def.e_constrs) in List.iter (fun constructor -> let name = keyword_remap constructor.ef_name in match constructor.ef_type with | TFun (args,_) -> output ( name ^ "(" ); output ( String.concat "," (List.map (fun (arg,_,t) -> arg ^ ":" ^ (s_type t) ) args) ); output ");\n\n"; | _ -> output ( name ^ ";\n\n" ) ) sorted_items; output "}\n"; file#close ;; *) let is_this expression = match (remove_parens expression).eexpr with | TConst TThis -> true | _ -> false ;; let is_super expression = match (remove_parens expression).eexpr with | TConst TSuper -> true | _ -> false ;; let is_assign_op op = match op with | OpAssign | OpAssignOp _ -> true | _ -> false ;; let rec script_type_string haxe_type = match haxe_type with | TType ({ t_path = ([],"Null") },[t]) -> (match follow t with | TAbstract ({ a_path = [],"Int" },_) | TAbstract ({ a_path = [],"Float" },_) | TAbstract ({ a_path = [],"Bool" },_) | TInst ({ cl_path = [],"Int" },_) | TInst ({ cl_path = [],"Float" },_) | TEnum ({ e_path = [],"Bool" },_) -> "Dynamic" | _ -> script_type_string t) | TInst ({cl_path=[],"Null"},[t]) -> (match follow t with | TAbstract ({ a_path = [],"Int" },_) | TAbstract ({ a_path = [],"Float" },_) | TAbstract ({ a_path = [],"Bool" },_) | TInst ({ cl_path = [],"Int" },_) | TInst ({ cl_path = [],"Float" },_) | TEnum ({ e_path = [],"Bool" },_) -> "Dynamic" | _ -> script_type_string t ) | _ -> match follow haxe_type with | TType ({t_path = [],"Array"},params) -> "Array" | TInst ({cl_path=[],"Array"},params) -> (match params with | [t] -> (match type_string_suff "" t false with | "int" -> "Array.int" | "Float" -> "Array.Float" | "bool" -> "Array.bool" | "::String" -> "Array.String" | "unsigned char" -> "Array.unsigned char" | "Dynamic" -> "Array.Any" | _ -> "Array.Object" ) | _ -> "Array.Object" ) | TAbstract (abs,pl) when abs.a_impl <> None -> script_type_string (Abstract.get_underlying_type abs pl); | _ -> type_string_suff "" haxe_type false ;; type array_of = | ArrayInterface of int | ArrayData of string | ArrayObject | ArrayAny | ArrayNone ;; let is_template_type t = false ;; let rec is_dynamic_in_cppia ctx expr = match expr.eexpr with | TCast(_,None) -> true | _ -> is_dynamic_in_cpp ctx expr ;; type cppia_op = | IaFunction | IaVar | IaToInterface | IaToDynArray | IaToDataArray | IaToInterfaceArray | IaFun | IaCast | IaBlock | IaBreak | IaContinue | IaIsNull | IaNotNull | IaSet | IaCall | IaCallGlobal | IaCallStatic | IaCallMember | IaCallSuper | IaCallThis | IaCallSuperNew | IaCreateEnum | IaADef | IaIf | IaIfElse | IaFStatic | IaFName | IaFThisInst | IaFLink | IaFThisName | IaFEnum | IaThrow | IaArrayI | IaPlusPlus | IaPlusPlusPost | IaMinusMinus | IaMinusMinusPost | IaNeg | IaBitNot | IaLogicNot | IaTVars | IaVarDecl | IaVarDeclI | IaNew | IaReturn | IaRetVal | IaPosInfo | IaObjDef | IaClassOf | IaWhile | IaFor | IaEnumI | IaSwitch | IaTry | IaImplDynamic | IaConstInt | IaConstFloat | IaConstString | IaConstFalse | IaConstTrue | IaConstNull | IaConsThis | IaConstSuper | IaCastInt | IaCastBool | IaInterface | IaClass | IaAccessNormal | IaAccessNot | IaAccessResolve | IaAccessCall | IaEnum | IaInline | IaMain | IaNoMain | IaResources | IaReso | IaNoCast | IaAccessCallNative | IaBinOp of Ast.binop ;; let cppia_op_info = function | IaFunction -> ("FUNCTION", 1) | IaVar -> ("VAR", 2) | IaToInterface -> ("TOINTERFACE", 3) | IaToDynArray -> ("TODYNARRAY", 4) | IaToDataArray -> ("TODATAARRAY", 5) | IaToInterfaceArray -> ("TOINTERFACEARRAY", 6) | IaFun -> ("FUN", 7) | IaCast -> ("CAST", 8) | IaBlock -> ("BLOCK", 9) | IaBreak -> ("BREAK", 10) | IaContinue -> ("CONTINUE", 11) | IaIsNull -> ("ISNULL", 12) | IaNotNull -> ("NOTNULL", 13) | IaSet -> ("SET", 14) | IaCall -> ("CALL", 15) | IaCallGlobal -> ("CALLGLOBAL", 16) | IaCallStatic -> ("CALLSTATIC", 17) | IaCallMember -> ("CALLMEMBER", 18) | IaCallSuper -> ("CALLSUPER", 19) | IaCallThis -> ("CALLTHIS", 20) | IaCallSuperNew -> ("CALLSUPERNEW", 21) | IaCreateEnum -> ("CREATEENUM", 22) | IaADef -> ("ADEF", 23) | IaIf -> ("IF", 24) | IaIfElse -> ("IFELSE", 25) | IaFName -> ("FNAME", 27) | IaFStatic -> ("FSTATIC", 28) | IaFThisInst -> ("FTHISINST", 29) | IaFLink -> ("FLINK", 30) | IaFThisName -> ("FTHISNAME", 31) | IaFEnum -> ("FENUM", 32) | IaThrow -> ("THROW", 33) | IaArrayI -> ("ARRAYI", 34) | IaPlusPlus -> ("++", 35) | IaPlusPlusPost -> ("+++", 36) | IaMinusMinus -> ("--", 37) | IaMinusMinusPost -> ("---", 38) | IaNeg -> ("NEG", 39) | IaBitNot -> ("~", 40) | IaLogicNot -> ("!", 41) | IaTVars -> ("TVARS", 42) | IaVarDecl -> ("VARDECL", 43) | IaVarDeclI -> ("VARDECLI", 44) | IaNew -> ("NEW", 45) | IaReturn -> ("RETURN", 46) | IaRetVal -> ("RETVAL", 47) | IaPosInfo -> ("POSINFO", 48) | IaObjDef -> ("OBJDEF", 49) | IaClassOf -> ("CLASSOF", 50) | IaWhile -> ("WHILE", 51) | IaFor -> ("FOR", 52) | IaEnumI -> ("ENUMI", 53) | IaSwitch -> ("SWITCH", 54) | IaTry -> ("TRY", 55) | IaImplDynamic -> ("IMPLDYNAMIC", 56) | IaConstInt -> ("i", 57) | IaConstFloat -> ("f", 58) | IaConstString -> ("s", 59) | IaConstFalse -> ("false", 60) | IaConstTrue -> ("true", 61) | IaConstNull -> ("NULL", 62) | IaConsThis -> ("THIS", 63) | IaConstSuper -> ("SUPER", 64) | IaCastInt -> ("CASTINT", 65) | IaCastBool -> ("CASTBOOL", 66) | IaInterface -> ("INTERFACE", 67) | IaClass -> ("CLASS", 68) | IaAccessNormal -> ("N", 69) | IaAccessNot -> ("n", 70) | IaAccessResolve -> ("R", 71) | IaAccessCall -> ("C", 72) | IaEnum -> ("ENUM", 73) | IaInline -> ("INLINE", 74) | IaMain -> ("MAIN", 75) | IaNoMain -> ("NOMAIN", 76) | IaResources -> ("RESOURCES", 77) | IaReso -> ("RESO", 78) | IaNoCast -> ("NOCAST", 79) | IaAccessCallNative -> ("V", 80) | IaBinOp OpAdd -> ("+", 101) | IaBinOp OpMult -> ("*", 102) | IaBinOp OpDiv -> ("/", 103) | IaBinOp OpSub -> ("-", 104) | IaBinOp OpAssign -> ("=", 105) | IaBinOp OpEq -> ("==", 106) | IaBinOp OpNotEq -> ("!=", 107) | IaBinOp OpGte -> (">=", 108) | IaBinOp OpLte -> ("<=", 109) | IaBinOp OpGt -> (">", 110) | IaBinOp OpLt -> ("<", 111) | IaBinOp OpAnd -> ("&", 112) | IaBinOp OpOr -> ("|", 113) | IaBinOp OpXor -> ("^", 114) | IaBinOp OpBoolAnd -> ("&&", 115) | IaBinOp OpBoolOr -> ("||", 116) | IaBinOp OpShr -> (">>", 117) | IaBinOp OpUShr -> (">>>", 118) | IaBinOp OpShl -> ("<<", 119) | IaBinOp OpMod -> ("%", 120) | IaBinOp OpInterval -> ("...", 121) | IaBinOp OpArrow -> ("=>", 122) | IaBinOp OpAssignOp OpAdd -> ("+=", 201) | IaBinOp OpAssignOp OpMult -> ("*=", 202) | IaBinOp OpAssignOp OpDiv -> ("/=", 203) | IaBinOp OpAssignOp OpSub -> ("-=", 204) | IaBinOp OpAssignOp OpAnd -> ("&=", 212) | IaBinOp OpAssignOp OpOr -> ("|=", 213) | IaBinOp OpAssignOp OpXor -> ("^=", 214) | IaBinOp OpAssignOp OpBoolAnd -> ("&&=", 215) | IaBinOp OpAssignOp OpBoolOr -> ("||=", 216) | IaBinOp OpAssignOp OpShr -> (">>=", 217) | IaBinOp OpAssignOp OpUShr -> (">>>=", 218) | IaBinOp OpAssignOp OpShl -> ("<<=", 219) | IaBinOp OpAssignOp OpMod -> ("%=", 220) | IaBinOp OpAssignOp OpInterval | IaBinOp OpAssignOp OpAssign | IaBinOp OpAssignOp OpEq | IaBinOp OpAssignOp OpNotEq | IaBinOp OpAssignOp OpGte | IaBinOp OpAssignOp OpLte | IaBinOp OpAssignOp OpGt | IaBinOp OpAssignOp OpLt | IaBinOp OpAssignOp OpAssignOp _ | IaBinOp OpAssignOp OpArrow -> assert false ;; class script_writer common_ctx ctx filename asciiOut = object(this) val debug = asciiOut val indent_str = if asciiOut then "\t" else "" val mutable indent = "" val mutable indents = [] val mutable just_finished_block = false val mutable classCount = 0 val mutable return_type = TMono(ref None) val buffer = Buffer.create 0 val identTable = Hashtbl.create 0 val fileTable = Hashtbl.create 0 val identBuffer = Buffer.create 0 method stringId name = try ( Hashtbl.find identTable name ) with Not_found -> begin let size = Hashtbl.length identTable in Hashtbl.add identTable name size; Buffer.add_string identBuffer ((string_of_int (String.length name)) ^ " " ^ name ^ "\n"); size; end method incClasses = classCount <- classCount +1 method stringText name = (string_of_int (this#stringId name)) ^ " " val typeTable = Hashtbl.create 0 val typeBuffer = Buffer.create 0 method typeId name = let name = if name="::hx::Class" then "::Class" else name in try ( Hashtbl.find typeTable name ) with Not_found -> begin let size = Hashtbl.length typeTable in Hashtbl.add typeTable name size; Buffer.add_string typeBuffer ((string_of_int (String.length name)) ^ " " ^ name ^ "\n"); size; end method write str = if asciiOut then Buffer.add_string buffer str else begin let push i = Buffer.add_char buffer (Char.chr i) in let pushI32 i = push (Int32.to_int (Int32.logand i (Int32.of_int 255))) in List.iter (fun i -> if ((Int32.compare i Int32.zero) >= 0) && ((Int32.compare i (Int32.of_int 254)) < 0) then pushI32 i else if ((Int32.compare i Int32.zero) >= 0) && ((Int32.compare i (Int32.of_int 65536)) < 0) then begin push 254; pushI32 i; pushI32 (Int32.shift_right i 8); end else begin push 255; pushI32 i; pushI32 (Int32.shift_right i 8); pushI32 (Int32.shift_right i 16); pushI32 (Int32.shift_right i 24); end ) (List.map Int32.of_string (Str.split (Str.regexp "[\n\t ]+") str) ); end; just_finished_block <- false method typeTextString typeName = (string_of_int (this#typeId typeName)) ^ " " method typeText typeT = (string_of_int (this#typeId (script_type_string typeT))) ^ " " method writeType typeT = this#write (this#typeText typeT) method boolText value = if value then "1" else "0" method writeBool value = this#write (if value then "1 " else "0 ") method staticText value = if value then "1" else "0" method writeData str = Buffer.add_string buffer str; method wint ival = this#write ((string_of_int ival)^" ") method ident name = this#wint (this#stringId name) method instText clazz = match clazz.cl_path with | ([],"Array") -> string_of_int (this#typeId "Array< ::Dynamic >") ^ " " | _ -> this#typeText (TInst(clazz,[])) method instName clazz = this#write (this#instText clazz) method enumText e = this#typeText (TEnum(e,[])) method enumName e = this#write (this#enumText e) method close = let out_file = open_out_bin filename in output_string out_file (if asciiOut then "CPPIA\n" else "CPPIB\n"); let idents = Buffer.contents identBuffer in output_string out_file ((string_of_int (Hashtbl.length identTable)) ^ "\n"); output_string out_file idents; let types = Buffer.contents typeBuffer in output_string out_file ((string_of_int (Hashtbl.length typeTable)) ^ "\n"); output_string out_file types; output_string out_file ( (string_of_int classCount) ^ "\n" ); let contents = Buffer.contents buffer in output_string out_file contents; close_out out_file method fileId file = try ( Hashtbl.find fileTable file ) with Not_found -> begin let stripped_file = strip_file common_ctx file in let result = this#stringId stripped_file in Hashtbl.add fileTable file result; result; end method constText c = match c with | TInt i -> (this#op IaConstInt) ^ (Printf.sprintf "%ld " i) | TFloat f -> (this#op IaConstFloat) ^ (this#stringText f) | TString s -> (this#op IaConstString) ^ (this#stringText s) | TBool true -> (this#op IaConstTrue) | TBool false -> (this#op IaConstFalse) | TNull -> (this#op IaConstNull) | TThis -> (this#op IaConsThis) | TSuper -> (this#op IaConstSuper) method get_array_type t = match follow t with | TInst ({cl_path=[],"Array"},[param]) -> let typeName = type_string_suff "" param false in (match typeName with | "::String" -> ArrayData "String" | "int" | "Float" | "bool" | "String" | "unsigned char" -> ArrayData typeName | "cpp::ArrayBase" | "Dynamic" -> ArrayAny | _ when is_interface_type param -> ArrayInterface (this#typeId (script_type_string param)) | _ -> ArrayObject ) | TAbstract (abs,pl) when abs.a_impl <> None -> this#get_array_type (Abstract.get_underlying_type abs pl); | _ -> ArrayNone; method pushReturn inType = let oldReturnType = return_type in return_type <- inType; fun () -> return_type <- oldReturnType; method fileText file = string_of_int (this#fileId file) method indent_one = this#write indent_str method push_indent = indents <- indent_str::indents; indent <- String.concat "" indents method pop_indent = match indents with | h::tail -> indents <- tail; indent <- String.concat "" indents | [] -> indent <- "/*?*/"; method write_i x = this#write (indent ^ x) method get_indent = indent method begin_expr = this#push_indent method end_expr = if not just_finished_block then this#write "\n"; this#pop_indent; just_finished_block <- true method op x = match cppia_op_info x with | (name,index) -> (if debug then name else string_of_int index) ^ " " method writeOp o = this#write (this#op o) method writeOpLine o = this#write ((this#op o) ^ "\n") method voidFunc isStatic isDynamic funcName fieldExpression = this#write ( (this#op IaFunction) ^ (this#staticText isStatic) ^ " " ^(this#boolText isDynamic) ^ " " ^(this#stringText funcName) ^ " "); this#write ((this#typeTextString "Void") ^ "0\n"); this#gen_expression fieldExpression method func isStatic isDynamic funcName ret args isInterface fieldExpression = this#write ( (this#op IaFunction) ^ (this#staticText isStatic) ^ " " ^(this#boolText isDynamic) ^ " " ^(this#stringText funcName) ^ " "); this#write ((this#typeText ret) ^ (string_of_int (List.length args)) ^ " "); List.iter (fun (name,opt,typ) -> this#write ( (this#stringText name) ^ (this#boolText opt) ^ " " ^ (this#typeText typ) ^ " " )) args; this#write "\n"; if (not isInterface) then begin match fieldExpression with | Some ({ eexpr = TFunction function_def } as e) -> this#gen_expression e | _ -> print_endline ("Missing function body for " ^ funcName ); end method var readAcc writeAcc isExtern isStatic name varType varExpr = this#write ( (this#op IaVar) ^ (this#staticText isStatic) ^ " " ^ (this#op readAcc) ^ (this#op writeAcc) ^ (this#boolText isExtern) ^ " " ^ (this#stringText name)^ (this#typeText varType) ^ (match varExpr with Some _ -> "1\n" | _ -> "0\n" ) ); match varExpr with | Some expression -> this#gen_expression expression | _ -> () method implDynamic = this#writeOpLine IaImplDynamic; method writeVar v = this#ident v.v_name; this#wint v.v_id; this#writeBool v.v_capture; this#writeType v.v_type; method writeList prefix len = this#write (prefix ^" " ^ (string_of_int (len)) ^ "\n"); method writePos expr = if debug then this#write ( (this#fileText expr.epos.pfile) ^ "\t" ^ (string_of_int (Lexer.get_error_line expr.epos) ) ^ indent); method checkCast toType expr forceCast fromGenExpression= let write_cast text = if (not fromGenExpression) then this#writePos expr; this#write (text ^"\n" ); this#begin_expr; this#gen_expression expr; this#end_expr; true; in let was_cast = if (is_interface_type toType) then begin if (is_dynamic_in_cppia ctx expr) then begin write_cast ( (this#op IaToInterface) ^ (this#typeText toType) ^ " " ^ (this#typeTextString "Dynamic") ) end else if (not (is_matching_interface_type toType expr.etype)) then begin write_cast ( (this#op IaToInterface) ^ (this#typeText toType) ^ " " ^ (this#typeText expr.etype) ) end else false end else begin let get_array_expr_type expr = if is_dynamic_in_cppia ctx expr then ArrayNone else this#get_array_type expr.etype in match (this#get_array_type toType), (get_array_expr_type expr) with | ArrayAny, _ -> false | ArrayObject, ArrayData _ -> write_cast (this#op IaToDynArray) | ArrayData t, ArrayNone | ArrayData t, ArrayObject | ArrayData t, ArrayAny -> write_cast ((this#op IaToDataArray) ^ (this#typeTextString ("Array." ^ t))) | ArrayInterface t, ArrayNone | ArrayInterface t, ArrayAny -> write_cast ((this#op IaToInterfaceArray) ^ (string_of_int t)) | _,_ -> (* a0,a1 -> let arrayString a = match a with | ArrayNone -> "ArrayNone" | ArrayAny -> "ArrayAny" | ArrayObject -> "ArrayObject" | ArrayData _ -> "ArrayData" | ArrayInterface _ -> "ArrayInterface" in this#write ("NOCAST " ^ (arrayString a0) ^ "=" ^ (arrayString a1)); *) false end in if (not was_cast) then begin if (forceCast) then begin let op =match (type_string expr.etype) with | "int" -> IaCastInt | "bool" -> IaCastBool | _ when is_interface_type toType -> IaNoCast | _ -> IaCast in this#writeOpLine op; end; this#gen_expression expr; end method gen_expression expr = let expression = remove_parens expr in this#begin_expr; (*this#write ( (this#fileText expression.epos.pfile) ^ "\t" ^ (string_of_int (Lexer.get_error_line expression.epos) ) ^ indent);*) this#writePos expression; (match expression.eexpr with | TFunction function_def -> this#write ( (this#op IaFun) ^ (this#typeText function_def.tf_type) ^ (string_of_int (List.length function_def.tf_args)) ^ "\n" ); List.iter (fun(arg,init) -> this#write (indent ^ indent_str ); this#writeVar arg; match init with | Some const -> this#write ("1 " ^ (this#constText const) ^ "\n") | _ -> this#write "0\n"; ) function_def.tf_args; let pop = this#pushReturn function_def.tf_type in this#gen_expression function_def.tf_expr; pop (); | TBlock expr_list -> this#writeList (this#op IaBlock) (List.length expr_list); List.iter this#gen_expression expr_list; | TConst const -> this#write (this#constText const) | TBreak -> this#writeOp IaBreak | TContinue -> this#writeOp IaContinue | TBinop (op,e1,e2) when op=OpAssign -> this#writeOpLine IaSet; this#gen_expression e1; this#checkCast e1.etype e2 false false; | TBinop (OpEq ,e1, { eexpr = TConst TNull } ) -> this#writeOpLine IaIsNull; this#gen_expression e1; | TBinop (OpNotEq ,e1, { eexpr = TConst TNull }) -> this#writeOpLine IaNotNull; this#gen_expression e1; | TBinop (OpEq , { eexpr = TConst TNull }, e1) -> this#writeOpLine IaIsNull; this#gen_expression e1; | TBinop (OpNotEq, { eexpr = TConst TNull }, e1) -> this#writeOpLine IaNotNull; this#gen_expression e1; | TBinop (op,e1,e2) -> this#writeOpLine (IaBinOp op); this#gen_expression e1; this#gen_expression e2; | TThrow e -> this#writeOpLine IaThrow; this#gen_expression e; | TArrayDecl expr_list -> this#write ( (this#op IaADef) ^ (this#typeText expression.etype) ^ " " ^(string_of_int (List.length expr_list))^"\n"); List.iter this#gen_expression expr_list; | TIf (e,e1,e2) -> (match e2 with | None -> this#writeOpLine IaIf; this#gen_expression e; this#gen_expression e1; | Some elze -> this#writeOpLine IaIfElse; this#gen_expression e; this#gen_expression e1; this#gen_expression elze; ) | TCall (func, arg_list) -> let argN = (string_of_int (List.length arg_list)) ^ " " in let is_real_function field = match field.cf_kind with | Method MethNormal | Method MethInline-> true | _ -> false; in let gen_call () = (match (remove_parens func).eexpr with | TField ( { eexpr = TLocal { v_name = "__global__" }}, field ) -> this#write ( (this#op IaCallGlobal) ^ (this#stringText (field_name field)) ^ argN ^ "\n"); | TField (obj,FStatic (class_def,field) ) when is_real_function field -> this#write ( (this#op IaCallStatic) ^ (this#instText class_def) ^ " " ^ (this#stringText field.cf_name) ^ argN ^ "\n"); | TField (obj,FInstance (_,_,field) ) when (is_this obj) && (is_real_function field) -> this#write ( (this#op IaCallThis) ^ (this#typeText obj.etype) ^ " " ^ (this#stringText field.cf_name) ^ argN ^ "\n"); | TField (obj,FInstance (_,_,field) ) when is_super obj -> this#write ( (this#op IaCallSuper) ^ (this#typeText obj.etype) ^ " " ^ (this#stringText field.cf_name) ^ argN ^ "\n"); | TField (obj,FInstance (_,_,field) ) when is_real_function field -> this#write ( (this#op IaCallMember) ^ (this#typeText obj.etype) ^ " " ^ (this#stringText field.cf_name) ^ argN ^ "\n"); this#gen_expression obj; | TField (obj,FDynamic (name) ) when (is_internal_member name || (type_string obj.etype = "::String" && name="cca") ) -> this#write ( (this#op IaCallMember) ^ (this#typeText obj.etype) ^ " " ^ (this#stringText name) ^ argN ^ "\n"); this#gen_expression obj; | TConst TSuper -> this#write ((this#op IaCallSuperNew) ^ (this#typeText func.etype) ^ " " ^ argN ^ "\n"); | TField (_,FEnum (enum,field)) -> this#write ((this#op IaCreateEnum) ^ (this#enumText enum) ^ " " ^ (this#stringText field.ef_name) ^ argN ^ "\n"); | _ -> this#write ( (this#op IaCall) ^ argN ^ "\n"); this#gen_expression func; ); let matched_args = match func.etype with | TFun (args,_) -> ( try ( List.iter2 (fun (_,_,protoT) arg -> this#checkCast protoT arg false false) args arg_list; true; ) with Invalid_argument _ -> (*print_endline "Bad count?";*) false ) | _ -> false in if not matched_args then List.iter this#gen_expression arg_list; in (match (remove_parens func).eexpr with | TField(obj,field) when is_array_or_dyn_array obj.etype && (field_name field)="map" -> (match this#get_array_type expression.etype with | ArrayData t -> this#write ( (this#op IaToDataArray) ^ (this#typeTextString ("Array." ^ t)) ^ "\n"); this#begin_expr; this#writePos func; gen_call(); this#end_expr; | ArrayInterface t -> this#write ( (this#op IaToInterfaceArray) ^ (string_of_int t) ^ "\n"); this#begin_expr; this#writePos func; gen_call(); this#end_expr; | _ -> gen_call(); ) | _ -> gen_call(); ); | TField (obj, acc) -> let typeText = this#typeText obj.etype in (match acc with | FDynamic name -> this#write ( (this#op IaFName) ^ typeText ^ " " ^ (this#stringText name) ^ "\n"); this#gen_expression obj; | FStatic (class_def,field) -> this#write ( (this#op IaFStatic) ^ (this#instText class_def) ^ " " ^ (this#stringText field.cf_name) ); | FInstance (_,_,field) when is_this obj -> this#write ( (this#op IaFThisInst) ^ typeText ^ " " ^ (this#stringText field.cf_name) ); | FInstance (_,_,field) -> this#write ( (this#op IaFLink) ^ typeText ^ " " ^ (this#stringText field.cf_name) ^ "\n"); this#gen_expression obj; | FClosure (_,field) when is_this obj -> this#write ( (this#op IaFThisName) ^typeText ^ " " ^ (this#stringText field.cf_name) ^ "\n") | FAnon (field) when is_this obj -> this#write ( (this#op IaFThisName) ^typeText ^ " " ^ (this#stringText field.cf_name) ^ "\n") | FClosure (_,field) | FAnon (field) -> this#write ( (this#op IaFName) ^typeText ^ " " ^ (this#stringText field.cf_name) ^ "\n"); this#gen_expression obj; | FEnum (enum,field) -> this#write ( (this#op IaFEnum) ^ (this#enumText enum) ^ " " ^ (this#stringText field.ef_name) ); ) | TArray (e1, e2) -> this#write ((this#op IaArrayI) ^ (this#typeText e1.etype) ^ "\n"); this#gen_expression e1; this#gen_expression e2; | TUnop (op, flag, e) -> this#writeOpLine (match op,flag with | Increment, Prefix -> IaPlusPlus | Increment, _ -> IaPlusPlusPost | Decrement, Prefix -> IaMinusMinus | Decrement, _ -> IaMinusMinusPost | Not, _ -> IaLogicNot | Neg, _ -> IaNeg | NegBits, _ -> IaBitNot ); this#gen_expression e; (* TODO - lval op-assign local/member/array *) | TLocal var -> this#write ((this#op IaVar) ^ (string_of_int var.v_id) ); | TVar (tvar,optional_init) -> this#write ( (this#op IaTVars) ^ (string_of_int (1)) ^ "\n"); this#write ("\t\t" ^ indent); (match optional_init with | None -> this#writeOp IaVarDecl; this#writeVar tvar; | Some init ->this#writeOp IaVarDeclI; let init = remove_parens init in this#writeVar tvar; this#write (" " ^ (this#typeText init.etype)); this#write "\n"; this#checkCast tvar.v_type init false false); | TNew (clazz,params,arg_list) -> this#write ((this#op IaNew) ^ (this#typeText (TInst(clazz,params))) ^ (string_of_int (List.length arg_list)) ^ "\n"); let rec matched_args clazz = match clazz.cl_constructor, clazz.cl_super with | None, Some super -> matched_args (fst super) | None, _ -> false | Some ctr, _ -> (match ctr.cf_type with | TFun(args,_) -> ( try ( List.iter2 (fun (_,_,protoT) arg -> this#checkCast protoT arg false false) args arg_list; true; ) with Invalid_argument _ -> (*print_endline "Bad count?";*) false ) | _ -> false ) in if not (matched_args clazz) then List.iter this#gen_expression arg_list; | TReturn optval -> (match optval with | None -> this#writeOpLine IaReturn; | Some value -> this#write ( (this#op IaRetVal) ^ (this#typeText value.etype) ^ "\n"); this#checkCast return_type value false false; ) | TObjectDecl ( ("fileName" , { eexpr = (TConst (TString file)) }) :: ("lineNumber" , { eexpr = (TConst (TInt line)) }) :: ("className" , { eexpr = (TConst (TString class_name)) }) :: ("methodName", { eexpr = (TConst (TString meth)) }) :: [] ) -> this#write ( (this#op IaPosInfo) ^ (this#stringText file) ^ (Printf.sprintf "%ld" line) ^ " " ^ (this#stringText class_name) ^ " " ^ (this#stringText meth)) | TObjectDecl values ->this#write ( (this#op IaObjDef) ^ (string_of_int (List.length values))); this#write " "; List.iter (fun (name,_) -> this#write (this#stringText name) ) values; this#write "\n"; List.iter (fun (_,e) -> this#gen_expression e ) values; | TTypeExpr type_expr -> let klass = "::" ^ (join_class_path (t_path type_expr) "::" ) in this#write ((this#op IaClassOf) ^ (string_of_int (this#typeId klass))) | TWhile (e1,e2,flag) -> this#write ( (this#op IaWhile) ^ (if flag=NormalWhile then "1" else "0" ) ^ "\n"); this#gen_expression e1; this#gen_expression e2; | TFor (tvar,init,loop) -> this#writeOp IaFor; this#writeVar tvar; this#write "\n"; this#gen_expression init; this#gen_expression loop; | TEnumParameter (expr,ef,i) -> let enum = match follow ef.ef_type with | TEnum(en,_) | TFun(_,TEnum(en,_)) -> en | _ -> assert false in this#write ( (this#op IaEnumI) ^ (this#typeText (TEnum(enum,[])) ) ^ (string_of_int i) ^ "\n"); this#gen_expression expr; | TSwitch (condition,cases,optional_default) -> this#write ( (this#op IaSwitch) ^ (string_of_int (List.length cases)) ^ " " ^ (match optional_default with None -> "0" | Some _ -> "1") ^ "\n"); this#gen_expression condition; List.iter (fun (cases_list,expression) -> this#writeList ("\t\t\t"^indent) (List.length cases_list); List.iter (fun value -> this#gen_expression value ) cases_list; this#gen_expression expression; ) cases; (match optional_default with None -> () | Some expr -> this#gen_expression expr); | TTry (e,catches) -> this#writeList (this#op IaTry) (List.length catches); this#gen_expression e; List.iter ( fun (tvar,catch_expr) -> this#write ("\t\t\t"^indent); this#writeVar tvar; this#write "\n"; this#gen_expression catch_expr; ) catches; | TCast (cast,None) -> this#checkCast expression.etype cast true true; | TCast (cast,Some _) -> this#checkCast expression.etype cast true true; | TParenthesis _ -> error "Unexpected parens" expression.epos | TMeta(_,_) -> error "Unexpected meta" expression.epos ); this#end_expr; end;; let generate_script_class common_ctx script class_def = script#incClasses; script#writeOp (if class_def.cl_interface then IaInterface else IaClass ); script#instName class_def; (match class_def.cl_super with | None -> script#ident "" | Some (c,_) -> script#instName c); script#wint (List.length class_def.cl_implements); List.iter (fun(c,_) -> script#instName c) class_def.cl_implements; script#write "\n"; (* Looks like some map impl classes have their bodies discarded - not sure best way to filter *) let non_dodgy_function field = class_def.cl_interface || match field.cf_kind, field.cf_expr with | Var _, _ -> true | Method MethDynamic, _ -> true | Method _, Some _ -> true | _ -> false in let ordered_statics = List.filter non_dodgy_function class_def.cl_ordered_statics in let ordered_fields = List.filter non_dodgy_function class_def.cl_ordered_fields in script#write ((string_of_int ( (List.length ordered_fields) + (List.length ordered_statics) + (match class_def.cl_constructor with Some _ -> 1 | _ -> 0 ) + (if (implement_dynamic_here class_def) then 1 else 0) + (match class_def.cl_init with Some _ -> 1 | _ -> 0 ) ) ) ^ "\n"); let generate_field isStatic field = match field.cf_kind, follow field.cf_type with | Var { v_read = AccInline; v_write = AccNever },_ -> script#writeOpLine IaInline; | Var v,_ -> let mode_code mode = match mode with | AccNormal -> IaAccessNormal | AccNo -> IaAccessNot | AccNever -> IaAccessNot | AccResolve -> IaAccessResolve | AccCall -> if ( (has_meta_key class_def.cl_meta Meta.NativeProperty) || (has_meta_key field.cf_meta Meta.NativeProperty) || (Common.defined common_ctx Define.ForceNativeProperty) ) then IaAccessCallNative else IaAccessCall; | AccInline -> IaAccessNormal | AccRequire (_,_) -> IaAccessNormal in let isExtern = is_extern_field field in script#var (mode_code v.v_read) (mode_code v.v_write) isExtern isStatic field.cf_name field.cf_type field.cf_expr | Method MethDynamic, TFun(args,ret) -> script#func isStatic true field.cf_name ret args class_def.cl_interface field.cf_expr | Method _, TFun(args,ret) when field.cf_name="new" -> script#func true false "new" (TInst(class_def,[])) args false field.cf_expr | Method _, TFun (args,ret) -> script#func isStatic false field.cf_name ret args class_def.cl_interface field.cf_expr | Method _, _ -> print_endline ("Unknown method type " ^ (join_class_path class_def.cl_path "." ) ^ "." ^field.cf_name ) in (match class_def.cl_constructor with | Some field -> generate_field true field | _ -> () ); (match class_def.cl_init with | Some expression -> script#voidFunc true false "__init__" expression | _ -> () ); List.iter (generate_field false) ordered_fields; List.iter (generate_field true) ordered_statics; if (implement_dynamic_here class_def) then script#implDynamic; script#write "\n"; ;; let generate_script_enum common_ctx script enum_def meta = script#incClasses; let sorted_items = List.sort (fun f1 f2 -> (f1.ef_index - f2.ef_index ) ) (pmap_values enum_def.e_constrs) in script#writeList ((script#op IaEnum) ^ (script#enumText enum_def)) (List.length sorted_items); List.iter (fun constructor -> let name = script#stringText constructor.ef_name in match constructor.ef_type with | TFun (args,_) -> script#write ( name ^ " " ^ (string_of_int (List.length args)) ); List.iter (fun (arg,_,t) -> script#write ( " " ^ (script#stringText arg) ^ " " ^ (script#typeText t) ) ) args; script#write "\n"; | _ -> script#write ( name ^ " 0\n" ) ) sorted_items; match meta with | Some expr -> script#write "1\n"; script#gen_expression expr | _ -> script#write "0\n"; script#write "\n" ;; let generate_cppia common_ctx = let debug = 1 in let null_file = new source_writer common_ctx ignore (fun () -> () ) in let ctx = new_context common_ctx null_file debug (ref PMap.empty) in ctx.ctx_class_member_types <- create_member_types common_ctx; let script = new script_writer common_ctx ctx common_ctx.file common_ctx.debug in ignore (script#stringId ""); ignore (script#typeId ""); List.iter (fun object_def -> (match object_def with | TClassDecl class_def when class_def.cl_extern -> () (*if (gen_externs) then gen_extern_class common_ctx class_def;*) | TClassDecl class_def -> let is_internal = is_internal_class class_def.cl_path in if (is_internal || (is_macro class_def.cl_meta)) then ( if (debug>1) then print_endline (" internal class " ^ (join_class_path class_def.cl_path ".") )) else begin ctx.ctx_class_name <- "::" ^ (join_class_path class_def.cl_path "::"); generate_script_class common_ctx script class_def end | TEnumDecl enum_def when enum_def.e_extern -> () | TEnumDecl enum_def -> let is_internal = is_internal_class enum_def.e_path in if (is_internal) then (if (debug>1) then print_endline (" internal enum " ^ (join_class_path enum_def.e_path ".") )) else begin let meta = Codegen.build_metadata common_ctx object_def in if (enum_def.e_extern) then (if (debug>1) then print_endline ("external enum " ^ (join_class_path enum_def.e_path ".") )); ctx.ctx_class_name <- "*"; generate_script_enum common_ctx script enum_def meta end | TTypeDecl _ | TAbstractDecl _ -> (* already done *) () ); ) common_ctx.types; (match common_ctx.main with | None -> script#writeOpLine IaNoMain; | Some e -> script#writeOpLine IaMain; script#gen_expression e ); script#write ( (script#op IaResources) ^ (string_of_int (Hashtbl.length common_ctx.resources)) ^ "\n"); Hashtbl.iter (fun name data -> script#write ((script#op IaReso) ^ (script#stringText name) ^ (string_of_int (String.length data)) ^ "\n"); ) common_ctx.resources; Hashtbl.iter (fun _ data -> script#writeData data) common_ctx.resources; script#close ;; (* The common_ctx contains the haxe AST in the "types" field and the resources *) let generate_source common_ctx = make_base_directory common_ctx.file; let debug = 1 in let exe_classes = ref [] in let boot_classes = ref [] in let boot_enums = ref [] in let nonboot_classes = ref [] in let init_classes = ref [] in let file_info = ref PMap.empty in let class_text path = join_class_path path "::" in let member_types = create_member_types common_ctx in let super_deps = create_super_dependencies common_ctx in let constructor_deps = create_constructor_dependencies common_ctx in let main_deps = ref [] in let extern_src = ref [] in let build_xml = ref "" in let scriptable = (Common.defined common_ctx Define.Scriptable) in List.iter (fun object_def -> (match object_def with | TClassDecl class_def when is_extern_class class_def -> build_xml := !build_xml ^ (get_class_code class_def Meta.BuildXml); let source = get_meta_string_path class_def.cl_meta Meta.SourceFile in if (source<>"") then extern_src := source :: !extern_src; | TClassDecl class_def -> let name = class_text class_def.cl_path in let is_internal = is_internal_class class_def.cl_path in if (is_internal || (is_macro class_def.cl_meta)) then ( if (debug>1) then print_endline (" internal class " ^ name )) else begin build_xml := !build_xml ^ (get_class_code class_def Meta.BuildXml); if (has_init_field class_def) then init_classes := class_def.cl_path :: !init_classes; if (has_boot_field class_def) then boot_classes := class_def.cl_path :: !boot_classes else if not (has_meta_key class_def.cl_meta Meta.NativeGen) then nonboot_classes := class_def.cl_path :: !nonboot_classes; let deps = generate_class_files common_ctx member_types super_deps constructor_deps class_def file_info scriptable in exe_classes := (class_def.cl_path, deps, object_def) :: !exe_classes; end | TEnumDecl enum_def when enum_def.e_extern -> () | TEnumDecl enum_def -> let name = class_text enum_def.e_path in let is_internal = is_internal_class enum_def.e_path in if (is_internal) then (if (debug>1) then print_endline (" internal enum " ^ name )) else begin let meta = Codegen.build_metadata common_ctx object_def in if (enum_def.e_extern) then (if (debug>1) then print_endline ("external enum " ^ name )); boot_enums := enum_def.e_path :: !boot_enums; let deps = generate_enum_files common_ctx enum_def super_deps meta file_info in exe_classes := (enum_def.e_path, deps, object_def) :: !exe_classes; end | TTypeDecl _ | TAbstractDecl _ -> (* already done *) () ); ) common_ctx.types; (match common_ctx.main with | None -> generate_dummy_main common_ctx | Some e -> let main_field = { cf_name = "__main__"; cf_type = t_dynamic; cf_expr = Some e; cf_pos = e.epos; cf_public = true; cf_meta = []; cf_overloads = []; cf_doc = None; cf_kind = Var { v_read = AccNormal; v_write = AccNormal; }; cf_params = [] } in let class_def = { null_class with cl_path = ([],"@Main"); cl_ordered_statics = [main_field] } in main_deps := find_referenced_types common_ctx (TClassDecl class_def) super_deps constructor_deps false true false; generate_main common_ctx member_types super_deps class_def file_info ); generate_boot common_ctx !boot_enums !boot_classes !nonboot_classes !init_classes; generate_files common_ctx file_info; write_resources common_ctx; (* Output class info if requested *) if (scriptable || (Common.defined common_ctx Define.DllExport) ) then begin let filename = try let value = Common.defined_value common_ctx Define.DllExport in if value="1" then raise Not_found; value with Not_found -> "export_classes.info" in if (filename <> "") then begin let escape s = let b = Buffer.create 0 in for i = 0 to String.length s - 1 do let c = String.unsafe_get s i in match c with | '\\' -> Buffer.add_char b c; Buffer.add_char b c; | ' ' -> Buffer.add_char b '\\'; Buffer.add_char b 's'; | '\n' -> Buffer.add_char b '\\'; Buffer.add_char b 'n'; | _ -> Buffer.add_char b c; done; Buffer.contents b; in let exeClasses = open_out filename in let out = output_string exeClasses in let outline str = output_string exeClasses (str ^ "\n") in let spath path = (join_class_path path ".") in let rec stype = function | TMono r -> (match !r with None -> "Dynamic" | Some t -> stype t) | TAbstract ({ a_path = ([],"Void") },[]) -> "void" | TAbstract ({ a_path = ([],"Bool") },[]) -> "bool" | TAbstract ({ a_path = ([],"Float") },[]) -> "float" | TAbstract ({ a_path = ([],"Int") },[]) -> "int" | TAbstract( { a_path = ([], "EnumValue") }, _ ) -> "Dynamic" | TEnum (enum,params) -> spath enum.e_path | TInst (klass,params) -> (match klass.cl_path, params with (* Array class *) (*| ([],"Array") when is_dynamic_array_param (List.hd params) -> "Dynamic" *) | _,_ when is_dynamic_type_param klass.cl_kind -> "Dynamic" | ([],"Array"), [t] -> "Array<" ^ (stype t) ^ ">" | (["haxe";"io"],"Unsigned_char__"),_ -> "uint8" | ([],"EnumValue"),_ -> "Dynamic" | ([],"Null"),[t] when cant_be_null t -> "Null<" ^ (stype t) ^ ">" | ([],"Null"),[t] -> (stype t) | _ -> spath klass.cl_path ) | TType (type_def,params) -> (match type_def.t_path, params with | ([],"Null"),[t] when cant_be_null t -> "Null<" ^ (stype t) ^ ">" | ([],"Array"), [t] -> "Array< " ^ (stype (follow t) ) ^ " >" | _,_ -> stype (apply_params type_def.t_params params type_def.t_type) ) | TLazy func -> stype ((!func)()) | TAbstract (abs,pl) when abs.a_impl <> None -> stype (Abstract.get_underlying_type abs pl) | TAbstract (abs,_) -> spath abs.a_path | TFun (args,ret) -> "fun<" ^ (List.fold_left (fun s (_,opt,t) -> s ^ (if opt then "?" else "") ^ (stype t) ^ ",") "" args) ^ (stype ret) ^ ">" | _ -> "Dynamic" in List.iter (fun (name,_,def) -> match def with | TClassDecl class_def -> outline ((if class_def.cl_interface then "interface " else "class ") ^ (spath name) ); (match class_def.cl_super with | Some (super,_) -> outline ("super " ^ (spath super.cl_path) ) | _ -> () ); List.iter ( fun(c,_) -> out ("implements " ^ (spath c.cl_path) ^ "\n") ) class_def.cl_implements; (match class_def.cl_dynamic with None -> () | Some t -> outline ("implementsdynamic " ^ (stype t))); (match class_def.cl_array_access with None -> () | Some t -> outline ("arrayaccess " ^ (stype t))); let args = function | TFun (args,_) -> List.iter (fun (name,opt,t) -> outline ("arg " ^ name ^ (if opt then " ? " else " : ") ^ (stype t) ) ) args; | _ -> () in let ret = function TFun (_,ret) -> stype ret | _ -> "Dynamic" in let print_field stat f = let pub = if f.cf_public then "pub " else "priv " in let stat = pub ^ ( if stat then "s " else "m " ) in (match f.cf_kind, f.cf_name with | Var { v_read = AccInline; v_write = AccNever },_ -> outline ("inlinevar " ^ f.cf_name ^ " " ^ (stype f.cf_type) ) | Var { v_read = AccNormal; v_write = AccNormal },_ -> outline ("var " ^ stat ^ f.cf_name ^ " " ^ (stype f.cf_type) ) | Var v,_ -> let saccess = function | AccNormal -> "v" | AccNo -> "0" | AccNever -> "!" | AccResolve -> "r" | AccCall -> "c" | AccInline -> "i" | AccRequire (_,_) -> "v" in outline ("property " ^ stat ^ (saccess v.v_read) ^ " " ^ (saccess v.v_write) ^ " " ^ f.cf_name ^ " " ^ (stype f.cf_type) ) | Method _, "new" -> outline ("function " ^ stat ^ "new " ^ (ret f.cf_type) ); args f.cf_type | Method MethDynamic, _ -> outline ("dynamicfunction " ^ stat ^ f.cf_name ^ " " ^ (ret f.cf_type) ); args f.cf_type | Method _, _ -> outline ("function " ^ stat ^ f.cf_name ^ " " ^ (ret f.cf_type) ); args f.cf_type ) in (match class_def.cl_constructor with | None -> () | Some f -> print_field false f); List.iter (print_field false) class_def.cl_ordered_fields; List.iter (print_field true) class_def.cl_ordered_statics; | TEnumDecl enum_def -> out ("enum " ^ (spath name) ^ "\n"); let sorted_items = List.sort (fun f1 f2 -> (f1.ef_index - f2.ef_index ) ) (pmap_values enum_def.e_constrs) in List.iter (fun constructor -> outline ("constructor " ^ constructor.ef_name); match constructor.ef_type with | TFun (args,_) -> List.iter (fun (arg,_,t) -> outline ("eparam " ^ arg ^ " " ^ (stype t) ) ) args; | _ -> () ) sorted_items; | _ -> () ) !exe_classes; (* Output file info too *) List.iter ( fun file -> let full_path = Common.get_full_path (try Common.find_file common_ctx file with Not_found -> file) in out ("file " ^ (escape file) ^ " " ^ (escape full_path) ^"\n") ) ( List.sort String.compare ( pmap_keys !file_info) ); close_out exeClasses; end; end; let output_name = match common_ctx.main_class with | Some path -> (snd path) | _ -> "output" in write_build_data common_ctx (common_ctx.file ^ "/Build.xml") !exe_classes !main_deps (!boot_enums@ !boot_classes) !build_xml !extern_src output_name; let cmd_defines = ref "" in PMap.iter ( fun name value -> match name with | "true" | "sys" | "dce" | "cpp" | "debug" -> () | _ -> cmd_defines := !cmd_defines ^ " -D" ^ name ^ "=\"" ^ (escape_command value) ^ "\"" ) common_ctx.defines; write_build_options common_ctx (common_ctx.file ^ "/Options.txt") common_ctx.defines; if ( not (Common.defined common_ctx Define.NoCompilation) ) then begin let old_dir = Sys.getcwd() in Sys.chdir common_ctx.file; let cmd = ref "haxelib run hxcpp Build.xml haxe" in if (common_ctx.debug) then cmd := !cmd ^ " -Ddebug"; cmd := !cmd ^ !cmd_defines; cmd := List.fold_left (fun cmd path -> cmd ^ " -I\"" ^ (escape_command path) ^ "\"" ) !cmd common_ctx.class_path; print_endline !cmd; if common_ctx.run_command !cmd <> 0 then failwith "Build failed"; Sys.chdir old_dir; end ;; let generate common_ctx = if (Common.defined common_ctx Define.Cppia) then generate_cppia common_ctx else generate_source common_ctx ;; haxe_3.2.1+dfsg.orig/gencs.ml0000664000175000017500000050106412607337712015763 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Gencommon.ReflectionCFs open Ast open Common open Type open Gencommon open Gencommon.SourceWriter open Printf open Option open ExtString let netname_to_hx name = let len = String.length name in let chr = String.get name 0 in String.make 1 (Char.uppercase chr) ^ (String.sub name 1 (len-1)) let rec is_cs_basic_type t = match follow t with | TInst( { cl_path = (["haxe"], "Int32") }, [] ) | TInst( { cl_path = (["haxe"], "Int64") }, [] ) | TAbstract ({ a_path = (["cs"], "Int64") },[]) | TAbstract ({ a_path = (["cs"], "UInt64") },[]) | TAbstract ({ a_path = ([], "Int") },[]) | TAbstract ({ a_path = ([], "Float") },[]) | TAbstract ({ a_path = ([], "Bool") },[]) -> true | TAbstract ({ a_path = (["cs"], "Pointer") },_) -> false | TAbstract _ when like_float t -> true | TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> is_cs_basic_type (Abstract.get_underlying_type a pl) | TEnum(e, _) when not (Meta.has Meta.Class e.e_meta) -> true | TInst(cl, _) when Meta.has Meta.Struct cl.cl_meta -> true | _ -> false (* see http://msdn.microsoft.com/en-us/library/2sk3x8a7(v=vs.71).aspx *) let cs_binops = [Ast.OpAdd, "op_Addition"; Ast.OpSub, "op_Subtraction"; Ast.OpMult, "op_Multiply"; Ast.OpDiv, "op_Division"; Ast.OpMod, "op_Modulus"; Ast.OpXor, "op_ExclusiveOr"; Ast.OpOr, "op_BitwiseOr"; Ast.OpAnd, "op_BitwiseAnd"; Ast.OpBoolAnd, "op_LogicalAnd"; Ast.OpBoolOr, "op_LogicalOr"; Ast.OpAssign, "op_Assign"; Ast.OpShl, "op_LeftShift"; Ast.OpShr, "op_RightShift"; Ast.OpShr, "op_SignedRightShift"; Ast.OpUShr, "op_UnsignedRightShift"; Ast.OpEq, "op_Equality"; Ast.OpGt, "op_GreaterThan"; Ast.OpLt, "op_LessThan"; Ast.OpNotEq, "op_Inequality"; Ast.OpGte, "op_GreaterThanOrEqual"; Ast.OpLte, "op_LessThanOrEqual"; Ast.OpAssignOp Ast.OpMult, "op_MultiplicationAssignment"; Ast.OpAssignOp Ast.OpSub, "op_SubtractionAssignment"; Ast.OpAssignOp Ast.OpXor, "op_ExclusiveOrAssignment"; Ast.OpAssignOp Ast.OpShl, "op_LeftShiftAssignment"; Ast.OpAssignOp Ast.OpMod, "op_ModulusAssignment"; Ast.OpAssignOp Ast.OpAdd, "op_AdditionAssignment"; Ast.OpAssignOp Ast.OpAnd, "op_BitwiseAndAssignment"; Ast.OpAssignOp Ast.OpOr, "op_BitwiseOrAssignment"; (* op_Comma *) Ast.OpAssignOp Ast.OpDiv, "op_DivisionAssignment";] let cs_unops = [Ast.Decrement, "op_Decrement"; Ast.Increment, "op_Increment"; Ast.Neg, "op_UnaryNegation"; Ast.Not, "op_LogicalNot"; Ast.NegBits, "op_OnesComplement"] let binops_names = List.fold_left (fun acc (op,n) -> PMap.add n op acc) PMap.empty cs_binops let unops_names = List.fold_left (fun acc (op,n) -> PMap.add n op acc) PMap.empty cs_unops let get_item = "get_Item" let set_item = "set_Item" let is_tparam t = match follow t with | TInst( { cl_kind = KTypeParameter _ }, [] ) -> true | _ -> false let rec is_int_float gen t = match follow (gen.greal_type t) with | TInst( { cl_path = (["haxe"], "Int32") }, [] ) | TAbstract ({ a_path = ([], "Int") },[]) | TAbstract ({ a_path = ([], "Float") },[]) -> true | TAbstract _ when like_float t && not (like_i64 t) -> true | TInst( { cl_path = (["haxe"; "lang"], "Null") }, [t] ) -> is_int_float gen t | _ -> false let is_bool t = match follow t with | TAbstract ({ a_path = ([], "Bool") },[]) -> true | _ -> false let is_exactly_bool gen t = match gen.gfollow#run_f t with | TAbstract ({ a_path = ([], "Bool") },[]) -> true | _ -> false let is_dynamic gen t = match follow (gen.greal_type t) with | TDynamic _ -> true | _ -> false let is_pointer gen t = match follow (gen.greal_type t) with | TAbstract( ( {a_path = ["cs"], "Pointer"}, _ ) ) | TInst( {cl_path = ["cs"], "Pointer"}, _ ) -> true | _ -> false let rec is_null t = match t with | TInst( { cl_path = (["haxe"; "lang"], "Null") }, _ ) | TType( { t_path = ([], "Null") }, _ ) -> true | TType( t, tl ) -> is_null (apply_params t.t_params tl t.t_type) | TMono r -> (match !r with | Some t -> is_null t | _ -> false) | TLazy f -> is_null (!f()) | _ -> false let rec get_ptr e = match e.eexpr with | TParenthesis e | TMeta(_,e) | TCast(e,_) -> get_ptr e | TCall( { eexpr = TLocal({ v_name = "__ptr__" }) }, [ e ] ) -> Some e | _ -> None let parse_explicit_iface = let regex = Str.regexp "\\." in let parse_explicit_iface str = let split = Str.split regex str in let rec get_iface split pack = match split with | clname :: fn_name :: [] -> fn_name, (List.rev pack, clname) | pack_piece :: tl -> get_iface tl (pack_piece :: pack) | _ -> assert false in get_iface split [] in parse_explicit_iface let is_string t = match follow t with | TInst( { cl_path = ([], "String") }, [] ) -> true | _ -> false let rec change_md = function | TAbstractDecl(a) when Meta.has Meta.Delegate a.a_meta && not (Meta.has Meta.CoreType a.a_meta) -> change_md (t_to_md a.a_this) | TClassDecl( { cl_kind = KAbstractImpl ({ a_this = TInst(impl,_) } as a) }) when Meta.has Meta.Delegate a.a_meta -> TClassDecl impl | md -> md (* ******************************************* *) (* CSharpSpecificESynf *) (* ******************************************* *) (* Some CSharp-specific syntax filters that must run before ExpressionUnwrap dependencies: It must run before ExprUnwrap, as it may not return valid Expr/Statement expressions It must run before ClassInstance, as it will detect expressions that need unchanged TTypeExpr *) module CSharpSpecificESynf = struct let name = "csharp_specific_e" let priority = solve_deps name [DBefore ExpressionUnwrap.priority; DBefore ClassInstance.priority; DAfter TryCatchWrapper.priority] let get_cl_from_t t = match follow t with | TInst(cl,_) -> cl | _ -> assert false let get_ab_from_t t = match follow t with | TAbstract(ab,_) -> ab | _ -> assert false let traverse gen runtime_cl = let basic = gen.gcon.basic in let uint = match get_type gen ([], "UInt") with | TTypeDecl t -> TType(t, []) | TAbstractDecl a -> TAbstract(a, []) | _ -> assert false in let is_var = alloc_var "__is__" t_dynamic in let name () = match gen.gcurrent_class with | Some cl -> path_s cl.cl_path | _ -> "" in let rec run e = match e.eexpr with (* Std.is() *) | TCall( { eexpr = TField( _, FStatic({ cl_path = ([], "Std") }, { cf_name = "is" })) }, [ obj; { eexpr = TTypeExpr(TClassDecl { cl_path = [], "Dynamic" } | TAbstractDecl { a_path = [], "Dynamic" }) }] ) -> Type.map_expr run e | TCall( { eexpr = TField( _, FStatic({ cl_path = ([], "Std") }, { cf_name = "is"}) ) }, [ obj; { eexpr = TTypeExpr(md) }] ) -> let md = change_md md in let mk_is obj md = { e with eexpr = TCall( { eexpr = TLocal is_var; etype = t_dynamic; epos = e.epos }, [ obj; { eexpr = TTypeExpr md; etype = t_dynamic (* this is after all a syntax filter *); epos = e.epos } ] ) } in let mk_or a b = { eexpr = TBinop(Ast.OpBoolOr, a, b); etype = basic.tbool; epos = e.epos } in let wrap_if_needed obj f = (* introduce temp variable for complex expressions *) match obj.eexpr with | TLocal(v) -> f obj | _ -> let var = mk_temp gen "is" obj.etype in let added = { obj with eexpr = TVar(var, Some(obj)); etype = basic.tvoid } in let local = mk_local var obj.epos in { eexpr = TBlock([ added; f local ]); etype = basic.tbool; epos = e.epos } in let obj = run obj in (match follow_module follow md with | TAbstractDecl{ a_path = ([], "Float") } when name() <> "haxe.lang.Runtime" -> (* on the special case of seeing if it is a Float, we need to test if both it is a float and if it is an Int *) let mk_is local = (* we check if it float or int or uint *) let eisint = mk_is local (TAbstractDecl (get_ab_from_t basic.tint)) in let eisuint = mk_is local (TAbstractDecl (get_ab_from_t uint)) in let eisfloat = mk_is local md in mk_paren (mk_or eisfloat (mk_or eisint eisuint)) in wrap_if_needed obj mk_is | TAbstractDecl{ a_path = ([], "Int") } when name() <> "haxe.lang.Runtime" -> (* int can be stored in double variable because of anonymous functions, check that case *) let mk_isint_call local = { eexpr = TCall( mk_static_field_access_infer runtime_cl "isInt" e.epos [], [ local ] ); etype = basic.tbool; epos = e.epos } in let mk_is local = let eisint = mk_is local (TAbstractDecl (get_ab_from_t basic.tint)) in let eisuint = mk_is local (TAbstractDecl (get_ab_from_t uint)) in mk_paren (mk_or (mk_or eisint eisuint) (mk_isint_call local)) in wrap_if_needed obj mk_is | TAbstractDecl{ a_path = ([], "UInt") } when name() <> "haxe.lang.Runtime" -> (* uint can be stored in double variable because of anonymous functions, check that case *) let mk_isuint_call local = { eexpr = TCall( mk_static_field_access_infer runtime_cl "isUInt" e.epos [], [ local ] ); etype = basic.tbool; epos = e.epos } in let mk_is local = let eisuint = mk_is local (TAbstractDecl (get_ab_from_t uint)) in mk_paren (mk_or eisuint (mk_isuint_call local)) in wrap_if_needed obj mk_is | _ -> mk_is obj md ) (* end Std.is() *) | TBinop( Ast.OpUShr, e1, e2 ) -> mk_cast e.etype { e with eexpr = TBinop( Ast.OpShr, mk_cast uint (run e1), run e2 ) } | TBinop( Ast.OpAssignOp Ast.OpUShr, e1, e2 ) -> let mk_ushr local = { e with eexpr = TBinop(Ast.OpAssign, local, run { e with eexpr = TBinop(Ast.OpUShr, local, run e2) }) } in let mk_local obj = let var = mk_temp gen "opUshr" obj.etype in let added = { obj with eexpr = TVar(var, Some(obj)); etype = basic.tvoid } in let local = mk_local var obj.epos in local, added in let e1 = run e1 in let ret = match e1.eexpr with | TField({ eexpr = TLocal _ }, _) | TField({ eexpr = TTypeExpr _ }, _) | TArray({ eexpr = TLocal _ }, _) | TLocal(_) -> mk_ushr e1 | TField(fexpr, field) -> let local, added = mk_local fexpr in { e with eexpr = TBlock([ added; mk_ushr { e1 with eexpr = TField(local, field) } ]); } | TArray(ea1, ea2) -> let local, added = mk_local ea1 in { e with eexpr = TBlock([ added; mk_ushr { e1 with eexpr = TArray(local, ea2) } ]); } | _ -> (* invalid left-side expression *) assert false in ret | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* CSharpSpecificSynf *) (* ******************************************* *) (* Some CSharp-specific syntax filters that can run after ExprUnwrap dependencies: Runs after ExprUnwrap *) module CSharpSpecificSynf = struct let name = "csharp_specific" let priority = solve_deps name [ DAfter ExpressionUnwrap.priority; DAfter ObjectDeclMap.priority; DAfter ArrayDeclSynf.priority; DAfter HardNullableSynf.priority ] let get_cl_from_t t = match follow t with | TInst(cl,_) -> cl | _ -> assert false let is_tparam t = match follow t with | TInst( { cl_kind = KTypeParameter _ }, _ ) -> true | _ -> false let traverse gen runtime_cl = let basic = gen.gcon.basic in let tchar = match ( get_type gen (["cs"], "Char16") ) with | TTypeDecl t -> TType(t,[]) | TAbstractDecl a -> TAbstract(a,[]) | _ -> assert false in let string_ext = get_cl ( get_type gen (["haxe";"lang"], "StringExt")) in let is_string t = match follow t with | TInst({ cl_path = ([], "String") }, []) -> true | _ -> false in let clstring = match basic.tstring with | TInst(cl,_) -> cl | _ -> assert false in let ti64 = match ( get_type gen (["cs"], "Int64") ) with | TTypeDecl t -> TType(t,[]) | TAbstractDecl a -> TAbstract(a,[]) | _ -> assert false in let boxed_ptr = if Common.defined gen.gcon Define.Unsafe then get_cl (get_type gen (["haxe";"lang"], "BoxedPointer")) (* get_abstract (get_type gen (["cs"],"Pointer")) *) else null_class in let is_struct t = (* not basic type *) match follow t with | TInst(cl, _) when Meta.has Meta.Struct cl.cl_meta -> true | _ -> false in let is_cl t = match gen.greal_type t with | TInst ( { cl_path = (["System"], "Type") }, [] ) -> true | _ -> false in let name () = match gen.gcurrent_class with | Some cl -> path_s cl.cl_path | _ -> "" in let rec run e = match e.eexpr with (* Std.int() *) | TCall( { eexpr = TField( _, FStatic({ cl_path = ([], "Std") }, { cf_name = "int" }) ) }, [obj] ) -> run (mk_cast basic.tint obj) (* end Std.int() *) (* TODO: change cf_name *) | TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = "length" })) -> { e with eexpr = TField(run ef, FDynamic "Length") } | TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = "toLowerCase" })) -> { e with eexpr = TField(run ef, FDynamic "ToLowerInvariant") } | TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = "toUpperCase" })) -> { e with eexpr = TField(run ef, FDynamic "ToUpperInvariant") } | TCall( { eexpr = TField(_, FStatic({ cl_path = [], "String" }, { cf_name = "fromCharCode" })) }, [cc] ) -> { e with eexpr = TNew(get_cl_from_t basic.tstring, [], [mk_cast tchar (run cc); mk_int gen 1 cc.epos]) } | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = ("charAt" as field) })) }, args ) | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = ("charCodeAt" as field) })) }, args ) | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = ("indexOf" as field) })) }, args ) | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = ("lastIndexOf" as field) })) }, args ) | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = ("split" as field) })) }, args ) | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = ("substring" as field) })) }, args ) | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = ("substr" as field) })) }, args ) -> { e with eexpr = TCall(mk_static_field_access_infer string_ext field e.epos [], [run ef] @ (List.map run args)) } | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, { cf_name = ("toString") })) }, [] ) -> run ef | TNew( { cl_path = ([], "String") }, [], [p] ) -> run p (* new String(myString) -> myString *) | TCast(expr, _) when like_float expr.etype && is_pointer gen e.etype -> let expr = run expr in mk_cast e.etype (mk_cast ti64 expr) | TCast(expr, _) when is_dynamic gen expr.etype && is_pointer gen e.etype -> (match get_ptr expr with | None -> (* unboxing *) let expr = run expr in mk_cast e.etype (mk_field_access gen (mk_cast (TInst(boxed_ptr,[])) expr) "value" e.epos) | Some e -> run e) | TCast(expr, _) when is_pointer gen expr.etype && is_dynamic gen e.etype -> (match get_ptr expr with | None -> (* boxing *) let expr = run expr in { e with eexpr = TNew(boxed_ptr,[],[expr]) } | Some e -> run e) | TCast(expr, _) when is_bool e.etype && not (is_exactly_bool gen expr.etype) -> { eexpr = TCall( mk_static_field_access_infer runtime_cl "toBool" expr.epos [], [ run expr ] ); etype = basic.tbool; epos = e.epos } | TCast(expr, _) when is_int_float gen e.etype && not (is_cs_basic_type (gen.greal_type expr.etype)) && ( Common.defined gen.gcon Define.EraseGenerics || not (is_null e.etype) ) && name() <> "haxe.lang.Runtime" -> let needs_cast = match gen.gfollow#run_f e.etype with | TInst _ -> false | _ -> true in let fun_name = if like_int e.etype then "toInt" else "toDouble" in let ret = { eexpr = TCall( mk_static_field_access_infer runtime_cl fun_name expr.epos [], [ run expr ] ); etype = basic.tint; epos = expr.epos } in if needs_cast then mk_cast e.etype ret else ret | TCast(expr, _) when (is_string e.etype) && (not (is_string expr.etype)) && name() <> "haxe.lang.Runtime" -> { e with eexpr = TCall( mk_static_field_access_infer runtime_cl "toString" expr.epos [], [run expr] ) } | TBinop( (Ast.OpNotEq as op), e1, e2) | TBinop( (Ast.OpEq as op), e1, e2) when is_string e1.etype || is_string e2.etype -> let mk_ret e = match op with | Ast.OpNotEq -> { e with eexpr = TUnop(Ast.Not, Ast.Prefix, e) } | _ -> e in mk_ret { e with eexpr = TCall({ eexpr = TField(mk_classtype_access clstring e.epos, FDynamic "Equals"); etype = TFun(["obj1",false,basic.tstring; "obj2",false,basic.tstring], basic.tbool); epos = e1.epos }, [ run e1; run e2 ]) } | TCast(expr, _) when is_tparam e.etype && name() <> "haxe.lang.Runtime" && not (Common.defined gen.gcon Define.EraseGenerics) -> let static = mk_static_field_access_infer (runtime_cl) "genericCast" e.epos [e.etype] in { e with eexpr = TCall(static, [mk_local (alloc_var "$type_param" e.etype) expr.epos; run expr]); } | TBinop( (Ast.OpNotEq as op), e1, e2) | TBinop( (Ast.OpEq as op), e1, e2) when is_struct e1.etype || is_struct e2.etype -> let mk_ret e = match op with | Ast.OpNotEq -> { e with eexpr = TUnop(Ast.Not, Ast.Prefix, e) } | _ -> e in mk_ret { e with eexpr = TCall({ eexpr = TField(run e1, FDynamic "Equals"); etype = TFun(["obj1",false,t_dynamic;], basic.tbool); epos = e1.epos }, [ run e2 ]) } | TBinop ( (Ast.OpEq as op), e1, e2 ) | TBinop ( (Ast.OpNotEq as op), e1, e2 ) when is_cl e1.etype && name() <> "haxe.lang.Runtime" -> let static = mk_static_field_access_infer (runtime_cl) "typeEq" e.epos [] in let ret = { e with eexpr = TCall(static, [run e1; run e2]); } in if op = Ast.OpNotEq then { ret with eexpr = TUnop(Ast.Not, Ast.Prefix, ret) } else ret | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; let add_cast_handler gen = let basic = gen.gcon.basic in (* starting to set gtparam_cast. *) (* NativeArray: the most important. *) (* var new_arr = new NativeArray(old_arr.Length); var i = -1; while( i < old_arr.Length ) { new_arr[i] = (TO_T) old_arr[i]; } *) let native_arr_cl = get_cl ( get_type gen (["cs"], "NativeArray") ) in let get_narr_param t = match follow t with | TInst({ cl_path = (["cs"], "NativeArray") }, [param]) -> param | _ -> assert false in let gtparam_cast_native_array e to_t = let old_param = get_narr_param e.etype in let new_param = get_narr_param to_t in let new_v = mk_temp gen "new_arr" to_t in let i = mk_temp gen "i" basic.tint in let old_len = mk_field_access gen e "Length" e.epos in let obj_v = mk_temp gen "obj" t_dynamic in let check_null = {eexpr = TBinop(Ast.OpNotEq, e, null e.etype e.epos); etype = basic.tbool; epos = e.epos} in let block = [ { eexpr = TVar( new_v, Some( { eexpr = TNew(native_arr_cl, [new_param], [old_len] ); etype = to_t; epos = e.epos } ) ); etype = basic.tvoid; epos = e.epos }; { eexpr = TVar(i, Some( mk_int gen (-1) e.epos )); etype = basic.tvoid; epos = e.epos }; { eexpr = TWhile( { eexpr = TBinop( Ast.OpLt, { eexpr = TUnop(Ast.Increment, Ast.Prefix, mk_local i e.epos); etype = basic.tint; epos = e.epos }, old_len ); etype = basic.tbool; epos = e.epos }, { eexpr = TBlock [ { eexpr = TVar(obj_v, Some (mk_cast t_dynamic { eexpr = TArray(e, mk_local i e.epos); etype = old_param; epos = e.epos })); etype = basic.tvoid; epos = e.epos }; { eexpr = TIf({ eexpr = TBinop(Ast.OpNotEq, mk_local obj_v e.epos, null e.etype e.epos); etype = basic.tbool; epos = e.epos }, { eexpr = TBinop( Ast.OpAssign, { eexpr = TArray(mk_local new_v e.epos, mk_local i e.epos); etype = new_param; epos = e.epos }, mk_cast new_param (mk_local obj_v e.epos) ); etype = new_param; epos = e.epos }, None); etype = basic.tvoid; epos = e.epos } ]; etype = basic.tvoid; epos = e.epos }, Ast.NormalWhile ); etype = basic.tvoid; epos = e.epos; }; mk_local new_v e.epos ] in { eexpr = TIf( check_null, { eexpr = TBlock(block); etype = to_t; epos = e.epos; }, Some(null new_v.v_type e.epos) ); etype = to_t; epos = e.epos; } in Hashtbl.add gen.gtparam_cast (["cs"], "NativeArray") gtparam_cast_native_array (* end set gtparam_cast *) (* Type Parameters Handling *) let handle_type_params gen ifaces base_generic = add_cast_handler gen; TypeParams.RealTypeParams.default_config gen (fun e t -> gen.gcon.warning ("Cannot cast to " ^ (debug_type t)) e.epos; mk_cast t e) ifaces base_generic let connecting_string = "?" (* ? see list here http://www.fileformat.info/info/unicode/category/index.htm and here for C# http://msdn.microsoft.com/en-us/library/aa664670.aspx *) let default_package = "cs" (* I'm having this separated as I'm still not happy with having a cs package. Maybe dotnet would be better? *) let strict_mode = ref false (* strict mode is so we can check for unexpected information *) (* reserved c# words *) let reserved = let res = Hashtbl.create 120 in List.iter (fun lst -> Hashtbl.add res lst ("@" ^ lst)) ["abstract"; "as"; "base"; "bool"; "break"; "byte"; "case"; "catch"; "char"; "checked"; "class"; "const"; "continue"; "decimal"; "default"; "delegate"; "do"; "double"; "else"; "enum"; "event"; "explicit"; "extern"; "false"; "finally"; "fixed"; "float"; "for"; "foreach"; "goto"; "if"; "implicit"; "in"; "int"; "interface"; "internal"; "is"; "lock"; "long"; "namespace"; "new"; "null"; "object"; "operator"; "out"; "override"; "params"; "private"; "protected"; "public"; "readonly"; "ref"; "return"; "sbyte"; "sealed"; "short"; "sizeof"; "stackalloc"; "static"; "string"; "struct"; "switch"; "this"; "throw"; "true"; "try"; "typeof"; "uint"; "ulong"; "unchecked"; "unsafe"; "ushort"; "using"; "virtual"; "volatile"; "void"; "while"; "add"; "ascending"; "by"; "descending"; "dynamic"; "equals"; "from"; "get"; "global"; "group"; "into"; "join"; "let"; "on"; "orderby"; "partial"; "remove"; "select"; "set"; "value"; "var"; "where"; "yield"]; res let dynamic_anon = TAnon( { a_fields = PMap.empty; a_status = ref Closed } ) let rec get_class_modifiers meta cl_type cl_access cl_modifiers = match meta with | [] -> cl_type,cl_access,cl_modifiers | (Meta.Struct,[],_) :: meta -> get_class_modifiers meta "struct" cl_access cl_modifiers | (Meta.Protected,[],_) :: meta -> get_class_modifiers meta cl_type "protected" cl_modifiers | (Meta.Internal,[],_) :: meta -> get_class_modifiers meta cl_type "internal" cl_modifiers (* no abstract for now | (":abstract",[],_) :: meta -> get_class_modifiers meta cl_type cl_access ("abstract" :: cl_modifiers) | (":static",[],_) :: meta -> get_class_modifiers meta cl_type cl_access ("static" :: cl_modifiers) TODO: support those types *) | (Meta.Final,[],_) :: meta -> get_class_modifiers meta cl_type cl_access ("sealed" :: cl_modifiers) | (Meta.Unsafe,[],_) :: meta -> get_class_modifiers meta cl_type cl_access ("unsafe" :: cl_modifiers) | _ :: meta -> get_class_modifiers meta cl_type cl_access cl_modifiers let rec get_fun_modifiers meta access modifiers = match meta with | [] -> access,modifiers | (Meta.Protected,[],_) :: meta -> get_fun_modifiers meta "protected" modifiers | (Meta.Internal,[],_) :: meta -> get_fun_modifiers meta "internal" modifiers | (Meta.ReadOnly,[],_) :: meta -> get_fun_modifiers meta access ("readonly" :: modifiers) | (Meta.Unsafe,[],_) :: meta -> get_fun_modifiers meta access ("unsafe" :: modifiers) | (Meta.Volatile,[],_) :: meta -> get_fun_modifiers meta access ("volatile" :: modifiers) | (Meta.Custom ("?prop_impl" | "?event_impl"),[],_) :: meta -> get_fun_modifiers meta "private" modifiers | _ :: meta -> get_fun_modifiers meta access modifiers (* this was the way I found to pass the generator context to be accessible across all functions here *) (* so 'configure' is almost 'top-level' and will have all functions needed to make this work *) let configure gen = let native_arr_cl = get_cl ( get_type gen (["cs"], "NativeArray") ) in gen.gclasses.nativearray <- (fun t -> TInst(native_arr_cl,[t])); gen.gclasses.nativearray_type <- (function TInst(_,[t]) -> t | _ -> assert false); gen.gclasses.nativearray_len <- (fun e p -> mk_field_access gen e "Length" p); let basic = gen.gcon.basic in let erase_generics = Common.defined gen.gcon Define.EraseGenerics in let fn_cl = get_cl (get_type gen (["haxe";"lang"],"Function")) in let null_t = if erase_generics then null_class else (get_cl (get_type gen (["haxe";"lang"],"Null")) ) in let runtime_cl = get_cl (get_type gen (["haxe";"lang"],"Runtime")) in let no_root = Common.defined gen.gcon Define.NoRoot in let change_id name = try Hashtbl.find reserved name with | Not_found -> let ret = String.concat "." (String.nsplit name "#") in List.hd (String.nsplit ret "`") in let change_clname n = change_id n in let change_ns_params_root md ns params = let ns,params = List.fold_left (fun (ns,params) nspart -> try let part, nparams = String.split nspart "`" in let nparams = int_of_string nparams in let rec loop i needed params = if i = nparams then (List.rev needed,params) else loop (i+1) (List.hd params :: needed) (List.tl params) in let needed,params = loop 0 [] params in let part = change_id part in (part ^ "<" ^ (String.concat ", " needed) ^ ">")::ns, params with _ -> (* Invalid_string / int_of_string *) (change_id nspart)::ns, params ) ([],params) ns in List.rev ns,params in let change_ns_params md params ns = if no_root then match ns with | [] when is_hxgen md -> ["haxe";"root"], params | [] -> (match md with | TClassDecl { cl_path = ([],"Std" | [],"Math") } -> ["haxe";"root"], params | TClassDecl { cl_meta = m } when Meta.has Meta.Enum m -> ["haxe";"root"], params | _ -> [], params) | ns when params = [] -> List.map change_id ns, params | ns -> change_ns_params_root md ns params else if params = [] then List.map change_id ns, params else change_ns_params_root md ns params in let change_ns md ns = let ns, _ = change_ns_params md [] ns in ns in let change_field = change_id in let write_id w name = write w (change_id name) in let write_field w name = write w (change_field name) in let ptr = if Common.defined gen.gcon Define.Unsafe then get_abstract (get_type gen (["cs"],"Pointer")) else null_abstract in let is_hxgeneric md = TypeParams.RealTypeParams.is_hxgeneric md in let rec field_is_hxgeneric e = match e.eexpr with | TParenthesis e | TMeta(_,e) -> field_is_hxgeneric e | TField(_, (FStatic(cl,_) | FInstance(cl,_,_)) ) -> (* print_endline ("is_hxgeneric " ^ path_s cl.cl_path ^ " : " ^ string_of_bool (is_hxgeneric (TClassDecl cl))); *) is_hxgeneric (TClassDecl cl) | _ -> true in gen.gfollow#add ~name:"follow_basic" (fun t -> match t with | TAbstract ({ a_path = ([], "Bool") },[]) | TAbstract ({ a_path = ([], "Void") },[]) | TAbstract ({ a_path = ([],"Float") },[]) | TAbstract ({ a_path = ([],"Int") },[]) | TAbstract ({ a_path = [],"UInt" },[]) | TType ({ t_path = ["cs"], "Int64" },[]) | TAbstract ({ a_path = ["cs"], "Int64" },[]) | TType ({ t_path = ["cs"],"UInt64" },[]) | TAbstract ({ a_path = ["cs"],"UInt64" },[]) | TType ({ t_path = ["cs"],"UInt8" },[]) | TAbstract ({ a_path = ["cs"],"UInt8" },[]) | TType ({ t_path = ["cs"],"Int8" },[]) | TAbstract ({ a_path = ["cs"],"Int8" },[]) | TType ({ t_path = ["cs"],"Int16" },[]) | TAbstract ({ a_path = ["cs"],"Int16" },[]) | TType ({ t_path = ["cs"],"UInt16" },[]) | TAbstract ({ a_path = ["cs"],"UInt16" },[]) | TType ({ t_path = ["cs"],"Char16" },[]) | TAbstract ({ a_path = ["cs"],"Char16" },[]) | TType ({ t_path = ["cs"],"Ref" },_) | TAbstract ({ a_path = ["cs"],"Ref" },_) | TType ({ t_path = ["cs"],"Out" },_) | TAbstract ({ a_path = ["cs"],"Out" },_) | TType ({ t_path = [],"Single" },[]) | TAbstract ({ a_path = [],"Single" },[]) -> Some t | TType (({ t_path = [],"Null" } as tdef),[t2]) -> Some (TType(tdef,[follow (gen.gfollow#run_f t2)])) | TAbstract({ a_path = ["cs"],"PointerAccess" },[t]) -> Some (TAbstract(ptr,[t])) | TAbstract (a, pl) when not (Meta.has Meta.CoreType a.a_meta) -> Some (gen.gfollow#run_f ( Abstract.get_underlying_type a pl) ) | TAbstract( { a_path = ([], "EnumValue") }, _ ) | TInst( { cl_path = ([], "EnumValue") }, _ ) -> Some t_dynamic | _ -> None); let module_s_params md params = let md = change_md md in let path = (t_infos md).mt_path in match path with | ([], "String") -> "string", params | ([], "Null") -> path_s (change_ns md ["haxe"; "lang"], change_clname "Null"), params | (ns,clname) -> let ns, params = change_ns_params md params ns in path_s (ns, change_clname clname), params in let module_s md = fst (module_s_params md []) in let ifaces = Hashtbl.create 1 in let ti64 = match ( get_type gen (["cs"], "Int64") ) with | TTypeDecl t -> TType(t,[]) | TAbstractDecl a -> TAbstract(a,[]) | _ -> assert false in let ttype = get_cl ( get_type gen (["System"], "Type") ) in let has_tdyn tl = List.exists (fun t -> match follow t with | TDynamic _ | TMono _ -> true | _ -> false ) tl in let rec real_type t = let t = gen.gfollow#run_f t in let ret = match t with | TAbstract (a, pl) when not (Meta.has Meta.CoreType a.a_meta) -> real_type (Abstract.get_underlying_type a pl) | TAbstract ({ a_path = (["cs";"_Flags"], "EnumUnderlying") }, [t]) -> real_type t | TInst( { cl_path = (["cs";"system"], "String") }, [] ) -> gen.gcon.basic.tstring; | TInst( { cl_path = (["haxe"], "Int32") }, [] ) -> gen.gcon.basic.tint | TInst( { cl_path = (["haxe"], "Int64") }, [] ) -> ti64 | TAbstract( { a_path = [],"Class" }, _ ) | TAbstract( { a_path = [],"Enum" }, _ ) | TAbstract( { a_path = ["haxe";"extern"],"Rest" }, _ ) | TInst( { cl_path = ([], "Class") }, _ ) | TInst( { cl_path = ([], "Enum") }, _ ) -> TInst(ttype,[]) | TInst( ({ cl_kind = KTypeParameter _ } as cl), _ ) when erase_generics && not (Meta.has Meta.NativeGeneric cl.cl_meta) -> t_dynamic | TInst({ cl_kind = KExpr _ }, _) -> t_dynamic | TEnum(_, []) | TInst(_, []) -> t | TInst(cl, params) when has_tdyn params && Hashtbl.mem ifaces cl.cl_path -> TInst(Hashtbl.find ifaces cl.cl_path, []) | TEnum(e, params) -> TEnum(e, List.map (fun _ -> t_dynamic) params) | TInst(cl, params) when Meta.has Meta.Enum cl.cl_meta -> TInst(cl, List.map (fun _ -> t_dynamic) params) | TInst(cl, params) -> TInst(cl, change_param_type (TClassDecl cl) params) | TType({ t_path = ([], "Null") }, [t]) -> (* Null<> handling is a little tricky. It will only change to haxe.lang.Null<> when the actual type is non-nullable or a type parameter It works on cases such as Hash returning Null since cast_detect will invoke real_type at the original type, Null, which will then return the type haxe.lang.Null<> *) if erase_generics then if is_cs_basic_type t then t_dynamic else real_type t else (match real_type t with | TInst( { cl_kind = KTypeParameter _ }, _ ) -> TInst(null_t, [t]) | _ when is_cs_basic_type t -> TInst(null_t, [t]) | _ -> real_type t) | TAbstract _ | TType _ -> t | TAnon (anon) when (match !(anon.a_status) with | Statics _ | EnumStatics _ | AbstractStatics _ -> true | _ -> false) -> t | TFun _ -> TInst(fn_cl,[]) | _ -> t_dynamic in ret and (* On hxcs, the only type parameters allowed to be declared are the basic c# types. That's made like this to avoid casting problems when type parameters in this case add nothing to performance, since the memory layout is always the same. To avoid confusion between Generic (which has a different meaning in hxcs AST), all those references are using dynamic_anon, which means Generic<{}> *) change_param_type md tl = let types = match md with | TClassDecl c -> c.cl_params | TEnumDecl e -> [] | TAbstractDecl a -> a.a_params | TTypeDecl t -> t.t_params in let is_hxgeneric = if types = [] then is_hxgen md else (TypeParams.RealTypeParams.is_hxgeneric md) in let ret t = let t_changed = real_type t in match is_hxgeneric, t_changed with | false, _ -> t (* Because Null<> types need a special compiler treatment for many operations (e.g. boxing/unboxing), Null<> type parameters will be transformed into Dynamic. *) | true, TInst ( { cl_path = (["haxe";"lang"], "Null") }, _ ) -> dynamic_anon | true, TInst ( { cl_kind = KTypeParameter _ }, _ ) -> t | true, TInst _ | true, TEnum _ | true, TAbstract _ when is_cs_basic_type t_changed -> t | true, TDynamic _ -> t | true, x -> dynamic_anon in if is_hxgeneric && (erase_generics || List.exists (fun t -> match follow t with | TDynamic _ -> true | _ -> false) tl) then List.map (fun _ -> t_dynamic) tl else List.map ret tl in let is_dynamic t = match real_type t with | TMono _ | TDynamic _ | TInst({ cl_kind = KTypeParameter _ }, _) -> true | TAnon anon -> (match !(anon.a_status) with | EnumStatics _ | Statics _ -> false | _ -> true ) | _ -> false in let rec t_s t = match real_type t with (* basic types *) | TAbstract ({ a_path = ([], "Bool") },[]) -> "bool" | TAbstract ({ a_path = ([], "Void") },[]) -> "object" | TAbstract ({ a_path = ([],"Float") },[]) -> "double" | TAbstract ({ a_path = ([],"Int") },[]) -> "int" | TAbstract ({ a_path = [],"UInt" },[]) -> "uint" | TType ({ t_path = ["cs"], "Int64" },[]) | TAbstract ({ a_path = ["cs"], "Int64" },[]) -> "long" | TType ({ t_path = ["cs"],"UInt64" },[]) | TAbstract ({ a_path = ["cs"],"UInt64" },[]) -> "ulong" | TType ({ t_path = ["cs"],"UInt8" },[]) | TAbstract ({ a_path = ["cs"],"UInt8" },[]) -> "byte" | TType ({ t_path = ["cs"],"Int8" },[]) | TAbstract ({ a_path = ["cs"],"Int8" },[]) -> "sbyte" | TType ({ t_path = ["cs"],"Int16" },[]) | TAbstract ({ a_path = ["cs"],"Int16" },[]) -> "short" | TType ({ t_path = ["cs"],"UInt16" },[]) | TAbstract ({ a_path = ["cs"],"UInt16" },[]) -> "ushort" | TType ({ t_path = ["cs"],"Char16" },[]) | TAbstract ({ a_path = ["cs"],"Char16" },[]) -> "char" | TType ({ t_path = [],"Single" },[]) | TAbstract ({ a_path = [],"Single" },[]) -> "float" | TInst ({ cl_path = ["haxe"],"Int32" },[]) | TAbstract ({ a_path = ["haxe"],"Int32" },[]) -> "int" | TInst ({ cl_path = ["haxe"],"Int64" },[]) | TAbstract ({ a_path = ["haxe"],"Int64" },[]) -> "long" | TInst ({ cl_path = ([], "Dynamic") },_) | TAbstract ({ a_path = ([], "Dynamic") },_) -> "object" | TType ({ t_path = ["cs"],"Out" },[t]) | TAbstract ({ a_path = ["cs"],"Out" },[t]) | TType ({ t_path = ["cs"],"Ref" },[t]) | TAbstract ({ a_path = ["cs"],"Ref" },[t]) -> t_s t | TInst({ cl_path = (["cs"], "NativeArray") }, [param]) -> let rec check_t_s t = match real_type t with | TInst({ cl_path = (["cs"], "NativeArray") }, [param]) -> (check_t_s param) ^ "[]" | _ -> t_s (run_follow gen t) in (check_t_s param) ^ "[]" | TInst({ cl_path = (["cs"], "Pointer") },[t]) | TAbstract({ a_path = (["cs"], "Pointer") },[t])-> let ret = t_s t in (if ret = "object" then "void" else ret) ^ "*" (* end of basic types *) | TInst ({ cl_kind = KTypeParameter _; cl_path=p }, []) -> snd p | TMono r -> (match !r with | None -> "object" | Some t -> t_s (run_follow gen t)) | TInst ({ cl_path = [], "String" }, []) -> "string" | TEnum (e, params) -> ("global::" ^ (module_s (TEnumDecl e))) | TInst (cl, _ :: _) when Meta.has Meta.Enum cl.cl_meta -> "global::" ^ module_s (TClassDecl cl) | TInst (({ cl_path = p } as cl), params) -> (path_param_s (TClassDecl cl) p params) | TType (({ t_path = p } as t), params) -> (path_param_s (TTypeDecl t) p params) | TAnon (anon) -> (match !(anon.a_status) with | Statics _ | EnumStatics _ -> "System.Type" | _ -> "object") | TDynamic _ -> "object" | TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> t_s (Abstract.get_underlying_type a pl) (* No Lazy type nor Function type made. That's because function types will be at this point be converted into other types *) | _ -> if !strict_mode then begin trace ("[ !TypeError " ^ (Type.s_type (Type.print_context()) t) ^ " ]"); assert false end else "[ !TypeError " ^ (Type.s_type (Type.print_context()) t) ^ " ]" and path_param_s md path params = match params with | [] -> "global::" ^ module_s md | _ when erase_generics && is_hxgeneric md -> "global::" ^ module_s md | _ -> let params = (List.map (fun t -> t_s t) (change_param_type md params)) in let str,params = module_s_params md params in if params = [] then "global::" ^ str else sprintf "global::%s<%s>" str (String.concat ", " params) in let rett_s t = match t with | TAbstract ({ a_path = ([], "Void") },[]) -> "void" | _ -> t_s t in let escape ichar b = match ichar with | 92 (* \ *) -> Buffer.add_string b "\\\\" | 39 (* ' *) -> Buffer.add_string b "\\\'" | 34 -> Buffer.add_string b "\\\"" | 13 (* \r *) -> Buffer.add_string b "\\r" | 10 (* \n *) -> Buffer.add_string b "\\n" | 9 (* \t *) -> Buffer.add_string b "\\t" | c when c < 32 || (c >= 127 && c <= 0xFFFF) -> Buffer.add_string b (Printf.sprintf "\\u%.4x" c) | c when c > 0xFFFF -> Buffer.add_string b (Printf.sprintf "\\U%.8x" c) | c -> Buffer.add_char b (Char.chr c) in let escape s = let b = Buffer.create 0 in (try UTF8.validate s; UTF8.iter (fun c -> escape (UChar.code c) b) s with UTF8.Malformed_code -> String.iter (fun c -> escape (Char.code c) b) s ); Buffer.contents b in let has_semicolon e = match e.eexpr with | TBlock _ | TFor _ | TSwitch _ | TTry _ | TIf _ -> false | TWhile (_,_,flag) when flag = Ast.NormalWhile -> false | _ -> true in let in_value = ref false in let rec md_s md = let md = follow_module (gen.gfollow#run_f) md in match md with | TClassDecl ({ cl_params = [] } as cl) -> t_s (TInst(cl,[])) | TClassDecl (cl) when not (is_hxgen md) -> t_s (TInst(cl,List.map (fun t -> t_dynamic) cl.cl_params)) | TEnumDecl ({ e_params = [] } as e) -> t_s (TEnum(e,[])) | TEnumDecl (e) when not (is_hxgen md) -> t_s (TEnum(e,List.map (fun t -> t_dynamic) e.e_params)) | TClassDecl cl -> t_s (TInst(cl,[])) | TEnumDecl e -> t_s (TEnum(e,[])) | TTypeDecl t -> t_s (TType(t, List.map (fun t -> t_dynamic) t.t_params)) | TAbstractDecl a -> t_s (TAbstract(a, List.map(fun t -> t_dynamic) a.a_params)) in let rec ensure_local e explain = match e.eexpr with | TLocal _ -> e | TCast(e,_) | TParenthesis e | TMeta(_,e) -> ensure_local e explain | _ -> gen.gcon.error ("This function argument " ^ explain ^ " must be a local variable.") e.epos; e in let rec ensure_refout e explain = match e.eexpr with | TField _ | TLocal _ -> e | TCast(e,_) | TParenthesis e | TMeta(_,e) -> ensure_refout e explain | _ -> gen.gcon.error ("This function argument " ^ explain ^ " must be a local variable.") e.epos; e in let last_line = ref (-1) in let begin_block w = write w "{"; push_indent w; newline w; last_line := -1 in let end_block w = pop_indent w; (if w.sw_has_content then newline w); write w "}"; newline w; last_line := -1 in let skip_line_directives = (not gen.gcon.debug && not (Common.defined gen.gcon Define.NoCompilation)) || Common.defined gen.gcon Define.RealPosition in let line_directive = if skip_line_directives then fun w p -> () else fun w p -> if p.pfile <> Ast.null_pos.pfile then (* Compiler Error CS1560 https://msdn.microsoft.com/en-us/library/z3t5e5sw(v=vs.90).aspx *) let cur_line = Lexer.get_error_line p in let file = Common.get_full_path p.pfile in if cur_line <> ((!last_line)+1) then let line = Ast.s_escape file in if String.length line <= 256 then begin print w "#line %d \"%s\"" cur_line line; newline w end else (* Compiler Error CS1560 https://msdn.microsoft.com/en-us/library/z3t5e5sw(v=vs.90).aspx *) begin print w "//line %d \"%s\"" cur_line line; newline w end; last_line := cur_line in let line_reset_directive = if skip_line_directives then fun w -> () else fun w -> print w "#line default" in let rec extract_tparams params el = match el with | ({ eexpr = TLocal({ v_name = "$type_param" }) } as tp) :: tl -> extract_tparams (tp.etype :: params) tl | _ -> (params, el) in let is_extern_prop t name = match follow (run_follow gen t), field_access gen t name with | TInst({ cl_interface = true; cl_extern = true } as cl, _), FNotFound -> not (is_hxgen (TClassDecl cl)) | _, FClassField(_,_,decl,v,_,t,_) -> Type.is_extern_field v && (Meta.has Meta.Property v.cf_meta || (decl.cl_extern && not (is_hxgen (TClassDecl decl)))) | _ -> false in let is_event t name = match follow (run_follow gen t), field_access gen t name with | TInst({ cl_interface = true; cl_extern = true } as cl, _), FNotFound -> not (is_hxgen (TClassDecl cl)) | _, FClassField(_,_,decl,v,_,_,_) -> Meta.has Meta.Event v.cf_meta | _ -> false in let extract_statements expr = let ret = ref [] in let rec loop expr = match expr.eexpr with | TCall ({ eexpr = TLocal { v_name = "__is__" | "__typeof__" | "__array__" | "__sizeof__" | "__delegate__" } }, el) -> List.iter loop el | TNew ({ cl_path = (["cs"], "NativeArray") }, params, [ size ]) -> () | TUnop (Ast.Increment, _, _) | TUnop (Ast.Decrement, _, _) | TBinop (Ast.OpAssign, _, _) | TBinop (Ast.OpAssignOp _, _, _) | TLocal { v_name = "__fallback__" } | TLocal { v_name = "__sbreak__" } -> ret := expr :: !ret | TConst _ | TLocal _ | TArray _ | TBinop _ | TField _ | TEnumParameter _ | TTypeExpr _ | TObjectDecl _ | TArrayDecl _ | TCast _ | TMeta _ | TParenthesis _ | TUnop _ -> Type.iter loop expr | TFunction _ -> () (* do not extract parameters from inside of it *) | _ -> ret := expr :: !ret in loop expr; (* [expr] *) List.rev !ret in let expr_s w e = last_line := -1; in_value := false; let rec expr_s w e = let was_in_value = !in_value in in_value := true; (match e.eexpr with | TCall({ eexpr = TField(ef,f) }, (_ :: _ as args) ) when (field_name f) = "get_Item" -> expr_s w ef; write w "["; let first = ref true in List.iter (fun f -> if !first then first := false else write w ", "; expr_s w f ) args; write w "]" | TCall({ eexpr = TField(ef,f) }, (_ :: _ :: _ as args) ) when (field_name f) = "set_Item" -> expr_s w ef; write w "["; let args, value = match List.rev args with | v :: args -> List.rev args, v | _ -> assert false in let first = ref true in List.iter (fun f -> if !first then first := false else write w ", "; expr_s w f ) args; write w "] = "; expr_s w value | TCall( ({ eexpr = TField(ef,f) } as e), [ev] ) when String.starts_with (field_name f) "add_" -> let name = field_name f in let propname = String.sub name 4 (String.length name - 4) in if is_event (gen.greal_type ef.etype) propname then begin expr_s w ef; write w "."; write_field w propname; write w " += "; expr_s w ev end else do_call w e [ev] | TCall( ({ eexpr = TField(ef,f) } as e), [ev] ) when String.starts_with (field_name f) "remove_" -> let name = field_name f in let propname = String.sub name 7 (String.length name - 7) in if is_event (gen.greal_type ef.etype) propname then begin expr_s w ef; write w "."; write_field w propname; write w " -= "; expr_s w ev end else do_call w e [ev] | TCall( ({ eexpr = TField(ef,f) } as e), [] ) when String.starts_with (field_name f) "get_" -> let name = field_name f in let propname = String.sub name 4 (String.length name - 4) in if is_extern_prop (gen.greal_type ef.etype) propname then begin expr_s w ef; write w "."; write_field w propname end else do_call w e [] | TCall( ({ eexpr = TField(ef,f) } as e), [v] ) when String.starts_with (field_name f) "set_" -> let name = field_name f in let propname = String.sub name 4 (String.length name - 4) in if is_extern_prop (gen.greal_type ef.etype) propname then begin expr_s w ef; write w "."; write_field w propname; write w " = "; expr_s w v end else do_call w e [v] | TField (e, (FStatic(_, cf) | FInstance(_, _, cf))) when Meta.has Meta.Native cf.cf_meta -> let rec loop meta = match meta with | (Meta.Native, [EConst (String s), _],_) :: _ -> expr_s w e; write w "."; write_field w s | _ :: tl -> loop tl | [] -> expr_s w e; write w "."; write_field w (cf.cf_name) in loop cf.cf_meta | TConst c -> (match c with | TInt i32 -> write w (Int32.to_string i32); (*match real_type e.etype with | TType( { t_path = (["haxe";"_Int64"], "NativeInt64") }, [] ) -> write w "L"; | _ -> () *) | TFloat s -> write w s; (if String.get s (String.length s - 1) = '.' then write w "0"); (*match real_type e.etype with | TType( { t_path = ([], "Single") }, [] ) -> write w "f" | _ -> () *) | TString s -> write w "\""; write w (escape s); write w "\"" | TBool b -> write w (if b then "true" else "false") | TNull when is_cs_basic_type e.etype || is_tparam e.etype -> write w "default("; write w (t_s e.etype); write w ")" | TNull -> write w "null" | TThis -> write w "this" | TSuper -> write w "base") | TLocal { v_name = "__sbreak__" } -> write w "break" | TLocal { v_name = "__undefined__" } -> write w (t_s (TInst(runtime_cl, List.map (fun _ -> t_dynamic) runtime_cl.cl_params))); write w ".undefined"; | TLocal { v_name = "__typeof__" } -> write w "typeof" | TLocal { v_name = "__sizeof__" } -> write w "sizeof" | TLocal var -> write_id w var.v_name | TField (_, FEnum(e, ef)) -> let s = ef.ef_name in print w "%s." ("global::" ^ module_s (TEnumDecl e)); write_field w s | TArray (e1, e2) -> expr_s w e1; write w "["; expr_s w e2; write w "]" | TBinop ((Ast.OpAssign as op), e1, e2) | TBinop ((Ast.OpAssignOp _ as op), e1, e2) -> expr_s w e1; write w ( " " ^ (Ast.s_binop op) ^ " " ); expr_s w e2 | TBinop (op, e1, e2) -> write w "( "; expr_s w e1; write w ( " " ^ (Ast.s_binop op) ^ " " ); expr_s w e2; write w " )" | TField ({ eexpr = TTypeExpr mt }, s) -> (match mt with | TClassDecl { cl_path = (["haxe"], "Int64") } -> write w ("global::" ^ module_s mt) | TClassDecl { cl_path = (["haxe"], "Int32") } -> write w ("global::" ^ module_s mt) | TClassDecl { cl_interface = true } -> write w ("global::" ^ module_s mt); write w "__Statics_"; | TClassDecl cl -> write w (t_s (TInst(cl, List.map (fun _ -> t_empty) cl.cl_params))) | TEnumDecl en -> write w (t_s (TEnum(en, List.map (fun _ -> t_empty) en.e_params))) | TTypeDecl td -> write w (t_s (gen.gfollow#run_f (TType(td, List.map (fun _ -> t_empty) td.t_params)))) | TAbstractDecl a -> write w (t_s (TAbstract(a, List.map (fun _ -> t_empty) a.a_params))) ); write w "."; write_field w (field_name s) | TField (e, s) when is_pointer gen e.etype -> (* take off the extra cast if possible *) let e = match e.eexpr with | TCast(e1,_) when Gencommon.CastDetect.type_iseq gen e.etype e1.etype -> e1 | _ -> e in expr_s w e; write w "->"; write_field w (field_name s) | TField (e, s) -> expr_s w e; write w "."; write_field w (field_name s) | TTypeExpr mt -> (match mt with | TClassDecl { cl_path = (["haxe"], "Int64") } -> write w ("global::" ^ module_s mt) | TClassDecl { cl_path = (["haxe"], "Int32") } -> write w ("global::" ^ module_s mt) | TClassDecl cl -> write w (t_s (TInst(cl, List.map (fun _ -> t_empty) cl.cl_params))); | TEnumDecl en -> write w (t_s (TEnum(en, List.map (fun _ -> t_empty) en.e_params))) | TTypeDecl td -> write w (t_s (gen.gfollow#run_f (TType(td, List.map (fun _ -> t_empty) td.t_params)))) | TAbstractDecl a -> write w (t_s (TAbstract(a, List.map (fun _ -> t_empty) a.a_params))) ) | TParenthesis e -> write w "("; expr_s w e; write w ")" | TMeta (_,e) -> expr_s w e | TArrayDecl el | TCall ({ eexpr = TLocal { v_name = "__array__" } }, el) | TCall ({ eexpr = TField(_, FStatic({ cl_path = (["cs"],"NativeArray") }, { cf_name = "make" })) }, el) -> let _, el = extract_tparams [] el in print w "new %s" (t_s e.etype); write w "{"; ignore (List.fold_left (fun acc e -> (if acc <> 0 then write w ", "); expr_s w e; acc + 1 ) 0 el); write w "}" | TCall ({ eexpr = TLocal { v_name = "__delegate__" } }, [del]) -> expr_s w del | TCall ({ eexpr = TLocal( { v_name = "__is__" } ) }, [ expr; { eexpr = TTypeExpr(md) } ] ) -> write w "( "; expr_s w expr; write w " is "; write w (md_s md); write w " )" | TCall ({ eexpr = TLocal( { v_name = "__as__" } ) }, [ expr; { eexpr = TTypeExpr(md) } ] ) -> write w "( "; expr_s w expr; write w " as "; write w (md_s md); write w " )" | TCall ({ eexpr = TLocal( { v_name = "__as__" } ) }, expr :: _ ) -> write w "( "; expr_s w expr; write w " as "; write w (t_s e.etype); write w " )"; | TCall ({ eexpr = TLocal( { v_name = "__cs__" } ) }, [ { eexpr = TConst(TString(s)) } ] ) -> write w s | TCall ({ eexpr = TLocal( { v_name = "__cs__" } ) }, { eexpr = TConst(TString(s)) } :: tl ) -> Codegen.interpolate_code gen.gcon s tl (write w) (expr_s w) e.epos | TCall ({ eexpr = TLocal( { v_name = "__stackalloc__" } ) }, [ e ] ) -> write w "stackalloc byte["; expr_s w e; write w "]" | TCall ({ eexpr = TLocal( { v_name = "__unsafe__" } ) }, [ e ] ) -> write w "unsafe"; expr_s w (mk_block e) | TCall ({ eexpr = TLocal( { v_name = "__checked__" } ) }, [ e ] ) -> write w "checked"; expr_s w (mk_block e) | TCall ({ eexpr = TLocal( { v_name = "__lock__" } ) }, [ eobj; eblock ] ) -> write w "lock("; expr_s w eobj; write w ")"; expr_s w (mk_block eblock) | TCall ({ eexpr = TLocal( { v_name = "__fixed__" } ) }, [ e ] ) -> let fixeds = ref [] in let rec loop = function | ({ eexpr = TVar(v, Some(e) ) } as expr) :: tl when is_pointer gen v.v_type -> let e = match get_ptr e with | None -> e | Some e -> e in fixeds := (v,e,expr) :: !fixeds; loop tl; | el when !fixeds <> [] -> let rec loop fx acc = match fx with | (v,e,expr) :: tl -> write w "fixed("; let vf = mk_temp gen "fixed" v.v_type in expr_s w { expr with eexpr = TVar(vf, Some e) }; write w ") "; begin_block w; expr_s w { expr with eexpr = TVar(v, Some (mk_local vf expr.epos)) }; write w ";"; newline w; loop tl (acc + 1) | [] -> acc in let nblocks = loop (List.rev !fixeds) 0 in in_value := false; expr_s w { e with eexpr = TBlock el }; for i = 1 to nblocks do end_block w done | _ -> trace (debug_expr e); gen.gcon.error "Invalid 'fixed' keyword format" e.epos in (match e.eexpr with | TBlock bl -> loop bl | _ -> trace "not block"; trace (debug_expr e); gen.gcon.error "Invalid 'fixed' keyword format" e.epos ) | TCall ({ eexpr = TLocal( { v_name = "__addressOf__" } ) }, [ e ] ) -> let e = ensure_local e "for addressOf" in write w "&"; expr_s w e | TCall ({ eexpr = TLocal( { v_name = "__valueOf__" } ) }, [ e ] ) -> write w "*("; expr_s w e; write w ")" | TCall ({ eexpr = TLocal( { v_name = "__goto__" } ) }, [ { eexpr = TConst(TInt v) } ] ) -> print w "goto label%ld" v | TCall ({ eexpr = TLocal( { v_name = "__label__" } ) }, [ { eexpr = TConst(TInt v) } ] ) -> print w "label%ld: {}" v | TCall ({ eexpr = TLocal( { v_name = "__rethrow__" } ) }, _) -> write w "throw" (* operator overloading handling *) | TCall({ eexpr = TField(ef, FInstance(cl,_,{ cf_name = "__get" })) }, [idx]) when not (is_hxgen (TClassDecl cl)) -> expr_s w { e with eexpr = TArray(ef, idx) } | TCall({ eexpr = TField(ef, FInstance(cl,_,{ cf_name = "__set" })) }, [idx; v]) when not (is_hxgen (TClassDecl cl)) -> expr_s w { e with eexpr = TBinop(Ast.OpAssign, { e with eexpr = TArray(ef, idx) }, v) } | TCall({ eexpr = TField(ef, FStatic(_,cf)) }, el) when PMap.mem cf.cf_name binops_names -> let _, elr = extract_tparams [] el in (match elr with | [e1;e2] -> expr_s w { e with eexpr = TBinop(PMap.find cf.cf_name binops_names, e1, e2) } | _ -> do_call w e el) | TCall({ eexpr = TField(ef, FStatic(_,cf)) }, el) when PMap.mem cf.cf_name unops_names -> (match extract_tparams [] el with | _, [e1] -> expr_s w { e with eexpr = TUnop(PMap.find cf.cf_name unops_names, Ast.Prefix,e1) } | _ -> do_call w e el) | TCall (e, el) -> do_call w e el | TNew (({ cl_path = (["cs"], "NativeArray") } as cl), params, [ size ]) -> let rec check_t_s t times = match real_type t with | TInst({ cl_path = (["cs"], "NativeArray") }, [param]) -> (check_t_s param (times+1)) | _ -> print w "new %s[" (t_s (run_follow gen t)); expr_s w size; print w "]"; let rec loop i = if i <= 0 then () else (write w "[]"; loop (i-1)) in loop (times - 1) in check_t_s (TInst(cl, params)) 0 | TNew ({ cl_path = ([], "String") } as cl, [], el) -> write w "new "; write w (t_s (TInst(cl, []))); write w "("; ignore (List.fold_left (fun acc e -> (if acc <> 0 then write w ", "); expr_s w e; acc + 1 ) 0 el); write w ")" | TNew ({ cl_kind = KTypeParameter _ } as cl, params, el) -> print w "default(%s) /* This code should never be reached. It was produced by the use of @:generic on a new type parameter instance: %s */" (t_s (TInst(cl,params))) (path_param_s (TClassDecl cl) cl.cl_path params) | TNew (cl, params, el) -> write w "new "; write w (path_param_s (TClassDecl cl) cl.cl_path params); write w "("; ignore (List.fold_left (fun acc e -> (if acc <> 0 then write w ", "); expr_s w e; acc + 1 ) 0 el); write w ")" | TUnop ((Ast.Increment as op), flag, e) | TUnop ((Ast.Decrement as op), flag, e) -> (match flag with | Ast.Prefix -> write w ( " " ^ (Ast.s_unop op) ^ " " ); expr_s w e | Ast.Postfix -> expr_s w e; write w (Ast.s_unop op)) | TUnop (op, flag, e) -> (match flag with | Ast.Prefix -> write w ( " " ^ (Ast.s_unop op) ^ " (" ); expr_s w e; write w ") " | Ast.Postfix -> write w "("; expr_s w e; write w (") " ^ Ast.s_unop op)) | TVar (var, eopt) -> print w "%s " (t_s var.v_type); write_id w var.v_name; (match eopt with | None -> write w " = "; expr_s w (null var.v_type e.epos) | Some e -> write w " = "; expr_s w e ) | TBlock [e] when was_in_value -> expr_s w e | TBlock el -> begin_block w; List.iter (fun e -> List.iter (fun e -> line_directive w e.epos; in_value := false; expr_s w e; (if has_semicolon e then write w ";"); newline w ) (extract_statements e) ) el; end_block w | TIf (econd, e1, Some(eelse)) when was_in_value -> write w "( "; expr_s w (mk_paren econd); write w " ? "; expr_s w (mk_paren e1); write w " : "; expr_s w (mk_paren eelse); write w " )"; | TIf (econd, e1, eelse) -> write w "if "; expr_s w (mk_paren econd); write w " "; in_value := false; expr_s w (mk_block e1); (match eelse with | None -> () | Some e -> write w "else "; in_value := false; let e = match e.eexpr with | TIf _ -> e | TBlock [{eexpr = TIf _} as e] -> e | _ -> mk_block e in expr_s w e ) | TWhile (econd, eblock, flag) -> (match flag with | Ast.NormalWhile -> write w "while "; expr_s w (mk_paren econd); write w " "; in_value := false; expr_s w (mk_block eblock) | Ast.DoWhile -> write w "do "; in_value := false; expr_s w (mk_block eblock); write w "while "; in_value := true; expr_s w (mk_paren econd); ) | TSwitch (econd, ele_l, default) -> write w "switch "; expr_s w (mk_paren econd); write w " "; begin_block w; List.iter (fun (el, e) -> List.iter (fun e -> write w "case "; in_value := true; expr_s w e; write w ":"; newline w; ) el; in_value := false; expr_s w (mk_block e); newline w; newline w ) ele_l; if is_some default then begin write w "default:"; newline w; in_value := false; expr_s w (get default); newline w; end; end_block w | TTry (tryexpr, ve_l) -> write w "try "; in_value := false; expr_s w (mk_block tryexpr); List.iter (fun (var, e) -> print w "catch (%s %s)" (t_s var.v_type) (var.v_name); in_value := false; expr_s w (mk_block e); newline w ) ve_l | TReturn eopt -> write w "return"; if is_some eopt then (write w " "; expr_s w (get eopt)) | TBreak -> write w "break" | TContinue -> write w "continue" | TThrow e -> write w "throw "; expr_s w e | TCast (e1,md_t) -> ((*match gen.gfollow#run_f e.etype with | TType({ t_path = ([], "UInt") }, []) -> write w "( unchecked ((uint) "; expr_s w e1; write w ") )" | _ ->*) (* FIXME I'm ignoring module type *) print w "((%s) (" (t_s e.etype); expr_s w e1; write w ") )" ) | TFor (_,_,content) -> write w "[ for not supported "; expr_s w content; write w " ]"; if !strict_mode then assert false | TObjectDecl _ -> write w "[ obj decl not supported ]"; if !strict_mode then assert false | TFunction _ -> write w "[ func decl not supported ]"; if !strict_mode then assert false | TEnumParameter _ -> write w "[ enum parameter not supported ]"; if !strict_mode then assert false ) and do_call w e el = let params, el = extract_tparams [] el in let params = List.rev params in expr_s w e; (match params with | _ :: _ when not (erase_generics && field_is_hxgeneric e) -> let md = match e.eexpr with | TField(ef, _) -> t_to_md (run_follow gen ef.etype) | _ -> assert false in write w "<"; ignore (List.fold_left (fun acc t -> (if acc <> 0 then write w ", "); write w (t_s t); acc + 1 ) 0 (change_param_type md params)); write w ">" | _ -> () ); let rec loop acc elist tlist = match elist, tlist with | e :: etl, (_,_,t) :: ttl -> (if acc <> 0 then write w ", "); (match real_type t with | TType({ t_path = (["cs"], "Ref") }, _) | TAbstract ({ a_path = (["cs"], "Ref") },_) -> let e = ensure_refout e "of type cs.Ref" in write w "ref "; expr_s w e | TType({ t_path = (["cs"], "Out") }, _) | TAbstract ({ a_path = (["cs"], "Out") },_) -> let e = ensure_refout e "of type cs.Out" in write w "out "; expr_s w e | _ -> expr_s w e ); loop (acc + 1) etl ttl | e :: etl, [] -> (if acc <> 0 then write w ", "); expr_s w e; loop (acc + 1) etl [] | _ -> () in write w "("; let ft = match follow e.etype with | TFun(args,_) -> args | _ -> [] in loop 0 el ft; write w ")" in expr_s w e in let rec gen_fpart_attrib w = function | EConst( Ident i ), _ -> write w i | EField( ef, f ), _ -> gen_fpart_attrib w ef; write w "."; write w f | _, p -> gen.gcon.error "Invalid expression inside @:meta metadata" p in let rec gen_spart w = function | EConst c, p -> (match c with | Int s | Float s | Ident s -> write w s | String s -> write w "\""; write w (escape s); write w "\"" | _ -> gen.gcon.error "Invalid expression inside @:meta metadata" p) | EField( ef, f ), _ -> gen_spart w ef; write w "."; write w f | EBinop( Ast.OpAssign, (EConst (Ident s), _), e2 ), _ -> write w s; write w " = "; gen_spart w e2 | EArrayDecl( el ), _ -> write w "new[] {"; let fst = ref true in List.iter (fun e -> if !fst then fst := false else write w ", "; gen_spart w e ) el; write w "}" | ECall(fpart,args), _ -> gen_fpart_attrib w fpart; write w "("; let fst = ref true in List.iter (fun e -> if !fst then fst := false else write w ", "; gen_spart w e ) args; write w ")" | _, p -> gen.gcon.error "Invalid expression inside @:meta metadata" p in let gen_attributes w metadata = List.iter (function | Meta.Meta, [EConst(String s), _], _ -> write w "["; write w s; write w "]"; newline w | Meta.Meta, [meta], _ -> write w "["; gen_spart w meta; write w "]"; newline w | _ -> () ) metadata in let gen_nocompletion w metadata = if Meta.has Meta.NoCompletion metadata then begin write w "[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"; newline w end; in let argt_s t = let w = new_source_writer () in let rec run t = match t with | TType (tdef,p) -> gen_attributes w tdef.t_meta; run (follow_once t) | TMono r -> (match !r with | Some t -> run t | _ -> () (* avoid infinite loop / should be the same in this context *)) | TLazy f -> run (!f()) | _ -> () in run t; let ret = match run_follow gen t with | TType ({ t_path = (["cs"], "Ref") }, [t]) | TAbstract ({ a_path = (["cs"], "Ref") },[t]) -> "ref " ^ t_s t | TType ({ t_path = (["cs"], "Out") }, [t]) | TAbstract ({ a_path = (["cs"], "Out") },[t]) -> "out " ^ t_s t | t -> t_s t in let c = contents w in if c <> "" then c ^ " " ^ ret else ret in let get_string_params cl cl_params = let hxgen = is_hxgen (TClassDecl cl) in match cl_params with | (_ :: _) when not (erase_generics && is_hxgeneric (TClassDecl cl)) -> let get_param_name t = match follow t with TInst(cl, _) -> snd cl.cl_path | _ -> assert false in let params = sprintf "<%s>" (String.concat ", " (List.map (fun (_, tcl) -> get_param_name tcl) cl_params)) in let params_extends = if hxgen (* this is temprorary, see https://github.com/HaxeFoundation/haxe/issues/3526 *) || not (Meta.has (Meta.Custom ":nativeTypeConstraints") cl.cl_meta) then [""] else List.fold_left (fun acc (name, t) -> match run_follow gen t with | TInst({cl_kind = KTypeParameter constraints}, _) when constraints <> [] -> (* base class should come before interface constraints *) let base_class_constraints = ref [] in let other_constraints = List.fold_left (fun acc t -> match follow t with (* string is implicitly sealed, maybe haxe should have it final as well *) | TInst ({ cl_path=[],"String" }, []) -> acc (* non-sealed class *) | TInst ({ cl_interface = false; cl_meta = meta},_) when not (Meta.has Meta.Final meta) -> base_class_constraints := (t_s t) :: !base_class_constraints; acc; (* interface *) | TInst ({ cl_interface = true}, _) -> (t_s t) :: acc (* skip anything other *) | _ -> acc ) [] constraints in let s_constraints = (!base_class_constraints @ other_constraints) in if s_constraints <> [] then (sprintf " where %s : %s" (get_param_name t) (String.concat ", " s_constraints) :: acc) else acc; | _ -> acc ) [] cl_params in (params, String.concat " " params_extends) | _ -> ("","") in let gen_field_decl w visibility v_n modifiers t n = let parts = ref [] in if visibility <> "" then parts := visibility :: !parts; if v_n <> "" then parts := v_n :: !parts; if modifiers <> [] then parts := modifiers @ !parts; if t <> "" then parts := t :: !parts; parts := n :: !parts; write w (String.concat " " (List.rev !parts)); in let rec gen_event w is_static cl (event,t,custom,add,remove) = let is_interface = cl.cl_interface in let visibility = if is_interface then "" else "public" in let visibility, modifiers = get_fun_modifiers event.cf_meta visibility ["event"] in let v_n = if is_static then "static" else "" in gen_field_decl w visibility v_n modifiers (t_s (run_follow gen t)) (change_field event.cf_name); if custom && not is_interface then begin write w " "; begin_block w; print w "add { _add_%s(value); }" event.cf_name; newline w; print w "remove { _remove_%s(value); }" event.cf_name; newline w; end_block w; newline w; end else write w ";\n"; newline w; in let rec gen_prop w is_static cl is_final (prop,t,get,set) = gen_attributes w prop.cf_meta; let is_interface = cl.cl_interface in let fn_is_final = function | None -> true | Some ({ cf_kind = Method mkind } as m) -> (match mkind with | MethInline -> true | _ -> false) || Meta.has Meta.Final m.cf_meta | _ -> assert false in let is_virtual = not (is_interface || is_final || Meta.has Meta.Final prop.cf_meta || fn_is_final get || fn_is_final set) in let fn_is_override = function | Some cf -> List.memq cf cl.cl_overrides | None -> false in let is_override = fn_is_override get || fn_is_override set in let visibility = if is_interface then "" else "public" in let visibility, modifiers = get_fun_modifiers prop.cf_meta visibility [] in let v_n = if is_static then "static" else if is_override && not is_interface then "override" else if is_virtual then "virtual" else "" in gen_nocompletion w prop.cf_meta; gen_field_decl w visibility v_n modifiers (t_s (run_follow gen t)) (change_field prop.cf_name); let check cf = match cf with | Some ({ cf_overloads = o :: _ } as cf) -> gen.gcon.error "Property functions with more than one overload is currently unsupported" cf.cf_pos; gen.gcon.error "Property functions with more than one overload is currently unsupported" o.cf_pos | _ -> () in check get; check set; write w " "; if is_interface then begin write w "{ "; let s = ref "" in (match prop.cf_kind with Var { v_read = AccCall } -> write w "get;"; s := " "; | _ -> ()); (match prop.cf_kind with Var { v_write = AccCall } -> print w "%sset;" !s | _ -> ()); write w " }"; newline w; end else begin begin_block w; (match get with | Some cf -> print w "get { return _get_%s(); }" prop.cf_name; newline w; cf.cf_meta <- (Meta.Custom "?prop_impl", [], null_pos) :: cf.cf_meta; | None -> ()); (match set with | Some cf -> print w "set { _set_%s(value); }" prop.cf_name; newline w; cf.cf_meta <- (Meta.Custom "?prop_impl", [], null_pos) :: cf.cf_meta; | None -> ()); end_block w; newline w; newline w; end; in let rec gen_class_field w ?(is_overload=false) is_static cl is_final cf = gen_attributes w cf.cf_meta; let is_interface = cl.cl_interface in let name, is_new, is_explicit_iface = match cf.cf_name with | "new" -> snd cl.cl_path, true, false | name when String.contains name '.' -> let fn_name, path = parse_explicit_iface name in (path_s path) ^ "." ^ fn_name, false, true | name -> try let binop = PMap.find name binops_names in "operator " ^ s_binop binop, false, false with | Not_found -> try let unop = PMap.find name unops_names in "operator " ^ s_unop unop, false, false with | Not_found -> if Meta.has (Meta.Custom "?prop_impl") cf.cf_meta || Meta.has (Meta.Custom "?event_impl") cf.cf_meta then "_" ^ name, false, false else name, false, false in let rec loop_static cl = match is_static, cl.cl_super with | false, _ -> [] | true, None -> [] | true, Some(cl,_) -> (try let cf2 = PMap.find cf.cf_name cl.cl_statics in Gencommon.CastDetect.type_eq gen EqStrict cf.cf_type cf2.cf_type; ["new"] with | Not_found | Unify_error _ -> loop_static cl ) in let modf = loop_static cl in (match cf.cf_kind with | Var _ | Method (MethDynamic) when not (Type.is_extern_field cf) -> (if is_overload || List.exists (fun cf -> cf.cf_expr <> None) cf.cf_overloads then gen.gcon.error "Only normal (non-dynamic) methods can be overloaded" cf.cf_pos); if not is_interface then begin let access, modifiers = get_fun_modifiers cf.cf_meta "public" [] in let modifiers = modifiers @ modf in gen_nocompletion w cf.cf_meta; gen_field_decl w access (if is_static then "static" else "") modifiers (t_s (run_follow gen cf.cf_type)) (change_field name); (match cf.cf_expr with | Some e -> write w " = "; expr_s w e; | None -> () ); write w ";" end (* TODO see how (get,set) variable handle when they are interfaces *) | Method _ when Type.is_extern_field cf || (match cl.cl_kind, cf.cf_expr with | KAbstractImpl _, None -> true | _ -> false) -> List.iter (fun cf -> if cl.cl_interface || cf.cf_expr <> None then gen_class_field w ~is_overload:true is_static cl (Meta.has Meta.Final cf.cf_meta) cf ) cf.cf_overloads | Var _ | Method MethDynamic -> () | Method mkind -> List.iter (fun cf -> if cl.cl_interface || cf.cf_expr <> None then gen_class_field w ~is_overload:true is_static cl (Meta.has Meta.Final cf.cf_meta) cf ) cf.cf_overloads; let is_virtual = not is_final && match mkind with | MethInline -> false | _ when not is_new -> true | _ -> false in let is_virtual = if not is_virtual || Meta.has Meta.Final cf.cf_meta then false else is_virtual in let is_override = List.memq cf cl.cl_overrides in let is_override = is_override || match cf.cf_name, follow cf.cf_type with | "Equals", TFun([_,_,targ], tret) -> (match follow targ, follow tret with | TDynamic _, TAbstract({ a_path = ([], "Bool") }, []) -> true | _ -> false) | "GetHashCode", TFun([],_) -> true | _ -> false in let is_override = if Meta.has (Meta.Custom "?prop_impl") cf.cf_meta then false else is_override in let is_virtual = is_virtual && not (Meta.has Meta.Final cl.cl_meta) && not (is_interface) in let visibility = if is_interface then "" else "public" in let visibility, modifiers = get_fun_modifiers cf.cf_meta visibility [] in let modifiers = modifiers @ modf in let visibility, is_virtual = if is_explicit_iface then "",false else if visibility = "private" then "private",false else visibility, is_virtual in let v_n = if is_static then "static" else if is_override && not is_interface then "override" else if is_virtual then "virtual" else "" in let cf_type = if is_override && not is_overload && not (Meta.has Meta.Overload cf.cf_meta) then match field_access gen (TInst(cl, List.map snd cl.cl_params)) cf.cf_name with | FClassField(_,_,_,_,_,actual_t,_) -> actual_t | _ -> assert false else cf.cf_type in let ret_type, args = match follow cf_type with | TFun (strbtl, t) -> (t, strbtl) | _ -> assert false in gen_nocompletion w cf.cf_meta; (* public static void funcName *) gen_field_decl w visibility v_n modifiers (if not is_new then (rett_s (run_follow gen ret_type)) else "") (change_field name); let params, params_ext = get_string_params cl cf.cf_params in (* (string arg1, object arg2) with T : object *) (match cf.cf_expr with | Some { eexpr = TFunction tf } -> print w "%s(%s)%s" (params) (String.concat ", " (List.map2 (fun (var, _) (_,_,t) -> sprintf "%s %s" (argt_s t) (change_id var.v_name)) tf.tf_args args)) (params_ext) | _ -> print w "%s(%s)%s" (params) (String.concat ", " (List.map (fun (name, _, t) -> sprintf "%s %s" (argt_s t) (change_id name)) args)) (params_ext) ); if is_interface then write w ";" else begin write w " "; let rec loop meta = match meta with | [] -> let expr = match cf.cf_expr with | None -> mk (TBlock([])) t_dynamic Ast.null_pos | Some s -> match s.eexpr with | TFunction tf -> mk_block (tf.tf_expr) | _ -> assert false (* FIXME *) in let needs_unchecked e = let rec loop e = match e.eexpr with (* a non-zero integer constant means that we want unchecked context *) | TConst (TInt i) when i <> Int32.zero -> raise Exit (* don't recurse into explicit checked blocks *) | TCall ({ eexpr = TLocal({ v_name = "__checked__" }) }, _) -> () (* skip reflection field hashes as they are safe *) | TNew ({ cl_path = (["haxe"; "lang"],"DynamicObject") }, [], [_; e1; _; e2]) -> loop e1; loop e2 | TNew ({ cl_path = (["haxe"; "lang"],"Closure") }, [], [eo; _; _]) -> loop eo | TCall ({ eexpr = TField (_, FStatic ({ cl_path = ["haxe"; "lang"],"Runtime" }, { cf_name = "getField" | "setField" | "getField_f" | "setField_f" | "callField" })) }, eo :: _ :: _ :: rest) -> loop eo; List.iter loop rest | _ -> Type.iter loop e in try (loop e; false) with Exit -> true in let write_method_expr e = match e.eexpr with | TBlock [] -> begin_block w; end_block w | TBlock _ -> let unchecked = needs_unchecked e in if unchecked then (begin_block w; write w "unchecked "); let t = Common.timer "expression to string" in expr_s w e; t(); line_reset_directive w; if unchecked then end_block w | _ -> assert false in (if is_new then begin let rec get_super_call el = match el with | ( { eexpr = TCall( { eexpr = TConst(TSuper) }, _) } as call) :: rest -> Some call, rest | ( { eexpr = TBlock(bl) } as block ) :: rest -> let ret, mapped = get_super_call bl in ret, ( { block with eexpr = TBlock(mapped) } :: rest ) | _ -> None, el in match expr.eexpr with | TBlock(bl) -> let super_call, rest = get_super_call bl in (match super_call with | None -> () | Some sc -> write w ": "; let t = Common.timer "expression to string" in expr_s w sc; write w " "; t() ); write_method_expr { expr with eexpr = TBlock(rest) } | _ -> assert false end else write_method_expr expr ) | (Meta.FunctionCode, [Ast.EConst (Ast.String contents),_],_) :: tl -> begin_block w; write w contents; end_block w | _ :: tl -> loop tl in loop cf.cf_meta end); newline w; newline w; in let check_special_behaviors w cl = match cl.cl_kind with | KAbstractImpl _ -> () | _ -> (* get/set pairs *) let pairs = ref PMap.empty in (try let get = PMap.find "__get" cl.cl_fields in List.iter (fun cf -> let args,ret = get_fun cf.cf_type in match args with | [_,_,idx] -> pairs := PMap.add (t_s idx) ( t_s ret, Some cf, None ) !pairs | _ -> gen.gcon.warning "The __get function must have exactly one argument (the index)" cf.cf_pos ) (get :: get.cf_overloads) with | Not_found -> ()); (try let set = PMap.find "__set" cl.cl_fields in List.iter (fun cf -> let args, ret = get_fun cf.cf_type in match args with | [_,_,idx; _,_,v] -> (try let vt, g, _ = PMap.find (t_s idx) !pairs in let tvt = t_s v in if vt <> tvt then gen.gcon.warning "The __get function of same index has a different type from this __set function" cf.cf_pos; pairs := PMap.add (t_s idx) (vt, g, Some cf) !pairs with | Not_found -> pairs := PMap.add (t_s idx) (t_s v, None, Some cf) !pairs) | _ -> gen.gcon.warning "The __set function must have exactly two arguments (index, value)" cf.cf_pos ) (set :: set.cf_overloads) with | Not_found -> ()); PMap.iter (fun idx (v, get, set) -> print w "public %s this[%s index]" v idx; begin_block w; (match get with | None -> () | Some _ -> write w "get"; begin_block w; write w "return this.__get(index);"; end_block w); (match set with | None -> () | Some _ -> write w "set"; begin_block w; write w "this.__set(index,value);"; end_block w); end_block w) !pairs; (if not (PMap.is_empty !pairs) then try let get = PMap.find "__get" cl.cl_fields in let idx_t, v_t = match follow get.cf_type with | TFun([_,_,arg_t],ret_t) -> t_s (run_follow gen arg_t), t_s (run_follow gen ret_t) | _ -> gen.gcon.error "The __get function must be a function with one argument. " get.cf_pos; assert false in List.iter (fun (cl,args) -> match cl.cl_array_access with | None -> () | Some t -> let changed_t = apply_params cl.cl_params (List.map (fun _ -> t_dynamic) cl.cl_params) t in let t_as_s = t_s (run_follow gen changed_t) in print w "%s %s.this[int key]" t_as_s (t_s (TInst(cl, args))); begin_block w; write w "get"; begin_block w; print w "return ((%s) this.__get(key));" t_as_s; end_block w; write w "set"; begin_block w; print w "this.__set(key, (%s) value);" v_t; end_block w; end_block w; newline w; newline w ) cl.cl_implements with | Not_found -> ()); if cl.cl_interface && is_hxgen (TClassDecl cl) && is_some cl.cl_array_access then begin let changed_t = apply_params cl.cl_params (List.map (fun _ -> t_dynamic) cl.cl_params) (get cl.cl_array_access) in print w "%s this[int key]" (t_s (run_follow gen changed_t)); begin_block w; write w "get;"; newline w; write w "set;"; newline w; end_block w; newline w; newline w end; (try if cl.cl_interface then raise Not_found; let cf = PMap.find "toString" cl.cl_fields in (if List.exists (fun c -> c.cf_name = "toString") cl.cl_overrides then raise Not_found); (match cf.cf_type with | TFun([], ret) -> (match real_type ret with | TInst( { cl_path = ([], "String") }, []) -> write w "public override string ToString()"; begin_block w; write w "return this.toString();"; end_block w; newline w; newline w | _ -> gen.gcon.error "A toString() function should return a String!" cf.cf_pos ) | _ -> () ) with | Not_found -> ()); (try if cl.cl_interface then raise Not_found; let cf = PMap.find "finalize" cl.cl_fields in (if List.exists (fun c -> c.cf_name = "finalize") cl.cl_overrides then raise Not_found); (match cf.cf_type with | TFun([], ret) -> (match real_type ret with | TAbstract( { a_path = ([], "Void") }, []) -> write w "~"; write w (snd cl.cl_path); write w "()"; begin_block w; write w "this.finalize();"; end_block w; newline w; newline w | _ -> gen.gcon.error "A finalize() function should be Void->Void!" cf.cf_pos ) | _ -> () ) with | Not_found -> ()); (* properties *) let handle_prop static f = match f.cf_kind with | Method _ -> () | Var v when not (Type.is_extern_field f) -> () | Var v -> let prop acc = match acc with | AccNo | AccNever | AccCall -> true | _ -> false in if prop v.v_read && prop v.v_write && (v.v_read = AccCall || v.v_write = AccCall) then begin let this = if static then mk_classtype_access cl f.cf_pos else { eexpr = TConst TThis; etype = TInst(cl,List.map snd cl.cl_params); epos = f.cf_pos } in print w "public %s%s %s" (if static then "static " else "") (t_s f.cf_type) (netname_to_hx f.cf_name); begin_block w; (match v.v_read with | AccCall -> write w "get"; begin_block w; write w "return "; expr_s w this; print w ".get_%s();" f.cf_name; end_block w | _ -> ()); (match v.v_write with | AccCall -> write w "set"; begin_block w; expr_s w this; print w ".set_%s(value);" f.cf_name; end_block w | _ -> ()); end_block w; end in if Meta.has Meta.BridgeProperties cl.cl_meta then begin List.iter (handle_prop true) cl.cl_ordered_statics; List.iter (handle_prop false) cl.cl_ordered_fields; end in let gen_class w cl = write w "#pragma warning disable 109, 114, 219, 429, 168, 162"; newline w; let should_close = match change_ns (TClassDecl cl) (fst (cl.cl_path)) with | [] -> false | ns -> print w "namespace %s " (String.concat "." ns); begin_block w; true in (try let _,m,_ = Meta.get (Meta.Custom "generic_iface") cl.cl_meta in let rec loop i acc = if i == 0 then acc else "object" :: (loop (pred i) acc) in let tparams = loop (match m with [(EConst(Int s),_)] -> int_of_string s | _ -> assert false) [] in cl.cl_meta <- (Meta.Meta, [ EConst(String("global::haxe.lang.GenericInterface(typeof(global::" ^ module_s (TClassDecl cl) ^ "<" ^ String.concat ", " tparams ^ ">))") ), cl.cl_pos ], cl.cl_pos) :: cl.cl_meta with Not_found -> ()); gen_attributes w cl.cl_meta; let is_main = match gen.gcon.main_class with | Some ( (_,"Main") as path) when path = cl.cl_path && not cl.cl_interface -> (* for cases where the main class is called Main, there will be a problem with creating the entry point there. In this special case, a special entry point class will be created *) write w "public class EntryPoint__Main "; begin_block w; write w "public static void Main() "; begin_block w; (if Hashtbl.mem gen.gtypes (["cs"], "Boot") then write w "global::cs.Boot.init();"; newline w); expr_s w { eexpr = TTypeExpr(TClassDecl cl); etype = t_dynamic; epos = Ast.null_pos }; write w ".main();"; end_block w; end_block w; newline w; false | Some path when path = cl.cl_path && not cl.cl_interface -> true | _ -> false in let clt, access, modifiers = get_class_modifiers cl.cl_meta (if cl.cl_interface then "interface" else "class") "public" [] in let is_final = clt = "struct" || Meta.has Meta.Final cl.cl_meta in let modifiers = [access] @ modifiers in print w "%s %s %s" (String.concat " " modifiers) clt (change_clname (snd cl.cl_path)); (* type parameters *) let params, params_ext = get_string_params cl cl.cl_params in let extends_implements = (match cl.cl_super with | None -> [] | Some (cl,p) -> [path_param_s (TClassDecl cl) cl.cl_path p]) @ (List.map (fun (cl,p) -> path_param_s (TClassDecl cl) cl.cl_path p) cl.cl_implements) in (match extends_implements with | [] -> print w "%s%s " params params_ext | _ -> print w "%s : %s%s " params (String.concat ", " extends_implements) params_ext); (* class head ok: *) (* public class Test : X, Y, Z where A : Y *) begin_block w; newline w; (* our constructor is expected to be a normal "new" function * if !strict_mode && is_some cl.cl_constructor then assert false;*) let rec loop meta = match meta with | [] -> () | (Meta.ClassCode, [Ast.EConst (Ast.String contents),_],_) :: tl -> write w contents | _ :: tl -> loop tl in loop cl.cl_meta; if is_main then begin write w "public static void Main()"; begin_block w; (if Hashtbl.mem gen.gtypes (["cs"], "Boot") then write w "global::cs.Boot.init();"; newline w); write w "main();"; end_block w end; (match cl.cl_init with | None -> () | Some init -> print w "static %s() " (snd cl.cl_path); expr_s w (mk_block init); line_reset_directive w; newline w; newline w ); (* collect properties and events *) let partition cf cflist = let events, props, nonprops = ref [], ref [], ref [] in List.iter (fun v -> match v.cf_kind with | Var { v_read = AccCall } | Var { v_write = AccCall } when Type.is_extern_field v && Meta.has Meta.Property v.cf_meta -> props := (v.cf_name, ref (v, v.cf_type, None, None)) :: !props; | Var { v_read = AccNormal; v_write = AccNormal } when Meta.has Meta.Event v.cf_meta -> if v.cf_public then gen.gcon.error "@:event fields must be private" v.cf_pos; v.cf_meta <- (Meta.SkipReflection, [], null_pos) :: v.cf_meta; events := (v.cf_name, ref (v, v.cf_type, false, None, None)) :: !events; | _ -> nonprops := v :: !nonprops; ) cflist; let events, nonprops = !events, !nonprops in let t = TInst(cl, List.map snd cl.cl_params) in let find_prop name = try List.assoc name !props with | Not_found -> match field_access gen t name with | FClassField (_,_,decl,v,_,t,_) when is_extern_prop (TInst(cl,List.map snd cl.cl_params)) name -> let ret = ref (v,t,None,None) in props := (name, ret) :: !props; ret | _ -> raise Not_found in let find_event name = List.assoc name events in let is_empty_function cf = match cf.cf_expr with | Some {eexpr = TFunction { tf_expr = {eexpr = TBlock []}}} -> true | _ -> false in let interf = cl.cl_interface in (* get all functions that are getters/setters *) let nonprops = List.filter (function | cf when String.starts_with cf.cf_name "get_" -> (try (* find the property *) let prop = find_prop (String.sub cf.cf_name 4 (String.length cf.cf_name - 4)) in let v, t, get, set = !prop in assert (get = None); prop := (v,t,Some cf,set); not interf with | Not_found -> true) | cf when String.starts_with cf.cf_name "set_" -> (try (* find the property *) let prop = find_prop (String.sub cf.cf_name 4 (String.length cf.cf_name - 4)) in let v, t, get, set = !prop in assert (set = None); prop := (v,t,get,Some cf); not interf with | Not_found -> true) | cf when String.starts_with cf.cf_name "add_" -> (try let event = find_event (String.sub cf.cf_name 4 (String.length cf.cf_name - 4)) in let v, t, _, add, remove = !event in assert (add = None); cf.cf_meta <- (Meta.Custom "?event_impl", [], null_pos) :: cf.cf_meta; let custom = not (is_empty_function cf) in event := (v, t, custom, Some cf, remove); false with | Not_found -> true) | cf when String.starts_with cf.cf_name "remove_" -> (try let event = find_event (String.sub cf.cf_name 7 (String.length cf.cf_name - 7)) in let v, t, _, add, remove = !event in assert (remove = None); cf.cf_meta <- (Meta.Custom "?event_impl", [], null_pos) :: cf.cf_meta; let custom = not (is_empty_function cf) in event := (v, t, custom, add, Some cf); false with | Not_found -> true) | _ -> true ) nonprops in let nonprops = ref nonprops in List.iter (fun (n,r) -> let ev, t, custom, add, remove = !r in let tmeth = (tfun [t] basic.tvoid) in match add, remove with | None, _ -> gen.gcon.error ("Missing event method add_" ^ n) ev.cf_pos; failwith "Build failed" | _, None -> gen.gcon.error ("Missing event method remove_" ^ n) ev.cf_pos; failwith "Build failed" | Some add, Some remove -> let check cf = try type_eq EqStrict cf.cf_type tmeth with Unify_error el -> List.iter (fun e -> gen.gcon.error (Typecore.unify_error_msg (print_context()) e) cf.cf_pos) el; failwith "Build failed"; in check add; check remove; if custom && not cl.cl_interface then nonprops := add :: remove :: !nonprops ) events; let evts = List.map (fun(_,v) -> !v) events in let ret = List.map (fun (_,v) -> !v) !props in let ret = List.filter (function | (_,_,None,None) -> false | _ -> true) ret in evts, ret, List.rev !nonprops in let fevents, fprops, fnonprops = partition cl cl.cl_ordered_fields in let sevents, sprops, snonprops = partition cl cl.cl_ordered_statics in (if is_some cl.cl_constructor then gen_class_field w false cl is_final (get cl.cl_constructor)); if not cl.cl_interface then begin (* we don't want to generate properties for abstract implementation classes, because they don't have object to work with *) List.iter (gen_event w true cl) sevents; if (match cl.cl_kind with KAbstractImpl _ -> false | _ -> true) then List.iter (gen_prop w true cl is_final) sprops; List.iter (gen_class_field w true cl is_final) snonprops end; List.iter (gen_event w false cl) fevents; List.iter (gen_prop w false cl is_final) fprops; List.iter (gen_class_field w false cl is_final) fnonprops; check_special_behaviors w cl; end_block w; if cl.cl_interface && cl.cl_ordered_statics <> [] then begin print w "public class %s__Statics_" (snd cl.cl_path); begin_block w; List.iter (gen_class_field w true { cl with cl_interface = false } is_final) cl.cl_ordered_statics; end_block w end; if should_close then end_block w in let gen_enum w e = let should_close = match change_ns (TEnumDecl e) (fst e.e_path) with | [] -> false | ns -> print w "namespace %s" (String.concat "." ns); begin_block w; true in gen_attributes w e.e_meta; print w "public enum %s" (change_clname (snd e.e_path)); begin_block w; write w (String.concat ", " (List.map (change_id) e.e_names)); end_block w; if should_close then end_block w in let module_type_gen w md_tp = reset_temps(); match md_tp with | TClassDecl cl -> if not cl.cl_extern then begin (if no_root && len w = 0 then write w "using haxe.root;\n"; newline w;); gen_class w cl; newline w; newline w end; (not cl.cl_extern) | TEnumDecl e -> if not e.e_extern && not (Meta.has Meta.Class e.e_meta) then begin (if no_root && len w = 0 then write w "using haxe.root;\n"; newline w;); gen_enum w e; newline w; newline w end; (not e.e_extern) | TAbstractDecl _ | TTypeDecl _ -> false in let module_gen w md_def = List.fold_left (fun should md -> module_type_gen w md || should) false md_def.m_types in (* generate source code *) init_ctx gen; Hashtbl.add gen.gspecial_vars "__rethrow__" true; Hashtbl.add gen.gspecial_vars "__typeof__" true; Hashtbl.add gen.gspecial_vars "__label__" true; Hashtbl.add gen.gspecial_vars "__goto__" true; Hashtbl.add gen.gspecial_vars "__is__" true; Hashtbl.add gen.gspecial_vars "__as__" true; Hashtbl.add gen.gspecial_vars "__cs__" true; Hashtbl.add gen.gspecial_vars "__checked__" true; Hashtbl.add gen.gspecial_vars "__lock__" true; Hashtbl.add gen.gspecial_vars "__fixed__" true; Hashtbl.add gen.gspecial_vars "__unsafe__" true; Hashtbl.add gen.gspecial_vars "__addressOf__" true; Hashtbl.add gen.gspecial_vars "__valueOf__" true; Hashtbl.add gen.gspecial_vars "__sizeof__" true; Hashtbl.add gen.gspecial_vars "__stackalloc__" true; Hashtbl.add gen.gspecial_vars "__delegate__" true; Hashtbl.add gen.gspecial_vars "__array__" true; Hashtbl.add gen.gspecial_vars "__ptr__" true; Hashtbl.add gen.gsupported_conversions (["haxe"; "lang"], "Null") (fun t1 t2 -> true); let last_needs_box = gen.gneeds_box in gen.gneeds_box <- (fun t -> match (gen.greal_type t) with | TAbstract( ( { a_path = ["cs"], "Pointer" }, _ ) ) | TInst( { cl_path = ["cs"], "Pointer" }, _ ) | TInst( { cl_path = (["haxe"; "lang"], "Null") }, _ ) -> true | _ -> last_needs_box t); gen.greal_type <- real_type; gen.greal_type_param <- change_param_type; SetHXGen.run_filter gen SetHXGen.default_hxgen_func; (* before running the filters, follow all possible types *) (* this is needed so our module transformations don't break some core features *) (* like multitype selection *) let run_follow_gen = run_follow gen in let rec type_map e = Type.map_expr_type (fun e->type_map e) (run_follow_gen) (fun tvar-> tvar.v_type <- (run_follow_gen tvar.v_type); tvar) e in let super_map (cl,tl) = (cl, List.map run_follow_gen tl) in List.iter (function | TClassDecl cl -> let all_fields = (Option.map_default (fun cf -> [cf]) [] cl.cl_constructor) @ cl.cl_ordered_fields @ cl.cl_ordered_statics in List.iter (fun cf -> cf.cf_type <- run_follow_gen cf.cf_type; cf.cf_expr <- Option.map type_map cf.cf_expr; (* add @:skipReflection to @:event vars *) match cf.cf_kind with | Var _ when (Meta.has Meta.Event cf.cf_meta) && not (Meta.has Meta.SkipReflection cf.cf_meta) -> cf.cf_meta <- (Meta.SkipReflection, [], null_pos) :: cf.cf_meta; | _ -> () ) all_fields; cl.cl_dynamic <- Option.map run_follow_gen cl.cl_dynamic; cl.cl_array_access <- Option.map run_follow_gen cl.cl_array_access; cl.cl_init <- Option.map type_map cl.cl_init; cl.cl_super <- Option.map super_map cl.cl_super; cl.cl_implements <- List.map super_map cl.cl_implements | _ -> () ) gen.gtypes_list; let closure_t = ClosuresToClass.DoubleAndDynamicClosureImpl.get_ctx gen 6 in (*let closure_t = ClosuresToClass.create gen 10 float_cl (fun l -> l) (fun l -> l) (fun args -> args) (fun args -> []) in ClosuresToClass.configure gen (ClosuresToClass.default_implementation closure_t (fun e _ _ -> e)); StubClosureImpl.configure gen (StubClosureImpl.default_implementation gen float_cl 10 (fun e _ _ -> e));*) let tp_v = alloc_var "$type_param" t_dynamic in let mk_tp t pos = { eexpr = TLocal(tp_v); etype = t; epos = pos } in TypeParams.configure gen (fun ecall efield params elist -> match efield.eexpr with | TField(_, FEnum _) -> { ecall with eexpr = TCall(efield, elist) } | _ -> { ecall with eexpr = TCall(efield, (List.map (fun t -> mk_tp t ecall.epos ) params) @ elist) } ); if not erase_generics then HardNullableSynf.configure gen (HardNullableSynf.traverse gen (fun e -> match real_type e.etype with | TInst({ cl_path = (["haxe";"lang"], "Null") }, [t]) -> let e = { e with eexpr = TParenthesis(e) } in { (mk_field_access gen e "value" e.epos) with etype = t } | _ -> trace (debug_type e.etype); gen.gcon.error "This expression is not a Nullable expression" e.epos; assert false ) (fun v t has_value -> match has_value, real_type v.etype with | true, TDynamic _ | true, TAnon _ | true, TMono _ -> { eexpr = TCall(mk_static_field_access_infer null_t "ofDynamic" v.epos [t], [mk_tp t v.epos; v]); etype = TInst(null_t, [t]); epos = v.epos } | _ -> { eexpr = TNew(null_t, [t], [gen.ghandle_cast t v.etype v; { eexpr = TConst(TBool has_value); etype = gen.gcon.basic.tbool; epos = v.epos } ]); etype = TInst(null_t, [t]); epos = v.epos } ) (fun e -> { eexpr = TCall( { (mk_field_access gen { (mk_paren e) with etype = real_type e.etype } "toDynamic" e.epos) with etype = TFun([], t_dynamic) }, []); etype = t_dynamic; epos = e.epos } ) (fun e -> mk_field_access gen { e with etype = real_type e.etype } "hasValue" e.epos ) (fun e1 e2 -> { eexpr = TCall( mk_field_access gen e1 "Equals" e1.epos, [e2]); etype = basic.tbool; epos = e1.epos; } ) true false ); let explicit_fn_name c tl fname = path_param_s (TClassDecl c) c.cl_path tl ^ "." ^ fname in FixOverrides.configure ~explicit_fn_name:explicit_fn_name ~get_vmtype:real_type gen; Normalize.configure gen ~metas:(Hashtbl.create 0); AbstractImplementationFix.configure gen; IteratorsInterface.configure gen (fun e -> e); OverrideFix.configure gen; ClosuresToClass.configure gen (ClosuresToClass.default_implementation closure_t (get_cl (get_type gen (["haxe";"lang"],"Function")) )); let enum_base = (get_cl (get_type gen (["haxe";"lang"],"Enum")) ) in let param_enum_base = (get_cl (get_type gen (["haxe";"lang"],"ParamEnum")) ) in EnumToClass.configure gen (Some (fun e -> mk_cast gen.gcon.basic.tint e)) true true enum_base param_enum_base false false; InterfaceVarsDeleteModf.configure gen; InterfaceProps.configure gen; let dynamic_object = (get_cl (get_type gen (["haxe";"lang"],"DynamicObject")) ) in let object_iface = get_cl (get_type gen (["haxe";"lang"],"IHxObject")) in (*fixme: THIS IS A HACK. take this off *) let empty_e = match (get_type gen (["haxe";"lang"], "EmptyObject")) with | TEnumDecl e -> e | _ -> assert false in (*OverloadingCtor.set_new_create_empty gen ({eexpr=TEnumField(empty_e, "EMPTY"); etype=TEnum(empty_e,[]); epos=null_pos;});*) let empty_expr = { eexpr = (TTypeExpr (TEnumDecl empty_e)); etype = (TAnon { a_fields = PMap.empty; a_status = ref (EnumStatics empty_e) }); epos = null_pos } in let empty_ef = try PMap.find "EMPTY" empty_e.e_constrs with Not_found -> gen.gcon.error "Required enum field EMPTY was not found" empty_e.e_pos; assert false in OverloadingConstructor.configure ~empty_ctor_type:(TEnum(empty_e, [])) ~empty_ctor_expr:({ eexpr=TField(empty_expr, FEnum(empty_e, empty_ef)); etype=TEnum(empty_e,[]); epos=null_pos; }) ~supports_ctor_inheritance:false gen; let rcf_static_find = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "findHash" Ast.null_pos [] in let rcf_static_lookup = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "lookupHash" Ast.null_pos [] in let rcf_static_insert, rcf_static_remove = if erase_generics then begin let get_specialized_postfix t = match t with | TAbstract({a_path = [],("Float" | "Int" as name)}, _) -> name | TAnon _ | TDynamic _ -> "Dynamic" | _ -> print_endline (debug_type t); assert false in (fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("insert" ^ get_specialized_postfix t) Ast.null_pos []), (fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("remove" ^ get_specialized_postfix t) Ast.null_pos []) end else (fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "insert" Ast.null_pos [t]), (fun t -> mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "remove" Ast.null_pos [t]) in let can_be_float = like_float in let rcf_on_getset_field main_expr field_expr field may_hash may_set is_unsafe = let is_float = can_be_float (real_type main_expr.etype) in let fn_name = if is_some may_set then "setField" else "getField" in let fn_name = if is_float then fn_name ^ "_f" else fn_name in let pos = field_expr.epos in let is_unsafe = { eexpr = TConst(TBool is_unsafe); etype = basic.tbool; epos = pos } in let should_cast = match main_expr.etype with | TAbstract({ a_path = ([], "Float") }, []) -> false | _ -> true in let infer = mk_static_field_access_infer runtime_cl fn_name field_expr.epos [] in let first_args = [ field_expr; { eexpr = TConst(TString field); etype = basic.tstring; epos = pos } ] @ if is_some may_hash then [ { eexpr = TConst(TInt (get may_hash)); etype = basic.tint; epos = pos } ] else [] in let args = first_args @ match is_float, may_set with | true, Some(set) -> [ if should_cast then mk_cast basic.tfloat set else set ] | false, Some(set) -> [ set ] | _ -> [ is_unsafe ] in let call = { main_expr with eexpr = TCall(infer,args) } in let call = if is_float && should_cast then mk_cast main_expr.etype call else call in call in let rcf_on_call_field ecall field_expr field may_hash args = let infer = mk_static_field_access_infer runtime_cl "callField" field_expr.epos [] in let hash_arg = match may_hash with | None -> [] | Some h -> [ { eexpr = TConst(TInt h); etype = basic.tint; epos = field_expr.epos } ] in let arr_call = if args <> [] then { eexpr = TArrayDecl args; etype = basic.tarray t_dynamic; epos = ecall.epos } else null (basic.tarray t_dynamic) ecall.epos in let call_args = [field_expr; { field_expr with eexpr = TConst(TString field); etype = basic.tstring } ] @ hash_arg @ [ arr_call ] in mk_cast ecall.etype { ecall with eexpr = TCall(infer, call_args) } in if not erase_generics then handle_type_params gen ifaces (get_cl (get_type gen (["haxe";"lang"], "IGenericObject"))) else begin add_cast_handler gen; TypeParams.RealTypeParams.RealTypeParamsModf.configure gen (TypeParams.RealTypeParams.RealTypeParamsModf.set_only_hxgeneric gen) end; let rcf_ctx = ReflectionCFs.new_ctx gen closure_t object_iface true rcf_on_getset_field rcf_on_call_field (fun hash hash_array length -> { hash with eexpr = TCall(rcf_static_find, [hash; hash_array; length]); etype=basic.tint }) (fun hash -> { hash with eexpr = TCall(rcf_static_lookup, [hash]); etype = gen.gcon.basic.tstring }) (fun hash_array length pos value -> let ecall = mk (TCall(rcf_static_insert value.etype, [hash_array; length; pos; value])) (if erase_generics then hash_array.etype else basic.tvoid) hash_array.epos in if erase_generics then { ecall with eexpr = TBinop(OpAssign, hash_array, ecall) } else ecall ) (fun hash_array length pos -> let t = gen.gclasses.nativearray_type hash_array.etype in { hash_array with eexpr = TCall(rcf_static_remove t, [hash_array; length; pos]); etype = gen.gcon.basic.tvoid } ) false in ReflectionCFs.UniversalBaseClass.default_config gen (get_cl (get_type gen (["haxe";"lang"],"HxObject")) ) object_iface dynamic_object; ReflectionCFs.configure_dynamic_field_access rcf_ctx false; (* let closure_func = ReflectionCFs.implement_closure_cl rcf_ctx ( get_cl (get_type gen (["haxe";"lang"],"Closure")) ) in *) let closure_cl = get_cl (get_type gen (["haxe";"lang"],"Closure")) in let varargs_cl = get_cl (get_type gen (["haxe";"lang"],"VarArgsFunction")) in let dynamic_name = gen.gmk_internal_name "hx" "invokeDynamic" in List.iter (fun cl -> List.iter (fun cf -> if cf.cf_name = dynamic_name then cl.cl_overrides <- cf :: cl.cl_overrides ) cl.cl_ordered_fields ) [closure_cl; varargs_cl]; let closure_func = ReflectionCFs.get_closure_func rcf_ctx closure_cl in ReflectionCFs.implement_varargs_cl rcf_ctx ( get_cl (get_type gen (["haxe";"lang"], "VarArgsBase")) ); let slow_invoke = mk_static_field_access_infer (runtime_cl) "slowCallField" Ast.null_pos [] in ReflectionCFs.configure rcf_ctx ~slow_invoke:(fun ethis efield eargs -> { eexpr = TCall(slow_invoke, [ethis; efield; eargs]); etype = t_dynamic; epos = ethis.epos; } ) object_iface; let objdecl_fn = ReflectionCFs.implement_dynamic_object_ctor rcf_ctx dynamic_object in ObjectDeclMap.configure gen (ObjectDeclMap.traverse gen objdecl_fn); InitFunction.configure gen true true; TArrayTransform.configure gen (TArrayTransform.default_implementation gen ( fun e binop -> match e.eexpr with | TArray(e1, e2) -> (match follow e1.etype with | TDynamic _ | TAnon _ | TMono _ -> true | TInst({ cl_kind = KTypeParameter _ }, _) -> true | TInst(c,p) when erase_generics && is_hxgeneric (TClassDecl c) && is_hxgen (TClassDecl c) -> (match c.cl_path with | [],"String" | ["cs"],"NativeArray" -> false | _ -> true) | _ -> match binop, change_param_type (t_to_md e1.etype) [e.etype] with | Some(Ast.OpAssignOp _), ([TDynamic _] | [TAnon _]) -> true | _ -> false) | _ -> assert false ) "__get" "__set" ); let field_is_dynamic t field = match field_access_esp gen (gen.greal_type t) field with | FEnumField _ -> false | FClassField (cl,p,_,_,_,t,_) -> if not erase_generics then false else let p = change_param_type (TClassDecl cl) p in is_dynamic (apply_params cl.cl_params p t) | _ -> true in let is_dynamic_expr e = is_dynamic e.etype || match e.eexpr with | TField(tf, f) -> field_is_dynamic tf.etype (f) | _ -> false in let may_nullable t = match gen.gfollow#run_f t with | TType({ t_path = ([], "Null") }, [t]) -> (match follow t with | TInst({ cl_path = ([], "String") }, []) | TAbstract ({ a_path = ([], "Float") },[]) | TInst({ cl_path = (["haxe"], "Int32")}, [] ) | TInst({ cl_path = (["haxe"], "Int64")}, [] ) | TAbstract ({ a_path = ([], "Int") },[]) | TAbstract ({ a_path = ([], "Bool") },[]) -> Some t | TAbstract _ when like_float t -> Some t | t when is_cs_basic_type t -> Some t | _ -> None ) | _ -> None in let is_double t = like_float t && not (like_int t) in let is_int t = like_int t in let is_null t = match real_type t with | TInst( { cl_path = (["haxe";"lang"], "Null") }, _ ) -> true | _ -> false in let is_null_expr e = is_null e.etype || match e.eexpr with | TField(tf, f) -> (match field_access_esp gen (real_type tf.etype) (f) with | FClassField(_,_,_,_,_,actual_t,_) -> is_null actual_t | _ -> false) | _ -> false in let should_handle_opeq t = match real_type t with | TDynamic _ | TAnon _ | TMono _ | TInst( { cl_kind = KTypeParameter _ }, _ ) | TInst( { cl_path = (["haxe";"lang"], "Null") }, _ ) -> true | _ -> false in let string_cl = match gen.gcon.basic.tstring with | TInst(c,[]) -> c | _ -> assert false in let is_undefined e = match e.eexpr with | TLocal { v_name = "__undefined__" } | TField(_,FStatic({cl_path=["haxe";"lang"],"Runtime"},{cf_name="undefined"})) -> true | _ -> false in DynamicOperators.configure gen (DynamicOperators.abstract_implementation gen (fun e -> match e.eexpr with | TBinop (Ast.OpEq, e1, e2) | TBinop (Ast.OpNotEq, e1, e2) -> ( (* dont touch (v == null) and (null == v) comparisons because they are handled by HardNullableSynf later *) match e1.eexpr, e2.eexpr with | TConst(TNull), _ when (not (is_tparam e2.etype) && is_dynamic e2.etype) || is_null_expr e2 -> false | _, TConst(TNull) when (not (is_tparam e1.etype) && is_dynamic e1.etype) || is_null_expr e1 -> false | _ when is_undefined e1 || is_undefined e2 -> false | _ -> should_handle_opeq e1.etype || should_handle_opeq e2.etype ) | TBinop (Ast.OpAssignOp Ast.OpAdd, e1, e2) -> is_dynamic_expr e1 || is_null_expr e1 || is_string e.etype | TBinop (Ast.OpAdd, e1, e2) -> is_dynamic e1.etype || is_dynamic e2.etype || is_tparam e1.etype || is_tparam e2.etype || is_string e1.etype || is_string e2.etype || is_string e.etype | TBinop (Ast.OpLt, e1, e2) | TBinop (Ast.OpLte, e1, e2) | TBinop (Ast.OpGte, e1, e2) | TBinop (Ast.OpGt, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2 || is_string e1.etype || is_string e2.etype | TBinop (_, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2 | TUnop (_, _, e1) -> is_dynamic_expr e1 || is_null_expr e1 (* we will see if the expression is Null also, as the unwrap from Unop will be the same *) | _ -> false) (fun e1 e2 -> let is_basic = is_cs_basic_type (follow e1.etype) || is_cs_basic_type (follow e2.etype) in let is_ref = if is_basic then false else match follow e1.etype, follow e2.etype with | TDynamic _, _ | _, TDynamic _ | TInst( { cl_path = ([], "String") }, [] ), _ | _, TInst( { cl_path = ([], "String") }, [] ) | TInst( { cl_kind = KTypeParameter _ }, [] ), _ | _, TInst( { cl_kind = KTypeParameter _ }, [] ) -> false | _, _ -> true in let static = mk_static_field_access_infer (runtime_cl) (if is_ref then "refEq" else "eq") e1.epos [] in { eexpr = TCall(static, [e1; e2]); etype = gen.gcon.basic.tbool; epos=e1.epos } ) (fun e e1 e2 -> match may_nullable e1.etype, may_nullable e2.etype with | Some t1, Some t2 -> let t1, t2 = if is_string t1 || is_string t2 then basic.tstring, basic.tstring else if is_double t1 || is_double t2 then basic.tfloat, basic.tfloat else if is_int t1 || is_int t2 then basic.tint, basic.tint else t1, t2 in { eexpr = TBinop(Ast.OpAdd, mk_cast t1 e1, mk_cast t2 e2); etype = e.etype; epos = e1.epos } | _ when is_string e.etype || is_string e1.etype || is_string e2.etype -> { eexpr = TCall( mk_static_field_access_infer runtime_cl "concat" e.epos [], [ e1; e2 ] ); etype = basic.tstring; epos = e.epos } | _ -> let static = mk_static_field_access_infer (runtime_cl) "plus" e1.epos [] in mk_cast e.etype { eexpr = TCall(static, [e1; e2]); etype = t_dynamic; epos=e1.epos }) (fun e1 e2 -> if is_string e1.etype then begin { e1 with eexpr = TCall(mk_static_field_access_infer string_cl "Compare" e1.epos [], [ e1; e2 ]); etype = gen.gcon.basic.tint } end else begin let static = mk_static_field_access_infer (runtime_cl) "compare" e1.epos [] in { eexpr = TCall(static, [e1; e2]); etype = gen.gcon.basic.tint; epos=e1.epos } end) ~handle_strings:false); FilterClosures.configure gen (FilterClosures.traverse gen (fun e1 s -> true) closure_func); let base_exception = get_cl (get_type gen (["System"], "Exception")) in let base_exception_t = TInst(base_exception, []) in let hx_exception = get_cl (get_type gen (["haxe";"lang"], "HaxeException")) in let hx_exception_t = TInst(hx_exception, []) in let rec is_exception t = match follow t with | TInst(cl,_) -> if cl == base_exception then true else (match cl.cl_super with | None -> false | Some (cl,arg) -> is_exception (TInst(cl,arg))) | _ -> false in TryCatchWrapper.configure gen ( TryCatchWrapper.traverse gen (fun t -> not (is_exception (real_type t))) (fun throwexpr expr -> let wrap_static = mk_static_field_access (hx_exception) "wrap" (TFun([("obj",false,t_dynamic)], base_exception_t)) expr.epos in { throwexpr with eexpr = TThrow { expr with eexpr = TCall(wrap_static, [expr]); etype = hx_exception_t }; etype = gen.gcon.basic.tvoid } ) (fun v_to_unwrap pos -> let local = mk_cast hx_exception_t { eexpr = TLocal(v_to_unwrap); etype = v_to_unwrap.v_type; epos = pos } in mk_field_access gen local "obj" pos ) (fun rethrow -> { rethrow with eexpr = TCall(mk_local (alloc_var "__rethrow__" t_dynamic) rethrow.epos, [rethrow]); etype = gen.gcon.basic.tvoid } ) (base_exception_t) (hx_exception_t) (fun v e -> let exc_cl = get_cl (get_type gen (["haxe";"lang"],"Exceptions")) in let exc_field = mk_static_field_access_infer exc_cl "exception" e.epos [] in let esetstack = mk (TBinop(Ast.OpAssign, exc_field, mk_local v e.epos)) v.v_type e.epos in Type.concat esetstack e; ) ); let get_typeof e = { e with eexpr = TCall( { eexpr = TLocal( alloc_var "__typeof__" t_dynamic ); etype = t_dynamic; epos = e.epos }, [e] ) } in ClassInstance.configure gen (ClassInstance.traverse gen (fun e mt -> get_typeof e )); CastDetect.configure gen (CastDetect.default_implementation gen (Some (TEnum(empty_e, []))) (not erase_generics) ~native_string_cast:false ~overloads_cast_to_base:true); (*FollowAll.configure gen;*) SwitchToIf.configure gen (SwitchToIf.traverse gen (fun e -> match e.eexpr with | TSwitch(cond, cases, def) -> (match gen.gfollow#run_f cond.etype with | TAbstract ({ a_path = ([], "Int") },[]) | TInst({ cl_path = ([], "String") },[]) -> (List.exists (fun (c,_) -> List.exists (fun expr -> match expr.eexpr with | TConst _ -> false | _ -> true ) c ) cases) | _ -> true ) | _ -> assert false ) true ) ; ExpressionUnwrap.configure gen (ExpressionUnwrap.traverse gen (fun e -> Some { eexpr = TVar(mk_temp gen "expr" e.etype, Some e); etype = gen.gcon.basic.tvoid; epos = e.epos })); UnnecessaryCastsRemoval.configure gen; IntDivisionSynf.configure gen (IntDivisionSynf.default_implementation gen true); UnreachableCodeEliminationSynf.configure gen (UnreachableCodeEliminationSynf.traverse gen false true true false); ArrayDeclSynf.configure gen (ArrayDeclSynf.default_implementation gen native_arr_cl); let goto_special = alloc_var "__goto__" t_dynamic in let label_special = alloc_var "__label__" t_dynamic in SwitchBreakSynf.configure gen (SwitchBreakSynf.traverse gen (fun e_loop n api -> api ({ eexpr = TCall( mk_local label_special e_loop.epos, [ mk_int gen n e_loop.epos ] ); etype = t_dynamic; epos = e_loop.epos }) false; e_loop ) (fun e_break n api -> { eexpr = TCall( mk_local goto_special e_break.epos, [ mk_int gen n e_break.epos ] ); etype = t_dynamic; epos = e_break.epos } ) ); DefaultArguments.configure gen (DefaultArguments.traverse gen); InterfaceMetas.configure gen; CSharpSpecificSynf.configure gen (CSharpSpecificSynf.traverse gen runtime_cl); CSharpSpecificESynf.configure gen (CSharpSpecificESynf.traverse gen runtime_cl); let out_files = ref [] in (* copy resource files *) if Hashtbl.length gen.gcon.resources > 0 then begin let src = gen.gcon.file ^ "/src/Resources" in Hashtbl.iter (fun name v -> let name = Codegen.escape_res_name name true in let full_path = src ^ "/" ^ name in mkdir_from_path full_path; let f = open_out_bin full_path in output_string f v; close_out f; out_files := (unique_full_path full_path) :: !out_files ) gen.gcon.resources; end; (* add resources array *) (try let res = get_cl (Hashtbl.find gen.gtypes (["haxe"], "Resource")) in let cf = PMap.find "content" res.cl_statics in let res = ref [] in Hashtbl.iter (fun name v -> res := { eexpr = TConst(TString name); etype = gen.gcon.basic.tstring; epos = Ast.null_pos } :: !res; ) gen.gcon.resources; cf.cf_expr <- Some ({ eexpr = TArrayDecl(!res); etype = gen.gcon.basic.tarray gen.gcon.basic.tstring; epos = Ast.null_pos }) with | Not_found -> ()); run_filters gen; (* after the filters have been run, add all hashed fields to FieldLookup *) let normalize_i i = let i = Int32.of_int (i) in if i < Int32.zero then Int32.logor (Int32.logand i (Int32.of_int 0x3FFFFFFF)) (Int32.shift_left Int32.one 30) else i in let nhash = ref 0 in let hashes = Hashtbl.fold (fun i s acc -> incr nhash; (normalize_i i,s) :: acc) rcf_ctx.rcf_hash_fields [] in let hashes = List.sort (fun (i,s) (i2,s2) -> compare i i2) hashes in let flookup_cl = get_cl (get_type gen (["haxe";"lang"], "FieldLookup")) in let haxe_libs = List.filter (function (_,_,_,lookup) -> is_some (lookup (["haxe";"lang"], "DceNo"))) gen.gcon.net_libs in (try (* first let's see if we're adding a -net-lib that has already a haxe.lang.FieldLookup *) let name,_,_,_ = List.find (function (_,_,_,lookup) -> is_some (lookup (["haxe";"lang"], "FieldLookup"))) gen.gcon.net_libs in if not (Common.defined gen.gcon Define.DllImport) then begin gen.gcon.warning ("The -net-lib with path " ^ name ^ " contains a Haxe-generated assembly. Please define `-D dll_import` to handle Haxe-generated dll import correctly") null_pos; raise Not_found end; if not (List.exists (function (n,_,_,_) -> n = name) haxe_libs) then gen.gcon.warning ("The -net-lib with path " ^ name ^ " contains a Haxe-generated assembly, however it wasn't compiled with `-dce no`. Recompilation with `-dce no` is recommended") null_pos; (* it has; in this case, we need to add the used fields on each __init__ *) flookup_cl.cl_extern <- true; let hashs_by_path = Hashtbl.create !nhash in Hashtbl.iter (fun (path,i) s -> Hashtbl.add hashs_by_path path (i,s)) rcf_ctx.rcf_hash_paths; Hashtbl.iter (fun _ md -> match md with | TClassDecl ({ cl_extern = false; cl_interface = false } as c) -> (try let all = Hashtbl.find_all hashs_by_path c.cl_path in let all = List.map (fun (i,s) -> normalize_i i, s) all in let all = List.sort (fun (i,s) (i2,s2) -> compare i i2) all in if all <> [] then begin let add = mk_static_field_access_infer flookup_cl "addFields" c.cl_pos [] in let expr = { eexpr = TCall(add, [ mk_nativearray_decl gen basic.tint (List.map (fun (i,s) -> { eexpr = TConst(TInt (i)); etype = basic.tint; epos = c.cl_pos }) all) c.cl_pos; mk_nativearray_decl gen basic.tstring (List.map (fun (i,s) -> { eexpr = TConst(TString (s)); etype = basic.tstring; epos = c.cl_pos }) all) c.cl_pos; ]); etype = basic.tvoid; epos = c.cl_pos } in match c.cl_init with | None -> c.cl_init <- Some expr | Some e -> c.cl_init <- Some { eexpr = TBlock([expr;e]); etype = basic.tvoid; epos = e.epos } end with | Not_found -> ()) | _ -> ()) gen.gtypes; with | Not_found -> try let basic = gen.gcon.basic in let cl = flookup_cl in let field_ids = PMap.find "fieldIds" cl.cl_statics in let fields = PMap.find "fields" cl.cl_statics in field_ids.cf_expr <- Some (mk_nativearray_decl gen basic.tint (List.map (fun (i,s) -> { eexpr = TConst(TInt (i)); etype = basic.tint; epos = field_ids.cf_pos }) hashes) field_ids.cf_pos); fields.cf_expr <- Some (mk_nativearray_decl gen basic.tstring (List.map (fun (i,s) -> { eexpr = TConst(TString s); etype = basic.tstring; epos = fields.cf_pos }) hashes) fields.cf_pos); with | Not_found -> gen.gcon.error "Fields 'fieldIds' and 'fields' were not found in class haxe.lang.FieldLookup" flookup_cl.cl_pos ); if Common.defined gen.gcon Define.DllImport then begin Hashtbl.iter (fun _ md -> match md with | TClassDecl ({ cl_extern = false } as c) -> (try let extra = match c.cl_params with | _ :: _ when not erase_generics -> "_" ^ string_of_int (List.length c.cl_params) | _ -> "" in let pack = match c.cl_path with | ([], _) when no_root && is_hxgen (TClassDecl c) -> ["haxe";"root"] | (p,_) -> p in let path = (pack, snd c.cl_path ^ extra) in ignore (List.find (function (_,_,_,lookup) -> is_some (lookup path)) haxe_libs); c.cl_extern <- true; with | Not_found -> ()) | _ -> ()) gen.gtypes end; TypeParams.RenameTypeParameters.run gen; let t = Common.timer "code generation" in let parts = Str.split_delim (Str.regexp "[\\/]+") gen.gcon.file in mkdir_recursive "" parts; generate_modules gen "cs" "src" module_gen out_files; if not (Common.defined gen.gcon Define.KeepOldOutput) then clean_files (gen.gcon.file ^ "/src") !out_files gen.gcon.verbose; dump_descriptor gen ("hxcs_build.txt") path_s module_s; if ( not (Common.defined gen.gcon Define.NoCompilation) ) then begin let old_dir = Sys.getcwd() in Sys.chdir gen.gcon.file; let cmd = "haxelib run hxcs hxcs_build.txt --haxe-version " ^ (string_of_int gen.gcon.version) ^ " --feature-level 1" in print_endline cmd; if gen.gcon.run_command cmd <> 0 then failwith "Build failed"; Sys.chdir old_dir; end; t() (* end of configure function *) let generate con = (try let gen = new_ctx con in let basic = con.basic in if Common.defined_value con Define.Dce = "no" then begin let m = { null_module with m_id = alloc_mid(); m_path = ["haxe";"lang"],"DceNo" } in let cl = mk_class m (["haxe";"lang"],"DceNo") null_pos in gen.gtypes_list <- (TClassDecl cl) :: gen.gtypes_list; Hashtbl.add gen.gtypes cl.cl_path (TClassDecl cl) end; (* make the basic functions in C# *) let type_cl = get_cl ( get_type gen (["System"], "Type")) in let basic_fns = [ mk_class_field "Equals" (TFun(["obj",false,t_dynamic], basic.tbool)) true Ast.null_pos (Method MethNormal) []; mk_class_field "ToString" (TFun([], basic.tstring)) true Ast.null_pos (Method MethNormal) []; mk_class_field "GetHashCode" (TFun([], basic.tint)) true Ast.null_pos (Method MethNormal) []; mk_class_field "GetType" (TFun([], TInst(type_cl, []))) true Ast.null_pos (Method MethNormal) []; ] in List.iter (fun cf -> gen.gbase_class_fields <- PMap.add cf.cf_name cf gen.gbase_class_fields) basic_fns; configure gen with | TypeNotFound path -> con.error ("Error. Module '" ^ (path_s path) ^ "' is required and was not included in build.") Ast.null_pos); debug_mode := false (* -net-lib implementation *) open IlData open IlMeta type net_lib_ctx = { nstd : bool; ncom : Common.context; nil : IlData.ilctx; } let is_haxe_keyword = function | "callback" | "cast" | "extern" | "function" | "in" | "typedef" | "using" | "var" | "untyped" | "inline" -> true | _ -> false let hxpath_to_net ctx path = try Hashtbl.find ctx.ncom.net_path_map path with | Not_found -> [],[],"Not_found" let add_cs = function | "haxe" :: ns -> "haxe" :: ns | "std" :: ns -> "std" :: ns | "cs" :: ns -> "cs" :: ns | "system" :: ns -> "cs" :: "system" :: ns | ns -> ns let escape_chars = String.replace_chars (fun chr -> if (chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || (chr >= '0' && chr <= '9') || chr = '_' then Char.escaped chr else "_x" ^ (string_of_int (Char.code chr)) ^ "_") let netcl_to_hx cl = let cl = if String.length cl > 0 && String.get cl 0 >= 'a' && String.get cl 0 <= 'z' then Char.escaped (Char.uppercase (String.get cl 0)) ^ (String.sub cl 1 (String.length cl - 1)) else cl in try let cl, nargs = String.split cl "`" in (escape_chars cl) ^ "_" ^ nargs with | Invalid_string -> escape_chars cl let netpath_to_hx std = function | [],[], cl -> [], netcl_to_hx cl | ns,[], cl -> let ns = (List.map (fun s -> String.lowercase (escape_chars s)) ns) in add_cs ns, netcl_to_hx cl | ns,(nhd :: ntl as nested), cl -> let nested = List.map (netcl_to_hx) nested in let ns = (List.map (fun s -> String.lowercase (escape_chars s)) ns) @ [nhd] in add_cs ns, String.concat "_" nested ^ "_" ^ netcl_to_hx cl let lookup_ilclass std com ilpath = let path = netpath_to_hx std ilpath in List.fold_right (fun (_,_,_,get_raw_class) acc -> match acc with | None -> get_raw_class path | Some p -> acc ) com.net_libs None let discard_nested = function | (ns,_),cl -> (ns,[]),cl let mk_type_path ctx path params = let pack, sub, name = match path with | ns,[], cl -> ns, None, netcl_to_hx cl | ns, (nhd :: ntl as nested), cl -> let nhd = netcl_to_hx nhd in let nested = List.map (netcl_to_hx) nested in ns, Some (String.concat "_" nested ^ "_" ^ netcl_to_hx cl), nhd in CTPath { tpackage = fst (netpath_to_hx ctx.nstd (pack,[],"")); Ast.tname = name; tparams = params; tsub = sub; } let raw_type_path ctx path params = { tpackage = fst path; Ast.tname = snd path; tparams = params; tsub = None; } let rec convert_signature ctx p = function | LVoid -> mk_type_path ctx ([],[],"Void") [] | LBool -> mk_type_path ctx ([],[],"Bool") [] | LChar -> mk_type_path ctx (["cs";"types"],[],"Char16") [] | LInt8 -> mk_type_path ctx (["cs";"types"],[],"Int8") [] | LUInt8 -> mk_type_path ctx (["cs";"types"],[],"UInt8") [] | LInt16 -> mk_type_path ctx (["cs";"types"],[],"Int16") [] | LUInt16 -> mk_type_path ctx (["cs";"types"],[],"UInt16") [] | LInt32 -> mk_type_path ctx ([],[],"Int") [] | LUInt32 -> mk_type_path ctx ([],[],"UInt") [] | LInt64 -> mk_type_path ctx (["haxe"],[],"Int64") [] | LUInt64 -> mk_type_path ctx (["cs";"types"],[],"UInt64") [] | LFloat32 -> mk_type_path ctx ([],[],"Single") [] | LFloat64 -> mk_type_path ctx ([],[],"Float") [] | LString -> mk_type_path ctx (["std"],[],"String") [] | LObject -> mk_type_path ctx ([],[],"Dynamic") [] | LPointer s | LManagedPointer s -> mk_type_path ctx (["cs"],[],"Pointer") [ TPType (convert_signature ctx p s) ] | LTypedReference -> mk_type_path ctx (["cs";"system"],[],"TypedReference") [] | LIntPtr -> mk_type_path ctx (["cs";"system"],[],"IntPtr") [] | LUIntPtr -> mk_type_path ctx (["cs";"system"],[],"UIntPtr") [] | LValueType (s,args) | LClass (s,args) -> mk_type_path ctx s (List.map (fun s -> TPType (convert_signature ctx p s)) args) | LTypeParam i -> mk_type_path ctx ([],[],"T" ^ string_of_int i) [] | LMethodTypeParam i -> mk_type_path ctx ([],[],"M" ^ string_of_int i) [] | LVector s -> mk_type_path ctx (["cs"],[],"NativeArray") [TPType (convert_signature ctx p s)] (* | LArray of ilsig_norm * (int option * int option) array *) | LMethod (_,ret,args) -> CTFunction (List.map (convert_signature ctx p) args, convert_signature ctx p ret) | _ -> mk_type_path ctx ([],[], "Dynamic") [] let ilpath_s = function | ns,[], name -> path_s (ns,name) | [],nested,name -> String.concat "." nested ^ "." ^ name | ns, nested, name -> String.concat "." ns ^ "." ^ String.concat "." nested ^ "." ^ name let get_cls = function | _,_,c -> c (* TODO: When possible on Haxe, use this to detect flag enums, and make an abstract with @:op() *) (* that behaves like an enum, and with an enum as its underlying type *) let enum_is_flag ilcls = let check_flag name ns = name = "FlagsAttribute" && ns = ["System"] in List.exists (fun a -> match a.ca_type with | TypeRef r -> check_flag r.tr_name r.tr_namespace | TypeDef d -> check_flag d.td_name d.td_namespace | Method m -> (match m.m_declaring with | Some d -> check_flag d.td_name d.td_namespace | _ -> false) | MemberRef r -> (match r.memr_class with | TypeRef r -> check_flag r.tr_name r.tr_namespace | TypeDef d -> check_flag d.td_name d.td_namespace | _ -> false) | _ -> false ) ilcls.cattrs let convert_ilenum ctx p ?(is_flag=false) ilcls = let meta = ref [ Meta.Native, [EConst (String (ilpath_s ilcls.cpath) ), p], p; Meta.CsNative, [], p; ] in let data = ref [] in List.iter (fun f -> match f.fname with | "value__" -> () | _ when not (List.mem CStatic f.fflags.ff_contract) -> () | _ -> let meta, const = match f.fconstant with | Some IChar i | Some IByte i | Some IShort i -> [Meta.CsNative, [EConst (Int (string_of_int i) ), p], p ], Int64.of_int i | Some IInt i -> [Meta.CsNative, [EConst (Int (Int32.to_string i) ), p], p ], Int64.of_int32 i | Some IFloat32 f | Some IFloat64 f -> [], Int64.of_float f | Some IInt64 i -> [], i | _ -> [], Int64.zero in data := ( { ec_name = f.fname; ec_doc = None; ec_meta = meta; ec_args = []; ec_pos = p; ec_params = []; ec_type = None; }, const) :: !data; ) ilcls.cfields; let data = List.stable_sort (fun (_,i1) (_,i2) -> Int64.compare i1 i2) (List.rev !data) in let _, c = netpath_to_hx ctx.nstd ilcls.cpath in let name = netname_to_hx c in EEnum { d_name = if is_flag then name ^ "_FlagsEnum" else name; d_doc = None; d_params = []; (* enums never have type parameters *) d_meta = !meta; d_flags = [EExtern]; d_data = List.map fst data; } let rec has_unmanaged = function | LPointer _ -> true | LManagedPointer s -> has_unmanaged s | LValueType (p,pl) -> List.exists (has_unmanaged) pl | LClass (p,pl) -> List.exists (has_unmanaged) pl | LVector s -> has_unmanaged s | LArray (s,a) -> has_unmanaged s | LMethod (c,r,args) -> has_unmanaged r || List.exists (has_unmanaged) args | _ -> false let convert_ilfield ctx p field = if not (Common.defined ctx.ncom Define.Unsafe) && has_unmanaged field.fsig.snorm then raise Exit; let p = { p with pfile = p.pfile ^" (" ^field.fname ^")" } in let cff_doc = None in let cff_pos = p in let cff_meta = ref [] in let cff_name = match field.fname with | name when String.length name > 5 -> (match String.sub name 0 5 with | "__hx_" -> raise Exit | _ -> name) | name -> name in let cff_access = match field.fflags.ff_access with | FAFamily | FAFamOrAssem -> APrivate | FAPublic -> APublic | _ -> raise Exit (* private instances aren't useful on externs *) in let readonly, acc = List.fold_left (fun (readonly,acc) -> function | CStatic -> readonly, AStatic :: acc | CInitOnly | CLiteral -> true, acc | _ -> readonly,acc ) (false,[cff_access]) field.fflags.ff_contract in if PMap.mem "net_loader_debug" ctx.ncom.defines then Printf.printf "\t%sfield %s : %s\n" (if List.mem AStatic acc then "static " else "") cff_name (IlMetaDebug.ilsig_s field.fsig.ssig); let kind = match readonly with | true -> FProp ("default", "never", Some (convert_signature ctx p field.fsig.snorm), None) | false -> FVar (Some (convert_signature ctx p field.fsig.snorm), None) in let cff_name, cff_meta = if String.get cff_name 0 = '%' then let name = (String.sub cff_name 1 (String.length cff_name - 1)) in "_" ^ name, (Meta.Native, [EConst (String (name) ), cff_pos], cff_pos) :: !cff_meta else cff_name, !cff_meta in { cff_name = cff_name; cff_doc = cff_doc; cff_pos = cff_pos; cff_meta = cff_meta; cff_access = acc; cff_kind = kind; } let convert_ilevent ctx p ev = let p = { p with pfile = p.pfile ^" (" ^ev.ename ^")" } in let name = ev.ename in let kind = FVar (Some (convert_signature ctx p ev.esig.snorm), None) in let meta = [Meta.Event, [], p; Meta.Keep,[],p; Meta.SkipReflection,[],p] in let acc = [APrivate] in let add_m acc m = match m with | None -> acc | Some (name,flags) -> if List.mem (CMStatic) flags.mf_contract then AStatic :: acc else acc in if PMap.mem "net_loader_debug" ctx.ncom.defines then Printf.printf "\tevent %s : %s\n" name (IlMetaDebug.ilsig_s ev.esig.ssig); let acc = add_m acc ev.eadd in let acc = add_m acc ev.eremove in let acc = add_m acc ev.eraise in { cff_name = name; cff_doc = None; cff_pos = p; cff_meta = meta; cff_access = acc; cff_kind = kind; } let convert_ilmethod ctx p m is_explicit_impl = if not (Common.defined ctx.ncom Define.Unsafe) && has_unmanaged m.msig.snorm then raise Exit; let force_check = Common.defined ctx.ncom Define.ForceLibCheck in let p = { p with pfile = p.pfile ^" (" ^m.mname ^")" } in let cff_doc = None in let cff_pos = p in let cff_name = match m.mname with | ".ctor" -> "new" | ".cctor"-> raise Exit (* __init__ field *) | "Equals" | "GetHashCode" -> raise Exit | name when String.length name > 5 -> (match String.sub name 0 5 with | "__hx_" -> raise Exit | _ -> name) | name -> name in let acc = match m.mflags.mf_access with | FAFamily | FAFamOrAssem -> APrivate (* | FAPrivate -> APrivate *) | FAPublic when List.mem SGetter m.msemantics || List.mem SSetter m.msemantics -> APrivate | FAPublic -> APublic | _ -> if PMap.mem "net_loader_debug" ctx.ncom.defines then Printf.printf "\tmethod %s (skipped) : %s\n" cff_name (IlMetaDebug.ilsig_s m.msig.ssig); raise Exit in let is_static = ref false in let acc, is_final = List.fold_left (fun (acc,is_final) -> function | CMStatic when cff_name <> "new" -> is_static := true; AStatic :: acc, is_final | CMVirtual when is_final = None -> acc, Some false | CMFinal -> acc, Some true | _ -> acc, is_final ) ([acc],None) m.mflags.mf_contract in if PMap.mem "net_loader_debug" ctx.ncom.defines then Printf.printf "\t%smethod %s : %s\n" (if !is_static then "static " else "") cff_name (IlMetaDebug.ilsig_s m.msig.ssig); let meta = [Meta.Overload, [], p] in let meta = match is_final with | None | Some true when not force_check -> (Meta.Final,[],p) :: meta | _ -> meta in let meta = if is_explicit_impl then (Meta.NoCompletion,[],p) :: (Meta.SkipReflection,[],p) :: meta else meta in (* let meta = if List.mem OSynchronized m.mflags.mf_interop then *) (* (Meta.Synchronized,[],p) :: meta *) (* else *) (* meta *) (* in *) let rec change_sig = function | LManagedPointer s -> LManagedPointer (change_sig s) | LPointer s -> LPointer (change_sig s) | LValueType (p,pl) -> LValueType(p, List.map change_sig pl) | LClass (p,pl) -> LClass(p, List.map change_sig pl) | LTypeParam i -> LObject | LVector s -> LVector (change_sig s) | LArray (s,a) -> LArray (change_sig s, a) | LMethod (c,r,args) -> LMethod (c, change_sig r, List.map change_sig args) | p -> p in let change_sig = if !is_static then change_sig else (fun s -> s) in let ret = if String.length cff_name > 4 && String.sub cff_name 0 4 = "set_" then match m.mret.snorm, m.margs with | LVoid, [_,_,s] -> s.snorm | _ -> m.mret.snorm else m.mret.snorm in let kind = let args = List.map (fun (name,flag,s) -> let t = match s.snorm with | LManagedPointer s -> let is_out = List.mem POut flag.pf_io && not (List.mem PIn flag.pf_io) in let name = if is_out then "Out" else "Ref" in mk_type_path ctx (["cs"],[],name) [ TPType (convert_signature ctx p s) ] | _ -> convert_signature ctx p (change_sig s.snorm) in name,false,Some t,None) m.margs in let ret = convert_signature ctx p (change_sig ret) in let types = List.map (fun t -> { tp_name = "M" ^ string_of_int t.tnumber; tp_params = []; tp_constraints = []; } ) m.mtypes in FFun { f_params = types; f_args = args; f_type = Some ret; f_expr = None; } in let cff_name, cff_meta = if String.get cff_name 0 = '%' then let name = (String.sub cff_name 1 (String.length cff_name - 1)) in "_" ^ name, (Meta.Native, [EConst (String (name) ), cff_pos], cff_pos) :: meta else cff_name, meta in let acc = match m.moverride with | None -> acc | _ when cff_name = "new" -> acc | Some (path,s) -> match lookup_ilclass ctx.nstd ctx.ncom path with | Some ilcls when not (List.mem SInterface ilcls.cflags.tdf_semantics) -> AOverride :: acc | None when ctx.ncom.verbose -> prerr_endline ("(net-lib) A referenced assembly for path " ^ ilpath_s path ^ " was not found"); acc | _ -> acc in { cff_name = cff_name; cff_doc = cff_doc; cff_pos = cff_pos; cff_meta = cff_meta; cff_access = acc; cff_kind = kind; } let convert_ilprop ctx p prop is_explicit_impl = if not (Common.defined ctx.ncom Define.Unsafe) && has_unmanaged prop.psig.snorm then raise Exit; let p = { p with pfile = p.pfile ^" (" ^prop.pname ^")" } in let pmflags = match prop.pget, prop.pset with | Some(_,fl1), _ -> Some fl1 | _, Some(_,fl2) -> Some fl2 | _ -> None in let cff_access = match pmflags with | Some { mf_access = FAFamily | FAFamOrAssem } -> APrivate | Some { mf_access = FAPublic } -> APublic | _ -> raise Exit (* non-public / protected fields don't interest us *) in let access acc = acc.mf_access in let cff_access = match pmflags with | Some m when List.mem CMStatic m.mf_contract -> [AStatic;cff_access] | _ -> [cff_access] in let get = match prop.pget with | None -> "never" | Some(s,_) when String.length s <= 4 || String.sub s 0 4 <> "get_" -> raise Exit (* special (?) getter; not used *) | Some(_,m) when access m <> FAPublic -> (match access m with | FAFamily | FAFamOrAssem -> "null" | _ -> "never") | Some _ -> "get" in let set = match prop.pset with | None -> "never" | Some(s,_) when String.length s <= 4 || String.sub s 0 4 <> "set_" -> raise Exit (* special (?) getter; not used *) | Some(_,m) when access m <> FAPublic -> (match access m with | FAFamily | FAFamOrAssem -> "null" | _ -> "never"); | Some _ -> "set" in if PMap.mem "net_loader_debug" ctx.ncom.defines then Printf.printf "\tproperty %s (%s,%s) : %s\n" prop.pname get set (IlMetaDebug.ilsig_s prop.psig.ssig); let ilsig = match prop.psig.snorm with | LMethod (_,ret,[]) -> ret | s -> raise Exit in let meta = if is_explicit_impl then [ Meta.NoCompletion,[],p; Meta.SkipReflection,[],p ] else [] in let kind = FProp (get, set, Some(convert_signature ctx p ilsig), None) in { cff_name = prop.pname; cff_doc = None; cff_pos = p; cff_meta = meta; cff_access = cff_access; cff_kind = kind; } let get_type_path ctx ct = match ct with | CTPath p -> p | _ -> assert false let is_explicit ctx ilcls i = let s = match i with | LClass(path,_) | LValueType(path,_) -> ilpath_s path | _ -> assert false in let len = String.length s in List.exists (fun m -> String.length m.mname > len && String.sub m.mname 0 len = s ) ilcls.cmethods let mke e p = (e,p) let mk_special_call name p args = mke (ECast( mke (EUntyped( mke (ECall( mke (EConst(Ident name)) p, args )) p )) p , None)) p let mk_this_call name p args = mke (ECall( mke (EField(mke (EConst(Ident "this")) p ,name)) p, args )) p let mk_metas metas p = List.map (fun m -> m,[],p) metas let mk_abstract_fun name p kind metas acc = let metas = mk_metas metas p in { cff_name = name; cff_doc = None; cff_pos = p; cff_meta = metas; cff_access = acc; cff_kind = kind; } let convert_fun_arg ctx p = function | LManagedPointer s -> mk_type_path ctx (["cs"],[],"Ref") [ TPType (convert_signature ctx p s) ] | s -> convert_signature ctx p s let convert_fun ctx p ret args = let args = List.map (convert_fun_arg ctx p) args in CTFunction(args, convert_signature ctx p ret) let get_clsname ctx cpath = match netpath_to_hx ctx.nstd cpath with | (_,n) -> n let convert_delegate ctx p ilcls = let p = { p with pfile = p.pfile ^" (abstract delegate)" } in (* will have the following methods: *) (* - new (haxeType:Func) *) (* - FromHaxeFunction(haxeType) *) (* - Invoke() *) (* - AsDelegate():Super *) (* - @:op(A+B) Add(d:absType) *) (* - @:op(A-B) Remove(d:absType) *) let abs_type = mk_type_path ctx (ilcls.cpath) (List.map (fun t -> TPType (mk_type_path ctx ([],[],"T" ^ string_of_int t.tnumber) [])) ilcls.ctypes) in let invoke = List.find (fun m -> m.mname = "Invoke") ilcls.cmethods in let ret = invoke.mret.snorm in let args = List.map (fun (_,_,s) -> s.snorm) invoke.margs in let haxe_type = convert_fun ctx p ret args in let types = List.map (fun t -> { tp_name = "T" ^ string_of_int t.tnumber; tp_params = []; tp_constraints = []; } ) ilcls.ctypes in let mk_op_fn op name p = let fn_name = List.assoc op cs_binops in let clsname = match ilcls.cpath with | (ns,inner,n) -> get_clsname ctx (ns,inner,"Delegate_"^n) in let expr = (ECall( (EField( (EConst(Ident (clsname)),p), fn_name ),p), [(EConst(Ident"arg1"),p);(EConst(Ident"arg2"),p)]),p) in FFun { f_params = types; f_args = ["arg1",false,Some abs_type,None;"arg2",false,Some abs_type,None]; f_type = Some abs_type; f_expr = Some ( (EReturn (Some expr), p) ); } in let mk_op op name = let p = { p with pfile = p.pfile ^" (op " ^ name ^ ")" } in { cff_name = name; cff_doc = None; cff_pos = p; cff_meta = [ Meta.Extern,[],p ; Meta.Op, [ (EBinop(op, (EConst(Ident"A"),p), (EConst(Ident"B"),p)),p) ], p ]; cff_access = [APublic;AInline;AStatic]; cff_kind = mk_op_fn op name p; } in let params = (List.map (fun s -> TPType (mk_type_path ctx ([],[],s.tp_name) []) ) types) in let underlying_type = match ilcls.cpath with | ns,inner,name -> mk_type_path ctx (ns,inner,"Delegate_" ^ name) params in let fn_new = FFun { f_params = []; f_args = ["hxfunc",false,Some haxe_type,None]; f_type = None; f_expr = Some ( EBinop(Ast.OpAssign, (EConst(Ident "this"),p), (mk_special_call "__delegate__" p [EConst(Ident "hxfunc"),p]) ), p ); } in let fn_from_hx = FFun { f_params = types; f_args = ["hxfunc",false,Some haxe_type,None]; f_type = Some( mk_type_path ctx ilcls.cpath params ); f_expr = Some( EReturn( Some (mk_special_call "__delegate__" p [EConst(Ident "hxfunc"),p] )), p); } in let i = ref 0 in let j = ref 0 in let fn_invoke = FFun { f_params = []; f_args = List.map (fun arg -> incr i; "arg" ^ string_of_int !i, false, Some (convert_fun_arg ctx p arg), None ) args; f_type = Some(convert_signature ctx p ret); f_expr = Some( EReturn( Some ( mk_this_call "Invoke" p (List.map (fun arg -> incr j; (EConst( Ident ("arg" ^ string_of_int !j) ), p) ) args ) )), p ); } in let fn_asdel = FFun { f_params = []; f_args = []; f_type = None; f_expr = Some( EReturn( Some ( EConst(Ident "this"), p ) ), p ); } in let fn_new = mk_abstract_fun "new" p fn_new [Meta.Extern] [APublic;AInline] in let fn_from_hx = mk_abstract_fun "FromHaxeFunction" p fn_from_hx [Meta.Extern;Meta.From] [APublic;AInline;AStatic] in let fn_invoke = mk_abstract_fun "Invoke" p fn_invoke [Meta.Extern] [APublic;AInline] in let fn_asdel = mk_abstract_fun "AsDelegate" p fn_asdel [Meta.Extern] [APublic;AInline] in let _, c = netpath_to_hx ctx.nstd ilcls.cpath in EAbstract { d_name = netname_to_hx c; d_doc = None; d_params = types; d_meta = mk_metas [Meta.Delegate] p; d_flags = [AIsType underlying_type]; d_data = [fn_new;fn_from_hx;fn_invoke;fn_asdel;mk_op Ast.OpAdd "Add";mk_op Ast.OpSub "Remove"]; } let convert_ilclass ctx p ?(delegate=false) ilcls = match ilcls.csuper with | Some { snorm = LClass ((["System"],[],"Enum"),[]) } -> convert_ilenum ctx p ilcls | _ -> let flags = ref [HExtern] in (* todo: instead of CsNative, use more specific definitions *) if PMap.mem "net_loader_debug" ctx.ncom.defines then begin let sup = match ilcls.csuper with | None -> [] | Some c -> [IlMetaDebug.ilsig_s c.ssig] in let sup = sup @ List.map (fun i -> IlMetaDebug.ilsig_s i.ssig) ilcls.cimplements in print_endline ("converting " ^ ilpath_s ilcls.cpath ^ " : " ^ (String.concat ", " sup)) end; let meta = ref [Meta.CsNative, [], p; Meta.Native, [EConst (String (ilpath_s ilcls.cpath) ), p], p] in let force_check = Common.defined ctx.ncom Define.ForceLibCheck in if not force_check then meta := (Meta.LibType,[],p) :: !meta; let is_interface = ref false in List.iter (fun f -> match f with | SSealed -> meta := (Meta.Final, [], p) :: !meta | SInterface -> is_interface := true; flags := HInterface :: !flags | SAbstract -> meta := (Meta.Abstract, [], p) :: !meta | _ -> () ) ilcls.cflags.tdf_semantics; (* (match ilcls.cflags.tdf_vis with *) (* | VPublic | VNestedFamOrAssem | VNestedFamily -> () *) (* | _ -> raise Exit); *) (match ilcls.csuper with | Some { snorm = LClass ( (["System"],[],"Object"), [] ) } -> () | Some ({ snorm = LClass ( (["System"],[],"ValueType"), [] ) } as s) -> flags := HExtends (get_type_path ctx (convert_signature ctx p s.snorm)) :: !flags; meta := (Meta.Struct,[],p) :: !meta | Some { snorm = LClass ( (["haxe";"lang"],[],"HxObject"), [] ) } -> meta := (Meta.HxGen,[],p) :: !meta | Some s -> flags := HExtends (get_type_path ctx (convert_signature ctx p s.snorm)) :: !flags | _ -> ()); let has_explicit_ifaces = ref false in List.iter (fun i -> match i.snorm with | LClass ( (["haxe";"lang"],[], "IHxObject"), _ ) -> meta := (Meta.HxGen,[],p) :: !meta (* | i when is_explicit ctx ilcls i -> () *) | i -> if is_explicit ctx ilcls i then has_explicit_ifaces := true; flags := if !is_interface then HExtends (get_type_path ctx (convert_signature ctx p i)) :: !flags else HImplements (get_type_path ctx (convert_signature ctx p i)) :: !flags ) ilcls.cimplements; (* this is needed because of explicit interfaces. see http://msdn.microsoft.com/en-us/library/aa288461(v=vs.71).aspx *) (* explicit interfaces can't be mapped into Haxe in any way - since their fields can't be accessed directly, but they still implement that interface *) if !has_explicit_ifaces && force_check then (* do not check on this specific case *) meta := (Meta.LibType,[],p) :: !meta; (* ArrayAccess *) ignore (List.exists (function | { psig = { snorm = LMethod(_,ret,[v]) } } -> flags := if !is_interface then (HExtends( raw_type_path ctx ([],"ArrayAccess") [ TPType (convert_signature ctx p ret) ]) :: !flags) else (HImplements( raw_type_path ctx ([],"ArrayAccess") [ TPType (convert_signature ctx p ret) ]) :: !flags); true | _ -> false) ilcls.cprops); let fields = ref [] in let run_fields fn f = List.iter (fun f -> try fields := fn f :: !fields with | Exit -> () ) f in let meths = if !is_interface then List.filter (fun m -> m.moverride = None) ilcls.cmethods else ilcls.cmethods in run_fields (fun m -> convert_ilmethod ctx p m (List.exists (fun m2 -> m != m2 && String.get m2.mname 0 <> '.' && String.ends_with m2.mname ("." ^ m.mname)) meths) ) meths; run_fields (convert_ilfield ctx p) ilcls.cfields; run_fields (fun prop -> convert_ilprop ctx p prop (List.exists (fun p2 -> prop != p2 && String.get p2.pname 0 <> '.' && String.ends_with p2.pname ("." ^ prop.pname)) ilcls.cprops) ) ilcls.cprops; run_fields (convert_ilevent ctx p) ilcls.cevents; let params = List.map (fun p -> { tp_name = "T" ^ string_of_int p.tnumber; tp_params = []; tp_constraints = []; }) ilcls.ctypes in if delegate then begin (* add op_Addition and op_Subtraction *) let path = ilcls.cpath in let thist = mk_type_path ctx path (List.map (fun t -> TPType (mk_type_path ctx ([],[],"T" ^ string_of_int t.tnumber) [])) ilcls.ctypes) in let op name = { cff_name = name; cff_doc = None; cff_pos = p; cff_meta = []; cff_access = [APublic;AStatic]; cff_kind = FFun { f_params = params; f_args = ["arg1",false,Some thist,None;"arg2",false,Some thist,None]; f_type = Some thist; f_expr = None; }; } in fields := op "op_Addition" :: op "op_Subtraction" :: !fields; end; let path = match ilcls.cpath with | ns,inner,name when delegate -> ns,inner,"Delegate_"^name | _ -> ilcls.cpath in let _, c = netpath_to_hx ctx.nstd path in EClass { d_name = netname_to_hx c; d_doc = None; d_params = params; d_meta = !meta; d_flags = !flags; d_data = !fields; } type il_any_field = | IlField of ilfield | IlMethod of ilmethod | IlProp of ilprop let get_fname = function | IlField f -> f.fname | IlMethod m -> m.mname | IlProp p -> p.pname let is_static = function | IlField f -> List.mem CStatic f.fflags.ff_contract | IlMethod m -> List.mem CMStatic m.mflags.mf_contract | IlProp p -> List.exists (function | None -> false | Some (_,m) -> List.mem CMStatic m.mf_contract ) [p.pget;p.pset] (* | _ -> false *) let change_name name = function | IlField f -> IlField { f with fname = name } | IlMethod m -> IlMethod { m with mname = name } | IlProp p -> IlProp { p with pname = name } let compatible_methods m1 m2 = match m1,m2 with | IlMethod { msig = { snorm = LMethod(_,ret1,args1) } }, IlMethod { msig = { snorm = LMethod(_,ret2,args2) } } -> ret1 = ret2 && args1 = args2 | _ -> false let ilcls_from_ilsig ctx ilsig = let path, params = match ilsig with | LClass(path, params) | LValueType(path, params) -> path, params | LObject -> (["System"],[],"Object"),[] | _ -> raise Not_found (* all other types won't appear as superclass *) in match lookup_ilclass ctx.nstd ctx.ncom path with | None -> raise Not_found | Some c -> c, params let rec ilapply_params params = function | LManagedPointer s -> LManagedPointer (ilapply_params params s) | LPointer s -> LPointer (ilapply_params params s) | LValueType (p,pl) -> LValueType(p, List.map (ilapply_params params) pl) | LClass (p,pl) -> LClass(p, List.map (ilapply_params params) pl) | LTypeParam i -> List.nth params i (* TODO: maybe i - 1? *) | LVector s -> LVector (ilapply_params params s) | LArray (s,a) -> LArray (ilapply_params params s, a) | LMethod (c,r,args) -> LMethod (c, ilapply_params params r, List.map (ilapply_params params) args) | p -> p let ilcls_with_params ctx cls params = match cls.ctypes with | [] -> cls | _ -> { cls with cfields = List.map (fun f -> { f with fsig = { f.fsig with snorm = ilapply_params params f.fsig.snorm } }) cls.cfields; cmethods = List.map (fun m -> { m with msig = { m.msig with snorm = ilapply_params params m.msig.snorm }; margs = List.map (fun (n,f,s) -> (n,f,{ s with snorm = ilapply_params params s.snorm })) m.margs; mret = { m.mret with snorm = ilapply_params params m.mret.snorm }; }) cls.cmethods; cprops = List.map (fun p -> { p with psig = { p.psig with snorm = ilapply_params params p.psig.snorm } }) cls.cprops; csuper = Option.map (fun s -> { s with snorm = ilapply_params params s.snorm } ) cls.csuper; cimplements = List.map (fun s -> { s with snorm = ilapply_params params s.snorm } ) cls.cimplements; } let rec compatible_params t1 t2 = match t1,t2 with | LManagedPointer(s1), LManagedPointer(s2) -> compatible_params s1 s2 | LManagedPointer(s1), s2 | s1, LManagedPointer(s2) -> compatible_params s1 s2 | _ -> t1 = t2 let compatible_methods m1 m2 = match m1, m2 with | LMethod(_,r1,a1), LMethod(_,r2,a2) -> (try List.for_all2 (fun a1 a2 -> compatible_params a1 a2) a1 a2 with | Invalid_argument _ -> false) | _ -> false let compatible_field f1 f2 = match f1, f2 with | IlMethod { msig = { snorm = LMethod(_,_,a1) } }, IlMethod { msig = { snorm = LMethod(_,_,a2) } } -> a1 = a2 | IlProp p1, IlProp p2 -> (* p1.psig.snorm = p2.psig.snorm *) true | IlField f1, IlField f2 -> (* f1.fsig.snorm = f2.fsig.snorm *) true | _ -> false let get_all_fields cls = let all_fields = List.map (fun f -> IlField f, cls.cpath, f.fname, List.mem CStatic f.fflags.ff_contract) cls.cfields in let all_fields = all_fields @ List.map (fun m -> IlMethod m, cls.cpath, m.mname, List.mem CMStatic m.mflags.mf_contract) cls.cmethods in let all_fields = all_fields @ List.map (function | p -> IlProp p, cls.cpath, p.pname, is_static (IlProp p) ) cls.cprops in all_fields let normalize_ilcls ctx cls = let force_check = Common.defined ctx.ncom Define.ForceLibCheck in (* first filter out overloaded fields of same signature *) let rec loop acc = function | [] -> acc | m :: cmeths -> let static = List.mem CMStatic m.mflags.mf_contract in if List.exists (fun m2 -> m.mname = m2.mname && List.mem CMStatic m2.mflags.mf_contract = static && compatible_methods m.msig.snorm m2.msig.snorm) cmeths then loop acc cmeths else loop (m :: acc) cmeths in let meths = loop [] cls.cmethods in (* fix overrides *) (* get only the methods that aren't declared as override, but may be *) let meths = List.map (fun v -> ref v) meths in let no_overrides = List.filter (fun m -> let m = !m in not (List.mem CMStatic m.mflags.mf_contract) ) meths in let no_overrides = ref no_overrides in let all_fields = ref [] in let all_events_name = Hashtbl.create 0 in (* avoid naming collision between events and functions *) let add_cls_events_collision cls = List.iter (fun m -> if not (List.mem CMStatic m.mflags.mf_contract) then Hashtbl.replace all_events_name m.mname true) cls.cmethods; List.iter (fun p -> if not (is_static (IlProp p)) then Hashtbl.replace all_events_name p.pname true) cls.cprops; in let rec loop cls = try match cls.csuper with | Some { snorm = LClass((["System"],[],"Object"),_) } | Some { snorm = LObject } | None -> () | Some s -> let cls, params = ilcls_from_ilsig ctx s.snorm in let cls = ilcls_with_params ctx cls params in if force_check then no_overrides := List.filter (fun v -> let m = !v in let is_override_here = List.exists (fun m2 -> m2.mname = m.mname && not (List.mem CMStatic m2.mflags.mf_contract) && compatible_methods m.msig.snorm m2.msig.snorm ) cls.cmethods in if is_override_here then v := { m with moverride = Some(cls.cpath, m.mname) }; not is_override_here ) !no_overrides; all_fields := get_all_fields cls @ !all_fields; add_cls_events_collision cls; List.iter (fun ev -> Hashtbl.replace all_events_name ev.ename true) cls.cevents; loop cls with | Not_found -> () in loop cls; add_cls_events_collision cls; if force_check then List.iter (fun v -> v := { !v with moverride = None }) !no_overrides; let added = ref [] in let current_all = ref (get_all_fields cls @ !all_fields) in (* look for interfaces and add missing implementations (some methods' implementation is optional) *) let rec loop_interface cls iface = try match iface.snorm with | LClass((["System"],[],"Object"),_) | LObject -> () | LClass(path,_) when path = cls.cpath -> () | s -> let cif, params = ilcls_from_ilsig ctx s in let cif = ilcls_with_params ctx cif params in List.iter (function | (f,_,name,false) as ff -> (* look for compatible fields *) if not (List.exists (function | (f2,_,name2,false) when (name = name2 || String.ends_with name2 ("." ^ name)) -> (* consider explicit implementations as implementations *) compatible_field f f2 | _ -> false ) !current_all) then begin current_all := ff :: !current_all; added := ff :: !added end else (* ensure it's public *) List.iter (fun mref -> match !mref with | m when m.mname = name && compatible_field f (IlMethod m) -> mref := { m with mflags = { m.mflags with mf_access = FAPublic } } | _ -> () ) meths | _ -> () ) (get_all_fields cif); List.iter (loop_interface cif) cif.cimplements with | Not_found -> () in List.iter (loop_interface cls) cls.cimplements; let added = List.map (function | (IlMethod m,a,name,b) when m.mflags.mf_access <> FAPublic -> (IlMethod { m with mflags = { m.mflags with mf_access = FAPublic } },a,name,b) | (IlField f,a,name,b) when f.fflags.ff_access <> FAPublic -> (IlField { f with fflags = { f.fflags with ff_access = FAPublic } },a,name,b) | s -> s ) !added in (* filter out properties that were already declared *) let props = if force_check then List.filter (function | p -> let static = is_static (IlProp p) in let name = p.pname in not (List.exists (function (IlProp _,_,n,s) -> s = static && name = n | _ -> false) !all_fields) (* | _ -> false *) ) cls.cprops else cls.cprops in let cls = { cls with cmethods = List.map (fun v -> !v) meths; cprops = props } in let clsfields = (get_all_fields cls) @ added in let super_fields = !all_fields in all_fields := clsfields @ !all_fields; let refclsfields = (List.map (fun v -> ref v) clsfields) in (* search static / non-static name clash *) (* change field name to not collide with haxe keywords *) let fold_field acc v = let f, p, name, is_static = !v in let change, copy = match name with | _ when is_haxe_keyword name -> true, false | _ -> ((is_static && List.exists (function | (f,_,n,false) -> name = n | _ -> false) !all_fields) || (not is_static && match f with (* filter methods that have the same name as fields *) | IlMethod _ -> List.exists (function | ( (IlProp _ | IlField _),_,n,false) -> name = n | _ -> false) super_fields || List.exists (function | ( (IlProp _ | IlField _),_,n,s) -> name = n | _ -> false) clsfields | _ -> false)), true in if change then begin let name = "%" ^ name in let changed = change_name name f, p, name, is_static in if not copy then v := changed; if copy then v :: ref changed :: acc else v :: acc end else v :: acc in let refclsfields = List.fold_left fold_field [] refclsfields in let rec fold (fields,methods,props) f = match !f with | IlField f,_,_,_ -> f :: fields,methods,props | IlMethod m,_,_,_ -> fields,m :: methods,props | IlProp p,_,_,_ -> fields,methods,p :: props in let fields, methods, props = List.fold_left fold ([],[],[]) refclsfields in { cls with cfields = fields; cprops = props; cmethods = methods; cevents = List.filter (fun ev -> not (Hashtbl.mem all_events_name ev.ename)) cls.cevents; } let add_net_std com file = com.net_std <- file :: com.net_std let add_net_lib com file std = let ilctx = ref None in let netpath_to_hx = netpath_to_hx std in let real_file = ref file in let get_ctx () = match !ilctx with | Some c -> c | None -> let file = if Sys.file_exists file then file else try Common.find_file com file with | Not_found -> try Common.find_file com (file ^ ".dll") with | Not_found -> failwith (".NET lib " ^ file ^ " not found") in real_file := file; let r = PeReader.create_r (open_in_bin file) com.defines in let ctx = PeReader.read r in let clr_header = PeReader.read_clr_header ctx in let cache = IlMetaReader.create_cache () in let meta = IlMetaReader.read_meta_tables ctx clr_header cache in close_in (r.PeReader.ch); if PMap.mem "net_loader_debug" com.defines then print_endline ("for lib " ^ file); let il_typedefs = Hashtbl.copy meta.il_typedefs in Hashtbl.clear meta.il_typedefs; Hashtbl.iter (fun _ td -> let path = IlMetaTools.get_path (TypeDef td) in if PMap.mem "net_loader_debug" com.defines then Printf.printf "found %s\n" (path_s (netpath_to_hx path)); Hashtbl.replace com.net_path_map (netpath_to_hx path) path; Hashtbl.replace meta.il_typedefs path td ) il_typedefs; let meta = { nstd = std; ncom = com; nil = meta } in ilctx := Some meta; meta in let cache = Hashtbl.create 0 in let lookup path = try Hashtbl.find cache path with | Not_found -> try let ctx = get_ctx() in let ns, n, cl = hxpath_to_net ctx path in let cls = IlMetaTools.convert_class ctx.nil (ns,n,cl) in let cls = normalize_ilcls ctx cls in Hashtbl.add cache path (Some cls); Some cls with | Not_found -> Hashtbl.add cache path None; None in let all_files () = Hashtbl.fold (fun path _ acc -> match path with | _,_ :: _, _ -> acc | _ -> netpath_to_hx path :: acc) (get_ctx()).nil.il_typedefs [] in let build path = let p = { pfile = !real_file ^ " @ " ^ path_s path; pmin = 0; pmax = 0; } in let pack = match fst path with | ["haxe";"root"] -> [] | p -> p in let cp = ref [] in let rec build path = try if PMap.mem "net_loader_debug" com.defines then Printf.printf "looking up %s\n" (path_s path); match lookup path with | Some({csuper = Some{snorm = LClass( (["System"],[],("Delegate"|"MulticastDelegate")),_)}} as cls) when List.mem SSealed cls.cflags.tdf_semantics -> let ctx = get_ctx() in let hxcls = convert_ilclass ctx p ~delegate:true cls in let delegate = convert_delegate ctx p cls in cp := (hxcls,p) :: (delegate,p) :: !cp; List.iter (fun ilpath -> let path = netpath_to_hx ilpath in build path ) cls.cnested | Some cls -> let ctx = get_ctx() in let hxcls = convert_ilclass ctx p cls in cp := (hxcls,p) :: !cp; List.iter (fun ilpath -> let path = netpath_to_hx ilpath in build path ) cls.cnested | _ -> () with | Not_found | Exit -> () in build path; match !cp with | [] -> None | cp -> Some (!real_file, (pack,cp)) in let build path p = build path in com.load_extern_type <- com.load_extern_type @ [build]; com.net_libs <- (file, std, all_files, lookup) :: com.net_libs let before_generate com = (* net version *) let net_ver = try int_of_string (PMap.find "net_ver" com.defines) with | Not_found -> Common.define_value com Define.NetVer "20"; 20 in if net_ver < 20 then failwith ( ".NET version is defined to target .NET " ^ string_of_int net_ver ^ ", but the compiler can only output code to versions equal or superior to .NET 2.0 (defined as 20)" ); let rec loop = function | v :: acc when v <= net_ver -> Common.raw_define com ("NET_" ^ string_of_int v); loop acc | _ -> () in loop [20;21;30;35;40;45]; (* net target *) let net_target = try String.lowercase (PMap.find "net_target" com.defines) with | Not_found -> "net" in Common.define_value com Define.NetTarget net_target; Common.raw_define com net_target; (* std dirs *) let stds = match com.net_std with | [] -> ["netlib"] | s -> s in (* look for all dirs that have the digraph NET_TARGET-NET_VER *) let digraph = net_target ^ "-" ^ string_of_int net_ver in let matched = ref [] in List.iter (fun f -> try let f = Common.find_file com (f ^ "/" ^ digraph) in matched := (f, Unix.opendir f) :: !matched with | _ -> ()) stds; if !matched = [] then failwith ( "No .NET std lib directory with the pattern '" ^ digraph ^ "' was found in the -net-std search path. " ^ "Try updating the hxcs lib to the latest version, or specifying another -net-std path."); List.iter (fun (path,f) -> let rec loop () = try let f = Unix.readdir f in let finsens = String.lowercase f in if String.ends_with finsens ".dll" then add_net_lib com (path ^ "/" ^ f) true; loop() with | End_of_file -> Unix.closedir f in loop() ) !matched; (* now force all libraries to initialize *) List.iter (function (_,_,_,lookup) -> ignore (lookup ([],""))) com.net_libs haxe_3.2.1+dfsg.orig/genjava.ml0000664000175000017500000041751612607337712016307 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open JData open Unix open Ast open Common open Type open Gencommon open Gencommon.SourceWriter open Printf open Option open ExtString module SS = Set.Make(String) let is_boxed_type t = match follow t with | TInst ({ cl_path = (["java";"lang"], "Boolean") }, []) | TInst ({ cl_path = (["java";"lang"], "Double") }, []) | TInst ({ cl_path = (["java";"lang"], "Integer") }, []) | TInst ({ cl_path = (["java";"lang"], "Byte") }, []) | TInst ({ cl_path = (["java";"lang"], "Short") }, []) | TInst ({ cl_path = (["java";"lang"], "Character") }, []) | TInst ({ cl_path = (["java";"lang"], "Float") }, []) -> true | TAbstract ({ a_path = (["java";"lang"], "Boolean") }, []) | TAbstract ({ a_path = (["java";"lang"], "Double") }, []) | TAbstract ({ a_path = (["java";"lang"], "Integer") }, []) | TAbstract ({ a_path = (["java";"lang"], "Byte") }, []) | TAbstract ({ a_path = (["java";"lang"], "Short") }, []) | TAbstract ({ a_path = (["java";"lang"], "Character") }, []) | TAbstract ({ a_path = (["java";"lang"], "Float") }, []) -> true | _ -> false let unboxed_type gen t tbyte tshort tchar tfloat = match follow t with | TInst ({ cl_path = (["java";"lang"], "Boolean") }, []) -> gen.gcon.basic.tbool | TInst ({ cl_path = (["java";"lang"], "Double") }, []) -> gen.gcon.basic.tfloat | TInst ({ cl_path = (["java";"lang"], "Integer") }, []) -> gen.gcon.basic.tint | TInst ({ cl_path = (["java";"lang"], "Byte") }, []) -> tbyte | TInst ({ cl_path = (["java";"lang"], "Short") }, []) -> tshort | TInst ({ cl_path = (["java";"lang"], "Character") }, []) -> tchar | TInst ({ cl_path = (["java";"lang"], "Float") }, []) -> tfloat | TAbstract ({ a_path = (["java";"lang"], "Boolean") }, []) -> gen.gcon.basic.tbool | TAbstract ({ a_path = (["java";"lang"], "Double") }, []) -> gen.gcon.basic.tfloat | TAbstract ({ a_path = (["java";"lang"], "Integer") }, []) -> gen.gcon.basic.tint | TAbstract ({ a_path = (["java";"lang"], "Byte") }, []) -> tbyte | TAbstract ({ a_path = (["java";"lang"], "Short") }, []) -> tshort | TAbstract ({ a_path = (["java";"lang"], "Character") }, []) -> tchar | TAbstract ({ a_path = (["java";"lang"], "Float") }, []) -> tfloat | _ -> assert false let rec t_has_type_param t = match follow t with | TInst({ cl_kind = KTypeParameter _ }, []) -> true | TEnum(_, params) | TAbstract(_, params) | TInst(_, params) -> List.exists t_has_type_param params | TFun(f,ret) -> t_has_type_param ret || List.exists (fun (_,_,t) -> t_has_type_param t) f | _ -> false let is_type_param t = match follow t with | TInst({ cl_kind = KTypeParameter _ }, _) -> true | _ -> false let rec t_has_type_param_shallow last t = match follow t with | TInst({ cl_kind = KTypeParameter _ }, []) -> true | TEnum(_, params) | TAbstract(_, params) | TInst(_, params) when not last -> List.exists (t_has_type_param_shallow true) params | TFun(f,ret) when not last -> t_has_type_param_shallow true ret || List.exists (fun (_,_,t) -> t_has_type_param_shallow true t) f | _ -> false let rec replace_type_param t = match follow t with | TInst({ cl_kind = KTypeParameter _ }, []) -> t_dynamic | TEnum(e, params) -> TEnum(e, List.map replace_type_param params) | TAbstract(a, params) -> TAbstract(a, List.map replace_type_param params) | TInst(cl, params) -> TInst(cl, List.map replace_type_param params) | _ -> t let is_java_basic_type t = match follow t with | TInst( { cl_path = (["haxe"], "Int32") }, [] ) | TInst( { cl_path = (["haxe"], "Int64") }, [] ) | TAbstract( { a_path = ([], "Single") }, [] ) | TAbstract( { a_path = (["java"], ("Int8" | "Int16" | "Char16" | "Int64")) }, [] ) | TAbstract( { a_path = ([], "Int") }, [] ) | TAbstract( { a_path = ([], "Float") }, [] ) | TAbstract( { a_path = ([], "Bool") }, [] ) -> true | _ -> false let is_bool t = match follow t with | TAbstract ({ a_path = ([], "Bool") },[]) -> true | _ -> false let like_bool t = match follow t with | TAbstract ({ a_path = ([], "Bool") },[]) | TAbstract ({ a_path = (["java";"lang"],"Boolean") },[]) | TInst ({ cl_path = (["java";"lang"],"Boolean") },[]) -> true | _ -> false let is_int_float gen t = match follow (gen.greal_type t) with | TInst( { cl_path = (["haxe"], "Int32") }, [] ) | TAbstract( { a_path = ([], "Int") }, [] ) | TAbstract( { a_path = ([], "Float") }, [] ) -> true | (TAbstract _ as t) when like_float t && not (like_i64 t)-> true | _ -> false let parse_explicit_iface = let regex = Str.regexp "\\." in let parse_explicit_iface str = let split = Str.split regex str in let rec get_iface split pack = match split with | clname :: fn_name :: [] -> fn_name, (List.rev pack, clname) | pack_piece :: tl -> get_iface tl (pack_piece :: pack) | _ -> assert false in get_iface split [] in parse_explicit_iface let is_string t = match follow t with | TInst( { cl_path = ([], "String") }, [] ) -> true | _ -> false let is_cl t = match follow t with | TInst({ cl_path = ["java";"lang"],"Class" },_) | TAbstract({ a_path = [], ("Class"|"Enum") },_) -> true | TAnon(a) when is_some (anon_class t) -> true | _ -> false (* ******************************************* *) (* JavaSpecificESynf *) (* ******************************************* *) (* Some Java-specific syntax filters that must run before ExpressionUnwrap dependencies: It must run before ExprUnwrap, as it may not return valid Expr/Statement expressions It must run before ClassInstance, as it will detect expressions that need unchanged TTypeExpr It must run after CastDetect, as it changes casts It must run after TryCatchWrapper, to change Std.is() calls inside there *) module JavaSpecificESynf = struct let name = "java_specific_e" let priority = solve_deps name [ DBefore ExpressionUnwrap.priority; DBefore ClassInstance.priority; DAfter CastDetect.priority; DAfter TryCatchWrapper.priority ] let get_cl_from_t t = match follow t with | TInst(cl,_) -> cl | _ -> assert false let traverse gen runtime_cl = let basic = gen.gcon.basic in let float_cl = get_cl ( get_type gen (["java";"lang"], "Double")) in let i8_md = ( get_type gen (["java";"lang"], "Byte")) in let i16_md = ( get_type gen (["java";"lang"], "Short")) in let i64_md = ( get_type gen (["java";"lang"], "Long")) in let c16_md = ( get_type gen (["java";"lang"], "Character")) in let f_md = ( get_type gen (["java";"lang"], "Float")) in let bool_md = get_type gen (["java";"lang"], "Boolean") in let is_var = alloc_var "__is__" t_dynamic in let rec run e = match e.eexpr with (* Math changes *) | TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "NaN" }) ) -> mk_static_field_access_infer float_cl "NaN" e.epos [] | TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "NEGATIVE_INFINITY" }) ) -> mk_static_field_access_infer float_cl "NEGATIVE_INFINITY" e.epos [] | TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "POSITIVE_INFINITY" }) ) -> mk_static_field_access_infer float_cl "POSITIVE_INFINITY" e.epos [] | TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "isNaN"}) ) -> mk_static_field_access_infer float_cl "isNaN" e.epos [] | TCall( ({ eexpr = TField( (_ as ef), FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = ("ffloor" as f) }) ) } as fe), p) | TCall( ({ eexpr = TField( (_ as ef), FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = ("fceil" as f) }) ) } as fe), p) -> Type.map_expr run { e with eexpr = TCall({ fe with eexpr = TField(ef, FDynamic (String.sub f 1 (String.length f - 1))) }, p) } | TCall( { eexpr = TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "floor" }) ) }, _) | TCall( { eexpr = TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "round" }) ) }, _) | TCall( { eexpr = TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "ceil" }) ) }, _) -> mk_cast basic.tint (Type.map_expr run { e with etype = basic.tfloat }) | TCall( ( { eexpr = TField( _, FStatic({ cl_path = (["java";"lang"], "Math") }, { cf_name = "isFinite" }) ) } as efield ), [v]) -> { e with eexpr = TCall( mk_static_field_access_infer runtime_cl "isFinite" efield.epos [], [run v] ) } (* end of math changes *) (* Std.is() *) | TCall( { eexpr = TField( _, FStatic({ cl_path = ([], "Std") }, { cf_name = "is" })) }, [ obj; { eexpr = TTypeExpr(md) } ] ) -> let mk_is is_basic obj md = let obj = if is_basic then mk_cast t_dynamic obj else obj in { e with eexpr = TCall( { eexpr = TLocal is_var; etype = t_dynamic; epos = e.epos }, [ run obj; { eexpr = TTypeExpr md; etype = t_dynamic (* this is after all a syntax filter *); epos = e.epos } ] ) } in (match follow_module follow md with | TAbstractDecl({ a_path = ([], "Float") }) -> { eexpr = TCall( mk_static_field_access_infer runtime_cl "isDouble" e.epos [], [ run obj ] ); etype = basic.tbool; epos = e.epos } | TAbstractDecl{ a_path = ([], "Int") } -> { eexpr = TCall( mk_static_field_access_infer runtime_cl "isInt" e.epos [], [ run obj ] ); etype = basic.tbool; epos = e.epos } | TAbstractDecl{ a_path = ([], "Bool") } -> mk_is true obj bool_md | TAbstractDecl{ a_path = ([], "Single") } -> mk_is true obj f_md | TAbstractDecl{ a_path = (["java"], "Int8") } -> mk_is true obj i8_md | TAbstractDecl{ a_path = (["java"], "Int16") } -> mk_is true obj i16_md | TAbstractDecl{ a_path = (["java"], "Char16") } -> mk_is true obj c16_md | TAbstractDecl{ a_path = (["java"], "Int64") } -> mk_is true obj i64_md | TClassDecl{ cl_path = (["haxe"], "Int64") } -> mk_is true obj i64_md | TAbstractDecl{ a_path = ([], "Dynamic") } | TClassDecl{ cl_path = ([], "Dynamic") } -> (match obj.eexpr with | TLocal _ | TConst _ -> { e with eexpr = TConst(TBool true) } | _ -> { e with eexpr = TBlock([run obj; { e with eexpr = TConst(TBool true) }]) } ) | _ -> mk_is false obj md ) (* end Std.is() *) | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* JavaSpecificSynf *) (* ******************************************* *) (* Some Java-specific syntax filters that can run after ExprUnwrap dependencies: Runs after ExprUnwarp *) module JavaSpecificSynf = struct let name = "java_specific" let priority = solve_deps name [ DAfter ExpressionUnwrap.priority; DAfter ObjectDeclMap.priority; DAfter ArrayDeclSynf.priority; DBefore IntDivisionSynf.priority ] let java_hash s = let h = ref Int32.zero in let thirtyone = Int32.of_int 31 in for i = 0 to String.length s - 1 do h := Int32.add (Int32.mul thirtyone !h) (Int32.of_int (int_of_char (String.unsafe_get s i))); done; !h let rec is_final_return_expr is_switch e = let is_final_return_expr = is_final_return_expr is_switch in match e.eexpr with | TReturn _ | TThrow _ -> true (* this is hack to not use 'break' on switch cases *) | TLocal { v_name = "__fallback__" } when is_switch -> true | TCall( { eexpr = TLocal { v_name = "__goto__" } }, _ ) -> true | TParenthesis p | TMeta (_,p) -> is_final_return_expr p | TBlock bl -> is_final_return_block is_switch bl | TSwitch (_, el_e_l, edef) -> List.for_all (fun (_,e) -> is_final_return_expr e) el_e_l && Option.map_default is_final_return_expr false edef (* | TMatch (_, _, il_vl_e_l, edef) -> List.for_all (fun (_,_,e) -> is_final_return_expr e)il_vl_e_l && Option.map_default is_final_return_expr false edef *) | TIf (_,eif, Some eelse) -> is_final_return_expr eif && is_final_return_expr eelse | TFor (_,_,e) -> is_final_return_expr e | TWhile (_,e,_) -> is_final_return_expr e | TFunction tf -> is_final_return_expr tf.tf_expr | TTry (e, ve_l) -> is_final_return_expr e && List.for_all (fun (_,e) -> is_final_return_expr e) ve_l | _ -> false and is_final_return_block is_switch el = match el with | [] -> false | final :: [] -> is_final_return_expr is_switch final | hd :: tl -> is_final_return_block is_switch tl let is_null e = match e.eexpr with | TConst(TNull) -> true | _ -> false let rec is_equatable gen t = match follow t with | TInst(cl,_) -> if cl.cl_path = (["haxe";"lang"], "IEquatable") then true else List.exists (fun (cl,p) -> is_equatable gen (TInst(cl,p))) cl.cl_implements || (match cl.cl_super with | Some(cl,p) -> is_equatable gen (TInst(cl,p)) | None -> false) | _ -> false (* Changing string switch will take an expression like switch(str) { case "a": case "b": } and modify it to: { var execute_def = true; switch(str.hashCode()) { case (hashcode of a): if (str == "a") { execute_def = false; ..code here } //else if (str == otherVariableWithSameHashCode) { ... } ... } if (execute_def) { ..default code } } this might actually be slower in some cases than a if/else approach, but it scales well and as a bonus, hashCode in java are cached, so we only have the performance hit once to cache it. *) let change_string_switch gen eswitch e1 ecases edefault = let basic = gen.gcon.basic in let is_final_ret = is_final_return_expr false eswitch in let has_default = is_some edefault in let block = ref [] in let local = match e1.eexpr with | TLocal _ -> e1 | _ -> let var = mk_temp gen "svar" e1.etype in let added = { e1 with eexpr = TVar(var, Some(e1)); etype = basic.tvoid } in let local = mk_local var e1.epos in block := added :: !block; local in let execute_def_var = mk_temp gen "executeDef" gen.gcon.basic.tbool in let execute_def = mk_local execute_def_var e1.epos in let execute_def_set = { eexpr = TBinop(Ast.OpAssign, execute_def, { eexpr = TConst(TBool false); etype = basic.tbool; epos = e1.epos }); etype = basic.tbool; epos = e1.epos } in let hash_cache = ref None in let local_hashcode = ref { local with eexpr = TCall({ local with eexpr = TField(local, FDynamic "hashCode"); etype = TFun([], basic.tint); }, []); etype = basic.tint } in let get_hash_cache () = match !hash_cache with | Some c -> c | None -> let var = mk_temp gen "hash" basic.tint in let cond = !local_hashcode in block := { eexpr = TVar(var, Some cond); etype = basic.tvoid; epos = local.epos } :: !block; let local = mk_local var local.epos in local_hashcode := local; hash_cache := Some local; local in let has_case = ref false in (* first we need to reorder all cases so all collisions are close to each other *) let get_str e = match e.eexpr with | TConst(TString s) -> s | _ -> assert false in let has_conflict = ref false in let rec reorder_cases unordered ordered = match unordered with | [] -> ordered | (el, e) :: tl -> let current = Hashtbl.create 1 in List.iter (fun e -> let str = get_str e in let hash = java_hash str in Hashtbl.add current hash true ) el; let rec extract_fields cases found_cases ret_cases = match cases with | [] -> found_cases, ret_cases | (el, e) :: tl -> if List.exists (fun e -> Hashtbl.mem current (java_hash (get_str e)) ) el then begin has_conflict := true; List.iter (fun e -> Hashtbl.add current (java_hash (get_str e)) true) el; extract_fields tl ( (el, e) :: found_cases ) ret_cases end else extract_fields tl found_cases ( (el, e) :: ret_cases ) in let found, remaining = extract_fields tl [] [] in let ret = if found <> [] then let ret = List.sort (fun (e1,_) (e2,_) -> compare (List.length e2) (List.length e1) ) ( (el, e) :: found ) in let rec loop ret acc = match ret with | (el, e) :: ( (_,_) :: _ as tl ) -> loop tl ( (true, el, e) :: acc ) | (el, e) :: [] -> ( (false, el, e) :: acc ) | _ -> assert false in List.rev (loop ret []) else (false, el, e) :: [] in reorder_cases remaining (ordered @ ret) in let already_in_cases = Hashtbl.create 0 in let change_case (has_fallback, el, e) = let conds, el = List.fold_left (fun (conds,el) e -> has_case := true; match e.eexpr with | TConst(TString s) -> let hashed = java_hash s in let equals_test = { eexpr = TCall({ e with eexpr = TField(local, FDynamic "equals"); etype = TFun(["obj",false,t_dynamic],basic.tbool) }, [ e ]); etype = basic.tbool; epos = e.epos } in let hashed_expr = { eexpr = TConst(TInt hashed); etype = basic.tint; epos = e.epos } in let hashed_exprs = if !has_conflict then begin if Hashtbl.mem already_in_cases hashed then el else begin Hashtbl.add already_in_cases hashed true; hashed_expr :: el end end else hashed_expr :: el in let conds = match conds with | None -> equals_test | Some c -> (* if there is more than one case, we should test first if hash equals to the one specified. This way we can save a heavier string compare *) let equals_test = mk_paren { eexpr = TBinop(Ast.OpBoolAnd, { eexpr = TBinop(Ast.OpEq, get_hash_cache(), hashed_expr); etype = basic.tbool; epos = e.epos }, equals_test); etype = basic.tbool; epos = e.epos; } in { eexpr = TBinop(Ast.OpBoolOr, equals_test, c); etype = basic.tbool; epos = e1.epos } in Some conds, hashed_exprs | _ -> assert false ) (None,[]) el in let e = if has_default then Type.concat execute_def_set e else e in let e = if !has_conflict then Type.concat e { e with eexpr = TBreak; etype = basic.tvoid } else e in let e = { eexpr = TIf(get conds, e, None); etype = basic.tvoid; epos = e.epos } in let e = if has_fallback then { e with eexpr = TBlock([ e; mk_local (alloc_var "__fallback__" t_dynamic) e.epos]) } else e in (el, e) in let switch = { eswitch with eexpr = TSwitch(!local_hashcode, List.map change_case (reorder_cases ecases []), None); } in (if !has_case then begin (if has_default then block := { e1 with eexpr = TVar(execute_def_var, Some({ e1 with eexpr = TConst(TBool true); etype = basic.tbool })); etype = basic.tvoid } :: !block); block := switch :: !block end); (match edefault with | None -> () | Some edef when not !has_case -> block := edef :: !block | Some edef -> let eelse = if is_final_ret then Some { eexpr = TThrow { eexpr = TConst(TNull); etype = t_dynamic; epos = edef.epos }; etype = basic.tvoid; epos = edef.epos } else None in block := { edef with eexpr = TIf(execute_def, edef, eelse); etype = basic.tvoid } :: !block ); { eswitch with eexpr = TBlock(List.rev !block) } let get_cl_from_t t = match follow t with | TInst(cl,_) -> cl | _ -> assert false let traverse gen runtime_cl = let basic = gen.gcon.basic in (* let tchar = mt_to_t_dyn ( get_type gen (["java"], "Char16") ) in *) (* let tbyte = mt_to_t_dyn ( get_type gen (["java"], "Int8") ) in *) (* let tshort = mt_to_t_dyn ( get_type gen (["java"], "Int16") ) in *) (* let tsingle = mt_to_t_dyn ( get_type gen ([], "Single") ) in *) let string_ext = get_cl ( get_type gen (["haxe";"lang"], "StringExt")) in let is_string t = match follow t with | TInst({ cl_path = ([], "String") }, []) -> true | _ -> false in let rec run e = match e.eexpr with (* for new NativeArray issues *) | TNew(({ cl_path = (["java"], "NativeArray") } as cl), [t], el) when is_type_param t -> mk_cast (TInst(cl,[t])) (mk_cast t_dynamic ({ e with eexpr = TNew(cl, [t_empty], List.map run el) })) (* Std.int() *) | TCall( { eexpr = TField( _, FStatic({ cl_path = ([], "Std") }, { cf_name = "int" })) }, [obj] ) -> run (mk_cast basic.tint obj) (* end Std.int() *) | TField( ef, FInstance({ cl_path = ([], "String") }, _, { cf_name = "length" }) ) -> { e with eexpr = TCall(Type.map_expr run e, []) } | TField( ef, field ) when field_name field = "length" && is_string ef.etype -> { e with eexpr = TCall(Type.map_expr run e, []) } | TCall( ( { eexpr = TField(ef, field) } as efield ), args ) when is_string ef.etype && String.get (field_name field) 0 = '_' -> let field = field_name field in { e with eexpr = TCall({ efield with eexpr = TField(run ef, FDynamic (String.sub field 1 ( (String.length field) - 1)) )}, List.map run args) } | TCall( ( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, _, field )) } as efield ), args ) -> let field = field.cf_name in (match field with | "charAt" | "charCodeAt" | "split" | "indexOf" | "lastIndexOf" | "substring" | "substr" -> { e with eexpr = TCall(mk_static_field_access_infer string_ext field e.epos [], [run ef] @ (List.map run args)) } | _ -> { e with eexpr = TCall(run efield, List.map run args) } ) (* | TCall( { eexpr = TField(ef, FInstance({ cl_path = [], "String" }, { cf_name = ("toString") })) }, [] ) -> run ef *) (* | TCast(expr, m) when is_boxed_type e.etype -> *) (* (* let unboxed_type gen t tbyte tshort tchar tfloat = match follow t with *) *) (* run { e with etype = unboxed_type gen e.etype tbyte tshort tchar tsingle } *) | TCast(expr, _) when is_bool e.etype -> { eexpr = TCall( mk_static_field_access_infer runtime_cl "toBool" expr.epos [], [ run expr ] ); etype = basic.tbool; epos = e.epos } | TCast(expr, _) when is_int_float gen e.etype && not (is_int_float gen expr.etype) -> let needs_cast = match gen.gfollow#run_f e.etype with | TInst _ -> false | _ -> true in let fun_name = if like_int e.etype then "toInt" else "toDouble" in let ret = { eexpr = TCall( mk_static_field_access_infer runtime_cl fun_name expr.epos [], [ run expr ] ); etype = if fun_name = "toDouble" then basic.tfloat else basic.tint; epos = expr.epos } in if needs_cast then mk_cast e.etype ret else ret (*| TCast(expr, c) when is_int_float gen e.etype -> (* cases when float x = (float) (java.lang.Double val); *) (* FIXME: this fix is broken since it will fail on cases where float x = (float) (java.lang.Float val) or similar. FIX THIS *) let need_second_cast = match gen.gfollow#run_f e.etype with | TInst _ -> false | _ -> true in if need_second_cast then { e with eexpr = TCast(mk_cast (follow e.etype) (run expr), c) } else Type.map_expr run e*) | TBinop( (Ast.OpAssignOp OpAdd as op), e1, e2) | TBinop( (Ast.OpAdd as op), e1, e2) when is_string e.etype || is_string e1.etype || is_string e2.etype -> let is_assign = match op with Ast.OpAssignOp _ -> true | _ -> false in let mk_to_string e = { e with eexpr = TCall( mk_static_field_access_infer runtime_cl "toString" e.epos [], [run e] ); etype = gen.gcon.basic.tstring } in let check_cast e = match gen.greal_type e.etype with | TDynamic _ | TAbstract({ a_path = ([], "Float") }, []) | TAbstract({ a_path = ([], "Single") }, []) -> mk_to_string e | _ -> run e in { e with eexpr = TBinop(op, (if is_assign then run e1 else check_cast e1), check_cast e2) } | TCast(expr, _) when is_string e.etype -> { e with eexpr = TCall( mk_static_field_access_infer runtime_cl "toString" expr.epos [], [run expr] ) } | TSwitch(cond, ecases, edefault) when is_string cond.etype -> (*let change_string_switch gen eswitch e1 ecases edefault =*) change_string_switch gen e (run cond) (List.map (fun (el,e) -> (el, run e)) ecases) (Option.map run edefault) | TBinop( (Ast.OpNotEq as op), e1, e2) | TBinop( (Ast.OpEq as op), e1, e2) when not (is_null e2 || is_null e1) && (is_string e1.etype || is_string e2.etype || is_equatable gen e1.etype || is_equatable gen e2.etype) -> let static = mk_static_field_access_infer (runtime_cl) "valEq" e1.epos [] in let eret = { eexpr = TCall(static, [run e1; run e2]); etype = gen.gcon.basic.tbool; epos=e.epos } in if op = Ast.OpNotEq then { eret with eexpr = TUnop(Ast.Not, Ast.Prefix, eret) } else eret | TBinop( (Ast.OpNotEq | Ast.OpEq as op), e1, e2) when is_cl e1.etype && is_cl e2.etype -> { e with eexpr = TBinop(op, mk_cast t_empty (run e1), mk_cast t_empty (run e2)) } | _ -> Type.map_expr run e in run let configure gen (mapping_func:texpr->texpr) = (if java_hash "Testing string hashCode implementation from haXe" <> (Int32.of_int 545883604) then assert false); let map e = Some(mapping_func e) in gen.gsyntax_filters#add ~name:name ~priority:(PCustom priority) map end;; (* ******************************************* *) (* handle @:throws *) (* ******************************************* *) let rec is_checked_exc cl = match cl.cl_path with | ["java";"lang"],"RuntimeException" -> false | ["java";"lang"],"Throwable" -> true | _ -> match cl.cl_super with | None -> false | Some(c,_) -> is_checked_exc c let rec cls_any_super cl supers = PMap.mem cl.cl_path supers || match cl.cl_super with | None -> false | Some(c,_) -> cls_any_super c supers let rec handle_throws gen cf = List.iter (handle_throws gen) cf.cf_overloads; match cf.cf_expr with | Some ({ eexpr = TFunction(tf) } as e) -> let rec collect_throws acc = function | (Meta.Throws, [Ast.EConst (Ast.String path), _],_) :: meta -> (try collect_throws (get_cl ( get_type gen (parse_path path)) :: acc) meta with | Not_found | TypeNotFound _ -> collect_throws acc meta) | [] -> acc | _ :: meta -> collect_throws acc meta in let cf_throws = collect_throws [] cf.cf_meta in let throws = ref (List.fold_left (fun map cl -> PMap.add cl.cl_path cl map ) PMap.empty cf_throws) in let rec iter e = match e.eexpr with | TTry(etry,ecatches) -> let old = !throws in let needs_check_block = ref true in List.iter (fun (v,e) -> Type.iter iter e; match follow (run_follow gen v.v_type) with | TInst({ cl_path = ["java";"lang"],"Throwable" },_) | TDynamic _ -> needs_check_block := false | TInst(c,_) when is_checked_exc c -> throws := PMap.add c.cl_path c !throws | _ ->() ) ecatches; if !needs_check_block then Type.iter iter etry; throws := old | TField(e, (FInstance(_,_,f) | FStatic(_,f) | FClosure(_,f))) -> let tdefs = collect_throws [] f.cf_meta in if tdefs <> [] && not (List.for_all (fun c -> cls_any_super c !throws) tdefs) then raise Exit; Type.iter iter e | TThrow e -> (match follow (run_follow gen e.etype) with | TInst(c,_) when is_checked_exc c && not (cls_any_super c !throws) -> raise Exit | _ -> iter e) | _ -> Type.iter iter e in (try Type.iter iter e with | Exit -> (* needs typed exception to be caught *) let throwable = get_cl (get_type gen (["java";"lang"],"Throwable")) in let catch_var = alloc_var "typedException" (TInst(throwable,[])) in let rethrow = mk_local catch_var e.epos in let hx_exception = get_cl (get_type gen (["haxe";"lang"], "HaxeException")) in let wrap_static = mk_static_field_access (hx_exception) "wrap" (TFun([("obj",false,t_dynamic)], t_dynamic)) rethrow.epos in let wrapped = { rethrow with eexpr = TThrow { rethrow with eexpr = TCall(wrap_static, [rethrow]) }; } in let map_throws cl = let var = alloc_var "typedException" (TInst(cl,List.map (fun _ -> t_dynamic) cl.cl_params)) in var, { tf.tf_expr with eexpr = TThrow (mk_local var e.epos) } in cf.cf_expr <- Some { e with eexpr = TFunction({ tf with tf_expr = mk_block { tf.tf_expr with eexpr = TTry(tf.tf_expr, List.map (map_throws) cf_throws @ [catch_var, wrapped]) } }) }) | _ -> () let connecting_string = "?" (* ? see list here http://www.fileformat.info/info/unicode/category/index.htm and here for C# http://msdn.microsoft.com/en-us/library/aa664670.aspx *) let default_package = "java" let strict_mode = ref false (* strict mode is so we can check for unexpected information *) (* reserved java words *) let reserved = let res = Hashtbl.create 120 in List.iter (fun lst -> Hashtbl.add res lst ("_" ^ lst)) ["abstract"; "assert"; "boolean"; "break"; "byte"; "case"; "catch"; "char"; "class"; "const"; "continue"; "default"; "do"; "double"; "else"; "enum"; "extends"; "final"; "false"; "finally"; "float"; "for"; "goto"; "if"; "implements"; "import"; "instanceof"; "int"; "interface"; "long"; "native"; "new"; "null"; "package"; "private"; "protected"; "public"; "return"; "short"; "static"; "strictfp"; "super"; "switch"; "synchronized"; "this"; "throw"; "throws"; "transient"; "true"; "try"; "void"; "volatile"; "while"; ]; res let dynamic_anon = TAnon( { a_fields = PMap.empty; a_status = ref Closed } ) let rec get_class_modifiers meta cl_type cl_access cl_modifiers = match meta with | [] -> cl_type,cl_access,cl_modifiers (*| (Meta.Struct,[],_) :: meta -> get_class_modifiers meta "struct" cl_access cl_modifiers*) | (Meta.Protected,[],_) :: meta -> get_class_modifiers meta cl_type "protected" cl_modifiers | (Meta.Internal,[],_) :: meta -> get_class_modifiers meta cl_type "" cl_modifiers (* no abstract for now | (":abstract",[],_) :: meta -> get_class_modifiers meta cl_type cl_access ("abstract" :: cl_modifiers) | (Meta.Static,[],_) :: meta -> get_class_modifiers meta cl_type cl_access ("static" :: cl_modifiers) TODO: support those types *) | (Meta.Final,[],_) :: meta -> get_class_modifiers meta cl_type cl_access ("final" :: cl_modifiers) | _ :: meta -> get_class_modifiers meta cl_type cl_access cl_modifiers let rec get_fun_modifiers meta access modifiers = match meta with | [] -> access,modifiers | (Meta.Protected,[],_) :: meta -> get_fun_modifiers meta "protected" modifiers | (Meta.Internal,[],_) :: meta -> get_fun_modifiers meta "" modifiers | (Meta.ReadOnly,[],_) :: meta -> get_fun_modifiers meta access ("final" :: modifiers) (*| (Meta.Unsafe,[],_) :: meta -> get_fun_modifiers meta access ("unsafe" :: modifiers)*) | (Meta.Volatile,[],_) :: meta -> get_fun_modifiers meta access ("volatile" :: modifiers) | (Meta.Transient,[],_) :: meta -> get_fun_modifiers meta access ("transient" :: modifiers) | (Meta.Native,[],_) :: meta -> get_fun_modifiers meta access ("native" :: modifiers) | _ :: meta -> get_fun_modifiers meta access modifiers (* this was the way I found to pass the generator context to be accessible across all functions here *) (* so 'configure' is almost 'top-level' and will have all functions needed to make this work *) let configure gen = let native_arr_cl = get_cl ( get_type gen (["java"], "NativeArray") ) in gen.gclasses.nativearray <- (fun t -> TInst(native_arr_cl,[t])); gen.gclasses.nativearray_type <- (function TInst(_,[t]) -> t | _ -> assert false); gen.gclasses.nativearray_len <- (fun e p -> mk_field_access gen e "length" p); let basic = gen.gcon.basic in let fn_cl = get_cl (get_type gen (["haxe";"lang"],"Function")) in let runtime_cl = get_cl (get_type gen (["haxe";"lang"],"Runtime")) in let nulltdef = get_tdef (get_type gen ([],"Null")) in (*let string_ref = get_cl ( get_type gen (["haxe";"lang"], "StringRefl")) in*) let ti64 = match ( get_type gen (["java"], "Int64") ) with | TAbstractDecl a -> TAbstract(a,[]) | _ -> assert false in let has_tdynamic params = List.exists (fun e -> match run_follow gen e with | TDynamic _ -> true | _ -> false) params in (* The type parameters always need to be changed to their boxed counterparts *) let change_param_type md params = match md with | TClassDecl( { cl_path = (["java"], "NativeArray") } ) -> params | TAbstractDecl { a_path=[],("Class" | "Enum") } | TClassDecl { cl_path = (["java";"lang"],("Class"|"Enum")) } -> List.map (fun _ -> t_dynamic) params | _ -> match params with | [] -> [] | _ -> if has_tdynamic params then List.map (fun _ -> t_dynamic) params else List.map (fun t -> let f_t = gen.gfollow#run_f t in match f_t with | TAbstract ({ a_path = ([], "Bool") },[]) | TAbstract ({ a_path = ([],"Float") },[]) | TInst ({ cl_path = ["haxe"],"Int32" },[]) | TInst ({ cl_path = ["haxe"],"Int64" },[]) | TAbstract ({ a_path = ([],"Int") },[]) | TType ({ t_path = ["java"], "Int64" },[]) | TAbstract ({ a_path = ["java"], "Int64" },[]) | TType ({ t_path = ["java"],"Int8" },[]) | TAbstract ({ a_path = ["java"],"Int8" },[]) | TType ({ t_path = ["java"],"Int16" },[]) | TAbstract ({ a_path = ["java"],"Int16" },[]) | TType ({ t_path = ["java"],"Char16" },[]) | TAbstract ({ a_path = ["java"],"Char16" },[]) | TType ({ t_path = [],"Single" },[]) | TAbstract ({ a_path = [],"Single" },[]) -> TType(nulltdef, [f_t]) (*| TType ({ t_path = [], "Null"*) | TInst (cl, ((_ :: _) as p)) when cl.cl_path <> (["java"],"NativeArray") -> (* TInst(cl, List.map (fun _ -> t_dynamic) p) *) TInst(cl,p) | TEnum (e, ((_ :: _) as p)) -> TEnum(e, List.map (fun _ -> t_dynamic) p) | _ -> t ) params in let change_clname name = String.map (function | '$' -> '.' | c -> c) name in let change_id name = try Hashtbl.find reserved name with | Not_found -> name in let rec change_ns ns = match ns with | [] -> ["haxe"; "root"] | _ -> List.map change_id ns in let change_field = change_id in let write_id w name = write w (change_id name) in let write_field w name = write w (change_field name) in gen.gfollow#add ~name:"follow_basic" (fun t -> match t with | TAbstract ({ a_path = ([], "Bool") },[]) | TAbstract ({ a_path = ([], "Void") },[]) | TAbstract ({ a_path = ([],"Float") },[]) | TAbstract ({ a_path = ([],"Int") },[]) | TInst( { cl_path = (["haxe"], "Int32") }, [] ) | TInst( { cl_path = (["haxe"], "Int64") }, [] ) | TType ({ t_path = ["java"], "Int64" },[]) | TAbstract ({ a_path = ["java"], "Int64" },[]) | TType ({ t_path = ["java"],"Int8" },[]) | TAbstract ({ a_path = ["java"],"Int8" },[]) | TType ({ t_path = ["java"],"Int16" },[]) | TAbstract ({ a_path = ["java"],"Int16" },[]) | TType ({ t_path = ["java"],"Char16" },[]) | TAbstract ({ a_path = ["java"],"Char16" },[]) | TType ({ t_path = [],"Single" },[]) | TAbstract ({ a_path = [],"Single" },[]) -> Some t | TType (({ t_path = [],"Null" } as tdef),[t2]) -> Some (TType(tdef,[gen.gfollow#run_f t2])) | TAbstract (a, pl) when not (Meta.has Meta.CoreType a.a_meta) -> Some (gen.gfollow#run_f ( Abstract.get_underlying_type a pl) ) | TAbstract( { a_path = ([], "EnumValue") }, _ ) | TInst( { cl_path = ([], "EnumValue") }, _ ) -> Some t_dynamic | _ -> None); let change_path path = (change_ns (fst path), change_clname (snd path)) in let path_s path meta = try match Meta.get Meta.JavaCanonical meta with | (Meta.JavaCanonical, [EConst(String pack), _; EConst(String name), _], _) -> if pack = "" then name else pack ^ "." ^ name | _ -> raise Not_found with Not_found -> match path with | (ns,clname) -> path_s (change_ns ns, change_clname clname) in let cl_cl = get_cl (get_type gen (["java";"lang"],"Class")) in let rec real_type t = let t = gen.gfollow#run_f t in match t with | TAbstract (a, pl) when not (Meta.has Meta.CoreType a.a_meta) -> real_type (Abstract.get_underlying_type a pl) | TInst( { cl_path = (["haxe"], "Int32") }, [] ) -> gen.gcon.basic.tint | TInst( { cl_path = (["haxe"], "Int64") }, [] ) -> ti64 | TAbstract( { a_path = ([], "Class") }, p ) | TAbstract( { a_path = ([], "Enum") }, p ) | TInst( { cl_path = ([], "Class") }, p ) | TInst( { cl_path = ([], "Enum") }, p ) -> TInst(cl_cl,[t_dynamic]) | TEnum(e,params) -> TEnum(e, List.map (fun _ -> t_dynamic) params) | TInst(c,params) when Meta.has Meta.Enum c.cl_meta -> TInst(c, List.map (fun _ -> t_dynamic) params) | TInst({ cl_kind = KExpr _ }, _) -> t_dynamic | TInst _ -> t | TType({ t_path = ([], "Null") }, [t]) when is_java_basic_type (gen.gfollow#run_f t) -> t_dynamic | TType({ t_path = ([], "Null") }, [t]) -> (match follow t with | TInst( { cl_kind = KTypeParameter _ }, []) -> t_dynamic (* real_type t *) | _ -> real_type t ) | TType _ | TAbstract _ -> t | TAnon (anon) -> (match !(anon.a_status) with | Statics _ | EnumStatics _ | AbstractStatics _ -> t | _ -> t_dynamic) | TFun _ -> TInst(fn_cl,[]) | _ -> t_dynamic in let scope = ref PMap.empty in let imports = ref [] in let clear_scope () = scope := PMap.empty; imports := []; in let add_scope name = scope := PMap.add name () !scope in let add_import pos path meta = let name = snd path in let rec loop = function | (pack, n) :: _ when name = n -> if path <> (pack,n) then gen.gcon.error ("This expression cannot be generated because " ^ path_s path meta ^ " is shadowed by the current scope and ") pos | _ :: tl -> loop tl | [] -> (* add import *) imports := path :: !imports in loop !imports in let path_s_import pos path meta = match path with | [], name when PMap.mem name !scope -> gen.gcon.error ("This expression cannot be generated because " ^ name ^ " is shadowed by the current scope") pos; name | pack1 :: _, name when PMap.mem pack1 !scope -> (* exists in scope *) add_import pos path meta; (* check if name exists in scope *) if PMap.mem name !scope then gen.gcon.error ("This expression cannot be generated because " ^ pack1 ^ " and " ^ name ^ " are both shadowed by the current scope") pos; name | _ -> path_s path meta in let is_dynamic t = match real_type t with | TMono _ | TDynamic _ | TInst({ cl_kind = KTypeParameter _ }, _) -> true | TAnon anon -> (match !(anon.a_status) with | EnumStatics _ | Statics _ | AbstractStatics _ -> false | _ -> true ) | _ -> false in let rec t_s pos t = match real_type t with (* basic types *) | TAbstract ({ a_path = ([], "Bool") },[]) -> "boolean" | TAbstract ({ a_path = ([], "Void") },[]) -> path_s_import pos (["java";"lang"], "Object") [] | TAbstract ({ a_path = ([],"Float") },[]) -> "double" | TAbstract ({ a_path = ([],"Int") },[]) -> "int" | TType ({ t_path = ["java"], "Int64" },[]) | TAbstract ({ a_path = ["java"], "Int64" },[]) -> "long" | TType ({ t_path = ["java"],"Int8" },[]) | TAbstract ({ a_path = ["java"],"Int8" },[]) -> "byte" | TType ({ t_path = ["java"],"Int16" },[]) | TAbstract ({ a_path = ["java"],"Int16" },[]) -> "short" | TType ({ t_path = ["java"],"Char16" },[]) | TAbstract ({ a_path = ["java"],"Char16" },[]) -> "char" | TType ({ t_path = [],"Single" },[]) | TAbstract ({ a_path = [],"Single" },[]) -> "float" | TInst ({ cl_path = ["haxe"],"Int32" },[]) | TAbstract ({ a_path = ["haxe"],"Int32" },[]) -> "int" | TInst ({ cl_path = ["haxe"],"Int64" },[]) | TAbstract ({ a_path = ["haxe"],"Int64" },[]) -> "long" | TInst({ cl_path = (["java"], "NativeArray") }, [param]) -> let rec check_t_s t = match real_type t with | TInst({ cl_path = (["java"], "NativeArray") }, [param]) -> (check_t_s param) ^ "[]" | _ -> t_s pos (run_follow gen t) in (check_t_s param) ^ "[]" (* end of basic types *) | TInst ({ cl_kind = KTypeParameter _; cl_path=p }, []) -> snd p | TAbstract ({ a_path = [], "Dynamic" },[]) -> path_s_import pos (["java";"lang"], "Object") [] | TMono r -> (match !r with | None -> "java.lang.Object" | Some t -> t_s pos (run_follow gen t)) | TInst ({ cl_path = [], "String" }, []) -> path_s_import pos (["java";"lang"], "String") [] | TAbstract ({ a_path = [], "Class" }, [p]) | TAbstract ({ a_path = [], "Enum" }, [p]) | TInst ({ cl_path = [], "Class" }, [p]) | TInst ({ cl_path = [], "Enum" }, [p]) -> path_param_s pos (TClassDecl cl_cl) (["java";"lang"], "Class") [p] [] | TAbstract ({ a_path = [], "Class" }, _) | TAbstract ({ a_path = [], "Enum" }, _) | TInst ({ cl_path = [], "Class" }, _) | TInst ({ cl_path = [], "Enum" }, _) -> path_s_import pos (["java";"lang"], "Class") [] | TEnum ({e_path = p; e_meta = meta}, _) -> path_s_import pos p meta | TInst (({cl_path = p; cl_meta = meta} as cl), _) when Meta.has Meta.Enum cl.cl_meta -> path_s_import pos p meta | TInst (({cl_path = p; cl_meta = meta} as cl), params) -> (path_param_s pos (TClassDecl cl) p params meta) | TType (({t_path = p; t_meta = meta} as t), params) -> (path_param_s pos (TTypeDecl t) p params meta) | TAnon (anon) -> (match !(anon.a_status) with | Statics _ | EnumStatics _ | AbstractStatics _ -> path_s_import pos (["java";"lang"], "Class") [] | _ -> path_s_import pos (["java";"lang"], "Object") []) | TDynamic _ -> path_s_import pos (["java";"lang"], "Object") [] (* No Lazy type nor Function type made. That's because function types will be at this point be converted into other types *) | _ -> if !strict_mode then begin trace ("[ !TypeError " ^ (Type.s_type (Type.print_context()) t) ^ " ]"); assert false end else "[ !TypeError " ^ (Type.s_type (Type.print_context()) t) ^ " ]" and param_t_s pos t = match run_follow gen t with | TAbstract ({ a_path = ([], "Bool") },[]) -> path_s_import pos (["java";"lang"], "Boolean") [] | TAbstract ({ a_path = ([],"Float") },[]) -> path_s_import pos (["java";"lang"], "Double") [] | TAbstract ({ a_path = ([],"Int") },[]) -> path_s_import pos (["java";"lang"], "Integer") [] | TType ({ t_path = ["java"], "Int64" },[]) | TAbstract ({ a_path = ["java"], "Int64" },[]) -> path_s_import pos (["java";"lang"], "Long") [] | TInst ({ cl_path = ["haxe"],"Int64" },[]) | TAbstract ({ a_path = ["haxe"],"Int64" },[]) -> path_s_import pos (["java";"lang"], "Long") [] | TInst ({ cl_path = ["haxe"],"Int32" },[]) | TAbstract ({ a_path = ["haxe"],"Int32" },[]) -> path_s_import pos (["java";"lang"], "Integer") [] | TType ({ t_path = ["java"],"Int8" },[]) | TAbstract ({ a_path = ["java"],"Int8" },[]) -> path_s_import pos (["java";"lang"], "Byte") [] | TType ({ t_path = ["java"],"Int16" },[]) | TAbstract ({ a_path = ["java"],"Int16" },[]) -> path_s_import pos (["java";"lang"], "Short") [] | TType ({ t_path = ["java"],"Char16" },[]) | TAbstract ({ a_path = ["java"],"Char16" },[]) -> path_s_import pos (["java";"lang"], "Character") [] | TType ({ t_path = [],"Single" },[]) | TAbstract ({ a_path = [],"Single" },[]) -> path_s_import pos (["java";"lang"], "Float") [] | TDynamic _ -> "?" | TInst (cl, params) -> t_s pos (TInst(cl, change_param_type (TClassDecl cl) params)) | TType (cl, params) -> t_s pos (TType(cl, change_param_type (TTypeDecl cl) params)) | TEnum (e, params) -> t_s pos (TEnum(e, change_param_type (TEnumDecl e) params)) | _ -> t_s pos t and path_param_s pos md path params meta = match params with | [] -> path_s_import pos path meta | _ when has_tdynamic (change_param_type md params) -> path_s_import pos path meta | _ -> sprintf "%s<%s>" (path_s_import pos path meta) (String.concat ", " (List.map (fun t -> param_t_s pos t) (change_param_type md params))) in let rett_s pos t = match t with | TAbstract ({ a_path = ([], "Void") },[]) -> "void" | _ -> t_s pos t in let high_surrogate c = (c lsr 10) + 0xD7C0 in let low_surrogate c = (c land 0x3FF) lor 0xDC00 in let escape ichar b = match ichar with | 92 (* \ *) -> Buffer.add_string b "\\\\" | 39 (* ' *) -> Buffer.add_string b "\\\'" | 34 -> Buffer.add_string b "\\\"" | 13 (* \r *) -> Buffer.add_string b "\\r" | 10 (* \n *) -> Buffer.add_string b "\\n" | 9 (* \t *) -> Buffer.add_string b "\\t" | c when c < 32 || (c >= 127 && c <= 0xFFFF) -> Buffer.add_string b (Printf.sprintf "\\u%.4x" c) | c when c > 0xFFFF -> Buffer.add_string b (Printf.sprintf "\\u%.4x\\u%.4x" (high_surrogate c) (low_surrogate c)) | c -> Buffer.add_char b (Char.chr c) in let escape s = let b = Buffer.create 0 in (try UTF8.validate s; UTF8.iter (fun c -> escape (UChar.code c) b) s with UTF8.Malformed_code -> String.iter (fun c -> escape (Char.code c) b) s ); Buffer.contents b in let has_semicolon e = match e.eexpr with | TLocal { v_name = "__fallback__" } | TCall ({ eexpr = TLocal( { v_name = "__label__" } ) }, [ { eexpr = TConst(TInt _) } ] ) -> false | TCall ({ eexpr = TLocal( { v_name = "__lock__" } ) }, _ ) -> false | TBlock _ | TFor _ | TSwitch _ | TTry _ | TIf _ -> false | TWhile (_,_,flag) when flag = Ast.NormalWhile -> false | _ -> true in let in_value = ref false in let rec md_s pos md = let md = follow_module (gen.gfollow#run_f) md in match md with | TClassDecl (cl) -> t_s pos (TInst(cl,[])) | TEnumDecl (e) -> t_s pos (TEnum(e,[])) | TTypeDecl t -> t_s pos (TType(t, [])) | TAbstractDecl a -> t_s pos (TAbstract(a, [])) in (* it seems that Java doesn't like when you create a new array with the type parameter defined so we'll just ignore all type parameters, and hope for the best! *) let rec transform_nativearray_t t = match real_type t with | TInst( ({ cl_path = (["java"], "NativeArray") } as narr), [t]) -> TInst(narr, [transform_nativearray_t t]) | TInst(cl, params) -> TInst(cl, List.map (fun _ -> t_dynamic) params) | TEnum(e, params) -> TEnum(e, List.map (fun _ -> t_dynamic) params) | TType(t, params) -> TType(t, List.map (fun _ -> t_dynamic) params) | _ -> t in let rec extract_tparams params el = match el with | ({ eexpr = TLocal({ v_name = "$type_param" }) } as tp) :: tl -> extract_tparams (tp.etype :: params) tl | _ -> (params, el) in let line_directive = if Common.defined gen.gcon Define.RealPosition then fun w p -> () else fun w p -> let cur_line = Lexer.get_error_line p in let file = Common.get_full_path p.pfile in print w "//line %d \"%s\"" cur_line (Ast.s_escape file); newline w in let extract_statements expr = let ret = ref [] in let rec loop expr = match expr.eexpr with | TCall ({ eexpr = TLocal { v_name = "__is__" | "__typeof__" | "__array__" } }, el) -> List.iter loop el | TNew ({ cl_path = (["java"], "NativeArray") }, params, [ size ]) -> () | TUnop (Ast.Increment, _, _) | TUnop (Ast.Decrement, _, _) | TBinop (Ast.OpAssign, _, _) | TBinop (Ast.OpAssignOp _, _, _) | TLocal { v_name = "__fallback__" } | TLocal { v_name = "__sbreak__" } -> ret := expr :: !ret | TConst _ | TLocal _ | TArray _ | TBinop _ | TField _ | TEnumParameter _ | TTypeExpr _ | TObjectDecl _ | TArrayDecl _ | TCast _ | TMeta _ | TParenthesis _ | TUnop _ -> Type.iter loop expr | TFunction _ -> () (* do not extract parameters from inside of it *) | _ -> ret := expr :: !ret in loop expr; (* [expr] *) List.rev !ret in let expr_s w e = in_value := false; let rec expr_s w e = let was_in_value = !in_value in in_value := true; match e.eexpr with | TConst c -> (match c with | TInt i32 -> print w "%ld" i32; (match real_type e.etype with | TType( { t_path = (["java"], "Int64") }, [] ) -> write w "L"; | _ -> () ) | TFloat s -> write w s; (* fix for Int notation, which only fit in a Float *) (if not (String.contains s '.' || String.contains s 'e' || String.contains s 'E') then write w ".0"); (match real_type e.etype with | TType( { t_path = ([], "Single") }, [] ) -> write w "f" | _ -> () ) | TString s -> print w "\"%s\"" (escape s) | TBool b -> write w (if b then "true" else "false") | TNull -> (match real_type e.etype with | TAbstract( { a_path = (["java"], "Int64") }, [] ) | TInst( { cl_path = (["haxe"], "Int64") }, [] ) -> write w "0L" | TInst( { cl_path = (["haxe"], "Int32") }, [] ) | TAbstract ({ a_path = ([], "Int") },[]) -> expr_s w ({ e with eexpr = TConst(TInt Int32.zero) }) | TAbstract ({ a_path = ([], "Float") },[]) -> expr_s w ({ e with eexpr = TConst(TFloat "0.0") }) | TAbstract ({ a_path = ([], "Bool") },[]) -> write w "false" | TAbstract _ when like_int e.etype -> expr_s w (mk_cast e.etype { e with eexpr = TConst(TInt Int32.zero) }) | TAbstract _ when like_float e.etype -> expr_s w (mk_cast e.etype { e with eexpr = TConst(TFloat "0.0") } ) | t -> write w ("null") ) | TThis -> write w "this" | TSuper -> write w "super") | TLocal { v_name = "__fallback__" } -> () | TLocal { v_name = "__sbreak__" } -> write w "break" | TLocal { v_name = "__undefined__" } -> write w (t_s e.epos (TInst(runtime_cl, List.map (fun _ -> t_dynamic) runtime_cl.cl_params))); write w ".undefined"; | TLocal var -> write_id w var.v_name | TField(_, FEnum(en,ef)) -> let s = ef.ef_name in print w "%s." (path_s_import e.epos en.e_path en.e_meta); write_field w s | TArray (e1, e2) -> expr_s w e1; write w "["; expr_s w e2; write w "]" | TBinop ((Ast.OpAssign as op), e1, e2) | TBinop ((Ast.OpAssignOp _ as op), e1, e2) -> expr_s w e1; write w ( " " ^ (Ast.s_binop op) ^ " " ); expr_s w e2 | TBinop (op, e1, e2) -> write w "( "; expr_s w e1; write w ( " " ^ (Ast.s_binop op) ^ " " ); expr_s w e2; write w " )" | TField (e, FStatic(_, cf)) when Meta.has Meta.Native cf.cf_meta -> let rec loop meta = match meta with | (Meta.Native, [EConst (String s), _],_) :: _ -> expr_s w e; write w "."; write_field w s | _ :: tl -> loop tl | [] -> expr_s w e; write w "."; write_field w (cf.cf_name) in loop cf.cf_meta | TField (e, s) -> expr_s w e; write w "."; write_field w (field_name s) | TTypeExpr (TClassDecl { cl_path = (["haxe"], "Int32") }) -> write w (path_s_import e.epos (["haxe"], "Int32") []) | TTypeExpr (TClassDecl { cl_path = (["haxe"], "Int64") }) -> write w (path_s_import e.epos (["haxe"], "Int64") []) | TTypeExpr mt -> write w (md_s e.epos mt) | TParenthesis e -> write w "("; expr_s w e; write w ")" | TMeta (_,e) -> expr_s w e | TCall ({ eexpr = TLocal { v_name = "__array__" } }, el) | TCall ({ eexpr = TField(_, FStatic({ cl_path = (["java"],"NativeArray") }, { cf_name = "make" })) }, el) | TArrayDecl el when t_has_type_param e.etype -> let _, el = extract_tparams [] el in print w "( (%s) (new %s " (t_s e.epos e.etype) (t_s e.epos (replace_type_param e.etype)); write w "{"; ignore (List.fold_left (fun acc e -> (if acc <> 0 then write w ", "); expr_s w e; acc + 1 ) 0 el); write w "}) )" | TCall ({ eexpr = TLocal { v_name = "__array__" } }, el) | TCall ({ eexpr = TField(_, FStatic({ cl_path = (["java"],"NativeArray") }, { cf_name = "make" })) }, el) | TArrayDecl el -> let _, el = extract_tparams [] el in print w "new %s" (param_t_s e.epos (transform_nativearray_t e.etype)); let is_double = match follow e.etype with | TInst(_,[ t ]) -> if like_float t && not (like_int t) then Some t else None | _ -> None in write w "{"; ignore (List.fold_left (fun acc e -> (if acc <> 0 then write w ", "); (* this is a hack so we are able to convert ints to boxed Double / Float when needed *) let e = if is_some is_double then mk_cast (get is_double) e else e in expr_s w e; acc + 1 ) 0 el); write w "}" | TCall( ( { eexpr = TField(_, FStatic({ cl_path = ([], "String") }, { cf_name = "fromCharCode" })) } ), [cc] ) -> write w "Character.toString((char) "; expr_s w cc; write w ")" | TCall ({ eexpr = TLocal( { v_name = "__is__" } ) }, [ expr; { eexpr = TTypeExpr(md) } ] ) -> write w "( "; expr_s w expr; write w " instanceof "; write w (md_s e.epos md); write w " )" | TCall ({ eexpr = TLocal( { v_name = "__java__" } ) }, [ { eexpr = TConst(TString(s)) } ] ) -> write w s | TCall ({ eexpr = TLocal( { v_name = "__java__" } ) }, { eexpr = TConst(TString(s)) } :: tl ) -> Codegen.interpolate_code gen.gcon s tl (write w) (expr_s w) e.epos | TCall ({ eexpr = TLocal( { v_name = "__lock__" } ) }, [ eobj; eblock ] ) -> write w "synchronized("; let rec loop eobj = match eobj.eexpr with | TTypeExpr md -> expr_s w eobj; write w ".class" | TMeta(_,e) | TParenthesis(e) -> loop e | _ -> expr_s w eobj in loop eobj; write w ")"; (match eblock.eexpr with | TBlock(_ :: _) -> expr_s w eblock | _ -> begin_block w; expr_s w eblock; if has_semicolon eblock then write w ";"; end_block w; ) | TCall ({ eexpr = TLocal( { v_name = "__goto__" } ) }, [ { eexpr = TConst(TInt v) } ] ) -> print w "break label%ld" v | TCall ({ eexpr = TLocal( { v_name = "__label__" } ) }, [ { eexpr = TConst(TInt v) } ] ) -> print w "label%ld:" v | TCall ({ eexpr = TLocal( { v_name = "__typeof__" } ) }, [ { eexpr = TTypeExpr md } as expr ] ) -> expr_s w expr; write w ".class" | TCall (e, el) -> let params, el = extract_tparams [] el in expr_s w e; (*(match params with | [] -> () | params -> let md = match e.eexpr with | TField(ef, _) -> t_to_md (run_follow gen ef.etype) | _ -> assert false in write w "<"; ignore (List.fold_left (fun acc t -> (if acc <> 0 then write w ", "); write w (param_t_s (change_param_type md t)); acc + 1 ) 0 params); write w ">" );*) write w "("; ignore (List.fold_left (fun acc e -> (if acc <> 0 then write w ", "); expr_s w e; acc + 1 ) 0 el); write w ")" | TNew (({ cl_path = (["java"], "NativeArray") } as cl), params, [ size ]) -> let rec check_t_s t times = match real_type t with | TInst({ cl_path = (["java"], "NativeArray") }, [param]) -> (check_t_s param (times+1)) | _ -> print w "new %s[" (t_s e.epos (transform_nativearray_t t)); expr_s w size; print w "]"; let rec loop i = if i <= 0 then () else (write w "[]"; loop (i-1)) in loop (times - 1) in check_t_s (TInst(cl, params)) 0 | TNew ({ cl_path = ([], "String") } as cl, [], el) -> write w "new "; write w (t_s e.epos (TInst(cl, []))); write w "("; ignore (List.fold_left (fun acc e -> (if acc <> 0 then write w ", "); expr_s w e; acc + 1 ) 0 el); write w ")" | TNew ({ cl_kind = KTypeParameter _ } as cl, params, el) -> print w "null /* This code should never be reached. It was produced by the use of @:generic on a new type parameter instance: %s */" (path_param_s e.epos (TClassDecl cl) cl.cl_path params cl.cl_meta) | TNew (cl, params, el) -> write w "new "; write w (path_param_s e.epos (TClassDecl cl) cl.cl_path params cl.cl_meta); write w "("; ignore (List.fold_left (fun acc e -> (if acc <> 0 then write w ", "); expr_s w e; acc + 1 ) 0 el); write w ")" | TUnop ((Ast.Increment as op), flag, e) | TUnop ((Ast.Decrement as op), flag, e) -> (match flag with | Ast.Prefix -> write w ( " " ^ (Ast.s_unop op) ^ " " ); expr_s w e | Ast.Postfix -> expr_s w e; write w (Ast.s_unop op)) | TUnop (op, flag, e) -> (match flag with | Ast.Prefix -> write w ( " " ^ (Ast.s_unop op) ^ " (" ); expr_s w e; write w ") " | Ast.Postfix -> write w "("; expr_s w e; write w (") " ^ Ast.s_unop op)) | TVar (var, eopt) -> print w "%s " (t_s e.epos var.v_type); write_id w var.v_name; (match eopt with | None -> write w " = "; expr_s w (null var.v_type e.epos) | Some e -> write w " = "; expr_s w e ) | TBlock [e] when was_in_value -> expr_s w e | TBlock el -> begin_block w; List.iter (fun e -> List.iter (fun e -> in_value := false; line_directive w e.epos; expr_s w e; if has_semicolon e then write w ";"; newline w; ) (extract_statements e) ) el; end_block w | TIf (econd, e1, Some(eelse)) when was_in_value -> write w "( "; expr_s w (mk_paren econd); write w " ? "; expr_s w (mk_paren e1); write w " : "; expr_s w (mk_paren eelse); write w " )"; | TIf (econd, e1, eelse) -> write w "if "; expr_s w (mk_paren econd); write w " "; in_value := false; expr_s w (mk_block e1); (match eelse with | None -> () | Some e -> write w "else"; in_value := false; expr_s w (mk_block e) ) | TWhile (econd, eblock, flag) -> (match flag with | Ast.NormalWhile -> write w "while "; expr_s w (mk_paren econd); write w ""; in_value := false; expr_s w (mk_block eblock) | Ast.DoWhile -> write w "do "; in_value := false; expr_s w (mk_block eblock); write w "while "; in_value := true; expr_s w (mk_paren econd); ) | TSwitch (econd, ele_l, default) -> write w "switch "; expr_s w (mk_paren econd); begin_block w; List.iter (fun (el, e) -> List.iter (fun e -> write w "case "; in_value := true; (match e.eexpr with | TField(_,FEnum(e,ef)) -> write w ef.ef_name | _ -> expr_s w e); write w ":"; newline w; ) el; in_value := false; expr_s w (mk_block e); newline w; newline w ) ele_l; if is_some default then begin write w "default:"; newline w; in_value := false; expr_s w (get default); newline w; end; end_block w | TTry (tryexpr, ve_l) -> write w "try "; in_value := false; expr_s w (mk_block tryexpr); let pos = e.epos in List.iter (fun (var, e) -> print w "catch (%s %s)" (t_s pos var.v_type) (var.v_name); in_value := false; expr_s w (mk_block e); newline w ) ve_l | TReturn eopt -> write w "return "; if is_some eopt then expr_s w (get eopt) | TBreak -> write w "break" | TContinue -> write w "continue" | TThrow e -> write w "throw "; expr_s w e | TCast (e1,md_t) -> ((*match gen.gfollow#run_f e.etype with | TType({ t_path = ([], "UInt") }, []) -> write w "( unchecked ((uint) "; expr_s w e1; write w ") )" | _ ->*) (* FIXME I'm ignoring module type *) print w "((%s) (" (t_s e.epos e.etype); expr_s w e1; write w ") )" ) | TFor (_,_,content) -> write w "[ for not supported "; expr_s w content; write w " ]"; if !strict_mode then assert false | TObjectDecl _ -> write w "[ obj decl not supported ]"; if !strict_mode then assert false | TFunction _ -> write w "[ func decl not supported ]"; if !strict_mode then assert false | TEnumParameter _ -> write w "[ enum parameter not supported ]"; if !strict_mode then assert false in expr_s w e in let rec gen_fpart_attrib w = function | EConst( Ident i ), _ -> write w i | EField( ef, f ), _ -> gen_fpart_attrib w ef; write w "."; write w f | _, p -> gen.gcon.error "Invalid expression inside @:meta metadata" p in let rec gen_spart w = function | EConst c, p -> (match c with | Int s | Float s | Ident s -> write w s | String s -> write w "\""; write w (escape s); write w "\"" | _ -> gen.gcon.error "Invalid expression inside @:meta metadata" p) | EField( ef, f ), _ -> gen_spart w ef; write w "."; write w f | EBinop( Ast.OpAssign, (EConst (Ident s), _), e2 ), _ -> write w s; write w " = "; gen_spart w e2 | EArrayDecl( el ), _ -> write w "{"; let fst = ref true in List.iter (fun e -> if !fst then fst := false else write w ", "; gen_spart w e ) el; write w "}" | ECall(fpart,args), _ -> gen_fpart_attrib w fpart; write w "("; let fst = ref true in List.iter (fun e -> if !fst then fst := false else write w ", "; gen_spart w e ) args; write w ")" | _, p -> gen.gcon.error "Invalid expression inside @:meta metadata" p in let gen_annotations w ?(add_newline=true) metadata = List.iter (function | Meta.Meta, [meta], _ -> write w "@"; gen_spart w meta; if add_newline then newline w else write w " "; | _ -> () ) metadata in let argt_s p t = let w = new_source_writer () in let rec run t = match t with | TType (tdef,p) -> gen_annotations w ~add_newline:false tdef.t_meta; run (follow_once t) | TMono r -> (match !r with | Some t -> run t | _ -> () (* avoid infinite loop / should be the same in this context *)) | TLazy f -> run (!f()) | _ -> () in run t; let ret = t_s p t in let c = contents w in if c <> "" then c ^ " " ^ ret else ret in let get_string_params cl_params = match cl_params with | [] -> ("","") | _ -> let params = sprintf "<%s>" (String.concat ", " (List.map (fun (_, tcl) -> match follow tcl with | TInst(cl, _) -> snd cl.cl_path | _ -> assert false) cl_params)) in let params_extends = List.fold_left (fun acc (name, t) -> match run_follow gen t with | TInst (cl, p) -> (match cl.cl_implements with | [] -> acc | _ -> acc) (* TODO | _ -> (sprintf " where %s : %s" name (String.concat ", " (List.map (fun (cl,p) -> path_param_s (TClassDecl cl) cl.cl_path p) cl.cl_implements))) :: acc ) *) | _ -> trace (t_s Ast.null_pos t); assert false (* FIXME it seems that a cl_params will never be anything other than cl.cl_params. I'll take the risk and fail if not, just to see if that confirms *) ) [] cl_params in (params, String.concat " " params_extends) in let write_parts w parts = let parts = List.filter (fun s -> s <> "") parts in write w (String.concat " " parts) in let rec gen_class_field w ?(is_overload=false) is_static cl is_final cf = let is_interface = cl.cl_interface in let name, is_new, is_explicit_iface = match cf.cf_name with | "new" -> snd cl.cl_path, true, false | name when String.contains name '.' -> let fn_name, path = parse_explicit_iface name in (path_s path cl.cl_meta) ^ "." ^ fn_name, false, true | name -> name, false, false in (match cf.cf_kind with | Var _ | Method (MethDynamic) when not (Type.is_extern_field cf) -> (if is_overload || List.exists (fun cf -> cf.cf_expr <> None) cf.cf_overloads then gen.gcon.error "Only normal (non-dynamic) methods can be overloaded" cf.cf_pos); if not is_interface then begin let access, modifiers = get_fun_modifiers cf.cf_meta "public" [] in write_parts w (access :: (if is_static then "static" else "") :: modifiers @ [(t_s cf.cf_pos (run_follow gen cf.cf_type)); (change_field name)]); (match cf.cf_expr with | Some e -> write w " = "; expr_s w e; write w ";" | None -> write w ";" ) end (* TODO see how (get,set) variable handle when they are interfaces *) | Method _ when Type.is_extern_field cf || (match cl.cl_kind, cf.cf_expr with | KAbstractImpl _, None -> true | _ -> false) -> List.iter (fun cf -> if cl.cl_interface || cf.cf_expr <> None then gen_class_field w ~is_overload:true is_static cl (Meta.has Meta.Final cf.cf_meta) cf ) cf.cf_overloads | Var _ | Method MethDynamic -> () | Method mkind -> List.iter (fun cf -> if cl.cl_interface || cf.cf_expr <> None then gen_class_field w ~is_overload:true is_static cl (Meta.has Meta.Final cf.cf_meta) cf ) cf.cf_overloads; let is_virtual = is_new || (not is_final && match mkind with | MethInline -> false | _ when not is_new -> true | _ -> false) in let is_override = match cf.cf_name with | "equals" when not is_static -> (match cf.cf_type with | TFun([_,_,t], ret) -> (match (real_type t, real_type ret) with | TDynamic _, TAbstract ({ a_path = ([], "Bool") },[]) | TAnon _, TAbstract ({ a_path = ([], "Bool") },[]) -> true | _ -> List.memq cf cl.cl_overrides ) | _ -> List.memq cf cl.cl_overrides) | "toString" when not is_static -> (match cf.cf_type with | TFun([], ret) -> (match real_type ret with | TInst( { cl_path = ([], "String") }, []) -> true | _ -> gen.gcon.error "A toString() function should return a String!" cf.cf_pos; false ) | _ -> List.memq cf cl.cl_overrides ) | "hashCode" when not is_static -> (match cf.cf_type with | TFun([], ret) -> (match real_type ret with | TAbstract ({ a_path = ([], "Int") },[]) -> true | _ -> gen.gcon.error "A hashCode() function should return an Int!" cf.cf_pos; false ) | _ -> List.memq cf cl.cl_overrides ) | _ -> List.memq cf cl.cl_overrides in let visibility = if is_interface then "" else "public" in let visibility, modifiers = get_fun_modifiers cf.cf_meta visibility [] in let visibility, is_virtual = if is_explicit_iface then "",false else visibility, is_virtual in let v_n = if is_static then "static" else if is_override && not is_interface then "" else if not is_virtual then "final" else "" in let cf_type = if is_override && not is_overload && not (Meta.has Meta.Overload cf.cf_meta) then match field_access gen (TInst(cl, List.map snd cl.cl_params)) cf.cf_name with | FClassField(_,_,_,_,_,actual_t,_) -> actual_t | _ -> assert false else cf.cf_type in let params = List.map snd cl.cl_params in let ret_type, args = match follow cf_type, follow cf.cf_type with | TFun (strbtl, t), TFun(rargs, _) -> (apply_params cl.cl_params params (real_type t), List.map2 (fun(_,_,t) (n,o,_) -> (n,o,apply_params cl.cl_params params (real_type t))) strbtl rargs) | _ -> assert false in (if is_override && not is_interface then write w "@Override "); gen_annotations w cf.cf_meta; (* public static void funcName *) let params, _ = get_string_params cf.cf_params in write_parts w (visibility :: v_n :: modifiers @ [params; (if is_new then "" else rett_s cf.cf_pos (run_follow gen ret_type)); (change_field name)]); (* (string arg1, object arg2) with T : object *) (match cf.cf_expr with | Some { eexpr = TFunction tf } -> print w "(%s)" (String.concat ", " (List.map2 (fun (var,_) (_,_,t) -> sprintf "%s %s" (argt_s cf.cf_pos (run_follow gen t)) (change_id var.v_name)) tf.tf_args args)) | _ -> print w "(%s)" (String.concat ", " (List.map (fun (name, _, t) -> sprintf "%s %s" (argt_s cf.cf_pos (run_follow gen t)) (change_id name)) args)) ); if is_interface || List.mem "native" modifiers then write w ";" else begin let rec loop meta = match meta with | [] -> let expr = match cf.cf_expr with | None -> mk (TBlock([])) t_dynamic Ast.null_pos | Some s -> match s.eexpr with | TFunction tf -> mk_block (tf.tf_expr) | _ -> assert false (* FIXME *) in (if is_new then begin (*let rec get_super_call el = match el with | ( { eexpr = TCall( { eexpr = TConst(TSuper) }, _) } as call) :: rest -> Some call, rest | ( { eexpr = TBlock(bl) } as block ) :: rest -> let ret, mapped = get_super_call bl in ret, ( { block with eexpr = TBlock(mapped) } :: rest ) | _ -> None, el in*) expr_s w expr end else begin expr_s w expr; end) | (Meta.Throws, [Ast.EConst (Ast.String t), _], _) :: tl -> print w " throws %s" t; loop tl | (Meta.FunctionCode, [Ast.EConst (Ast.String contents),_],_) :: tl -> begin_block w; write w contents; end_block w | _ :: tl -> loop tl in loop cf.cf_meta end); newline w; newline w in let gen_class w cl = let cf_filters = [ handle_throws ] in List.iter (fun f -> List.iter (f gen) cl.cl_ordered_fields) cf_filters; List.iter (fun f -> List.iter (f gen) cl.cl_ordered_statics) cf_filters; let should_close = match change_ns (fst cl.cl_path) with | [] -> false | ns -> print w "package %s;" (String.concat "." (change_ns ns)); newline w; newline w; false in let rec loop_meta meta acc = match meta with | (Meta.SuppressWarnings, [Ast.EConst (Ast.String w),_],_) :: meta -> loop_meta meta (w :: acc) | _ :: meta -> loop_meta meta acc | _ -> acc in let suppress_warnings = loop_meta cl.cl_meta [ "rawtypes"; "unchecked" ] in write w "import haxe.root.*;"; newline w; let w_header = w in let w = new_source_writer () in clear_scope(); (* add all haxe.root.* to imports *) List.iter (function | TClassDecl { cl_path = ([],c) } -> imports := ([],c) :: !imports | TEnumDecl { e_path = ([],c) } -> imports := ([],c) :: !imports | TAbstractDecl { a_path = ([],c) } -> imports := ([],c) :: !imports | _ -> () ) gen.gtypes_list; newline w; write w "@SuppressWarnings(value={"; let first = ref true in List.iter (fun s -> (if !first then first := false else write w ", "); print w "\"%s\"" (escape s) ) suppress_warnings; write w "})"; newline w; gen_annotations w cl.cl_meta; let clt, access, modifiers = get_class_modifiers cl.cl_meta (if cl.cl_interface then "interface" else "class") "public" [] in let is_final = Meta.has Meta.Final cl.cl_meta in write_parts w (access :: modifiers @ [clt; (change_clname (snd cl.cl_path))]); (* type parameters *) let params, _ = get_string_params cl.cl_params in let cl_p_to_string (c,p) = let p = List.map (fun t -> match follow t with | TMono _ | TDynamic _ -> t_empty | _ -> t) p in path_param_s cl.cl_pos (TClassDecl c) c.cl_path p c.cl_meta in print w "%s" params; (if is_some cl.cl_super then print w " extends %s" (cl_p_to_string (get cl.cl_super))); (match cl.cl_implements with | [] -> () | _ -> print w " %s %s" (if cl.cl_interface then "extends" else "implements") (String.concat ", " (List.map cl_p_to_string cl.cl_implements)) ); (* class head ok: *) (* public class Test : X, Y, Z where A : Y *) begin_block w; (* our constructor is expected to be a normal "new" function * if !strict_mode && is_some cl.cl_constructor then assert false;*) let rec loop cl = List.iter (fun cf -> add_scope cf.cf_name) cl.cl_ordered_fields; List.iter (fun cf -> add_scope cf.cf_name) cl.cl_ordered_statics; match cl.cl_super with | Some(c,_) -> loop c | None -> () in loop cl; let rec loop meta = match meta with | [] -> () | (Meta.ClassCode, [Ast.EConst (Ast.String contents),_],_) :: tl -> write w contents | _ :: tl -> loop tl in loop cl.cl_meta; (match gen.gcon.main_class with | Some path when path = cl.cl_path -> write w "public static void main(String[] args)"; begin_block w; (try let t = Hashtbl.find gen.gtypes ([], "Sys") in match t with | TClassDecl(cl) when PMap.mem "_args" cl.cl_statics -> write w "Sys._args = args;"; newline w | _ -> () with | Not_found -> () ); write w "main();"; end_block w; newline w | _ -> () ); (match cl.cl_init with | None -> () | Some init -> write w "static"; expr_s w (mk_block init); newline w ); (if is_some cl.cl_constructor then gen_class_field w false cl is_final (get cl.cl_constructor)); (if not cl.cl_interface then List.iter (gen_class_field w true cl is_final) cl.cl_ordered_statics); List.iter (gen_class_field w false cl is_final) cl.cl_ordered_fields; end_block w; if should_close then end_block w; (* add imports *) List.iter (function | ["haxe";"root"], _ | [], _ -> () | path -> write w_header "import "; write w_header (path_s path []); write w_header ";\n" ) !imports; add_writer w w_header in let gen_enum w e = let should_close = match change_ns (fst e.e_path) with | [] -> false | ns -> print w "package %s;" (String.concat "." (change_ns ns)); newline w; newline w; false in gen_annotations w e.e_meta; print w "public enum %s" (change_clname (snd e.e_path)); begin_block w; write w (String.concat ", " (List.map (change_id) e.e_names)); end_block w; if should_close then end_block w in let module_type_gen w md_tp = match md_tp with | TClassDecl cl -> if not cl.cl_extern then begin gen_class w cl; newline w; newline w end; (not cl.cl_extern) | TEnumDecl e -> if not e.e_extern && not (Meta.has Meta.Class e.e_meta) then begin gen_enum w e; newline w; newline w end; (not e.e_extern) | TTypeDecl e -> false | TAbstractDecl a -> false in let module_gen w md = module_type_gen w md in (* generate source code *) init_ctx gen; Hashtbl.add gen.gspecial_vars "__label__" true; Hashtbl.add gen.gspecial_vars "__goto__" true; Hashtbl.add gen.gspecial_vars "__is__" true; Hashtbl.add gen.gspecial_vars "__typeof__" true; Hashtbl.add gen.gspecial_vars "__java__" true; Hashtbl.add gen.gspecial_vars "__lock__" true; Hashtbl.add gen.gspecial_vars "__array__" true; gen.greal_type <- real_type; gen.greal_type_param <- change_param_type; SetHXGen.run_filter gen SetHXGen.default_hxgen_func; (* before running the filters, follow all possible types *) (* this is needed so our module transformations don't break some core features *) (* like multitype selection *) let run_follow_gen = run_follow gen in let rec type_map e = Type.map_expr_type (fun e->type_map e) (run_follow_gen) (fun tvar-> tvar.v_type <- (run_follow_gen tvar.v_type); tvar) e in let super_map (cl,tl) = (cl, List.map run_follow_gen tl) in List.iter (function | TClassDecl cl -> let all_fields = (Option.map_default (fun cf -> [cf]) [] cl.cl_constructor) @ cl.cl_ordered_fields @ cl.cl_ordered_statics in List.iter (fun cf -> cf.cf_type <- run_follow_gen cf.cf_type; cf.cf_expr <- Option.map type_map cf.cf_expr ) all_fields; cl.cl_dynamic <- Option.map run_follow_gen cl.cl_dynamic; cl.cl_array_access <- Option.map run_follow_gen cl.cl_array_access; cl.cl_init <- Option.map type_map cl.cl_init; cl.cl_super <- Option.map super_map cl.cl_super; cl.cl_implements <- List.map super_map cl.cl_implements | _ -> () ) gen.gtypes_list; let closure_t = ClosuresToClass.DoubleAndDynamicClosureImpl.get_ctx gen 6 in (*let closure_t = ClosuresToClass.create gen 10 float_cl (fun l -> l) (fun l -> l) (fun args -> args) (fun args -> []) in ClosuresToClass.configure gen (ClosuresToClass.default_implementation closure_t (fun e _ _ -> e)); StubClosureImpl.configure gen (StubClosureImpl.default_implementation gen float_cl 10 (fun e _ _ -> e));*) let get_vmtype t = match real_type t with | TInst({ cl_path = ["java"],"NativeArray" }, tl) -> t | TInst(c,tl) -> TInst(c,List.map (fun _ -> t_dynamic) tl) | TEnum(e,tl) -> TEnum(e, List.map (fun _ -> t_dynamic) tl) | TType(t,tl) -> TType(t, List.map (fun _ -> t_dynamic) tl) | TAbstract(a,tl) -> TAbstract(a, List.map (fun _ -> t_dynamic) tl) | t -> t in FixOverrides.configure ~get_vmtype gen; Normalize.configure gen ~metas:(Hashtbl.create 0); AbstractImplementationFix.configure gen; IteratorsInterface.configure gen (fun e -> e); ClosuresToClass.configure gen (ClosuresToClass.default_implementation closure_t (get_cl (get_type gen (["haxe";"lang"],"Function")) )); let enum_base = (get_cl (get_type gen (["haxe";"lang"],"Enum")) ) in let param_enum_base = (get_cl (get_type gen (["haxe";"lang"],"ParamEnum")) ) in EnumToClass.configure gen (None) false true enum_base param_enum_base false false; InterfaceVarsDeleteModf.configure gen; let dynamic_object = (get_cl (get_type gen (["haxe";"lang"],"DynamicObject")) ) in let object_iface = get_cl (get_type gen (["haxe";"lang"],"IHxObject")) in (*fixme: THIS IS A HACK. take this off *) let empty_e = match (get_type gen (["haxe";"lang"], "EmptyObject")) with | TEnumDecl e -> e | _ -> assert false in (*OverloadingCtor.set_new_create_empty gen ({eexpr=TEnumField(empty_e, "EMPTY"); etype=TEnum(empty_e,[]); epos=null_pos;});*) let empty_expr = { eexpr = (TTypeExpr (TEnumDecl empty_e)); etype = (TAnon { a_fields = PMap.empty; a_status = ref (EnumStatics empty_e) }); epos = null_pos } in let empty_ef = try PMap.find "EMPTY" empty_e.e_constrs with Not_found -> gen.gcon.error "Required enum field EMPTY was not found" empty_e.e_pos; assert false in OverloadingConstructor.configure ~empty_ctor_type:(TEnum(empty_e, [])) ~empty_ctor_expr:({ eexpr=TField(empty_expr, FEnum(empty_e, empty_ef)); etype=TEnum(empty_e,[]); epos=null_pos; }) ~supports_ctor_inheritance:false gen; let rcf_static_find = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "findHash" Ast.null_pos [] in (*let rcf_static_lookup = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) "lookupHash" Ast.null_pos [] in*) let get_specialized_postfix t = match t with | TAbstract({a_path = [],"Float"}, _) -> "Float" | TInst({cl_path = [],"String"},_) -> "String" | TAnon _ | TDynamic _ -> "Dynamic" | _ -> print_endline (debug_type t); assert false in let rcf_static_insert t = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("insert" ^ get_specialized_postfix t) Ast.null_pos [] in let rcf_static_remove t = mk_static_field_access_infer (get_cl (get_type gen (["haxe";"lang"], "FieldLookup"))) ("remove" ^ get_specialized_postfix t) Ast.null_pos [] in let can_be_float t = like_float (real_type t) in let rcf_on_getset_field main_expr field_expr field may_hash may_set is_unsafe = let is_float = can_be_float (if is_none may_set then main_expr.etype else (get may_set).etype) in let fn_name = if is_some may_set then "setField" else "getField" in let fn_name = if is_float then fn_name ^ "_f" else fn_name in let pos = field_expr.epos in let is_unsafe = { eexpr = TConst(TBool is_unsafe); etype = basic.tbool; epos = pos } in let should_cast = match main_expr.etype with | TAbstract({ a_path = ([], "Float") }, []) -> false | _ -> true in let infer = mk_static_field_access_infer runtime_cl fn_name field_expr.epos [] in let first_args = [ field_expr; { eexpr = TConst(TString field); etype = basic.tstring; epos = pos } ] @ if is_some may_hash then [ { eexpr = TConst(TInt (get may_hash)); etype = basic.tint; epos = pos } ] else [] in let args = first_args @ match is_float, may_set with | true, Some(set) -> [ if should_cast then mk_cast basic.tfloat set else set ] | false, Some(set) -> [ set ] | _ -> [ is_unsafe ] in let call = { main_expr with eexpr = TCall(infer,args) } in let call = if is_float && should_cast then mk_cast main_expr.etype call else call in call in let rcf_on_call_field ecall field_expr field may_hash args = let infer = mk_static_field_access_infer runtime_cl "callField" field_expr.epos [] in let hash_arg = match may_hash with | None -> [] | Some h -> [ { eexpr = TConst(TInt h); etype = basic.tint; epos = field_expr.epos } ] in let arr_call = if args <> [] then { eexpr = TArrayDecl args; etype = basic.tarray t_dynamic; epos = ecall.epos } else null (basic.tarray t_dynamic) ecall.epos in let call_args = [field_expr; { field_expr with eexpr = TConst(TString field); etype = basic.tstring } ] @ hash_arg @ [ arr_call ] in mk_cast ecall.etype { ecall with eexpr = TCall(infer, call_args); etype = t_dynamic } in let rcf_ctx = ReflectionCFs.new_ctx gen closure_t object_iface false rcf_on_getset_field rcf_on_call_field (fun hash hash_array length -> { hash with eexpr = TCall(rcf_static_find, [hash; hash_array; length]); etype=basic.tint }) (fun hash -> hash) (fun hash_array length pos value -> { hash_array with eexpr = TBinop(OpAssign, hash_array, mk (TCall(rcf_static_insert value.etype, [hash_array; length; pos; value])) hash_array.etype hash_array.epos) }) (fun hash_array length pos -> let t = gen.gclasses.nativearray_type hash_array.etype in { hash_array with eexpr = TCall(rcf_static_remove t, [hash_array; length; pos]); etype = gen.gcon.basic.tvoid } ) false in ReflectionCFs.UniversalBaseClass.default_config gen (get_cl (get_type gen (["haxe";"lang"],"HxObject")) ) object_iface dynamic_object; ReflectionCFs.configure_dynamic_field_access rcf_ctx false; (* let closure_func = ReflectionCFs.implement_closure_cl rcf_ctx ( get_cl (get_type gen (["haxe";"lang"],"Closure")) ) in *) let closure_cl = get_cl (get_type gen (["haxe";"lang"],"Closure")) in let closure_func = ReflectionCFs.get_closure_func rcf_ctx closure_cl in ReflectionCFs.implement_varargs_cl rcf_ctx ( get_cl (get_type gen (["haxe";"lang"], "VarArgsBase")) ); let slow_invoke = mk_static_field_access_infer (runtime_cl) "slowCallField" Ast.null_pos [] in ReflectionCFs.configure rcf_ctx ~slow_invoke:(fun ethis efield eargs -> { eexpr = TCall(slow_invoke, [ethis; efield; eargs]); etype = t_dynamic; epos = ethis.epos; } ) object_iface; let objdecl_fn = ReflectionCFs.implement_dynamic_object_ctor rcf_ctx dynamic_object in ObjectDeclMap.configure gen (ObjectDeclMap.traverse gen objdecl_fn); InitFunction.configure gen true true; TArrayTransform.configure gen (TArrayTransform.default_implementation gen ( fun e _ -> match e.eexpr with | TArray ({ eexpr = TLocal { v_extra = Some( _ :: _, _) } }, _) -> (* captured transformation *) false | TArray(e1, e2) -> ( match run_follow gen (follow e1.etype) with | TInst({ cl_path = (["java"], "NativeArray") }, _) -> false | _ -> true ) | _ -> assert false ) "__get" "__set" ); let field_is_dynamic t field = match field_access_esp gen (gen.greal_type t) field with | FClassField (cl,p,_,_,_,t,_) -> let p = change_param_type (TClassDecl cl) p in is_dynamic (apply_params cl.cl_params p t) | FEnumField _ -> false | _ -> true in let is_type_param e = match follow e with | TInst( { cl_kind = KTypeParameter _ },[]) -> true | _ -> false in let is_dynamic_expr e = is_dynamic e.etype || match e.eexpr with | TField(tf, f) -> field_is_dynamic tf.etype f | _ -> false in let may_nullable t = match gen.gfollow#run_f t with | TType({ t_path = ([], "Null") }, [t]) -> (match follow t with | TInst({ cl_path = ([], "String") }, []) | TAbstract ({ a_path = ([], "Float") },[]) | TInst({ cl_path = (["haxe"], "Int32")}, [] ) | TInst({ cl_path = (["haxe"], "Int64")}, [] ) | TAbstract ({ a_path = ([], "Int") },[]) | TAbstract ({ a_path = ([], "Bool") },[]) -> Some t | t when is_java_basic_type t -> Some t | _ -> None ) | _ -> None in let is_double t = like_float t && not (like_int t) in let is_int t = like_int t in DynamicOperators.configure gen (DynamicOperators.abstract_implementation gen (fun e -> match e.eexpr with | TBinop (Ast.OpEq, e1, e2) -> is_dynamic e1.etype || is_dynamic e2.etype || is_type_param e1.etype || is_type_param e2.etype | TBinop (Ast.OpAdd, e1, e2) | TBinop (Ast.OpNotEq, e1, e2) -> is_dynamic e1.etype || is_dynamic e2.etype || is_type_param e1.etype || is_type_param e2.etype | TBinop (Ast.OpLt, e1, e2) | TBinop (Ast.OpLte, e1, e2) | TBinop (Ast.OpGte, e1, e2) | TBinop (Ast.OpGt, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2 || is_string e1.etype || is_string e2.etype | TBinop (_, e1, e2) -> is_dynamic e.etype || is_dynamic_expr e1 || is_dynamic_expr e2 | TUnop (_, _, e1) -> is_dynamic_expr e1 | _ -> false) (fun e1 e2 -> let is_null e = match e.eexpr with | TConst(TNull) | TLocal({ v_name = "__undefined__" }) -> true | _ -> false in match e1.eexpr, e2.eexpr with | TConst c1, TConst c2 when is_null e1 || is_null e2 -> { e1 with eexpr = TConst(TBool (c1 = c2)); etype = basic.tbool } | _ when is_null e1 || is_null e2 && not (is_java_basic_type e1.etype || is_java_basic_type e2.etype) -> { e1 with eexpr = TBinop(Ast.OpEq, e1, e2); etype = basic.tbool } | _ -> let is_ref = match follow e1.etype, follow e2.etype with | TDynamic _, _ | _, TDynamic _ | TAbstract ({ a_path = ([], "Float") },[]) , _ | TInst( { cl_path = (["haxe"], "Int32") }, [] ), _ | TInst( { cl_path = (["haxe"], "Int64") }, [] ), _ | TAbstract ({ a_path = ([], "Int") },[]) , _ | TAbstract ({ a_path = ([], "Bool") },[]) , _ | _, TAbstract ({ a_path = ([], "Float") },[]) | _, TAbstract ({ a_path = ([], "Int") },[]) | _, TInst( { cl_path = (["haxe"], "Int32") }, [] ) | _, TInst( { cl_path = (["haxe"], "Int64") }, [] ) | _, TAbstract ({ a_path = ([], "Bool") },[]) | TInst( { cl_kind = KTypeParameter _ }, [] ), _ | _, TInst( { cl_kind = KTypeParameter _ }, [] ) -> false | _, _ -> true in let static = mk_static_field_access_infer (runtime_cl) (if is_ref then "refEq" else "eq") e1.epos [] in { eexpr = TCall(static, [e1; e2]); etype = gen.gcon.basic.tbool; epos=e1.epos } ) (fun e e1 e2 -> match may_nullable e1.etype, may_nullable e2.etype with | Some t1, Some t2 -> let t1, t2 = if is_string t1 || is_string t2 then basic.tstring, basic.tstring else if is_double t1 || is_double t2 then basic.tfloat, basic.tfloat else if is_int t1 || is_int t2 then basic.tint, basic.tint else t1, t2 in { eexpr = TBinop(Ast.OpAdd, mk_cast t1 e1, mk_cast t2 e2); etype = e.etype; epos = e1.epos } | _ -> let static = mk_static_field_access_infer (runtime_cl) "plus" e1.epos [] in mk_cast e.etype { eexpr = TCall(static, [e1; e2]); etype = t_dynamic; epos=e1.epos }) (fun e1 e2 -> if is_string e1.etype then begin { e1 with eexpr = TCall(mk_field_access gen e1 "compareTo" e1.epos, [ e2 ]); etype = gen.gcon.basic.tint } end else begin let static = mk_static_field_access_infer (runtime_cl) "compare" e1.epos [] in { eexpr = TCall(static, [e1; e2]); etype = gen.gcon.basic.tint; epos=e1.epos } end)); FilterClosures.configure gen (FilterClosures.traverse gen (fun e1 s -> true) closure_func); let base_exception = get_cl (get_type gen (["java"; "lang"], "Throwable")) in let base_exception_t = TInst(base_exception, []) in let hx_exception = get_cl (get_type gen (["haxe";"lang"], "HaxeException")) in let hx_exception_t = TInst(hx_exception, []) in let rec is_exception t = match follow t with | TInst(cl,_) -> if cl == base_exception then true else (match cl.cl_super with | None -> false | Some (cl,arg) -> is_exception (TInst(cl,arg))) | _ -> false in TryCatchWrapper.configure gen ( TryCatchWrapper.traverse gen (fun t -> not (is_exception (real_type t))) (fun throwexpr expr -> let wrap_static = mk_static_field_access (hx_exception) "wrap" (TFun([("obj",false,t_dynamic)], hx_exception_t)) expr.epos in { throwexpr with eexpr = TThrow { expr with eexpr = TCall(wrap_static, [expr]); etype = hx_exception_t }; etype = gen.gcon.basic.tvoid } ) (fun v_to_unwrap pos -> let local = mk_cast hx_exception_t { eexpr = TLocal(v_to_unwrap); etype = v_to_unwrap.v_type; epos = pos } in mk_field_access gen local "obj" pos ) (fun rethrow -> let wrap_static = mk_static_field_access (hx_exception) "wrap" (TFun([("obj",false,t_dynamic)], hx_exception_t)) rethrow.epos in { rethrow with eexpr = TThrow { rethrow with eexpr = TCall(wrap_static, [rethrow]); etype = hx_exception_t }; } ) (base_exception_t) (hx_exception_t) (fun v e -> let exc_cl = get_cl (get_type gen (["haxe";"lang"],"Exceptions")) in let exc_field = mk_static_field_access_infer exc_cl "setException" e.epos [] in let esetstack = { eexpr = TCall(exc_field,[mk_local v e.epos]); etype = gen.gcon.basic.tvoid; epos = e.epos } in Type.concat esetstack e; ) ); let get_typeof e = { e with eexpr = TCall( { eexpr = TLocal( alloc_var "__typeof__" t_dynamic ); etype = t_dynamic; epos = e.epos }, [e] ) } in ClassInstance.configure gen (ClassInstance.traverse gen (fun e mt -> get_typeof e)); (*let v = alloc_var "$type_param" t_dynamic in*) TypeParams.configure gen (fun ecall efield params elist -> { ecall with eexpr = TCall(efield, elist) } ); CastDetect.configure gen (CastDetect.default_implementation gen ~native_string_cast:false (Some (TEnum(empty_e, []))) false); (*FollowAll.configure gen;*) SwitchToIf.configure gen (SwitchToIf.traverse gen (fun e -> match e.eexpr with | TSwitch(cond, cases, def) -> (match gen.gfollow#run_f cond.etype with | TInst( { cl_path = (["haxe"], "Int32") }, [] ) | TAbstract ({ a_path = ([], "Int") },[]) | TInst({ cl_path = ([], "String") },[]) -> (List.exists (fun (c,_) -> List.exists (fun expr -> match expr.eexpr with | TConst _ -> false | _ -> true ) c ) cases) | _ -> true ) | _ -> assert false ) true ); ExpressionUnwrap.configure gen (ExpressionUnwrap.traverse gen (fun e -> Some { eexpr = TVar(mk_temp gen "expr" e.etype, Some e); etype = gen.gcon.basic.tvoid; epos = e.epos })); UnnecessaryCastsRemoval.configure gen; IntDivisionSynf.configure gen (IntDivisionSynf.default_implementation gen true); UnreachableCodeEliminationSynf.configure gen (UnreachableCodeEliminationSynf.traverse gen false true true true); ArrayDeclSynf.configure gen (ArrayDeclSynf.default_implementation gen native_arr_cl); let goto_special = alloc_var "__goto__" t_dynamic in let label_special = alloc_var "__label__" t_dynamic in SwitchBreakSynf.configure gen (SwitchBreakSynf.traverse gen (fun e_loop n api -> { e_loop with eexpr = TBlock( { eexpr = TCall( mk_local label_special e_loop.epos, [ mk_int gen n e_loop.epos ] ); etype = t_dynamic; epos = e_loop.epos } :: [e_loop] ) }; ) (fun e_break n api -> { eexpr = TCall( mk_local goto_special e_break.epos, [ mk_int gen n e_break.epos ] ); etype = t_dynamic; epos = e_break.epos } ) ); DefaultArguments.configure gen (DefaultArguments.traverse gen); InterfaceMetas.configure gen; JavaSpecificSynf.configure gen (JavaSpecificSynf.traverse gen runtime_cl); JavaSpecificESynf.configure gen (JavaSpecificESynf.traverse gen runtime_cl); (* add native String as a String superclass *) let str_cl = match gen.gcon.basic.tstring with | TInst(cl,_) -> cl | _ -> assert false in str_cl.cl_super <- Some (get_cl (get_type gen (["haxe";"lang"], "NativeString")), []); let mkdir dir = if not (Sys.file_exists dir) then Unix.mkdir dir 0o755 in mkdir gen.gcon.file; mkdir (gen.gcon.file ^ "/src"); let out_files = ref [] in (* add resources array *) let res = ref [] in Hashtbl.iter (fun name v -> res := { eexpr = TConst(TString name); etype = gen.gcon.basic.tstring; epos = Ast.null_pos } :: !res; let name = Codegen.escape_res_name name true in let full_path = gen.gcon.file ^ "/src/" ^ name in mkdir_from_path full_path; let f = open_out_bin full_path in output_string f v; close_out f; out_files := (unique_full_path full_path) :: !out_files ) gen.gcon.resources; (try let c = get_cl (Hashtbl.find gen.gtypes (["haxe"], "Resource")) in let cf = PMap.find "content" c.cl_statics in cf.cf_expr <- Some ({ eexpr = TArrayDecl(!res); etype = gen.gcon.basic.tarray gen.gcon.basic.tstring; epos = Ast.null_pos }) with | Not_found -> ()); run_filters gen; TypeParams.RenameTypeParameters.run gen; let t = Common.timer "code generation" in let parts = Str.split_delim (Str.regexp "[\\/]+") gen.gcon.file in mkdir_recursive "" parts; generate_modules_t gen "java" "src" change_path module_gen out_files; if not (Common.defined gen.gcon Define.KeepOldOutput) then clean_files (gen.gcon.file ^ "/src") !out_files gen.gcon.verbose; let path_s_desc path = path_s path [] in dump_descriptor gen ("hxjava_build.txt") path_s_desc (fun md -> path_s_desc (t_infos md).mt_path); if ( not (Common.defined gen.gcon Define.NoCompilation) ) then begin let old_dir = Sys.getcwd() in Sys.chdir gen.gcon.file; let cmd = "haxelib run hxjava hxjava_build.txt --haxe-version " ^ (string_of_int gen.gcon.version) ^ " --feature-level 1" in print_endline cmd; if gen.gcon.run_command cmd <> 0 then failwith "Build failed"; Sys.chdir old_dir; end; t() (* end of configure function *) let before_generate con = let java_ver = try int_of_string (PMap.find "java_ver" con.defines) with | Not_found -> Common.define_value con Define.JavaVer "7"; 7 in if java_ver < 5 then failwith ("Java version is defined to target Java " ^ string_of_int java_ver ^ ", but the compiler can only output code to versions equal or superior to Java 5"); let rec loop i = Common.raw_define con ("java" ^ (string_of_int i)); if i > 0 then loop (i - 1) in loop java_ver; () let generate con = let exists = ref false in con.java_libs <- List.map (fun (file,std,close,la,gr) -> if String.ends_with file "hxjava-std.jar" then begin exists := true; (file,true,close,la,gr) end else (file,std,close,la,gr)) con.java_libs; if not !exists then failwith "Your version of hxjava is outdated. Please update it by running: `haxelib update hxjava`"; let gen = new_ctx con in gen.gallow_tp_dynamic_conversion <- true; let basic = con.basic in (* make the basic functions in java *) let cl_cl = get_cl (get_type gen (["java";"lang"],"Class")) in let basic_fns = [ mk_class_field "equals" (TFun(["obj",false,t_dynamic], basic.tbool)) true Ast.null_pos (Method MethNormal) []; mk_class_field "toString" (TFun([], basic.tstring)) true Ast.null_pos (Method MethNormal) []; mk_class_field "hashCode" (TFun([], basic.tint)) true Ast.null_pos (Method MethNormal) []; mk_class_field "getClass" (TFun([], (TInst(cl_cl,[t_dynamic])))) true Ast.null_pos (Method MethNormal) []; mk_class_field "wait" (TFun([], basic.tvoid)) true Ast.null_pos (Method MethNormal) []; mk_class_field "notify" (TFun([], basic.tvoid)) true Ast.null_pos (Method MethNormal) []; mk_class_field "notifyAll" (TFun([], basic.tvoid)) true Ast.null_pos (Method MethNormal) []; ] in List.iter (fun cf -> gen.gbase_class_fields <- PMap.add cf.cf_name cf gen.gbase_class_fields) basic_fns; (try configure gen with | TypeNotFound path -> con.error ("Error. Module '" ^ (path_s path) ^ "' is required and was not included in build.") Ast.null_pos); debug_mode := false (** Java lib *) open JData type java_lib_ctx = { jcom : Common.context; (* current tparams context *) mutable jtparams : jtypes list; } exception ConversionError of string * pos let error s p = raise (ConversionError (s, p)) let is_haxe_keyword = function | "callback" | "cast" | "extern" | "function" | "in" | "typedef" | "using" | "var" | "untyped" | "inline" -> true | _ -> false let jname_to_hx name = let name = if name <> "" && (String.get name 0 < 'A' || String.get name 0 > 'Z') then Char.escaped (Char.uppercase (String.get name 0)) ^ String.sub name 1 (String.length name - 1) else name in let name = String.concat "__" (String.nsplit name "_") in String.map (function | '$' -> '_' | c -> c) name let normalize_pack pack = List.map (function | "" -> "" | str when String.get str 0 >= 'A' && String.get str 0 <= 'Z' -> String.lowercase str | str -> str ) pack let jpath_to_hx (pack,name) = match pack, name with | ["haxe";"root"], name -> [], name | "com" :: ("oracle" | "sun") :: _, _ | "javax" :: _, _ | "org" :: ("ietf" | "jcp" | "omg" | "w3c" | "xml") :: _, _ | "sun" :: _, _ | "sunw" :: _, _ -> "java" :: normalize_pack pack, jname_to_hx name | pack, name -> normalize_pack pack, jname_to_hx name let real_java_path ctx (pack,name) = path_s (pack, name) let lookup_jclass com path = let path = jpath_to_hx path in List.fold_right (fun (_,_,_,_,get_raw_class) acc -> match acc with | None -> get_raw_class path | Some p -> Some p ) com.java_libs None let mk_type_path ctx path params = let name, sub = try let p, _ = String.split (snd path) "$" in jname_to_hx p, Some (jname_to_hx (snd path)) with | Invalid_string -> jname_to_hx (snd path), None in let pack = fst (jpath_to_hx path) in let pack, sub, name = match path with | [], ("Float" as c) | [], ("Int" as c) | [], ("Single" as c) | [], ("Bool" as c) | [], ("Dynamic" as c) | [], ("Iterator" as c) | [], ("ArrayAccess" as c) | [], ("Iterable" as c) -> [], Some c, "StdTypes" | [], ("String" as c) -> ["std"], None, c | _ -> pack, sub, name in CTPath { tpackage = pack; tname = name; tparams = params; tsub = sub; } let has_tparam name params = List.exists(fun (n,_,_) -> n = name) params let rec convert_arg ctx p arg = match arg with | TAny | TType (WSuper, _) -> TPType (mk_type_path ctx ([], "Dynamic") []) | TType (_, jsig) -> TPType (convert_signature ctx p jsig) and convert_signature ctx p jsig = match jsig with | TByte -> mk_type_path ctx (["java"; "types"], "Int8") [] | TChar -> mk_type_path ctx (["java"; "types"], "Char16") [] | TDouble -> mk_type_path ctx ([], "Float") [] | TFloat -> mk_type_path ctx ([], "Single") [] | TInt -> mk_type_path ctx ([], "Int") [] | TLong -> mk_type_path ctx (["haxe"], "Int64") [] | TShort -> mk_type_path ctx (["java"; "types"], "Int16") [] | TBool -> mk_type_path ctx ([], "Bool") [] | TObject ( (["haxe";"root"], name), args ) -> mk_type_path ctx ([], name) (List.map (convert_arg ctx p) args) (** nullable types *) (* replaced from Null to the actual abstract type to fix #2738 *) (* | TObject ( (["java";"lang"], "Integer"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Int") []) ] *) (* | TObject ( (["java";"lang"], "Double"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Float") []) ] *) (* | TObject ( (["java";"lang"], "Float"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Single") []) ] *) (* | TObject ( (["java";"lang"], "Boolean"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx ([], "Bool") []) ] *) (* | TObject ( (["java";"lang"], "Byte"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Int8") []) ] *) (* | TObject ( (["java";"lang"], "Character"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Char16") []) ] *) (* | TObject ( (["java";"lang"], "Short"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["java";"types"], "Int16") []) ] *) (* | TObject ( (["java";"lang"], "Long"), [] ) -> mk_type_path ctx ([], "Null") [ TPType (mk_type_path ctx (["haxe"], "Int64") []) ] *) (** other std types *) | TObject ( (["java";"lang"], "Object"), [] ) -> mk_type_path ctx ([], "Dynamic") [] | TObject ( (["java";"lang"], "String"), [] ) -> mk_type_path ctx ([], "String") [] | TObject ( (["java";"lang"], "Enum"), [_] ) -> mk_type_path ctx ([], "EnumValue") [] (** other types *) | TObject ( path, [] ) -> (match lookup_jclass ctx.jcom path with | Some (jcl, _, _) -> mk_type_path ctx path (List.map (fun _ -> convert_arg ctx p TAny) jcl.ctypes) | None -> mk_type_path ctx path []) | TObject ( path, args ) -> mk_type_path ctx path (List.map (convert_arg ctx p) args) | TObjectInner (pack, (name, params) :: inners) -> let actual_param = match List.rev inners with | (_, p) :: _ -> p | _ -> assert false in mk_type_path ctx (pack, name ^ "$" ^ String.concat "$" (List.map fst inners)) (List.map (fun param -> convert_arg ctx p param) actual_param) | TObjectInner (pack, inners) -> assert false | TArray (jsig, _) -> mk_type_path ctx (["java"], "NativeArray") [ TPType (convert_signature ctx p jsig) ] | TMethod _ -> JReader.error "TMethod cannot be converted directly into Complex Type" | TTypeParameter s -> (match ctx.jtparams with | cur :: others -> if has_tparam s cur then mk_type_path ctx ([], s) [] else begin if ctx.jcom.verbose && not(List.exists (has_tparam s) others) then print_endline ("Type parameter " ^ s ^ " was not found while building type!"); mk_type_path ctx ([], "Dynamic") [] end | _ -> if ctx.jcom.verbose then print_endline ("Empty type parameter stack!"); mk_type_path ctx ([], "Dynamic") []) let convert_constant ctx p const = Option.map_default (function | ConstString s -> Some (EConst (String s), p) | ConstInt i -> Some (EConst (Int (Printf.sprintf "%ld" i)), p) | ConstFloat f | ConstDouble f -> Some (EConst (Float (Printf.sprintf "%E" f)), p) | _ -> None) None const let rec same_sig parent jsig = match jsig with | TObject (p,targs) -> parent = p || List.exists (function | TType (_,s) -> same_sig parent s | _ -> false) targs | TObjectInner(p, ntargs) -> parent = (p, String.concat "$" (List.map fst ntargs)) || List.exists (fun (_,targs) -> List.exists (function | TType(_,s) -> same_sig parent s | _ -> false) targs) ntargs | TArray(s,_) -> same_sig parent s | _ -> false let convert_param ctx p parent param = let name, constraints = match param with | (name, Some extends_sig, implem_sig) -> name, extends_sig :: implem_sig | (name, None, implemem_sig) -> name, implemem_sig in let constraints = List.map (fun s -> if same_sig parent s then (TObject( (["java";"lang"], "Object"), [])) else s) constraints in { tp_name = name; tp_params = []; tp_constraints = List.map (convert_signature ctx p) constraints; } let get_type_path ctx ct = match ct with | CTPath p -> p | _ -> assert false let is_override field = List.exists (function | AttrVisibleAnnotations [{ ann_type = TObject( (["java";"lang"], "Override"), _ ) }] -> true | _ -> false) field.jf_attributes let mk_override field = { field with jf_attributes = ((AttrVisibleAnnotations [{ ann_type = TObject( (["java";"lang"], "Override"), [] ); ann_elements = [] }]) :: field.jf_attributes) } let del_override field = { field with jf_attributes = List.filter (fun a -> not (is_override_attrib a)) field.jf_attributes } let get_canonical ctx p pack name = (Meta.JavaCanonical, [EConst (String (String.concat "." pack)), p; EConst (String name), p], p) let convert_java_enum ctx p pe = let meta = ref (get_canonical ctx p (fst pe.cpath) (snd pe.cpath) :: [Meta.Native, [EConst (String (real_java_path ctx pe.cpath) ), p], p ]) in let data = ref [] in List.iter (fun f -> (* if List.mem JEnum f.jf_flags then *) match f.jf_vmsignature with | TObject( path, [] ) when path = pe.cpath && List.mem JStatic f.jf_flags && List.mem JFinal f.jf_flags -> data := { ec_name = f.jf_name; ec_doc = None; ec_meta = []; ec_args = []; ec_pos = p; ec_params = []; ec_type = None; } :: !data; | _ -> () ) pe.cfields; EEnum { d_name = jname_to_hx (snd pe.cpath); d_doc = None; d_params = []; (* enums never have type parameters *) d_meta = !meta; d_flags = [EExtern]; d_data = List.rev !data; } let convert_java_field ctx p jc field = let p = { p with pfile = p.pfile ^" (" ^field.jf_name ^")" } in let cff_doc = None in let cff_pos = p in let cff_meta = ref [] in let cff_access = ref [] in let cff_name = match field.jf_name with | "" -> "new" | ""-> raise Exit (* __init__ field *) | name when String.length name > 5 -> (match String.sub name 0 5 with | "__hx_" | "this$" -> raise Exit | _ -> name) | name -> name in let jf_constant = ref field.jf_constant in let readonly = ref false in List.iter (function | JPublic -> cff_access := APublic :: !cff_access | JPrivate -> raise Exit (* private instances aren't useful on externs *) | JProtected -> cff_access := APrivate :: !cff_access | JStatic -> cff_access := AStatic :: !cff_access | JFinal -> cff_meta := (Meta.Final, [], p) :: !cff_meta; (match field.jf_kind, field.jf_vmsignature, field.jf_constant with | JKField, TObject _, _ -> jf_constant := None | JKField, _, Some _ -> readonly := true; jf_constant := None; | _ -> jf_constant := None) (* | JSynchronized -> cff_meta := (Meta.Synchronized, [], p) :: !cff_meta *) | JVolatile -> cff_meta := (Meta.Volatile, [], p) :: !cff_meta | JTransient -> cff_meta := (Meta.Transient, [], p) :: !cff_meta (* | JVarArgs -> cff_meta := (Meta.VarArgs, [], p) :: !cff_meta *) | _ -> () ) field.jf_flags; List.iter (function | AttrDeprecated when jc.cpath <> (["java";"util"],"Date") -> cff_meta := (Meta.Deprecated, [], p) :: !cff_meta (* TODO: pass anotations as @:meta *) | AttrVisibleAnnotations ann -> List.iter (function | { ann_type = TObject( (["java";"lang"], "Override"), [] ) } -> cff_access := AOverride :: !cff_access | _ -> () ) ann | _ -> () ) field.jf_attributes; List.iter (fun jsig -> match convert_signature ctx p jsig with | CTPath path -> cff_meta := (Meta.Throws, [Ast.EConst (Ast.String (path_s (path.tpackage,path.tname))), p],p) :: !cff_meta | _ -> () ) field.jf_throws; let kind = match field.jf_kind with | JKField when !readonly -> FProp ("default", "null", Some (convert_signature ctx p field.jf_signature), None) | JKField -> FVar (Some (convert_signature ctx p field.jf_signature), None) | JKMethod -> match field.jf_signature with | TMethod (args, ret) -> let old_types = ctx.jtparams in (match ctx.jtparams with | c :: others -> ctx.jtparams <- (c @ field.jf_types) :: others | [] -> ctx.jtparams <- field.jf_types :: []); let i = ref 0 in let args = List.map (fun s -> incr i; "param" ^ string_of_int !i, false, Some(convert_signature ctx p s), None ) args in let t = Option.map_default (convert_signature ctx p) (mk_type_path ctx ([], "Void") []) ret in cff_meta := (Meta.Overload, [], p) :: !cff_meta; let types = List.map (function | (name, Some ext, impl) -> { tp_name = name; tp_params = []; tp_constraints = List.map (convert_signature ctx p) (ext :: impl); } | (name, None, impl) -> { tp_name = name; tp_params = []; tp_constraints = List.map (convert_signature ctx p) (impl); } ) field.jf_types in ctx.jtparams <- old_types; FFun ({ f_params = types; f_args = args; f_type = Some t; f_expr = None }) | _ -> error "Method signature was expected" p in let cff_name, cff_meta = match String.get cff_name 0 with | '%' -> let name = (String.sub cff_name 1 (String.length cff_name - 1)) in if not (is_haxe_keyword name) then cff_meta := (Meta.Deprecated, [EConst(String( "This static field `_" ^ name ^ "` is deprecated and will be removed in later versions. Please use `" ^ name ^ "` instead") ),p], p) :: !cff_meta; "_" ^ name, (Meta.Native, [EConst (String (name) ), cff_pos], cff_pos) :: !cff_meta | _ -> match String.nsplit cff_name "$" with | [ no_dollar ] -> cff_name, !cff_meta | parts -> String.concat "_" parts, (Meta.Native, [EConst (String (cff_name) ), cff_pos], cff_pos) :: !cff_meta in if PMap.mem "java_loader_debug" ctx.jcom.defines then Printf.printf "\t%s%sfield %s : %s\n" (if List.mem AStatic !cff_access then "static " else "") (if List.mem AOverride !cff_access then "override " else "") cff_name (s_sig field.jf_signature); { cff_name = cff_name; cff_doc = cff_doc; cff_pos = cff_pos; cff_meta = cff_meta; cff_access = !cff_access; cff_kind = kind } let rec japply_params params jsig = match params with | [] -> jsig | _ -> match jsig with | TTypeParameter s -> (try List.assoc s params with | Not_found -> jsig) | TObject(p,tl) -> TObject(p, args params tl) | TObjectInner(sl, stll) -> TObjectInner(sl, List.map (fun (s,tl) -> (s, args params tl)) stll) | TArray(s,io) -> TArray(japply_params params s, io) | TMethod(sl, sopt) -> TMethod(List.map (japply_params params) sl, Option.map (japply_params params) sopt) | _ -> jsig and args params tl = match params with | [] -> tl | _ -> List.map (function | TAny -> TAny | TType(w,s) -> TType(w,japply_params params s)) tl let mk_params jtypes = List.map (fun (s,_,_) -> (s,TTypeParameter s)) jtypes let convert_java_class ctx p jc = match List.mem JEnum jc.cflags with | true -> (* is enum *) [convert_java_enum ctx p jc] | false -> let flags = ref [HExtern] in if PMap.mem "java_loader_debug" ctx.jcom.defines then begin let sup = jc.csuper :: jc.cinterfaces in print_endline ("converting " ^ (if List.mem JAbstract jc.cflags then "abstract " else "") ^ JData.path_s jc.cpath ^ " : " ^ (String.concat ", " (List.map s_sig sup))); end; (* todo: instead of JavaNative, use more specific definitions *) let meta = ref [Meta.JavaNative, [], p; Meta.Native, [EConst (String (real_java_path ctx jc.cpath) ), p], p; get_canonical ctx p (fst jc.cpath) (snd jc.cpath)] in let force_check = Common.defined ctx.jcom Define.ForceLibCheck in if not force_check then meta := (Meta.LibType,[],p) :: !meta; let is_interface = ref false in List.iter (fun f -> match f with | JFinal -> meta := (Meta.Final, [], p) :: !meta | JInterface -> is_interface := true; flags := HInterface :: !flags | JAbstract -> meta := (Meta.Abstract, [], p) :: !meta | JAnnotation -> meta := (Meta.Annotation, [], p) :: !meta | _ -> () ) jc.cflags; (match jc.csuper with | TObject( (["java";"lang"], "Object"), _ ) -> () | TObject( (["haxe";"lang"], "HxObject"), _ ) -> meta := (Meta.HxGen,[],p) :: !meta | _ -> flags := HExtends (get_type_path ctx (convert_signature ctx p jc.csuper)) :: !flags ); List.iter (fun i -> match i with | TObject ( (["haxe";"lang"], "IHxObject"), _ ) -> meta := (Meta.HxGen,[],p) :: !meta | _ -> flags := if !is_interface then HExtends (get_type_path ctx (convert_signature ctx p i)) :: !flags else HImplements (get_type_path ctx (convert_signature ctx p i)) :: !flags ) jc.cinterfaces; let fields = ref [] in let jfields = ref [] in if jc.cpath <> (["java";"lang"], "CharSequence") then List.iter (fun f -> try if !is_interface && List.mem JStatic f.jf_flags then () else begin fields := convert_java_field ctx p jc f :: !fields; jfields := f :: !jfields end with | Exit -> () ) (jc.cfields @ jc.cmethods); (* make sure the throws types are imported correctly *) let imports = List.concat (List.map (fun f -> List.map (fun jsig -> match convert_signature ctx p jsig with | CTPath path -> let pos = { p with pfile = p.pfile ^ " (" ^ f.jf_name ^" @:throws)" } in EImport( List.map (fun s -> s,pos) (path.tpackage @ [path.tname]), INormal ) | _ -> assert false ) f.jf_throws ) jc.cmethods) in (EClass { d_name = jname_to_hx (snd jc.cpath); d_doc = None; d_params = List.map (convert_param ctx p jc.cpath) jc.ctypes; d_meta = !meta; d_flags = !flags; d_data = !fields; }) :: imports let create_ctx com = { jcom = com; jtparams = []; } let rec has_type_param = function | TTypeParameter _ -> true | TMethod (lst, opt) -> List.exists has_type_param lst || Option.map_default has_type_param false opt | TArray (s,_) -> has_type_param s | TObjectInner (_, stpl) -> List.exists (fun (_,sigs) -> List.exists has_type_param_arg sigs) stpl | TObject(_, pl) -> List.exists has_type_param_arg pl | _ -> false and has_type_param_arg = function | TType(_,s) -> has_type_param s | _ -> false let rec japply_params jparams jsig = match jparams with | [] -> jsig | _ -> match jsig with | TObject(path,p) -> TObject(path, List.map (japply_params_tp jparams ) p) | TObjectInner(sl,stargl) -> TObjectInner(sl,List.map (fun (s,targ) -> (s, List.map (japply_params_tp jparams) targ)) stargl) | TArray(jsig,io) -> TArray(japply_params jparams jsig,io) | TMethod(args,ret) -> TMethod(List.map (japply_params jparams ) args, Option.map (japply_params jparams ) ret) | TTypeParameter s -> (try List.assoc s jparams with | Not_found -> jsig) | _ -> jsig and japply_params_tp jparams jtype_argument = match jtype_argument with | TAny -> TAny | TType(w,jsig) -> TType(w,japply_params jparams jsig) let mk_jparams jtypes params = match jtypes, params with | [], [] -> [] | _, [] -> List.map (fun (s,_,_) -> s, TObject( (["java";"lang"], "Object"), [] ) ) jtypes | _ -> List.map2 (fun (s,_,_) jt -> match jt with | TAny -> s, TObject((["java";"lang"],"Object"),[]) | TType(_,jsig) -> s, jsig) jtypes params let rec compatible_signature_arg ?arg_test f1 f2 = let arg_test = match arg_test with | None -> (fun _ _ -> true) | Some a -> a in if f1 = f2 then true else match f1, f2 with | TObject(p,a), TObject(p2,a2) -> p = p2 && arg_test a a2 | TObjectInner(sl, stal), TObjectInner(sl2, stal2) -> sl = sl2 && List.map fst stal = List.map fst stal2 | TArray(s,_) , TArray(s2,_) -> compatible_signature_arg s s2 | TTypeParameter t1 , TTypeParameter t2 -> t1 = t2 | _ -> false let rec compatible_param p1 p2 = match p1, p2 with | TType (_,s1), TType(_,s2) -> compatible_signature_arg ~arg_test:compatible_tparams s1 s2 | TAny, TType(_, TObject( (["java";"lang"],"Object"), _ )) -> true | TType(_, TObject( (["java";"lang"],"Object"), _ )), TAny -> true | _ -> false and compatible_tparams p1 p2 = try match p1, p2 with | [], [] -> true | _, [] -> let p2 = List.map (fun _ -> TAny) p1 in List.for_all2 compatible_param p1 p2 | [], _ -> let p1 = List.map (fun _ -> TAny) p2 in List.for_all2 compatible_param p1 p2 | _, _ -> List.for_all2 compatible_param p1 p2 with | Invalid_argument("List.for_all2") -> false let get_adapted_sig f f2 = match f.jf_types with | [] -> f.jf_signature | _ -> let jparams = mk_jparams f.jf_types (List.map (fun (s,_,_) -> TType(WNone, TTypeParameter s)) f2.jf_types) in japply_params jparams f.jf_signature let compatible_methods f1 f2 = if List.length f1.jf_types <> List.length f2.jf_types then false else match (get_adapted_sig f1 f2), f2.jf_signature with | TMethod(a1,_), TMethod(a2,_) when List.length a1 = List.length a2 -> List.for_all2 compatible_signature_arg a1 a2 | _ -> false let jcl_from_jsig com jsig = let path, params = match jsig with | TObject(path, params) -> path,params | TObjectInner(sl, stll) -> let last_params = ref [] in let real_path = sl, String.concat "$" (List.map (fun (s,p) -> last_params := p; s) stll) in real_path, !last_params | _ -> raise Not_found in match lookup_jclass com path with | None -> raise Not_found | Some(c,_,_) -> c,params let jclass_with_params com cls params = try match cls.ctypes with | [] -> cls | _ -> let jparams = mk_jparams cls.ctypes params in { cls with cfields = List.map (fun f -> { f with jf_signature = japply_params jparams f.jf_signature }) cls.cfields; cmethods = List.map (fun f -> { f with jf_signature = japply_params jparams f.jf_signature }) cls.cmethods; csuper = japply_params jparams cls.csuper; cinterfaces = List.map (japply_params jparams) cls.cinterfaces; } with Invalid_argument("List.map2") -> if com.verbose then prerr_endline ("Differing parameters for class: " ^ path_s cls.cpath); cls let is_object = function | TObject( (["java";"lang"], "Object"), [] ) -> true | _ -> false let is_tobject = function | TObject _ | TObjectInner _ -> true | _ -> false let simplify_args args = if List.for_all (function | TAny -> true | _ -> false) args then [] else args let compare_type com s1 s2 = if s1 = s2 then 0 else if not (is_tobject s1) then if is_tobject s2 then (* Dynamic *) 1 else if compatible_signature_arg s1 s2 then 0 else raise Exit else if not (is_tobject s2) then -1 else begin let rec loop ?(first_error=true) s1 s2 : bool = if is_object s1 then s1 = s2 else if compatible_signature_arg s1 s2 then begin let p1, p2 = match s1, s2 with | TObject(_, p1), TObject(_,p2) -> p1, p2 | TObjectInner(_, npl1), TObjectInner(_, npl2) -> snd (List.hd (List.rev npl1)), snd (List.hd (List.rev npl2)) | _ -> assert false (* not tobject *) in let p1, p2 = simplify_args p1, simplify_args p2 in let lp1 = List.length p1 in let lp2 = List.length p2 in if lp1 > lp2 then true else if lp2 > lp1 then false else begin (* if compatible tparams, it's fine *) if not (compatible_tparams p1 p2) then raise Exit; (* meaning: found, but incompatible type parameters *) true end end else try let c, p = jcl_from_jsig com s1 in let jparams = mk_jparams c.ctypes p in let super = japply_params jparams c.csuper in let implements = List.map (japply_params jparams) c.cinterfaces in loop ~first_error:first_error super s2 || List.exists (fun super -> loop ~first_error:first_error super s2) implements with | Not_found -> prerr_endline ("-java-lib: The type " ^ (s_sig s1) ^ " is referred but was not found. Compilation may not occur correctly."); prerr_endline "Did you forget to include a needed lib?"; if first_error then not (loop ~first_error:false s2 s1) else false in if loop s1 s2 then if loop s2 s1 then 0 else 1 else if loop s2 s1 then -1 else -2 end (* given a list of same overload functions, choose the best (or none) *) let select_best com flist = let rec loop cur_best = function | [] -> Some cur_best | f :: flist -> match get_adapted_sig f cur_best, cur_best.jf_signature with | TMethod(_,Some r), TMethod(_, Some r2) -> (try match compare_type com r r2 with | 0 -> (* same type - select any of them *) loop cur_best flist | 1 -> loop f flist | -1 -> loop cur_best flist | -2 -> (* error - no type is compatible *) if com.verbose then prerr_endline (f.jf_name ^ ": The types " ^ (s_sig r) ^ " and " ^ (s_sig r2) ^ " are incompatible"); (* bet that the current best has "beaten" other types *) loop cur_best flist | _ -> assert false with | Exit -> (* incompatible type parameters *) (* error mode *) if com.verbose then prerr_endline (f.jf_name ^ ": Incompatible argument return signatures: " ^ (s_sig r) ^ " and " ^ (s_sig r2)); None) | TMethod _, _ -> (* select the method *) loop f flist | _ -> loop cur_best flist in match loop (List.hd flist) (List.tl flist) with | Some f -> Some f | None -> match List.filter (fun f -> not (is_override f)) flist with (* error mode; take off all override methods *) | [] -> None | f :: [] -> Some f | f :: flist -> Some f (* pick one *) (**** begin normalize_jclass helpers ****) let fix_overrides_jclass com cls = let force_check = Common.defined com Define.ForceLibCheck in let methods = if force_check then List.map (fun f -> del_override f) cls.cmethods else cls.cmethods in let cmethods = methods in let super_fields = [] in let super_methods = [] in let nonstatics = List.filter (fun f -> not (List.mem JStatic f.jf_flags)) (cls.cfields @ cls.cmethods) in let is_pub = fun f -> List.exists (function | JPublic | JProtected -> true | _ -> false) f.jf_flags in let cmethods, super_fields = if not (List.mem JInterface cls.cflags) then List.filter is_pub cmethods, List.filter is_pub super_fields else cmethods,super_fields in let rec loop cls super_methods super_fields cmethods nonstatics = try match cls.csuper with | TObject((["java";"lang"],"Object"),_) -> super_methods,super_fields,cmethods,nonstatics | _ -> let cls, params = jcl_from_jsig com cls.csuper in let cls = jclass_with_params com cls params in let nonstatics = (List.filter (fun f -> (List.mem JStatic f.jf_flags)) (cls.cfields @ cls.cmethods)) @ nonstatics in let super_methods = cls.cmethods @ super_methods in let super_fields = cls.cfields @ super_fields in let cmethods = if force_check then begin let overriden = ref [] in let cmethods = List.map (fun jm -> (* TODO rewrite/standardize empty spaces *) if not (is_override jm) && not (List.mem JStatic jm.jf_flags) && List.exists (fun msup -> let ret = msup.jf_name = jm.jf_name && not(List.mem JStatic msup.jf_flags) && compatible_methods msup jm in if ret then begin let f = mk_override msup in overriden := { f with jf_flags = jm.jf_flags } :: !overriden end; ret ) cls.cmethods then mk_override jm else jm ) cmethods in !overriden @ cmethods end else cmethods in loop cls super_methods super_fields cmethods nonstatics with | Not_found -> super_methods,super_fields,cmethods,nonstatics in loop cls super_methods super_fields cmethods nonstatics let normalize_jclass com cls = (* after adding the noCheck metadata, this option will annotate what changes were needed *) (* and that are now deprecated *) let force_check = Common.defined com Define.ForceLibCheck in (* fix overrides *) let super_methods, super_fields, cmethods, nonstatics = fix_overrides_jclass com cls in let all_methods = cmethods @ super_methods in (* look for interfaces and add missing implementations (may happen on abstracts or by vmsig differences *) (* (libType): even with libType enabled, we need to add these missing fields - otherwise we won't be able to use them from Haxe *) let added_interface_fields = ref [] in let rec loop_interface abstract cls iface = try match iface with | TObject ((["java";"lang"],"Object"), _) -> () | TObject (path,_) when path = cls.cpath -> () | _ -> let cif, params = jcl_from_jsig com iface in let cif = jclass_with_params com cif params in List.iter (fun jf -> if not(List.mem JStatic jf.jf_flags) && not (List.exists (fun jf2 -> jf.jf_name = jf2.jf_name && not (List.mem JStatic jf2.jf_flags) && jf.jf_signature = jf2.jf_signature) all_methods) then begin let jf = if abstract && force_check then del_override jf else jf in let jf = { jf with jf_flags = JPublic :: jf.jf_flags } in (* interfaces implementations are always public *) added_interface_fields := jf :: !added_interface_fields; end ) cif.cmethods; (* we don't need to loop again in the interface unless we are in an abstract class, since these interfaces are already normalized *) if abstract then List.iter (loop_interface abstract cif) cif.cinterfaces; with Not_found -> () in List.iter (loop_interface (List.mem JAbstract cls.cflags) cls) cls.cinterfaces; let nonstatics = !added_interface_fields @ nonstatics in let cmethods = !added_interface_fields @ cmethods in (* for each added field in the interface, lookup in super_methods possible methods to include *) (* so we can choose the better method still *) let cmethods = if not force_check then cmethods else List.fold_left (fun cmethods im -> (* see if any of the added_interface_fields need to be declared as override *) let f = List.find_all (fun jf -> jf.jf_name = im.jf_name && compatible_methods jf im) super_methods in let f = List.map mk_override f in f @ cmethods ) cmethods !added_interface_fields; in (* take off equals, hashCode and toString from interface *) let cmethods = if List.mem JInterface cls.cflags then List.filter (fun jf -> match jf.jf_name, jf.jf_vmsignature with | "equals", TMethod([TObject( (["java";"lang"],"Object"), _)],_) | "hashCode", TMethod([], _) | "toString", TMethod([], _) -> false | _ -> true ) cmethods else cmethods in (* change field name to not collide with haxe keywords and with static/non-static members *) let fold_field acc f = let change, both = match f.jf_name with | _ when List.mem JStatic f.jf_flags && List.exists (fun f2 -> f.jf_name = f2.jf_name) nonstatics -> true, true | _ -> is_haxe_keyword f.jf_name, false in let f2 = if change then { f with jf_name = "%" ^ f.jf_name } else f in if both then f :: f2 :: acc else f2 :: acc in (* change static fields that have the same name as methods *) let cfields = List.fold_left fold_field [] cls.cfields in let cmethods = List.fold_left fold_field [] cmethods in (* take off variable fields that have the same name as methods *) (* and take off variables that already have been declared *) let filter_field f f2 = f != f2 && (List.mem JStatic f.jf_flags = List.mem JStatic f2.jf_flags) && f.jf_name = f2.jf_name && f2.jf_kind <> f.jf_kind in let cfields = List.filter (fun f -> if List.mem JStatic f.jf_flags then not (List.exists (filter_field f) cmethods) else not (List.exists (filter_field f) nonstatics) && not (List.exists (fun f2 -> f != f2 && f.jf_name = f2.jf_name && not (List.mem JStatic f2.jf_flags)) super_fields) ) cfields in (* now filter any method that clashes with a field - on a superclass *) let cmethods = if force_check then List.filter (fun f -> if List.mem JStatic f.jf_flags then true else not (List.exists (filter_field f) super_fields) ) cmethods else cmethods in (* removing duplicate fields. They are there because of return type covariance in Java *) (* Also, if a method overrides a previous definition, and changes a type parameters' variance, *) (* we will take it off *) (* this means that some rare codes will never compile on Haxe, but unless Haxe adds variance support *) (* I can't see how this can be any different *) let rec loop acc = function | [] -> acc | f :: cmeths -> match List.partition (fun f2 -> f.jf_name = f2.jf_name && compatible_methods f f2) cmeths with | [], cmeths -> loop (f :: acc) cmeths | flist, cmeths -> match select_best com (f :: flist) with | None -> loop acc cmeths | Some f -> loop (f :: acc) cmeths in (* last pass: take off all cfields that are internal / private (they won't be accessible anyway) *) let cfields = List.filter(fun f -> List.exists (fun f -> f = JPublic || f = JProtected) f.jf_flags) cfields in let cmethods = loop [] cmethods in { cls with cfields = cfields; cmethods = cmethods } (**** end normalize_jclass helpers ****) let get_classes_zip zip = let ret = ref [] in List.iter (function | { Zip.is_directory = false; Zip.filename = f } when (String.sub (String.uncapitalize f) (String.length f - 6) 6) = ".class" && not (String.exists f "$") -> (match List.rev (String.nsplit f "/") with | clsname :: pack -> if not (String.contains clsname '$') then begin let path = jpath_to_hx (List.rev pack, String.sub clsname 0 (String.length clsname - 6)) in ret := path :: !ret end | _ -> ret := ([], jname_to_hx f) :: !ret) | _ -> () ) (Zip.entries zip); !ret let add_java_lib com file std = let file = if Sys.file_exists file then file else try Common.find_file com file with | Not_found -> try Common.find_file com (file ^ ".jar") with | Not_found -> failwith ("Java lib " ^ file ^ " not found") in let hxpack_to_jpack = Hashtbl.create 16 in let get_raw_class, close, list_all_files = (* check if it is a directory or jar file *) match (Unix.stat file).st_kind with | S_DIR -> (* open classes directly from directory *) let all = ref [] in let rec iter_files pack dir path = try let file = Unix.readdir dir in let filepath = path ^ "/" ^ file in (if String.ends_with file ".class" && not (String.exists file "$") then let file = String.sub file 0 (String.length file - 6) in let path = jpath_to_hx (pack,file) in all := path :: !all; Hashtbl.add hxpack_to_jpack path (pack,file) else if (Unix.stat filepath).st_kind = S_DIR && file <> "." && file <> ".." then let pack = pack @ [file] in iter_files (pack) (Unix.opendir filepath) filepath); iter_files pack dir path with | End_of_file | Unix.Unix_error _ -> Unix.closedir dir in iter_files [] (Unix.opendir file) file; let all = !all in (fun (pack, name) -> let real_path = file ^ "/" ^ (String.concat "/" pack) ^ "/" ^ (name ^ ".class") in try let data = Std.input_file ~bin:true real_path in Some(JReader.parse_class (IO.input_string data), real_path, real_path) with | _ -> None), (fun () -> ()), (fun () -> all) | _ -> (* open zip file *) let closed = ref false in let zip = ref (Zip.open_in file) in let check_open () = if !closed then begin prerr_endline ("JAR file " ^ file ^ " already closed"); (* if this happens, find when *) zip := Zip.open_in file; closed := false end in List.iter (function | { Zip.is_directory = false; Zip.filename = filename } when String.ends_with filename ".class" -> let pack = String.nsplit filename "/" in (match List.rev pack with | [] -> () | name :: pack -> let name = String.sub name 0 (String.length name - 6) in let pack = List.rev pack in Hashtbl.add hxpack_to_jpack (jpath_to_hx (pack,name)) (pack,name)) | _ -> () ) (Zip.entries !zip); (fun (pack, name) -> check_open(); try let location = (String.concat "/" (pack @ [name]) ^ ".class") in let entry = Zip.find_entry !zip location in let data = Zip.read_entry !zip entry in Some(JReader.parse_class (IO.input_string data), file, file ^ "@" ^ location) with | Not_found -> None), (fun () -> if not !closed then begin closed := true; Zip.close_in !zip end), (fun () -> check_open(); get_classes_zip !zip) in let cached_types = Hashtbl.create 12 in let get_raw_class path = try Hashtbl.find cached_types path with | Not_found -> try let pack, name = Hashtbl.find hxpack_to_jpack path in let try_file (pack,name) = match get_raw_class (pack,name) with | None -> Hashtbl.add cached_types path None; None | Some (i, p1, p2) -> Hashtbl.add cached_types path (Some(i,p1,p2)); (* type loop normalization *) let ret = Some (normalize_jclass com i, p1, p2) in Hashtbl.replace cached_types path ret; ret in try_file (pack,name) with Not_found -> None in let replace_canonical_name p pack name_original name_replace decl = let mk_meta name = (Meta.JavaCanonical, [EConst (String (String.concat "." pack)), p; EConst(String name), p], p) in let add_meta name metas = if Meta.has Meta.JavaCanonical metas then List.map (function | (Meta.JavaCanonical,[EConst (String cpack), _; EConst(String cname), _],_) -> let did_replace,name = String.replace cname name_original name_replace in if not did_replace then print_endline (cname ^ " -> " ^ name_original ^ " -> " ^ name_replace); mk_meta name | m -> m ) metas else mk_meta name :: metas in match decl with | EClass c -> EClass { c with d_meta = add_meta c.d_name c.d_meta } | EEnum e -> EEnum { e with d_meta = add_meta e.d_name e.d_meta } | EAbstract a -> EAbstract { a with d_meta = add_meta a.d_name a.d_meta } | d -> d in let rec build ctx path p types = try if List.mem path !types then None else begin let first = match !types with | [ ["java";"lang"], "String" ] | [] -> true | p :: _ -> false in types := path :: !types; match get_raw_class path, path with | None, ([], c) -> build ctx (["haxe";"root"], c) p types | None, _ -> None | Some (cls, real_path, pos_path), _ -> let is_disallowed_inner = first && String.exists (snd cls.cpath) "$" in let is_disallowed_inner = if is_disallowed_inner then begin let outer, inner = String.split (snd cls.cpath) "$" in match get_raw_class (fst path, outer) with | None -> false | _ -> true end else false in if is_disallowed_inner then None else begin if com.verbose then print_endline ("Parsed Java class " ^ (path_s cls.cpath)); let old_types = ctx.jtparams in ctx.jtparams <- cls.ctypes :: ctx.jtparams; let pos = { pfile = pos_path; pmin = 0; pmax = 0; } in let pack = match fst path with | ["haxe";"root"] -> [] | p -> p in let ppath = Hashtbl.find hxpack_to_jpack path in let inner = List.fold_left (fun acc (path,out,_,_) -> let path = jpath_to_hx path in (if out <> Some ppath then acc else match build ctx path p types with | Some(_,(_, classes)) -> let base = snd ppath ^ "$" in (List.map (fun (def,p) -> replace_canonical_name p (fst ppath) base (snd ppath ^ ".") def, p) classes) @ acc | _ -> acc); ) [] cls.cinner_types in (* add _Statics class *) let inner = try if not (List.mem JInterface cls.cflags) then raise Not_found; let smethods = List.filter (fun f -> List.mem JStatic f.jf_flags) cls.cmethods in let sfields = List.filter (fun f -> List.mem JStatic f.jf_flags) cls.cfields in if not (smethods <> [] || sfields <> []) then raise Not_found; let obj = TObject( (["java";"lang"],"Object"), []) in let ncls = convert_java_class ctx pos { cls with cmethods = smethods; cfields = sfields; cflags = []; csuper = obj; cinterfaces = []; cinner_types = []; ctypes = [] } in match ncls with | EClass c :: imports -> (EClass { c with d_name = c.d_name ^ "_Statics" }, pos) :: inner @ List.map (fun i -> i,pos) imports | _ -> assert false with | Not_found -> inner in let inner_alias = ref SS.empty in List.iter (fun x -> match fst x with | EClass c -> inner_alias := SS.add c.d_name !inner_alias; | _ -> () ) inner; let alias_list = ref [] in List.iter (fun x -> match x with | (EClass c, pos) -> begin let parts = String.nsplit c.d_name "_24" in match parts with | _ :: _ -> let alias_name = String.concat "_" parts in if (not (SS.mem alias_name !inner_alias)) && (not (String.exists (snd path) "_24")) then begin let alias_def = ETypedef { d_name = alias_name; d_doc = None; d_params = c.d_params; d_meta = []; d_flags = []; d_data = CTPath { tpackage = pack; tname = snd path; tparams = List.map (fun tp -> TPType (CTPath { tpackage = []; tname = tp.tp_name; tparams = []; tsub = None; }) ) c.d_params; tsub = Some(c.d_name); }; } in inner_alias := SS.add alias_name !inner_alias; alias_list := (alias_def, pos) :: !alias_list; end | _ -> () end | _ -> () ) inner; let inner = List.concat [!alias_list ; inner] in let classes = List.map (fun t -> t,pos) (convert_java_class ctx pos cls) in let imports, defs = List.partition (function | (EImport(_),_) -> true | _ -> false) (classes @ inner) in let ret = Some ( real_path, (pack, imports @ defs) ) in ctx.jtparams <- old_types; ret end end with | JReader.Error_message msg -> prerr_endline ("Class reader failed: " ^ msg); None | e -> if com.verbose then begin (* prerr_endline (Printexc.get_backtrace ()); requires ocaml 3.11 *) prerr_endline (Printexc.to_string e) end; None in let build path p = build (create_ctx com) path p (ref [["java";"lang"], "String"]) in let cached_files = ref None in let list_all_files () = match !cached_files with | None -> let ret = list_all_files () in cached_files := Some ret; ret | Some r -> r in (* TODO: add_dependency m mdep *) com.load_extern_type <- com.load_extern_type @ [build]; com.java_libs <- (file, std, close, list_all_files, get_raw_class) :: com.java_libs haxe_3.2.1+dfsg.orig/genjs.ml0000664000175000017500000012552012607337712015771 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open Common type pos = Ast.pos type sourcemap = { sources : (string) DynArray.t; sources_hash : (string, int) Hashtbl.t; mappings : Rbuffer.t; mutable source_last_line : int; mutable source_last_col : int; mutable source_last_file : int; mutable print_comma : bool; mutable output_last_col : int; mutable output_current_col : int; } type ctx = { com : Common.context; buf : Rbuffer.t; packages : (string list,unit) Hashtbl.t; smap : sourcemap; js_modern : bool; js_flatten : bool; mutable current : tclass; mutable statics : (tclass * string * texpr) list; mutable inits : texpr list; mutable tabs : string; mutable in_value : tvar option; mutable in_loop : bool; mutable handle_break : bool; mutable id_counter : int; mutable type_accessor : module_type -> string; mutable separator : bool; mutable found_expose : bool; } type object_store = { os_name : string; mutable os_fields : object_store list; } let get_exposed ctx path meta = if not ctx.js_modern then [] else try let (_, args, pos) = Meta.get Meta.Expose meta in (match args with | [ EConst (String s), _ ] -> [s] | [] -> [path] | _ -> error "Invalid @:expose parameters" pos) with Not_found -> [] let dot_path = Ast.s_type_path let flat_path (p,s) = (* Replace _ with _$ in paths to prevent name collisions. *) let escape str = String.concat "_$" (ExtString.String.nsplit str "_") in match p with | [] -> escape s | _ -> String.concat "_" (List.map escape p) ^ "_" ^ (escape s) let s_path ctx = if ctx.js_flatten then flat_path else dot_path let kwds = let h = Hashtbl.create 0 in List.iter (fun s -> Hashtbl.add h s ()) [ "abstract"; "as"; "boolean"; "break"; "byte"; "case"; "catch"; "char"; "class"; "continue"; "const"; "debugger"; "default"; "delete"; "do"; "double"; "else"; "enum"; "export"; "extends"; "false"; "final"; "finally"; "float"; "for"; "function"; "goto"; "if"; "implements"; "import"; "in"; "instanceof"; "int"; "interface"; "is"; "let"; "long"; "namespace"; "native"; "new"; "null"; "package"; "private"; "protected"; "public"; "return"; "short"; "static"; "super"; "switch"; "synchronized"; "this"; "throw"; "throws"; "transient"; "true"; "try"; "typeof"; "use"; "var"; "void"; "volatile"; "while"; "with"; "yield" ]; h (* Identifiers Haxe reserves to make the JS output cleaner. These can still be used in untyped code (TLocal), but are escaped upon declaration. *) let kwds2 = let h = Hashtbl.create 0 in List.iter (fun s -> Hashtbl.add h s ()) [ (* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects *) "Infinity"; "NaN"; "decodeURI"; "decodeURIComponent"; "encodeURI"; "encodeURIComponent"; "escape"; "eval"; "isFinite"; "isNaN"; "parseFloat"; "parseInt"; "undefined"; "unescape"; "JSON"; "Number"; "Object"; "console"; "window"; "require"; ]; h let valid_js_ident s = String.length s > 0 && try for i = 0 to String.length s - 1 do match String.unsafe_get s i with | 'a'..'z' | 'A'..'Z' | '$' | '_' -> () | '0'..'9' when i > 0 -> () | _ -> raise Exit done; true with Exit -> false let field s = if Hashtbl.mem kwds s || not (valid_js_ident s) then "[\"" ^ s ^ "\"]" else "." ^ s let ident s = if Hashtbl.mem kwds s then "$" ^ s else s let check_var_declaration v = if Hashtbl.mem kwds2 v.v_name then v.v_name <- "$" ^ v.v_name let anon_field s = if Hashtbl.mem kwds s || not (valid_js_ident s) then "'" ^ s ^ "'" else s let static_field s = match s with | "length" | "name" -> ".$" ^ s | s -> field s let has_feature ctx = Common.has_feature ctx.com let add_feature ctx = Common.add_feature ctx.com let handle_newlines ctx str = if ctx.com.debug then let rec loop from = try begin let next = String.index_from str from '\n' + 1 in Rbuffer.add_char ctx.smap.mappings ';'; ctx.smap.output_last_col <- 0; ctx.smap.print_comma <- false; loop next end with Not_found -> ctx.smap.output_current_col <- String.length str - from in loop 0 else () let spr ctx s = ctx.separator <- false; handle_newlines ctx s; Rbuffer.add_string ctx.buf s let print ctx = ctx.separator <- false; Printf.kprintf (fun s -> begin handle_newlines ctx s; Rbuffer.add_string ctx.buf s end) let unsupported p = error "This expression cannot be compiled to Javascript" p let add_mapping ctx e = if not ctx.com.debug || e.epos.pmin < 0 then () else let pos = e.epos in let smap = ctx.smap in let file = try Hashtbl.find smap.sources_hash pos.pfile with Not_found -> let length = DynArray.length smap.sources in Hashtbl.replace smap.sources_hash pos.pfile length; DynArray.add smap.sources pos.pfile; length in let line, col = Lexer.find_pos pos in let line = line - 1 in let col = col - 1 in if smap.source_last_file != file || smap.source_last_line != line || smap.source_last_col != col then begin if smap.print_comma then Rbuffer.add_char smap.mappings ',' else smap.print_comma <- true; let base64_vlq number = let encode_digit digit = let chars = [| 'A';'B';'C';'D';'E';'F';'G';'H';'I';'J';'K';'L';'M';'N';'O';'P'; 'Q';'R';'S';'T';'U';'V';'W';'X';'Y';'Z';'a';'b';'c';'d';'e';'f'; 'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v'; 'w';'x';'y';'z';'0';'1';'2';'3';'4';'5';'6';'7';'8';'9';'+';'/' |] in Array.unsafe_get chars digit in let to_vlq number = if number < 0 then ((-number) lsl 1) + 1 else number lsl 1 in let rec loop vlq = let shift = 5 in let base = 1 lsl shift in let mask = base - 1 in let continuation_bit = base in let digit = vlq land mask in let next = vlq asr shift in Rbuffer.add_char smap.mappings (encode_digit ( if next > 0 then digit lor continuation_bit else digit)); if next > 0 then loop next else () in loop (to_vlq number) in base64_vlq (smap.output_current_col - smap.output_last_col); base64_vlq (file - smap.source_last_file); base64_vlq (line - smap.source_last_line); base64_vlq (col - smap.source_last_col); smap.source_last_file <- file; smap.source_last_line <- line; smap.source_last_col <- col; smap.output_last_col <- smap.output_current_col end let write_mappings ctx = let basefile = Filename.basename ctx.com.file in print ctx "\n//# sourceMappingURL=%s.map" basefile; let channel = open_out_bin (ctx.com.file ^ ".map") in let sources = DynArray.to_list ctx.smap.sources in let to_url file = ExtString.String.map (fun c -> if c == '\\' then '/' else c) (Common.get_full_path file) in output_string channel "{\n"; output_string channel "\"version\":3,\n"; output_string channel ("\"file\":\"" ^ (String.concat "\\\\" (ExtString.String.nsplit basefile "\\")) ^ "\",\n"); output_string channel ("\"sourceRoot\":\"file:///\",\n"); output_string channel ("\"sources\":[" ^ (String.concat "," (List.map (fun s -> "\"" ^ to_url s ^ "\"") sources)) ^ "],\n"); if Common.defined ctx.com Define.SourceMapContent then begin output_string channel ("\"sourcesContent\":[" ^ (String.concat "," (List.map (fun s -> try "\"" ^ Ast.s_escape (Std.input_file ~bin:true s) ^ "\"" with _ -> "null") sources)) ^ "],\n"); end; output_string channel "\"names\":[],\n"; output_string channel "\"mappings\":\""; Rbuffer.output_buffer channel ctx.smap.mappings; output_string channel "\"\n"; output_string channel "}"; close_out channel let newline ctx = match Rbuffer.nth ctx.buf (Rbuffer.length ctx.buf - 1) with | '}' | '{' | ':' when not ctx.separator -> print ctx "\n%s" ctx.tabs | _ -> print ctx ";\n%s" ctx.tabs let newprop ctx = match Rbuffer.nth ctx.buf (Rbuffer.length ctx.buf - 1) with | '{' -> print ctx "\n%s" ctx.tabs | _ -> print ctx "\n%s," ctx.tabs let semicolon ctx = match Rbuffer.nth ctx.buf (Rbuffer.length ctx.buf - 1) with | '}' when not ctx.separator -> () | _ -> spr ctx ";" let rec concat ctx s f = function | [] -> () | [x] -> f x | x :: l -> f x; spr ctx s; concat ctx s f l let fun_block ctx f p = let e = List.fold_left (fun e (a,c) -> match c with | None | Some TNull -> e | Some c -> Type.concat (Codegen.set_default ctx.com a c p) e ) f.tf_expr f.tf_args in e let open_block ctx = let oldt = ctx.tabs in ctx.tabs <- "\t" ^ ctx.tabs; (fun() -> ctx.tabs <- oldt) let rec has_return e = match e.eexpr with | TBlock [] -> false | TBlock el -> has_return (List.hd (List.rev el)) | TReturn _ -> true | _ -> false let rec iter_switch_break in_switch e = match e.eexpr with | TFunction _ | TWhile _ | TFor _ -> () | TSwitch _ when not in_switch -> iter_switch_break true e | TBreak when in_switch -> raise Exit | _ -> iter (iter_switch_break in_switch) e let handle_break ctx e = let old = ctx.in_loop, ctx.handle_break in ctx.in_loop <- true; try iter_switch_break false e; ctx.handle_break <- false; (fun() -> ctx.in_loop <- fst old; ctx.handle_break <- snd old; ) with Exit -> spr ctx "try {"; let b = open_block ctx in newline ctx; ctx.handle_break <- true; (fun() -> b(); ctx.in_loop <- fst old; ctx.handle_break <- snd old; newline ctx; spr ctx "} catch( e ) { if( e != \"__break__\" ) throw e; }"; ) let this ctx = match ctx.in_value with None -> "this" | Some _ -> "$this" let is_dynamic_iterator ctx e = let check x = has_feature ctx "HxOverrides.iter" && (match follow x.etype with | TInst ({ cl_path = [],"Array" },_) | TInst ({ cl_kind = KTypeParameter _}, _) | TAnon _ | TDynamic _ | TMono _ -> true | _ -> false ) in match e.eexpr with | TField (x,f) when field_name f = "iterator" -> check x | _ -> false let gen_constant ctx p = function | TInt i -> print ctx "%ld" i | TFloat s -> spr ctx s | TString s -> print ctx "\"%s\"" (Ast.s_escape s) | TBool b -> spr ctx (if b then "true" else "false") | TNull -> spr ctx "null" | TThis -> spr ctx (this ctx) | TSuper -> assert false let rec gen_call ctx e el in_value = match e.eexpr , el with | TConst TSuper , params -> (match ctx.current.cl_super with | None -> error "Missing api.setCurrentClass" e.epos | Some (c,_) -> print ctx "%s.call(%s" (ctx.type_accessor (TClassDecl c)) (this ctx); List.iter (fun p -> print ctx ","; gen_value ctx p) params; spr ctx ")"; ); | TField ({ eexpr = TConst TSuper },f) , params -> (match ctx.current.cl_super with | None -> error "Missing api.setCurrentClass" e.epos | Some (c,_) -> let name = field_name f in print ctx "%s.prototype%s.call(%s" (ctx.type_accessor (TClassDecl c)) (field name) (this ctx); List.iter (fun p -> print ctx ","; gen_value ctx p) params; spr ctx ")"; ); | TCall (x,_) , el when (match x.eexpr with TLocal { v_name = "__js__" } -> false | _ -> true) -> spr ctx "("; gen_value ctx e; spr ctx ")"; spr ctx "("; concat ctx "," (gen_value ctx) el; spr ctx ")"; | TLocal { v_name = "__new__" }, { eexpr = TConst (TString cl) } :: params -> print ctx "new %s(" cl; concat ctx "," (gen_value ctx) params; spr ctx ")"; | TLocal { v_name = "__new__" }, e :: params -> spr ctx "new "; gen_value ctx e; spr ctx "("; concat ctx "," (gen_value ctx) params; spr ctx ")"; | TLocal { v_name = "__js__" }, [{ eexpr = TConst (TString "this") }] -> spr ctx (this ctx) | TLocal { v_name = "__js__" }, [{ eexpr = TConst (TString code) }] -> spr ctx (String.concat "\n" (ExtString.String.nsplit code "\r\n")) | TLocal { v_name = "__js__" }, { eexpr = TConst (TString code); epos = p } :: tl -> Codegen.interpolate_code ctx.com code tl (spr ctx) (gen_expr ctx) p | TLocal { v_name = "__instanceof__" }, [o;t] -> spr ctx "("; gen_value ctx o; print ctx " instanceof "; gen_value ctx t; spr ctx ")"; | TLocal { v_name = "__typeof__" }, [o] -> spr ctx "typeof("; gen_value ctx o; spr ctx ")"; | TLocal { v_name = "__strict_eq__" } , [x;y] -> (* add extra parenthesis here because of operator precedence *) spr ctx "(("; gen_value ctx x; spr ctx ") === "; gen_value ctx y; spr ctx ")"; | TLocal { v_name = "__strict_neq__" } , [x;y] -> (* add extra parenthesis here because of operator precedence *) spr ctx "(("; gen_value ctx x; spr ctx ") !== "; gen_value ctx y; spr ctx ")"; | TLocal ({v_name = "__define_feature__"}), [_;e] -> gen_expr ctx e | TLocal { v_name = "__feature__" }, { eexpr = TConst (TString f) } :: eif :: eelse -> (if has_feature ctx f then gen_value ctx eif else match eelse with | [] -> () | e :: _ -> gen_value ctx e) | TLocal { v_name = "__resources__" }, [] -> spr ctx "["; concat ctx "," (fun (name,data) -> spr ctx "{ "; spr ctx "name : "; gen_constant ctx e.epos (TString name); spr ctx ", data : "; gen_constant ctx e.epos (TString (Codegen.bytes_serialize data)); spr ctx "}" ) (Hashtbl.fold (fun name data acc -> (name,data) :: acc) ctx.com.resources []); spr ctx "]"; | TLocal { v_name = "`trace" }, [e;infos] -> if has_feature ctx "haxe.Log.trace" then begin let t = (try List.find (fun t -> t_path t = (["haxe"],"Log")) ctx.com.types with _ -> assert false) in spr ctx (ctx.type_accessor t); spr ctx ".trace("; gen_value ctx e; spr ctx ","; gen_value ctx infos; spr ctx ")"; end else begin spr ctx "console.log("; gen_value ctx e; spr ctx ")"; end | _ -> gen_value ctx e; spr ctx "("; concat ctx "," (gen_value ctx) el; spr ctx ")" and gen_expr ctx e = add_mapping ctx e; match e.eexpr with | TConst c -> gen_constant ctx e.epos c | TLocal v -> spr ctx (ident v.v_name) | TArray (e1,{ eexpr = TConst (TString s) }) when valid_js_ident s && (match e1.eexpr with TConst (TInt _|TFloat _) -> false | _ -> true) -> gen_value ctx e1; spr ctx (field s) | TArray (e1,e2) -> gen_value ctx e1; spr ctx "["; gen_value ctx e2; spr ctx "]"; | TBinop (op,{ eexpr = TField (x,f) },e2) when field_name f = "iterator" -> gen_value ctx x; spr ctx (field "iterator"); print ctx " %s " (Ast.s_binop op); gen_value ctx e2; | TBinop (op,e1,e2) -> gen_value ctx e1; print ctx " %s " (Ast.s_binop op); gen_value ctx e2; | TField (x,f) when field_name f = "iterator" && is_dynamic_iterator ctx e -> add_feature ctx "use.$iterator"; print ctx "$iterator("; gen_value ctx x; print ctx ")"; | TField (x,FClosure (Some ({cl_path=[],"Array"},_), {cf_name="push"})) -> (* see https://github.com/HaxeFoundation/haxe/issues/1997 *) add_feature ctx "use.$arrayPushClosure"; print ctx "$arrayPushClosure("; gen_value ctx x; print ctx ")" | TField (x,FClosure (_,f)) -> add_feature ctx "use.$bind"; (match x.eexpr with | TConst _ | TLocal _ -> print ctx "$bind("; gen_value ctx x; print ctx ","; gen_value ctx x; print ctx "%s)" (field f.cf_name) | _ -> print ctx "($_="; gen_value ctx x; print ctx ",$bind($_,$_%s))" (field f.cf_name)) | TEnumParameter (x,_,i) -> gen_value ctx x; print ctx "[%i]" (i + 2) | TField ({ eexpr = TConst (TInt _ | TFloat _) } as x,f) -> gen_expr ctx { e with eexpr = TField(mk (TParenthesis x) x.etype x.epos,f) } | TField (x, (FInstance(_,_,f) | FStatic(_,f) | FAnon(f))) when Meta.has Meta.SelfCall f.cf_meta -> gen_value ctx x; | TField (x,f) -> gen_value ctx x; let name = field_name f in spr ctx (match f with FStatic _ -> static_field name | FEnum _ | FInstance _ | FAnon _ | FDynamic _ | FClosure _ -> field name) | TTypeExpr t -> spr ctx (ctx.type_accessor t) | TParenthesis e -> spr ctx "("; gen_value ctx e; spr ctx ")"; | TMeta (_,e) -> gen_expr ctx e | TReturn eo -> if ctx.in_value <> None then unsupported e.epos; (match eo with | None -> spr ctx "return" | Some e -> spr ctx "return "; gen_value ctx e); | TBreak -> if not ctx.in_loop then unsupported e.epos; if ctx.handle_break then spr ctx "throw \"__break__\"" else spr ctx "break" | TContinue -> if not ctx.in_loop then unsupported e.epos; spr ctx "continue" | TBlock el -> print ctx "{"; let bend = open_block ctx in List.iter (gen_block_element ctx) el; bend(); newline ctx; print ctx "}"; | TFunction f -> let old = ctx.in_value, ctx.in_loop in ctx.in_value <- None; ctx.in_loop <- false; print ctx "function(%s) " (String.concat "," (List.map ident (List.map arg_name f.tf_args))); gen_expr ctx (fun_block ctx f e.epos); ctx.in_value <- fst old; ctx.in_loop <- snd old; ctx.separator <- true | TCall (e,el) -> gen_call ctx e el false | TArrayDecl el -> spr ctx "["; concat ctx "," (gen_value ctx) el; spr ctx "]" | TThrow e -> spr ctx "throw "; gen_value ctx e; | TVar (v,eo) -> spr ctx "var "; check_var_declaration v; spr ctx (ident v.v_name); begin match eo with | None -> () | Some e -> spr ctx " = "; gen_value ctx e end | TNew ({ cl_path = [],"Array" },_,[]) -> print ctx "[]" | TNew (c,_,el) -> (match c.cl_constructor with | Some cf when Meta.has Meta.SelfCall cf.cf_meta -> () | _ -> print ctx "new "); print ctx "%s(" (ctx.type_accessor (TClassDecl c)); concat ctx "," (gen_value ctx) el; spr ctx ")" | TIf (cond,e,eelse) -> spr ctx "if"; gen_value ctx cond; spr ctx " "; gen_expr ctx e; (match eelse with | None -> () | Some e2 -> (match e.eexpr with | TObjectDecl _ -> ctx.separator <- false | _ -> ()); semicolon ctx; spr ctx " else "; gen_expr ctx e2); | TUnop (op,Ast.Prefix,e) -> spr ctx (Ast.s_unop op); gen_value ctx e | TUnop (op,Ast.Postfix,e) -> gen_value ctx e; spr ctx (Ast.s_unop op) | TWhile (cond,e,Ast.NormalWhile) -> let handle_break = handle_break ctx e in spr ctx "while"; gen_value ctx cond; spr ctx " "; gen_expr ctx e; handle_break(); | TWhile (cond,e,Ast.DoWhile) -> let handle_break = handle_break ctx e in spr ctx "do "; gen_expr ctx e; semicolon ctx; spr ctx " while"; gen_value ctx cond; handle_break(); | TObjectDecl fields -> spr ctx "{ "; concat ctx ", " (fun (f,e) -> (match e.eexpr with | TMeta((Meta.QuotedField,_,_),e) -> print ctx "'%s' : " f; | _ -> print ctx "%s : " (anon_field f)); gen_value ctx e ) fields; spr ctx "}"; ctx.separator <- true | TFor (v,it,e) -> check_var_declaration v; let handle_break = handle_break ctx e in let it = ident (match it.eexpr with | TLocal v -> v.v_name | _ -> let id = ctx.id_counter in ctx.id_counter <- ctx.id_counter + 1; let name = "$it" ^ string_of_int id in print ctx "var %s = " name; gen_value ctx it; newline ctx; name ) in print ctx "while( %s.hasNext() ) {" it; let bend = open_block ctx in newline ctx; print ctx "var %s = %s.next()" (ident v.v_name) it; gen_block_element ctx e; bend(); newline ctx; spr ctx "}"; handle_break(); | TTry (e,catchs) -> spr ctx "try "; gen_expr ctx e; let vname = (match catchs with [(v,_)] -> check_var_declaration v; v.v_name | _ -> let id = ctx.id_counter in ctx.id_counter <- ctx.id_counter + 1; "$e" ^ string_of_int id ) in print ctx " catch( %s ) {" vname; let bend = open_block ctx in let last = ref false in let else_block = ref false in if (has_feature ctx "haxe.CallStack.exceptionStack") then begin newline ctx; print ctx "%s.lastException = %s" (ctx.type_accessor (TClassDecl { null_class with cl_path = ["haxe"],"CallStack" })) vname end; if (has_feature ctx "js.Boot.HaxeError") then begin newline ctx; print ctx "if (%s instanceof %s) %s = %s.val" vname (ctx.type_accessor (TClassDecl { null_class with cl_path = ["js";"_Boot"],"HaxeError" })) vname vname; end; List.iter (fun (v,e) -> if !last then () else let t = (match follow v.v_type with | TEnum (e,_) -> Some (TEnumDecl e) | TInst (c,_) -> Some (TClassDecl c) | TAbstract (a,_) -> Some (TAbstractDecl a) | TFun _ | TLazy _ | TType _ | TAnon _ -> assert false | TMono _ | TDynamic _ -> None ) in match t with | None -> last := true; if !else_block then print ctx "{"; if vname <> v.v_name then begin newline ctx; print ctx "var %s = %s" v.v_name vname; end; gen_block_element ctx e; if !else_block then begin newline ctx; print ctx "}"; end | Some t -> if not !else_block then newline ctx; print ctx "if( %s.__instanceof(%s," (ctx.type_accessor (TClassDecl { null_class with cl_path = ["js"],"Boot" })) vname; gen_value ctx (mk (TTypeExpr t) (mk_mono()) e.epos); spr ctx ") ) {"; let bend = open_block ctx in if vname <> v.v_name then begin newline ctx; print ctx "var %s = %s" v.v_name vname; end; gen_block_element ctx e; bend(); newline ctx; spr ctx "} else "; else_block := true ) catchs; if not !last then print ctx "throw(%s)" vname; bend(); newline ctx; spr ctx "}"; | TSwitch (e,cases,def) -> spr ctx "switch"; gen_value ctx e; spr ctx " {"; newline ctx; List.iter (fun (el,e2) -> List.iter (fun e -> match e.eexpr with | TConst(c) when c = TNull -> spr ctx "case null: case undefined:"; | _ -> spr ctx "case "; gen_value ctx e; spr ctx ":" ) el; let bend = open_block ctx in gen_block_element ctx e2; if not (has_return e2) then begin newline ctx; print ctx "break"; end; bend(); newline ctx; ) cases; (match def with | None -> () | Some e -> spr ctx "default:"; let bend = open_block ctx in gen_block_element ctx e; bend(); newline ctx; ); spr ctx "}" | TCast (e,None) -> gen_expr ctx e | TCast (e1,Some t) -> print ctx "%s.__cast(" (ctx.type_accessor (TClassDecl { null_class with cl_path = ["js"],"Boot" })); gen_expr ctx e1; spr ctx " , "; spr ctx (ctx.type_accessor t); spr ctx ")" and gen_block_element ?(after=false) ctx e = match e.eexpr with | TBlock el -> List.iter (gen_block_element ~after ctx) el | TCall ({ eexpr = TLocal { v_name = "__feature__" } }, { eexpr = TConst (TString f) } :: eif :: eelse) -> if has_feature ctx f then gen_block_element ~after ctx eif else (match eelse with | [] -> () | [e] -> gen_block_element ~after ctx e | _ -> assert false) | TFunction _ -> gen_block_element ~after ctx (mk (TParenthesis e) e.etype e.epos) | TObjectDecl fl -> List.iter (fun (_,e) -> gen_block_element ~after ctx e) fl | _ -> if not after then newline ctx; gen_expr ctx e; if after then newline ctx and gen_value ctx e = add_mapping ctx e; let assign e = mk (TBinop (Ast.OpAssign, mk (TLocal (match ctx.in_value with None -> assert false | Some v -> v)) t_dynamic e.epos, e )) e.etype e.epos in let value() = let old = ctx.in_value, ctx.in_loop in let r = alloc_var "$r" t_dynamic in ctx.in_value <- Some r; ctx.in_loop <- false; spr ctx "(function($this) "; spr ctx "{"; let b = open_block ctx in newline ctx; spr ctx "var $r"; newline ctx; (fun() -> newline ctx; spr ctx "return $r"; b(); newline ctx; spr ctx "}"; ctx.in_value <- fst old; ctx.in_loop <- snd old; print ctx "(%s))" (this ctx) ) in match e.eexpr with | TConst _ | TLocal _ | TArray _ | TBinop _ | TField _ | TEnumParameter _ | TTypeExpr _ | TParenthesis _ | TObjectDecl _ | TArrayDecl _ | TNew _ | TUnop _ | TFunction _ -> gen_expr ctx e | TMeta (_,e1) -> gen_value ctx e1 | TCall (e,el) -> gen_call ctx e el true | TReturn _ | TBreak | TContinue -> unsupported e.epos | TCast (e1, None) -> gen_value ctx e1 | TCast (e1, Some t) -> print ctx "%s.__cast(" (ctx.type_accessor (TClassDecl { null_class with cl_path = ["js"],"Boot" })); gen_value ctx e1; spr ctx " , "; spr ctx (ctx.type_accessor t); spr ctx ")" | TVar _ | TFor _ | TWhile _ | TThrow _ -> (* value is discarded anyway *) let v = value() in gen_expr ctx e; v() | TBlock [e] -> gen_value ctx e | TBlock el -> let v = value() in let rec loop = function | [] -> spr ctx "return null"; | [e] -> gen_expr ctx (assign e); | e :: l -> gen_expr ctx e; newline ctx; loop l in loop el; v(); | TIf (cond,e,eo) -> (* remove parenthesis unless it's an operation with higher precedence than ?: *) let cond = (match cond.eexpr with | TParenthesis { eexpr = TBinop ((Ast.OpAssign | Ast.OpAssignOp _),_,_) | TIf _ } -> cond | TParenthesis e -> e | _ -> cond ) in gen_value ctx cond; spr ctx "?"; gen_value ctx e; spr ctx ":"; (match eo with | None -> spr ctx "null" | Some e -> gen_value ctx e); | TSwitch (cond,cases,def) -> let v = value() in gen_expr ctx (mk (TSwitch (cond, List.map (fun (e1,e2) -> (e1,assign e2)) cases, match def with None -> None | Some e -> Some (assign e) )) e.etype e.epos); v() | TTry (b,catchs) -> let v = value() in let block e = mk (TBlock [e]) e.etype e.epos in gen_expr ctx (mk (TTry (block (assign b), List.map (fun (v,e) -> v, block (assign e)) catchs )) e.etype e.epos); v() let generate_package_create ctx (p,_) = let rec loop acc = function | [] -> () | p :: l when Hashtbl.mem ctx.packages (p :: acc) -> loop (p :: acc) l | p :: l -> Hashtbl.add ctx.packages (p :: acc) (); (match acc with | [] -> if ctx.js_modern then print ctx "var %s = {}" p else print ctx "var %s = %s || {}" p p | _ -> let p = String.concat "." (List.rev acc) ^ (field p) in if ctx.js_modern then print ctx "%s = {}" p else print ctx "if(!%s) %s = {}" p p ); ctx.separator <- true; newline ctx; loop (p :: acc) l in match p with | [] -> print ctx "var " | _ -> loop [] p let check_field_name c f = match f.cf_name with | "prototype" | "__proto__" | "constructor" -> error ("The field name '" ^ f.cf_name ^ "' is not allowed in JS") (match f.cf_expr with None -> c.cl_pos | Some e -> e.epos); | _ -> () let gen_class_static_field ctx c f = match f.cf_expr with | None | Some { eexpr = TConst TNull } when not (has_feature ctx "Type.getClassFields") -> () | None when is_extern_field f -> () | None -> print ctx "%s%s = null" (s_path ctx c.cl_path) (static_field f.cf_name); newline ctx | Some e -> match e.eexpr with | TFunction _ -> let path = (s_path ctx c.cl_path) ^ (static_field f.cf_name) in let dot_path = (dot_path c.cl_path) ^ (static_field f.cf_name) in ctx.id_counter <- 0; print ctx "%s = " path; (match (get_exposed ctx dot_path f.cf_meta) with [s] -> print ctx "$hx_exports.%s = " s | _ -> ()); gen_value ctx e; newline ctx; | _ -> ctx.statics <- (c,f.cf_name,e) :: ctx.statics let can_gen_class_field ctx = function | { cf_expr = (None | Some { eexpr = TConst TNull }) } when not (has_feature ctx "Type.getInstanceFields") -> false | f -> not (is_extern_field f) let gen_class_field ctx c f = check_field_name c f; match f.cf_expr with | None -> newprop ctx; print ctx "%s: " (anon_field f.cf_name); print ctx "null"; | Some e -> newprop ctx; print ctx "%s: " (anon_field f.cf_name); ctx.id_counter <- 0; gen_value ctx e; ctx.separator <- false let generate_class___name__ ctx c = if has_feature ctx "js.Boot.isClass" then begin let p = s_path ctx c.cl_path in print ctx "%s.__name__ = " p; if has_feature ctx "Type.getClassName" then print ctx "[%s]" (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" (Ast.s_escape s)) (fst c.cl_path @ [snd c.cl_path]))) else print ctx "true"; newline ctx; end let generate_class ctx c = ctx.current <- c; ctx.id_counter <- 0; (match c.cl_path with | [],"Function" -> error "This class redefine a native one" c.cl_pos | _ -> ()); let p = s_path ctx c.cl_path in let hxClasses = has_feature ctx "Type.resolveClass" in if ctx.js_flatten then print ctx "var " else generate_package_create ctx c.cl_path; if ctx.js_modern || not hxClasses then print ctx "%s = " p else print ctx "%s = $hxClasses[\"%s\"] = " p (dot_path c.cl_path); (match (get_exposed ctx (dot_path c.cl_path) c.cl_meta) with [s] -> print ctx "$hx_exports.%s = " s | _ -> ()); (match c.cl_kind with | KAbstractImpl _ -> (* abstract implementations only contain static members and don't need to have constructor functions *) print ctx "{}"; ctx.separator <- true | _ -> (match c.cl_constructor with | Some { cf_expr = Some e } -> gen_expr ctx e | _ -> (print ctx "function() { }"); ctx.separator <- true) ); newline ctx; if ctx.js_modern && hxClasses then begin print ctx "$hxClasses[\"%s\"] = %s" (dot_path c.cl_path) p; newline ctx; end; generate_class___name__ ctx c; (match c.cl_implements with | [] -> () | l -> print ctx "%s.__interfaces__ = [%s]" p (String.concat "," (List.map (fun (i,_) -> ctx.type_accessor (TClassDecl i)) l)); newline ctx; ); let gen_props props = String.concat "," (List.map (fun (p,v) -> p ^":\""^v^"\"") props) in let has_property_reflection = (has_feature ctx "Reflect.getProperty") || (has_feature ctx "Reflect.setProperty") in if has_property_reflection then begin (match Codegen.get_properties c.cl_ordered_statics with | [] -> () | props -> print ctx "%s.__properties__ = {%s}" p (gen_props props); newline ctx); end; List.iter (gen_class_static_field ctx c) c.cl_ordered_statics; let has_class = has_feature ctx "js.Boot.getClass" && (c.cl_super <> None || c.cl_ordered_fields <> [] || c.cl_constructor <> None) in let has_prototype = c.cl_super <> None || has_class || List.exists (can_gen_class_field ctx) c.cl_ordered_fields in if has_prototype then begin (match c.cl_super with | None -> print ctx "%s.prototype = {" p; | Some (csup,_) -> let psup = ctx.type_accessor (TClassDecl csup) in print ctx "%s.__super__ = %s" p psup; newline ctx; print ctx "%s.prototype = $extend(%s.prototype,{" p psup; ); let bend = open_block ctx in List.iter (fun f -> if can_gen_class_field ctx f then gen_class_field ctx c f) c.cl_ordered_fields; if has_class then begin newprop ctx; print ctx "__class__: %s" p; end; if has_property_reflection then begin let props = Codegen.get_properties c.cl_ordered_fields in (match c.cl_super with | _ when props = [] -> () | Some (csup,_) when Codegen.has_properties csup -> newprop ctx; let psup = s_path ctx csup.cl_path in print ctx "__properties__: $extend(%s.prototype.__properties__,{%s})" psup (gen_props props) | _ -> newprop ctx; print ctx "__properties__: {%s}" (gen_props props)); end; bend(); print ctx "\n}"; (match c.cl_super with None -> ctx.separator <- true | _ -> print ctx ")"); newline ctx end let generate_enum ctx e = let p = s_path ctx e.e_path in let ename = List.map (fun s -> Printf.sprintf "\"%s\"" (Ast.s_escape s)) (fst e.e_path @ [snd e.e_path]) in if ctx.js_flatten then print ctx "var " else generate_package_create ctx e.e_path; print ctx "%s = " p; if has_feature ctx "Type.resolveEnum" then print ctx "$hxClasses[\"%s\"] = " (dot_path e.e_path); print ctx "{"; if has_feature ctx "js.Boot.isEnum" then print ctx " __ename__ : %s," (if has_feature ctx "Type.getEnumName" then "[" ^ String.concat "," ename ^ "]" else "true"); print ctx " __constructs__ : [%s] }" (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" s) e.e_names)); ctx.separator <- true; newline ctx; List.iter (fun n -> let f = PMap.find n e.e_constrs in print ctx "%s%s = " p (field f.ef_name); (match f.ef_type with | TFun (args,_) -> let sargs = String.concat "," (List.map (fun (n,_,_) -> ident n) args) in print ctx "function(%s) { var $x = [\"%s\",%d,%s]; $x.__enum__ = %s;" sargs f.ef_name f.ef_index sargs p; if has_feature ctx "has_enum" then spr ctx " $x.toString = $estr;"; spr ctx " return $x; }"; ctx.separator <- true; | _ -> print ctx "[\"%s\",%d]" f.ef_name f.ef_index; newline ctx; if has_feature ctx "has_enum" then begin print ctx "%s%s.toString = $estr" p (field f.ef_name); newline ctx; end; print ctx "%s%s.__enum__ = %s" p (field f.ef_name) p; ); newline ctx ) e.e_names; if has_feature ctx "Type.allEnums" then begin let ctors_without_args = List.filter (fun s -> let ef = PMap.find s e.e_constrs in match follow ef.ef_type with | TFun _ -> false | _ -> true ) e.e_names in print ctx "%s.__empty_constructs__ = [%s]" p (String.concat "," (List.map (fun s -> Printf.sprintf "%s.%s" p s) ctors_without_args)); newline ctx end; match Codegen.build_metadata ctx.com (TEnumDecl e) with | None -> () | Some e -> print ctx "%s.__meta__ = " p; gen_expr ctx e; newline ctx let generate_static ctx (c,f,e) = print ctx "%s%s = " (s_path ctx c.cl_path) (static_field f); gen_value ctx e; newline ctx let generate_require ctx path meta = let _, args, mp = Meta.get Meta.JsRequire meta in let p = (s_path ctx path) in if ctx.js_flatten then spr ctx "var " else generate_package_create ctx path; (match args with | [(EConst(String(module_name)),_)] -> print ctx "%s = require(\"%s\")" p module_name | [(EConst(String(module_name)),_) ; (EConst(String(object_path)),_)] -> print ctx "%s = require(\"%s\").%s" p module_name object_path | _ -> error "Unsupported @:jsRequire format" mp); newline ctx let generate_type ctx = function | TClassDecl c -> (match c.cl_init with | None -> () | Some e -> ctx.inits <- e :: ctx.inits); (* Special case, want to add Math.__name__ only when required, handle here since Math is extern *) let p = s_path ctx c.cl_path in if p = "Math" then generate_class___name__ ctx c; (* Another special case for Std because we do not want to generate it if it's empty. *) if p = "Std" && c.cl_ordered_statics = [] then () else if not c.cl_extern then generate_class ctx c else if Meta.has Meta.JsRequire c.cl_meta && is_directly_used ctx.com c.cl_meta then generate_require ctx c.cl_path c.cl_meta else if not ctx.js_flatten && Meta.has Meta.InitPackage c.cl_meta then (match c.cl_path with | ([],_) -> () | _ -> generate_package_create ctx c.cl_path) | TEnumDecl e when e.e_extern -> if Meta.has Meta.JsRequire e.e_meta && is_directly_used ctx.com e.e_meta then generate_require ctx e.e_path e.e_meta | TEnumDecl e -> generate_enum ctx e | TTypeDecl _ | TAbstractDecl _ -> () let set_current_class ctx c = ctx.current <- c let alloc_ctx com = let ctx = { com = com; buf = Rbuffer.create 16000; packages = Hashtbl.create 0; smap = { source_last_line = 0; source_last_col = 0; source_last_file = 0; print_comma = false; output_last_col = 0; output_current_col = 0; sources = DynArray.create(); sources_hash = Hashtbl.create 0; mappings = Rbuffer.create 16; }; js_modern = not (Common.defined com Define.JsClassic); js_flatten = not (Common.defined com Define.JsUnflatten); statics = []; inits = []; current = null_class; tabs = ""; in_value = None; in_loop = false; handle_break = false; id_counter = 0; type_accessor = (fun _ -> assert false); separator = false; found_expose = false; } in ctx.type_accessor <- (fun t -> let p = t_path t in match t with | TClassDecl ({ cl_extern = true } as c) when not (Meta.has Meta.JsRequire c.cl_meta) -> dot_path p | TEnumDecl ({ e_extern = true } as e) when not (Meta.has Meta.JsRequire e.e_meta) -> dot_path p | _ -> s_path ctx p); ctx let gen_single_expr ctx e expr = if expr then gen_expr ctx e else gen_value ctx e; let str = Rbuffer.unsafe_contents ctx.buf in Rbuffer.reset ctx.buf; ctx.id_counter <- 0; str let generate com = let t = Common.timer "generate js" in (match com.js_gen with | Some g -> g() | None -> let ctx = alloc_ctx com in if has_feature ctx "Class" || has_feature ctx "Type.getClassName" then add_feature ctx "js.Boot.isClass"; if has_feature ctx "Enum" || has_feature ctx "Type.getEnumName" then add_feature ctx "js.Boot.isEnum"; let exposed = List.concat (List.map (fun t -> match t with | TClassDecl c -> let path = dot_path c.cl_path in let class_exposed = get_exposed ctx path c.cl_meta in let static_exposed = List.map (fun f -> get_exposed ctx (path ^ static_field f.cf_name) f.cf_meta ) c.cl_ordered_statics in List.concat (class_exposed :: static_exposed) | _ -> [] ) com.types) in let anyExposed = exposed <> [] in let exportMap = ref (PMap.create String.compare) in let exposedObject = { os_name = ""; os_fields = [] } in let toplevelExposed = ref [] in List.iter (fun path -> ( let parts = ExtString.String.nsplit path "." in let rec loop p pre = match p with | f :: g :: ls -> let path = match pre with "" -> f | pre -> (pre ^ "." ^ f) in if not (PMap.exists path !exportMap) then ( let elts = { os_name = f; os_fields = [] } in exportMap := PMap.add path elts !exportMap; let cobject = match pre with "" -> exposedObject | pre -> PMap.find pre !exportMap in cobject.os_fields <- elts :: cobject.os_fields ); loop (g :: ls) path; | f :: [] when pre = "" -> toplevelExposed := f :: !toplevelExposed; | _ -> () in loop parts ""; )) exposed; let var_global = ( "$global", "typeof window != \"undefined\" ? window : typeof global != \"undefined\" ? global : typeof self != \"undefined\" ? self : this" ) in let closureArgs = [] in let closureArgs = if has_feature ctx "js.Lib.global" then var_global :: closureArgs else closureArgs in let closureArgs = if (anyExposed && not (Common.defined com Define.ShallowExpose)) then ( "$hx_exports", (* TODO(bruno): Remove runtime branching when standard node haxelib is available *) "typeof window != \"undefined\" ? window : exports" ) :: closureArgs else closureArgs in (* Provide console for environments that may not have it. *) let closureArgs = if (not (Common.defined com Define.JsEs5)) then ( "console", "typeof console != \"undefined\" ? console : {log:function(){}}" ) :: closureArgs else closureArgs in if Common.raw_defined com "nodejs" then (* Add node globals to pseudo-keywords, so they are not shadowed by local vars *) List.iter (fun s -> Hashtbl.replace kwds2 s ()) [ "global"; "process"; "__filename"; "__dirname"; "module" ]; if ctx.js_modern then begin (* Additional ES5 strict mode keywords. *) List.iter (fun s -> Hashtbl.replace kwds s ()) [ "arguments"; "eval" ]; (* Wrap output in a closure *) if (anyExposed && (Common.defined com Define.ShallowExpose)) then ( print ctx "var $hx_exports = $hx_exports || {}"; ctx.separator <- true; newline ctx ); print ctx "(function (%s) { \"use strict\"" (String.concat ", " (List.map fst closureArgs)); newline ctx; let rec print_obj f root = ( let path = root ^ "." ^ f.os_name in print ctx "%s = %s || {}" path path; ctx.separator <- true; newline ctx; concat ctx ";" (fun g -> print_obj g path) f.os_fields ) in List.iter (fun f -> print_obj f "$hx_exports") exposedObject.os_fields; end; (* If ctx.js_modern, console is defined in closureArgs. *) if (not ctx.js_modern) && (not (Common.defined com Define.JsEs5)) then add_feature ctx "js.Lib.global"; (* console polyfill will check console from $global *) if (not ctx.js_modern) && (has_feature ctx "js.Lib.global") then print ctx "var %s = %s;\n" (fst var_global) (snd var_global); if (not ctx.js_modern) && (not (Common.defined com Define.JsEs5)) then spr ctx "var console = $global.console || {log:function(){}};\n"; (* TODO: fix $estr *) let vars = [] in let vars = (if has_feature ctx "Type.resolveClass" || has_feature ctx "Type.resolveEnum" then ("$hxClasses = " ^ (if ctx.js_modern then "{}" else "$hxClasses || {}")) :: vars else vars) in let vars = if has_feature ctx "has_enum" then ("$estr = function() { return " ^ (ctx.type_accessor (TClassDecl { null_class with cl_path = ["js"],"Boot" })) ^ ".__string_rec(this,''); }") :: vars else vars in (match List.rev vars with | [] -> () | vl -> print ctx "var %s" (String.concat "," vl); ctx.separator <- true; newline ctx ); if List.exists (function TClassDecl { cl_extern = false; cl_super = Some _ } -> true | _ -> false) com.types then begin print ctx "function $extend(from, fields) { function Inherit() {} Inherit.prototype = from; var proto = new Inherit(); for (var name in fields) proto[name] = fields[name]; if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString; return proto; } "; end; List.iter (generate_type ctx) com.types; let rec chk_features e = if is_dynamic_iterator ctx e then add_feature ctx "use.$iterator"; match e.eexpr with | TField (_,FClosure _) -> add_feature ctx "use.$bind" | _ -> Type.iter chk_features e in List.iter chk_features ctx.inits; List.iter (fun (_,_,e) -> chk_features e) ctx.statics; if has_feature ctx "use.$iterator" then begin add_feature ctx "use.$bind"; print ctx "function $iterator(o) { if( o instanceof Array ) return function() { return HxOverrides.iter(o); }; return typeof(o.iterator) == 'function' ? $bind(o,o.iterator) : o.iterator; }"; newline ctx; end; if has_feature ctx "use.$bind" then begin print ctx "var $_, $fid = 0"; newline ctx; print ctx "function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; o.hx__closures__[m.__id__] = f; } return f; }"; newline ctx; end; if has_feature ctx "use.$arrayPushClosure" then begin print ctx "function $arrayPushClosure(a) {"; print ctx " return function(x) { a.push(x); }; "; print ctx "}"; newline ctx end; List.iter (gen_block_element ~after:true ctx) (List.rev ctx.inits); List.iter (generate_static ctx) (List.rev ctx.statics); (match com.main with | None -> () | Some e -> gen_expr ctx e; newline ctx); if ctx.js_modern then begin print ctx "})(%s)" (String.concat ", " (List.map snd closureArgs)); newline ctx; if (anyExposed && (Common.defined com Define.ShallowExpose)) then ( List.iter (fun f -> print ctx "var %s = $hx_exports.%s" f.os_name f.os_name; ctx.separator <- true; newline ctx ) exposedObject.os_fields; List.iter (fun f -> print ctx "var %s = $hx_exports.%s" f f; ctx.separator <- true; newline ctx ) !toplevelExposed ); end; if com.debug then write_mappings ctx else (try Sys.remove (com.file ^ ".map") with _ -> ()); let ch = open_out_bin com.file in Rbuffer.output_buffer ch ctx.buf; close_out ch); t() haxe_3.2.1+dfsg.orig/genneko.ml0000664000175000017500000006632412607337712016317 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open Nast open Common type context = { version : int; com : Common.context; packages : (string list, unit) Hashtbl.t; globals : (string list * string, string) Hashtbl.t; mutable curglobal : int; mutable macros : bool; mutable curclass : string; mutable curmethod : string; mutable inits : (tclass * texpr) list; mutable label_count : int; } let files = Hashtbl.create 0 let pos ctx p = if ctx.macros then { psource = p.pfile; pline = p.pmin lor ((p.pmax - p.pmin) lsl 20); } else let file = (match ctx.com.debug with | true -> ctx.curclass ^ "::" ^ ctx.curmethod | false -> try Hashtbl.find files p.pfile with Not_found -> let path = (match Common.defined ctx.com Common.Define.AbsolutePath with | true -> if (Filename.is_relative p.pfile) then Filename.concat (Sys.getcwd()) p.pfile else p.pfile | false -> try (* lookup relative path *) let len = String.length p.pfile in let base = List.find (fun path -> let l = String.length path in len > l && String.sub p.pfile 0 l = path ) ctx.com.Common.class_path in let l = String.length base in String.sub p.pfile l (len - l) with Not_found -> p.pfile ) in Hashtbl.add files p.pfile path; path ) in { psource = file; pline = Lexer.get_error_line p; } let gen_global_name ctx path = match path with | [], name -> name | _ -> try Hashtbl.find ctx.globals path with Not_found -> let name = "@G" ^ string_of_int ctx.curglobal in ctx.curglobal <- ctx.curglobal + 1; Hashtbl.add ctx.globals path name; name let null p = (EConst Null,p) let this p = (EConst This,p) let int p n = (EConst (Int n),p) let str p s = (EConst (String s),p) let ident p s = let l = String.length s in if l > 10 && String.sub s 0 10 = "__dollar__" then (EConst (Builtin (String.sub s 10 (l - 10))),p) else (EConst (Ident s),p) let field p e f = (EField (e,f),p) let builtin p n = (EConst (Builtin n),p) let call p e el = (ECall (e,el),p) let array p el = call p (builtin p "array") el let pmap_list f p = PMap.fold (fun v acc -> f v :: acc) p [] let rec needs_return e = match e with | (EBlock l,_) -> let rec loop = function | [] -> true | [x] -> needs_return x | _ :: l -> loop l in loop l | (EReturn _,_) -> false | _ -> true let with_return e = if needs_return e then let p = snd e in let ret = EReturn (Some (null p)),p in match e with | (EBlock l,_) -> (EBlock (l @ [ret]),p) | _ -> (EBlock [e;ret] , p) else e let gen_type_path p (path,t) = match path with | [] -> ident p t | path :: l -> let epath = List.fold_left (fun e path -> field p e path) (ident p path) l in field p epath t let rec gen_big_string ctx p s = let max = 1 lsl 16 - 1 in if String.length s > max then (EBinop ("+",str p (String.sub s 0 max),gen_big_string ctx p (String.sub s max (String.length s - max))),p) else str p s let gen_constant ctx pe c = let p = pos ctx pe in match c with | TInt i -> (try let h = Int32.to_int (Int32.shift_right_logical i 24) in if (h land 128 = 0) <> (h land 64 = 0) then raise Exit; int p (Int32.to_int i) with _ -> if ctx.version < 2 then error "This integer is too big to be compiled to a Neko 31-bit integer. Please use a Float instead" pe; (EConst (Int32 i),p)) | TFloat f -> (EConst (Float f),p) | TString s -> call p (field p (ident p "String") "new") [gen_big_string ctx p s] | TBool b -> (EConst (if b then True else False),p) | TNull -> null p | TThis -> this p | TSuper -> assert false let rec gen_binop ctx p op e1 e2 = (EBinop (Ast.s_binop op,gen_expr ctx e1,gen_expr ctx e2),p) and gen_unop ctx p op flag e = match op with | Increment -> (EBinop ((if flag = Prefix then "+=" else "++="), gen_expr ctx e , int p 1),p) | Decrement -> (EBinop ((if flag = Prefix then "-=" else "--="), gen_expr ctx e , int p 1),p) | Not -> call p (builtin p "not") [gen_expr ctx e] | Neg -> (EBinop ("-",int p 0, gen_expr ctx e),p) | NegBits -> (EBinop ("-",int p (-1), gen_expr ctx e),p) and gen_call ctx p e el = match e.eexpr , el with | TConst TSuper , _ -> let c = (match follow e.etype with TInst (c,_) -> c | _ -> assert false) in call p (builtin p "call") [ field p (gen_type_path p c.cl_path) "__construct__"; this p; array p (List.map (gen_expr ctx) el) ] | TLocal { v_name = "__resources__" }, [] -> call p (builtin p "array") (Hashtbl.fold (fun name data acc -> (EObject [("name",gen_constant ctx e.epos (TString name));("data",gen_big_string ctx p data)],p) :: acc ) ctx.com.resources []) | TField ({ eexpr = TConst TSuper; etype = t },f) , _ -> let c = (match follow t with TInst (c,_) -> c | _ -> assert false) in call p (builtin p "call") [ field p (gen_type_path p (fst c.cl_path,"@" ^ snd c.cl_path)) (field_name f); this p; array p (List.map (gen_expr ctx) el) ] | _ , _ -> let e = (match gen_expr ctx e with EFunction _, _ as e -> (EBlock [e],p) | e -> e) in call p e (List.map (gen_expr ctx) el) and gen_expr ctx e = let p = pos ctx e.epos in match e.eexpr with | TConst c -> gen_constant ctx e.epos c | TLocal v when v.v_name.[0] = '$' -> (EConst (Builtin (String.sub v.v_name 1 (String.length v.v_name - 1))),p) | TLocal v -> if v.v_capture then (EArray (ident p v.v_name,int p 0),p) else ident p v.v_name | TArray (e1,e2) -> (EArray (gen_expr ctx e1,gen_expr ctx e2),p) | TBinop (OpAssign,{ eexpr = TField (e1,f) },e2) -> (EBinop ("=",field p (gen_expr ctx e1) (field_name f),gen_expr ctx e2),p) | TBinop (op,e1,e2) -> gen_binop ctx p op e1 e2 | TField (e2,FClosure (_,f)) -> (match follow e.etype with | TFun (args,_) -> let n = List.length args in if n > 5 then error "Cannot create closure with more than 5 arguments" e.epos; let tmp = ident p "@tmp" in EBlock [ (EVars ["@tmp", Some (gen_expr ctx e2); "@fun", Some (field p tmp f.cf_name)] , p); if ctx.macros then call p (builtin p "closure") [ident p "@fun";tmp] else call p (ident p ("@closure" ^ string_of_int n)) [tmp;ident p "@fun"] ] , p | _ -> assert false) | TEnumParameter (e,_,i) -> EArray (field p (gen_expr ctx e) "args",int p i),p | TField (e,f) -> field p (gen_expr ctx e) (field_name f) | TTypeExpr t -> gen_type_path p (t_path t) | TParenthesis e -> (EParenthesis (gen_expr ctx e),p) | TMeta (_,e) -> gen_expr ctx e | TObjectDecl fl -> let hasToString = ref false in let fl = List.map (fun (f,e) -> if f = "toString" then hasToString := (match follow e.etype with TFun ([],_) -> true | _ -> false); f , gen_expr ctx e) fl in (EObject (if !hasToString then ("__string",ident p "@default__string") :: fl else fl),p) | TArrayDecl el -> call p (field p (ident p "Array") "new1") [array p (List.map (gen_expr ctx) el); int p (List.length el)] | TCall (e,el) -> gen_call ctx p e el | TNew (c,_,params) -> call p (field p (gen_type_path p c.cl_path) "new") (List.map (gen_expr ctx) params) | TUnop (op,flag,e) -> gen_unop ctx p op flag e | TVar (v,eo) -> (EVars ( let e = (match eo with | None -> if v.v_capture then Some (call p (builtin p "array") [null p]) else None | Some e -> let e = gen_expr ctx e in if v.v_capture then Some (call p (builtin p "array") [e]) else Some e ) in [v.v_name, e] ),p) | TFunction f -> let inits = List.fold_left (fun acc (a,c) -> let acc = if a.v_capture then (EBinop ("=",ident p a.v_name,call p (builtin p "array") [ident p a.v_name]),p) :: acc else acc in match c with | None | Some TNull -> acc | Some c -> gen_expr ctx (Codegen.set_default ctx.com a c e.epos) :: acc ) [] f.tf_args in let e = gen_expr ctx f.tf_expr in let e = (match inits with [] -> e | _ -> EBlock (List.rev (e :: inits)),p) in (EFunction (List.map arg_name f.tf_args, with_return e),p) | TBlock el -> (EBlock (List.map (gen_expr ctx) el), p) | TFor (v, it, e) -> let it = gen_expr ctx it in let e = gen_expr ctx e in let next = call p (field p (ident p "@tmp") "next") [] in let next = (if v.v_capture then call p (builtin p "array") [next] else next) in (EBlock [(EVars ["@tmp", Some it],p); (EWhile (call p (field p (ident p "@tmp") "hasNext") [], (EBlock [ (EVars [v.v_name, Some next],p); e ],p) ,NormalWhile),p)] ,p) | TIf (cond,e1,e2) -> (* if(e)-1 is parsed as if( e - 1 ) *) let parent e = mk (TParenthesis e) e.etype e.epos in let e1 = (match e1.eexpr with TConst (TInt n) when n < 0l -> parent e1 | TConst (TFloat f) when f.[0] = '-' -> parent e1 | _ -> e1) in (EIf (gen_expr ctx cond,gen_expr ctx e1,(match e2 with None -> None | Some e -> Some (gen_expr ctx e))),p) | TWhile (econd,e,flag) -> (EWhile (gen_expr ctx econd, gen_expr ctx e, match flag with Ast.NormalWhile -> NormalWhile | Ast.DoWhile -> DoWhile),p) | TTry (e,catchs) -> let rec loop = function | [] -> call p (builtin p "rethrow") [ident p "@tmp"] | (v,e) :: l -> let e2 = loop l in let path = (match follow v.v_type with | TInst (c,_) -> Some c.cl_path | TEnum (e,_) -> Some e.e_path | TAbstract (a,_) -> Some a.a_path | TDynamic _ -> None | _ -> assert false ) in let cond = (match path with | None -> (EConst True,p) | Some path -> call p (field p (gen_type_path p (["neko"],"Boot")) "__instanceof") [ident p "@tmp"; gen_type_path p path] ) in let id = ident p "@tmp" in let id = (if v.v_capture then call p (builtin p "array") [id] else id) in let e = gen_expr ctx e in (EIf (cond,(EBlock [ EVars [v.v_name,Some id],p; e; ],p),Some e2),p) in let catchs = loop catchs in let catchs = (EBlock [ (EIf ( (EBinop ("==",call p (builtin p "typeof") [ident p "@tmp"],builtin p "tstring"),p), (EBinop ("=",ident p "@tmp",call p (field p (ident p "String") "new") [ident p "@tmp"]),p), None ),p); catchs; ],p) in (ETry (gen_expr ctx e,"@tmp",catchs),p) | TReturn eo -> (EReturn (match eo with None -> Some (null p) | Some e -> Some (gen_expr ctx e)),p) | TBreak -> (EBreak None,p) | TContinue -> (EContinue,p) | TThrow e -> call p (builtin p "throw") [gen_expr ctx e] | TCast (e,None) -> gen_expr ctx e | TCast (e1,Some t) -> gen_expr ctx (Codegen.default_cast ~vtmp:"@tmp" ctx.com e1 t e.etype e.epos) | TSwitch (e,cases,eo) -> let e = gen_expr ctx e in let eo = (match eo with None -> None | Some e -> Some (gen_expr ctx e)) in try (ESwitch ( e, List.map (fun (el,e2) -> match List.map (gen_expr ctx) el with | [] -> assert false | [e] -> e, gen_expr ctx e2 | _ -> raise Exit ) cases, eo ),p) with Exit -> (EBlock [ (EVars ["@tmp",Some e],p); List.fold_left (fun acc (el,e) -> let cond = (match el with | [] -> assert false | e :: l -> let eq e = (EBinop ("==",ident p "@tmp",gen_expr ctx e),p) in List.fold_left (fun acc e -> (EBinop ("||",acc,eq e),p)) (eq e) l ) in EIf (cond,gen_expr ctx e,Some acc),p ) (match eo with None -> null p | Some e -> e) (List.rev cases) ],p) let gen_method ctx p c acc = ctx.curmethod <- c.cf_name; if is_extern_field c then acc else match c.cf_expr with | None -> ((c.cf_name, null p) :: acc) | Some e -> match e.eexpr with | TCall ({ eexpr = TField (_,FStatic ({cl_path=["neko"],"Lib"},{cf_name="load" | "loadLazy" as load})) },[{ eexpr = TConst (TString m) };{ eexpr = TConst (TString f) };{ eexpr = TConst (TInt n) }]) -> let p = pos ctx e.epos in let e = call p (EField (builtin p "loader","loadprim"),p) [(EBinop ("+",(EBinop ("+",str p m,str p "@"),p),str p f),p); (EConst (Int (Int32.to_int n)),p)] in let e = (if load = "load" then e else (ETry (e,"@e",call p (ident p "@lazy_error") [ident p "@e"]),p)) in (c.cf_name, e) :: acc | TFunction _ -> ((if c.cf_name = "new" then "__construct__" else c.cf_name), gen_expr ctx e) :: acc | _ -> (c.cf_name, null p) :: acc let gen_class ctx c = ctx.curclass <- s_type_path c.cl_path; ctx.curmethod <- "$init"; let p = pos ctx c.cl_pos in let clpath = gen_type_path p (fst c.cl_path,"@" ^ snd c.cl_path) in let stpath = gen_type_path p c.cl_path in let fnew = (match c.cl_constructor with | Some f -> (match f.cf_expr with | Some {eexpr = TFunction tf} -> let params = List.map (fun (v,_) -> v.v_name) tf.tf_args in gen_method ctx p f ["new",(EFunction (params,(EBlock [ (EVars ["@o",Some (call p (builtin p "new") [null p])],p); (call p (builtin p "objsetproto") [ident p "@o"; clpath]); (call p (builtin p "call") [field p (this p) "__construct__"; ident p "@o"; array p (List.map (ident p) params)]); (EReturn (Some (ident p "@o")),p) ],p)),p)] | _ -> []) | None -> [] ) in let fstring = (try let f = PMap.find "toString" c.cl_fields in match follow f.cf_type with | TFun ([],_) -> ["__string",ident p "@default__string"] | _ -> [] with Not_found -> [] ) in let fserialize = "__serialize" , ident p "@serialize" in let others = (match c.cl_implements with | [] -> [] | l -> ["__interfaces__",array p (List.map (fun (c,_) -> gen_type_path p c.cl_path) l)] ) @ (match c.cl_super with | None -> [] | Some (c,_) -> ["__super__", gen_type_path p c.cl_path] ) in let build (f,e) = (EBinop ("=",field p (ident p "@tmp") f,e),p) in let tmp = (EVars ["@tmp",Some (call p (builtin p "new") [null p])],p) in let estat = (EBinop ("=", stpath, ident p "@tmp"),p) in let gen_props props = (EObject (List.map (fun (n,s) -> n,str p s) props),p) in let sprops = (match Codegen.get_properties c.cl_ordered_statics with | [] -> [] | l -> ["__properties__",gen_props l] ) in let sfields = List.map build ( ("prototype",clpath) :: sprops @ PMap.fold (gen_method ctx p) c.cl_statics (fnew @ others) ) in let eclass = (EBinop ("=", clpath, ident p "@tmp"),p) in let mfields = List.map build (PMap.fold (gen_method ctx p) c.cl_fields (fserialize :: fstring)) in let props = Codegen.get_properties c.cl_ordered_fields in let emeta = (EBinop ("=",field p clpath "__class__",stpath),p) :: (match props with | [] -> [] | _ -> let props = gen_props props in let props = (match c.cl_super with | Some (csup,_) when Codegen.has_properties csup -> (EBlock [ (EVars ["@tmp",Some props],p); call p (builtin p "objsetproto") [ident p "@tmp";field p (field p (gen_type_path p csup.cl_path) "prototype") "__properties__"]; ident p "@tmp" ],p) | _ -> props ) in [EBinop ("=",field p clpath "__properties__",props),p]) @ match c.cl_path with | [] , name -> [(EBinop ("=",field p (ident p "@classes") name,ident p name),p)] | _ -> [] in let emeta = if ctx.macros then (EBinop ("=",field p stpath "__ct__",call p (builtin p "typewrap") [Obj.magic (TClassDecl c)]),p) :: emeta else emeta in let eextends = (match c.cl_super with | None -> [] | Some (c,_) -> let esuper = gen_type_path p (fst c.cl_path,"@" ^ snd c.cl_path) in [call p (builtin p "objsetproto") [clpath; esuper]] ) in (EBlock (tmp :: eclass :: mfields @ tmp :: estat :: sfields @ eextends @ emeta),p) let gen_enum_constr ctx path c = ctx.curmethod <- c.ef_name; let p = pos ctx c.ef_pos in (EBinop ("=",field p path c.ef_name, match follow c.ef_type with | TFun (params,_) -> let params = List.map (fun (n,_,_) -> n) params in (EFunction (params, (EBlock [ (EVars ["@tmp",Some (EObject [ "tag" , str p c.ef_name; "index" , int p c.ef_index; "args" , array p (List.map (ident p) params); ],p)],p); call p (builtin p "objsetproto") [ident p "@tmp"; field p path "prototype"]; ident p "@tmp"; ],p) ),p) | _ -> (EBlock [ (EVars ["@tmp",Some (EObject ["tag" , str p c.ef_name; "index", int p c.ef_index; "__serialize" , ident p "@tag_serialize"],p)],p); call p (builtin p "objsetproto") [ident p "@tmp"; field p path "prototype"]; ident p "@tmp"; ],p) ),p) let gen_enum ctx e = ctx.curclass <- s_type_path e.e_path; ctx.curmethod <- "$init"; let p = pos ctx e.e_pos in let path = gen_type_path p e.e_path in let uname = (EConst (Ident (gen_global_name ctx e.e_path)),p) in (EBlock ( (EBinop ("=",uname, call p (builtin p "new") [null p]),p) :: (EBinop ("=",path, uname),p) :: (EBinop ("=",field p uname "prototype", (EObject [ "__enum__" , uname; "__serialize" , ident p "@serialize"; "__string" , ident p "@enum_to_string" ],p)),p) :: pmap_list (gen_enum_constr ctx uname) e.e_constrs @ (match e.e_path with | [] , name -> [EBinop ("=",field p (ident p "@classes") name,ident p name),p] | _ -> []) ),p) let gen_type ctx t acc = match t with | TClassDecl c -> (match c.cl_init with | None -> () | Some e -> ctx.inits <- (c,e) :: ctx.inits); if c.cl_extern then acc else gen_class ctx c :: acc | TEnumDecl e -> if e.e_extern then acc else gen_enum ctx e :: acc | TTypeDecl _ | TAbstractDecl _ -> acc let gen_static_vars ctx t = match t with | TEnumDecl _ | TTypeDecl _ | TAbstractDecl _ -> [] | TClassDecl c -> if c.cl_extern then [] else List.fold_right (fun f acc -> match f.cf_expr with | None -> acc | Some e -> match e.eexpr with | TFunction _ -> acc | _ -> ctx.curclass <- s_type_path c.cl_path; ctx.curmethod <- "$statics"; let p = pos ctx e.epos in (EBinop ("=", (field p (gen_type_path p c.cl_path) f.cf_name), gen_expr ctx e ),p) :: acc ) c.cl_ordered_statics [] let gen_package ctx t = let rec loop acc p = match p with | [] -> [] | x :: l -> let path = acc @ [x] in if not (Hashtbl.mem ctx.packages path) then begin let p = pos ctx (t_infos t).mt_pos in let e = (EBinop ("=",gen_type_path p (acc,x),call p (builtin p "new") [null p]),p) in Hashtbl.add ctx.packages path (); (match acc with | [] -> let reg = (EBinop ("=",field p (ident p "@classes") x,ident p x),p) in e :: reg :: loop path l | _ -> e :: loop path l) end else loop path l in loop [] (fst (t_path t)) let gen_boot ctx = (EBlock [ EBinop ("=",field null_pos (gen_type_path null_pos (["neko"],"Boot")) "__classes",ident null_pos "@classes"),null_pos; call null_pos (field null_pos (gen_type_path null_pos (["neko"],"Boot")) "__init") []; ],null_pos) let gen_name ctx acc t = match t with | TEnumDecl e when e.e_extern -> acc | TEnumDecl e -> let p = pos ctx e.e_pos in let name = fst e.e_path @ [snd e.e_path] in let arr = call p (field p (ident p "Array") "new1") [array p (List.map (fun n -> gen_constant ctx e.e_pos (TString n)) name); int p (List.length name)] in let path = gen_type_path p e.e_path in let setname = (EBinop ("=",field p path "__ename__",arr),p) in let arr = call p (field p (ident p "Array") "new1") [array p (List.map (fun n -> gen_constant ctx e.e_pos (TString n)) e.e_names); int p (List.length e.e_names)] in let setconstrs = (EBinop ("=", field p path "__constructs__", arr),p) in let meta = (match Codegen.build_metadata ctx.com (TEnumDecl e) with | None -> [] | Some e -> [EBinop ("=",field p path "__meta__", gen_expr ctx e),p] ) in let meta = if ctx.macros then (EBinop ("=",field p path "__et__",call p (builtin p "typewrap") [Obj.magic t]),p) :: meta else meta in setname :: setconstrs :: meta @ acc | TClassDecl c -> if c.cl_extern || (match c.cl_kind with KTypeParameter _ -> true | _ -> false) then acc else let p = pos ctx c.cl_pos in let name = fst c.cl_path @ [snd c.cl_path] in let arr = call p (field p (ident p "Array") "new1") [array p (List.map (fun n -> gen_constant ctx c.cl_pos (TString n)) name); int p (List.length name)] in (EBinop ("=",field p (gen_type_path p c.cl_path) "__name__",arr),p) :: (match c.cl_implements with | [] -> acc | l -> let interf = field p (gen_type_path p c.cl_path) "__interfaces__" in (EBinop ("=",interf, call p (field p (ident p "Array") "new1") [interf; int p (List.length l)]),p) :: acc) | TTypeDecl _ | TAbstractDecl _ -> acc let generate_libs_init = function | [] -> [] | libs -> (* var @s = $loader.loadprim("std@sys_string",0)(); var @env = $loader.loadprim("std@get_env",1); var @b = if( @s == "Windows" ) @env("HAXEPATH") + "\\lib\\" else try $loader.loadprim("std@file_contents",1)(@env("HOME")+"/.haxelib") + "/" catch e if( @s == "Linux" ) if( $loader(loadprim("std@sys_exists",1))("/usr/lib/haxe/lib") ) "/usr/lib/haxe/lib" else "/usr/share/haxe/lib/" else "/usr/local/lib/haxe/lib/"; if( try $loader.loadprim("std@sys_file_type",1)(".haxelib") == "dir" catch e false ) @b = $loader.loadprim("std@file_full_path",1)(".haxelib") + "/"; if( $loader.loadprim("std@sys_is64",0)() ) @s = @s + 64; @b = @b + "/" *) let p = null_pos in let es = ident p "@s" in let loadp n nargs = call p (field p (builtin p "loader") "loadprim") [str p ("std@" ^ n); int p nargs] in let op o e1 e2 = (EBinop (o,e1,e2),p) in let boot = [ (EVars [ "@s",Some (call p (loadp "sys_string" 0) []); "@env",Some (loadp "get_env" 1); "@b", Some (EIf (op "==" es (str p "Windows"), op "+" (call p (ident p "@env") [str p "HAXEPATH"]) (str p "\\lib\\"), Some (ETry ( op "+" (call p (loadp "file_contents" 1) [op "+" (call p (ident p "@env") [str p "HOME"]) (str p "/.haxelib")]) (str p "/"), "e", (EIf (op "==" es (str p "Linux"), (EIf (call p (loadp "sys_exists" 1) [ str p "/usr/lib/haxe/lib" ], str p "/usr/lib/haxe/lib/", Some (str p "/usr/share/haxe/lib/")),p), Some (str p "/usr/local/lib/haxe/lib/") ),p) ),p) ),p); ],p); (EIf ((ETry (op "==" (call p (loadp "sys_file_type" 1) [str p ".haxelib"]) (str p "dir"),"e",(EConst False,p)),p),op "=" (ident p "@b") (op "+" (call p (loadp "file_full_path" 1) [str p ".haxelib"]) (str p "/")), None),p); (EIf (call p (loadp "sys_is64" 0) [],op "=" es (op "+" es (int p 64)),None),p); op "=" es (op "+" es (str p "/")); ] in let lpath = field p (builtin p "loader") "path" in boot @ List.map (fun dir -> let full_path = dir.[0] = '/' || dir.[1] = ':' in let dstr = str p dir in (* // for each lib dir $loader.path = $array($loader.path,@b+dir+@s); *) op "=" lpath (call p (builtin p "array") [op "+" (if full_path then dstr else op "+" (ident p "@b") dstr) (ident p "@s"); lpath]) ) libs let new_context com ver macros = { version = ver; com = com; globals = Hashtbl.create 0; curglobal = 0; packages = Hashtbl.create 0; macros = macros; curclass = "$boot"; curmethod = "$init"; inits = []; label_count = 0; } let header() = let p = { psource = "
"; pline = 1 } in let fields l = let rec loop = function | [] -> assert false | [x] -> ident p x | x :: l -> field p (loop l) x in loop (List.rev l) in let func pl e = (EFunction (pl,(EReturn (Some e),p)),p) in let inits = [ "@classes",call p (builtin p "new") [null p]; "@enum_to_string",func [] (call p (fields ["neko";"Boot";"__enum_str"]) [this p]); "@serialize",func [] (call p (fields ["neko";"Boot";"__serialize"]) [this p]); "@tag_serialize",func [] (call p (fields ["neko";"Boot";"__tagserialize"]) [this p]); "@lazy_error",func ["e"] (call p (builtin p "varargs") [func ["_"] (call p (builtin p "throw") [ident p "e"])]); "@default__string",func [] (EBlock [ EVars ["@s",Some (call p (field p (this p) "toString") [])] ,p; EIf ((EBinop ("!=",call p (builtin p "typeof") [ident p "@s"],builtin p "tobject"),p),(EReturn (Some (null p)),p),None),p; EReturn (Some (field p (ident p "@s") "__s")),p; ],p) ] in let inits = inits @ List.map (fun nargs -> let args = Array.to_list (Array.init nargs (fun i -> Printf.sprintf "%c" (char_of_int (int_of_char 'a' + i)))) in let efun = (EFunction (args,(EBlock [ (EBinop ("=",(EConst This,p),ident p "@this"),p); call p (ident p "@fun") (List.map (ident p) args); ],p)),p) in let eif = EIf ((EBinop ("==",ident p "@fun",null p),p),null p,Some efun) in let e = func ["@this";"@fun"] (eif,p) in "@closure" ^ string_of_int nargs, e ) [0;1;2;3;4;5] in List.map (fun (v,e)-> EBinop ("=",ident p v,e),p) inits let build ctx types = let packs = List.concat (List.map (gen_package ctx) types) in let names = List.fold_left (gen_name ctx) [] types in let methods = List.rev (List.fold_left (fun acc t -> gen_type ctx t acc) [] types) in let boot = gen_boot ctx in let inits = List.map (fun (c,e) -> ctx.curclass <- s_type_path c.cl_path; ctx.curmethod <- "__init__"; gen_expr ctx e ) (List.rev ctx.inits) in ctx.inits <- []; let vars = List.concat (List.map (gen_static_vars ctx) types) in packs @ methods @ boot :: names @ inits @ vars let generate com = let ctx = new_context com (if Common.defined com Define.NekoV1 then 1 else 2) false in let t = Common.timer "neko generation" in let libs = (EBlock (generate_libs_init com.neko_libs) , { psource = "
"; pline = 1; }) in let el = build ctx com.types in let emain = (match com.main with None -> [] | Some e -> [gen_expr ctx e]) in let e = (EBlock ((header()) @ libs :: el @ emain), null_pos) in let source = Common.defined com Define.NekoSource in let use_nekoc = Common.defined com Define.UseNekoc in if not use_nekoc then begin try mkdir_from_path com.file; let ch = IO.output_channel (open_out_bin com.file) in Nbytecode.write ch (Ncompile.compile ctx.version e); IO.close_out ch; with Ncompile.Error (msg,pos) -> let pfile = Common.find_file com pos.psource in let rec loop p = let pp = { pfile = pfile; pmin = p; pmax = p; } in if Lexer.get_error_line pp >= pos.pline then pp else loop (p + 1) in error msg (loop 0) end; let command cmd = try com.run_command cmd with _ -> -1 in let neko_file = (try Filename.chop_extension com.file with _ -> com.file) ^ ".neko" in if source || use_nekoc then begin let ch = IO.output_channel (open_out_bin neko_file) in Binast.write ch e; IO.close_out ch; end; if use_nekoc && command ("nekoc" ^ (if ctx.version > 1 then " -version " ^ string_of_int ctx.version else "") ^ " \"" ^ neko_file ^ "\"") <> 0 then failwith "Neko compilation failure"; if source then begin if command ("nekoc -p \"" ^ neko_file ^ "\"") <> 0 then failwith "Failed to print neko code"; Sys.remove neko_file; Sys.rename ((try Filename.chop_extension com.file with _ -> com.file) ^ "2.neko") neko_file; end; t() haxe_3.2.1+dfsg.orig/genphp.ml0000664000175000017500000020067112607337712016145 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open Common type method_name = { mutable mpath : path; mutable mname : string; } type inline_method = { iname : string; iindex : int; iexpr : texpr; ihasthis : bool; iin_block : bool; iarguments : string list; ilocals : (string,string) PMap.t; iinv_locals : (string,string) PMap.t; } type context = { com : Common.context; ch : out_channel; buf : Buffer.t; path : path; stack : Codegen.stack_context; mutable nested_loops : int; mutable inline_index : int; mutable curclass : tclass; mutable curmethod : string; mutable tabs : string; mutable in_value : string option; mutable in_loop : bool; mutable in_block : bool; mutable in_instance_method : bool; mutable imports : (string,string list list) Hashtbl.t; mutable extern_required_paths : (string list * string) list; mutable extern_classes_with_init : path list; mutable locals : (string,string) PMap.t; mutable inv_locals : (string,string) PMap.t; mutable local_types : t list; mutable inits : texpr list; mutable constructor_block : bool; mutable all_dynamic_methods: method_name list; mutable dynamic_methods: tclass_field list; mutable is_call : bool; mutable cwd : string; mutable inline_methods : inline_method list; mutable lib_path : string; } let join_class_path path separator = let result = match fst path, snd path with | [], s -> s | el, s -> String.concat separator el ^ separator ^ s in if (String.contains result '+') then begin let idx = String.index result '+' in (String.sub result 0 idx) ^ (String.sub result (idx+1) ((String.length result) - idx -1 ) ) end else result;; (* Get a string to represent a type. The "suffix" will be nothing or "_obj", depending if we want the name of the pointer class or the pointee (_obj class *) let rec class_string klass suffix params = (match klass.cl_path with (* Array class *) | ([],"Array") -> (snd klass.cl_path) ^ suffix ^ "<" ^ (String.concat "," (List.map type_string params) ) ^ " >" | _ when (match klass.cl_kind with KTypeParameter _ -> true | _ -> false) -> "Dynamic" | ([],"#Int") -> "/* # */int" | (["haxe";"io"],"Unsigned_char__") -> "unsigned char" | ([],"Class") -> "Class" | ([],"Null") -> (match params with | [t] -> (match follow t with | TInst ({ cl_path = [],"Int" },_) | TInst ({ cl_path = [],"Float" },_) | TEnum ({ e_path = [],"Bool" },_) -> "Dynamic" | _ -> "/*NULL*/" ^ (type_string t) ) | _ -> assert false); (* Normal class *) | _ -> (join_class_path klass.cl_path "::") ^ suffix ) and type_string_suff suffix haxe_type = (match haxe_type with | TMono r -> (match !r with None -> "Dynamic" | Some t -> type_string_suff suffix t) | TAbstract ({ a_path = [],"Int" },[]) -> "int" | TAbstract ({ a_path = [],"Float" },[]) -> "double" | TAbstract ({ a_path = [],"Bool" },[]) -> "bool" | TAbstract ({ a_path = [],"Void" },[]) -> "Void" | TEnum (enum,params) -> (join_class_path enum.e_path "::") ^ suffix | TInst (klass,params) -> (class_string klass suffix params) | TAbstract (abs,params) -> (join_class_path abs.a_path "::") ^ suffix | TType (type_def,params) -> (match type_def.t_path with | [] , "Null" -> (match params with | [t] -> (match follow t with | TInst ({ cl_path = [],"Int" },_) | TInst ({ cl_path = [],"Float" },_) | TEnum ({ e_path = [],"Bool" },_) -> "Dynamic" | _ -> type_string_suff suffix t) | _ -> assert false); | [] , "Array" -> (match params with | [t] -> "Array<" ^ (type_string (follow t) ) ^ " >" | _ -> assert false) | _ -> type_string_suff suffix (apply_params type_def.t_params params type_def.t_type) ) | TFun (args,haxe_type) -> "Dynamic" | TAnon anon -> "Dynamic" | TDynamic haxe_type -> "Dynamic" | TLazy func -> type_string_suff suffix ((!func)()) ) and type_string haxe_type = type_string_suff "" haxe_type;; let debug_expression expression type_too = "/* " ^ Type.s_expr_kind expression ^ (if (type_too) then " = " ^ (type_string (follow expression.etype)) else "") ^ " */";; let rec register_extern_required_path ctx path = if (List.exists(fun p -> p = path) ctx.extern_classes_with_init) && not (List.exists(fun p -> p = path) ctx.extern_required_paths) then ctx.extern_required_paths <- path :: ctx.extern_required_paths let s_expr_expr = Type.s_expr_kind let s_expr_name e = s_type (print_context()) (follow e.etype) let s_type_name t = s_type (print_context()) t and start_with s test = let len = String.length test in (String.length s > len && String.sub s 0 len = test) let rec is_uncertain_type t = match follow t with | TInst (c, _) -> c.cl_interface | TMono _ -> true | TAnon a -> (match !(a.a_status) with | Statics _ | EnumStatics _ -> false | _ -> true) | TDynamic _ -> true | _ -> false let is_uncertain_expr e = is_uncertain_type e.etype let rec is_anonym_type t = match follow t with | TAnon a -> (match !(a.a_status) with | Statics _ | EnumStatics _ -> false | _ -> true) | TDynamic _ -> true | _ -> false let is_anonym_expr e = is_anonym_type e.etype let rec is_unknown_type t = match follow t with | TMono r -> (match !r with | None -> true | Some t -> is_unknown_type t) | _ -> false let is_unknown_expr e = is_unknown_type e.etype let rec is_string_type t = match follow t with | TInst ({cl_path = ([], "String")}, _) -> true | TAnon a -> (match !(a.a_status) with | Statics ({cl_path = ([], "String")}) -> true | _ -> false) | TAbstract (a,pl) -> is_string_type (Abstract.get_underlying_type a pl) | _ -> false let is_string_expr e = is_string_type e.etype let to_string ctx e = let v = alloc_var "__call__" t_dynamic in let f = mk (TLocal v) t_dynamic e.epos in mk (TCall (f, [ Codegen.string ctx.com "_hx_string_rec" e.epos; e; Codegen.string ctx.com "" e.epos])) ctx.com.basic.tstring e.epos let as_string_expr ctx e = match e.eexpr with | TConst (TNull) -> to_string ctx e | _ when not (is_string_expr e) -> to_string ctx e | _ -> e (* for known String type that could have null value *) let to_string_null ctx e = let v = alloc_var "__call__" t_dynamic in let f = mk (TLocal v) t_dynamic e.epos in mk (TCall (f, [ Codegen.string ctx.com "_hx_string_or_null" e.epos; e])) ctx.com.basic.tstring e.epos let as_string_expr ctx e = match e.eexpr with | TConst (TNull) -> to_string ctx e | TConst (TString s) -> e | TBinop (op,_,_) when (is_string_expr e)-> e | TCall ({eexpr = TField({eexpr = TTypeExpr(TClassDecl {cl_path = ([],"Std")})},FStatic(c,f) )}, [_]) when (f.cf_name="string") -> e | TCall ({eexpr = TLocal _}, [{eexpr = TConst (TString ("_hx_string_rec" | "_hx_str_or_null"))}]) -> e | _ when not (is_string_expr e) -> to_string ctx e | _ -> to_string_null ctx e let spr ctx s = Buffer.add_string ctx.buf s let print ctx = Printf.kprintf (fun s -> Buffer.add_string ctx.buf s) (*--php-prefix - added by skial bainn*) let prefix_class com name = match com.php_prefix with | Some prefix_class (* when not (String.length name <= 2 || String.sub name 0 2 = "__") *) -> prefix_class ^ name | _ -> name let prefix_init_replace com code = let r = Str.regexp "php_Boot" in Str.global_replace r ("php_" ^ (prefix_class com "Boot")) code let s_path ctx path isextern p = if isextern then begin register_extern_required_path ctx path; snd path end else begin (match path with (*--php-prefix*) | ([],"List") -> (prefix_class ctx.com "HList") (*--php-prefix*) | ([],name) -> (prefix_class ctx.com name) | (pack,name) -> (try (match Hashtbl.find ctx.imports name with | [p] when p = pack -> () | packs -> if not (List.mem pack packs) then Hashtbl.replace ctx.imports name (pack :: packs)) with Not_found -> Hashtbl.add ctx.imports name [pack]); (*--php-prefix*) String.concat "_" pack ^ "_" ^ (prefix_class ctx.com name)) end let s_path_haxe path = match fst path, snd path with | [], s -> s | el, s -> String.concat "." el ^ "." ^ s let escape_bin s = let b = Buffer.create 0 in for i = 0 to String.length s - 1 do match Char.code (String.unsafe_get s i) with | c when c = Char.code('\\') || c = Char.code('"') || c = Char.code('$') -> Buffer.add_string b "\\"; Buffer.add_char b (Char.chr c) | c when c < 32 -> Buffer.add_string b (Printf.sprintf "\\x%.2X" c) | c -> Buffer.add_char b (Char.chr c) done; Buffer.contents b (* haxe reserved words that match php ones: break, case, class, continue, default, do, else, extends, for, function, if, new, return, static, switch, var, while, interface, implements, public, private, try, catch, throw *) (* PHP only (for future use): cfunction, old_function *) let is_keyword n = match String.lowercase n with | "and" | "or" | "xor" | "__file__" | "exception" | "__line__" | "array" | "as" | "const" | "declare" | "die" | "echo"| "elseif" | "empty" | "enddeclare" | "endfor" | "endforeach" | "endif" | "endswitch" | "endwhile" | "eval" | "exit" | "foreach"| "global" | "include" | "include_once" | "isset" | "list" | "namespace" | "print" | "require" | "require_once" | "unset" | "use" | "__function__" | "__class__" | "__method__" | "final" | "php_user_filter" | "protected" | "abstract" | "__set" | "__get" | "__call" | "clone" | "instanceof" | "break" | "case" | "class" | "continue" | "default" | "do" | "else" | "extends" | "for" | "function" | "if" | "new" | "return" | "static" | "switch" | "var" | "while" | "interface" | "implements" | "public" | "private" | "try" | "catch" | "throw" -> true | "goto" | _ -> false let s_ident n = let suf = "h" in if (is_keyword n) then (suf ^ n) else n let s_ident_field n = if (is_keyword n) then ("{\"" ^ (escape_bin n) ^ "\"}") else n let s_ident_local n = let suf = "h" in match String.lowercase n with | "globals" | "_server" | "_get" | "_post" | "_cookie" | "_files" | "_env" | "_request" | "_session" -> suf ^ n | _ -> n let create_directory com ldir = let atm_path = ref (String.create 0) in atm_path := com.file; if not (Sys.file_exists com.file) then (Unix.mkdir com.file 0o755); (List.iter (fun p -> atm_path := !atm_path ^ "/" ^ p; if not (Sys.file_exists !atm_path) then (Unix.mkdir !atm_path 0o755);) ldir) let write_resource dir name data = let rdir = dir ^ "/res" in if not (Sys.file_exists dir) then Unix.mkdir dir 0o755; if not (Sys.file_exists rdir) then Unix.mkdir rdir 0o755; let name = Codegen.escape_res_name name false in let ch = open_out_bin (rdir ^ "/" ^ name) in output_string ch data; close_out ch let stack_init com use_add = Codegen.stack_context_init com "GLOBALS['%s']" "GLOBALS['%e']" "__hx__spos" "tmp" use_add null_pos let init com cwd path def_type = let rec create acc = function | [] -> () | d :: l -> let pdir = String.concat "/" (List.rev (d :: acc)) in if not (Sys.file_exists pdir) then Unix.mkdir pdir 0o755; create (d :: acc) l in let dir = if cwd <> "" then com.file :: (cwd :: fst path) else com.file :: fst path; in create [] dir; let filename path = prefix_class com (match path with | [], "List" -> "HList"; | _, s -> s) in (*--php-prefix*) let ch = open_out (String.concat "/" dir ^ "/" ^ (filename path) ^ (if def_type = 0 then ".class" else if def_type = 1 then ".enum" else if def_type = 2 then ".interface" else ".extern") ^ ".php") in let imports = Hashtbl.create 0 in Hashtbl.add imports (snd path) [fst path]; { com = com; stack = stack_init com false; tabs = ""; ch = ch; path = path; buf = Buffer.create (1 lsl 14); in_value = None; in_loop = false; in_instance_method = false; imports = imports; extern_required_paths = []; extern_classes_with_init = []; curclass = null_class; curmethod = ""; locals = PMap.empty; inv_locals = PMap.empty; local_types = []; inits = []; constructor_block = false; dynamic_methods = []; all_dynamic_methods = []; is_call = false; cwd = cwd; inline_methods = []; nested_loops = 0; inline_index = 0; in_block = false; lib_path = match com.php_lib with None -> "lib" | Some s -> s; } let unsupported msg p = error ("This expression cannot be generated to PHP: " ^ msg) p let newline ctx = match Buffer.nth ctx.buf (Buffer.length ctx.buf - 1) with | '{' | ':' | ' ' | '}' when Buffer.nth ctx.buf (Buffer.length ctx.buf - 2) != '"' -> print ctx "\n%s" ctx.tabs | _ -> print ctx ";\n%s" ctx.tabs let rec concat ctx s f = function | [] -> () | [x] -> f x | x :: l -> f x; spr ctx s; concat ctx s f l let open_block ctx = let oldt = ctx.tabs in ctx.tabs <- "\t" ^ ctx.tabs; (fun() -> ctx.tabs <- oldt) let parent e = match e.eexpr with | TParenthesis _ -> e | _ -> mk (TParenthesis e) e.etype e.epos let inc_extern_path ctx path = let rec slashes n = if n = 0 then "" else ("../" ^ slashes (n-1)) in let pre = if ctx.cwd = "" then ctx.lib_path ^ "/" else "" in match path with | ([],name) -> pre ^ (slashes (List.length (fst ctx.path))) ^ (prefix_class ctx.com name) ^ ".extern.php" | (pack,name) -> pre ^ (slashes (List.length (fst ctx.path))) ^ String.concat "/" pack ^ "/" ^ (prefix_class ctx.com name) ^ ".extern.php" let close ctx = output_string ctx.ch " if path <> ctx.path then output_string ctx.ch ("require_once dirname(__FILE__).'/" ^ (inc_extern_path ctx path) ^ "';\n"); ) (List.rev ctx.extern_required_paths); output_string ctx.ch "\n"; output_string ctx.ch (Buffer.contents ctx.buf); close_out ctx.ch let save_locals ctx = let old = ctx.locals in let old_inv = ctx.inv_locals in (fun() -> ctx.locals <- old; ctx.inv_locals <- old_inv) let define_local ctx l = let rec loop n = let name = (if n = 1 then s_ident_local l else s_ident_local (l ^ string_of_int n)) in if PMap.mem name ctx.inv_locals then loop (n+1) else begin ctx.locals <- PMap.add l name ctx.locals; ctx.inv_locals <- PMap.add name l ctx.inv_locals; name end in loop 1 let this ctx = if ctx.in_value <> None then "$__hx__this" else "$this" let gen_constant ctx p = function | TInt i -> print ctx "%ld" i | TFloat s -> spr ctx s | TString s -> print ctx "\"%s\"" (escape_bin s) | TBool b -> spr ctx (if b then "true" else "false") | TNull -> spr ctx "null" | TThis -> spr ctx (this ctx) | TSuper -> spr ctx "ERROR /* unexpected call to super in gen_constant */" let arg_is_opt c = match c with | Some _ -> true | None -> false let s_funarg ctx arg t p o = let byref = if (String.length arg > 7 && String.sub arg 0 7 = "byref__") then "&" else "" in print ctx "%s$%s" byref (s_ident_local arg); if o then spr ctx " = null" (* match c with | _, Some _ -> spr ctx " = null" | _, None -> () *) let is_in_dynamic_methods ctx e s = List.exists (fun dm -> (* TODO: I agree, this is a mess ... but after hours of trials and errors I gave up; maybe in a calmer day *) ((String.concat "." ((fst dm.mpath) @ ["#" ^ (snd dm.mpath)])) ^ "." ^ dm.mname) = (s_type_name e.etype ^ "." ^ s) ) ctx.all_dynamic_methods let is_dynamic_method f = (match f.cf_kind with | Var _ -> true | Method MethDynamic -> true | _ -> false) let fun_block ctx f p = let e = (match f.tf_expr with { eexpr = TBlock [{ eexpr = TBlock _ } as e] } -> e | e -> e) in let e = List.fold_left (fun e (v,c) -> match c with | None | Some TNull -> e | Some c -> Type.concat (Codegen.set_default ctx.com v c p) e ) e f.tf_args in if ctx.com.debug then begin Codegen.stack_block ctx.stack ctx.curclass ctx.curmethod e end else mk_block e let rec gen_array_args ctx lst = match lst with | [] -> () | h :: t -> spr ctx "["; gen_value ctx h; spr ctx "]"; gen_array_args ctx t and gen_call ctx e el = let rec genargs lst = (match lst with | [] -> () | h :: [] -> spr ctx " = "; gen_value ctx h; | h :: t -> spr ctx "["; gen_value ctx h; spr ctx "]"; genargs t) in match e.eexpr , el with | TConst TSuper , params -> (match ctx.curclass.cl_super with | None -> assert false | Some (c,_) -> spr ctx "parent::__construct("; concat ctx "," (gen_value ctx) params; spr ctx ")"; ); | TField ({ eexpr = TConst TSuper },f) , params -> (match ctx.curclass.cl_super with | None -> assert false | Some (c,_) -> print ctx "parent::%s(" (s_ident (field_name f)); concat ctx "," (gen_value ctx) params; spr ctx ")"; ); | TLocal { v_name = "__set__" }, { eexpr = TConst (TString code) } :: el -> print ctx "$%s" code; genargs el; | TLocal { v_name = "__set__" }, e :: el -> gen_value ctx e; genargs el; | TLocal { v_name = "__setfield__" }, e :: (f :: el) -> gen_value ctx e; spr ctx "->{"; gen_value ctx f; spr ctx "}"; genargs el; | TLocal { v_name = "__field__" }, e :: ({ eexpr = TConst (TString code) } :: el) -> gen_value ctx e; spr ctx "->"; spr ctx code; gen_array_args ctx el; | TLocal { v_name = "__field__" }, e :: (f :: el) -> gen_value ctx e; spr ctx "->"; gen_value ctx f; gen_array_args ctx el; | TLocal { v_name = "__prefix__" }, [] -> (match ctx.com.php_prefix with | Some prefix -> print ctx "\"%s\"" prefix | None -> spr ctx "null") | TLocal { v_name = "__var__" }, { eexpr = TConst (TString code) } :: el -> print ctx "$%s" code; gen_array_args ctx el; | TLocal { v_name = "__var__" }, e :: el -> gen_value ctx e; gen_array_args ctx el; | TLocal { v_name = "__call__" }, { eexpr = TConst (TString code) } :: el -> spr ctx code; spr ctx "("; concat ctx ", " (gen_value ctx) el; spr ctx ")"; | TLocal { v_name = "__php__" }, [{ eexpr = TConst (TString code) }] -> (*--php-prefix*) spr ctx (prefix_init_replace ctx.com code) | TLocal { v_name = "__php__" }, { eexpr = TConst (TString code); epos = p } :: tl -> Codegen.interpolate_code ctx.com code tl (spr ctx) (gen_expr ctx) p | TLocal { v_name = "__instanceof__" }, [e1;{ eexpr = TConst (TString t) }] -> gen_value ctx e1; print ctx " instanceof %s" t; | TLocal { v_name = "__physeq__" }, [e1;e2] -> spr ctx "("; gen_value ctx e1; spr ctx " === "; gen_value ctx e2; spr ctx ")" | TLocal _, [] | TFunction _, [] | TCall _, [] | TParenthesis _, [] | TMeta _, [] | TBlock _, [] -> ctx.is_call <- true; spr ctx "call_user_func("; gen_value ctx e; ctx.is_call <- false; spr ctx ")"; | TLocal _, el | TFunction _, el | TCall _, el | TParenthesis _, el | TMeta _, el | TBlock _, el -> ctx.is_call <- true; spr ctx "call_user_func_array("; gen_value ctx e; ctx.is_call <- false; spr ctx ", array("; concat ctx ", " (gen_value ctx) el; spr ctx "))" (* | TCall (x,_), el when (match x.eexpr with | TLocal _ -> false | _ -> true) -> ctx.is_call <- true; spr ctx "call_user_func_array("; gen_value ctx e; ctx.is_call <- false; spr ctx ", array("; concat ctx ", " (gen_value ctx) el; spr ctx "))" *) | _ -> ctx.is_call <- true; gen_value ctx e; ctx.is_call <- false; spr ctx "("; concat ctx ", " (gen_value ctx) el; spr ctx ")"; and could_be_string_var s = s = "length" and gen_uncertain_string_var ctx s e = match s with | "length" -> spr ctx "_hx_len("; gen_value ctx e; spr ctx ")" | _ -> gen_field_access ctx true e s; and gen_string_var ctx s e = match s with | "length" -> spr ctx "strlen("; gen_value ctx e; spr ctx ")" | _ -> unsupported "gen_string_var " e.epos; and gen_string_static_call ctx s e el = match s with | "fromCharCode" -> spr ctx "chr("; concat ctx ", " (gen_value ctx) el; spr ctx ")"; | _ -> unsupported "gen_string_static_call " e.epos; and could_be_string_call s = s = "substr" || s = "substring" || s = "charAt" || s = "charCodeAt" || s = "indexOf" || s = "lastIndexOf" || s = "split" || s = "toLowerCase" || s = "toString" || s = "toUpperCase" and gen_string_call ctx s e el = match s with | "substr" -> spr ctx "_hx_substr("; gen_value ctx e; spr ctx ", "; concat ctx ", " (gen_value ctx) el; spr ctx ")" | "substring" -> spr ctx "_hx_substring("; gen_value ctx e; spr ctx ", "; concat ctx ", " (gen_value ctx) el; spr ctx ")" | "charAt" -> spr ctx "_hx_char_at("; gen_value ctx e; spr ctx ", "; concat ctx ", " (gen_value ctx) el; spr ctx ")" | "cca" -> spr ctx "ord(substr("; gen_value ctx e; spr ctx ","; concat ctx ", " (gen_value ctx) el; spr ctx ",1))" | "charCodeAt" -> spr ctx "_hx_char_code_at("; gen_value ctx e; spr ctx ", "; concat ctx ", " (gen_value ctx) el; spr ctx ")" | "indexOf" -> spr ctx "_hx_index_of("; gen_value ctx e; spr ctx ", "; concat ctx ", " (gen_value ctx) el; spr ctx ")" | "lastIndexOf" -> spr ctx "_hx_last_index_of("; gen_value ctx e; spr ctx ", "; concat ctx ", " (gen_value ctx) el; spr ctx ")" | "split" -> spr ctx "_hx_explode("; concat ctx ", " (gen_value ctx) el; spr ctx ", "; gen_value ctx e; spr ctx ")" | "toLowerCase" -> spr ctx "strtolower("; gen_value ctx e; spr ctx ")" | "toUpperCase" -> spr ctx "strtoupper("; gen_value ctx e; spr ctx ")" | "toString" -> gen_value ctx e; | _ -> unsupported "gen_string_call" e.epos; and gen_uncertain_string_call ctx s e el = spr ctx "_hx_string_call("; gen_value ctx e; print ctx ", \"%s\", array(" s; concat ctx ", " (gen_value ctx) el; spr ctx "))" and gen_field_op ctx e = match e.eexpr with | TField (f,s) -> (match follow e.etype with | TFun _ -> gen_field_access ctx true f (field_name s) | _ -> gen_value_op ctx e) | _ -> gen_value_op ctx e and gen_value_op ctx e = match e.eexpr with | TBinop (op,_,_) when op = Ast.OpAnd || op = Ast.OpOr || op = Ast.OpXor -> gen_value ctx e; | _ -> gen_value ctx e and is_static t = match follow t with | TAnon a -> (match !(a.a_status) with | Statics c -> true | _ -> false) | _ -> false and gen_member_access ctx isvar e s = match follow e.etype with | TAnon a -> (match !(a.a_status) with | EnumStatics _ -> print ctx "::%s%s" (if isvar then "$" else "") (s_ident s) | Statics _ -> print ctx "::%s%s" (if isvar then "$" else "") (s_ident s) | _ -> print ctx "->%s" (if isvar then s_ident_field s else s_ident s)) | _ -> print ctx "->%s" (if isvar then s_ident_field s else s_ident s) and gen_field_access ctx isvar e s = match e.eexpr with | TTypeExpr t -> spr ctx (s_path ctx (t_path t) false e.epos); gen_member_access ctx isvar e s | TLocal _ -> gen_expr ctx e; print ctx "->%s" (if isvar then s_ident_field s else s_ident s) | TArray (e1,e2) -> spr ctx "_hx_array_get("; gen_value ctx e1; spr ctx ", "; gen_value ctx e2; spr ctx ")"; gen_member_access ctx isvar e s | TBlock _ | TParenthesis _ | TMeta _ | TObjectDecl _ | TArrayDecl _ | TNew _ -> spr ctx "_hx_deref("; ctx.is_call <- false; gen_value ctx e; spr ctx ")"; gen_member_access ctx isvar e s | TCast (ec, _) when (match ec.eexpr with | TNew _ | TArrayDecl _ -> true | _ -> false) -> spr ctx "_hx_deref("; ctx.is_call <- false; gen_value ctx e; spr ctx ")"; gen_member_access ctx isvar e s | _ -> gen_expr ctx e; gen_member_access ctx isvar e s and gen_dynamic_function ctx isstatic name f params p = let old = ctx.in_value in let old_l = ctx.locals in let old_li = ctx.inv_locals in let old_t = ctx.local_types in ctx.in_value <- None; ctx.local_types <- List.map snd params @ ctx.local_types; let byref = if (String.length name > 9 && String.sub name 0 9 = "__byref__") then "&" else "" in print ctx "function %s%s(" byref name; concat ctx ", " (fun (v,c) -> let arg = define_local ctx v.v_name in s_funarg ctx arg v.v_type p (arg_is_opt c); ) f.tf_args; spr ctx ") {"; if (List.length f.tf_args) > 0 then begin if isstatic then print ctx " return call_user_func_array(self::$%s, array(" name else print ctx " return call_user_func_array($this->%s, array(" name; concat ctx ", " (fun (v,_) -> spr ctx ("$" ^ v.v_name) ) f.tf_args; print ctx ")); }"; end else if isstatic then print ctx " return call_user_func(self::$%s); }" name else print ctx " return call_user_func($this->%s); }" name; newline ctx; if isstatic then print ctx "public static $%s = null" name else print ctx "public $%s = null" name; ctx.in_value <- old; ctx.locals <- old_l; ctx.inv_locals <- old_li; ctx.local_types <- old_t and gen_function ctx name f params p = let old = ctx.in_value in let old_l = ctx.locals in let old_li = ctx.inv_locals in let old_t = ctx.local_types in ctx.in_value <- None; ctx.local_types <- List.map snd params @ ctx.local_types; let byref = if (String.length name > 9 && String.sub name 0 9 = "__byref__") then "&" else "" in print ctx "function %s%s(" byref name; concat ctx ", " (fun (v,o) -> let arg = define_local ctx v.v_name in s_funarg ctx arg v.v_type p (arg_is_opt o); ) f.tf_args; print ctx ") "; gen_expr ctx (fun_block ctx f p); ctx.in_value <- old; ctx.locals <- old_l; ctx.inv_locals <- old_li; ctx.local_types <- old_t and gen_inline_function ctx f hasthis p = ctx.nested_loops <- ctx.nested_loops - 1; let old = ctx.in_value in let old_l = ctx.locals in let old_li = ctx.inv_locals in let old_t = ctx.local_types in ctx.in_value <- Some "closure"; let args a = List.map (fun (v,_) -> v.v_name) a in let arguments = ref [] in if hasthis then begin arguments := "this" :: !arguments end; PMap.iter (fun n _ -> arguments := !arguments @ [n]) old_li; spr ctx "array(new _hx_lambda(array("; let c = ref 0 in List.iter (fun a -> if !c > 0 then spr ctx ", "; incr c; print ctx "&$%s" a; ) (remove_internals !arguments); spr ctx "), \""; spr ctx (inline_function ctx (args f.tf_args) hasthis (fun_block ctx f p)); print ctx "\"), 'execute')"; ctx.in_value <- old; ctx.locals <- old_l; ctx.inv_locals <- old_li; ctx.local_types <- old_t; ctx.nested_loops <- ctx.nested_loops + 1; and unset_locals ctx old_l = let lst = ref [] in PMap.iter (fun n _ -> if not (PMap.exists n old_l) then lst := ["$" ^ n] @ !lst; ) ctx.inv_locals; if (List.length !lst) > 0 then begin newline ctx; spr ctx "unset("; concat ctx "," (fun (s) -> spr ctx s; ) !lst; spr ctx ")" end and gen_while_expr ctx e = let old_loop = ctx.in_loop in ctx.in_loop <- true; let old_nested_loops = ctx.nested_loops in ctx.nested_loops <- 1; let old_l = ctx.inv_locals in let b = save_locals ctx in (match e.eexpr with | TBlock (el) -> List.iter (fun e -> newline ctx; gen_expr ctx e) el; | _ -> newline ctx; gen_expr ctx e); unset_locals ctx old_l; b(); ctx.nested_loops <- old_nested_loops; ctx.in_loop <- old_loop and gen_tfield ctx e e1 s = match follow e.etype with | TFun (args, _) -> (if ctx.is_call then begin gen_field_access ctx false e1 s end else if is_in_dynamic_methods ctx e1 s then begin gen_field_access ctx true e1 s; end else begin let ob ex = (match ex with | TTypeExpr t -> print ctx "\""; spr ctx (s_path ctx (t_path t) false e1.epos); print ctx "\"" | _ -> gen_expr ctx e1) in spr ctx "(isset("; gen_field_access ctx true e1 s; spr ctx ") ? "; gen_field_access ctx true e1 s; spr ctx ": array("; ob e1.eexpr; print ctx ", \"%s\"))" (s_ident s); end) | TMono _ -> if ctx.is_call then gen_field_access ctx false e1 s else gen_uncertain_string_var ctx s e1 | _ -> if is_string_expr e1 then gen_string_var ctx s e1 else if is_uncertain_expr e1 then gen_uncertain_string_var ctx s e1 else gen_field_access ctx true e1 s and gen_expr ctx e = let in_block = ctx.in_block in ctx.in_block <- false; let restore_in_block ctx inb = if inb then ctx.in_block <- true in match e.eexpr with | TConst c -> gen_constant ctx e.epos c | TLocal v -> spr ctx ("$" ^ (try PMap.find v.v_name ctx.locals with Not_found -> (s_ident_local v.v_name))) | TArray (e1,e2) -> (match e1.eexpr with | TCall _ | TBlock _ | TParenthesis _ | TMeta _ | TArrayDecl _ -> spr ctx "_hx_array_get("; gen_value ctx e1; spr ctx ", "; gen_value ctx e2; spr ctx ")"; | TCast (ec, _) when (match ec.eexpr with | TArrayDecl _ | TBlock _ -> true | _ -> false) -> spr ctx "_hx_array_get("; gen_value ctx e1; spr ctx ", "; gen_value ctx e2; spr ctx ")"; | _ -> gen_value ctx e1; spr ctx "["; gen_value ctx e2; spr ctx "]"); | TBinop (op,e1,e2) -> (* these operators are non-assoc in php, let let's make sure to separate them with parenthesises *) let non_assoc = function | (Ast.OpEq | Ast.OpNotEq | Ast.OpGt | Ast.OpGte | Ast.OpLt | Ast.OpLte) -> true | _ -> false in (match e1.eexpr with | TBinop (op2,_,_) when non_assoc op && non_assoc op2 -> gen_expr ctx { e with eexpr = TBinop (op,mk (TParenthesis e1) e1.etype e1.epos,e2) } | _ -> let leftside e = (match e.eexpr with | TArray(te1, te2) -> gen_value ctx te1; spr ctx "->a["; gen_value ctx te2; spr ctx "]"; | _ -> gen_field_op ctx e1;) in let leftsidec e = (match e.eexpr with | TArray(te1, te2) -> gen_value ctx te1; spr ctx "->a["; gen_value ctx te2; spr ctx "]"; | TField (e1,s) -> gen_field_access ctx true e1 (field_name s) | _ -> gen_field_op ctx e1;) in let leftsidef e = (match e.eexpr with | TField (e1,s) -> gen_field_access ctx true e1 (field_name s) | _ -> gen_field_op ctx e1; ) in (match op with | Ast.OpMod -> spr ctx "_hx_mod("; gen_value_op ctx e1; spr ctx ", "; gen_value_op ctx e2; spr ctx ")"; | Ast.OpAssign -> (match e1.eexpr with | TArray(te1, te2) when (match te1.eexpr with | TCall _ | TParenthesis _ -> true | _ -> false) -> spr ctx "_hx_array_assign("; gen_value ctx te1; spr ctx ", "; gen_value ctx te2; spr ctx ", "; gen_value_op ctx e2; spr ctx ")"; | _ -> leftsidef e1; spr ctx " = "; gen_value_op ctx e2; ) | Ast.OpAssignOp(Ast.OpAdd) when (is_uncertain_expr e1 && is_uncertain_expr e2) -> (match e1.eexpr with | TArray(te1, te2) -> let t1 = define_local ctx "__hx__t1" in let t2 = define_local ctx "__hx__t2" in print ctx "_hx_array_assign($%s = " t1; gen_value ctx te1; print ctx ", $%s = " t2; gen_value ctx te2; print ctx ", $%s->a[$%s] + " t1 t2; gen_value_op ctx e2; spr ctx ")"; | _ -> leftside e1; spr ctx " = "; spr ctx "_hx_add("; gen_value_op ctx e1; spr ctx ", "; gen_value_op ctx e2; spr ctx ")"; ) | Ast.OpAssignOp(Ast.OpAdd) when (is_string_expr e1 || is_string_expr e2) -> leftside e1; spr ctx " .= "; gen_value_op ctx (as_string_expr ctx e2); | Ast.OpAssignOp(Ast.OpShl) -> leftside e1; spr ctx " <<= "; gen_value_op ctx e2; | Ast.OpAssignOp(Ast.OpUShr) -> leftside e1; spr ctx " = "; spr ctx "_hx_shift_right("; gen_value_op ctx e1; spr ctx ", "; gen_value_op ctx e2; spr ctx ")"; | Ast.OpAssignOp(Ast.OpMod) -> leftside e1; spr ctx " = "; spr ctx "_hx_mod("; gen_value_op ctx e1; spr ctx ", "; gen_value_op ctx e2; spr ctx ")"; | Ast.OpAssignOp(_) -> leftsidec e1; print ctx " %s " (Ast.s_binop op); gen_value_op ctx e2; | Ast.OpAdd when (is_uncertain_expr e1 && is_uncertain_expr e2) -> spr ctx "_hx_add("; gen_value_op ctx e1; spr ctx ", "; gen_value_op ctx e2; spr ctx ")"; | Ast.OpAdd when (is_string_expr e1 || is_string_expr e2) -> gen_value_op ctx (as_string_expr ctx e1); spr ctx " . "; gen_value_op ctx (as_string_expr ctx e2); | Ast.OpShl -> gen_value_op ctx e1; spr ctx " << "; gen_value_op ctx e2; | Ast.OpUShr -> spr ctx "_hx_shift_right("; gen_value_op ctx e1; spr ctx ", "; gen_value_op ctx e2; spr ctx ")"; | Ast.OpNotEq | Ast.OpEq -> let s_op = if op = Ast.OpNotEq then " != " else " == " in let s_phop = if op = Ast.OpNotEq then " !== " else " === " in let se1 = s_expr_name e1 in let se2 = s_expr_name e2 in if e1.eexpr = TConst (TNull) || e2.eexpr = TConst (TNull) then begin (match e1.eexpr with | TField (f, s) when is_anonym_expr e1 || is_unknown_expr e1 -> spr ctx "_hx_field("; gen_value ctx f; print ctx ", \"%s\")" (field_name s); | _ -> gen_field_op ctx e1; ); spr ctx s_phop; (match e2.eexpr with | TField (f, s) when is_anonym_expr e2 || is_unknown_expr e2 -> spr ctx "_hx_field("; gen_value ctx f; print ctx ", \"%s\")" (field_name s); | _ -> gen_field_op ctx e2); end else if ((se1 = "Int" || se1 = "Null") && (se2 = "Int" || se2 = "Null")) || ((se1 = "Float" || se1 = "Null") && (se2 = "Float" || se2 = "Null")) then begin gen_field_op ctx e1; spr ctx s_phop; gen_field_op ctx e2; end else if ((se1 = "Int" || se1 = "Float" || se1 = "Null" || se1 = "Null") && (se1 = "Int" || se1 = "Float" || se1 = "Null" || se1 = "Null")) || (is_unknown_expr e1 && is_unknown_expr e2) || is_anonym_expr e1 || is_anonym_expr e2 then begin if op = Ast.OpNotEq then spr ctx "!"; spr ctx "_hx_equal("; gen_field_op ctx e1; spr ctx ", "; gen_field_op ctx e2; spr ctx ")"; end else if ( se1 == se2 || (match e1.eexpr with | TConst _ | TLocal _ | TArray _ | TNew _ -> true | _ -> false) || (match e2.eexpr with | TConst _ | TLocal _ | TArray _ | TNew _ -> true | _ -> false) || is_string_expr e1 || is_string_expr e2 || is_anonym_expr e1 || is_anonym_expr e2 || is_unknown_expr e1 || is_unknown_expr e2 ) && (type_string (follow e1.etype)) <> "Dynamic" && (type_string (follow e2.etype)) <> "Dynamic" then begin gen_field_op ctx e1; spr ctx s_phop; gen_field_op ctx e2; end else begin let tmp = define_local ctx "_t" in print ctx "(is_object($%s = " tmp; gen_field_op ctx e1; print ctx ") && !($%s instanceof Enum) ? $%s%s" tmp tmp s_phop; gen_field_op ctx e2; print ctx " : $%s%s" tmp s_op; gen_field_op ctx e2; spr ctx ")"; end | Ast.OpGt | Ast.OpGte | Ast.OpLt | Ast.OpLte when is_string_expr e1 -> spr ctx "(strcmp("; gen_field_op ctx e1; spr ctx ", "; gen_field_op ctx e2; spr ctx ")"; let op_str = match op with | Ast.OpGt -> ">" | Ast.OpGte -> ">=" | Ast.OpLt -> "<" | Ast.OpLte -> "<=" | _ -> assert false in print ctx "%s 0)" op_str | _ -> leftside e1; print ctx " %s " (Ast.s_binop op); gen_value_op ctx e2; )); | TEnumParameter(e1,_,i) -> spr ctx "_hx_deref("; gen_value ctx e1; spr ctx ")"; print ctx "->params[%d]" i; | TField (e1,s) -> gen_tfield ctx e e1 (field_name s) | TTypeExpr t -> print ctx "_hx_qtype(\"%s\")" (s_path_haxe (t_path t)) | TParenthesis e -> (match e.eexpr with | TParenthesis _ | TReturn _ -> gen_value ctx e; | _ -> spr ctx "("; gen_value ctx e; spr ctx ")" ); | TMeta (_,e) -> gen_expr ctx e | TReturn eo -> (match eo with | None -> spr ctx "return" | Some e when (match follow e.etype with TEnum({ e_path = [],"Void" },[]) | TAbstract ({ a_path = [],"Void" },[]) -> true | _ -> false) -> gen_value ctx e; newline ctx; spr ctx "return" | Some e -> (match e.eexpr with | TThrow _ -> () | _ -> spr ctx "return "); gen_value ctx e; ); | TBreak -> if ctx.in_loop then spr ctx "break" else print ctx "break %d" ctx.nested_loops | TContinue -> if ctx.in_loop then spr ctx "continue" else print ctx "continue %d" ctx.nested_loops | TBlock [] -> spr ctx "{}" | TBlock el -> let old_l = ctx.inv_locals in let b = save_locals ctx in print ctx "{"; let bend = open_block ctx in let cb = ( if not ctx.constructor_block then (fun () -> ()) else begin ctx.constructor_block <- false; if List.length ctx.dynamic_methods > 0 then newline ctx else spr ctx " "; List.iter (fun (f) -> let name = f.cf_name in match f.cf_expr with | Some { eexpr = TFunction fd } -> print ctx "if(!isset($this->%s)) $this->%s = " name name; gen_inline_function ctx fd true e.epos; newline ctx; | _ -> () ) ctx.dynamic_methods; if Codegen.constructor_side_effects e then begin print ctx "if(!%s::$skip_constructor) {" (s_path ctx (["php"],"Boot") false e.epos); (fun() -> print ctx "}") end else (fun() -> ()); end) in let remaining = ref (List.length el) in let build e = newline ctx; if (in_block && !remaining = 1) then begin (match e.eexpr with | TIf _ | TSwitch _ | TThrow _ | TWhile _ | TFor _ | TTry _ | TBreak | TBlock _ -> restore_in_block ctx in_block; gen_expr ctx e; unset_locals ctx old_l; | TReturn (Some e1) -> (match e1.eexpr with | TIf _ | TSwitch _ | TThrow _ | TWhile _ | TFor _ | TTry _ | TBlock _ -> () | _ -> spr ctx "return " ); gen_expr ctx e1; | _ -> spr ctx "return "; gen_value ctx e; ) end else begin gen_expr ctx e; end; decr remaining; in List.iter build el; if ctx.in_loop then begin unset_locals ctx old_l; end; bend(); newline ctx; cb(); print ctx "}"; b(); | TFunction f -> let old = ctx.in_value, ctx.in_loop in let old_meth = ctx.curmethod in ctx.in_value <- None; ctx.in_loop <- false; ctx.curmethod <- ctx.curmethod ^ "@" ^ string_of_int (Lexer.get_error_line e.epos); gen_inline_function ctx f false e.epos; ctx.curmethod <- old_meth; ctx.in_value <- fst old; ctx.in_loop <- snd old; | TCall (ec,el) -> (match ec.eexpr with | TArray _ -> spr ctx "call_user_func_array("; gen_value ctx ec; spr ctx ", array("; concat ctx ", " (gen_value ctx) el; spr ctx "))"; | TField (ef,s) when is_static ef.etype && is_string_expr ef -> gen_string_static_call ctx (field_name s) ef el | TField (ef,s) when is_string_expr ef -> gen_string_call ctx (field_name s) ef el | TField (ef,s) when is_anonym_expr ef && could_be_string_call (field_name s) -> gen_uncertain_string_call ctx (field_name s) ef el | _ -> gen_call ctx ec el); | TArrayDecl el -> spr ctx "(new _hx_array(array("; concat ctx ", " (gen_value ctx) el; spr ctx ")))"; | TThrow e -> spr ctx "throw new HException("; gen_value ctx e; spr ctx ")"; | TVar (v,eo) -> spr ctx "$"; let restore = save_locals ctx in let n = define_local ctx v.v_name in let restore2 = save_locals ctx in restore(); (match eo with | None -> print ctx "%s = null" (s_ident_local n) | Some e -> print ctx "%s = " (s_ident_local n); gen_value ctx e); restore2() | TNew (c,_,el) -> (match c.cl_path, el with | ([], "String"), _ -> concat ctx "" (gen_value ctx) el | ([], "Array"), el -> spr ctx "new _hx_array(array("; concat ctx ", " (gen_value ctx) el; spr ctx "))" | (_, _), _ -> print ctx "new %s(" (s_path ctx c.cl_path c.cl_extern e.epos); let count = ref (-1) in concat ctx ", " (fun e -> incr count; match c.cl_constructor with | Some f -> gen_value ctx e; | _ -> (); ) el; spr ctx ")") | TIf (cond,e,eelse) -> spr ctx "if"; gen_value ctx (parent cond); spr ctx " "; restore_in_block ctx in_block; gen_expr ctx (mk_block e); (match eelse with | None -> () | Some e when e.eexpr = TConst(TNull) -> () | Some e -> spr ctx " else "; restore_in_block ctx in_block; gen_expr ctx (mk_block e)); | TUnop (op,Ast.Prefix,e) -> (match e.eexpr with | TArray(te1, te2) -> (match op with | Increment -> spr ctx "_hx_array_increment("; gen_value ctx te1; spr ctx ","; gen_value ctx te2; spr ctx ")"; | Decrement -> spr ctx "_hx_array_decrement("; gen_value ctx te1; spr ctx ","; gen_value ctx te2; spr ctx ")"; | _ -> spr ctx (Ast.s_unop op); gen_value ctx te1; spr ctx "["; gen_value ctx te2; spr ctx "]"; ); | TField (e1,s) -> spr ctx (Ast.s_unop op); gen_tfield ctx e e1 (field_name s) | _ -> spr ctx (Ast.s_unop op); gen_value ctx e) | TUnop (op,Ast.Postfix,e) -> (match e.eexpr with | TArray(te1, te2) -> gen_value ctx te1; spr ctx "->a["; gen_value ctx te2; spr ctx "]"; | TField (e1,s) -> gen_field_access ctx true e1 (field_name s) | _ -> gen_value ctx e); spr ctx (Ast.s_unop op) | TWhile (cond,e,Ast.NormalWhile) -> let old = save_locals ctx in spr ctx "while"; gen_value ctx (parent cond); spr ctx " {"; let bend = open_block ctx in gen_while_expr ctx e; bend(); newline ctx; spr ctx "}"; old() | TWhile (cond,e,Ast.DoWhile) -> let old = save_locals ctx in spr ctx "do {"; let bend = open_block ctx in gen_while_expr ctx e; bend(); newline ctx; spr ctx "} while"; gen_value ctx (parent cond); old() | TObjectDecl fields -> spr ctx "_hx_anonymous(array("; concat ctx ", " (fun (f,e) -> print ctx "\"%s\" => " (escape_bin f); gen_value ctx e) fields; spr ctx "))" | TFor (v,it,e) -> let b = save_locals ctx in let tmp = define_local ctx "__hx__it" in let v = define_local ctx v.v_name in (match it.eexpr with | TCall (e,_) -> (match e.eexpr with | TField (e,f) -> spr ctx "if(null == "; gen_value ctx e; spr ctx ") throw new HException('null iterable')"; newline ctx; | _ -> ()); | _ -> () ); print ctx "$%s = " tmp; gen_value ctx it; newline ctx; print ctx "while($%s->hasNext()) {" tmp; let bend = open_block ctx in newline ctx; (* unset loop variable (issue #2900) *) print ctx "unset($%s)" v; newline ctx; print ctx "$%s = $%s->next()" v tmp; gen_while_expr ctx e; bend(); newline ctx; spr ctx "}"; b(); | TTry (e,catchs) -> spr ctx "try "; restore_in_block ctx in_block; gen_expr ctx (mk_block e); let old = save_locals ctx in let ex = define_local ctx "__hx__e" in print ctx "catch(Exception $%s) {" ex; let bend = open_block ctx in let first = ref true in let catchall = ref false in let evar = define_local ctx "_ex_" in newline ctx; print ctx "$%s = ($%s instanceof HException) ? $%s->e : $%s" evar ex ex ex; old(); List.iter (fun (v,e) -> let ev = define_local ctx v.v_name in newline ctx; let b = save_locals ctx in if not !first then spr ctx "else "; (match follow v.v_type with | TEnum (te,_) -> (match te.e_path with | [], "Bool" -> print ctx "if(is_bool($%s = $%s))" ev evar | _ -> print ctx "if(($%s = $%s) instanceof %s)" ev evar (s_path ctx te.e_path te.e_extern e.epos)); restore_in_block ctx in_block; gen_expr ctx (mk_block e); | TInst (tc,_) -> (match tc.cl_path with | [], "Int" -> print ctx "if(is_int($%s = $%s))" ev evar | [], "Float" -> print ctx "if(is_numeric($%s = $%s))" ev evar | [], "String" -> print ctx "if(is_string($%s = $%s))" ev evar | [], "Array" -> print ctx "if(($%s = $%s) instanceof _hx_array)" ev evar | _ -> print ctx "if(($%s = $%s) instanceof %s)" ev evar (s_path ctx tc.cl_path tc.cl_extern e.epos)); restore_in_block ctx in_block; gen_expr ctx (mk_block e); | TAbstract (ta,_) -> (match ta.a_path with | [], "Int" -> print ctx "if(is_int($%s = $%s))" ev evar | [], "Float" -> print ctx "if(is_numeric($%s = $%s))" ev evar | [], "Bool" -> print ctx "if(is_bool($%s = $%s))" ev evar | _ -> print ctx "if(($%s = $%s) instanceof %s)" ev evar (s_path ctx ta.a_path false e.epos)); restore_in_block ctx in_block; gen_expr ctx (mk_block e); | TFun _ | TLazy _ | TType _ | TAnon _ -> assert false | TMono _ | TDynamic _ -> catchall := true; if not !first then spr ctx "{ "; print ctx "$%s = $%s" ev evar; newline ctx; restore_in_block ctx in_block; gen_expr ctx (mk_block e); if not !first then spr ctx "}" ); b(); first := false; ) catchs; if not !catchall then print ctx " else throw $%s;" ex; bend(); newline ctx; spr ctx "}" | TSwitch (e,cases,def) -> let old_loop = ctx.in_loop in ctx.in_loop <- false; ctx.nested_loops <- ctx.nested_loops + 1; let old = save_locals ctx in spr ctx "switch"; gen_value ctx (parent e); spr ctx " {"; newline ctx; List.iter (fun (el,e2) -> List.iter (fun e -> spr ctx "case "; gen_value ctx e; spr ctx ":"; ) el; restore_in_block ctx in_block; gen_expr ctx (mk_block e2); print ctx "break"; newline ctx; ) cases; (match def with | None -> () | Some e -> spr ctx "default:"; restore_in_block ctx in_block; gen_expr ctx (mk_block e); print ctx "break"; newline ctx; ); spr ctx "}"; ctx.nested_loops <- ctx.nested_loops - 1; ctx.in_loop <- old_loop; old() | TCast (e,None) -> gen_expr ctx e | TCast (e1,Some t) -> let mk_texpr = function | TClassDecl c -> TAnon { a_fields = PMap.empty; a_status = ref (Statics c) } | TEnumDecl e -> TAnon { a_fields = PMap.empty; a_status = ref (EnumStatics e) } | TAbstractDecl a -> TAnon { a_fields = PMap.empty; a_status = ref (AbstractStatics a) } | TTypeDecl _ -> assert false in spr ctx "_hx_cast("; gen_expr ctx e1; spr ctx ", "; gen_expr ctx (mk (TTypeExpr t) (mk_texpr t) e1.epos); spr ctx ")" and argument_list_from_locals include_this in_var l = let lst = ref [] in if (include_this && in_var) then lst := "__hx__this" :: !lst else if include_this then lst := "this" :: !lst; PMap.iter (fun n _ -> lst := !lst @ [n]; ) l; !lst and remove_internals args = List.filter (fun a -> a = "__hx__this" || not (start_with a "__hx__")) args; and inline_block ctx e = let index = ctx.inline_index in ctx.inline_index <- ctx.inline_index + 1; let block = { iname = (s_path ctx ctx.curclass.cl_path ctx.curclass.cl_extern ctx.curclass.cl_pos) ^ "_" ^ string_of_int index; iindex = index; ihasthis = ctx.in_instance_method; (* param this *) iarguments = []; iexpr = e; ilocals = ctx.locals; iin_block = true; iinv_locals = ctx.inv_locals; } in print ctx "%s(" block.iname; let in_value = (match ctx.in_value with Some _ -> true | _ -> false) in (match remove_internals (argument_list_from_locals ctx.in_instance_method in_value ctx.locals) with | [] -> () | l -> print ctx "$%s" (String.concat ", $" l) ); spr ctx ")"; ctx.inline_methods <- ctx.inline_methods @ [block] and inline_function ctx args hasthis e = let index = ctx.inline_index in ctx.inline_index <- ctx.inline_index + 1; let block = { iname = (s_path ctx ctx.curclass.cl_path ctx.curclass.cl_extern ctx.curclass.cl_pos) ^ "_" ^ string_of_int index; iindex = index; ihasthis = hasthis; (* param this *) iarguments = args; iexpr = e; ilocals = ctx.locals; iin_block = false; iinv_locals = ctx.inv_locals; } in ctx.inline_methods <- ctx.inline_methods @ [block]; block.iname and canbe_ternary_param e = match e.eexpr with | TTypeExpr _ | TConst _ | TLocal _ | TField (_,FEnum _) | TParenthesis _ | TMeta _ | TObjectDecl _ | TArrayDecl _ | TCall _ | TUnop _ | TNew _ | TCast (_, _) | TBlock [_] -> true | TIf (_,e,eelse) -> cangen_ternary e eelse | _ -> false and cangen_ternary e eelse = match eelse with | Some other -> (canbe_ternary_param e) && (canbe_ternary_param other) | _ -> false and gen_value ctx e = match e.eexpr with | TTypeExpr _ | TConst _ | TLocal _ | TArray _ | TBinop _ | TEnumParameter _ | TField _ | TParenthesis _ | TObjectDecl _ | TArrayDecl _ | TCall _ | TUnop _ | TNew _ | TFunction _ -> gen_expr ctx e | TMeta (_,e1) -> gen_value ctx e1 | TBlock [] -> () | TCast (e, _) | TBlock [e] -> gen_value ctx e | TIf (cond,e,eelse) when (cangen_ternary e eelse) -> spr ctx "("; gen_value ctx cond; spr ctx " ? "; gen_value ctx e; (match eelse with | Some e -> spr ctx " : "; gen_value ctx e | _ ->()); spr ctx ")"; (* | TIf (cond,e,eelse) -> spr ctx "if"; gen_value ctx (parent cond); spr ctx " "; restore_in_block ctx in_block; gen_expr ctx (mk_block e); (match eelse with | None -> () | Some e when e.eexpr = TConst(TNull) -> () | Some e -> spr ctx " else "; restore_in_block ctx in_block; gen_expr ctx (mk_block e)); *) | TBlock _ | TBreak | TContinue | TVar _ | TReturn _ | TWhile _ | TThrow _ | TSwitch _ | TFor _ | TIf _ | TTry _ -> inline_block ctx e let rec is_instance_method_defined cls m = if PMap.exists m cls.cl_fields then true else match cls.cl_super with | Some (scls, _) -> is_instance_method_defined scls m | None -> false let is_method_defined ctx m static = if static then PMap.exists m ctx.curclass.cl_statics else is_instance_method_defined ctx.curclass m let generate_self_method ctx rights m static setter = if setter then ( if static then print ctx "%s function %s($v) { return call_user_func(self::$%s, $v); }" rights (s_ident m) (s_ident m) else print ctx "%s function %s($v) { return call_user_func($this->%s, $v); }" rights (s_ident m) (s_ident m) ) else ( if static then print ctx "%s function %s() { return call_user_func(self::$%s); }" rights (s_ident m) (s_ident m) else print ctx "%s function %s() { return call_user_func($this->%s); }" rights (s_ident m) (s_ident m) ); newline ctx let gen_assigned_value ctx eo = match eo with | Some ({eexpr = TConst _} as e) -> print ctx " = "; gen_value ctx e | _ -> () let generate_field ctx static f = if not (is_extern_field f) then newline ctx; ctx.locals <- PMap.empty; ctx.inv_locals <- PMap.empty; ctx.in_instance_method <- not static; let rights = if static then "static" else "public" in let p = ctx.curclass.cl_pos in match f.cf_expr with | Some { eexpr = TFunction fd } -> if f.cf_name = "__construct" then ctx.curmethod <- "new" else ctx.curmethod <- f.cf_name; spr ctx (rights ^ " "); if is_dynamic_method f then gen_dynamic_function ctx static (s_ident f.cf_name) fd f.cf_params p else gen_function ctx (s_ident f.cf_name) fd f.cf_params p | _ -> if (is_extern_field f) then () else if ctx.curclass.cl_interface then match follow f.cf_type, f.cf_kind with | TFun (args,r), Method _ -> print ctx "function %s(" (s_ident f.cf_name); concat ctx ", " (fun (arg,o,t) -> s_funarg ctx arg t p o; ) args; print ctx ")"; | _ -> spr ctx "//"; () else if (match f.cf_kind with | Var v -> (match v.v_read, v.v_write with | AccCall, AccCall -> let m1 = "get_" ^ f.cf_name in let m2 = "set_" ^ f.cf_name in if not (is_method_defined ctx m1 static) then ( generate_self_method ctx rights m1 static false; print ctx "%s $%s" rights (s_ident m1); if not (is_method_defined ctx m2 static) then newline ctx); if not (is_method_defined ctx m2 static) then ( generate_self_method ctx rights m2 static true; print ctx "%s $%s" rights (s_ident m2); newline ctx); false | AccCall, _ -> let m = "get_" ^ f.cf_name in if not (is_method_defined ctx m static) then generate_self_method ctx rights m static false; print ctx "%s $%s" rights (s_ident_field f.cf_name); gen_assigned_value ctx f.cf_expr; true | _, AccCall -> let m = "set_" ^ f.cf_name in if not (is_method_defined ctx m static) then generate_self_method ctx rights m static true; print ctx "%s $%s" rights (s_ident_field f.cf_name); gen_assigned_value ctx f.cf_expr; true | _ -> false) | _ -> false) then () else begin let name = if static then s_ident f.cf_name else f.cf_name in if static then (match f.cf_kind with | Var _ -> (match follow f.cf_type with | TFun _ | TDynamic _ -> print ctx "static function %s() { $args = func_get_args(); return call_user_func_array(self::$%s, $args); }" name name; newline ctx; | _ -> () ) | _ -> () ); print ctx "%s $%s" rights name; gen_assigned_value ctx f.cf_expr end let generate_static_field_assign ctx path f = let p = ctx.curclass.cl_pos in if not ctx.curclass.cl_interface then (match f.cf_expr with | None -> () | Some e -> match e.eexpr with | TConst _ -> () | TFunction fd -> (match f.cf_kind with | Var _ when (match follow f.cf_type with | TFun _ | TDynamic _ -> true; | _ -> false) -> newline ctx; print ctx "%s::$%s = " (s_path ctx path false p) (s_ident f.cf_name); gen_value ctx e | Method MethDynamic -> newline ctx; print ctx "%s::$%s = " (s_path ctx path false p) (s_ident f.cf_name); gen_value ctx e | _ -> ()) | _ when is_extern_field f -> () | _ -> newline ctx; print ctx "%s::$%s = " (s_path ctx path false p) (s_ident f.cf_name); gen_value ctx e) let rec super_has_dynamic c = match c.cl_super with | None -> false | Some (csup, _) -> (match csup.cl_dynamic with | Some _ -> true | _ -> super_has_dynamic csup) let generate_inline_method ctx c m = (match ctx.inline_methods with | [] -> () | h :: t -> ctx.inline_methods <- t ); ctx.curclass <- c; let old = save_locals ctx in ctx.in_value <- Some m.iname; ctx.in_block <- m.iin_block; ctx.in_loop <- false; ctx.locals <- m.ilocals; ctx.inv_locals <- m.iinv_locals; newline ctx; print ctx "function %s(" m.iname; (* arguments *) let in_value = (match ctx.in_value with Some _ -> true | _ -> false) in let arguments = remove_internals (argument_list_from_locals m.ihasthis in_value ctx.locals) in let arguments = match arguments with | [h] when h = "this" -> ["__hx__this"] | h :: t when h = "this" -> "__hx__this" :: t | _ -> arguments in let marguments = List.map (define_local ctx) m.iarguments in let arguments = (List.map (fun a -> "&$" ^ a) arguments) @ (List.map (fun a -> "$" ^ a) marguments) in (match arguments with | [] -> () | l -> spr ctx (String.concat ", " arguments) ); spr ctx ") {"; ctx.nested_loops <- ctx.nested_loops - 1; let block = open_block ctx in newline ctx; gen_expr ctx m.iexpr; block(); old(); ctx.nested_loops <- ctx.nested_loops + 1; newline ctx; spr ctx "}" let generate_class ctx c = let requires_constructor = ref true in ctx.curclass <- c; ctx.local_types <- List.map snd c.cl_params; print ctx "%s %s " (if c.cl_interface then "interface" else "class") (s_path ctx c.cl_path c.cl_extern c.cl_pos); (match c.cl_super with | None -> () | Some (csup,_) -> requires_constructor := false; print ctx "extends %s " (s_path ctx csup.cl_path csup.cl_extern c.cl_pos)); let implements = ExtList.List.unique ~cmp:(fun a b -> (fst a).cl_path = (fst b).cl_path) c.cl_implements in (match implements with | [] -> () | l -> spr ctx (if c.cl_interface then "extends " else "implements "); concat ctx ", " (fun (i,_) -> print ctx "%s" (s_path ctx i.cl_path i.cl_extern c.cl_pos)) l); spr ctx "{"; let get_dynamic_methods = List.filter is_dynamic_method c.cl_ordered_fields in if not ctx.curclass.cl_interface then ctx.dynamic_methods <- get_dynamic_methods; let cl = open_block ctx in (match c.cl_constructor with | None -> if !requires_constructor && not c.cl_interface then begin newline ctx; spr ctx "public function __construct(){}" end; | Some f -> let f = { f with cf_name = "__construct"; cf_public = true; } in ctx.constructor_block <- true; generate_field ctx false f; ); List.iter (generate_field ctx false) c.cl_ordered_fields; (match c.cl_dynamic with | Some _ when not c.cl_interface && not (super_has_dynamic c) -> newline ctx; spr ctx "public $__dynamics = array();\n\tpublic function __get($n) {\n\t\tif(isset($this->__dynamics[$n]))\n\t\t\treturn $this->__dynamics[$n];\n\t}\n\tpublic function __set($n, $v) {\n\t\t$this->__dynamics[$n] = $v;\n\t}\n\tpublic function __call($n, $a) {\n\t\tif(isset($this->__dynamics[$n]) && is_callable($this->__dynamics[$n]))\n\t\t\treturn call_user_func_array($this->__dynamics[$n], $a);\n\t\tif('toString' == $n)\n\t\t\treturn $this->__toString();\n\t\tthrow new HException(\"Unable to call <\".$n.\">\");\n\t}" | Some _ | _ -> if List.length ctx.dynamic_methods > 0 then begin newline ctx; spr ctx "public function __call($m, $a) {\n\t\tif(isset($this->$m) && is_callable($this->$m))\n\t\t\treturn call_user_func_array($this->$m, $a);\n\t\telse if(isset($this->__dynamics[$m]) && is_callable($this->__dynamics[$m]))\n\t\t\treturn call_user_func_array($this->__dynamics[$m], $a);\n\t\telse if('toString' == $m)\n\t\t\treturn $this->__toString();\n\t\telse\n\t\t\tthrow new HException('Unable to call <'.$m.'>');\n\t}"; end; ); List.iter (generate_field ctx true) c.cl_ordered_statics; let gen_props props = String.concat "," (List.map (fun (p,v) -> "\"" ^ p ^ "\" => \"" ^ v ^ "\"") props) in let rec fields c = let list = Codegen.get_properties (c.cl_ordered_statics @ c.cl_ordered_fields) in match c.cl_super with | Some (csup, _) -> list @ fields csup | None -> list in if not c.cl_interface then (match fields c with | [] -> () | props -> newline ctx; print ctx "static $__properties__ = array(%s)" (gen_props props); ); cl(); newline ctx; if PMap.exists "__toString" c.cl_fields then () else if PMap.exists "toString" c.cl_fields && (not c.cl_interface) && (not c.cl_extern) then begin print ctx "\tfunction __toString() { return $this->toString(); }"; newline ctx end else if (not c.cl_interface) && (not c.cl_extern) then begin print ctx "\tfunction __toString() { return '%s'; }" (s_path_haxe c.cl_path) ; newline ctx end; print ctx "}" let createmain com e = let filename = match com.php_front with None -> "index.php" | Some n -> n in let ctx = { com = com; stack = stack_init com false; tabs = ""; ch = open_out (com.file ^ "/" ^ filename); path = ([], ""); buf = Buffer.create (1 lsl 14); in_value = None; in_loop = false; in_instance_method = false; imports = Hashtbl.create 0; extern_required_paths = []; extern_classes_with_init = []; curclass = null_class; curmethod = ""; locals = PMap.empty; inv_locals = PMap.empty; local_types = []; inits = []; constructor_block = false; dynamic_methods = []; all_dynamic_methods = []; is_call = false; cwd = ""; inline_methods = []; nested_loops = 0; inline_index = 0; in_block = false; lib_path = match com.php_lib with None -> "lib" | Some s -> s; } in spr ctx "if(version_compare(PHP_VERSION, '5.1.0', '<')) { exit('Your current PHP version is: ' . PHP_VERSION . '. Haxe/PHP generates code for version 5.1.0 or later'); }"; newline ctx; newline ctx; spr ctx ("require_once dirname(__FILE__).'/" ^ ctx.lib_path ^ "/php/" ^ (prefix_class com "Boot.class.php';\n\n")); gen_value ctx e; newline ctx; spr ctx "\n?>"; close ctx let generate_main ctx c = (match c.cl_ordered_statics with | [{ cf_expr = Some e }] -> gen_value ctx e; | _ -> assert false); newline ctx let generate_enum ctx e = ctx.local_types <- List.map snd e.e_params; let pack = open_block ctx in let ename = s_path ctx e.e_path e.e_extern e.e_pos in print ctx "class %s extends Enum {" ename; PMap.iter (fun _ c -> newline ctx; match c.ef_type with | TFun (args,_) -> print ctx "public static function %s($" (s_ident c.ef_name); concat ctx ", $" (fun (a,o,t) -> spr ctx a; if o then spr ctx " = null"; ) args; spr ctx ") {"; print ctx " return new %s(\"%s\", %d, array($" ename (s_ident c.ef_name) c.ef_index; concat ctx ", $" (fun (a,_,_) -> spr ctx a) args; print ctx ")); }"; | _ -> print ctx "public static $%s" (s_ident c.ef_name); ) e.e_constrs; newline ctx; spr ctx "public static $__constructors = array("; let first = ref true in PMap.iter (fun _ c -> if not !first then spr ctx ", "; print ctx "%d => '%s'" c.ef_index (s_ident c.ef_name); first := false; ) e.e_constrs; spr ctx ")"; newline ctx; (match Codegen.build_metadata ctx.com (TEnumDecl e) with | None -> () | Some _ -> spr ctx "public static $__meta__"; newline ctx); pack(); print ctx "}"; PMap.iter (fun _ c -> match c.ef_type with | TFun (args,_) -> (); | _ -> newline ctx; print ctx "%s::$%s = new %s(\"%s\", %d)" ename (s_ident c.ef_name) ename c.ef_name c.ef_index; ) e.e_constrs; newline ctx; match Codegen.build_metadata ctx.com (TEnumDecl e) with | None -> () | Some e -> print ctx "%s::$__meta__ = " ename; gen_expr ctx e; newline ctx let generate com = let all_dynamic_methods = ref [] in let extern_classes_with_init = ref [] in let php_lib_path = (match com.php_lib with None -> "lib" | Some n -> n) in create_directory com (Str.split (Str.regexp "/") php_lib_path); (* check for methods with the same name but different case *) let check_class_fields c = let lc_names = ref [] in let special_cases = ["toString"] in let loop c lst static = let in_special_cases name = (List.exists (fun n -> String.lowercase n = name) (special_cases @ List.map (fun f -> f.cf_name) c.cl_overrides)) in List.iter(fun cf -> let name = String.lowercase cf.cf_name in let prefixed_name s = (if s then "s_" else "i_") ^ name in match cf.cf_kind, cf.cf_expr with | (Method _, Some e) when not (in_special_cases name) -> (try let lc = List.find (fun n -> let n = snd n in if static then (n = (prefixed_name false)) else ((n = (prefixed_name false)) || (n = (prefixed_name true))) ) !lc_names in unsupported ("method '" ^ (s_type_path c.cl_path) ^ "." ^ cf.cf_name ^ "' already exists here '" ^ (fst lc) ^ "' (different case?)") c.cl_pos with Not_found -> lc_names := ((s_type_path c.cl_path) ^ "." ^ cf.cf_name, prefixed_name static) :: !lc_names) | _ -> () ) lst in let rec _check_class_fields cl = (match cl.cl_super with | Some (s,_) -> _check_class_fields s | _ -> ()); loop cl cl.cl_ordered_statics true; loop cl cl.cl_ordered_fields false in _check_class_fields c in List.iter (fun t -> (match t with | TClassDecl c -> check_class_fields c | TEnumDecl e -> let e_names = ref [] in List.iter(fun en -> ( if List.exists (fun n -> n = String.lowercase en) !e_names then unsupported ("'" ^ en ^ "' constructor exists with different case") e.e_pos else e_names := (String.lowercase en) :: !e_names )) (e.e_names) | _ -> ()) ) com.types; List.iter (fun t -> (match t with | TClassDecl c -> let dynamic_methods_names lst = List.map (fun fd -> { mpath = c.cl_path; mname = fd.cf_name; }) (List.filter is_dynamic_method lst) in all_dynamic_methods := dynamic_methods_names c.cl_ordered_fields @ !all_dynamic_methods; if c.cl_extern then (match c.cl_init with | Some _ -> extern_classes_with_init := c.cl_path :: !extern_classes_with_init; | _ -> ()) else all_dynamic_methods := dynamic_methods_names c.cl_ordered_statics @ !all_dynamic_methods; | _ -> ()) ) com.types; List.iter (Codegen.fix_abstract_inheritance com) com.types; List.iter (fun t -> (match t with | TClassDecl c -> if c.cl_extern then begin (match c.cl_init with | None -> () | Some e -> let ctx = init com php_lib_path c.cl_path 3 in gen_expr ctx e; newline ctx; close ctx; ); end else let ctx = init com php_lib_path c.cl_path (if c.cl_interface then 2 else 0) in ctx.extern_classes_with_init <- !extern_classes_with_init; ctx.all_dynamic_methods <- !all_dynamic_methods; generate_class ctx c; (match c.cl_init with | None -> () | Some e -> newline ctx; gen_expr ctx e); List.iter (generate_static_field_assign ctx c.cl_path) c.cl_ordered_statics; if c.cl_path = (["php"], "Boot") && com.debug then begin newline ctx; print ctx "$%s = new _hx_array(array())" ctx.stack.Codegen.stack_var; newline ctx; print ctx "$%s = new _hx_array(array())" ctx.stack.Codegen.stack_exc_var; end; let rec loop l = match l with | [] -> () | h :: _ -> generate_inline_method ctx c h; loop ctx.inline_methods in loop ctx.inline_methods; newline ctx; close ctx | TEnumDecl e -> if e.e_extern then () else let ctx = init com php_lib_path e.e_path 1 in generate_enum ctx e; close ctx | TTypeDecl _ | TAbstractDecl _ -> ()); ) com.types; (match com.main with | None -> () | Some e -> createmain com e); Hashtbl.iter (fun name data -> write_resource com.file name data ) com.resources; haxe_3.2.1+dfsg.orig/genpy.ml0000664000175000017500000024621012607337712016005 0ustar andyandy00000000000000(* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open Common module Utils = struct let class_of_module_type mt = match mt with | TClassDecl c -> c | _ -> failwith ("Not a class: " ^ (s_type_path (t_infos mt).mt_path)) let find_type com path = try List.find (fun mt -> match mt with | TAbstractDecl _ -> false | _ -> (t_infos mt).mt_path = path ) com.types with Not_found -> error (Printf.sprintf "Could not find type %s\n" (s_type_path path)) null_pos let mk_static_field c cf p = let ta = TAnon { a_fields = c.cl_statics; a_status = ref (Statics c) } in let ethis = mk (TTypeExpr (TClassDecl c)) ta p in let t = monomorphs cf.cf_params cf.cf_type in mk (TField (ethis,(FStatic (c,cf)))) t p let mk_static_call c cf el p = let ef = mk_static_field c cf p in let tr = match follow ef.etype with | TFun(args,tr) -> tr | _ -> assert false in mk (TCall(ef,el)) tr p let resolve_static_field c n = try PMap.find n c.cl_statics with Not_found -> failwith (Printf.sprintf "Class %s has no field %s" (s_type_path c.cl_path) n) let mk_static_field_2 c n p = mk_static_field c (resolve_static_field c n) p let mk_static_call_2 c n el p = mk_static_call c (resolve_static_field c n) el p end module KeywordHandler = struct let kwds = let h = Hashtbl.create 0 in List.iter (fun s -> Hashtbl.add h s ()) [ "and"; "as"; "assert"; "break"; "class"; "continue"; "def"; "del"; "elif"; "else"; "except"; "exec"; "finally"; "for"; "from"; "global"; "if"; "import"; "in"; "is"; "lambda"; "not"; "or"; "pass"; " raise"; "return"; "try"; "while"; "with"; "yield"; "None"; "True"; "False"; ]; h let kwds2 = let h = Hashtbl.create 0 in List.iter (fun s -> Hashtbl.add h s ()) [ "len"; "int"; "float"; "list"; "bool"; "str"; "isinstance"; "print"; "min"; "max"; "hasattr"; "getattr"; "setattr"; "delattr"; "callable"; "type"; "ord"; "chr"; "iter"; "map"; "filter"; "tuple"; "dict"; "set"; "bytes"; "bytearray" ]; h let handle_keywords s = let l = String.length s in if Hashtbl.mem kwds s then "_hx_" ^ s (* handle special __ underscore behaviour (creates private fields for objects) for fields but only if the field doesn't end with at least one underscores like __iter__ because these are special fields *) else if l > 2 && String.sub s 0 2 = "__" && String.sub s (l - 1) 1 <> "_" then "_hx_" ^ s else s let check_var_declaration v = if Hashtbl.mem kwds2 v.v_name then v.v_name <- "_hx_" ^ v.v_name end module Transformer = struct type adjusted_expr = { a_expr : texpr; a_blocks : texpr list; a_next_id : unit -> string; a_is_value : bool; } let como = ref None let t_bool = ref t_dynamic let t_void = ref t_dynamic let t_string = ref t_dynamic let t_int = ref t_dynamic let c_reflect = ref (fun () -> null_class) let init com = como := Some com; t_bool := com.basic.tbool; t_void := com.basic.tvoid; t_string := com.basic.tstring; t_int := com.basic.tint; c_reflect := fun () -> Utils.class_of_module_type (Utils.find_type com ([],"Reflect")) and debug_expr e = let s_type = Type.s_type (print_context()) in let s = Type.s_expr_pretty "\t" s_type e in Printf.printf "%s\n" s and debug_expr_with_type e = let s_type = Type.s_type (print_context()) in let es = Type.s_expr_pretty "\t" s_type e in let t = s_type e.etype in Printf.printf "%s : %s\n" es t and debug_type t = let s_type = Type.s_type (print_context()) in let t = s_type t in Printf.printf "%s\n" t let new_counter () = let n = ref (-1) in (fun () -> incr n; Printf.sprintf "_hx_local_%i" !n ) let to_expr ae = match ae.a_blocks with | [] -> ae.a_expr | el -> match ae.a_expr.eexpr with | TBlock el2 -> { ae.a_expr with eexpr = TBlock (el @ el2) } | _ -> { ae.a_expr with eexpr = TBlock (el @ [ae.a_expr])} let lift_expr ?(is_value = false) ?(next_id = None) ?(blocks = []) e = let next_id = match next_id with | None -> new_counter() | Some f -> f in { a_expr = e; a_blocks = blocks; a_next_id = next_id; a_is_value = is_value } let lift_expr1 is_value next_id blocks e = lift_expr ~is_value:is_value ~next_id:(Some next_id) ~blocks:blocks e let to_tvar ?(capture = false) n t = alloc_var n t (* { v_name = n; v_type = t; v_id = 0; v_capture = capture; v_extra = None; v_meta = [] } *) let create_non_local n pos = let s = "nonlocal " ^ (KeywordHandler.handle_keywords n) in (* TODO: this is a hack... *) let id = mk (TLocal (to_tvar "python_Syntax._pythonCode" t_dynamic ) ) !t_void pos in let id2 = mk (TLocal( to_tvar s t_dynamic )) !t_void pos in mk (TCall(id, [id2])) t_dynamic pos let to_tlocal_expr ?(capture = false) n t p = mk (TLocal (to_tvar ~capture:capture n t)) t p let check_unification e t = match follow e.etype,follow t with | TAnon an1, TAnon an2 -> PMap.iter (fun s cf -> if not (PMap.mem s an1.a_fields) then an1.a_fields <- PMap.add s cf an1.a_fields ) an2.a_fields; e | _ -> e let dynamic_field_read e s = Utils.mk_static_call_2 ((!c_reflect)()) "field" [e;mk (TConst (TString s)) !t_string e.epos] e.epos let dynamic_field_write e1 s e2 = Utils.mk_static_call_2 ((!c_reflect)()) "setField" [e1;mk (TConst (TString s)) !t_string e1.epos;e2] e1.epos let dynamic_field_read_write next_id e1 s op e2 = let id = next_id() in let temp_var = to_tvar id e1.etype in let temp_var_def = mk (TVar(temp_var,Some e1)) e1.etype e1.epos in let temp_local = mk (TLocal temp_var) e1.etype e1.epos in let e_field = dynamic_field_read temp_local s in let e_op = mk (TBinop(op,e_field,e2)) e_field.etype e_field.epos in let e_set_field = dynamic_field_write temp_local s e_op in mk (TBlock [ temp_var_def; e_set_field; ]) e_set_field.etype e_set_field.epos let add_non_locals_to_func e = match e.eexpr with | TFunction tf -> let cur = ref PMap.empty in let save () = let prev = !cur in (fun () -> cur := prev ) in let declare v = cur := PMap.add v.v_id v !cur; in List.iter (fun (v,_) -> declare v) tf.tf_args; let non_locals = Hashtbl.create 0 in let rec it e = match e.eexpr with | TVar(v,e1) -> begin match e1 with | Some e -> maybe_continue e | None -> () end; declare v; | TTry(e1,catches) -> it e1; List.iter (fun (v,e) -> let restore = save() in declare v; it e; restore() ) catches; | TBinop( (OpAssign | OpAssignOp(_)), { eexpr = TLocal v }, e2) -> if not (PMap.mem v.v_id !cur) then Hashtbl.add non_locals v.v_id v; maybe_continue e2; | TFunction _ -> () | _ -> Type.iter it e and maybe_continue e = match e.eexpr with | TFunction _ -> () | _ -> it e in it tf.tf_expr; let el = Hashtbl.fold (fun k v acc -> (create_non_local v.v_name e.epos) :: acc ) non_locals [] in let el = tf.tf_expr :: el in let tf = { tf with tf_expr = { tf.tf_expr with eexpr = TBlock(List.rev el)}} in {e with eexpr = TFunction tf} | _ -> assert false let rec transform_function tf ae is_value = let p = tf.tf_expr.epos in let assigns = List.fold_left (fun acc (v,value) -> match value with | None | Some TNull -> acc | Some ct -> let a_local = mk (TLocal v) v.v_type p in let a_null = mk (TConst TNull) v.v_type p in let a_cmp = mk (TBinop(OpEq,a_local,a_null)) !t_bool p in let a_value = mk (TConst(ct)) v.v_type p in let a_assign = mk (TBinop(OpAssign,a_local,a_value)) v.v_type p in let a_if = mk (TIf(a_cmp,a_assign,None)) !t_void p in a_if :: acc ) [] tf.tf_args in let body = match assigns with | [] -> tf.tf_expr | _ -> let eb = mk (TBlock (List.rev assigns)) t_dynamic p in Type.concat eb tf.tf_expr in let e1 = to_expr (transform_expr ~next_id:(Some ae.a_next_id) body) in let fn = mk (TFunction({ tf_expr = e1; tf_args = tf.tf_args; tf_type = tf.tf_type; })) ae.a_expr.etype p in let fn = add_non_locals_to_func fn in if is_value then begin let new_name = ae.a_next_id() in let new_var = alloc_var new_name tf.tf_type in let new_local = mk (TLocal new_var) fn.etype p in let def = mk (TVar(new_var,Some fn)) fn.etype p in lift_expr1 false ae.a_next_id [def] new_local end else lift_expr fn and transform_var_expr ae eo v = let b,new_expr = match eo with | None -> [],None | Some e1 -> let f = transform_expr1 true ae.a_next_id [] e1 in let b = f.a_blocks in b,Some(f.a_expr) in let e = mk (TVar(v,new_expr)) ae.a_expr.etype ae.a_expr.epos in lift_expr ~next_id:(Some ae.a_next_id) ~blocks:b e and transform_expr ?(is_value = false) ?(next_id = None) ?(blocks = []) (e : texpr) : adjusted_expr = transform1 (lift_expr ~is_value ~next_id ~blocks e) and transform_expr1 is_value next_id blocks e = transform_expr ~is_value ~next_id:(Some next_id) ~blocks e and transform_exprs_to_block el tb is_value p next_id = match el with | [e] -> transform_expr ~is_value ~next_id:(Some next_id) e | _ -> let size = List.length el in let res = DynArray.create () in ExtList.List.iteri (fun i e -> (* this removes len(x) calls which are reproduced by the inlined return of Array.push even if the value is not used *) let is_removable_statement e = (not is_value || i < size-1) && match e.eexpr with | TField(_, FInstance({cl_path = [],"list"},_,{ cf_name = "length" })) -> true | _ -> false in if not (is_removable_statement e) then let ae = transform_expr ~is_value ~next_id:(Some next_id) e in List.iter (DynArray.add res) ae.a_blocks; DynArray.add res ae.a_expr else () ) el; lift_expr (mk (TBlock (DynArray.to_list res)) tb p) and transform_switch ae is_value e1 cases edef = let case_functions = ref [] in let case_to_if (el,e) eelse = let val_reversed = List.rev el in let mk_eq e = mk (TBinop(OpEq,e1,e)) !t_bool (punion e1.epos e.epos) in let cond = match val_reversed with | [] -> assert false | [e] -> mk_eq e | e :: el -> List.fold_left (fun eelse e -> mk (TBinop(OpBoolOr,eelse,mk_eq e)) !t_bool (punion eelse.epos e.epos)) (mk_eq e) el in let eif = if is_value then begin let name = ae.a_next_id() in let func = exprs_to_func [e] name ae in case_functions := !case_functions @ func.a_blocks; let call = func.a_expr in mk (TIf(cond,call,eelse)) ae.a_expr.etype ae.a_expr.epos end else mk (TIf(cond,e,eelse)) ae.a_expr.etype e.epos in eif in let rev_cases = List.rev cases in let edef = Some (match edef with | None -> mk (TBlock []) ae.a_expr.etype ae.a_expr.epos | Some e -> e) in let res = match rev_cases,edef with | [],Some edef -> edef | [],None -> (* I don't think that can happen? *) assert false | [case],_ -> case_to_if case edef | case :: cases,_ -> List.fold_left (fun acc case -> case_to_if case (Some acc)) (case_to_if case edef) cases in let res = if is_value then mk (TBlock ((List.rev (res :: !case_functions)))) res.etype res.epos else res in forward_transform res ae and transform_string_switch ae is_value e1 cases edef = let length_map = Hashtbl.create 0 in List.iter (fun (el,e) -> List.iter (fun es -> match es.eexpr with | TConst (TString s) -> let l = String.length s in let sl = try Hashtbl.find length_map l with Not_found -> let sl = ref [] in Hashtbl.replace length_map l sl; sl in sl := ([es],e) :: !sl; | _ -> () ) el ) cases; if Hashtbl.length length_map < 2 then transform_switch ae is_value e1 cases edef else let mk_eq e1 e2 = mk (TBinop(OpEq,e1,e2)) !t_bool (punion e1.epos e2.epos) in let mk_or e1 e2 = mk (TBinop(OpOr,e1,e2)) !t_bool (punion e1.epos e2.epos) in let mk_if (el,e) eo = let eif = List.fold_left (fun eacc e -> mk_or eacc (mk_eq e1 e)) (mk_eq e1 (List.hd el)) (List.tl el) in mk (TIf(Codegen.mk_parent eif,e,eo)) e.etype e.epos in let cases = Hashtbl.fold (fun i el acc -> let eint = mk (TConst (TInt (Int32.of_int i))) !t_int e1.epos in let fs = match List.fold_left (fun eacc ec -> Some (mk_if ec eacc)) edef !el with Some e -> e | None -> assert false in ([eint],fs) :: acc ) length_map [] in let c_string = match !t_string with TInst(c,_) -> c | _ -> assert false in let cf_length = PMap.find "length" c_string.cl_fields in let ef = mk (TField(e1,FInstance(c_string,[],cf_length))) !t_int e1.epos in let res_var = alloc_var (ae.a_next_id()) ef.etype in let res_local = {ef with eexpr = TLocal res_var} in let var_expr = {ef with eexpr = TVar(res_var,Some ef)} in let e = mk (TBlock [ var_expr; mk (TSwitch(res_local,cases,edef)) ae.a_expr.etype e1.epos ]) ae.a_expr.etype e1.epos in forward_transform e ae and transform_op_assign_op ae e1 op one is_value post = let e1_ = transform_expr e1 ~is_value:true ~next_id:(Some ae.a_next_id) in let handle_as_local temp_local = let ex = ae.a_expr in let res_var = alloc_var (ae.a_next_id()) ex.etype in let res_local = {ex with eexpr = TLocal res_var} in let plus = {ex with eexpr = TBinop(op,temp_local,one)} in let var_expr = {ex with eexpr = TVar(res_var,Some temp_local)} in let assign_expr = {ex with eexpr = TBinop(OpAssign,e1_.a_expr,plus)} in let blocks = if post then [var_expr;assign_expr;res_local] else [assign_expr;temp_local] in (* TODO: block is ignored in the else case? *) let block = e1_.a_blocks @ blocks in if is_value then begin let f = exprs_to_func block (ae.a_next_id()) ae in lift_expr f.a_expr ~is_value:true ~next_id:(Some ae.a_next_id) ~blocks:f.a_blocks end else begin let block = e1_.a_blocks @ [assign_expr] in transform_exprs_to_block block ex.etype false ex.epos ae.a_next_id end in match e1_.a_expr.eexpr with | TArray({eexpr = TLocal _},{eexpr = TLocal _}) | TField({eexpr = TLocal _},_) | TLocal _ -> handle_as_local e1_.a_expr | TArray(e1,e2) -> let id = ae.a_next_id() in let temp_var_l = alloc_var id e1.etype in let temp_local_l = {e1 with eexpr = TLocal temp_var_l} in let temp_var_l = {e1 with eexpr = TVar(temp_var_l,Some e1)} in let id = ae.a_next_id() in let temp_var_r = alloc_var id e2.etype in let temp_local_r = {e2 with eexpr = TLocal temp_var_r} in let temp_var_r = {e2 with eexpr = TVar(temp_var_r,Some e2)} in let id = ae.a_next_id() in let temp_var = alloc_var id e1_.a_expr.etype in let temp_local = {e1_.a_expr with eexpr = TLocal temp_var} in let temp_var_expr = {e1_.a_expr with eexpr = TArray(temp_local_l,temp_local_r)} in let temp_var = {e1_.a_expr with eexpr = TVar(temp_var,Some temp_var_expr)} in let plus = {ae.a_expr with eexpr = TBinop(op,temp_local,one)} in let assign_expr = {ae.a_expr with eexpr = TBinop(OpAssign,temp_var_expr,plus)} in let block = e1_.a_blocks @ [temp_var_l;temp_var_r;temp_var;assign_expr;if post then temp_local else temp_var_expr] in if is_value then begin let f = exprs_to_func block (ae.a_next_id()) ae in lift_expr f.a_expr ~is_value:true ~next_id:(Some ae.a_next_id) ~blocks:f.a_blocks end else transform_exprs_to_block block ae.a_expr.etype false ae.a_expr.epos ae.a_next_id | TField(e1,fa) -> let temp_var_l = alloc_var (ae.a_next_id()) e1.etype in let temp_local_l = {e1 with eexpr = TLocal temp_var_l} in let temp_var_l = {e1 with eexpr = TVar(temp_var_l,Some e1)} in let temp_var = alloc_var (ae.a_next_id()) e1_.a_expr.etype in let temp_local = {e1_.a_expr with eexpr = TLocal temp_var} in let temp_var_expr = {e1_.a_expr with eexpr = TField(temp_local_l,fa)} in let temp_var = {e1_.a_expr with eexpr = TVar(temp_var,Some temp_var_expr)} in let plus = {ae.a_expr with eexpr = TBinop(op,temp_local,one)} in let assign_expr = {ae.a_expr with eexpr = TBinop(OpAssign,temp_var_expr,plus)} in let block = e1_.a_blocks @ [temp_var_l;temp_var;assign_expr;if post then temp_local else temp_var_expr] in if is_value then begin let f = exprs_to_func block (ae.a_next_id()) ae in lift_expr f.a_expr ~is_value:true ~next_id:(Some ae.a_next_id) ~blocks:f.a_blocks end else transform_exprs_to_block block ae.a_expr.etype false ae.a_expr.epos ae.a_next_id | _ -> debug_expr e1_.a_expr; assert false and var_to_treturn_expr ?(capture = false) n t p = let x = mk (TLocal (to_tvar ~capture:capture n t)) t p in mk (TReturn (Some x)) t p and exprs_to_func exprs name base = let convert_return_expr (expr:texpr) = match expr.eexpr with | TWhile(_,_,_) -> let ret = { expr with eexpr = TReturn (None) } in [expr; ret] | TFunction(f) -> let ret = var_to_treturn_expr name f.tf_type f.tf_expr.epos in [expr;ret] | TBinop(OpAssign, l, r) -> let r = { l with eexpr = TReturn(Some l) } in [expr; r] | x -> let ret_expr = { expr with eexpr = TReturn( Some(expr) )} in [ret_expr] in let def = (let ex = match exprs with | [] -> assert false | [x] -> (let exs = convert_return_expr x in match exs with | [] -> assert false | [x] -> x | x -> match List.rev x with | x::xs -> mk (TBlock exs) x.etype base.a_expr.epos | _ -> assert false) | x -> match List.rev x with | x::xs -> (let ret = x in let tail = List.rev xs in let block = tail @ (convert_return_expr ret) in match List.rev block with | x::_ -> mk (TBlock block) x.etype base.a_expr.epos | _ -> assert false) | _ -> assert false in let f1 = { tf_args = []; tf_type = TFun([],ex.etype); tf_expr = ex} in let fexpr = mk (TFunction f1) ex.etype ex.epos in let fvar = to_tvar name fexpr.etype in let f = add_non_locals_to_func fexpr in let assign = { ex with eexpr = TVar(fvar, Some(f))} in let call_expr = (mk (TLocal fvar) fexpr.etype ex.epos ) in let substitute = mk (TCall(call_expr, [])) ex.etype ex.epos in lift_expr ~blocks:[assign] substitute) in match exprs with | [{ eexpr = TFunction({ tf_args = []} as f) } as x] -> let l = to_tlocal_expr name f.tf_type f.tf_expr.epos in let substitute = mk (TCall(l, [])) f.tf_type f.tf_expr.epos in lift_expr ~blocks:[x] substitute | _ -> def and transform_call is_value e params ae = let trans is_value blocks e = transform_expr1 is_value ae.a_next_id blocks e in let trans1 e params = let e = trans true [] e in let blocks = e.a_blocks @ (List.flatten (List.map (fun (p) -> p.a_blocks) params)) in let params = List.map (fun (p) -> p.a_expr) params in let e = { ae.a_expr with eexpr = TCall(e.a_expr, params) } in lift_expr ~blocks:blocks e in match e, params with (* the foreach block should not be handled as a value *) | ({ eexpr = TField(_, FStatic({cl_path = ["python";],"Syntax"},{ cf_name = "_foreach" }))} as e, [e1;e2;e3]) -> trans1 e [trans true [] e1; trans true [] e2; trans false [] e3] | (e, params) -> trans1 e (List.map (trans true []) params) and transform1 ae : adjusted_expr = let trans is_value blocks e = transform_expr1 is_value ae.a_next_id blocks e in let lift is_value blocks e = lift_expr1 is_value ae.a_next_id blocks e in let a_expr = ae.a_expr in match ae.a_is_value,ae.a_expr.eexpr with | (is_value,TBlock [x]) -> trans is_value [] x | (false,TBlock []) -> lift_expr a_expr | (true,TBlock []) -> lift_expr (mk (TConst TNull) ae.a_expr.etype ae.a_expr.epos) | (false,TBlock el) -> transform_exprs_to_block el ae.a_expr.etype false ae.a_expr.epos ae.a_next_id | (true,TBlock el) -> let name = ae.a_next_id() in let block,tr = match List.rev el with | e :: el -> List.rev ((mk (TReturn (Some e)) t_dynamic e.epos) :: el),e.etype | [] -> assert false in let my_block = transform_exprs_to_block block tr false ae.a_expr.epos ae.a_next_id in let fn = mk (TFunction { tf_args = []; tf_type = tr; tf_expr = my_block.a_expr; }) ae.a_expr.etype ae.a_expr.epos in let t_var = alloc_var name ae.a_expr.etype in let f = add_non_locals_to_func fn in let fn_assign = mk (TVar (t_var,Some f)) ae.a_expr.etype ae.a_expr.epos in let ev = mk (TLocal t_var) ae.a_expr.etype ae.a_expr.epos in let substitute = mk (TCall(ev,[])) ae.a_expr.etype ae.a_expr.epos in lift_expr ~blocks:[fn_assign] substitute | (is_value,TFunction(f)) -> transform_function f ae is_value | (_,TVar(v,None)) -> transform_var_expr ae None v | (false, TVar(v,Some({ eexpr = TUnop((Increment | Decrement as unop),post_fix,({eexpr = TLocal _ | TField({eexpr = TConst TThis},_)} as ve))} as e1))) -> let one = {e1 with eexpr = TConst (TInt (Int32.of_int 1))} in let op = if unop = Increment then OpAdd else OpSub in let inc = {e1 with eexpr = TBinop(op,ve,one)} in let inc_assign = {e1 with eexpr = TBinop(OpAssign,ve,inc)} in let var_assign = {e1 with eexpr = TVar(v,Some ve)} in if post_fix = Postfix then lift true [var_assign] inc_assign else lift true [inc_assign] var_assign | (_,TVar(v,eo)) -> transform_var_expr ae eo v | (_,TFor(v,e1,e2)) -> let a1 = trans true [] e1 in let a2 = to_expr (trans false [] e2) in let name = (ae.a_next_id ()) in let t_var = alloc_var name e1.etype in let mk_local v p = { eexpr = TLocal v; etype = v.v_type; epos = p } in let ev = mk_local t_var e1.epos in let ehasnext = mk (TField(ev,quick_field e1.etype "hasNext")) (tfun [] (!t_bool) ) e1.epos in let ehasnext = mk (TCall(ehasnext,[])) ehasnext.etype ehasnext.epos in let enext = mk (TField(ev,quick_field e1.etype "next")) (tfun [] v.v_type) e1.epos in let enext = mk (TCall(enext,[])) v.v_type e1.epos in let var_assign = mk (TVar (v,Some enext)) v.v_type a_expr.epos in let ebody = Type.concat var_assign (a2) in let var_decl = mk (TVar (t_var,Some a1.a_expr)) (!t_void) e1.epos in let twhile = mk (TWhile((mk (TParenthesis ehasnext) ehasnext.etype ehasnext.epos),ebody,NormalWhile)) (!t_void) e1.epos in let blocks = a1.a_blocks @ [var_decl] in lift_expr ~blocks: blocks twhile | (_,TReturn None) -> ae | (_,TReturn (Some ({eexpr = TFunction f} as ef))) -> let n = ae.a_next_id() in let e1 = to_expr (trans false [] f.tf_expr) in let f = mk (TFunction { tf_args = f.tf_args; tf_type = f.tf_type; tf_expr = e1; }) ef.etype ef.epos in let f1 = add_non_locals_to_func f in let var_n = alloc_var n ef.etype in let f1_assign = mk (TVar(var_n,Some f1)) !t_void f1.epos in let var_local = mk (TLocal var_n) ef.etype f1.epos in let er = mk (TReturn (Some var_local)) t_dynamic ae.a_expr.epos in lift true [f1_assign] er | (_,TReturn Some(x)) -> let x1 = trans true [] x in (match x1.a_blocks with | [] -> lift true [] { ae.a_expr with eexpr = TReturn(Some x1.a_expr) } | blocks -> let f = exprs_to_func (blocks @ [x1.a_expr]) (ae.a_next_id()) ae in lift true f.a_blocks {a_expr with eexpr = TReturn (Some f.a_expr)}) | (_, TParenthesis(e1)) -> let e1 = trans true [] e1 in let p = { ae.a_expr with eexpr = TParenthesis(e1.a_expr)} in lift true e1.a_blocks p | (_, TEnumParameter(e1,ef,i)) -> let e1 = trans true [] e1 in let p = { ae.a_expr with eexpr = TEnumParameter(e1.a_expr,ef,i)} in lift true e1.a_blocks p | (true, TIf(econd, eif, eelse)) -> (let econd1 = trans true [] econd in let eif1 = trans true [] eif in let eelse1 = match eelse with | Some x -> Some(trans true [] x) | None -> None in let blocks = [] in let eif2, blocks = match eif1.a_blocks with | [] -> eif1.a_expr, blocks | x -> let regular = let fname = eif1.a_next_id () in let f = exprs_to_func (List.append eif1.a_blocks [eif1.a_expr]) fname ae in f.a_expr, List.append blocks f.a_blocks in match eif1.a_blocks with | [{ eexpr = TVar(_, Some({ eexpr = TFunction(_)}))} as b] -> eif1.a_expr, List.append blocks [b] | _ -> regular in let eelse2, blocks = match eelse1 with | None -> None, blocks | Some({ a_blocks = []} as x) -> Some(x.a_expr), blocks | Some({ a_blocks = b} as eelse1) -> let regular = let fname = eelse1.a_next_id () in let f = exprs_to_func (List.append eelse1.a_blocks [eelse1.a_expr]) fname ae in Some(f.a_expr), List.append blocks f.a_blocks in match b with | [{ eexpr = TVar(_, Some({ eexpr = TFunction(f)}))} as b] -> Some(eelse1.a_expr), List.append blocks [b] | _ -> regular in let blocks = List.append econd1.a_blocks blocks in let new_if = { ae.a_expr with eexpr = TIf(econd1.a_expr, eif2, eelse2) } in match blocks with | [] -> let meta = Meta.Custom(":ternaryIf"), [], ae.a_expr.epos in let ternary = { ae.a_expr with eexpr = TMeta(meta, new_if) } in lift_expr ~blocks:blocks ternary | b -> let f = exprs_to_func (List.append blocks [new_if]) (ae.a_next_id ()) ae in lift_expr ~blocks:f.a_blocks f.a_expr) | (false, TIf(econd, eif, eelse)) -> let econd = trans true [] econd in let eif = to_expr (trans false [] eif) in let eelse = match eelse with | Some(x) -> Some(to_expr (trans false [] x)) | None -> None in let new_if = { ae.a_expr with eexpr = TIf(econd.a_expr, eif, eelse) } in lift false econd.a_blocks new_if | (false, TWhile(econd, e1, NormalWhile)) -> let econd1 = trans true [] econd in let e11 = to_expr (trans false [] e1) in let new_while = mk (TWhile(econd1.a_expr,e11,NormalWhile)) a_expr.etype a_expr.epos in lift false econd1.a_blocks new_while | (true, TWhile(econd, ebody, NormalWhile)) -> let econd = trans true [] econd in let ebody = to_expr (trans false [] ebody) in let ewhile = { ae.a_expr with eexpr = TWhile(econd.a_expr, ebody, NormalWhile) } in let eval = { ae.a_expr with eexpr = TConst(TNull) } in let f = exprs_to_func (List.append econd.a_blocks [ewhile; eval]) (ae.a_next_id ()) ae in lift true f.a_blocks f.a_expr | (false, TWhile(econd, ebody, DoWhile)) -> let not_expr = { econd with eexpr = TUnop(Not, Prefix, econd) } in let break_expr = mk TBreak !t_void econd.epos in let if_expr = mk (TIf(not_expr, break_expr, None)) (!t_void) econd.epos in let new_e = match ebody.eexpr with | TBlock(exprs) -> { econd with eexpr = TBlock( List.append exprs [if_expr]) } | _ -> { econd with eexpr = TBlock( List.append [ebody] [if_expr]) } in let true_expr = mk (TConst(TBool(true))) econd.etype ae.a_expr.epos in let new_expr = { ae.a_expr with eexpr = TWhile( true_expr, new_e, NormalWhile) } in forward_transform new_expr ae | (is_value, TSwitch(e, cases, edef)) -> begin match follow e.etype with | TInst({cl_path = [],"str"},_) -> transform_string_switch ae is_value e cases edef | _ -> transform_switch ae is_value e cases edef end (* anon field access on optional params *) | (is_value, TField(e,FAnon cf)) when Meta.has Meta.Optional cf.cf_meta -> let e = dynamic_field_read e cf.cf_name in transform_expr ~is_value:is_value e | (is_value, TBinop(OpAssign,{eexpr = TField(e1,FAnon cf)},e2)) when Meta.has Meta.Optional cf.cf_meta -> let e = dynamic_field_write e1 cf.cf_name e2 in transform_expr ~is_value:is_value e | (is_value, TBinop(OpAssignOp op,{eexpr = TField(e1,FAnon cf)},e2)) when Meta.has Meta.Optional cf.cf_meta -> let e = dynamic_field_read_write ae.a_next_id e1 cf.cf_name op e2 in transform_expr ~is_value:is_value e (* TODO we need to deal with Increment, Decrement too! | (_, TUnop( (Increment | Decrement) as unop, op,{eexpr = TField(e1,FAnon cf)})) when Meta.has Meta.Optional cf.cf_meta -> let = dynamic_field_read e cf.cf_name in let e = dynamic_field_read_write_unop ae.a_next_id e1 cf.cf_name unop op in Printf.printf "dyn read write\n"; transform_expr e *) (* anon field access with non optional members like iterator, length, split must be handled too, we need to Reflect on them too when it's a runtime method *) | (is_value, TUnop( (Increment | Decrement) as unop, op, e)) -> let one = { ae.a_expr with eexpr = TConst(TInt(Int32.of_int(1)))} in let is_postfix = match op with | Postfix -> true | Prefix -> false in let op = match unop with | Increment -> OpAdd | Decrement -> OpSub | _ -> assert false in transform_op_assign_op ae e op one is_value is_postfix | (_, TUnop(op, Prefix, e)) -> let e1 = trans true [] e in let r = { a_expr with eexpr = TUnop(op, Prefix, e1.a_expr) } in lift_expr ~blocks:e1.a_blocks r | (is_value, TField(e,FDynamic s)) -> let e = dynamic_field_read e s in transform_expr ~is_value:is_value e | (is_value, TBinop(OpAssign,{eexpr = TField(e1,FDynamic s)},e2)) -> let e = dynamic_field_write e1 s e2 in transform_expr ~is_value:is_value e | (is_value, TBinop(OpAssignOp op,{eexpr = TField(e1,FDynamic s)},e2)) -> let e = dynamic_field_read_write ae.a_next_id e1 s op e2 in transform_expr ~is_value:is_value e | (is_value, TField(e1, FClosure(Some ({cl_path = [],("str" | "list")},_),cf))) -> let e = dynamic_field_read e1 cf.cf_name in transform_expr ~is_value:is_value e | (is_value, TBinop(OpAssign, left, right))-> (let left = trans true [] left in let right = trans true [] right in let r = { a_expr with eexpr = TBinop(OpAssign, left.a_expr, right.a_expr)} in if is_value then (let blocks = List.concat [left.a_blocks; right.a_blocks; [r]] in let f = exprs_to_func blocks (ae.a_next_id ()) ae in lift true f.a_blocks f.a_expr) else lift false (List.append left.a_blocks right.a_blocks) r) | (is_value, TBinop(OpAssignOp(x), left, right)) -> let right = trans true [] right in let v = right.a_expr in let res = transform_op_assign_op ae left x v is_value false in lift true (List.append right.a_blocks res.a_blocks) res.a_expr | (_, TBinop(op, left, right))-> (let left = trans true [] left in let right = trans true [] right in let r = { a_expr with eexpr = TBinop(op, left.a_expr, right.a_expr)} in lift false (List.append left.a_blocks right.a_blocks) r) | (true, TThrow(x)) -> let block = TBlock([a_expr; { a_expr with eexpr = TConst(TNull) }]) in let r = { a_expr with eexpr = block } in forward_transform r ae | (false, TThrow(x)) -> let x = trans true [] x in let r = { a_expr with eexpr = TThrow(x.a_expr)} in lift false x.a_blocks r | (_, TNew(c, tp, params)) -> let params = List.map (trans true []) params in let blocks = List.flatten (List.map (fun (p) -> p.a_blocks) params) in let params = List.map (fun (p) -> p.a_expr) params in let e = { a_expr with eexpr = TNew(c, tp, params) } in lift false blocks e | (is_value, TCall(e,params)) -> transform_call is_value e params ae | (_, TArray(e1, e2)) -> let e1 = trans true [] e1 in let e2 = trans true [] e2 in let r = { a_expr with eexpr = TArray(e1.a_expr, e2.a_expr)} in let blocks = List.append e1.a_blocks e2.a_blocks in lift_expr ~blocks:blocks r | (false, TTry(etry, catches)) -> let etry = trans false [] etry in let catches = List.map (fun(v,e) -> v, trans false [] e) catches in let blocks = List.flatten (List.map (fun (_,e) -> e.a_blocks) catches) in let catches = List.map (fun(v,e) -> v, e.a_expr) catches in let r = { a_expr with eexpr = TTry(etry.a_expr, catches)} in let blocks = List.append etry.a_blocks blocks in lift false blocks r | (true, TTry(etry, catches)) -> let id = ae.a_next_id () in let temp_var = to_tvar id a_expr.etype in let temp_var_def = { a_expr with eexpr = TVar(temp_var, None) } in let temp_local = { a_expr with eexpr = TLocal(temp_var)} in let mk_temp_assign right = { a_expr with eexpr = TBinop(OpAssign, temp_local, right)} in let etry = mk_temp_assign etry in let catches = List.map (fun (v,e)-> v, mk_temp_assign e) catches in let new_try = { a_expr with eexpr = TTry(etry, catches)} in let block = [temp_var_def; new_try; temp_local] in let new_block = { a_expr with eexpr = TBlock(block)} in forward_transform new_block ae | (_, TObjectDecl(fields)) -> let fields = List.map (fun (name,ex) -> name, trans true [] ex) fields in let blocks = List.flatten (List.map (fun (_,ex) -> ex.a_blocks) fields) in let fields = List.map (fun (name,ex) -> name, ex.a_expr) fields in let r = { a_expr with eexpr = (TObjectDecl(fields) )} in lift_expr ~blocks r | (_, TArrayDecl(values)) -> let values = List.map (trans true []) values in let blocks = List.flatten (List.map (fun (v) -> v.a_blocks) values) in let exprs = List.map (fun (v) -> v.a_expr) values in let r = { a_expr with eexpr = TArrayDecl exprs } in lift_expr ~blocks:blocks r | (is_value, TCast(e1,Some mt)) -> let e = Codegen.default_cast ~vtmp:(ae.a_next_id()) (match !como with Some com -> com | None -> assert false) e1 mt ae.a_expr.etype ae.a_expr.epos in transform_expr ~is_value:is_value e | (is_value, TCast(e,None)) -> let e = trans is_value [] e in let r = { a_expr with eexpr = TCast(e.a_expr, None)} in lift_expr ~blocks:e.a_blocks r | (_, TField(e,f)) -> let e = trans true [] e in let r = { a_expr with eexpr = TField(e.a_expr, f) } in lift_expr ~blocks:e.a_blocks r | (is_value, TMeta(m, e)) -> let e = trans is_value [] e in let r = { a_expr with eexpr = TMeta(m, e.a_expr); etype = e.a_expr.etype } in lift_expr ~blocks:e.a_blocks r | ( _, TLocal _ ) -> lift_expr a_expr | ( _, TConst _ ) -> lift_expr a_expr | ( _, TTypeExpr _ ) -> lift_expr a_expr | ( _, TUnop _ ) -> assert false | ( true, TWhile(econd, ebody, DoWhile) ) -> let new_expr = trans false [] a_expr in let f = exprs_to_func (new_expr.a_blocks @ [new_expr.a_expr]) (ae.a_next_id()) ae in lift_expr ~is_value:true ~blocks:f.a_blocks f.a_expr | ( _, TBreak ) | ( _, TContinue ) -> lift_expr a_expr and transform e = to_expr (transform1 (lift_expr e)) and forward_transform e base = transform1 (lift_expr1 base.a_is_value base.a_next_id base.a_blocks e) let transform_to_value e = to_expr (transform1 (lift_expr e ~is_value:true)) end module Printer = struct type print_context = { pc_indent : string; pc_next_anon_func : unit -> string; pc_debug : bool; pc_com : Common.context; } let has_feature pctx = Common.has_feature pctx.pc_com let add_feature pctx = Common.add_feature pctx.pc_com let create_context = let n = ref (-1) in (fun indent com debug -> { pc_indent = indent; pc_next_anon_func = (fun () -> incr n; Printf.sprintf "anon_%i" !n); pc_debug = debug; pc_com = com; } ) let tabs = ref "" let opt o f s = match o with | None -> "" | Some v -> s ^ (f v) (* TODO: both of these are crazy *) let is_type p t = (fun r -> let x = t_infos r in (String.concat "." (fst x.mt_path)) = p && (snd x.mt_path) = t ) let is_type1 p s = (fun t -> match follow t with | TInst(c,_) -> (is_type p s)(TClassDecl c) | TAbstract(a,_) -> (is_type p s)(TAbstractDecl a) | TEnum(en,_) -> (is_type p s)(TEnumDecl en) | _ -> false ) let is_underlying_string t = match follow t with | TAbstract(a,tl) -> (is_type1 "" "str")(Abstract.get_underlying_type a tl) | _ -> false let is_underlying_array t = match follow t with | TAbstract(a,tl) -> (is_type1 "" "list")(Abstract.get_underlying_type a tl) | _ -> false let rec is_anon_or_dynamic t = match follow t with | TAbstract(a,tl) -> is_anon_or_dynamic (Abstract.get_underlying_type a tl) | TAnon _ | TDynamic _ -> true | _ -> false let handle_keywords s = KeywordHandler.handle_keywords s let print_unop = function | Increment | Decrement -> assert false | Not -> "not " | Neg -> "-"; | NegBits -> "~" let print_binop = function | OpAdd -> "+" | OpSub -> "-" | OpMult -> "*" | OpDiv -> "/" | OpAssign -> "=" | OpEq -> "==" | OpNotEq -> "!=" | OpGt -> ">" | OpGte -> ">=" | OpLt -> "<" | OpLte -> "<=" | OpAnd -> "&" | OpOr -> "|" | OpXor -> "^" | OpBoolAnd -> "and" | OpBoolOr -> "or" | OpShl -> "<<" | OpShr -> ">>" | OpUShr -> ">>" | OpMod -> "%" | OpInterval | OpArrow | OpAssignOp _ -> assert false let print_string s = Printf.sprintf "\"%s\"" (Ast.s_escape s) let print_constant = function | TThis -> "self" | TNull -> "None" | TBool(true) -> "True" | TBool(false) -> "False" | TString(s) -> print_string s | TInt(i) -> Int32.to_string i | TFloat s -> s | TSuper -> "super" let print_base_type tp = try begin match Meta.get Meta.Native tp.mt_meta with | _,[EConst(String s),_],_ -> s | _ -> raise Not_found end with Not_found -> let pack,name = tp.mt_path in (String.concat "_" pack) ^ (if pack = [] then name else "_" ^ name) let print_module_type mt = print_base_type (t_infos mt) let print_metadata (name,_,_) = Printf.sprintf "@%s" name let rec remove_outer_parens e = match e.eexpr with | TParenthesis(e) -> remove_outer_parens e | TMeta((Meta.Custom ":ternaryIf",_,_),_) -> e | TMeta(_,e) -> remove_outer_parens e | _ -> e let print_args args p = let had_value = ref false in let had_var_args = ref false in let had_kw_args = ref false in let sl = List.map (fun (v,cto) -> let check_err () = if !had_var_args || !had_kw_args then error "Arguments after KwArgs/VarArgs are not allowed" p in KeywordHandler.check_var_declaration v; let name = handle_keywords v.v_name in match follow v.v_type with | TAbstract({a_path = ["python"],"KwArgs"},_) -> if !had_kw_args then error "Arguments after KwArgs are not allowed" p; had_kw_args := true; "**" ^ name | TAbstract({a_path = ["python"],"VarArgs"},_) -> check_err (); had_var_args := true; "*" ^ name | _ -> check_err (); name ^ match cto with | None when !had_value -> " = None" | None -> "" | Some ct -> had_value := true; Printf.sprintf " = %s" (print_constant ct) ) args in String.concat "," sl let rec print_op_assign_right pctx e = match e.eexpr with | TIf({eexpr = TParenthesis econd},eif,Some eelse) | TIf(econd,eif,Some eelse) -> Printf.sprintf "%s if %s else %s" (print_expr pctx eif) (print_expr pctx econd) (print_expr pctx eelse) | _ -> print_expr pctx (remove_outer_parens e) and print_var pctx v eo = match eo with | Some ({eexpr = TFunction tf} as e) -> print_function pctx tf (Some v.v_name) e.epos | _ -> let s_init = match eo with | None -> "None" | Some e -> print_op_assign_right pctx e in Printf.sprintf "%s = %s" (handle_keywords v.v_name) s_init and print_function pctx tf name p = let s_name = match name with | None -> pctx.pc_next_anon_func() | Some s -> handle_keywords s in let s_args = print_args tf.tf_args p in let s_expr = print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} tf.tf_expr in Printf.sprintf "def %s(%s):\n%s\t%s" s_name s_args pctx.pc_indent s_expr and print_tarray_list pctx e1 e2 = let s1 = (print_expr pctx e1) in let s2 = (print_expr pctx e2) in let default = Printf.sprintf "python_internal_ArrayImpl._get(%s, %s)" s1 s2 in let handle_index = match e2.eexpr with | TConst TInt index -> if Int32.to_int index >= 0 then Printf.sprintf "(%s[%s] if %s < len(%s) else None)" s1 s2 s2 s1 else "None" | TLocal _ -> Printf.sprintf "(%s[%s] if %s >= 0 and %s < len(%s) else None)" s1 s2 s2 s2 s1 | _ -> default in match e1.eexpr with | TLocal _ -> handle_index | TField ({eexpr=(TConst TThis | TLocal _)},_) -> handle_index | _ -> default and is_safe_string pctx x = let follow_parens e = match e.eexpr with | TParenthesis e -> e | _ -> e in match (follow_parens x).eexpr with | TBinop(OpAdd, e1, e2) -> is_safe_string pctx e1 && is_safe_string pctx e2 | TCall (e1,_) -> let id = print_expr pctx (follow_parens e1) in (match id with | "Std.string" -> true | _ -> false) | TConst (TString s) -> true | _ -> false and print_expr pctx e = let indent = pctx.pc_indent in let print_expr_indented e = print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e in match e.eexpr with | TConst ct -> print_constant ct | TTypeExpr mt -> print_module_type mt | (TLocal v | TParenthesis({ eexpr = (TLocal v) })) -> handle_keywords v.v_name | TEnumParameter(e1,_,index) -> Printf.sprintf "%s.params[%i]" (print_expr pctx e1) index | TArray(e1,e2) when (is_type1 "" "list")(e1.etype) || is_underlying_array e1.etype -> print_tarray_list pctx e1 e2 | TArray({etype = t} as e1,e2) when is_anon_or_dynamic t -> Printf.sprintf "HxOverrides.arrayGet(%s, %s)" (print_expr pctx e1) (print_expr pctx e2) | TArray(e1,e2) -> Printf.sprintf "%s[%s]" (print_expr pctx e1) (print_expr pctx e2) | TBinop(OpAssign, {eexpr = TArray(e1,e2)}, e3) when (is_type1 "" "list")(e1.etype) || is_underlying_array e1.etype -> Printf.sprintf "python_internal_ArrayImpl._set(%s, %s, %s)" (print_expr pctx e1) (print_expr pctx e2) (print_expr pctx e3) | TBinop(OpAssign,{eexpr = TArray({etype = t} as e1,e2)},e3) when is_anon_or_dynamic t -> Printf.sprintf "HxOverrides.arraySet(%s,%s,%s)" (print_expr pctx e1) (print_expr pctx e2) (print_expr pctx e3) | TBinop(OpAssign,{eexpr = TArray(e1,e2)},e3) -> Printf.sprintf "%s[%s] = %s" (print_expr pctx e1) (print_expr pctx e2) (print_expr pctx (remove_outer_parens e3) ) | TBinop(OpAssign,{eexpr = TField(ef1,fa)},e2) -> Printf.sprintf "%s = %s" (print_field pctx ef1 fa true) (print_op_assign_right pctx e2) | TBinop(OpAssign,e1,e2) -> Printf.sprintf "%s = %s" (print_expr pctx e1) (print_expr pctx (remove_outer_parens e2)) | TBinop(op,e1,({eexpr = TBinop(_,_,_)} as e2)) -> print_expr pctx { e with eexpr = TBinop(op, e1, { e2 with eexpr = TParenthesis(e2) })} | TBinop(OpEq,{eexpr = TCall({eexpr = TLocal {v_name = "__typeof__"}},[e1])},e2) -> begin match e2.eexpr with | TConst(TString s) -> begin match s with | "string" -> Printf.sprintf "Std._hx_is(%s, str)" (print_expr pctx e1) | "boolean" -> Printf.sprintf "Std._hx_is(%s, bool)" (print_expr pctx e1) | "number" -> Printf.sprintf "Std._hx_is(%s, float)" (print_expr pctx e1) | _ -> assert false end | _ -> assert false end | TBinop(OpEq,e1,({eexpr = TConst TNull} as e2)) -> Printf.sprintf "(%s is %s)" (print_expr pctx e1) (print_expr pctx e2) | TBinop(OpNotEq,e1,({eexpr = TConst TNull} as e2)) -> Printf.sprintf "(%s is not %s)" (print_expr pctx e1) (print_expr pctx e2) | TBinop(OpEq|OpNotEq as op,e1, e2) -> let ops = match op with | OpEq -> "is", "==", "HxOverrides.eq" | OpNotEq -> "is not", "!=", "not HxOverrides.eq" | _ -> assert false in let third (_,_,x) = x in let fst (x,_,_) = x in let snd (_,x,_) = x in let is_list_or_anon x = begin match x with | TInst({cl_path = [],("list")},_) -> true | TAnon _ -> true | _ -> false end in let is_const_byte x = match x.eexpr with | TConst TInt x -> let x = Int32.to_int x in x >= 0 && x <= 256 | _ -> false in (match follow e1.etype, follow e2.etype with | TAbstract({a_path = [],("Int")}, _),TAbstract({a_path = [],("Int")}, _) when is_const_byte e2 || is_const_byte e1 -> Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (snd ops) (print_expr pctx e2) (* the following optimization causes a problem with polygonal unit tests see: https://github.com/HaxeFoundation/haxe/issues/2952 *) (* Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (fst ops) (print_expr pctx e2) *) | TInst({cl_path = [],("list")},_), _ -> Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (fst ops) (print_expr pctx e2) | TDynamic _, TDynamic _ -> Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2) | TDynamic _, x | x, TDynamic _ when is_list_or_anon x -> Printf.sprintf "%s(%s,%s)" (third ops) (print_expr pctx e1) (print_expr pctx e2) | _,_ -> Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (snd ops) (print_expr pctx e2)) | TBinop(OpMod,e1,e2) when (is_type1 "" "Int")(e1.etype) && (is_type1 "" "Int")(e2.etype) -> (match e1.eexpr with | TConst(TInt(x)) when (Int32.to_int x) >= 0 -> (* constant optimization *) Printf.sprintf "%s %% %s" (print_expr pctx e1) (print_expr pctx e2) | _ -> Printf.sprintf "HxOverrides.mod(%s, %s)" (print_expr pctx e1) (print_expr pctx e2)) | TBinop(OpMod,e1,e2) -> Printf.sprintf "HxOverrides.modf(%s, %s)" (print_expr pctx e1) (print_expr pctx e2) | TBinop(OpUShr,e1,e2) -> Printf.sprintf "HxOverrides.rshift(%s, %s)" (print_expr pctx e1) (print_expr pctx e2) | TBinop(OpAdd,e1,e2) when (is_type1 "" "str")(e.etype) || is_underlying_string e.etype -> let rec safe_string ex = match ex.eexpr, ex.etype with | e, _ when is_safe_string pctx ex -> print_expr pctx ex | TBinop(OpAdd, e1, e2), x when (is_type1 "" "str")(x) -> Printf.sprintf "(%s + %s)" (safe_string e1) (safe_string e2) | (TLocal(_)),x when (is_type1 "" "str")(x) -> (* we could add this pattern too, but is it sideeffect free?? | TField({ eexpr = TLocal(_)},_) *) let s = (print_expr pctx ex) in Printf.sprintf "(\"null\" if %s is None else %s)" s s | _,x when (is_type1 "" "str")(x) -> Printf.sprintf "HxOverrides.stringOrNull(%s)" (print_expr pctx ex) | _,_ -> if has_feature pctx "Std.string" then Printf.sprintf "Std.string(%s)" (print_expr pctx ex) else Printf.sprintf "str(%s)" (print_expr pctx ex) in let e1_str = safe_string e1 in let e2_str = safe_string e2 in Printf.sprintf "(%s + %s)" e1_str e2_str | TBinop(OpAdd,e1,e2) when (match follow e.etype with TDynamic _ -> true | _ -> false) -> Printf.sprintf "python_Boot._add_dynamic(%s,%s)" (print_expr pctx e1) (print_expr pctx e2) | TBinop(op,e1,e2) -> Printf.sprintf "(%s %s %s)" (print_expr pctx e1) (print_binop op) (print_expr pctx e2) | TField(e1,fa) -> print_field pctx e1 fa false | TParenthesis e1 -> Printf.sprintf "(%s)" (print_expr pctx e1) | TObjectDecl fl -> let fl2 = ref fl in begin match follow e.etype with | TAnon an -> PMap.iter (fun s cf -> if not (List.mem_assoc s fl) then fl2 := (s,null cf.cf_type cf.cf_pos) :: !fl2 ) an.a_fields | _ -> () end; Printf.sprintf "_hx_AnonObject(%s)" (print_exprs_named pctx ", " !fl2) | TArrayDecl el -> Printf.sprintf "[%s]" (print_exprs pctx ", " el) | TCall(e1,el) -> print_call pctx e1 el e | TNew(c,_,el) -> let id = print_base_type (t_infos (TClassDecl c)) in Printf.sprintf "%s(%s)" id (print_exprs pctx ", " el) | TUnop(Not,Prefix,e1) -> Printf.sprintf "(%s%s)" (print_unop Not) (print_expr pctx e1) | TUnop(op,Prefix,e1) -> Printf.sprintf "%s%s" (print_unop op) (print_expr pctx e1) | TFunction tf -> print_function pctx tf None e.epos | TVar (v,eo) -> KeywordHandler.check_var_declaration v; print_var pctx v eo | TBlock [] -> Printf.sprintf "pass" | TBlock [{ eexpr = TBlock _} as b] -> print_expr pctx b | TBlock el -> let old = !tabs in tabs := pctx.pc_indent; let s = print_block_exprs pctx ("\n" ^ !tabs) pctx.pc_debug el in tabs := old; Printf.sprintf "%s" s | TIf(econd,eif,(Some {eexpr = TIf _} as eelse)) -> print_if_else pctx econd eif eelse true | TIf(econd,eif,eelse) -> print_if_else pctx econd eif eelse false | TWhile(econd,e1,NormalWhile) -> Printf.sprintf "while %s:\n%s\t%s" (print_expr pctx (remove_outer_parens econd)) indent (print_expr_indented e1) | TWhile(econd,e1,DoWhile) -> error "Currently not supported" e.epos | TTry(e1,catches) -> print_try pctx e1 catches | TReturn eo -> Printf.sprintf "return%s" (opt eo (print_op_assign_right pctx) " ") | TBreak -> "break" | TContinue -> "continue" | TThrow e1 -> let rec is_native_exception t = match Abstract.follow_with_abstracts t with | TInst ({ cl_path = [],"BaseException" }, _) -> true | TInst ({ cl_super = Some csup }, _) -> is_native_exception (TInst(fst csup, snd csup)) | _ -> false in if is_native_exception e1.etype then Printf.sprintf "raise %s" (print_expr pctx e1) else Printf.sprintf "raise _HxException(%s)" (print_expr pctx e1) | TCast(e1,None) -> print_expr pctx e1 | TMeta((Meta.Custom ":ternaryIf",_,_),{eexpr = TIf(econd,eif,Some eelse)}) -> Printf.sprintf "(%s if %s else %s)" (print_expr pctx eif) (print_expr pctx econd) (print_expr pctx eelse) | TMeta(_,e1) -> print_expr pctx e1 | TSwitch _ | TCast(_, Some _) | TFor _ | TUnop(_,Postfix,_) -> assert false and print_if_else pctx econd eif eelse as_elif = let econd1 = match econd.eexpr with | TParenthesis e -> e | _ -> econd in let if_str = print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} eif in let indent = pctx.pc_indent in let else_str = if as_elif then opt eelse (print_expr pctx) "el" else opt eelse (print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent}) (Printf.sprintf "else:\n%s\t" indent) in let else_str = if else_str = "" then "" else "\n" ^ indent ^ else_str in Printf.sprintf "if %s:\n%s\t%s%s" (print_expr pctx (remove_outer_parens econd1)) indent if_str else_str and print_field pctx e1 fa is_assign = let obj = match e1.eexpr with | TConst TSuper -> "super()" | _ -> print_expr pctx e1 in let name = field_name fa in let is_extern = (match fa with | FInstance(c,_,_) -> c.cl_extern | FStatic(c,_) -> c.cl_extern | _ -> false) in let do_default () = Printf.sprintf "%s.%s" obj (if is_extern then name else (handle_keywords name)) in let call_override s = match s with | "iterator" | "toUpperCase" | "toLowerCase" | "pop" | "shift" | "join" | "push" | "map" | "filter" -> true | _ -> false in match fa with (* we need to get rid of these cases in the transformer, how is this handled in js *) | FInstance(c,_,{cf_name = "length"}) when (is_type "" "list")(TClassDecl c) -> Printf.sprintf "len(%s)" (print_expr pctx e1) | FInstance(c,_,{cf_name = "length"}) when (is_type "" "str")(TClassDecl c) -> Printf.sprintf "len(%s)" (print_expr pctx e1) | FStatic(c,{cf_name = "fromCharCode"}) when (is_type "" "str")(TClassDecl c) -> Printf.sprintf "HxString.fromCharCode" | FStatic({cl_path = ["python";"internal"],"UBuiltins"},{cf_name = s}) -> s | FInstance _ | FStatic _ -> do_default () | FAnon cf when is_assign && call_override(name) -> begin match follow cf.cf_type with | TFun([],_) -> Printf.sprintf "python_lib_FuncTools.partial(HxOverrides.%s, %s)" name obj | _ -> do_default() end | _ -> do_default() and print_try pctx e1 catches = let has_catch_all = List.exists (fun (v,_) -> match v.v_type with | TDynamic _ -> true | _ -> false ) catches in let has_only_catch_all = has_catch_all && begin match catches with | [_] -> true | _ -> false end in let print_catch pctx i (v,e) = KeywordHandler.check_var_declaration v; let is_empty_expr = begin match e.eexpr with | TBlock [] -> true | _ -> false end in let indent = pctx.pc_indent in (* Don't generate assignment to catch variable when catch expression is an empty block *) let assign = if is_empty_expr then "" else Printf.sprintf "%s = _hx_e1\n%s" v.v_name indent in let handle_base_type bt = let t = print_base_type bt in let print_type_check t_str = Printf.sprintf "if isinstance(_hx_e1, %s):\n%s\t%s\t%s" t_str indent assign (print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e) in let res = match t with | "str" -> print_type_check "str" | "Bool" -> print_type_check "bool" | "Int" -> print_type_check "int" | "Float" -> print_type_check "float" | t -> print_type_check t in if i > 0 then indent ^ "el" ^ res else res in match follow v.v_type with | TDynamic _ -> begin if has_only_catch_all then Printf.sprintf "%s%s" assign (print_expr pctx e) else (* Dynamic is always the last block *) Printf.sprintf "%selse:\n\t%s%s\t%s" indent indent assign (print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e) end | TInst(c,_) -> handle_base_type (t_infos (TClassDecl c)) | TEnum(en,_) -> handle_base_type (t_infos (TEnumDecl en)) | TAbstract(a,_) -> handle_base_type (t_infos (TAbstractDecl a)) | _ -> assert false in let indent = pctx.pc_indent in let print_expr_indented e = print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e in let try_str = Printf.sprintf "try:\n%s\t%s\n%s" indent (print_expr_indented e1) indent in let except = if has_feature pctx "has_throw" then Printf.sprintf "except Exception as _hx_e:\n%s\t_hx_e1 = _hx_e.val if isinstance(_hx_e, _HxException) else _hx_e\n%s\t" indent indent else Printf.sprintf "except Exception as _hx_e:\n%s\t_hx_e1 = _hx_e\n%s\t" indent indent in let catch_str = String.concat (Printf.sprintf "\n") (ExtList.List.mapi (fun i catch -> print_catch {pctx with pc_indent = "\t" ^ pctx.pc_indent} i catch) catches) in let except_end = if not has_catch_all then Printf.sprintf "\n%s\telse:\n%s\t\traise _hx_e" indent indent else "" in Printf.sprintf "%s%s%s%s" try_str except catch_str except_end and print_call2 pctx e1 el = let id = print_expr pctx e1 in match id,el with | "__define_feature__",[_;e] -> print_expr pctx e | "super",_ -> let s_el = (print_call_args pctx e1 el) in Printf.sprintf "super().__init__(%s)" s_el | ("python_Syntax._pythonCode"),[({ eexpr = TConst (TString code) } as ecode); {eexpr = TArrayDecl tl}] -> let exprs = Array.of_list tl in let i = ref 0 in let err msg = let pos = { ecode.epos with pmin = ecode.epos.pmin + !i } in error msg pos in let regex = Str.regexp "[{}]" in let rec loop m = match m with | [] -> "" | Str.Text txt :: tl -> i := !i + String.length txt; txt ^ (loop tl) | Str.Delim a :: Str.Delim b :: tl when a = b -> i := !i + 2; a ^ (loop tl) | Str.Delim "{" :: Str.Text n :: Str.Delim "}" :: tl -> (try let expr = Array.get exprs (int_of_string n) in let txt = print_expr pctx expr in i := !i + 2 + String.length n; txt ^ (loop tl) with | Failure "int_of_string" -> err ("Index expected. Got " ^ n) | Invalid_argument _ -> err ("Out-of-bounds pythonCode special parameter: " ^ n)) | Str.Delim x :: _ -> err ("Unexpected " ^ x) in loop (Str.full_split regex code) | ("python_Syntax._pythonCode"), [e] -> print_expr pctx e | "python_Syntax._callNamedUntyped",el -> let res,fields = match List.rev el with | {eexpr = TObjectDecl fields} :: el -> List.rev el,fields | _ -> assert false in begin match res with | e1 :: [] -> Printf.sprintf "%s(%s)" (print_expr pctx e1) (print_params_named pctx ", " fields) | e1 :: el -> Printf.sprintf "%s(%s, %s)" (print_expr pctx e1) (print_exprs pctx ", " el) (print_params_named pctx ", " fields) | [] -> Printf.sprintf "%s(%s)" (print_expr pctx e1) (print_params_named pctx ", " fields) end | "python_Syntax.varArgs",[e1] -> "*" ^ (print_expr pctx e1) | "python_Syntax.call" ,e1 :: [{eexpr = TArrayDecl el}]-> Printf.sprintf "%s(%s)" (print_expr pctx e1) (print_exprs pctx ", " el) | "python_Syntax.field",[e1;{eexpr = TConst(TString id)}] -> Printf.sprintf "%s.%s" (print_expr pctx e1) id | "python_Syntax._tuple", [{eexpr = TArrayDecl el}] -> (match el with | [e] -> Printf.sprintf "(%s,)" (print_expr pctx e) | _ -> Printf.sprintf "(%s)" (print_exprs pctx ", " el)) | "python_Syntax._arrayAccess", e1 :: {eexpr = TArrayDecl el} :: etrail -> let trailing_colon = match etrail with | [{eexpr = TConst(TBool(true))}] -> true | _ -> false in Printf.sprintf "%s[%s%s]" (print_expr pctx e1) (print_exprs pctx ":" el) (if trailing_colon then ":" else "") | "python_Syntax.isIn",[e1;e2] -> Printf.sprintf "%s in %s" (print_expr pctx e1) (print_expr pctx e2) | "python_Syntax.delete",[e1] -> Printf.sprintf "del %s" (print_expr pctx e1) | "python_Syntax.binop",[e0;{eexpr = TConst(TString id)};e2] -> Printf.sprintf "(%s %s %s)" (print_expr pctx e0) id (print_expr pctx e2) | "python_Syntax.assign",[e0;e1] -> Printf.sprintf "%s = %s" (print_expr pctx e0) (print_expr pctx e1) | "python_Syntax.arraySet",[e1;e2;e3] -> Printf.sprintf "%s[%s] = %s" (print_expr pctx e1) (print_expr pctx e2) (print_expr pctx e3) | "python_Syntax._newInstance", e1 :: [{eexpr = TArrayDecl el}] -> Printf.sprintf "%s(%s)" (print_expr pctx e1) (print_exprs pctx ", " el) | "python_Syntax.opPow", [e1;e2] -> Printf.sprintf "(%s ** %s)" (print_expr pctx e1) (print_expr pctx e2) | "python_Syntax._foreach",[e1;e2;e3] -> let pctx = {pctx with pc_indent = "\t" ^ pctx.pc_indent} in let i = pctx.pc_indent in Printf.sprintf "for %s in %s:\n%s%s" (print_expr pctx e1) (print_expr pctx e2) i (print_expr pctx e3) | _,el -> Printf.sprintf "%s(%s)" id (print_call_args pctx e1 el) and print_call pctx e1 el call_expr = let get_native_fields t = match follow t with | TAnon(a) -> let fold f cf acc = if Meta.has Meta.Native cf.cf_meta then begin let _, args, mp = Meta.get Meta.Native cf.cf_meta in match args with | [( EConst(String s),_)] -> PMap.add f s acc | _ -> acc end else acc in let mapping = PMap.foldi fold a.a_fields PMap.empty in mapping | _ -> PMap.empty in let native_fields_str native_fields = let fold_dict k v acc = let prefix = if acc = "" then "" else "," in Printf.sprintf "%s%s\"%s\":\"%s\"" acc prefix (handle_keywords k) v in PMap.foldi fold_dict native_fields "" in match e1.eexpr, el with | TLocal { v_name = "`trace" }, [e;infos] -> if has_feature pctx "haxe.Log.trace" then begin "haxe_Log.trace(" ^ (print_expr pctx e) ^ "," ^ (print_expr pctx infos) ^ ")" end else if is_safe_string pctx e then "print(" ^ (print_expr pctx e) ^ ")" else "print(str(" ^ (print_expr pctx e) ^ "))" | TField(e1,((FAnon {cf_name = (("join" | "push" | "map" | "filter") as s)}) | FDynamic (("join" | "push" | "map" | "filter") as s))), [x] -> Printf.sprintf "HxOverrides.%s(%s, %s)" s (print_expr pctx e1) (print_expr pctx x) | TField(e1,((FAnon {cf_name = (("iterator" | "toUpperCase" | "toLowerCase" | "pop" | "shift") as s)}) | FDynamic (("iterator" | "toUpperCase" | "toLowerCase" | "pop" | "shift") as s))), [] -> Printf.sprintf "HxOverrides.%s(%s)" s (print_expr pctx e1) | TField(_, (FStatic({cl_path = ["python"; "_KwArgs"], "KwArgs_Impl_"},{ cf_name="fromT" }))), [e2] -> let t = match follow call_expr.etype with | TAbstract(_, [t]) -> t | _ -> assert false in let native_fields = get_native_fields t in if PMap.is_empty native_fields then print_call2 pctx e1 el else let s1 = native_fields_str native_fields in Printf.sprintf "python__KwArgs_KwArgs_Impl_.fromT(HxOverrides.mapKwArgs(%s, {%s}))" (print_expr pctx e2) s1 | TField(_, (FStatic({cl_path = ["python"; "_KwArgs"], "KwArgs_Impl_"},{ cf_name="toDictHelper" }))), [e2; et] -> let native_fields = get_native_fields et.etype in if PMap.is_empty native_fields then print_call2 pctx e1 el else let s1 = native_fields_str native_fields in Printf.sprintf "python__KwArgs_KwArgs_Impl_.toDictHelper(HxOverrides.reverseMapKwArgs(%s, {%s}), None)" (print_expr pctx e2) s1 | _,_ -> print_call2 pctx e1 el and print_call_args pctx e1 el = let print_arg pctx i x = let e = match x.eexpr, follow x.etype with | TConst TNull, TAbstract({a_path = ["python"],"KwArgs"},_) -> "{}" | TConst TNull, TAbstract({a_path = ["python"],"VarArgs"},_) -> "[]" | _ -> (print_expr pctx x) in let prefix = match e1.eexpr, follow x.etype with (* the should not apply for the instance methods of the abstract itself *) | TField(_, FStatic({cl_path = ["python"; "_KwArgs"],"KwArgs_Impl_"},f)), _ when i == 0 && Meta.has Meta.Impl f.cf_meta -> "" | TField(_, FStatic({cl_path = ["python"; "_VarArgs"],"VarArgs_Impl_"},f)), _ when i == 0 && Meta.has Meta.Impl f.cf_meta -> "" | _, TAbstract({a_path = ["python"],"KwArgs"},_) -> "**" | _, TAbstract({a_path = ["python"],"VarArgs"},_) -> "*" | _, _ -> "" in prefix ^ e in String.concat "," (ExtList.List.mapi (print_arg pctx) el) and print_exprs pctx sep el = String.concat sep (List.map (print_expr pctx) el) and last_debug_comment = ref ("") and print_block_exprs pctx sep print_debug_comment el = if print_debug_comment then begin let el = List.fold_left (fun acc e -> let line = Lexer.get_error_line e.epos in let debug_line = (Printf.sprintf "# %s:%i" e.epos.pfile line) in let res = if (!last_debug_comment) <> debug_line then (print_expr pctx e) :: debug_line :: acc else (print_expr pctx e) :: acc in last_debug_comment := debug_line; res ) [] el in String.concat sep (List.rev el) end else print_exprs pctx sep el and print_exprs_named pctx sep fl = let args = String.concat sep (List.map (fun (s,e) -> Printf.sprintf "'%s': %s" (handle_keywords s) (print_expr pctx e)) fl) in Printf.sprintf "{%s}" args and print_params_named pctx sep fl = let args = String.concat sep (List.map (fun (s,e) -> Printf.sprintf "%s= %s" (handle_keywords s) (print_expr pctx e)) fl) in Printf.sprintf "%s" args let handle_keywords s = KeywordHandler.handle_keywords s end module Generator = struct type context = { com : Common.context; buf : Buffer.t; packages : (string,int) Hashtbl.t; mutable static_inits : (unit -> unit) list; mutable class_inits : (unit -> unit) list; mutable indent_count : int; transform_time : float; print_time : float; } let has_feature ctx = Common.has_feature ctx.com let add_feature ctx = Common.add_feature ctx.com type class_field_infos = { cfd_fields : string list; cfd_props : string list; cfd_methods : string list; } type import_type = | IModule of string | IObject of string * string let mk_context com = { com = com; buf = Buffer.create 16000; packages = Hashtbl.create 0; static_inits = []; class_inits = []; indent_count = 0; transform_time = 0.; print_time = 0.; } (* Transformer interface *) let transform_expr e = (* let e = Codegen.UnificationCallback.run Transformer.check_unification e in *) Transformer.transform e let transform_to_value e = (* let e = Codegen.UnificationCallback.run Transformer.check_unification e in *) Transformer.transform_to_value e (* Printer interface *) let get_path mt = Printer.print_base_type mt let tfunc_str f pctx name p = Printer.print_function pctx f name p let texpr_str e pctx = Printer.print_expr pctx e let handle_keywords s = Printer.handle_keywords s (* Helper *) let get_full_name mt = (* TODO: haxe source is crazy *) s_type_path mt.mt_path let collect_class_field_data cfl = let fields = DynArray.create () in let props = DynArray.create () in let methods = DynArray.create () in List.iter (fun cf -> match cf.cf_kind with | Var({v_read = AccResolve}) -> () | Var _ when is_extern_field cf -> () | Var({v_read = AccCall}) -> if Meta.has Meta.IsVar cf.cf_meta then DynArray.add fields cf.cf_name else DynArray.add props cf.cf_name | Var _ -> DynArray.add fields cf.cf_name | _ -> DynArray.add methods cf.cf_name ) cfl; { cfd_fields = DynArray.to_list fields; cfd_props = DynArray.to_list props; cfd_methods = DynArray.to_list methods; } let collect_class_statics_data cfl = let fields = DynArray.create () in List.iter (fun cf -> if not (is_extern_field cf) then DynArray.add fields cf.cf_name ) cfl; DynArray.to_list fields let filter_py_metas metas = List.filter (fun (n,_,_) -> match n with Meta.Custom ":python" -> true | _ -> false) metas let get_members_with_init_expr c = List.filter (fun cf -> match cf.cf_kind with | Var _ when is_extern_field cf -> false | Var _ when cf.cf_expr = None -> true | _ -> false ) c.cl_ordered_fields (* Printing *) let spr ctx s = Buffer.add_string ctx.buf s let spr_line ctx s = Buffer.add_string ctx.buf s; Buffer.add_string ctx.buf "\n" let print ctx = Printf.kprintf (fun s -> begin Buffer.add_string ctx.buf s end) let newline ctx = if not (Buffer.length ctx.buf = 0) then spr ctx "\n" (* Generating functions *) let gen_py_metas ctx metas indent = List.iter (fun (n,el,_) -> match el with | [EConst(String s),_] -> print ctx "%s@%s\n" indent s | _ -> assert false ) metas let gen_expr ctx e field indent = let pctx = Printer.create_context ("\t" ^ indent) ctx.com ctx.com.debug in let e = match e.eexpr with | TFunction(f) -> {e with eexpr = TBlock [e]} | _ -> e in let expr2 = transform_to_value e in let name = "_hx_init_" ^ (String.concat "_" (ExtString.String.nsplit field ".")) in let maybe_split_expr expr2 = match expr2.eexpr with | TBlock es when es <> [] && field <> "" -> begin match List.rev es with | e_last :: el -> let new_last = {e_last with eexpr = TReturn (Some e_last)} in let new_block = {expr2 with eexpr = TBlock (List.rev (new_last :: el))} in let v_name = alloc_var name (tfun [] e_last.etype) in let f_name = mk (TLocal v_name) v_name.v_type e_last.epos in let call_f = mk (TCall(f_name,[])) e_last.etype e_last.epos in Some new_block,call_f | _ -> assert false end | _ -> None,expr2 in let r = maybe_split_expr expr2 in match r with | Some e1,e2 -> let expr_string_1 = texpr_str e1 pctx in let expr_string_2 = texpr_str e2 pctx in print ctx "%sdef %s():\n\t%s" indent name expr_string_1; newline ctx; print ctx "%s%s = %s" indent field expr_string_2; | None,e2 -> let expr_string_2 = texpr_str e2 pctx in if field = "" then spr ctx expr_string_2 else print ctx "%s%s = %s" indent field expr_string_2 let gen_func_expr ctx e c name metas extra_args indent stat p = let pctx = Printer.create_context indent ctx.com ctx.com.debug in let e = match e.eexpr with | TFunction(f) -> let args = List.map (fun s -> alloc_var s t_dynamic,None ) extra_args in {e with eexpr = TFunction {f with tf_args = args @ f.tf_args}} | _ -> e in if stat then begin newline ctx; spr ctx indent; spr ctx "@staticmethod\n" end; let expr1 = transform_expr e in let expr_string = match expr1.eexpr with | TFunction f -> tfunc_str f pctx (Some name) p | _ -> Printf.sprintf "%s = %s" name (texpr_str expr1 pctx) in gen_py_metas ctx metas indent; spr ctx indent; spr ctx expr_string let gen_class_constructor ctx c cf = let member_inits = get_members_with_init_expr c in let py_metas = filter_py_metas cf.cf_meta in begin match cf.cf_expr with | Some ({eexpr = TFunction f} as ef) -> let ethis = mk (TConst TThis) (TInst(c,List.map snd c.cl_params)) cf.cf_pos in let member_data = List.map (fun cf -> let ef = mk (TField(ethis,FInstance(c,[],cf))) cf.cf_type cf.cf_pos in (* TODO *) mk (TBinop(OpAssign,ef,null ef.etype ef.epos)) ef.etype ef.epos ) member_inits in let e = concat (mk (TBlock member_data) ctx.com.basic.tvoid cf.cf_pos) f.tf_expr in let ef = {ef with eexpr = TFunction {f with tf_expr = e}} in cf.cf_expr <- Some ef; newline ctx; newline ctx; gen_func_expr ctx ef c "__init__" py_metas ["self"] "\t" false cf.cf_pos | _ -> assert false end let gen_class_field ctx c p cf = let field = handle_keywords cf.cf_name in begin match cf.cf_expr with | None -> ()(* print ctx "\t# var %s" field *) | Some e -> newline ctx; newline ctx; begin match cf.cf_kind with | Method _ -> let py_metas = filter_py_metas cf.cf_meta in gen_func_expr ctx e c field py_metas ["self"] "\t" false cf.cf_pos; | _ -> gen_expr ctx e (Printf.sprintf "# var %s" field) "\t"; end end let gen_class_empty_constructor ctx p cfl = if has_feature ctx "Type.createEmptyInstance" then begin newline ctx; newline ctx; print ctx "\t@staticmethod\n\tdef _hx_empty_init(_hx_o):"; let found_fields = ref false in List.iter (fun cf -> match cf.cf_kind with | Var ({v_read = AccResolve | AccCall}) -> () | Var _ -> found_fields := true; newline ctx; print ctx "\t\t_hx_o.%s = None" (handle_keywords cf.cf_name) | _ -> () ) cfl; if not !found_fields then spr ctx "\t\tpass" end else begin newline ctx end let gen_class_statics ctx c p = let methods, other = List.partition (fun cf -> match cf.cf_kind with | Method _ -> (match cf.cf_expr with Some _ -> true | _ -> false) | _ -> false ) c.cl_ordered_statics in (* generate non methods *) let has_empty_static_vars = ref false in List.iter (fun cf -> let p = get_path (t_infos (TClassDecl c)) in let field = handle_keywords cf.cf_name in match cf.cf_expr with | None -> has_empty_static_vars := true; newline ctx; print ctx "\t%s = None" field | Some e -> (let f = fun () -> newline ctx; gen_expr ctx e (Printf.sprintf "%s.%s" p field) ""; in ctx.static_inits <- f :: ctx.static_inits) ) other; (* generate static methods *) let has_static_methods = ref false in List.iter (fun cf -> has_static_methods := true; let field = handle_keywords cf.cf_name in let py_metas = filter_py_metas cf.cf_meta in let e = match cf.cf_expr with Some e -> e | _ -> assert false in newline ctx; gen_func_expr ctx e c field py_metas [] "\t" true cf.cf_pos; ) methods; !has_static_methods || !has_empty_static_vars let gen_class_init ctx c = match c.cl_init with | None -> () | Some e -> let is_math = c.cl_path = ([], "Math") in let math_feature = has_feature ctx "Math" in let f = if is_math && not math_feature then fun () -> () else fun () -> let e = transform_expr e in newline ctx; spr ctx (texpr_str e (Printer.create_context "" ctx.com ctx.com.debug)); in ctx.class_inits <- f :: ctx.class_inits let gen_class ctx c = if not c.cl_extern then begin let is_nativegen = Meta.has Meta.NativeGen c.cl_meta in let mt = (t_infos (TClassDecl c)) in let p = get_path mt in let p_name = get_full_name mt in let x = collect_class_field_data c.cl_ordered_fields in let p_super = match c.cl_super with | None -> None | Some (csup,_) -> Some (get_path (t_infos (TClassDecl csup))) in let p_interfaces = List.map (fun (c,tl) -> get_path (t_infos (TClassDecl c)) ) c.cl_implements in newline ctx; newline ctx; newline ctx; print ctx "class %s" p; (match p_super with Some p -> print ctx "(%s)" p | _ -> ()); spr ctx ":"; let use_pass = ref true in if not is_nativegen then begin if has_feature ctx "python._hx_class_name" then begin use_pass := false; print ctx "\n\t_hx_class_name = \"%s\"" p_name end; let print_field names field quote = if has_feature ctx ("python." ^ field) then try let q s = if quote then "\"" ^ s ^ "\"" else s in let s = match names with | [] when (match c.cl_super with Some _ -> false | _ -> true) -> (* always overwrite parent's class fields *) raise Exit | _ -> "[" ^ (String.concat ", " (List.map q names)) ^ "]" in use_pass := false; print ctx "\n\t%s = %s" field s with Exit -> () in print_field x.cfd_fields "_hx_fields" true; print_field x.cfd_methods "_hx_methods" true; (* TODO: It seems strange to have a separation for member fields but a plain _hx_statics for static ones *) print_field (collect_class_statics_data c.cl_ordered_statics) "_hx_statics" true; print_field (p_interfaces) "_hx_interfaces" false; if has_feature ctx "python._hx_super" then (match p_super with | None -> () | Some ps -> use_pass := false; print ctx "\n\t_hx_super = %s\n" ps ); end; begin match c.cl_constructor with | Some cf -> gen_class_constructor ctx c cf; | None -> () end; List.iter (fun cf -> gen_class_field ctx c p cf) c.cl_ordered_fields; let has_inner_static = gen_class_statics ctx c p in let has_empty_constructor = match ((Meta.has Meta.NativeGen c.cl_meta) || c.cl_interface), c.cl_ordered_fields with | true,_ | _, [] -> false | _ -> gen_class_empty_constructor ctx p c.cl_ordered_fields; has_feature ctx "Type.createEmptyInstance" in let use_pass = !use_pass && (not has_inner_static) && (not has_empty_constructor) && match x.cfd_methods with | [] -> c.cl_constructor = None | _ -> c.cl_interface in if use_pass then spr ctx "\n\tpass"; if not is_nativegen then begin if has_feature ctx "python._hx_class" then print ctx "\n%s._hx_class = %s" p p; if has_feature ctx "python._hx_classes" then print ctx "\n_hx_classes[\"%s\"] = %s" p_name p; end end; gen_class_init ctx c let gen_enum_metadata ctx en p = let meta = Codegen.build_metadata ctx.com (TEnumDecl en) in match meta with | None -> () | Some e -> newline ctx; print ctx "%s.__meta__ = " p; gen_expr ctx e "" "" let gen_enum ctx en = let mt = (t_infos (TEnumDecl en)) in let p = get_path mt in let p_name = get_full_name mt in let enum_constructs = PMap.foldi (fun k ef acc -> ef :: acc) en.e_constrs [] in let enum_constructs = List.sort (fun a b -> if a.ef_index < b.ef_index then -1 else if a.ef_index > b.ef_index then 1 else 0) enum_constructs in newline ctx; newline ctx; print ctx "class %s(Enum):" p; let use_pass = ref true in if has_feature ctx "python._hx_class_name" then begin use_pass := false; print ctx "\n\t_hx_class_name = \"%s\"" p_name end; if has_feature ctx "python._hx_constructs" then begin let fix = match enum_constructs with [] -> "" | _ -> "\"" in let enum_constructs_str = fix ^ (String.concat ("\", \"") (List.map (fun ef -> ef.ef_name) enum_constructs)) ^ fix in use_pass := false; print ctx "\n\t_hx_constructs = [%s]" enum_constructs_str; end; let const_constructors,param_constructors = List.partition (fun ef -> match follow ef.ef_type with | TFun(_,_) -> false | _ -> true ) enum_constructs in List.iter (fun ef -> match follow ef.ef_type with | TFun(args, _) -> let print_args args = let had_optional = ref false in let sl = List.map (fun (n,o,_) -> let name = handle_keywords n in let arg_value = if !had_optional then "= None" else if o then begin had_optional := true; " = None" end else "" in Printf.sprintf "%s%s" name arg_value ) args in String.concat "," sl in let f = handle_keywords ef.ef_name in let param_str = print_args args in let args_str = String.concat "," (List.map (fun (n,_,_) -> handle_keywords n) args) in newline ctx; newline ctx; print ctx "\t@staticmethod\n\tdef %s(%s):\n" f param_str; print ctx "\t\treturn %s(\"%s\", %i, [%s])" p ef.ef_name ef.ef_index args_str; use_pass := false; | _ -> assert false ) param_constructors; if !use_pass then spr ctx "\n\tpass"; List.iter (fun ef -> (* TODO: haxe source has api.quoteString for ef.ef_name *) let f = handle_keywords ef.ef_name in newline ctx; print ctx "%s.%s = %s(\"%s\", %i, list())" p f p ef.ef_name ef.ef_index ) const_constructors; if has_feature ctx "python._hx_class" then print ctx "\n%s._hx_class = %s" p p; if has_feature ctx "python._hx_classes" then print ctx "\n_hx_classes[\"%s\"] = %s" p_name p; gen_enum_metadata ctx en p let gen_abstract ctx a = newline ctx; newline ctx; newline ctx; let mt = (t_infos (TAbstractDecl a)) in let p = get_path mt in let p_name = get_full_name mt in print ctx "class %s:" p; let use_pass = ref true in if has_feature ctx "python._hx_class_name" then begin use_pass := false; print ctx "\n\t_hx_class_name = \"%s\"" p_name end; (match a.a_impl with | Some c -> List.iter (fun cf -> use_pass := false; if cf.cf_name = "_new" then gen_class_constructor ctx c cf else gen_class_field ctx c p cf ) c.cl_ordered_statics | None -> ()); if !use_pass then spr ctx "\n\tpass"; if has_feature ctx "python._hx_class" then print ctx "\n%s._hx_class = %s" p p; if has_feature ctx "python._hx_classes" then print ctx "\n_hx_classes[\"%s\"] = %s" p_name p let gen_type ctx mt = match mt with | TClassDecl c -> gen_class ctx c | TEnumDecl en when not en.e_extern -> gen_enum ctx en | TAbstractDecl {a_path = [],"UInt"} -> () | TAbstractDecl {a_path = [],"Enum"} -> () | TAbstractDecl {a_path = [],"EnumValue"} when not (has_feature ctx "has_enum") -> () | TAbstractDecl {a_path = [],"Void"} -> () | TAbstractDecl {a_path = [],"Int"} when not (has_feature ctx "Int.*") -> () | TAbstractDecl {a_path = [],"Float"} when not (has_feature ctx "Float.*") -> () | TAbstractDecl {a_path = [],"Class"} when not (has_feature ctx "Class.*") -> () | TAbstractDecl {a_path = [],"Dynamic"} when not (has_feature ctx "Dynamic.*") -> () | TAbstractDecl {a_path = [],"Bool"} when not (has_feature ctx "Bool.*") -> () | TAbstractDecl a when Meta.has Meta.CoreType a.a_meta -> gen_abstract ctx a | _ -> () (* Generator parts *) let gen_resources ctx = if Hashtbl.length ctx.com.resources > 0 then begin let slash_index = try (String.rindex ctx.com.file '/')+1 with Not_found -> 0 in let len = String.length ctx.com.file - slash_index in let file_name = String.sub ctx.com.file slash_index len in newline ctx; newline ctx; newline ctx; spr ctx "def _hx_resources__():"; spr ctx "\n\timport inspect"; spr ctx "\n\timport sys"; spr ctx "\n\tif not hasattr(sys.modules[__name__], '__file__'):"; print ctx "\n\t\t_file = '%s'" file_name; spr ctx "\n\telse:"; spr ctx "\n\t\t_file = __file__"; spr ctx "\n\treturn {"; let first = ref true in Hashtbl.iter (fun k v -> let prefix = if !first then begin first := false; ""; end else "," in let k_enc = Codegen.escape_res_name k false in print ctx "%s\"%s\": open('%%s.%%s'%%(_file,'%s'),'rb').read()" prefix (Ast.s_escape k) k_enc; Std.output_file (ctx.com.file ^ "." ^ k_enc) v ) ctx.com.resources; spr ctx "}" end let gen_imports ctx = let import path meta = if Meta.has Meta.PythonImport meta && is_directly_used ctx.com meta then begin let _, args, mp = Meta.get Meta.PythonImport meta in let class_name = match path with | [],name -> name | path,name -> (ExtString.String.join "_" path) ^ "_" ^ name in let import_type,ignore_error = match args with | [(EConst(String(module_name)), _)] | [(EConst(String(module_name)), _); (EBinop(OpAssign, (EConst(Ident("ignoreError")),_), (EConst(Ident("false")),_)),_)] -> IModule module_name, false | [(EConst(String(module_name)), _); (EBinop(OpAssign, (EConst(Ident("ignoreError")),_), (EConst(Ident("true")),_)),_)] -> IModule module_name,true | [(EConst(String(module_name)), _); (EConst(String(object_name)), _)] | [(EConst(String(module_name)), _); (EConst(String(object_name)), _); (EBinop(OpAssign, (EConst(Ident("ignoreError")),_), (EConst(Ident("false")),_)),_)] -> IObject (module_name,object_name), false | [(EConst(String(module_name)), _); (EConst(String(object_name)), _); (EBinop(OpAssign, (EConst(Ident("ignoreError")),_), (EConst(Ident("true")),_)),_)] -> IObject (module_name,object_name), true | _ -> error "Unsupported @:pythonImport format" mp in let import = match import_type with | IModule module_name -> (* importing whole module *) "import " ^ module_name ^ " as " ^ class_name | IObject (module_name,object_name) -> if String.contains object_name '.' then (* importing nested class *) "import " ^ module_name ^ " as _hx_temp_import; " ^ class_name ^ " = _hx_temp_import." ^ object_name ^ "; del _hx_temp_import" else (* importing a class from a module *) "from " ^ module_name ^ " import " ^ object_name ^ " as " ^ class_name in newline ctx; if ignore_error then begin spr ctx "try:\n\t"; spr_line ctx import; spr ctx "except:\n\tpass" end else spr ctx import end in List.iter (fun mt -> match mt with | TClassDecl c when c.cl_extern -> import c.cl_path c.cl_meta | TEnumDecl e when e.e_extern -> import e.e_path e.e_meta | _ -> () ) ctx.com.types let gen_types ctx = let used_paths = Hashtbl.create 0 in let find_type path = Hashtbl.add used_paths path true; Utils.find_type ctx.com path in let need_anon_for_trace = (has_feature ctx "has_anon_trace") && (has_feature ctx "haxe.Log.trace") in if (has_feature ctx "has_anon") || (has_feature ctx "_hx_AnonObject") || need_anon_for_trace then begin let with_body = (has_feature ctx "has_anon") || need_anon_for_trace in newline ctx; newline ctx; newline ctx; spr ctx "class _hx_AnonObject:\n"; if with_body then begin spr ctx "\tdef __init__(self, fields):\n"; spr ctx "\t\tself.__dict__ = fields" end else spr ctx "\tpass"; Hashtbl.add used_paths ([],"_hx_AnonObject") true; end; if has_feature ctx "python._hx_classes" then begin newline ctx; newline ctx; newline ctx; spr ctx "_hx_classes = {}"; end; if has_feature ctx "Boot.*" then gen_type ctx (find_type (["python"],"Boot")); if has_feature ctx "has_enum" || has_feature ctx "Enum.*" then gen_type ctx (find_type ([],"Enum")); if has_feature ctx "HxOverrides.*" then gen_type ctx (find_type ([],"HxOverrides")); List.iter (fun mt -> if not (Hashtbl.mem used_paths (t_infos mt).mt_path) then gen_type ctx mt ) ctx.com.types let gen_static_inits ctx = newline ctx; List.iter (fun f -> f()) (List.rev ctx.static_inits) let gen_class_inits ctx = newline ctx; List.iter (fun f -> f()) (List.rev ctx.class_inits) let gen_main ctx = match ctx.com.main with | None -> () | Some e -> newline ctx; newline ctx; gen_expr ctx e "" "" (* Entry point *) let run com = Transformer.init com; let ctx = mk_context com in gen_imports ctx; gen_resources ctx; gen_types ctx; gen_class_inits ctx; gen_static_inits ctx; gen_main ctx; mkdir_from_path com.file; let ch = open_out_bin com.file in output_string ch (Buffer.contents ctx.buf); close_out ch end let generate com = Generator.run comhaxe_3.2.1+dfsg.orig/genswf.ml0000664000175000017500000011723212607337712016155 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Swf open As3 open As3hl open Genswf9 open Type open Common open Ast let rec make_tpath = function | HMPath (pack,name) -> let pdyn = ref false in let pack, name = match pack, name with | [], "void" -> [], "Void" | [], "int" -> [], "Int" | [], "uint" -> [], "UInt" | [], "Number" -> [], "Float" | [], "Boolean" -> [], "Bool" | [], "Object" -> ["flash";"utils"], "Object" | [], "Function" -> ["flash";"utils"], "Function" | [], "Class" | [],"Array" -> pdyn := true; pack, name | [], "Error" -> ["flash";"errors"], "Error" | [] , "XML" -> ["flash";"xml"], "XML" | [] , "XMLList" -> ["flash";"xml"], "XMLList" | [] , "QName" -> ["flash";"utils"], "QName" | [] , "Namespace" -> ["flash";"utils"], "Namespace" | [] , "RegExp" -> ["flash";"utils"], "RegExp" | ["__AS3__";"vec"] , "Vector" -> ["flash"], "Vector" | _ -> pack, name in { tpackage = pack; tname = name; tparams = if !pdyn then [TPType (CTPath { tpackage = []; tname = "Dynamic"; tparams = []; tsub = None; })] else[]; tsub = None; } | HMName (id,ns) -> { tpackage = (match ns with | HNInternal (Some ns) -> ExtString.String.nsplit ns "." | HNPrivate (Some ns) -> (try let file, line = ExtString.String.split ns ".as$" in [file ^ "_" ^ line] with _ -> []) | _ -> []); tname = id; tparams = []; tsub = None; } | HMNSAny (id) -> { tpackage = []; tname = id; tparams = []; tsub = None; } | HMMultiName _ -> assert false | HMRuntimeName _ -> assert false | HMRuntimeNameLate -> assert false | HMMultiNameLate _ -> assert false | HMAttrib _ -> assert false | HMAny -> assert false | HMParams (t,params) -> let params = List.map (fun t -> TPType (CTPath (make_tpath t))) params in { (make_tpath t) with tparams = params } let make_param cl p = { tpackage = fst cl; tname = snd cl; tparams = [TPType (CTPath { tpackage = fst p; tname = snd p; tparams = []; tsub = None })]; tsub = None } let make_topt = function | None -> { tpackage = []; tname = "Dynamic"; tparams = []; tsub = None } | Some t -> make_tpath t let make_type t = CTPath (make_topt t) let make_dyn_type t = match make_topt t with | { tpackage = ["flash";"utils"]; tname = ("Object"|"Function") } -> make_type None | o -> CTPath o let is_valid_path com pack name = let rec loop = function | [] -> false | load :: l -> match load (pack,name) Ast.null_pos with | None -> loop l | Some (file,(_,a)) -> true in let file = Printf.sprintf "%s/%s.hx" (String.concat "/" pack) name in loop com.load_extern_type || (try ignore(Common.find_file com file); true with Not_found -> false) let build_class com c file = let path = make_tpath c.hlc_name in let pos = { pfile = file ^ "@" ^ s_type_path (path.tpackage,path.tname); pmin = 0; pmax = 0 } in match path with | { tpackage = ["flash";"utils"]; tname = ("Object"|"Function") } -> let inf = { d_name = path.tname; d_doc = None; d_params = []; d_meta = []; d_flags = []; d_data = CTPath { tpackage = []; tname = "Dynamic"; tparams = []; tsub = None; }; } in (path.tpackage, [(ETypedef inf,pos)]) | _ -> (* make flags *) let flags = [HExtern] in let flags = if c.hlc_interface then HInterface :: flags else flags in let flags = (match c.hlc_super with | None | Some (HMPath ([],"Object")) -> flags | Some (HMPath ([],"Function")) -> flags (* found in AIR SDK *) | Some s -> HExtends (make_tpath s) :: flags ) in let flags = List.map (fun i -> let i = (match i with | HMMultiName (Some id,ns) -> let rec loop = function | [] -> HMPath ([],id) | HNPublic (Some ns) :: _ when is_valid_path com (ExtString.String.nsplit ns ".") id -> HMPath (ExtString.String.nsplit ns ".",id) | _ :: l -> loop l in loop ns | HMPath _ -> i | _ -> assert false ) in if c.hlc_interface then HExtends (make_tpath i) else HImplements (make_tpath i) ) (Array.to_list c.hlc_implements) @ flags in let flags = if c.hlc_sealed || Common.defined com Define.FlashStrict then flags else HImplements (make_tpath (HMPath ([],"Dynamic"))) :: flags in (* make fields *) let getters = Hashtbl.create 0 in let setters = Hashtbl.create 0 in let override = Hashtbl.create 0 in let is_xml = (match path.tpackage, path.tname with | ["flash";"xml"], ("XML" | "XMLList") -> true | _ -> false ) in let make_field stat acc f = let meta = ref [] in let flags = (match f.hlf_name with | HMPath _ -> [APublic] | HMName (_,ns) -> (match ns with | HNPrivate _ | HNNamespace "http://www.adobe.com/2006/flex/mx/internal" -> [] | HNNamespace ns -> if not (c.hlc_interface || is_xml) then meta := (Meta.Ns,[String ns]) :: !meta; [APublic] | HNExplicit _ | HNInternal _ | HNPublic _ -> [APublic] | HNStaticProtected _ | HNProtected _ -> meta := (Meta.Protected,[]) :: !meta; [APrivate]) | _ -> [] ) in if flags = [] then acc else let flags = if stat then AStatic :: flags else flags in let name = (make_tpath f.hlf_name).tname in let mk_meta() = List.map (fun (s,cl) -> s, List.map (fun c -> EConst c,pos) cl, pos) (!meta) in let cf = { cff_name = name; cff_doc = None; cff_pos = pos; cff_meta = mk_meta(); cff_access = flags; cff_kind = FVar (None,None); } in match f.hlf_kind with | HFVar v -> if v.hlv_const then cf.cff_kind <- FProp ("default","never",Some (make_type v.hlv_type),None) else cf.cff_kind <- FVar (Some (make_dyn_type v.hlv_type),None); cf :: acc | HFMethod m when m.hlm_override -> Hashtbl.add override (name,stat) (); acc | HFMethod m -> (match m.hlm_kind with | MK3Normal -> let t = m.hlm_type in let p = ref 0 and pn = ref 0 in let make_type = if stat || name = "new" then make_dyn_type else make_type in let args = List.map (fun at -> let aname = (match t.hlmt_pnames with | None -> incr pn; "p" ^ string_of_int !pn | Some l -> match List.nth l !p with | None -> incr pn; "p" ^ string_of_int !pn | Some i -> i ) in let opt_val = (match t.hlmt_dparams with | None -> None | Some l -> try Some (List.nth l (!p - List.length t.hlmt_args + List.length l)) with _ -> None ) in incr p; let t = make_type at in let is_opt = ref false in let def_val = match opt_val with | None -> None | Some v -> let v = (match v with | HVNone | HVNull | HVNamespace _ | HVString _ -> is_opt := true; None | HVBool b -> Some (Ident (if b then "true" else "false")) | HVInt i | HVUInt i -> Some (Int (Int32.to_string i)) | HVFloat f -> Some (Float (float_repres f)) ) in match v with | None -> None | Some v -> (* add for --gen-hx-classes generation *) meta := (Meta.DefParam,[String aname;v]) :: !meta; Some (EConst v,pos) in (aname,!is_opt,Some t,def_val) ) t.hlmt_args in let args = if t.hlmt_var_args then args @ List.map (fun _ -> incr pn; ("p" ^ string_of_int !pn,true,Some (make_type None),None)) [1;2;3;4;5] else args in let f = { f_params = []; f_args = args; f_type = Some (make_type t.hlmt_ret); f_expr = None; } in cf.cff_meta <- mk_meta(); cf.cff_kind <- FFun f; cf :: acc | MK3Getter -> Hashtbl.add getters (name,stat) m.hlm_type.hlmt_ret; acc | MK3Setter -> Hashtbl.add setters (name,stat) (match m.hlm_type.hlmt_args with [t] -> t | _ -> assert false); acc ) | _ -> acc in let fields = if c.hlc_interface then [] else make_field false [] { hlf_name = HMPath ([],"new"); hlf_slot = 0; hlf_metas = None; hlf_kind = HFMethod { hlm_type = { c.hlc_construct with hlmt_ret = Some (HMPath ([],"void")) }; hlm_final = false; hlm_override = false; hlm_kind = MK3Normal } } in let fields = Array.fold_left (make_field false) fields c.hlc_fields in let fields = Array.fold_left (make_field true) fields c.hlc_static_fields in let make_get_set name stat tget tset = let get, set, t = (match tget, tset with | None, None -> assert false | Some t, None -> true, false, t | None, Some t -> false, true, t | Some t1, Some t2 -> true, true, (if t1 <> t2 then None else t1) ) in let t = if name = "endian" then Some (HMPath (["flash";"utils"],"Endian")) else t in let flags = [APublic] in let flags = if stat then AStatic :: flags else flags in { cff_name = name; cff_pos = pos; cff_doc = None; cff_access = flags; cff_meta = []; cff_kind = if get && set then FVar (Some (make_dyn_type t), None) else FProp ((if get then "default" else "never"),(if set then "default" else "never"),Some (make_dyn_type t),None); } in let fields = Hashtbl.fold (fun (name,stat) t acc -> if Hashtbl.mem override (name,stat) then acc else make_get_set name stat (Some t) (try Some (Hashtbl.find setters (name,stat)) with Not_found -> None) :: acc ) getters fields in let fields = Hashtbl.fold (fun (name,stat) t acc -> if Hashtbl.mem getters (name,stat) || Hashtbl.mem override (name,stat) then acc else make_get_set name stat None (Some t) :: acc ) setters fields in try (* If the class only contains static String constants, make it an enum *) let real_type = ref "" in let rec loop = function | [] -> [] | f :: l -> match f.cff_kind with | FVar (Some (CTPath { tpackage = []; tname = ("String" | "Int" | "UInt") as tname }),None) when List.mem AStatic f.cff_access -> if !real_type = "" then real_type := tname else if !real_type <> tname then raise Exit; { ec_name = f.cff_name; ec_pos = pos; ec_args = []; ec_params = []; ec_meta = []; ec_doc = None; ec_type = None; } :: loop l | FFun { f_args = [] } when f.cff_name = "new" -> loop l | _ -> raise Exit in List.iter (function HExtends _ | HImplements _ -> raise Exit | _ -> ()) flags; let constr = loop fields in let name = "fakeEnum:" ^ String.concat "." (path.tpackage @ [path.tname]) in if not (Common.raw_defined com name) then raise Exit; let enum_data = { d_name = path.tname; d_doc = None; d_params = []; d_meta = [(Meta.FakeEnum,[EConst (Ident !real_type),pos],pos)]; d_flags = [EExtern]; d_data = constr; } in (path.tpackage, [(EEnum enum_data,pos)]) with Exit -> let class_data = { d_name = path.tname; d_doc = None; d_params = []; d_meta = if c.hlc_final && List.exists (fun f -> f.cff_name <> "new" && not (List.mem AStatic f.cff_access)) fields then [Meta.Final,[],pos] else []; d_flags = flags; d_data = fields; } in (path.tpackage, [(EClass class_data,pos)]) let extract_data (_,tags) = let t = Common.timer "read swf" in let h = Hashtbl.create 0 in let rec loop_field f = match f.hlf_kind with | HFClass c -> let path = make_tpath f.hlf_name in (match path with | { tpackage = []; tname = "Float" | "Bool" | "Int" | "UInt" | "Dynamic" } -> () | { tpackage = _; tname = "MethodClosure" } -> () | _ -> Hashtbl.add h (path.tpackage,path.tname) c) | _ -> () in List.iter (fun t -> match t.tdata with | TActionScript3 (_,as3) -> List.iter (fun i -> Array.iter loop_field i.hls_fields) (As3hlparse.parse as3) | _ -> () ) tags; t(); h let remove_debug_infos as3 = let hl = As3hlparse.parse as3 in let methods = Hashtbl.create 0 in let rec loop_field f = { f with hlf_kind = (match f.hlf_kind with | HFMethod m -> HFMethod { m with hlm_type = loop_method m.hlm_type } | HFFunction f -> HFFunction (loop_method f) | HFVar v -> HFVar v | HFClass c -> HFClass (loop_class c)) } and loop_class c = (* mutate in order to preserve sharing *) c.hlc_construct <- loop_method c.hlc_construct; c.hlc_fields <- Array.map loop_field c.hlc_fields; c.hlc_static_construct <- loop_method c.hlc_static_construct; c.hlc_static_fields <- Array.map loop_field c.hlc_static_fields; c and loop_static s = { hls_method = loop_method s.hls_method; hls_fields = Array.map loop_field s.hls_fields; } and loop_method m = try Hashtbl.find methods m.hlmt_index with Not_found -> let m2 = { m with hlmt_debug_name = None; hlmt_pnames = None } in Hashtbl.add methods m.hlmt_index m2; m2.hlmt_function <- (match m.hlmt_function with None -> None | Some f -> Some (loop_function f)); m2 and loop_function f = let cur = ref 0 in let positions = MultiArray.map (fun op -> let p = !cur in (match op with | HDebugReg _ | HDebugLine _ | HDebugFile _ | HBreakPointLine _ | HTimestamp -> () | _ -> incr cur); p ) f.hlf_code in MultiArray.add positions (!cur); let code = MultiArray.create() in MultiArray.iteri (fun pos op -> match op with | HDebugReg _ | HDebugLine _ | HDebugFile _ | HBreakPointLine _ | HTimestamp -> () | _ -> let p delta = MultiArray.get positions (pos + delta) - MultiArray.length code in let op = (match op with | HJump (j,delta) -> HJump (j, p delta) | HSwitch (d,deltas) -> HSwitch (p d,List.map p deltas) | HFunction m -> HFunction (loop_method m) | HCallStatic (m,args) -> HCallStatic (loop_method m,args) | HClassDef c -> HClassDef c (* mutated *) | _ -> op) in MultiArray.add code op ) f.hlf_code; f.hlf_code <- code; f.hlf_trys <- Array.map (fun t -> { t with hltc_start = MultiArray.get positions t.hltc_start; hltc_end = MultiArray.get positions t.hltc_end; hltc_handle = MultiArray.get positions t.hltc_handle; } ) f.hlf_trys; f in As3hlparse.flatten (List.map loop_static hl) let parse_swf com file = let t = Common.timer "read swf" in let is_swc = file_extension file = "swc" || file_extension file = "ane" in let file = (try Common.find_file com file with Not_found -> failwith ((if is_swc then "SWC" else "SWF") ^ " Library not found : " ^ file)) in let ch = if is_swc then begin let zip = Zip.open_in file in try let entry = Zip.find_entry zip "library.swf" in let ch = IO.input_string (Zip.read_entry zip entry) in Zip.close_in zip; ch with _ -> Zip.close_in zip; failwith ("The input swc " ^ file ^ " is corrupted") end else IO.input_channel (open_in_bin file) in let h, tags = try Swf.parse ch with Out_of_memory -> failwith ("Out of memory while parsing " ^ file) | _ -> failwith ("The input swf " ^ file ^ " is corrupted") in IO.close_in ch; List.iter (fun t -> match t.tdata with | TActionScript3 (id,as3) when not com.debug && com.display = DMNone -> t.tdata <- TActionScript3 (id,remove_debug_infos as3) | _ -> () ) tags; t(); (h,tags) let add_swf_lib com file extern = let swf_data = ref None in let swf_classes = ref None in let getSWF = (fun() -> match !swf_data with | None -> let d = parse_swf com file in swf_data := Some d; d | Some d -> d ) in let extract = (fun() -> match !swf_classes with | None -> let d = extract_data (getSWF()) in swf_classes := Some d; d | Some d -> d ) in let build cl p = match (try Some (Hashtbl.find (extract()) cl) with Not_found -> None) with | None -> None | Some c -> Some (file, build_class com c file) in com.load_extern_type <- com.load_extern_type @ [build]; if not extern then com.swf_libs <- (file,getSWF,extract) :: com.swf_libs (* ------------------------------- *) let tag ?(ext=false) d = { tid = 0; textended = ext; tdata = d; } let convert_header com (w,h,fps,bg) = let high = (max w h) * 20 in let rec loop b = if 1 lsl b > high then b else loop (b + 1) in let bits = loop 0 in { h_version = Common.flash_version_tag com.flash_version; h_size = { rect_nbits = bits + 1; left = 0; top = 0; right = w * 20; bottom = h * 20; }; h_frame_count = 1; h_fps = to_float16 (if fps > 127.0 then 127.0 else fps); h_compressed = not (Common.defined com Define.NoSwfCompress); } , bg let default_header com = convert_header com (400,300,30.,0xFFFFFF) type dependency_kind = | DKInherit | DKExpr | DKType let build_dependencies t = let h = ref PMap.empty in let add_path p k = h := PMap.add (p,k) () !h; in let rec add_type_rec l t = if List.memq t l then () else match t with | TEnum (e,pl) -> add_path e.e_path DKType; List.iter (add_type_rec (t::l)) pl; | TInst (c,pl) -> (match c.cl_kind with KTypeParameter _ -> () | _ -> add_path c.cl_path DKType); List.iter (add_type_rec (t::l)) pl; | TAbstract (a,pl) -> if Meta.has Meta.CoreType a.a_meta then add_path a.a_path DKType; List.iter (add_type_rec (t::l)) pl; | TFun (pl,t2) -> List.iter (fun (_,_,t2) -> add_type_rec (t::l) t2) pl; add_type_rec (t::l) t2; | TAnon a -> PMap.iter (fun _ f -> add_type_rec (t::l) f.cf_type) a.a_fields | TDynamic t2 -> add_type_rec (t::l) t2; | TLazy f -> add_type_rec l ((!f)()) | TMono r -> (match !r with | None -> () | Some t -> add_type_rec l t) | TType (tt,pl) -> add_type_rec (t::l) tt.t_type; List.iter (add_type_rec (t::l)) pl and add_type t = add_type_rec [] t and add_expr e = match e.eexpr with | TTypeExpr t -> add_path (Type.t_path t) DKExpr | TNew (c,pl,el) -> add_path c.cl_path DKExpr; List.iter add_type pl; List.iter add_expr el; | TFunction f -> List.iter (fun (v,_) -> add_type v.v_type) f.tf_args; add_type f.tf_type; add_expr f.tf_expr; | TFor (v,e1,e2) -> add_type v.v_type; add_expr e1; add_expr e2; | TVar (v,eo) -> add_type v.v_type; begin match eo with | None -> () | Some e -> add_expr e end | _ -> Type.iter add_expr e and add_field f = add_type f.cf_type; match f.cf_expr with | None -> () | Some e -> add_expr e in let add_inherit (c,pl) = add_path c.cl_path DKInherit; List.iter add_type pl; in (match t with | TClassDecl c when not c.cl_extern -> List.iter add_field c.cl_ordered_fields; List.iter add_field c.cl_ordered_statics; (match c.cl_constructor with | None -> () | Some f -> add_field f; if c.cl_path <> (["flash"],"Boot") then add_path (["flash"],"Boot") DKExpr; ); (match c.cl_init with | None -> () | Some e -> add_expr e); (match c.cl_super with | None -> add_path ([],"Object") DKInherit; | Some x -> add_inherit x); List.iter (fun (_,t) -> (* add type-parameters constraints dependencies *) match follow t with | TInst (c,_) -> List.iter add_inherit c.cl_implements | _ -> () ) c.cl_params; List.iter add_inherit c.cl_implements; | TEnumDecl e when not e.e_extern -> PMap.iter (fun _ f -> add_type f.ef_type) e.e_constrs; | _ -> ()); h := PMap.remove (([],"Int"),DKType) (!h); h := PMap.remove (([],"Int"),DKExpr) (!h); h := PMap.remove (([],"Void"),DKType) (!h); PMap.foldi (fun (c,k) () acc -> (c,k) :: acc) (!h) [] let build_swc_catalog com types = let node x att l = Xml.Element (x,att,l) in let make_path t sep = let path, name = t_path t in String.concat sep (path @ [name]) in let make_id path = match Genswf9.real_path path with | [],n -> n | l,n -> (String.concat "." l) ^ ":" ^ n in let build_script t = let deps = build_dependencies t in node "script" [("name",make_path t "/");("mod","0")] ([ node "def" ["id",make_id (t_path t)] []; node "dep" [("id","AS3");("type","n")] []; ] @ List.map (fun (p,k) -> let t = (match k with | DKInherit -> "i" | DKExpr -> (match p with "flash" :: _ :: _ , _ -> "i" | _ -> "e") | DKType -> "s" ) in node "dep" [("id",make_id p);("type",t)] [] ) deps) in let x = node "swc" ["xmlns","http://www.adobe.com/flash/swccatalog/9"] [ node "versions" [] [ node "swc" ["version","1.2"] []; node "haxe" ["version",Printf.sprintf "%d.%.2d" (com.version/10000) (com.version mod 10000)] []; ]; node "features" [] [ node "feature-script-deps" [] []; node "feature-files" [] []; ]; node "libraries" [] [ node "library" ["path","library.swf"] (List.map build_script types) ]; node "files" [] []; ] in "\n" ^ Xml.to_string_fmt x let remove_classes toremove lib hcl = let lib = lib() in match !toremove with | [] -> lib | _ -> let hcl = hcl() in match List.filter (fun c -> Hashtbl.mem hcl c) (!toremove) with | [] -> lib | classes -> let rec tags = function | [] -> [] | t :: l -> match t.tdata with | TActionScript3 (h,data) -> let data = As3hlparse.parse data in let rec loop f = match f.hlf_kind with | HFClass _ -> let path = make_tpath f.hlf_name in not (List.mem (path.tpackage,path.tname) classes) | _ -> true in let data = List.map (fun s -> { s with hls_fields = Array.of_list (List.filter loop (Array.to_list s.hls_fields)) }) data in let data = List.filter (fun s -> Array.length s.hls_fields > 0) data in (if data = [] then tags l else { t with tdata = TActionScript3 (h,As3hlparse.flatten data) } :: tags l) | _ -> t :: tags l in toremove := List.filter (fun p -> not (List.mem p classes)) !toremove; fst lib, tags (snd lib) type file_format = | BJPG | BPNG | BGIF | SWAV | SMP3 let detect_format data p = match (try data.[0],data.[1],data.[2] with _ -> '\x00','\x00','\x00') with | '\xFF', '\xD8', _ -> BJPG | '\x89', 'P', 'N' -> BPNG | 'R', 'I', 'F' -> SWAV | 'I', 'D', '3' -> SMP3 | '\xFF', i, _ when (int_of_char i) land 0xE2 = 0xE2 -> SMP3 | 'G', 'I', 'F' -> BGIF | _ -> error "Unknown file format" p open TTFData let build_swf9 com file swc = let boot_name = if swc <> None || Common.defined com Define.HaxeBoot then "haxe" else "boot_" ^ (String.sub (Digest.to_hex (Digest.string (Filename.basename file))) 0 4) in let code = Genswf9.generate com boot_name in let code = (match swc with | Some cat -> cat := build_swc_catalog com (List.map (fun (t,_,_) -> t) code); List.map (fun (t,m,f) -> let path = (match t_path t with | [], name -> name | path, name -> String.concat "/" path ^ "/" ^ name ) in let init = { hls_method = m; hls_fields = [|f|]; } in tag (TActionScript3 (Some (1,path),As3hlparse.flatten [init])) ) code | None -> let inits = List.map (fun (_,m,f) -> { hls_method = m; hls_fields = [|f|]; } ) code in [tag (TActionScript3 ((if Common.defined com Define.SwfUseDoAbc then Some(1,boot_name) else None), As3hlparse.flatten inits))] ) in let cid = ref 0 in let classes = ref [{ f9_cid = None; f9_classname = boot_name }] in let res = Hashtbl.fold (fun name data acc -> incr cid; classes := { f9_cid = Some !cid; f9_classname = s_type_path (Genswf9.resource_path name) } :: !classes; tag (TBinaryData (!cid,data)) :: acc ) com.resources [] in let load_file_data file p = let file = try Common.find_file com file with Not_found -> file in if String.length file > 5 && String.sub file 0 5 = "data:" then String.sub file 5 (String.length file - 5) else (try Std.input_file ~bin:true file with Invalid_argument("String.create") -> error "File is too big (max 16MB allowed)" p | _ -> error "File not found" p) in let bmp = List.fold_left (fun acc t -> match t with | TClassDecl c -> let rec loop = function | [] -> acc | (Meta.Font,(EConst (String file),p) :: args,_) :: l -> let file = try Common.find_file com file with Not_found -> file in let ch = try open_in_bin file with _ -> error "File not found" p in let ttf = try TTFParser.parse ch with e -> error ("Error while parsing font " ^ file ^ " : " ^ Printexc.to_string e) p in close_in ch; let get_string e = match fst e with | EConst (String s) -> Some s | _ -> raise Not_found in let ttf_config = { ttfc_range_str = ""; ttfc_font_name = None; } in begin match args with | (EConst (String str),_) :: _ -> ttf_config.ttfc_range_str <- str; | _ -> () end; begin match args with | _ :: [e] -> begin match fst e with | EObjectDecl fl -> begin try ttf_config.ttfc_font_name <- get_string (List.assoc "fontName" fl) with Not_found -> () end | _ -> () end | _ -> () end; let ttf_swf = TTFSwfWriter.to_swf ttf ttf_config in let ch = IO.output_string () in let b = IO.output_bits ch in TTFSwfWriter.write_font2 ch b ttf_swf; let data = IO.close_out ch in incr cid; classes := { f9_cid = Some !cid; f9_classname = s_type_path c.cl_path } :: !classes; tag (TFont3 { cd_id = !cid; cd_data = data; }) :: loop l | (Meta.Bitmap,[EConst (String file),p],_) :: l -> let data = load_file_data file p in incr cid; classes := { f9_cid = Some !cid; f9_classname = s_type_path c.cl_path } :: !classes; let raw() = tag (TBitsJPEG2 { bd_id = !cid; bd_data = data; bd_table = None; bd_alpha = None; bd_deblock = Some 0 }) in let t = (match detect_format data p with | BPNG -> (* There is a bug in Flash PNG decoder for 24-bits PNGs : Color such has 0xFF00FF is decoded as 0xFE00FE. In that particular case, we will then embed the decoded PNG bytes instead. *) (try let png = Png.parse (IO.input_string data) in let h = Png.header png in (match h.Png.png_color with | Png.ClTrueColor (Png.TBits8,Png.NoAlpha) -> if h.Png.png_width * h.Png.png_height * 4 > Sys.max_string_length then begin com.warning "Flash will loose some color information for this file, add alpha channel to preserve it" p; raise Exit; end; let data = Extc.unzip (Png.data png) in let raw_data = Png.filter png data in let cmp_data = Extc.zip raw_data in tag ~ext:true (TBitsLossless2 { bll_id = !cid; bll_format = 5; bll_width = h.Png.png_width; bll_height = h.Png.png_height; bll_data = cmp_data }) | _ -> raw()) with Exit -> raw() | _ -> com.error ("Failed to decode this PNG " ^ file) p; raw(); ) | _ -> raw() ) in t :: loop l | (Meta.Bitmap,[EConst (String dfile),p1;EConst (String afile),p2],_) :: l -> let ddata = load_file_data dfile p1 in let adata = load_file_data afile p2 in (match detect_format ddata p1 with | BJPG -> () | _ -> error "RGB channel must be a JPG file" p1); (match detect_format adata p2 with | BPNG -> () | _ -> error "Alpha channel must be a PNG file" p2); let png = Png.parse (IO.input_string adata) in let h = Png.header png in let amask = (match h.Png.png_color with | Png.ClTrueColor (Png.TBits8,Png.HaveAlpha) -> let data = Extc.unzip (Png.data png) in let raw_data = Png.filter png data in let alpha = String.make (h.Png.png_width * h.Png.png_height) '\000' in for i = 0 to String.length alpha do String.unsafe_set alpha i (String.unsafe_get raw_data (i lsl 2)); done; Extc.zip alpha | _ -> error "PNG file must contain 8 bit alpha channel" p2 ) in incr cid; classes := { f9_cid = Some !cid; f9_classname = s_type_path c.cl_path } :: !classes; tag (TBitsJPEG3 { bd_id = !cid; bd_data = ddata; bd_table = None; bd_alpha = Some amask; bd_deblock = Some 0 }) :: loop l | (Meta.File,[EConst (String file),p],_) :: l -> let data = load_file_data file p in incr cid; classes := { f9_cid = Some !cid; f9_classname = s_type_path c.cl_path } :: !classes; tag (TBinaryData (!cid,data)) :: loop l | (Meta.Sound,[EConst (String file),p],_) :: l -> let data = load_file_data file p in let make_flags fmt mono freq bits = let fbits = (match freq with 5512 when fmt <> 2 -> 0 | 11025 -> 1 | 22050 -> 2 | 44100 -> 3 | _ -> failwith ("Unsupported frequency " ^ string_of_int freq)) in let bbits = (match bits with 8 -> 0 | 16 -> 1 | _ -> failwith ("Unsupported bits " ^ string_of_int bits)) in (fmt lsl 4) lor (fbits lsl 2) lor (bbits lsl 1) lor (if mono then 0 else 1) in let flags, samples, data = (match detect_format data p with | SWAV -> (try let i = IO.input_string data in if IO.nread i 4 <> "RIFF" then raise Exit; ignore(IO.nread i 4); (* size *) if IO.nread i 4 <> "WAVE" || IO.nread i 4 <> "fmt " then raise Exit; let chunk_size = IO.read_i32 i in if not (chunk_size = 0x10 || chunk_size = 0x12 || chunk_size = 0x40) then failwith ("Unsupported chunk size " ^ string_of_int chunk_size); if IO.read_ui16 i <> 1 then failwith "Not a PCM file"; let chan = IO.read_ui16 i in if chan > 2 then failwith "Too many channels"; let freq = IO.read_i32 i in ignore(IO.read_i32 i); ignore(IO.read_i16 i); let bits = IO.read_ui16 i in if chunk_size <> 0x10 then ignore(IO.nread i (chunk_size - 0x10)); if IO.nread i 4 <> "data" then raise Exit; let data_size = IO.read_i32 i in let data = IO.nread i data_size in make_flags 0 (chan = 1) freq bits, (data_size * 8 / (chan * bits)), data with Exit | IO.No_more_input | IO.Overflow _ -> error "Invalid WAV file" p | Failure msg -> error ("Invalid WAV file (" ^ msg ^ ")") p ) | SMP3 -> (try let sampling = ref 0 in let mono = ref false in let samples = ref 0 in let i = IO.input_string data in let rec read_frame() = match (try IO.read_byte i with IO.No_more_input -> -1) with | -1 -> () | 0x49 -> (* ID3 *) if IO.nread i 2 <> "D3" then raise Exit; ignore(IO.read_ui16 i); (* version *) ignore(IO.read_byte i); (* flags *) let size = IO.read_byte i land 0x7F in let size = size lsl 7 lor (IO.read_byte i land 0x7F) in let size = size lsl 7 lor (IO.read_byte i land 0x7F) in let size = size lsl 7 lor (IO.read_byte i land 0x7F) in ignore(IO.nread i size); (* id3 data *) read_frame() | 0x54 -> (* TAG and TAG+ *) if IO.nread i 3 = "AG+" then ignore(IO.nread i 223) else ignore(IO.nread i 124); read_frame() | 0xFF -> let infos = IO.read_byte i in let ver = (infos lsr 3) land 3 in sampling := [|11025;0;22050;44100|].(ver); let layer = (infos lsr 1) land 3 in let bits = IO.read_byte i in let bitrate = (if ver = 3 then [|0;32;40;48;56;64;80;96;112;128;160;192;224;256;320;-1|] else [|0;8;16;24;32;40;48;56;64;80;96;112;128;144;160;-1|]).(bits lsr 4) in let srate = [| [|11025;12000;8000;-1|]; [|-1;-1;-1;-1|]; [|22050;24000;16000;-1|]; [|44100;48000;32000;-1|]; |].(ver).((bits lsr 2) land 3) in let pad = (bits lsr 1) land 1 in mono := (IO.read_byte i) lsr 6 = 3; let bpp = (if ver = 3 then 144 else 72) in let size = ((bpp * bitrate * 1000) / srate) + pad - 4 in ignore(IO.nread i size); samples := !samples + (if layer = 3 then 384 else 1152); read_frame() | _ -> raise Exit in read_frame(); make_flags 2 !mono !sampling 16, (!samples), ("\x00\x00" ^ data) with Exit | IO.No_more_input | IO.Overflow _ -> error "Invalid MP3 file" p | Failure msg -> error ("Invalid MP3 file (" ^ msg ^ ")") p ) | _ -> error "Sound extension not supported (only WAV or MP3)" p ) in incr cid; classes := { f9_cid = Some !cid; f9_classname = s_type_path c.cl_path } :: !classes; tag (TSound { so_id = !cid; so_flags = flags; so_samples = samples; so_data = data }) :: loop l | _ :: l -> loop l in loop c.cl_meta | _ -> acc ) [] com.types in let clips = [tag (TF9Classes (List.rev !classes))] in res @ bmp @ code @ clips let merge com file priority (h1,tags1) (h2,tags2) = (* prioritize header+bgcolor for first swf *) let header = if priority then { h2 with h_version = max h2.h_version (Common.flash_version_tag com.flash_version) } else h1 in let tags1 = if priority then List.filter (function { tdata = TSetBgColor _ } -> false | _ -> true) tags1 else tags1 in (* remove unused tags *) let use_stage = priority && Common.defined com Define.FlashUseStage in let classes = ref [] in let nframe = ref 0 in let tags2 = List.filter (fun t -> match t.tdata with | TPlaceObject2 _ | TPlaceObject3 _ | TRemoveObject2 _ | TRemoveObject _ -> use_stage | TShowFrame -> incr nframe; use_stage | TFilesAttributes _ | TEnableDebugger2 _ | TScenes _ -> false | TMetaData _ -> not (Common.defined com Define.SwfMetadata) | TSetBgColor _ -> priority | TExport el when !nframe = 0 && com.flash_version >= 9. -> let el = List.filter (fun e -> let path = parse_path e.exp_name in let b = List.exists (fun t -> t_path t = path) com.types in if not b && fst path = [] then List.iter (fun t -> if snd (t_path t) = snd path then error ("Linkage name '" ^ snd path ^ "' in '" ^ file ^ "' should be '" ^ s_type_path (t_path t) ^"'") (t_infos t).mt_pos; ) com.types; b ) el in classes := !classes @ List.map (fun e -> { f9_cid = Some e.exp_id; f9_classname = e.exp_name }) el; false | TF9Classes el when !nframe = 0 -> classes := !classes @ List.filter (fun e -> e.f9_cid <> None) el; false | _ -> true ) tags2 in (* rebuild character ids *) let max_id = ref (-1) in List.iter (SwfParser.scan (fun id -> if id > !max_id then max_id := id; id) (fun id -> id)) tags1; incr max_id; let rec loop t = SwfParser.scan (fun id -> id + !max_id) (fun id -> id + !max_id) t; match t.tdata with | TClip c -> List.iter loop c.c_tags | _ -> () in List.iter loop tags2; let classes = List.map (fun e -> match e.f9_cid with None -> e | Some id -> { e with f9_cid = Some (id + !max_id) }) !classes in (* merge timelines *) let rec loop l1 l2 = match l1, l2 with | ({ tdata = TSetBgColor _ } as t) :: l1, _ | ({ tdata = TEnableDebugger2 _ } as t) :: l1, _ | ({ tdata = TFilesAttributes _ } as t) :: l1, _ -> t :: loop l1 l2 | _, ({ tdata = TSetBgColor _ } as t) :: l2 -> t :: loop l1 l2 | { tdata = TShowFrame } :: l1, { tdata = TShowFrame } :: l2 -> tag TShowFrame :: loop l1 l2 | { tdata = TF9Classes el } :: l1, _ -> (* merge all classes together *) tag (TF9Classes (classes @ el)) :: loop l1 l2 | x :: l1, { tdata = TShowFrame } :: _ -> (* wait until we finish frame on other swf *) x :: loop l1 l2 | _ , x :: l2 -> x :: loop l1 l2 | x :: l1, [] -> x :: loop l1 l2 | [], [] -> [] in let tags = loop tags1 tags2 in header, tags let generate com swf_header = let t = Common.timer "generate swf" in let swc = if Common.defined com Define.Swc then Some (ref "") else None in let file , codeclip = (try let f , c = ExtString.String.split com.file "@" in f, Some c with _ -> com.file , None) in (* list exports *) let exports = Hashtbl.create 0 in let toremove = ref [] in List.iter (fun (file,lib,_) -> let _, tags = lib() in List.iter (fun t -> match t.tdata with | TExport l -> List.iter (fun e -> Hashtbl.add exports e.exp_name ()) l | TF9Classes el -> List.iter (fun e -> if e.f9_cid <> None then List.iter (fun t -> let extern = (match t with | TClassDecl c -> c.cl_extern | TEnumDecl e -> e.e_extern | TAbstractDecl a -> false | TTypeDecl t -> false ) in if not extern && s_type_path (t_path t) = e.f9_classname then match t with | TClassDecl c -> if Meta.has Meta.Bind c.cl_meta then toremove := (t_path t) :: !toremove else error ("Class already exists in '" ^ file ^ "', use @:bind to redefine it") (t_infos t).mt_pos | _ -> error ("Invalid redefinition of class defined in '" ^ file ^ "'") (t_infos t).mt_pos ) com.types; ) el | _ -> () ) tags; ) com.swf_libs; (* build haxe swf *) let tags = build_swf9 com file swc in let header, bg = (match swf_header with None -> default_header com | Some h -> convert_header com h) in let bg = tag (TSetBgColor { cr = bg lsr 16; cg = (bg lsr 8) land 0xFF; cb = bg land 0xFF }) in let swf_debug_password = try Digest.to_hex(Digest.string (Common.defined_value com Define.SwfDebugPassword)) with Not_found -> "" in let debug = (if Common.defined com Define.Fdb then [tag (TEnableDebugger2 (0, swf_debug_password))] else []) in let meta_data = try let file = Common.defined_value com Define.SwfMetadata in let file = try Common.find_file com file with Not_found -> file in let data = try Std.input_file ~bin:true file with Sys_error _ -> failwith ("Metadata resource file not found : " ^ file) in [tag(TMetaData (data))] with Not_found -> [] in let fattr = (if com.flash_version < 8. then [] else [tag (TFilesAttributes { fa_network = Common.defined com Define.NetworkSandbox; fa_as3 = true; fa_metadata = meta_data <> []; fa_gpu = com.flash_version > 9. && Common.defined com Define.SwfGpu; fa_direct_blt = com.flash_version > 9. && Common.defined com Define.SwfDirectBlit; })] ) in let fattr = if Common.defined com Define.AdvancedTelemetry then fattr @ [tag (TUnknown (0x5D,"\x00\x00"))] else fattr in let swf_script_limits = try let s = Common.defined_value com Define.SwfScriptTimeout in let i = try int_of_string s with _ -> error "Argument to swf_script_timeout must be an integer" Ast.null_pos in [tag(TScriptLimits (256, if i < 0 then 0 else if i > 65535 then 65535 else i))] with Not_found -> [] in let swf = header, fattr @ meta_data @ bg :: debug @ swf_script_limits @ tags @ [tag TShowFrame] in (* merge swf libraries *) let priority = ref (swf_header = None) in let swf = List.fold_left (fun swf (file,lib,cl) -> let swf = merge com file !priority swf (remove_classes toremove lib cl) in priority := false; swf ) swf com.swf_libs in let swf = match swf with | header,tags when Common.defined com Define.SwfPreloaderFrame -> let rec loop l = match l with | ({tdata = TFilesAttributes _ | TUnknown (0x5D,"\x00\x00") | TMetaData _ | TSetBgColor _ | TEnableDebugger2 _ | TScriptLimits _} as t) :: l -> t :: loop l | t :: l -> tag TShowFrame :: t :: l | [] -> [] in {header with h_frame_count = header.h_frame_count + 1},loop tags | _ -> swf in t(); (* write swf/swc *) let t = Common.timer "write swf" in let level = (try int_of_string (Common.defined_value com Define.SwfCompressLevel) with Not_found -> 9) in SwfParser.init Extc.input_zip (Extc.output_zip ~level); (match swc with | Some cat -> let ch = IO.output_strings() in Swf.write ch swf; let swf = IO.close_out ch in let z = Zip.open_out file in Zip.add_entry (!cat) z "catalog.xml"; Zip.add_entry (match swf with [s] -> s | _ -> failwith "SWF too big for SWC") z ~level:0 "library.swf"; Zip.close_out z | None -> let ch = IO.output_channel (open_out_bin file) in Swf.write ch swf; IO.close_out ch; ); t() ;; SwfParser.init Extc.input_zip Extc.output_zip; Swf.warnings := false; haxe_3.2.1+dfsg.orig/genswf9.ml0000664000175000017500000021373412607337712016252 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open As3 open As3hl open Common type read = Read type write = Unused__ | Write type tkind = | KInt | KUInt | KFloat | KBool | KType of hl_name | KDynamic | KNone type register = { rid : int; rtype : tkind; mutable rused : bool; mutable rinit : bool; mutable rcond : bool; } type 'a access = | VReg of register | VId of hl_name | VCast of hl_name * tkind | VGlobal of hl_name | VArray | VScope of hl_slot | VVolatile of hl_name * tkind option | VSuper of hl_name type local = | LReg of register | LScope of hl_slot | LGlobal of hl_name type code_infos = { mutable iregs : register DynArray.t; mutable ipos : int; mutable istack : int; mutable imax : int; mutable iscopes : int; mutable imaxscopes : int; mutable iloop : int; mutable icond : bool; } type try_infos = { tr_pos : int; tr_end : int; tr_catch_pos : int; tr_type : t; } type context = { (* globals *) com : Common.context; debugger : bool; swc : bool; boot : path; swf_protected : bool; need_ctor_skip : bool; mutable cur_class : tclass; mutable debug : bool; mutable last_line : int; mutable last_file : string; (* per-function *) mutable locals : (int,tvar * local) PMap.t; mutable code : hl_opcode DynArray.t; mutable infos : code_infos; mutable trys : try_infos list; mutable breaks : (unit -> unit) list; mutable continues : (int -> unit) list; mutable in_static : bool; mutable block_vars : (hl_slot * string * hl_name option) list; mutable try_scope_reg : register option; mutable for_call : bool; } let rec follow t = match Type.follow t with | TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) -> follow (Abstract.get_underlying_type a tl) | t -> t let invalid_expr p = error "Invalid expression" p let stack_error p = error "Stack error" p let index_int (x : int) : 'a index = Obj.magic (x + 1) let index_nz_int (x : int) : 'a index_nz = Obj.magic x let tid (x : 'a index) : int = Obj.magic x let ethis = mk (TConst TThis) (mk_mono()) null_pos let dynamic_prop = HMMultiNameLate [HNPublic (Some "")] let is_special_compare e1 e2 = match e1.eexpr, e2.eexpr with | TConst TNull, _ | _ , TConst TNull -> None | _ -> match follow e1.etype, follow e2.etype with | TInst ({ cl_path = ["flash"],"NativeXml" } as c,_) , _ | _ , TInst ({ cl_path = ["flash"],"NativeXml" } as c,_) -> Some c | _ -> None let write ctx op = DynArray.add ctx.code op; ctx.infos.ipos <- ctx.infos.ipos + 1; let s = ctx.infos.istack + As3hlparse.stack_delta op in ctx.infos.istack <- s; if s > ctx.infos.imax then ctx.infos.imax <- s; match op with | HScope -> let n = ctx.infos.iscopes + 1 in ctx.infos.iscopes <- n; if n > ctx.infos.imaxscopes then ctx.infos.imaxscopes <- n | HPopScope -> ctx.infos.iscopes <- ctx.infos.iscopes - 1 | _ -> () let jump ctx cond = let op = DynArray.length ctx.code in let p = ctx.infos.ipos in write ctx (HJump (cond,0)); (fun () -> let delta = ctx.infos.ipos - p in DynArray.set ctx.code op (HJump (cond,delta)) ) let jump_back ctx = let p = ctx.infos.ipos in write ctx HLabel; (fun cond -> let delta = p - ctx.infos.ipos in write ctx (HJump (cond,delta)) ) let real_path = function | [] , "Int" -> [] , "int" | [] , "UInt" -> [] , "uint" | [] , "Float" -> [] , "Number" | [] , "Bool" -> [] , "Boolean" | [] , "Enum" -> [] , "Class" | [] , "EnumValue" -> [] , "Object" | ["flash";"xml"], "XML" -> [], "XML" | ["flash";"xml"], "XMLList" -> [], "XMLList" | ["flash";"utils"], "QName" -> [] , "QName" | ["flash";"utils"], "Namespace" -> [] , "Namespace" | ["flash";"utils"], "Object" -> [] , "Object" | ["flash";"utils"], "Function" -> [] , "Function" | ["flash"] , "FlashXml__" -> [] , "Xml" | ["flash";"errors"] , "Error" -> [], "Error" | ["flash"] , "Vector" -> ["__AS3__";"vec"], "Vector" | path -> path let type_path ctx path = let pack, name = real_path path in HMPath (pack,name) let rec follow_basic t = match t with | TMono r -> (match !r with | Some t -> follow_basic t | _ -> t) | TLazy f -> follow_basic (!f()) | TType ({ t_path = [],"Null" },[tp]) -> (match follow_basic tp with | TMono _ | TFun _ | TAbstract ({ a_path = ([],"Int") },[]) | TAbstract ({ a_path = ([],"Float") },[]) | TAbstract ({ a_path = [],"UInt" },[]) | TAbstract ({ a_path = ([],"Bool") },[]) | TInst ({ cl_path = (["haxe"],"Int32") },[]) -> t | t -> t) | TType ({ t_path = ["flash";"utils"],"Object" },[]) | TType ({ t_path = ["flash";"utils"],"Function" },[]) | TType ({ t_path = [],"UInt" },[]) -> t | TType (t,tl) -> follow_basic (apply_params t.t_params tl t.t_type) | TAbstract (a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> follow_basic (apply_params a.a_params pl a.a_this) | _ -> t let rec type_id ctx t = match follow_basic t with | TInst ({ cl_path = ["haxe"],"Int32" },_) -> type_path ctx ([],"Int") | TInst ({ cl_path = ["flash"],"Vector" } as c,pl) -> (match pl with | [TInst({cl_kind = KTypeParameter _},_)] -> type_path ctx ([],"Object") | _ -> HMParams (type_path ctx c.cl_path,List.map (type_id ctx) pl)) | TInst (c,_) -> (match c.cl_kind with | KTypeParameter l -> (match l with | [t] -> type_id ctx t | _ -> type_path ctx ([],"Object")) | KExtension (c,params) -> type_id ctx (TInst (c,params)) | _ -> type_path ctx c.cl_path) | TAbstract (a,_) -> type_path ctx a.a_path | TFun _ | TType ({ t_path = ["flash";"utils"],"Function" },[]) -> type_path ctx ([],"Function") | TType ({ t_path = ([],"UInt") as path },_) -> type_path ctx path | TEnum ({ e_path = ["flash"],"XmlType"; e_extern = true },_) -> HMPath ([],"String") | TEnum (e,_) -> let rec loop = function | [] -> type_path ctx e.e_path | (Meta.FakeEnum,[Ast.EConst (Ast.Ident n),_],_) :: _ -> type_path ctx ([],n) | _ :: l -> loop l in loop e.e_meta | _ -> HMPath ([],"Object") let type_opt ctx t = match follow_basic t with | TDynamic _ | TMono _ -> None | _ -> Some (type_id ctx t) let type_void ctx t = match follow t with | TEnum ({ e_path = [],"Void" },_) | TAbstract ({ a_path = [],"Void" },_) -> Some (HMPath ([],"void")) | _ -> type_opt ctx t let classify ctx t = match follow_basic t with | TAbstract ({ a_path = [],"Int" },_) | TInst ({ cl_path = [],"Int" },_) | TInst ({ cl_path = ["haxe"],"Int32" },_) -> KInt | TAbstract ({ a_path = [],"Float" },_) | TInst ({ cl_path = [],"Float" },_) -> KFloat | TAbstract ({ a_path = [],"Bool" },_) | TEnum ({ e_path = [],"Bool" },_) -> KBool | TAbstract ({ a_path = [],"Void" },_) | TEnum ({ e_path = [],"Void" },_) -> KDynamic | TEnum ({ e_path = ["flash"],"XmlType"; e_extern = true },_) -> KType (HMPath ([],"String")) | TEnum (e,_) -> let rec loop = function | [] -> KType (type_id ctx t) | (Meta.FakeEnum,[Ast.EConst (Ident n),_],_) :: _ -> (match n with | "Int" -> KInt | "UInt" -> KUInt | "String" -> KType (HMPath ([],"String")) | _ -> assert false) | _ :: l -> loop l in loop e.e_meta | TAbstract ({ a_path = [],"UInt" },_) | TType ({ t_path = [],"UInt" },_) -> KUInt | TFun _ | TType ({ t_path = ["flash";"utils"],"Function" },[]) -> KType (HMPath ([],"Function")) | TAnon a -> (match !(a.a_status) with | Statics _ -> KNone | _ -> KDynamic) | TType ({ t_path = ["flash";"utils"],"Object" },[]) -> KType (HMPath ([],"Object")) | TInst _ | TAbstract _ -> KType (type_id ctx t) | TMono _ | TType _ | TDynamic _ -> KDynamic | TLazy _ -> assert false (* some field identifiers might cause issues with SWC *) let reserved i = match i with | "int" -> "_" ^ i | _ -> i let ident i = HMPath ([],reserved i) let as3 p = HMName (p,HNNamespace "http://adobe.com/AS3/2006/builtin") let property ctx p t = match follow t with | TInst ({ cl_path = [],"Array" },_) -> (match p with | "length" -> ident p, Some KInt, false (* UInt in the spec *) | "map" | "filter" when Common.defined ctx.com Define.NoFlashOverride -> ident (p ^ "HX"), None, true | "copy" | "insert" | "remove" | "iterator" | "toString" | "map" | "filter" -> ident p , None, true | _ -> as3 p, None, false); | TInst ({ cl_path = ["flash"],"Vector" },_) -> (match p with | "length" -> ident p, Some KInt, false (* UInt in the spec *) | "fixed" | "toString" -> ident p, None, false | "iterator" -> ident p, None, true | _ -> as3 p, None, false); | TInst ({ cl_path = [],"String" },_) -> (match p with | "length" (* Int in AS3/Haxe *) -> ident p, None, false | "charCodeAt" when Common.defined ctx.com Define.NoFlashOverride -> ident (p ^ "HX"), None, true | "charCodeAt" (* use Haxe version *) -> ident p, None, true | "cca" -> as3 "charCodeAt", None, false | _ -> as3 p, None, false); | TInst ({ cl_path = [],"Date" },_) -> (match p with | "toString" when Common.defined ctx.com Define.NoFlashOverride -> ident (p ^ "HX"), None, true | _ -> ident p, None, false) | TAnon a -> (match !(a.a_status) with | Statics { cl_path = [], "Math" } -> (match p with | "POSITIVE_INFINITY" | "NEGATIVE_INFINITY" | "NaN" -> ident p, Some KFloat, false | "floor" | "ceil" | "round" when ctx.for_call -> ident p, Some KInt, false | "ffloor" | "fceil" | "fround" -> ident (String.sub p 1 (String.length p - 1)), None, false | _ -> ident p, None, false) | _ -> ident p, None, false) | TInst ({ cl_kind = KExtension _ } as c,params) -> (* cast type when accessing an extension field *) (try let f = PMap.find p c.cl_fields in ident p, Some (classify ctx (apply_params c.cl_params params f.cf_type)), false with Not_found -> ident p, None, false) | TInst ({ cl_interface = true } as c,_) -> (* lookup the interface in which the field was actually declared *) let rec loop c = try (match PMap.find p c.cl_fields with | { cf_kind = Var _ | Method MethDynamic } -> raise Exit (* no vars in interfaces in swf9 *) | _ -> c) with Not_found -> let rec loop2 = function | [] -> raise Not_found | (i,_) :: l -> try loop i with Not_found -> loop2 l in loop2 c.cl_implements in (try let c = loop c in let ns = HMName (reserved p, HNNamespace (match c.cl_path with [],n -> n | l,n -> String.concat "." l ^ ":" ^ n)) in ns, None, false with Not_found | Exit -> ident p, None, false) | _ -> ident p, None, false let default_infos() = { ipos = 0; istack = 0; imax = 0; iregs = DynArray.create(); iscopes = 0; imaxscopes = 0; iloop = -1; icond = false; } let alloc_reg ctx k = let regs = ctx.infos.iregs in try let p = DynArray.index_of (fun r -> not r.rused && k = r.rtype) regs in let r = DynArray.unsafe_get regs p in r.rused <- true; r.rinit <- false; r with Not_found -> let r = { rid = DynArray.length regs + 1; rused = true; rinit = false; rtype = k; rcond = false; } in DynArray.add regs r; r let coerce ctx t = (* it would be useful to know if we don't already have this type on the stack (as detected by the bytecode verifier)... maybe this get removed at JIT, so it's only useful to reduce codesize *) if t <> KNone then write ctx (match t with | KInt -> HToInt | KUInt -> HToUInt | KFloat -> HToNumber | KBool -> HToBool | KType t -> HCast t | KDynamic -> HAsAny | KNone -> assert false ) let set_reg ctx r = if not r.rinit then begin r.rinit <- true; if ctx.infos.icond then r.rcond <- true; end; coerce ctx r.rtype; write ctx (HSetReg r.rid) let set_reg_dup ctx r = if not r.rinit then begin r.rinit <- true; if ctx.infos.icond then r.rcond <- true; end; coerce ctx r.rtype; write ctx HDup; write ctx (HSetReg r.rid) let free_reg ctx r = r.rused <- false let pop ctx n = let rec loop n = if n > 0 then begin write ctx HPop; loop (n - 1) end in if n < 0 then assert false; let old = ctx.infos.istack in loop n; ctx.infos.istack <- old let is_member ctx name = let rec loop c = PMap.mem name c.cl_fields || (match c.cl_super with None -> false | Some (c,_) -> loop c) in loop ctx.cur_class let rename_block_var ctx v = (* we need to rename it since slots are accessed on a by-name basis *) let rec loop i = let name = v.v_name ^ string_of_int i in if List.exists (fun(_,x,_) -> name = x) ctx.block_vars || is_member ctx name then loop (i + 1) else v.v_name <- name in loop 1 let define_local ctx ?(init=false) v p = let name = v.v_name in let t = v.v_type in let l = (if v.v_capture then begin let topt = type_opt ctx t in if List.exists (fun (_,x,_) -> name = x) ctx.block_vars || is_member ctx name then rename_block_var ctx v; let pos = List.length ctx.block_vars + 1 in ctx.block_vars <- (pos,v.v_name,topt) :: ctx.block_vars; LScope pos end else let r = alloc_reg ctx (classify ctx t) in if ctx.debug then write ctx (HDebugReg (name, r.rid, ctx.last_line)); r.rinit <- init; LReg r ) in ctx.locals <- PMap.add v.v_id (v,l) ctx.locals let is_set v = (Obj.magic v) = Write let gen_local_access ctx v p (forset : 'a) : 'a access = match snd (try PMap.find v.v_id ctx.locals with Not_found -> error ("Unbound variable " ^ v.v_name) p) with | LReg r -> VReg r | LScope n -> write ctx (HGetScope 1); VScope n | LGlobal p -> if is_set forset then write ctx (HFindProp p); VGlobal p let get_local_register ctx v = match (try snd (PMap.find v.v_id ctx.locals) with Not_found -> LScope 0) with | LReg r -> Some r | _ -> None let rec setvar ctx (acc : write access) kret = match acc with | VReg r -> if kret <> None then set_reg_dup ctx r else set_reg ctx r; | VGlobal _ | VId _ | VCast _ | VArray | VScope _ when kret <> None -> let r = alloc_reg ctx (match kret with None -> assert false | Some k -> k) in set_reg_dup ctx r; setvar ctx acc None; write ctx (HReg r.rid); free_reg ctx r | VGlobal g -> write ctx (HSetProp g) | VId id | VCast (id,_) -> write ctx (HInitProp id) | VVolatile (id,_) -> write ctx (HArray 1); write ctx (HInitProp id) | VArray -> write ctx (HSetProp dynamic_prop); ctx.infos.istack <- ctx.infos.istack - 1 | VScope n -> write ctx (HSetSlot n) | VSuper id -> write ctx (HSetSuper id) let getvar ctx (acc : read access) = match acc with | VReg r -> if not r.rinit then begin r.rinit <- true; r.rcond <- true; end; write ctx (HReg r.rid) | VId id -> write ctx (HGetProp id) | VVolatile (id,t) -> write ctx (HGetProp id); write ctx (HSmallInt 0); write ctx (HGetProp dynamic_prop); ctx.infos.istack <- ctx.infos.istack - 1; (match t with | None -> () | Some t -> coerce ctx t) | VCast (id,t) -> write ctx (HGetProp id); coerce ctx t | VGlobal g -> write ctx (HGetLex g); | VArray -> write ctx (HGetProp dynamic_prop); ctx.infos.istack <- ctx.infos.istack - 1 | VScope n -> write ctx (HGetSlot n) | VSuper id -> write ctx (HGetSuper id) let open_block ctx retval = let old_stack = ctx.infos.istack in let old_regs = DynArray.map (fun r -> r.rused) ctx.infos.iregs in let old_locals = ctx.locals in (fun() -> if ctx.infos.istack <> old_stack + (if retval then 1 else 0) then assert false; let rcount = DynArray.length old_regs + 1 in DynArray.iter (fun r -> if r.rid < rcount then r.rused <- DynArray.unsafe_get old_regs (r.rid - 1) else r.rused <- false ) ctx.infos.iregs; ctx.locals <- old_locals; ) let begin_branch ctx = if ctx.infos.icond then (fun() -> ()) else begin ctx.infos.icond <- true; (fun() -> ctx.infos.icond <- false) end let begin_switch ctx = let branch = begin_branch ctx in let switch_index = DynArray.length ctx.code in let switch_pos = ctx.infos.ipos in write ctx (HSwitch (0,[])); let constructs = ref [] in let max = ref 0 in let ftag tag = if tag > !max then max := tag; constructs := (tag,ctx.infos.ipos) :: !constructs; in let fend() = let cases = Array.create (!max + 1) 1 in List.iter (fun (tag,pos) -> Array.set cases tag (pos - switch_pos)) !constructs; DynArray.set ctx.code switch_index (HSwitch (1,Array.to_list cases)); branch(); in fend, ftag let debug_infos ?(is_min=true) ctx p = if ctx.debug then begin let line = Lexer.get_error_line (if is_min then p else { p with pmin = p.pmax }) in if ctx.last_file <> p.pfile then begin write ctx (HDebugFile (if ctx.debugger then Common.get_full_path p.pfile else p.pfile)); ctx.last_file <- p.pfile; ctx.last_line <- -1; end; if ctx.last_line <> line then begin write ctx (HDebugLine line); ctx.last_line <- line; end end let to_utf8 str = try UTF8.validate str; str; with UTF8.Malformed_code -> let b = UTF8.Buf.create 0 in String.iter (fun c -> UTF8.Buf.add_char b (UChar.of_char c)) str; UTF8.Buf.contents b let gen_constant ctx c t p = match c with | TInt i -> let unsigned = classify ctx t = KUInt in if Int32.compare i (-128l) > 0 && Int32.compare i 128l < 0 then begin write ctx (HSmallInt (Int32.to_int i)); if unsigned then write ctx HToUInt; end else write ctx (if unsigned then HUIntRef i else HIntRef i) | TFloat f -> let f = float_of_string f in write ctx (HFloat f); | TString s -> write ctx (HString (to_utf8 s)); | TBool b -> write ctx (if b then HTrue else HFalse); | TNull -> write ctx HNull; coerce ctx (classify ctx t) | TThis -> write ctx HThis | TSuper -> assert false let end_fun ctx args dparams tret = { hlmt_index = 0; hlmt_ret = type_void ctx tret; hlmt_args = List.map (fun (v,_) -> type_opt ctx v.v_type) args; hlmt_native = false; hlmt_var_args = false; hlmt_debug_name = None; hlmt_dparams = dparams; hlmt_pnames = if ctx.swc || ctx.debugger then Some (List.map (fun (v,_) -> Some v.v_name) args) else None; hlmt_new_block = false; hlmt_unused_flag = false; hlmt_arguments_defined = false; hlmt_uses_dxns = false; hlmt_function = None; } let begin_fun ctx args tret el stat p = let old_locals = ctx.locals in let old_code = ctx.code in let old_infos = ctx.infos in let old_trys = ctx.trys in let old_bvars = ctx.block_vars in let old_static = ctx.in_static in let last_line = ctx.last_line in let old_treg = ctx.try_scope_reg in ctx.infos <- default_infos(); ctx.code <- DynArray.create(); ctx.trys <- []; ctx.block_vars <- []; ctx.in_static <- stat; ctx.last_line <- -1; ctx.last_file <- ""; debug_infos ctx p; let rec find_this e = match e.eexpr with | TFunction _ -> () | TConst TThis | TConst TSuper -> raise Exit | _ -> Type.iter find_this e in let this_reg = try List.iter find_this el; false with Exit -> true in ctx.locals <- PMap.foldi (fun _ (v,l) acc -> match l with | LReg _ -> acc | LScope _ -> PMap.add v.v_id (v,LGlobal (ident v.v_name)) acc | LGlobal _ -> PMap.add v.v_id (v,l) acc ) ctx.locals PMap.empty; let dparams = ref None in let make_constant_value r c t = let v = (match classify ctx t, c with | _, None -> HVNone | (KInt | KFloat | KUInt | KBool) as kind, Some c -> (match c with | TInt i -> if kind = KUInt then HVUInt i else HVInt i | TFloat s -> HVFloat (float_of_string s) | TBool b -> HVBool b | TNull -> error ("In Flash9, null can't be used as basic type " ^ s_type (print_context()) t) p | _ -> assert false) | _, Some TNull -> HVNone | k, Some c -> write ctx (HReg r.rid); write ctx HNull; let j = jump ctx J3Neq in gen_constant ctx c t p; coerce ctx k; write ctx (HSetReg r.rid); j(); HVNone ) in match !dparams with | None -> if c <> None then dparams := Some [v] | Some l -> dparams := Some (v :: l) in let args, varargs = (match List.rev args with | (({ v_name = "__arguments__"; v_type = t } as v),_) :: l -> (match follow t with | TInst ({ cl_path = ([],"Array") },_) -> List.rev l, Some (v,true) | _ -> List.rev l, Some(v,false)) | _ -> args, None ) in List.iter (fun (v,c) -> let t = v.v_type in define_local ctx v ~init:true p; match gen_local_access ctx v null_pos Write with | VReg r -> make_constant_value r c t | acc -> let r = alloc_reg ctx (classify ctx t) in make_constant_value r c t; write ctx (HReg r.rid); setvar ctx acc None ) args; (match varargs with | None -> () | Some (v,_) -> define_local ctx v ~init:true p; ignore(alloc_reg ctx (classify ctx v.v_type))); let dparams = (match !dparams with None -> None | Some l -> Some (List.rev l)) in let is_not_rethrow (_,e) = match e.eexpr with | TBlock [{ eexpr = TThrow { eexpr = TNew (_,_,[]) } }] -> false | _ -> true in let rec loop_try e = match e.eexpr with | TFunction _ -> () | TTry (_,catches) when List.exists is_not_rethrow catches -> raise Exit | _ -> Type.iter loop_try e in ctx.try_scope_reg <- (try List.iter loop_try el; None with Exit -> Some (alloc_reg ctx KDynamic)); (fun () -> let hasblock = ctx.block_vars <> [] || ctx.try_scope_reg <> None in let code = DynArray.to_list ctx.code in let extra = ( if hasblock then begin let scope = (match ctx.try_scope_reg with | None -> [HScope] | Some r -> [HDup; HSetReg r.rid; HScope] ) in HThis :: HScope :: HNewBlock :: scope end else if this_reg then [HThis; HScope] else [] ) in (* add dummy registers initialization *) let extra = extra @ List.concat (List.map (fun r -> if not r.rcond then [] else let s = [HSetReg r.rid] in match r.rtype with | KInt -> HSmallInt 0 :: s | KUInt -> HSmallInt 0 :: HToUInt :: s | KFloat -> HNaN :: s | KBool -> HFalse :: s | KType t -> HNull :: HAsType t :: s | KDynamic -> HNull :: HAsAny :: s | KNone -> HNull :: HAsType (HMPath ([],"Class")) :: s ) (DynArray.to_list ctx.infos.iregs)) in let delta = List.length extra in let f = { hlf_stack_size = (if ctx.infos.imax = 0 && (hasblock || this_reg) then 1 else ctx.infos.imax); hlf_nregs = DynArray.length ctx.infos.iregs + 1; hlf_init_scope = 1; hlf_max_scope = ctx.infos.imaxscopes + 1 + (if hasblock then 2 else if this_reg then 1 else 0); hlf_code = MultiArray.of_array (Array.of_list (extra @ code)); hlf_trys = Array.of_list (List.map (fun t -> { hltc_start = t.tr_pos + delta; hltc_end = t.tr_end + delta; hltc_handle = t.tr_catch_pos + delta; hltc_type = type_opt ctx t.tr_type; hltc_name = None; } ) (List.rev ctx.trys)); hlf_locals = Array.of_list (List.map (fun (id,name,t) -> ident name, t, id, false) ctx.block_vars); } in let mt = { (end_fun ctx args dparams tret) with hlmt_var_args = (match varargs with Some (_,true) -> true | _ -> false); hlmt_arguments_defined = (match varargs with Some (_,false) -> true | _ -> false); hlmt_new_block = hasblock; hlmt_function = Some f; } in ctx.locals <- old_locals; ctx.code <- old_code; ctx.infos <- old_infos; ctx.trys <- old_trys; ctx.block_vars <- old_bvars; ctx.in_static <- old_static; ctx.last_line <- last_line; ctx.try_scope_reg <- old_treg; mt ) let empty_method ctx p = let f = begin_fun ctx [] ctx.com.basic.tvoid [] true p in write ctx HRetVoid; f() let begin_loop ctx = let old_loop = ctx.infos.iloop in let old_breaks = ctx.breaks in let old_conts = ctx.continues in ctx.infos.iloop <- ctx.infos.istack; ctx.breaks <- []; ctx.continues <- []; (fun cont_pos -> if ctx.infos.istack <> ctx.infos.iloop then assert false; List.iter (fun j -> j()) ctx.breaks; List.iter (fun j -> j cont_pos) ctx.continues; ctx.infos.iloop <- old_loop; ctx.breaks <- old_breaks; ctx.continues <- old_conts; ) let no_value ctx retval = (* does not push a null but still increment the stack like if a real value was pushed *) if retval then ctx.infos.istack <- ctx.infos.istack + 1 let pop_value ctx retval = (* if we have multiple branches, make sure to forget about previous branch value *) if retval then ctx.infos.istack <- ctx.infos.istack - 1 let gen_expr_ref = ref (fun _ _ _ -> assert false) let gen_expr ctx e retval = (!gen_expr_ref) ctx e retval let rec gen_access ctx e (forset : 'a) : 'a access = match e.eexpr with | TLocal v -> gen_local_access ctx v e.epos forset | TField ({ eexpr = TConst TSuper } as e1,f) -> let f = field_name f in let id, _, _ = property ctx f e1.etype in write ctx HThis; VSuper id | TEnumParameter (e1,_,i) -> gen_expr ctx true e1; write ctx (HGetProp (ident "params")); write ctx (HSmallInt i); VArray | TField (e1,fa) -> let f = field_name fa in let id, k, closure = property ctx f e1.etype in if closure && not ctx.for_call then error "In Flash9, this method cannot be accessed this way : please define a local function" e1.epos; (match e1.eexpr with | TConst (TThis|TSuper) when not ctx.in_static -> write ctx (HFindProp id) | _ -> gen_expr ctx true e1); (match k with | Some t -> VCast (id,t) | None -> match follow e1.etype, follow e.etype with | _ , TFun _ when not ctx.for_call -> VCast(id,classify ctx e.etype) | TEnum _, _ -> VId id | TInst (_,tl), et -> let is_type_parameter_field = match fa with | FInstance(_,_,cf) -> (match follow cf.cf_type with TInst({cl_kind = KTypeParameter _},_) -> true | _ -> false) | _ -> List.exists (fun t -> follow t == et) tl in (* if the return type is one of the type-parameters, then we need to cast it *) if is_type_parameter_field then VCast (id, classify ctx e.etype) else if Codegen.is_volatile e.etype then VVolatile (id,None) else VId id | TAnon a, _ when (match !(a.a_status) with Statics _ | EnumStatics _ -> true | _ -> false) -> if Codegen.is_volatile e.etype then VVolatile (id,None) else VId id | _ -> if Codegen.is_volatile e.etype then VVolatile (id,Some (classify ctx e.etype)) else VCast (id,classify ctx e.etype) ) | TArray ({ eexpr = TLocal { v_name = "__global__" } },{ eexpr = TConst (TString s) }) -> let path = parse_path s in let id = type_path ctx path in if is_set forset then write ctx HGetGlobalScope; VGlobal id | TArray (e,eindex) -> gen_expr ctx true e; gen_expr ctx true eindex; VArray | TTypeExpr t -> let id = type_path ctx (t_path t) in if is_set forset then write ctx HGetGlobalScope; VGlobal id | _ -> invalid_expr e.epos let gen_expr_twice ctx e = match e.eexpr with | TLocal v -> (match get_local_register ctx v with | Some r -> write ctx (HReg r.rid); write ctx (HReg r.rid); | None -> gen_expr ctx true e; write ctx HDup) | TConst _ -> gen_expr ctx true e; gen_expr ctx true e; | _ -> gen_expr ctx true e; write ctx HDup let gen_access_rw ctx e : (read access * write access) = match e.eexpr with | TArray ({ eexpr = TLocal _ }, { eexpr = TConst _ }) | TArray ({ eexpr = TLocal _ }, { eexpr = TLocal _ }) | TField ({ eexpr = TLocal _ },_) | TField ({ eexpr = TConst _ },_) -> let w = gen_access ctx e Write in let r = gen_access ctx e Read in r, w | TArray (e,eindex) -> let r = (match e.eexpr with TLocal v -> get_local_register ctx v | _ -> None) in (match r with | None -> let r = alloc_reg ctx (classify ctx e.etype) in gen_expr ctx true e; set_reg ctx r; write ctx (HReg r.rid); gen_expr_twice ctx eindex; write ctx (HReg r.rid); write ctx HSwap; free_reg ctx r; | Some r -> write ctx (HReg r.rid); gen_expr_twice ctx eindex; write ctx (HReg r.rid); write ctx HSwap; ); VArray, VArray | TField _ -> let w = gen_access ctx e Write in write ctx HDup; Obj.magic w, w | _ -> let w = gen_access ctx e Write in let r = gen_access ctx e Read in r, w let rec gen_type ctx t = match t with | HMParams (t,tl) -> write ctx (HGetLex t); List.iter (gen_type ctx) tl; write ctx (HApplyType (List.length tl)); | _ -> write ctx (HGetLex t) let rec gen_expr_content ctx retval e = match e.eexpr with | TConst c -> gen_constant ctx c e.etype e.epos | TThrow e -> ctx.infos.icond <- true; if has_feature ctx.com "haxe.CallStack.exceptionStack" then begin getvar ctx (VGlobal (type_path ctx (["flash"],"Boot"))); let id = type_path ctx (["flash";"errors"],"Error") in write ctx (HFindPropStrict id); write ctx (HConstructProperty (id,0)); setvar ctx (VId (ident "lastError")) None; end; gen_expr ctx true e; write ctx HThrow; no_value ctx retval; | TParenthesis e | TMeta (_,e) -> gen_expr ctx retval e | TObjectDecl fl -> List.iter (fun (name,e) -> write ctx (HString (reserved name)); gen_expr ctx true e ) fl; write ctx (HObject (List.length fl)) | TArrayDecl el -> List.iter (gen_expr ctx true) el; write ctx (HArray (List.length el)) | TBlock el -> let rec loop = function | [] -> if retval then write ctx HNull | [e] -> gen_expr ctx retval e | e :: l -> gen_expr ctx false e; loop l in let b = open_block ctx retval in loop el; b(); | TVar (v,ei) -> define_local ctx v e.epos; (match ei with | None -> () | Some e -> let acc = gen_local_access ctx v e.epos Write in gen_expr ctx true e; setvar ctx acc None) | TReturn None -> write ctx HRetVoid; ctx.infos.icond <- true; no_value ctx retval | TReturn (Some e) -> gen_expr ctx true e; write ctx HRet; ctx.infos.icond <- true; no_value ctx retval | TField _ | TLocal _ | TTypeExpr _ -> getvar ctx (gen_access ctx e Read) (* both accesses return dynamic so let's cast them to the real type *) | TEnumParameter _ | TArray _ -> getvar ctx (gen_access ctx e Read); coerce ctx (classify ctx e.etype) | TBinop (op,e1,e2) -> gen_binop ctx retval op e1 e2 e.etype e.epos | TCall (f,el) -> gen_call ctx retval f el e.etype | TNew ({ cl_path = [],"Array" },_,[]) -> (* it seems that [] is 4 time faster than new Array() *) write ctx (HArray 0) | TNew (c,tl,pl) -> let id = type_id ctx (TInst (c,tl)) in (match id with | HMParams _ -> gen_type ctx id; List.iter (gen_expr ctx true) pl; write ctx (HConstruct (List.length pl)) | _ -> write ctx (HFindPropStrict id); List.iter (gen_expr ctx true) pl; write ctx (HConstructProperty (id,List.length pl)) ); | TFunction f -> write ctx (HFunction (generate_function ctx f true)) | TIf (e0,e1,e2) -> let j = jump_expr ctx e0 false in let branch = begin_branch ctx in gen_expr ctx retval e1; let t = classify ctx e.etype in if retval && classify ctx e1.etype <> t then coerce ctx t; (match e2 with | None -> j() | Some e -> (* two expresssions, but one per branch *) pop_value ctx retval; let jend = jump ctx J3Always in j(); gen_expr ctx retval e; if retval && classify ctx e.etype <> t then coerce ctx t; jend()); branch(); | TWhile (econd,e,flag) -> let jstart = jump ctx J3Always in let end_loop = begin_loop ctx in let branch = begin_branch ctx in let loop = jump_back ctx in if flag = DoWhile then jstart(); gen_expr ctx false e; if flag = NormalWhile then jstart(); let continue_pos = ctx.infos.ipos in let _ = jump_expr_gen ctx econd true (fun j -> loop j; (fun() -> ())) in branch(); end_loop continue_pos; if retval then write ctx HNull | TUnop (op,flag,e) -> gen_unop ctx retval op flag e | TTry (e2,cases) -> if ctx.infos.istack <> 0 then error "Cannot compile try/catch as a right-side expression in Flash9" e.epos; let branch = begin_branch ctx in let p = ctx.infos.ipos in gen_expr ctx retval e2; let pend = ctx.infos.ipos in let jend = jump ctx J3Always in let rec loop ncases = function | [] -> [] | (v,e) :: l -> let b = open_block ctx retval in let t = v.v_type in ctx.trys <- { tr_pos = p; tr_end = pend; tr_catch_pos = ctx.infos.ipos; tr_type = t; } :: ctx.trys; ctx.infos.istack <- ctx.infos.istack + 1; if ctx.infos.imax < ctx.infos.istack then ctx.infos.imax <- ctx.infos.istack; write ctx HThis; write ctx HScope; (match ctx.try_scope_reg with | None -> () | Some r -> write ctx (HReg r.rid); write ctx HScope); (* store the exception into local var, using a tmp register if needed *) define_local ctx v e.epos; let r = (match snd (try PMap.find v.v_id ctx.locals with Not_found -> assert false) with | LReg _ -> None | _ -> let r = alloc_reg ctx (classify ctx t) in set_reg ctx r; Some r ) in let acc = gen_local_access ctx v e.epos Write in (match r with None -> () | Some r -> write ctx (HReg r.rid)); setvar ctx acc None; (* ----- *) let rec call_loop e = match e.eexpr with | TCall _ | TNew _ -> raise Exit | TFunction _ -> () | _ -> Type.iter call_loop e in let has_call = (try call_loop e; false with Exit -> true) in if has_call && has_feature ctx.com "haxe.CallStack.exceptionStack" then begin getvar ctx (gen_local_access ctx v e.epos Read); write ctx (HAsType (type_path ctx (["flash";"errors"],"Error"))); let j = jump ctx J3False in getvar ctx (VGlobal (type_path ctx (["flash"],"Boot"))); getvar ctx (gen_local_access ctx v e.epos Read); setvar ctx (VId (ident "lastError")) None; j(); end; gen_expr ctx retval e; b(); if retval then ctx.infos.istack <- ctx.infos.istack - 1; match l with | [] -> [] | _ -> let j = jump ctx J3Always in j :: loop (ncases + 1) l in let loops = loop (List.length ctx.trys) cases in List.iter (fun j -> j()) loops; branch(); jend() | TFor (v,it,e) -> gen_expr ctx true it; let r = alloc_reg ctx KDynamic in set_reg ctx r; let branch = begin_branch ctx in let b = open_block ctx retval in define_local ctx v e.epos; let end_loop = begin_loop ctx in let continue_pos = ctx.infos.ipos in let start = jump_back ctx in write ctx (HReg r.rid); write ctx (HCallProperty (ident "hasNext",0)); let jend = jump ctx J3False in let acc = gen_local_access ctx v e.epos Write in write ctx (HReg r.rid); write ctx (HCallProperty (ident "next",0)); setvar ctx acc None; gen_expr ctx false e; start J3Always; end_loop continue_pos; jend(); if retval then getvar ctx (gen_local_access ctx v e.epos Read); b(); branch(); free_reg ctx r; | TBreak -> pop ctx (ctx.infos.istack - ctx.infos.iloop); ctx.breaks <- jump ctx J3Always :: ctx.breaks; no_value ctx retval | TContinue -> pop ctx (ctx.infos.istack - ctx.infos.iloop); let op = DynArray.length ctx.code in let p = ctx.infos.ipos in write ctx (HJump (J3Always,0)); ctx.continues <- (fun target -> DynArray.set ctx.code op (HJump (J3Always,target - p))) :: ctx.continues; no_value ctx retval | TSwitch (e0,el,eo) -> let t = classify ctx e.etype in (try let t0 = classify ctx e0.etype in (* generate optimized int switch *) if t0 <> KInt && t0 <> KUInt then raise Exit; let rec get_int e = match e.eexpr with | TConst (TInt n) -> if n < 0l || n > 512l then raise Exit; Int32.to_int n | TParenthesis e | TBlock [e] | TMeta (_,e) -> get_int e | _ -> raise Not_found in List.iter (fun (vl,_) -> List.iter (fun v -> try ignore (get_int v) with _ -> raise Exit ) vl) el; gen_expr ctx true e0; if t0 <> KInt then write ctx HToInt; let switch, case = begin_switch ctx in (match eo with | None -> if retval then begin write ctx HNull; coerce ctx t; end; | Some e -> gen_expr ctx retval e; if retval && classify ctx e.etype <> t then coerce ctx t); let jends = List.map (fun (vl,e) -> let j = jump ctx J3Always in List.iter (fun v -> case (get_int v)) vl; pop_value ctx retval; gen_expr ctx retval e; if retval && classify ctx e.etype <> t then coerce ctx t; j ) el in List.iter (fun j -> j()) jends; switch(); with Exit -> let r = alloc_reg ctx (classify ctx e0.etype) in gen_expr ctx true e0; set_reg ctx r; let branch = begin_branch ctx in let prev = ref (fun () -> ()) in let jend = List.map (fun (vl,e) -> (!prev)(); let rec loop = function | [] -> assert false | [v] -> write ctx (HReg r.rid); gen_expr ctx true v; prev := jump ctx J3Neq; | v :: l -> write ctx (HReg r.rid); gen_expr ctx true v; let j = jump ctx J3Eq in loop l; j() in loop vl; gen_expr ctx retval e; pop_value ctx retval; if retval && classify ctx e.etype <> t then coerce ctx t; jump ctx J3Always ) el in (!prev)(); free_reg ctx r; (match eo with | None -> if retval then begin write ctx HNull; coerce ctx t; end; | Some e -> gen_expr ctx retval e; if retval && classify ctx e.etype <> t then coerce ctx t; ); List.iter (fun j -> j()) jend; branch()); | TCast (e1,t) -> gen_expr ctx retval e1; if retval then begin match t with | None -> (* no error if cast failure *) let t1 = classify ctx e1.etype in let t = classify ctx e.etype in if t1 <> t then coerce ctx t; | Some t -> (* manual cast *) let tid = (match gen_access ctx (mk (TTypeExpr t) t_dynamic e.epos) Read with | VGlobal id -> id | _ -> assert false ) in match classify ctx e.etype with | KType n when (match n with HMPath ([],"String") -> false | _ -> true) -> (* for normal classes, we can use native cast *) write ctx (HCast tid) | KInt | KUInt -> (* allow any number to be cast to int (will coerce) *) write ctx HDup; write ctx (HIsType (HMPath([],"Number"))); let j = jump ctx J3True in write ctx (HString "Class cast error"); write ctx HThrow; j(); write ctx (HCast tid) | _ -> (* we need to check with "is" first, to prevent convertion *) write ctx HDup; write ctx (HIsType tid); let j = jump ctx J3True in write ctx (HString "Class cast error"); write ctx HThrow; j(); write ctx (HCast tid) end and gen_call ctx retval e el r = match e.eexpr , el with | TLocal { v_name = "__is__" }, [e;t] -> gen_expr ctx true e; gen_expr ctx true t; write ctx (HOp A3OIs) | TField (_,FStatic ({ cl_path = [],"Std" },{ cf_name = "is" })),[e;{ eexpr = TTypeExpr (TClassDecl _) } as t] -> (* fast inlining of Std.is with known values *) gen_expr ctx true e; gen_expr ctx true t; write ctx (HOp A3OIs) | TLocal { v_name = "__as__" }, [e;t] -> gen_expr ctx true e; gen_expr ctx true t; write ctx (HOp A3OAs) | TLocal { v_name = "__int__" }, [e] -> gen_expr ctx true e; write ctx HToInt | TLocal { v_name = "__float__" }, [e] -> gen_expr ctx true e; write ctx HToNumber | TLocal { v_name = "__foreach__" }, [obj;counter] -> gen_expr ctx true obj; gen_expr ctx true counter; write ctx HForEach | TLocal { v_name = "__forin__" }, [obj;counter] -> gen_expr ctx true obj; gen_expr ctx true counter; write ctx HForIn | TLocal { v_name = "__has_next__" }, [obj;counter] -> let oreg = match gen_access ctx obj Read with VReg r -> r | _ -> error "Must be a local variable" obj.epos in let creg = match gen_access ctx counter Read with VReg r -> r | _ -> error "Must be a local variable" obj.epos in write ctx (HNext (oreg.rid,creg.rid)) | TLocal { v_name = "__hkeys__" }, [e2] | TLocal { v_name = "__foreach__" }, [e2] | TLocal { v_name = "__keys__" }, [e2] -> let racc = alloc_reg ctx (KType (type_path ctx ([],"Array"))) in let rcounter = alloc_reg ctx KInt in let rtmp = alloc_reg ctx KDynamic in write ctx (HSmallInt 0); set_reg ctx rcounter; write ctx (HArray 0); set_reg ctx racc; gen_expr ctx true e2; set_reg ctx rtmp; let start = jump ctx J3Always in let loop = jump_back ctx in write ctx (HReg racc.rid); write ctx (HReg rtmp.rid); write ctx (HReg rcounter.rid); (match e.eexpr with | TLocal { v_name = "__foreach__" } -> write ctx HForEach | TLocal { v_name = "__hkeys__" } -> write ctx HForIn; write ctx (HSmallInt 1); write ctx (HCallProperty (as3 "substr",1)); | _ -> write ctx HForIn); write ctx (HCallPropVoid (as3 "push",1)); start(); write ctx (HNext (rtmp.rid,rcounter.rid)); loop J3True; write ctx (HReg racc.rid); free_reg ctx rtmp; free_reg ctx rcounter; free_reg ctx racc; | TLocal { v_name = "__new__" }, e :: el -> gen_expr ctx true e; List.iter (gen_expr ctx true) el; write ctx (HConstruct (List.length el)) | TLocal { v_name = "__delete__" }, [o;f] -> gen_expr ctx true o; gen_expr ctx true f; write ctx (HDeleteProp dynamic_prop); | TLocal { v_name = "__unprotect__" }, [e] -> write ctx (HGetLex (type_path ctx (["flash"],"Boot"))); gen_expr ctx true e; write ctx (HCallProperty (ident "__unprotect__",1)); | TLocal { v_name = "__typeof__" }, [e] -> gen_expr ctx true e; write ctx HTypeof | TLocal { v_name = "__in__" }, [e; f] -> gen_expr ctx true e; gen_expr ctx true f; write ctx (HOp A3OIn) | TLocal { v_name = "__resources__" }, [] -> let count = ref 0 in Hashtbl.iter (fun name data -> incr count; write ctx (HString "name"); write ctx (HString name); write ctx (HObject 1); ) ctx.com.resources; write ctx (HArray !count) | TLocal { v_name = "__vmem_set__" }, [{ eexpr = TConst (TInt code) };e1;e2] -> gen_expr ctx true e2; gen_expr ctx true e1; write ctx (HOp (match code with | 0l -> A3OMemSet8 | 1l -> A3OMemSet16 | 2l -> A3OMemSet32 | 3l -> A3OMemSetFloat | 4l -> A3OMemSetDouble | _ -> assert false )) | TLocal { v_name = "__vmem_get__" }, [{ eexpr = TConst (TInt code) };e] -> gen_expr ctx true e; write ctx (HOp (match code with | 0l -> A3OMemGet8 | 1l -> A3OMemGet16 | 2l -> A3OMemGet32 | 3l -> A3OMemGetFloat | 4l -> A3OMemGetDouble | _ -> assert false )) | TLocal { v_name = "__vmem_sign__" }, [{ eexpr = TConst (TInt code) };e] -> gen_expr ctx true e; write ctx (HOp (match code with | 0l -> A3OSign1 | 1l -> A3OSign8 | 2l -> A3OSign16 | _ -> assert false )) | TLocal { v_name = "__vector__" }, [ep] -> gen_type ctx (type_id ctx r); write ctx HGetGlobalScope; gen_expr ctx true ep; write ctx (HCallStack 1) | TArray ({ eexpr = TLocal { v_name = "__global__" } },{ eexpr = TConst (TString s) }), _ -> (match gen_access ctx e Read with | VGlobal id -> write ctx (HFindPropStrict id); List.iter (gen_expr ctx true) el; write ctx (HCallProperty (id,List.length el)); | _ -> assert false) | TConst TSuper , _ -> write ctx HThis; List.iter (gen_expr ctx true) el; write ctx (HConstructSuper (List.length el)); | TField ({ eexpr = TConst TSuper },f) , _ -> let id = ident (field_name f) in write ctx (HFindPropStrict id); List.iter (gen_expr ctx true) el; write ctx (HCallSuper (id,List.length el)); coerce ctx (classify ctx r); | TField ({ eexpr = TConst TThis },f) , _ when not ctx.in_static -> let id = ident (field_name f) in write ctx (HFindProp id); List.iter (gen_expr ctx true) el; if retval then begin write ctx (HCallProperty (id,List.length el)); coerce ctx (classify ctx r); end else write ctx (HCallPropVoid (id,List.length el)) | TField (e1,f) , _ -> let old = ctx.for_call in ctx.for_call <- true; gen_expr ctx true e1; let id , _, _ = property ctx (field_name f) e1.etype in ctx.for_call <- old; List.iter (gen_expr ctx true) el; if retval then begin write ctx (HCallProperty (id,List.length el)); coerce ctx (classify ctx r); end else write ctx (HCallPropVoid (id,List.length el)) | _ -> gen_expr ctx true e; write ctx HGetGlobalScope; List.iter (gen_expr ctx true) el; write ctx (HCallStack (List.length el)); coerce ctx (classify ctx r) and gen_unop ctx retval op flag e = let k = classify ctx e.etype in match op with | Not -> gen_expr ctx true e; write ctx (HOp A3ONot); | Neg -> gen_expr ctx true e; write ctx (HOp (if k = KInt then A3OINeg else A3ONeg)); | NegBits -> gen_expr ctx true e; write ctx (HOp A3OBitNot); | Increment | Decrement -> let incr = (op = Increment) in let r = (match e.eexpr with TLocal v -> get_local_register ctx v | _ -> None) in match r with | Some r when r.rtype = KInt -> if not r.rinit then r.rcond <- true; if retval && flag = Postfix then getvar ctx (VReg r); write ctx (if incr then HIncrIReg r.rid else HDecrIReg r.rid); if retval && flag = Prefix then getvar ctx (VReg r); | _ -> let acc_read, acc_write = gen_access_rw ctx e in let op = (match k, incr with | KInt, true -> A3OIIncr | KInt, false -> A3OIDecr | _ , true -> A3OIncr | _ , false -> A3ODecr ) in getvar ctx acc_read; match flag with | Postfix when retval -> let r = alloc_reg ctx k in write ctx HDup; set_reg ctx r; write ctx (HOp op); setvar ctx acc_write None; write ctx (HReg r.rid); free_reg ctx r | Postfix | Prefix -> write ctx (HOp op); setvar ctx acc_write (if retval then Some k else None) and check_binop ctx e1 e2 = let invalid = (match classify ctx e1.etype, classify ctx e2.etype with | KInt, KUInt | KUInt, KInt -> (match e1.eexpr, e2.eexpr with TConst (TInt i) , _ | _ , TConst (TInt i) -> i < 0l | _ -> true) | _ -> false) in if invalid then error "Comparison of Int and UInt might lead to unexpected results" (punion e1.epos e2.epos); and gen_binop ctx retval op e1 e2 t p = let write_op op = let iop = (match op with | OpAdd -> Some A3OIAdd | OpSub -> Some A3OISub | OpMult -> Some A3OIMul | _ -> None ) in let op = (match op with | OpAdd -> A3OAdd | OpSub -> A3OSub | OpMult -> A3OMul | OpDiv -> A3ODiv | OpAnd -> A3OAnd | OpOr -> A3OOr | OpXor -> A3OXor | OpShl -> A3OShl | OpShr -> A3OShr | OpUShr -> A3OUShr | OpMod -> A3OMod | _ -> assert false ) in match iop with | Some iop -> let k1 = classify ctx e1.etype in let k2 = classify ctx e2.etype in (match k1, k2 with | KInt, KInt | KUInt, KUInt | KInt, KUInt | KUInt, KInt -> write ctx (HOp iop); let ret = classify ctx t in if ret <> KInt then coerce ctx ret | _ -> write ctx (HOp op); (* add is a generic operation, so let's make sure we don't loose our type in the process *) if op = A3OAdd then coerce ctx (classify ctx t)) | _ -> write ctx (HOp op); if op = A3OMod && classify ctx e1.etype = KInt && classify ctx e2.etype = KInt then coerce ctx (classify ctx t); in let gen_op o = check_binop ctx e1 e2; gen_expr ctx true e1; gen_expr ctx true e2; write ctx (HOp o) in let gen_eq() = match is_special_compare e1 e2 with | None -> gen_op A3OEq | Some c -> let f = FStatic (c,try PMap.find "compare" c.cl_statics with Not_found -> assert false) in gen_expr ctx true (mk (TCall (mk (TField (mk (TTypeExpr (TClassDecl c)) t_dynamic p,f)) t_dynamic p,[e1;e2])) ctx.com.basic.tbool p); in match op with | OpAssign -> let acc = gen_access ctx e1 Write in gen_expr ctx true e2; setvar ctx acc (if retval then Some (classify ctx e1.etype) else None) | OpBoolAnd -> write ctx HFalse; let j = jump_expr ctx e1 false in let b = begin_branch ctx in write ctx HPop; gen_expr ctx true e2; coerce ctx KBool; j(); b(); | OpBoolOr -> write ctx HTrue; let j = jump_expr ctx e1 true in let b = begin_branch ctx in write ctx HPop; gen_expr ctx true e2; coerce ctx KBool; j(); b(); | OpAssignOp op -> let racc, wacc = gen_access_rw ctx e1 in getvar ctx racc; gen_expr ctx true e2; write_op op; setvar ctx wacc (if retval then Some (classify ctx e1.etype) else None) | OpAdd | OpMult | OpDiv | OpSub | OpAnd | OpOr | OpXor | OpMod -> gen_expr ctx true e1; gen_expr ctx true e2; write_op op | OpShl | OpShr | OpUShr -> gen_expr ctx true e1; gen_expr ctx true e2; write_op op; coerce ctx (classify ctx e1.etype) | OpEq -> gen_eq() | OpNotEq -> gen_eq(); write ctx (HOp A3ONot) | OpGt -> gen_op A3OGt | OpGte -> gen_op A3OGte | OpLt -> gen_op A3OLt | OpLte -> gen_op A3OLte | OpInterval | OpArrow -> assert false and gen_expr ctx retval e = let old = ctx.infos.istack in debug_infos ctx e.epos; gen_expr_content ctx retval e; if old <> ctx.infos.istack then begin if old + 1 <> ctx.infos.istack then stack_error e.epos; if not retval then write ctx HPop; end else if retval then stack_error e.epos and generate_function ctx fdata stat = let f = begin_fun ctx fdata.tf_args fdata.tf_type [fdata.tf_expr] stat fdata.tf_expr.epos in gen_expr ctx false fdata.tf_expr; (match follow fdata.tf_type with | TEnum ({ e_path = [],"Void" },[]) | TAbstract ({ a_path = [],"Void" },[]) -> debug_infos ctx ~is_min:false fdata.tf_expr.epos; write ctx HRetVoid | _ -> (* check that we have a return that can be accepted by Flash9 VM *) let rec loop e = match e.eexpr with | TBlock [] -> false | TBlock l -> loop (List.hd (List.rev l)) | TReturn None -> true | TReturn (Some e) -> let rec inner_loop e = match e.eexpr with | TSwitch _ | TFor _ | TWhile _ | TTry _ -> false | TIf _ -> loop e | TParenthesis e | TMeta(_,e) -> inner_loop e | _ -> true in inner_loop e | TIf (_,e1,Some e2) -> loop e1 && loop e2 | TParenthesis e | TMeta(_,e) -> loop e | _ -> false in if not (loop fdata.tf_expr) then write ctx HRetVoid; ); f() and jump_expr_gen ctx e jif jfun = match e.eexpr with | TParenthesis e | TMeta(_,e) -> jump_expr_gen ctx e jif jfun | TBinop (op,e1,e2) -> let j t f = check_binop ctx e1 e2; gen_expr ctx true e1; gen_expr ctx true e2; jfun (if jif then t else f) in (match op with | OpEq when is_special_compare e1 e2 = None -> j J3Eq J3Neq | OpNotEq when is_special_compare e1 e2 = None -> j J3Neq J3Eq | OpGt -> j J3Gt J3NotGt | OpGte -> j J3Gte J3NotGte | OpLt -> j J3Lt J3NotLt | OpLte -> j J3Lte J3NotLte | _ -> gen_expr ctx true e; jfun (if jif then J3True else J3False)) | _ -> gen_expr ctx true e; jfun (if jif then J3True else J3False) and jump_expr ctx e jif = jump_expr_gen ctx e jif (jump ctx) let do_debug ctx meta = let old = ctx.debug in ctx.debug <- (old || Meta.has Meta.Debug meta) && not (Meta.has Meta.NoDebug meta); (fun() -> ctx.debug <- old) let generate_method ctx fdata stat fmeta = let old = do_debug ctx fmeta in let m = generate_function ctx fdata stat in old(); m let generate_construct ctx fdata c = (* make all args optional to allow no-param constructor *) let cargs = if not ctx.need_ctor_skip then fdata.tf_args else List.map (fun (v,c) -> let c = (match c with Some _ -> c | None -> Some (match classify ctx v.v_type with | KInt | KUInt -> TInt 0l | KFloat -> TFloat "0" | KBool -> TBool false | KType _ | KDynamic | KNone -> TNull) ) in v,c ) fdata.tf_args in let f = begin_fun ctx cargs fdata.tf_type [ethis;fdata.tf_expr] false fdata.tf_expr.epos in (* if skip_constructor, then returns immediatly *) if ctx.need_ctor_skip then (match c.cl_kind with | KGenericInstance _ -> () | _ when not (Codegen.constructor_side_effects fdata.tf_expr) -> () | _ -> let id = ident "skip_constructor" in getvar ctx (VGlobal (type_path ctx (["flash"],"Boot"))); getvar ctx (VId id); let j = jump ctx J3False in write ctx HRetVoid; j()); (* --- *) PMap.iter (fun _ f -> match f.cf_expr, f.cf_kind with | Some { eexpr = TFunction fdata }, Method MethDynamic -> let id = ident f.cf_name in write ctx (HFindProp id); write ctx (HGetProp id); let j = jump ctx J3True in write ctx (HFindProp id); write ctx (HFunction (generate_method ctx fdata false [])); write ctx (HInitProp id); j(); | _ -> () ) c.cl_fields; gen_expr ctx false fdata.tf_expr; debug_infos ctx ~is_min:false fdata.tf_expr.epos; write ctx HRetVoid; f() , List.length fdata.tf_args let rec is_const e = match e.eexpr with | TConst _ -> true | TArrayDecl el | TBlock el -> List.for_all is_const el | TObjectDecl fl -> List.for_all (fun (_,e) -> is_const e) fl | TParenthesis e | TMeta(_,e) -> is_const e | TFunction _ -> true | _ -> false let generate_class_statics ctx c const = List.iter (fun f -> match f.cf_expr with | Some { eexpr = TFunction _ } when (match f.cf_kind with Method (MethNormal | MethInline) -> true | _ -> false) -> () | Some e when is_const e = const -> write ctx (HGetLex (type_path ctx c.cl_path)); gen_expr ctx true e; if Codegen.is_volatile f.cf_type then write ctx (HArray 1); write ctx (HInitProp (ident f.cf_name)); | _ -> () ) c.cl_ordered_statics let need_init ctx c = not ctx.swc && not c.cl_extern && List.exists (fun f -> match f.cf_expr with Some e -> not (is_const e) | _ -> false) c.cl_ordered_statics let generate_extern_inits ctx = List.iter (fun t -> match t with | TClassDecl c when c.cl_extern -> (match c.cl_init with | None -> () | Some e -> gen_expr ctx false e); | _ -> () ) ctx.com.types let generate_inits ctx = let finit = begin_fun ctx [] ctx.com.basic.tvoid [] true null_pos in if not ctx.swc then generate_extern_inits ctx; List.iter (fun t -> match t with | TClassDecl c when need_init ctx c -> let id = ident "init__" in getvar ctx (VGlobal (type_path ctx c.cl_path)); getvar ctx (VId id); let j = jump ctx J3True in getvar ctx (VGlobal (type_path ctx c.cl_path)); write ctx HTrue; setvar ctx (VId id) None; let branch = begin_branch ctx in generate_class_statics ctx c false; branch(); j() | _ -> () ) ctx.com.types; (match ctx.com.main with | None -> () | Some e -> gen_expr ctx false e); write ctx HRetVoid; finit() let generate_class_init ctx c hc = write ctx HGetGlobalScope; if c.cl_interface then write ctx HNull else begin let path = (match c.cl_super with None -> ([],"Object") | Some (sup,_) -> sup.cl_path) in write ctx (HGetLex (type_path ctx path)); write ctx HScope; write ctx (HGetLex (type_path ctx path)); end; write ctx (HClassDef hc); List.iter (fun f -> match f.cf_expr, f.cf_kind with | Some { eexpr = TFunction fdata }, Method MethDynamic -> write ctx HDup; write ctx (HFunction (generate_method ctx fdata true f.cf_meta)); write ctx (HInitProp (ident f.cf_name)); | _ -> () ) c.cl_ordered_statics; if not c.cl_interface then write ctx HPopScope; write ctx (HInitProp (type_path ctx c.cl_path)); if ctx.swc && c.cl_path = ctx.boot then generate_extern_inits ctx; (match c.cl_init with | None -> () | Some e -> gen_expr ctx false e; if ctx.block_vars <> [] then error "You can't have a local variable referenced from a closure inside __init__ (FP 10.1.53 crash)" e.epos; ); generate_class_statics ctx c true; if ctx.swc then begin generate_class_statics ctx c false; if ctx.block_vars <> [] then error "You can't have a local variable referenced from a closure inside a static (FP 10.1.53 crash)" c.cl_pos; end let generate_enum_init ctx e hc meta = let path = ([],"Object") in let name_id = type_path ctx e.e_path in write ctx HGetGlobalScope; write ctx (HGetLex (type_path ctx path)); write ctx HScope; write ctx (HGetLex (type_path ctx path)); write ctx (HClassDef hc); write ctx HPopScope; write ctx (HInitProp name_id); PMap.iter (fun _ f -> match f.ef_type with | TFun _ -> () | _ -> write ctx (HGetLex name_id); write ctx (HFindPropStrict name_id); write ctx (HString f.ef_name); write ctx (HInt f.ef_index); write ctx HNull; write ctx (HConstructProperty (name_id,3)); write ctx (HInitProp (ident f.ef_name)); ) e.e_constrs; write ctx (HGetLex name_id); List.iter (fun n -> write ctx (HString n)) e.e_names; write ctx (HArray (List.length e.e_names)); write ctx (HInitProp (ident "__constructs__")); match meta with | None -> () | Some e -> write ctx (HGetLex name_id); gen_expr ctx true e; write ctx (HInitProp (ident "__meta__")) let extract_meta meta = let rec loop = function | [] -> [] | (Meta.Meta,[ECall ((EConst (Ident n),_),args),_],_) :: l -> let mk_arg (a,p) = match a with | EConst (String s) -> (None, s) | EBinop (OpAssign,(EConst (Ident n),_),(EConst (String s),_)) -> (Some n, s) | _ -> error "Invalid meta definition" p in { hlmeta_name = n; hlmeta_data = Array.of_list (List.map mk_arg args) } :: loop l | _ :: l -> loop l in match loop meta with | [] -> None | l -> Some (Array.of_list l) let generate_field_kind ctx f c stat = let method_kind() = let rec loop = function | [] -> f.cf_name, MK3Normal | (Meta.Getter,[EConst (Ident f),_],_) :: _ -> f, MK3Getter | (Meta.Setter,[EConst (Ident f),_],_) :: _ -> f, MK3Setter | _ :: l -> loop l in loop f.cf_meta in if is_extern_field f then None else match f.cf_expr with | Some { eexpr = TFunction fdata } -> let rec loop c name = match c.cl_super with | None -> false | Some (c,_) -> PMap.exists name c.cl_fields || loop c name in (match f.cf_kind with | Method MethDynamic when List.memq f c.cl_overrides -> None | Var _ | Method MethDynamic -> Some (HFVar { hlv_type = Some (type_path ctx ([],"Function")); hlv_value = HVNone; hlv_const = false; }) | _ -> let name, kind = method_kind() in let m = generate_method ctx fdata stat f.cf_meta in Some (HFMethod { hlm_type = m; hlm_final = stat || (Meta.has Meta.Final f.cf_meta); hlm_override = not stat && (loop c name || loop c f.cf_name); hlm_kind = kind; }) ); | _ when c.cl_interface && not stat -> (match follow f.cf_type, f.cf_kind with | TFun (args,tret), Method (MethNormal | MethInline) -> let dparams = ref None in List.iter (fun (_,o,t) -> match !dparams with | None -> if o then dparams := Some [HVNone] | Some l -> dparams := Some (HVNone :: l) ) args; let dparams = (match !dparams with None -> None | Some l -> Some (List.rev l)) in Some (HFMethod { hlm_type = end_fun ctx (List.map (fun (a,opt,t) -> alloc_var a t, (if opt then Some TNull else None)) args) dparams tret; hlm_final = false; hlm_override = false; hlm_kind = snd (method_kind()); }) | _ -> None) | _ -> Some (HFVar { hlv_type = if Codegen.is_volatile f.cf_type then Some (type_path ctx ([],"Array")) else type_opt ctx f.cf_type; hlv_value = HVNone; hlv_const = false; }) let check_constructor ctx c f = (* check that we don't assign a super Float var before we call super() : will result in NaN *) let rec loop e = Type.iter loop e; match e.eexpr with | TCall ({ eexpr = TConst TSuper },_) -> raise Exit | TBinop (OpAssign,{ eexpr = TField({ eexpr = TConst TThis },FInstance (cc,_,cf)) },_) when c != cc && (match classify ctx cf.cf_type with KFloat | KDynamic -> true | _ -> false) -> error "You cannot assign some super class vars before calling super() in flash, this will reset them to default value" e.epos | _ -> () in try loop f.tf_expr with Exit -> () let generate_class ctx c = let name = type_path ctx c.cl_path in ctx.cur_class <- c; let cid , cnargs = (match c.cl_constructor with | None -> if c.cl_interface then { (empty_method ctx null_pos) with hlmt_function = None }, 0 else generate_construct ctx { tf_args = []; tf_type = ctx.com.basic.tvoid; tf_expr = { eexpr = TBlock []; etype = ctx.com.basic.tvoid; epos = null_pos; } } c | Some f -> match f.cf_expr with | Some { eexpr = TFunction fdata } -> let old = do_debug ctx f.cf_meta in let m = generate_construct ctx fdata c in check_constructor ctx c fdata; old(); m | _ -> assert false ) in let has_protected = ref None in let make_name f stat = let rec find_meta c = try let f = PMap.find f.cf_name (if stat then c.cl_statics else c.cl_fields) in if List.memq f c.cl_overrides then raise Not_found; f.cf_meta with Not_found -> match c.cl_super with | None -> [] | Some _ when stat -> [] | Some (c,_) -> find_meta c in let protect() = let p = (match c.cl_path with [], n -> n | p, n -> String.concat "." p ^ ":" ^ n) in has_protected := Some p; HMName (f.cf_name,HNProtected p) in let rec loop_meta = function | [] -> if not f.cf_public && ctx.swf_protected then protect() else ident f.cf_name | x :: l -> match x with | ((Meta.Getter | Meta.Setter),[EConst (Ident f),_],_) -> ident f | (Meta.Ns,[EConst (String ns),_],_) -> HMName (f.cf_name,HNNamespace ns) | (Meta.Protected,[],_) -> protect() | _ -> loop_meta l in if c.cl_interface then HMName (reserved f.cf_name, HNNamespace (match c.cl_path with [],n -> n | l,n -> String.concat "." l ^ ":" ^ n)) else loop_meta (find_meta c) in let generate_prop f acc alloc_slot = match f.cf_kind with | Method _ -> acc | Var v -> (* let p = f.cf_pos in *) (* let ethis = mk (TConst TThis) (TInst (c,[])) p in *) acc in let fields = PMap.fold (fun f acc -> let acc = generate_prop f acc (fun() -> 0) in match generate_field_kind ctx f c false with | None -> acc | Some k -> { hlf_name = make_name f false; hlf_slot = 0; hlf_kind = k; hlf_metas = extract_meta f.cf_meta; } :: acc ) c.cl_fields [] in let fields = if c.cl_path <> ctx.boot then fields else begin { hlf_name = make_name { cf_name = "init"; cf_public = ctx.swc && ctx.swf_protected; cf_meta = []; cf_doc = None; cf_pos = c.cl_pos; cf_type = TFun ([],t_dynamic); cf_params = []; cf_expr = None; cf_kind = Method MethNormal; cf_overloads = []; } false; hlf_slot = 0; hlf_kind = (HFMethod { hlm_type = generate_inits ctx; hlm_final = false; hlm_override = true; hlm_kind = MK3Normal; }); hlf_metas = None; } :: fields end in let st_field_count = ref 0 in let st_meth_count = ref 0 in let statics = List.rev (List.fold_left (fun acc f -> let acc = generate_prop f acc (fun() -> incr st_meth_count; !st_meth_count) in match generate_field_kind ctx f c true with | None -> acc | Some k -> let count = (match k with HFMethod _ -> st_meth_count | HFVar _ -> st_field_count | _ -> assert false) in incr count; { hlf_name = make_name f true; hlf_slot = !count; hlf_kind = k; hlf_metas = extract_meta f.cf_meta; } :: acc ) [] c.cl_ordered_statics) in let statics = if not (need_init ctx c) then statics else { hlf_name = ident "init__"; hlf_slot = (incr st_field_count; !st_field_count); hlf_kind = HFVar { hlv_type = (Some (type_id ctx ctx.com.basic.tbool)); hlv_value = HVNone; hlv_const = false; }; hlf_metas = None; } :: statics in let rec is_dynamic c = if c.cl_dynamic <> None || c.cl_array_access <> None then true else match c.cl_super with | None -> false | Some (c,_) -> is_dynamic c in { hlc_index = 0; hlc_name = name; hlc_super = (if c.cl_interface then None else Some (type_path ctx (match c.cl_super with None -> [],"Object" | Some (c,_) -> c.cl_path))); hlc_sealed = not (is_dynamic c); hlc_final = Meta.has Meta.Final c.cl_meta; hlc_interface = c.cl_interface; hlc_namespace = (match !has_protected with None -> None | Some p -> Some (HNProtected p)); hlc_implements = Array.of_list (List.map (fun (c,_) -> if not c.cl_interface then error "Can't implement class in Flash9" c.cl_pos; let pack, name = real_path c.cl_path in HMMultiName (Some name,[HNPublic (Some (String.concat "." pack))]) ) c.cl_implements); hlc_construct = cid; hlc_fields = Array.of_list fields; hlc_static_construct = empty_method ctx c.cl_pos; hlc_static_fields = Array.of_list statics; } let generate_enum ctx e meta = let name_id = type_path ctx e.e_path in let api = ctx.com.basic in let f = begin_fun ctx [alloc_var "tag" api.tstring, None;alloc_var "index" api.tint, None;alloc_var "params" (api.tarray (mk_mono())), None] api.tvoid [ethis] false e.e_pos in let tag_id = ident "tag" in let index_id = ident "index" in let params_id = ident "params" in write ctx (HFindProp tag_id); write ctx (HReg 1); write ctx (HInitProp tag_id); write ctx (HFindProp index_id); write ctx (HReg 2); write ctx (HInitProp index_id); write ctx (HFindProp params_id); write ctx (HReg 3); write ctx (HInitProp params_id); write ctx HRetVoid; let construct = f() in let f = begin_fun ctx [] api.tstring [] true e.e_pos in write ctx (HGetLex (type_path ctx (["flash"],"Boot"))); write ctx HThis; write ctx (HCallProperty (ident "enum_to_string",1)); write ctx HRet; let tostring = f() in let st_field_count = ref 0 in let st_meth_count = ref 0 in let constrs = PMap.fold (fun f acc -> let st_count = (match f.ef_type with TFun _ -> st_meth_count | _ -> st_field_count) in incr st_count; { hlf_name = ident f.ef_name; hlf_slot = !st_count; hlf_kind = (match f.ef_type with | TFun (args,_) -> let fdata = begin_fun ctx (List.map (fun (a,opt,t) -> alloc_var a t, (if opt then Some TNull else None)) args) (TEnum (e,[])) [] true f.ef_pos in write ctx (HFindPropStrict name_id); write ctx (HString f.ef_name); write ctx (HInt f.ef_index); let n = ref 0 in List.iter (fun _ -> incr n; write ctx (HReg !n)) args; write ctx (HArray (!n)); write ctx (HConstructProperty (name_id,3)); write ctx HRet; let fid = fdata() in HFMethod { hlm_type = fid; hlm_final = true; hlm_override = false; hlm_kind = MK3Normal; } | _ -> HFVar { hlv_type = (Some name_id); hlv_value = HVNone; hlv_const = false; } ); hlf_metas = None; } :: acc ) e.e_constrs [] in let constrs = (match meta with | None -> constrs | Some _ -> incr st_field_count; { hlf_name = ident "__meta__"; hlf_slot = !st_field_count; hlf_kind = HFVar { hlv_type = None; hlv_value = HVNone; hlv_const = false; }; hlf_metas = None; } :: constrs ) in { hlc_index = 0; hlc_name = name_id; hlc_super = Some (type_path ctx ([],"Object")); hlc_sealed = true; hlc_final = true; hlc_interface = false; hlc_namespace = None; hlc_implements = [||]; hlc_construct = construct; hlc_fields = [| { hlf_name = tag_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"String")); hlv_value = HVNone; hlv_const = false; }; hlf_metas = None }; { hlf_name = index_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"int")); hlv_value = HVNone; hlv_const = false; }; hlf_metas = None }; { hlf_name = params_id; hlf_slot = 0; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"Array")); hlv_value = HVNone; hlv_const = false; }; hlf_metas = None }; { hlf_name = ident "__enum__"; hlf_slot = 0; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"Boolean")); hlv_value = HVBool true; hlv_const = true }; hlf_metas = None }; { hlf_name = ident "toString"; hlf_slot = 0; hlf_kind = HFMethod { hlm_type = tostring; hlm_final = true; hlm_override = false; hlm_kind = MK3Normal; }; hlf_metas = None; }; |]; hlc_static_construct = empty_method ctx e.e_pos; hlc_static_fields = Array.of_list (List.rev ({ hlf_name = ident "__isenum"; hlf_slot = !st_field_count + 2; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"Boolean")); hlv_value = HVBool true; hlv_const = true; }; hlf_metas = None; } :: { hlf_name = ident "__constructs__"; hlf_slot = !st_field_count + 1; hlf_kind = HFVar { hlv_type = Some (HMPath ([],"Array")); hlv_value = HVNone; hlv_const = false; }; hlf_metas = None; } :: constrs)); } let rec generate_type ctx t = match t with | TClassDecl c -> if c.cl_path = (["flash";"_Boot"],"RealBoot") then c.cl_path <- ctx.boot; if c.cl_extern && (c.cl_path <> ([],"Dynamic") || Meta.has Meta.RealPath c.cl_meta) then None else let debug = do_debug ctx c.cl_meta in let hlc = generate_class ctx c in let init = begin_fun ctx [] ctx.com.basic.tvoid [ethis] false c.cl_pos in generate_class_init ctx c hlc; write ctx HRetVoid; debug(); Some (init(), { hlf_name = type_path ctx c.cl_path; hlf_slot = 0; hlf_kind = HFClass hlc; hlf_metas = extract_meta c.cl_meta; }) | TEnumDecl e -> if e.e_extern then None else let meta = Codegen.build_metadata ctx.com t in let hlc = generate_enum ctx e meta in let init = begin_fun ctx [] ctx.com.basic.tvoid [ethis] false e.e_pos in generate_enum_init ctx e hlc meta; write ctx HRetVoid; Some (init(), { hlf_name = type_path ctx e.e_path; hlf_slot = 0; hlf_kind = HFClass hlc; hlf_metas = extract_meta e.e_meta; }) | TAbstractDecl ({ a_path = [],"Dynamic" } as a) -> generate_type ctx (TClassDecl (mk_class a.a_module a.a_path a.a_pos)) | TTypeDecl _ | TAbstractDecl _ -> None let resource_path name = (["_res"],"_" ^ String.concat "_" (ExtString.String.nsplit name ".")) let generate_resource ctx name = let c = mk_class null_module (resource_path name) null_pos in c.cl_super <- Some (mk_class null_module (["flash";"utils"],"ByteArray") null_pos,[]); let t = TClassDecl c in match generate_type ctx t with | Some (m,f) -> (t,m,f) | None -> assert false let generate com boot_name = let ctx = { com = com; need_ctor_skip = Common.has_feature com "Type.createEmptyInstance"; debug = com.Common.debug; cur_class = null_class; boot = ([],boot_name); debugger = Common.defined com Define.Fdb; swc = Common.defined com Define.Swc; swf_protected = Common.defined com Define.SwfProtected; code = DynArray.create(); locals = PMap.empty; infos = default_infos(); trys = []; breaks = []; continues = []; block_vars = []; in_static = false; last_line = -1; last_file = ""; try_scope_reg = None; for_call = false; } in let types = if ctx.swc && com.main_class = None then (* make sure that both Boot and RealBoot are the first two classes in the SWC this way initializing RealBoot will also run externs __init__ blocks before another class static is defined *) let hd = ref [] in let types = List.fold_left (fun acc t -> match t_path t with | ["flash";"_Boot"],"RealBoot" -> hd := !hd @ [t]; acc | ["flash"], "Boot" -> hd := t :: !hd; acc | _ -> t :: acc ) [] com.types in !hd @ List.rev types else com.types in let res = Hashtbl.fold (fun name _ acc -> generate_resource ctx name :: acc) com.resources [] in let classes = List.fold_left (fun acc t -> match generate_type ctx t with | None -> acc | Some (m,f) -> (t,m,f) :: acc ) res types in List.rev classes ;; Random.self_init(); gen_expr_ref := gen_expr haxe_3.2.1+dfsg.orig/genxml.ml0000664000175000017500000004516612607337712016164 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open Common open ExtString type xml = | Node of string * (string * string) list * xml list | PCData of string | CData of string let tag name = Node (name,[],[]) let xml name att = Node (name,att,[]) let node name att childs = Node (name,att,childs) let pcdata s = PCData s let cdata s = CData s let pmap f m = PMap.fold (fun x acc -> f x :: acc) m [] let gen_path (p,n) priv = ("path",String.concat "." (p @ [n])) let gen_string s = if String.contains s '<' || String.contains s '>' || String.contains s '&' then cdata s else pcdata s let gen_doc s = (* remove trailing space and convert newlines *) let s = ExtString.String.strip s in let s = String.concat "\n" (ExtString.String.nsplit (String.concat "\n" (ExtString.String.nsplit s "\r\n")) "\r") in node "haxe_doc" [] [gen_string s] let gen_doc_opt d = match d with | None -> [] | Some s -> [gen_doc s] let gen_arg_name (name,opt,_) = (if opt then "?" else "") ^ name let real_path path meta = let rec loop = function | [] -> path | (Meta.RealPath,[(Ast.EConst (Ast.String s),_)],_) :: _ -> parse_path s | _ :: l -> loop l in loop meta let tpath t = let i = t_infos t in real_path i.mt_path i.mt_meta let rec follow_param t = match t with | TMono r -> (match !r with | Some t -> follow_param t | _ -> t) | TType ({ t_path = [],"Null" } as t,tl) -> follow_param (apply_params t.t_params tl t.t_type) | _ -> t let gen_meta meta = let meta = List.filter (fun (m,_,_) -> match m with Meta.Used | Meta.MaybeUsed | Meta.RealPath -> false | _ -> true) meta in match meta with | [] -> [] | _ -> let nodes = List.map (fun (m,el,_) -> node "m" ["n",fst (MetaInfo.to_string m)] (List.map (fun e -> node "e" [] [gen_string (Ast.s_expr e)]) el) ) meta in [node "meta" [] nodes] let rec gen_type ?(values=None) t = match t with | TMono m -> (match !m with None -> tag "unknown" | Some t -> gen_type t) | TEnum (e,params) -> gen_type_decl "e" (TEnumDecl e) params | TInst (c,params) -> gen_type_decl "c" (TClassDecl c) params | TAbstract (a,params) -> gen_type_decl "x" (TAbstractDecl a) params | TType (t,params) -> gen_type_decl "t" (TTypeDecl t) params | TFun (args,r) -> let names = String.concat ":" (List.map gen_arg_name args) in let values = match values with | None -> [] | Some values -> let has_value = ref false in let values = List.map (fun (n,_,_) -> try let e = PMap.find n values in has_value := true; let s = Ast.s_expr e in s with Not_found -> "" ) args in if !has_value then ["v",String.concat ":" values] else [] in let args = List.map (fun (_,opt,t) -> if opt then follow_param t else t ) args in node "f" (("a",names) :: values) (List.map gen_type (args @ [r])) | TAnon a -> node "a" [] (pmap (fun f -> gen_field [] { f with cf_public = false }) a.a_fields) | TDynamic t2 -> node "d" [] (if t == t2 then [] else [gen_type t2]) | TLazy f -> gen_type (!f()) and gen_type_decl n t pl = let i = t_infos t in node n [gen_path (tpath t) i.mt_private] (List.map gen_type pl) and gen_field att f = let add_get_set acc name att = match acc with | AccNormal | AccResolve | AccRequire _ -> att | AccNo | AccNever -> (name, "null") :: att | AccCall -> (name,"accessor") :: att | AccInline -> (name,"inline") :: att in let att = (match f.cf_expr with None -> att | Some e -> ("line",string_of_int (Lexer.get_error_line e.epos)) :: att) in let att,values = (match f.cf_kind with | Var v -> let att = try begin match Meta.get Meta.Value f.cf_meta with | (_,[e],_) -> ("expr",Ast.s_expr e) :: att | _ -> att end with Not_found -> att in add_get_set v.v_read "get" (add_get_set v.v_write "set" att),PMap.empty | Method m -> let att = match m with | MethNormal | MethMacro -> ("set", "method") :: att | MethDynamic -> ("set", "dynamic") :: att | MethInline -> ("get", "inline") :: ("set","null") :: att in att,get_value_meta f.cf_meta ) in let att = (match f.cf_params with [] -> att | l -> ("params", String.concat ":" (List.map (fun (n,_) -> n) l)) :: att) in let overloads = match List.map (gen_field []) f.cf_overloads with | [] -> [] | nl -> [node "overloads" [] nl] in let field_name cf = try begin match Meta.get Meta.RealPath cf.cf_meta with | _,[EConst (String (s)),_],_ -> s | _ -> raise Not_found end; with Not_found -> cf.cf_name in node (field_name f) (if f.cf_public then ("public","1") :: att else att) (gen_type ~values:(Some values) f.cf_type :: gen_meta f.cf_meta @ gen_doc_opt f.cf_doc @ overloads) let gen_constr e = let doc = gen_doc_opt e.ef_doc in let args, t = (match follow e.ef_type with | TFun (args,_) -> ["a",String.concat ":" (List.map gen_arg_name args)] , List.map (fun (_,opt,t) -> gen_type (if opt then follow_param t else t)) args @ doc | _ -> [] , doc ) in node e.ef_name args (t @ gen_meta e.ef_meta) let gen_ordered_constr e = let rec loop el = match el with | n :: el -> gen_constr (PMap.find n e.e_constrs) :: loop el | [] -> [] in loop e.e_names let gen_type_params ipos priv path params pos m = let mpriv = (if priv then [("private","1")] else []) in let mpath = (if m.m_path <> path then [("module",snd (gen_path m.m_path false))] else []) in let file = (if ipos && pos <> null_pos then [("file",pos.pfile)] else []) in gen_path path priv :: ("params", String.concat ":" (List.map fst params)) :: (file @ mpriv @ mpath) let gen_class_path name (c,pl) = node name [("path",s_type_path (tpath (TClassDecl c)))] (List.map gen_type pl) let rec exists f c = PMap.exists f.cf_name c.cl_fields || match c.cl_super with | None -> false | Some (csup,_) -> exists f csup let rec gen_type_decl com pos t = let m = (t_infos t).mt_module in match t with | TClassDecl c -> let stats = List.filter (fun cf -> cf.cf_name <> "__meta__" && not (Meta.has Meta.GenericInstance cf.cf_meta) ) c.cl_ordered_statics in let stats = List.map (gen_field ["static","1"]) stats in let fields = List.filter (fun cf -> not (Meta.has Meta.GenericInstance cf.cf_meta) ) c.cl_ordered_fields in let fields = (match c.cl_super with | None -> List.map (fun f -> f,[]) fields | Some (csup,_) -> List.map (fun f -> if exists f csup then (f,["override","1"]) else (f,[])) fields ) in let fields = List.map (fun (f,att) -> gen_field att f) fields in let constr = (match c.cl_constructor with None -> [] | Some f -> [gen_field [] f]) in let impl = List.map (gen_class_path (if c.cl_interface then "extends" else "implements")) c.cl_implements in let tree = (match c.cl_super with | None -> impl | Some x -> gen_class_path "extends" x :: impl ) in let doc = gen_doc_opt c.cl_doc in let meta = gen_meta c.cl_meta in let ext = (if c.cl_extern then [("extern","1")] else []) in let interf = (if c.cl_interface then [("interface","1")] else []) in let dynamic = (match c.cl_dynamic with | None -> [] | Some t -> [node "haxe_dynamic" [] [gen_type t]] ) in node "class" (gen_type_params pos c.cl_private (tpath t) c.cl_params c.cl_pos m @ ext @ interf) (tree @ stats @ fields @ constr @ doc @ meta @ dynamic) | TEnumDecl e -> let doc = gen_doc_opt e.e_doc in let meta = gen_meta e.e_meta in node "enum" (gen_type_params pos e.e_private (tpath t) e.e_params e.e_pos m) (gen_ordered_constr e @ doc @ meta) | TTypeDecl t -> let doc = gen_doc_opt t.t_doc in let meta = gen_meta t.t_meta in let tt = gen_type t.t_type in node "typedef" (gen_type_params pos t.t_private t.t_path t.t_params t.t_pos m) (tt :: doc @ meta) | TAbstractDecl a -> let doc = gen_doc_opt a.a_doc in let meta = gen_meta a.a_meta in let mk_cast t = node "icast" [] [gen_type t] in let mk_field_cast (t,cf) = node "icast" ["field",cf.cf_name] [gen_type t] in let sub = (match a.a_from,a.a_from_field with [],[] -> [] | l1,l2 -> [node "from" [] ((List.map mk_cast l1) @ (List.map mk_field_cast l2))]) in let super = (match a.a_to,a.a_to_field with [],[] -> [] | l1,l2 -> [node "to" [] ((List.map mk_cast l1) @ (List.map mk_field_cast l2))]) in let impl = (match a.a_impl with None -> [] | Some c -> [node "impl" [] [gen_type_decl com pos (TClassDecl c)]]) in let this = [node "this" [] [gen_type a.a_this]] in node "abstract" (gen_type_params pos a.a_private (tpath t) a.a_params a.a_pos m) (sub @ this @ super @ doc @ meta @ impl) let escape_entities s = Xml.to_string (Xml.PCData s) let att_str att = String.concat "" (List.map (fun (a,v) -> Printf.sprintf " %s=\"%s\"" a (escape_entities v)) att) let rec write_xml ch tabs x = match x with | Node (name,att,[]) -> IO.printf ch "%s<%s%s/>" tabs name (att_str att) | Node (name,att,[x]) -> IO.printf ch "%s<%s%s>" tabs name (att_str att); write_xml ch "" x; IO.printf ch "" name; | Node (name,att,childs) -> IO.printf ch "%s<%s%s>\n" tabs name (att_str att); List.iter (fun x -> write_xml ch (tabs ^ "\t") x; IO.printf ch "\n"; ) childs; IO.printf ch "%s" tabs name | PCData s -> IO.printf ch "%s" s | CData s -> IO.printf ch "" s let generate com file = let t = Common.timer "construct xml" in let x = node "haxe" [] (List.map (gen_type_decl com true) (List.filter (fun t -> not (Meta.has Meta.NoDoc (t_infos t).mt_meta)) com.types)) in t(); let t = Common.timer "write xml" in let ch = IO.output_channel (open_out_bin file) in write_xml ch "" x; IO.close_out ch; t() let gen_type_string ctx t = let x = gen_type_decl ctx false t in let ch = IO.output_string() in write_xml ch "" x; IO.close_out ch (* -------------------------------------------------------------------------- *) (* PRINT HX FROM TYPE *) let rec create_dir acc = function | [] -> () | d :: l -> let path = acc ^ "/" ^ d in (try Unix.mkdir path 0o777 with _ -> ()); create_dir path l let conv_path p = match List.rev (fst p) with | x :: l when x.[0] = '_' -> List.rev (("priv" ^ x) :: l), snd p | _ -> p let get_real_path meta path = try let real_path = match Meta.get Meta.RealPath meta with | (_,[(EConst(String s),_)],_) -> s | _ -> raise Not_found in match List.rev (String.nsplit real_path ".") with | name :: pack -> (List.rev pack), name | _ -> raise Not_found with | Not_found -> path let generate_type com t = let base_path = "hxclasses" in let pack, name = let info = t_infos t in get_real_path info.mt_meta info.mt_path in create_dir "." (base_path :: pack); match pack, name with | ["flash";"net"], "NetStreamPlayTransitions" | ["flash";"filters"], "BitmapFilterQuality" | ["flash";"display"], ("BitmapDataChannel" | "GraphicsPathCommand") -> () | _ -> let f = open_out_bin (base_path ^ "/" ^ (match pack with [] -> "" | l -> String.concat "/" l ^ "/") ^ name ^ ".hx") in let ch = IO.output_channel f in let p fmt = IO.printf ch fmt in if pack <> [] then IO.printf ch "package %s;\n\n" (String.concat "." pack); let rec notnull t = match t with | TMono r -> (match !r with | None -> t | Some t -> notnull t) | TLazy f -> notnull ((!f)()) | TType ({ t_path = [],"Null" },[t]) -> t | _ -> t in let rec path meta p tl = let p = conv_path (get_real_path meta p) in (if fst p = pack then snd p else s_type_path p) ^ (match tl with [] -> "" | _ -> "<" ^ String.concat "," (List.map stype tl) ^ ">") and stype t = match t with | TMono r -> (match !r with | None -> "Unknown" | Some t -> stype t) | TInst ({ cl_kind = KTypeParameter _ } as c,tl) -> path [] ([],snd c.cl_path) tl | TInst (c,tl) -> path c.cl_meta c.cl_path tl | TEnum (e,tl) -> path e.e_meta e.e_path tl | TType (t,tl) -> path t.t_meta t.t_path tl | TAbstract (a,tl) -> path a.a_meta a.a_path tl | TAnon a -> let fields = PMap.fold (fun f acc -> (f.cf_name ^ " : " ^ stype f.cf_type) :: acc) a.a_fields [] in "{" ^ String.concat ", " fields ^ "}" | TLazy f -> stype ((!f)()) | TDynamic t2 -> if t == t2 then "Dynamic" else "Dynamic<" ^ stype t2 ^ ">" | TFun ([],ret) -> "Void -> " ^ ftype ret | TFun (args,ret) -> String.concat " -> " (List.map (fun (_,_,t) -> ftype t) args) ^ " -> " ^ ftype ret and ftype t = match t with | TMono r -> (match !r with | None -> stype t | Some t -> ftype t) | TLazy f -> ftype ((!f)()) | TFun _ -> "(" ^ stype t ^ ")" | _ -> stype t in let sparam (n,v,t) = match v with | None -> n ^ " : " ^ stype t | Some (Ident "null") -> if is_nullable (notnull t) then "?" ^ n ^ " : " ^ stype (notnull t) else (* we have not found a default value stored in metadata, let's generate it *) n ^ " : " ^ stype t ^ " = " ^ (match follow t with | TAbstract ({ a_path = [],("Int"|"Float"|"UInt") },_) -> "0" | TAbstract ({ a_path = [],"Bool" },_) -> "false" | _ -> "null") | Some v -> n ^ " : " ^ stype t ^ " = " ^ (match s_constant v with "nan" -> "0./*NaN*/" | v -> v) in let print_meta ml = List.iter (fun (m,pl,_) -> match m with | Meta.DefParam | Meta.CoreApi | Meta.Used | Meta.MaybeUsed | Meta.FlatEnum | Meta.Value | Meta.DirectlyUsed -> () | _ -> match pl with | [] -> p "@%s " (fst (MetaInfo.to_string m)) | l -> p "@%s(%s) " (fst (MetaInfo.to_string m)) (String.concat "," (List.map Ast.s_expr pl)) ) ml in let access is_read a = match a, pack with | AccNever, "flash" :: _ -> "null" | _ -> s_access is_read a in let rec print_field stat f = p "\t"; print_meta f.cf_meta; if stat then p "static "; let name = try (match Meta.get Meta.RealPath f.cf_meta with | (Meta.RealPath, [EConst( String s ), _], _) -> s | _ -> raise Not_found) with Not_found -> f.cf_name in (match f.cf_kind with | Var v -> p "var %s" name; if v.v_read <> AccNormal || v.v_write <> AccNormal then p "(%s,%s)" (access true v.v_read) (access false v.v_write); p " : %s" (stype f.cf_type); | Method m -> let params, ret = (match follow f.cf_type with | TFun (args,ret) -> List.map (fun (a,o,t) -> let rec loop = function | [] -> Ident "null" | (Meta.DefParam,[(EConst (String p),_);(EConst v,_)],_) :: _ when p = a -> (match v with | Float "1.#QNAN" -> Float "0./*NaN*/" | Float "4294967295." -> Int "0xFFFFFFFF" | Int "16777215" -> Int "0xFFFFFF" | Float x -> (try let f = float_of_string x in let s = string_of_int (int_of_float f) in if s ^ "." = x then Int s else v with _ -> v) | _ -> v) | _ :: l -> loop l in a,(if o then Some (loop f.cf_meta) else None ),t ) args, ret | _ -> assert false ) in let tparams = (match f.cf_params with [] -> "" | l -> "<" ^ String.concat "," (List.map fst l) ^ ">") in p "function %s%s(%s) : %s" name tparams (String.concat ", " (List.map sparam params)) (stype ret); ); p ";\n"; if Meta.has Meta.Overload f.cf_meta then List.iter (fun f -> print_field stat f) f.cf_overloads in (match t with | TClassDecl c -> print_meta c.cl_meta; p "extern %s %s" (if c.cl_interface then "interface" else "class") (stype (TInst (c,List.map snd c.cl_params))); let ext = (match c.cl_super with | None -> [] | Some (c,pl) -> [" extends " ^ stype (TInst (c,pl))] ) in let ext = List.fold_left (fun acc (i,pl) -> ((if c.cl_interface then " extends " else " implements ") ^ stype (TInst (i,pl))) :: acc) ext c.cl_implements in let ext = (match c.cl_dynamic with | None -> ext | Some t -> (match c.cl_path with | ["flash";"errors"], _ -> ext | _ when t == t_dynamic -> " implements Dynamic" :: ext | _ -> (" implements Dynamic<" ^ stype t ^ ">") :: ext) ) in let ext = (match c.cl_path with | ["flash";"utils"], "ByteArray" -> " implements ArrayAccess" :: ext | ["flash";"utils"], "Dictionnary" -> [" implements ArrayAccess"] | ["flash";"xml"], "XML" -> [" implements Dynamic"] | ["flash";"xml"], "XMLList" -> [" implements ArrayAccess"] | ["flash";"display"],"MovieClip" -> [" extends Sprite #if !flash_strict implements Dynamic #end"] | ["flash";"errors"], "Error" -> [" #if !flash_strict implements Dynamic #end"] | _ -> ext ) in p "%s" (String.concat "" (List.rev ext)); p " {\n"; let sort l = let a = Array.of_list (List.filter (fun f -> f.cf_public && not (List.memq f c.cl_overrides)) l) in let name = function "new" -> "" | n -> n in Array.sort (fun f1 f2 -> match f1.cf_kind, f2.cf_kind with | Var _, Var _ | Method _ , Method _ -> compare (name f1.cf_name) (name f2.cf_name) | Var _, _ -> -1 | _ -> 1 ) a; Array.to_list a in List.iter (print_field false) (sort (match c.cl_constructor with None -> c.cl_ordered_fields | Some f -> f :: c.cl_ordered_fields)); List.iter (print_field true) (sort c.cl_ordered_statics); p "}\n"; | TEnumDecl e -> print_meta e.e_meta; p "extern enum %s {\n" (stype (TEnum(e,List.map snd e.e_params))); let sort l = let a = Array.of_list l in Array.sort compare a; Array.to_list a in List.iter (fun n -> let c = PMap.find n e.e_constrs in p "\t%s" c.ef_name; (match follow c.ef_type with | TFun (args,_) -> p "(%s)" (String.concat ", " (List.map sparam (List.map (fun (a,o,t) -> a,(if o then Some (Ident "null") else None),t) args))) | _ -> ()); p ";\n"; ) (if Meta.has Meta.FakeEnum e.e_meta then sort e.e_names else e.e_names); p "}\n" | TTypeDecl t -> print_meta t.t_meta; p "typedef %s = " (stype (TType (t,List.map snd t.t_params))); p "%s" (stype t.t_type); p "\n"; | TAbstractDecl a -> print_meta a.a_meta; p "abstract %s {}" (stype (TAbstract (a,List.map snd a.a_params))); ); IO.close_out ch let generate_hx com = List.iter (generate_type com) com.types haxe_3.2.1+dfsg.orig/haxe.hxproj0000664000175000017500000001241612607337712016511 0ustar andyandy00000000000000 make -j4 MSVC=1 FD_OUTPUT=1 -f Makefile.win kill haxe haxe_3.2.1+dfsg.orig/interp.ml0000664000175000017500000045631112607337712016171 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Common open Nast open Unix open Type (* ---------------------------------------------------------------------- *) (* TYPES *) type value = | VNull | VBool of bool | VInt of int | VFloat of float | VString of string | VObject of vobject | VArray of value array | VAbstract of vabstract | VFunction of vfunction | VClosure of value list * (value list -> value list -> value) | VInt32 of int32 and vobject = { mutable ofields : (int * value) array; mutable oproto : vobject option; } and vabstract = | ADeallocated of int ref | AKind of vabstract | AHash of (value, value) Hashtbl.t | ARandom of Random.State.t ref | ABuffer of Buffer.t | APos of Ast.pos | AFRead of (in_channel * bool ref) | AFWrite of out_channel | AReg of regexp | AZipI of zlib | AZipD of zlib | AUtf8 of UTF8.Buf.buf | ASocket of Unix.file_descr | ATDecl of module_type | AUnsafe of Obj.t | ALazyType of (unit -> Type.t) ref | ANekoAbstract of Extc.value | ANekoBuffer of value | ACacheRef of value | AInt32Kind | ATls of value ref | AProcess of Process.process and vfunction = | Fun0 of (unit -> value) | Fun1 of (value -> value) | Fun2 of (value -> value -> value) | Fun3 of (value -> value -> value -> value) | Fun4 of (value -> value -> value -> value -> value) | Fun5 of (value -> value -> value -> value -> value -> value) | FunVar of (value list -> value) and regexp = { r : Str.regexp; mutable r_string : string; mutable r_groups : (int * int) option array; } and zlib = { z : Extc.zstream; mutable z_flush : Extc.zflush; } type cmp = | CEq | CSup | CInf | CUndef type extern_api = { pos : Ast.pos; get_com : unit -> Common.context; get_type : string -> Type.t option; get_module : string -> Type.t list; on_generate : (Type.t list -> unit) -> unit; after_generate : (unit -> unit) -> unit; on_type_not_found : (string -> value) -> unit; parse_string : string -> Ast.pos -> bool -> Ast.expr; type_expr : Ast.expr -> Type.texpr; store_typed_expr : Type.texpr -> Ast.expr; get_display : string -> string; allow_package : string -> unit; type_patch : string -> string -> bool -> string option -> unit; meta_patch : string -> string -> string option -> bool -> unit; set_js_generator : (value -> unit) -> unit; get_local_type : unit -> t option; get_expected_type : unit -> t option; get_call_arguments : unit -> Ast.expr list option; get_local_method : unit -> string; get_local_using : unit -> tclass list; get_local_vars : unit -> (string, Type.tvar) PMap.t; get_build_fields : unit -> value; get_pattern_locals : Ast.expr -> Type.t -> (string,Type.tvar * Ast.pos) PMap.t; define_type : value -> unit; define_module : string -> value list -> ((string * Ast.pos) list * Ast.import_mode) list -> Ast.type_path list -> unit; module_dependency : string -> string -> bool -> unit; current_module : unit -> module_def; delayed_macro : int -> (unit -> (unit -> value)); use_cache : unit -> bool; format_string : string -> Ast.pos -> Ast.expr; cast_or_unify : Type.t -> texpr -> Ast.pos -> Type.texpr; add_global_metadata : string -> string -> (bool * bool * bool) -> unit; } type callstack = { cpos : pos; cthis : value; cstack : int; cenv : value array; } type context = { gen : Genneko.context; types : (Type.path,int) Hashtbl.t; prototypes : (string list, vobject) Hashtbl.t; fields_cache : (int,string) Hashtbl.t; mutable error : bool; mutable error_proto : vobject; mutable enums : (value * string) array array; mutable do_call : value -> value -> value list -> pos -> value; mutable do_string : value -> string; mutable do_loadprim : value -> value -> value; mutable do_compare : value -> value -> cmp; mutable loader : value; mutable exports : value; (* runtime *) mutable stack : value DynArray.t; mutable callstack : callstack list; mutable callsize : int; mutable exc : pos list; mutable vthis : value; mutable venv : value array; (* context *) mutable curapi : extern_api; mutable on_reused : (unit -> bool) list; mutable is_reused : bool; (* eval *) mutable locals_map : (string, int) PMap.t; mutable locals_count : int; mutable locals_barrier : int; mutable locals_env : string DynArray.t; mutable globals : (string, value ref) PMap.t; } type access = | AccThis | AccLocal of int | AccGlobal of value ref | AccEnv of int | AccField of (unit -> value) * string | AccArray of (unit -> value) * (unit -> value) exception Runtime of value exception Builtin_error exception Error of string * Ast.pos list exception Abort exception Continue exception Break of value exception Return of value exception Invalid_expr exception Sys_exit of int (* ---------------------------------------------------------------------- *) (* UTILS *) let get_ctx_ref = ref (fun() -> assert false) let encode_complex_type_ref = ref (fun t -> assert false) let encode_type_ref = ref (fun t -> assert false) let decode_type_ref = ref (fun t -> assert false) let encode_expr_ref = ref (fun e -> assert false) let decode_expr_ref = ref (fun e -> assert false) let encode_texpr_ref = ref (fun e -> assert false) let decode_texpr_ref = ref (fun e -> assert false) let encode_clref_ref = ref (fun c -> assert false) let enc_hash_ref = ref (fun h -> assert false) let enc_array_ref = ref (fun l -> assert false) let dec_array_ref = ref (fun v -> assert false) let enc_string_ref = ref (fun s -> assert false) let make_ast_ref = ref (fun _ -> assert false) let make_complex_type_ref = ref (fun _ -> assert false) let encode_tvar_ref = ref (fun _ -> assert false) let decode_path_ref = ref (fun _ -> assert false) let decode_import_ref = ref (fun _ -> assert false) let get_ctx() = (!get_ctx_ref)() let enc_array (l:value list) : value = (!enc_array_ref) l let dec_array (l:value) : value list = (!dec_array_ref) l let encode_complex_type (t:Ast.complex_type) : value = (!encode_complex_type_ref) t let encode_type (t:Type.t) : value = (!encode_type_ref) t let decode_type (v:value) : Type.t = (!decode_type_ref) v let encode_expr (e:Ast.expr) : value = (!encode_expr_ref) e let decode_expr (e:value) : Ast.expr = (!decode_expr_ref) e let encode_texpr (e:Type.texpr) : value = (!encode_texpr_ref) e let decode_texpr (v:value) : Type.texpr = (!decode_texpr_ref) v let encode_clref (c:tclass) : value = (!encode_clref_ref) c let enc_hash (h:('a,'b) Hashtbl.t) : value = (!enc_hash_ref) h let make_ast (e:texpr) : Ast.expr = (!make_ast_ref) e let enc_string (s:string) : value = (!enc_string_ref) s let make_complex_type (t:Type.t) : Ast.complex_type = (!make_complex_type_ref) t let encode_tvar (v:tvar) : value = (!encode_tvar_ref) v let decode_path (v:value) : Ast.type_path = (!decode_path_ref) v let decode_import (v:value) : ((string * Ast.pos) list * Ast.import_mode) = (!decode_import_ref) v let to_int f = Int32.of_float (mod_float f 2147483648.0) let need_32_bits i = Int32.compare (Int32.logand (Int32.add i 0x40000000l) 0x80000000l) Int32.zero <> 0 let best_int i = if need_32_bits i then VInt32 i else VInt (Int32.to_int i) let make_pos p = let low = p.pline land 0xFFFFF in { Ast.pfile = p.psource; Ast.pmin = low; Ast.pmax = low + (p.pline lsr 20); } let warn ctx msg p = (ctx.curapi.get_com()).Common.warning msg (make_pos p) let rec pop ctx n = if n > 0 then begin DynArray.delete_last ctx.stack; pop ctx (n - 1); end let pop_ret ctx f n = let v = f() in pop ctx n; v let push ctx v = DynArray.add ctx.stack v let hash f = let h = ref 0 in for i = 0 to String.length f - 1 do h := !h * 223 + int_of_char (String.unsafe_get f i); done; if Sys.word_size = 64 then Int32.to_int (Int32.shift_right (Int32.shift_left (Int32.of_int !h) 1) 1) else !h let constants = let h = Hashtbl.create 0 in List.iter (fun f -> Hashtbl.add h (hash f) f) ["done";"read";"write";"min";"max";"file";"args";"loadprim";"loadmodule";"__a";"__s";"h"; "tag";"index";"length";"message";"pack";"name";"params";"sub";"doc";"kind";"meta";"access"; "constraints";"opt";"type";"value";"ret";"expr";"field";"values";"get";"__string";"toString"; "$";"add";"remove";"has";"__t";"module";"isPrivate";"isPublic";"isExtern";"isInterface";"exclude"; "constructs";"names";"superClass";"interfaces";"fields";"statics";"constructor";"init";"t"; "gid";"uid";"atime";"mtime";"ctime";"dev";"ino";"nlink";"rdev";"size";"mode";"pos";"len"; "binops";"unops";"from";"to";"array";"op";"isPostfix";"impl"; "id";"capture";"extra";"v";"ids";"vars";"en";"overrides";"status"]; h let h_get = hash "__get" and h_set = hash "__set" and h_add = hash "__add" and h_radd = hash "__radd" and h_sub = hash "__sub" and h_rsub = hash "__rsub" and h_mult = hash "__mult" and h_rmult = hash "__rmult" and h_div = hash "__div" and h_rdiv = hash "__rdiv" and h_mod = hash "__mod" and h_rmod = hash "__rmod" and h_string = hash "__string" and h_compare = hash "__compare" and h_constructs = hash "__constructs__" and h_a = hash "__a" and h_s = hash "__s" and h_class = hash "__class__" let exc v = raise (Runtime v) let hash_field ctx f = let h = hash f in (try let f2 = Hashtbl.find ctx.fields_cache h in if f <> f2 then exc (VString ("Field conflict between " ^ f ^ " and " ^ f2)); with Not_found -> Hashtbl.add ctx.fields_cache h f); h let field_name ctx fid = try Hashtbl.find ctx.fields_cache fid with Not_found -> "???" let obj hash fields = let fields = Array.of_list (List.map (fun (k,v) -> hash k, v) fields) in Array.sort (fun (k1,_) (k2,_) -> compare k1 k2) fields; { ofields = fields; oproto = None; } let parse_int s = let rec loop_hex i = if i = String.length s then s else match String.unsafe_get s i with | '0'..'9' | 'a'..'f' | 'A'..'F' -> loop_hex (i + 1) | _ -> String.sub s 0 i in let rec loop sp i = if i = String.length s then (if sp = 0 then s else String.sub s sp (i - sp)) else match String.unsafe_get s i with | '0'..'9' -> loop sp (i + 1) | ' ' when sp = i -> loop (sp + 1) (i + 1) | '-' when i = 0 -> loop sp (i + 1) | ('x' | 'X') when i = 1 && String.get s 0 = '0' -> loop_hex (i + 1) | _ -> String.sub s sp (i - sp) in best_int (Int32.of_string (loop 0 0)) let parse_float s = let rec loop sp i = if i = String.length s then (if sp = 0 then s else String.sub s sp (i - sp)) else match String.unsafe_get s i with | ' ' when sp = i -> loop (sp + 1) (i + 1) | '0'..'9' | '-' | '+' | 'e' | 'E' | '.' -> loop sp (i + 1) | _ -> String.sub s sp (i - sp) in float_of_string (loop 0 0) let find_sub str sub start = let sublen = String.length sub in if sublen = 0 then 0 else let found = ref 0 in let len = String.length str in try for i = start to len - sublen do let j = ref 0 in while String.unsafe_get str (i + !j) = String.unsafe_get sub !j do incr j; if !j = sublen then begin found := i; raise Exit; end; done; done; raise Not_found with Exit -> !found let nargs = function | Fun0 _ -> 0 | Fun1 _ -> 1 | Fun2 _ -> 2 | Fun3 _ -> 3 | Fun4 _ -> 4 | Fun5 _ -> 5 | FunVar _ -> -1 let rec get_field o fid = let rec loop min max = if min < max then begin let mid = (min + max) lsr 1 in let cid, v = Array.unsafe_get o.ofields mid in if cid < fid then loop (mid + 1) max else if cid > fid then loop min mid else v end else match o.oproto with | None -> VNull | Some p -> get_field p fid in loop 0 (Array.length o.ofields) let set_field o fid v = let rec loop min max = let mid = (min + max) lsr 1 in if min < max then begin let cid, _ = Array.unsafe_get o.ofields mid in if cid < fid then loop (mid + 1) max else if cid > fid then loop min mid else Array.unsafe_set o.ofields mid (cid,v) end else let fields = Array.make (Array.length o.ofields + 1) (fid,v) in Array.blit o.ofields 0 fields 0 mid; Array.blit o.ofields mid fields (mid + 1) (Array.length o.ofields - mid); o.ofields <- fields in loop 0 (Array.length o.ofields) let rec remove_field o fid = let rec loop min max = let mid = (min + max) lsr 1 in if min < max then begin let cid, v = Array.unsafe_get o.ofields mid in if cid < fid then loop (mid + 1) max else if cid > fid then loop min mid else begin let fields = Array.make (Array.length o.ofields - 1) (fid,VNull) in Array.blit o.ofields 0 fields 0 mid; Array.blit o.ofields (mid + 1) fields mid (Array.length o.ofields - mid - 1); o.ofields <- fields; true end end else false in loop 0 (Array.length o.ofields) let rec get_field_opt o fid = let rec loop min max = if min < max then begin let mid = (min + max) lsr 1 in let cid, v = Array.unsafe_get o.ofields mid in if cid < fid then loop (mid + 1) max else if cid > fid then loop min mid else Some v end else match o.oproto with | None -> None | Some p -> get_field_opt p fid in loop 0 (Array.length o.ofields) let catch_errors ctx ?(final=(fun() -> ())) f = let n = DynArray.length ctx.stack in try let v = f() in final(); Some v with Runtime v -> pop ctx (DynArray.length ctx.stack - n); final(); let rec loop o = if o == ctx.error_proto then true else match o.oproto with None -> false | Some p -> loop p in (match v with | VObject o when loop o -> (match get_field o (hash "message"), get_field o (hash "pos") with | VObject msg, VAbstract (APos pos) -> (match get_field msg h_s with | VString msg -> raise (Typecore.Error (Typecore.Custom msg,pos)) | _ -> ()); | _ -> ()); | _ -> ()); raise (Error (ctx.do_string v,List.map (fun s -> make_pos s.cpos) ctx.callstack)) | Abort -> pop ctx (DynArray.length ctx.stack - n); final(); None let make_library fl = let h = Hashtbl.create 0 in List.iter (fun (n,f) -> Hashtbl.add h n f) fl; h (* ---------------------------------------------------------------------- *) (* NEKO INTEROP *) type primitive = (string * Extc.value * int) type neko_context = { load : string -> int -> primitive; call : primitive -> value list -> value; } let neko = let is_win = Sys.os_type = "Win32" || Sys.os_type = "Cygwin" in let neko = Extc.dlopen (if is_win then "neko.dll" else "libneko.so") in let null = Extc.dlint 0 in let neko = if Obj.magic neko == null && not is_win then Extc.dlopen "libneko.dylib" else neko in if Obj.magic neko == null then None else let load v = let s = Extc.dlsym neko v in if (Obj.magic s) == null then failwith ("Could not load neko." ^ v); s in ignore(Extc.dlcall0 (load "neko_global_init")); let vm = Extc.dlcall1 (load "neko_vm_alloc") null in ignore(Extc.dlcall1 (load "neko_vm_select") vm); let loader = Extc.dlcall2 (load "neko_default_loader") null null in let loadprim = let l1 = load "neko_val_field" in let l2 = Extc.dlcall1 (load "neko_val_id") (Extc.dlstring "loadprim") in Extc.dlcall2 (l1) loader (l2) in let callN = load "neko_val_callN" in let callEx = load "neko_val_callEx" in let copy_string = load "neko_copy_string" in let alloc_root = load "neko_alloc_root" in let free_root = load "neko_free_root" in let alloc_root v = let r = Extc.dlcall1 alloc_root (Extc.dlint 1) in Extc.dlsetptr r v; r in let free_root r = ignore(Extc.dlcall1 free_root r) in ignore(alloc_root vm); ignore(alloc_root loader); ignore(alloc_root loadprim); let alloc_string s = Extc.dlcall2 copy_string (Extc.dlstring s) (Extc.dlint (String.length s)) in let alloc_int (i:int) : Extc.value = Obj.magic i in let loadprim n args = let exc = ref null in let vargs = [|alloc_string n;alloc_int args|] in let p = Extc.dlcall5 callEx loader loadprim (Obj.magic vargs) (Extc.dlint 2) (Obj.magic exc) in if !exc != null then failwith ("Failed to load " ^ n ^ ":" ^ string_of_int args); ignore(alloc_root p); (n,p,args) in let call_raw_prim (_,p,nargs) (args:Extc.value array) = Extc.dlcall3 callN p (Obj.magic args) (Extc.dlint nargs) in (* a bit tricky since load "val_true" does not work as expected on Windows *) let unser = try loadprim "std@unserialize" 2 with _ -> ("",null,0) in (* did we fail to load std.ndll ? *) if (match unser with ("",_,_) -> true | _ -> false) then None else let val_true = call_raw_prim unser [|alloc_string "T";loader|] in let val_false = call_raw_prim unser [|alloc_string "F";loader|] in let val_null = call_raw_prim unser [|alloc_string "N";loader|] in let is_64 = call_raw_prim (loadprim "std@sys_is64" 0) [||] == val_true in let alloc_i32, is_v2 = (try load "neko_alloc_int32", true with _ -> Obj.magic 0, false) in let alloc_i32 = if is_v2 then (fun i -> Extc.dlcall1 alloc_i32 (Extc.dlint32 i)) else (fun i -> alloc_int (Int32.to_int (if Int32.compare i Int32.zero < 0 then Int32.logand i 0x7FFFFFFFl else Int32.logor i 0x80000000l))) in let tag_bits = if is_v2 then 4 else 3 in let tag_mask = (1 lsl tag_bits) - 1 in let ptr_size = if is_64 then 8 else 4 in let val_field v i = Extc.dladdr v ((i + 1) * ptr_size) in let val_str v = Extc.dladdr v 4 in let val_fun_env v = Extc.dladdr v (8 + ptr_size) in (* alloc support *) let alloc_function = load "neko_alloc_function" in let alloc_array = load "neko_alloc_array" in let alloc_float = load "neko_alloc_float" in let alloc_object = load "neko_alloc_object" in let alloc_field = load "neko_alloc_field" in let alloc_abstract = load "neko_alloc_abstract" in let val_gc = load "neko_val_gc" in let val_field_name = load "neko_val_field_name" in let val_iter_fields = load "neko_val_iter_fields" in let gen_callback = Extc.dlcaml_callback 2 in (* roots *) let on_abstract_gc = Extc.dlcaml_callback 1 in let root_index = ref 0 in let roots = Hashtbl.create 0 in Callback.register "dlcallb1" (fun a -> let index : int = Obj.magic (Extc.dlptr (val_field a 1)) in Hashtbl.remove roots index; null ); (* wrapping *) let copy_string v = let head = Extc.dltoint (Extc.dlptr v) in let size = head asr tag_bits in let s = String.create size in Extc.dlmemcpy (Extc.dlstring s) (val_str v) size; s in let buffers = ref [] in let rec value_neko ?(obj=VNull) = function | VNull -> val_null | VBool b -> if b then val_true else val_false | VInt i -> alloc_int i | VAbstract (ANekoAbstract a) -> a | VAbstract (ANekoBuffer (VString buf)) -> let v = value_neko (VString buf) in buffers := (buf,v) :: !buffers; v | VString s -> let v = alloc_string s in (* make a copy *) ignore(copy_string v); v | VObject o as obj -> let vo = Extc.dlcall1 alloc_object null in Array.iter (fun (id,v) -> ignore(Extc.dlcall3 alloc_field vo (Extc.dlint id) (value_neko ~obj v)) ) o.ofields; vo | VClosure _ -> failwith "Closure not supported" | VFunction f -> let callb = Extc.dlcall3 alloc_function gen_callback (Extc.dlint (-1)) (Obj.magic "") in let index = !root_index in incr root_index; Hashtbl.add roots index (f,obj); let a = Extc.dlcall2 alloc_abstract null (Obj.magic index) in if Extc.dlptr (val_field a 1) != Obj.magic index then assert false; ignore(Extc.dlcall2 val_gc a on_abstract_gc); Extc.dlsetptr (val_fun_env callb) a; callb | VArray a -> let va = Extc.dlcall1 alloc_array (Extc.dlint (Array.length a)) in Array.iteri (fun i v -> Extc.dlsetptr (val_field va i) (value_neko v) ) a; va | VFloat f -> Extc.dlcall1 alloc_float (Obj.magic f) | VAbstract _ -> failwith "Abstract not supported" | VInt32 i -> alloc_i32 i in let obj_r = ref [] in let obj_fun = (fun v id -> obj_r := (v,id) :: !obj_r; val_null) in let rec neko_value (v:Extc.value) = if Obj.is_int (Obj.magic v) then VInt (Obj.magic v) else let head = Extc.dltoint (Extc.dlptr v) in match head land tag_mask with | 0 -> VNull | 2 -> VBool (v == val_true) | 3 -> VString (copy_string v) | 4 -> ignore(Extc.dlcall3 val_iter_fields v (Extc.dlcallback 2) (Obj.magic obj_fun)); let r = !obj_r in obj_r := []; let ctx = get_ctx() in let fields = List.rev_map (fun (v,id) -> let iid = Extc.dltoint id in if not (Hashtbl.mem ctx.fields_cache iid) then begin let name = copy_string (Extc.dlcall1 val_field_name id) in ignore(hash_field ctx name); end; iid, neko_value v ) r in VObject { ofields = Array.of_list fields; oproto = None } | 5 -> VArray (Array.init (head asr tag_bits) (fun i -> neko_value (Extc.dlptr (val_field v i)))) | 7 -> let r = alloc_root v in let a = ANekoAbstract v in Gc.finalise (fun _ -> free_root r) a; VAbstract a | t -> failwith ("Unsupported Neko value tag " ^ string_of_int t) in Callback.register "dlcallb2" (fun args nargs -> (* get back the VM env, which was set in value_neko *) let env = Extc.dlptr (Extc.dladdr vm (2 * ptr_size)) in (* extract the index stored in abstract data *) let index : int = Obj.magic (Extc.dlptr (val_field env 1)) in let f, obj = (try Hashtbl.find roots index with Not_found -> assert false) in let nargs = Extc.dltoint nargs in let rec loop i = if i = nargs then [] else neko_value (Extc.dlptr (Extc.dladdr args (i * ptr_size))) :: loop (i + 1) in let v = (get_ctx()).do_call obj (VFunction f) (loop 0) { psource = ""; pline = 0; } in value_neko v ); let callprim (n,p,nargs) args = let arr = Array.of_list (List.map value_neko args) in let exc = ref null in if Array.length arr <> nargs then failwith n; let ret = Extc.dlcall5 callEx val_null p (Obj.magic arr) (Extc.dlint nargs) (Obj.magic exc) in if !exc != null then raise (Runtime (neko_value !exc)); (match !buffers with | [] -> () | l -> buffers := []; (* copy back data *) List.iter (fun (buf,v) -> Extc.dlmemcpy (Extc.dlstring buf) (val_str v) (String.length buf); ) l); neko_value ret in Some { load = loadprim; call = callprim; } (* ---------------------------------------------------------------------- *) (* BUILTINS *) let builtins = let p = { psource = ""; pline = 0 } in let error() = raise Builtin_error in let vint = function | VInt n -> n | _ -> error() in let varray = function | VArray a -> a | _ -> error() in let vstring = function | VString s -> s | _ -> error() in let vobj = function | VObject o -> o | _ -> error() in let vfun = function | VFunction f -> f | VClosure (cl,f) -> FunVar (f cl) | _ -> error() in let vhash = function | VAbstract (AHash h) -> h | _ -> error() in let build_stack sl = let make p = let p = make_pos p in VArray [|VString p.Ast.pfile;VInt (Lexer.get_error_line p)|] in VArray (Array.of_list (List.map make sl)) in let do_closure args args2 = match args with | f :: obj :: args -> (get_ctx()).do_call obj f (args @ args2) p | _ -> assert false in let funcs = [ (* array *) "array", FunVar (fun vl -> VArray (Array.of_list vl)); "amake", Fun1 (fun v -> VArray (Array.create (vint v) VNull)); "acopy", Fun1 (fun a -> VArray (Array.copy (varray a))); "asize", Fun1 (fun a -> VInt (Array.length (varray a))); "asub", Fun3 (fun a p l -> VArray (Array.sub (varray a) (vint p) (vint l))); "ablit", Fun5 (fun dst dstp src p l -> Array.blit (varray src) (vint p) (varray dst) (vint dstp) (vint l); VNull ); "aconcat", Fun1 (fun arr -> let arr = Array.map varray (varray arr) in VArray (Array.concat (Array.to_list arr)) ); (* string *) "string", Fun1 (fun v -> VString ((get_ctx()).do_string v)); "smake", Fun1 (fun l -> VString (String.make (vint l) '\000')); "ssize", Fun1 (fun s -> VInt (String.length (vstring s))); "scopy", Fun1 (fun s -> VString (String.copy (vstring s))); "ssub", Fun3 (fun s p l -> VString (String.sub (vstring s) (vint p) (vint l))); "sget", Fun2 (fun s p -> try VInt (int_of_char (String.get (vstring s) (vint p))) with Invalid_argument _ -> VNull ); "sset", Fun3 (fun s p c -> let c = char_of_int ((vint c) land 0xFF) in try String.set (vstring s) (vint p) c; VInt (int_of_char c) with Invalid_argument _ -> VNull); "sblit", Fun5 (fun dst dstp src p l -> String.blit (vstring src) (vint p) (vstring dst) (vint dstp) (vint l); VNull ); "sfind", Fun3 (fun src pos pat -> try VInt (find_sub (vstring src) (vstring pat) (vint pos)) with Not_found -> VNull ); (* object *) "new", Fun1 (fun o -> match o with | VNull -> VObject { ofields = [||]; oproto = None } | VObject o -> VObject { ofields = Array.copy o.ofields; oproto = o.oproto } | _ -> error() ); "objget", Fun2 (fun o f -> match o with | VObject o -> get_field o (vint f) | _ -> VNull ); "objset", Fun3 (fun o f v -> match o with | VObject o -> set_field o (vint f) v; v | _ -> VNull ); "objcall", Fun3 (fun o f pl -> match o with | VObject oo -> (get_ctx()).do_call o (get_field oo (vint f)) (Array.to_list (varray pl)) p | _ -> VNull ); "objfield", Fun2 (fun o f -> match o with | VObject o -> let p = o.oproto in o.oproto <- None; let v = get_field_opt o (vint f) in o.oproto <- p; VBool (v <> None) | _ -> VBool false ); "objremove", Fun2 (fun o f -> VBool (remove_field (vobj o) (vint f)) ); "objfields", Fun1 (fun o -> VArray (Array.map (fun (fid,_) -> VInt fid) (vobj o).ofields) ); "hash", Fun1 (fun v -> VInt (hash_field (get_ctx()) (vstring v))); "fasthash", Fun1 (fun v -> VInt (hash (vstring v))); "field", Fun1 (fun v -> try VString (Hashtbl.find (get_ctx()).fields_cache (vint v)) with Not_found -> VNull ); "objsetproto", Fun2 (fun o p -> let o = vobj o in (match p with | VNull -> o.oproto <- None | VObject p -> o.oproto <- Some p | _ -> error()); VNull; ); "objgetproto", Fun1 (fun o -> match (vobj o).oproto with | None -> VNull | Some p -> VObject p ); (* function *) "nargs", Fun1 (fun f -> VInt (nargs (vfun f)) ); "call", Fun3 (fun f o args -> (get_ctx()).do_call o f (Array.to_list (varray args)) p ); "closure", FunVar (fun vl -> match vl with | VFunction f :: _ :: _ -> VClosure (vl, do_closure) | _ -> exc (VString "Can't create closure : value is not a function") ); "apply", FunVar (fun vl -> match vl with | f :: args -> let f = vfun f in VFunction (FunVar (fun args2 -> (get_ctx()).do_call VNull (VFunction f) (args @ args2) p)) | _ -> exc (VString "Invalid closure arguments number") ); "varargs", Fun1 (fun f -> match f with | VFunction (FunVar _) | VFunction (Fun1 _) | VClosure _ -> VFunction (FunVar (fun vl -> (get_ctx()).do_call VNull f [VArray (Array.of_list vl)] p)) | _ -> error() ); (* numbers *) (* skip iadd, isub, idiv, imult *) "isnan", Fun1 (fun f -> match f with | VFloat f -> VBool (f <> f) | _ -> VBool false ); "isinfinite", Fun1 (fun f -> match f with | VFloat f -> VBool (f = infinity || f = neg_infinity) | _ -> VBool false ); "int", Fun1 (fun v -> match v with | VInt _ | VInt32 _ -> v | VFloat f -> best_int (to_int f) | VString s -> (try parse_int s with _ -> VNull) | _ -> VNull ); "float", Fun1 (fun v -> match v with | VInt i -> VFloat (float_of_int i) | VInt32 i -> VFloat (Int32.to_float i) | VFloat _ -> v | VString s -> (try VFloat (parse_float s) with _ -> VNull) | _ -> VNull ); (* abstract *) "getkind", Fun1 (fun v -> match v with | VAbstract a -> VAbstract (AKind a) | VInt32 _ -> VAbstract (AKind AInt32Kind) | _ -> error() ); "iskind", Fun2 (fun v k -> match v, k with | VAbstract a, VAbstract (AKind k) -> VBool (Obj.tag (Obj.repr a) = Obj.tag (Obj.repr k)) | VInt32 _, VAbstract (AKind AInt32Kind) -> VBool true | _, VAbstract (AKind _) -> VBool false | _ -> error() ); (* hash *) "hkey", Fun1 (fun v -> VInt (Hashtbl.hash v)); "hnew", Fun1 (fun v -> VAbstract (AHash (match v with | VNull -> Hashtbl.create 0 | VInt n -> Hashtbl.create n | _ -> error())) ); "hresize", Fun1 (fun v -> VNull); "hget", Fun3 (fun h k cmp -> if cmp <> VNull then assert false; (try Hashtbl.find (vhash h) k with Not_found -> VNull) ); "hmem", Fun3 (fun h k cmp -> if cmp <> VNull then assert false; VBool (Hashtbl.mem (vhash h) k) ); "hremove", Fun3 (fun h k cmp -> if cmp <> VNull then assert false; let h = vhash h in let old = Hashtbl.mem h k in if old then Hashtbl.remove h k; VBool old ); "hset", Fun4 (fun h k v cmp -> if cmp <> VNull then assert false; let h = vhash h in let old = Hashtbl.mem h k in Hashtbl.replace h k v; VBool (not old); ); "hadd", Fun4 (fun h k v cmp -> if cmp <> VNull then assert false; let h = vhash h in let old = Hashtbl.mem h k in Hashtbl.add h k v; VBool (not old); ); "hiter", Fun2 (fun h f -> Hashtbl.iter (fun k v -> ignore ((get_ctx()).do_call VNull f [k;v] p)) (vhash h); VNull); "hcount", Fun1 (fun h -> VInt (Hashtbl.length (vhash h))); "hsize", Fun1 (fun h -> VInt (Hashtbl.length (vhash h))); (* misc *) "print", FunVar (fun vl -> List.iter (fun v -> let ctx = get_ctx() in let com = ctx.curapi.get_com() in com.print (ctx.do_string v) ) vl; VNull); "throw", Fun1 (fun v -> exc v); "rethrow", Fun1 (fun v -> let ctx = get_ctx() in ctx.callstack <- List.rev (List.map (fun p -> { cpos = p; cthis = ctx.vthis; cstack = DynArray.length ctx.stack; cenv = ctx.venv }) ctx.exc) @ ctx.callstack; exc v ); "istrue", Fun1 (fun v -> match v with | VNull | VInt 0 | VBool false | VInt32 0l -> VBool false | _ -> VBool true ); "not", Fun1 (fun v -> match v with | VNull | VInt 0 | VBool false | VInt32 0l -> VBool true | _ -> VBool false ); "typeof", Fun1 (fun v -> VInt (match v with | VNull -> 0 | VInt _ | VInt32 _ -> 1 | VFloat _ -> 2 | VBool _ -> 3 | VString _ -> 4 | VObject _ -> 5 | VArray _ -> 6 | VFunction _ | VClosure _ -> 7 | VAbstract _ -> 8) ); "compare", Fun2 (fun a b -> match (get_ctx()).do_compare a b with | CUndef -> VNull | CEq -> VInt 0 | CSup -> VInt 1 | CInf -> VInt (-1) ); "pcompare", Fun2 (fun a b -> assert false ); "excstack", Fun0 (fun() -> build_stack (get_ctx()).exc ); "callstack", Fun0 (fun() -> build_stack (List.map (fun s -> s.cpos) (get_ctx()).callstack) ); "version", Fun0 (fun() -> VInt 200 ); (* extra *) "use_neko_dll", Fun0 (fun() -> VBool (neko <> None) ); ] in let vals = [ "tnull", VInt 0; "tint", VInt 1; "tfloat", VInt 2; "tbool", VInt 3; "tstring", VInt 4; "tobject", VInt 5; "tarray", VInt 6; "tfunction", VInt 7; "tabstract", VInt 8; ] in let h = Hashtbl.create 0 in List.iter (fun (n,f) -> Hashtbl.add h n (VFunction f)) funcs; List.iter (fun (n,v) -> Hashtbl.add h n v) vals; h (* ---------------------------------------------------------------------- *) (* STD LIBRARY *) let free_abstract a = match a with | VAbstract vp -> Obj.set_tag (Obj.repr vp) 0 (* this will mute it as Deallocated *) | _ -> assert false let std_lib = let p = { psource = ""; pline = 0 } in let error() = raise Builtin_error in let make_list l = let rec loop acc = function | [] -> acc | x :: l -> loop (VArray [|x;acc|]) l in loop VNull (List.rev l) in let num = function | VInt i -> float_of_int i | VInt32 i -> Int32.to_float i | VFloat f -> f | _ -> error() in let make_date f = VInt32 (Int32.of_float f) in let date = function | VInt32 i -> Int32.to_float i | VInt i -> float_of_int i | _ -> error() in let make_i32 i = VInt32 i in let int32 = function | VInt i -> Int32.of_int i | VInt32 i -> i | _ -> error() in let vint = function | VInt n -> n | _ -> error() in let vstring = function | VString s -> s | _ -> error() in let int32_addr h = let base = Int32.to_int (Int32.logand h 0xFFFFFFl) in let str = Printf.sprintf "%ld.%d.%d.%d" (Int32.shift_right_logical h 24) (base lsr 16) ((base lsr 8) land 0xFF) (base land 0xFF) in Unix.inet_addr_of_string str in let int32_op op = Fun2 (fun a b -> make_i32 (op (int32 a) (int32 b))) in make_library ([ (* math *) "math_atan2", Fun2 (fun a b -> VFloat (atan2 (num a) (num b))); "math_pow", Fun2 (fun a b -> VFloat ((num a) ** (num b))); "math_abs", Fun1 (fun v -> match v with | VInt i -> VInt (abs i) | VInt32 i -> VInt32 (Int32.abs i) | VFloat f -> VFloat (abs_float f) | _ -> error() ); "math_ceil", Fun1 (fun v -> match v with VInt _ | VInt32 _ -> v | _ -> best_int (to_int (ceil (num v)))); "math_floor", Fun1 (fun v -> match v with VInt _ | VInt32 _ -> v | _ -> best_int (to_int (floor (num v)))); "math_round", Fun1 (fun v -> match v with VInt _ | VInt32 _ -> v | _ -> best_int (to_int (floor (num v +. 0.5)))); "math_pi", Fun0 (fun() -> VFloat (4.0 *. atan 1.0)); "math_sqrt", Fun1 (fun v -> VFloat (sqrt (num v))); "math_atan", Fun1 (fun v -> VFloat (atan (num v))); "math_cos", Fun1 (fun v -> VFloat (cos (num v))); "math_sin", Fun1 (fun v -> VFloat (sin (num v))); "math_tan", Fun1 (fun v -> VFloat (tan (num v))); "math_log", Fun1 (fun v -> VFloat (Pervasives.log (num v))); "math_exp", Fun1 (fun v -> VFloat (exp (num v))); "math_acos", Fun1 (fun v -> VFloat (acos (num v))); "math_asin", Fun1 (fun v -> VFloat (asin (num v))); "math_fceil", Fun1 (fun v -> VFloat (ceil (num v))); "math_ffloor", Fun1 (fun v -> VFloat (floor (num v))); "math_fround", Fun1 (fun v -> VFloat (floor (num v +. 0.5))); "math_int", Fun1 (fun v -> match v with | VInt _ | VInt32 _ -> v | VFloat f -> best_int (to_int (if f < 0. then ceil f else floor f)) | _ -> error() ); (* buffer *) "buffer_new", Fun0 (fun() -> VAbstract (ABuffer (Buffer.create 0)) ); "buffer_add", Fun2 (fun b v -> match b with | VAbstract (ABuffer b) -> Buffer.add_string b ((get_ctx()).do_string v); VNull | _ -> error() ); "buffer_add_char", Fun2 (fun b v -> match b, v with | VAbstract (ABuffer b), VInt n when n >= 0 && n < 256 -> Buffer.add_char b (char_of_int n); VNull | _ -> error() ); "buffer_add_sub", Fun4 (fun b s p l -> match b, s, p, l with | VAbstract (ABuffer b), VString s, VInt p, VInt l -> (try Buffer.add_substring b s p l; VNull with _ -> error()) | _ -> error() ); "buffer_string", Fun1 (fun b -> match b with | VAbstract (ABuffer b) -> VString (Buffer.contents b) | _ -> error() ); "buffer_reset", Fun1 (fun b -> match b with | VAbstract (ABuffer b) -> Buffer.reset b; VNull; | _ -> error() ); "buffer_get_length", Fun1 (fun b -> match b with | VAbstract (ABuffer b) -> VInt (Buffer.length b) | _ -> error() ); (* date *) "date_now", Fun0 (fun () -> make_date (Unix.time()) ); "date_new", Fun1 (fun v -> make_date (match v with | VNull -> Unix.time() | VString s -> (match String.length s with | 19 -> let r = Str.regexp "^\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9]\\)-\\([0-9][0-9]\\) \\([0-9][0-9]\\):\\([0-9][0-9]\\):\\([0-9][0-9]\\)$" in if not (Str.string_match r s 0) then exc (VString ("Invalid date format : " ^ s)); let t = Unix.localtime (Unix.time()) in let t = { t with tm_year = int_of_string (Str.matched_group 1 s) - 1900; tm_mon = int_of_string (Str.matched_group 2 s) - 1; tm_mday = int_of_string (Str.matched_group 3 s); tm_hour = int_of_string (Str.matched_group 4 s); tm_min = int_of_string (Str.matched_group 5 s); tm_sec = int_of_string (Str.matched_group 6 s); } in fst (Unix.mktime t) | 10 -> assert false | 8 -> assert false | _ -> exc (VString ("Invalid date format : " ^ s))); | _ -> error()) ); "date_set_hour", Fun4 (fun d h m s -> let d = date d in let t = Unix.localtime d in make_date (fst (Unix.mktime { t with tm_hour = vint h; tm_min = vint m; tm_sec = vint s })) ); "date_set_day", Fun4 (fun d y m da -> let d = date d in let t = Unix.localtime d in make_date (fst (Unix.mktime { t with tm_year = vint y - 1900; tm_mon = vint m - 1; tm_mday = vint da })) ); "date_format", Fun2 (fun d fmt -> match fmt with | VNull -> let t = Unix.localtime (date d) in VString (Printf.sprintf "%.4d-%.2d-%.2d %.2d:%.2d:%.2d" (t.tm_year + 1900) (t.tm_mon + 1) t.tm_mday t.tm_hour t.tm_min t.tm_sec) | VString "%w" -> (* week day *) let t = Unix.localtime (date d) in VString (string_of_int t.tm_wday) | VString _ -> exc (VString "Custom date format is not supported") (* use native Haxe implementation *) | _ -> error() ); "date_get_hour", Fun1 (fun d -> let t = Unix.localtime (date d) in let o = obj (hash_field (get_ctx())) [ "h", VInt t.tm_hour; "m", VInt t.tm_min; "s", VInt t.tm_sec; ] in VObject o ); "date_get_day", Fun1 (fun d -> let t = Unix.localtime (date d) in let o = obj (hash_field (get_ctx())) [ "d", VInt t.tm_mday; "m", VInt (t.tm_mon + 1); "y", VInt (t.tm_year + 1900); ] in VObject o ); (* string *) "string_split", Fun2 (fun s d -> make_list (match s, d with | VString "", VString _ -> [VString ""] | VString s, VString "" -> Array.to_list (Array.init (String.length s) (fun i -> VString (String.make 1 (String.get s i)))) | VString s, VString d -> List.map (fun s -> VString s) (ExtString.String.nsplit s d) | _ -> error()) ); "url_encode", Fun1 (fun s -> let s = vstring s in let b = Buffer.create 0 in let hex = "0123456789ABCDEF" in for i = 0 to String.length s - 1 do let c = String.unsafe_get s i in match c with | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '-' | '.' -> Buffer.add_char b c | _ -> Buffer.add_char b '%'; Buffer.add_char b (String.unsafe_get hex (int_of_char c lsr 4)); Buffer.add_char b (String.unsafe_get hex (int_of_char c land 0xF)); done; VString (Buffer.contents b) ); "url_decode", Fun1 (fun s -> let s = vstring s in let b = Buffer.create 0 in let len = String.length s in let decode c = match c with | '0'..'9' -> Some (int_of_char c - int_of_char '0') | 'a'..'f' -> Some (int_of_char c - int_of_char 'a' + 10) | 'A'..'F' -> Some (int_of_char c - int_of_char 'A' + 10) | _ -> None in let rec loop i = if i = len then () else let c = String.unsafe_get s i in match c with | '%' -> let p1 = (try decode (String.get s (i + 1)) with _ -> None) in let p2 = (try decode (String.get s (i + 2)) with _ -> None) in (match p1, p2 with | Some c1, Some c2 -> Buffer.add_char b (char_of_int ((c1 lsl 4) lor c2)); loop (i + 3) | _ -> loop (i + 1)); | '+' -> Buffer.add_char b ' '; loop (i + 1) | c -> Buffer.add_char b c; loop (i + 1) in loop 0; VString (Buffer.contents b) ); "base_encode", Fun2 (fun s b -> match s, b with | VString s, VString "0123456789abcdef" when String.length s = 16 -> VString (Digest.to_hex s) | VString s, VString b -> if String.length b <> 64 then assert false; let tbl = Array.init 64 (String.unsafe_get b) in VString (Base64.str_encode ~tbl s) | _ -> error() ); "base_decode", Fun2 (fun s b -> let s = vstring s in let b = vstring b in if String.length b <> 64 then assert false; let tbl = Array.init 64 (String.unsafe_get b) in VString (Base64.str_decode ~tbl:(Base64.make_decoding_table tbl) s) ); "make_md5", Fun1 (fun s -> VString (Digest.string (vstring s)) ); (* sprintf *) (* int32 *) "int32_new", Fun1 (fun v -> match v with | VInt32 _ -> v | VInt i -> make_i32 (Int32.of_int i) | VFloat f -> make_i32 (Int32.of_float f) | _ -> error() ); "int32_to_int", Fun1 (fun v -> let v = int32 v in let i = Int32.to_int v in if Int32.compare (Int32.of_int i) v <> 0 then error(); VInt i ); "int32_to_float", Fun1 (fun v -> VFloat (Int32.to_float (int32 v)) ); "int32_compare", Fun2 (fun a b -> VInt (Int32.compare (int32 a) (int32 b)) ); "int32_add", int32_op Int32.add; "int32_sub", int32_op Int32.sub; "int32_mul", int32_op Int32.mul; "int32_div", int32_op Int32.div; "int32_shl", int32_op (fun a b -> Int32.shift_left a (Int32.to_int b)); "int32_shr", int32_op (fun a b -> Int32.shift_right a (Int32.to_int b)); "int32_ushr", int32_op (fun a b -> Int32.shift_right_logical a (Int32.to_int b)); "int32_mod", int32_op Int32.rem; "int32_or", int32_op Int32.logor; "int32_and", int32_op Int32.logand; "int32_xor", int32_op Int32.logxor; "int32_neg", Fun1 (fun v -> make_i32 (Int32.neg (int32 v))); "int32_complement", Fun1 (fun v -> make_i32 (Int32.lognot (int32 v))); (* misc *) "same_closure", Fun2 (fun a b -> VBool (match a, b with | VClosure (la,fa), VClosure (lb,fb) -> fa == fb && List.length la = List.length lb && List.for_all2 (fun a b -> (get_ctx()).do_compare a b = CEq) la lb | VFunction a, VFunction b -> a == b | _ -> false) ); "double_bytes", Fun2 (fun f big -> let f = (match f with VFloat f -> f | VInt i -> float_of_int i | _ -> error()) in match big with | VBool big -> let ch = IO.output_string() in if big then IO.BigEndian.write_double ch f else IO.write_double ch f; VString (IO.close_out ch) | _ -> error() ); "float_bytes", Fun2 (fun f big -> let f = (match f with VFloat f -> f | VInt i -> float_of_int i | _ -> error()) in match big with | VBool big -> let ch = IO.output_string() in let i = Int32.bits_of_float f in if big then IO.BigEndian.write_real_i32 ch i else IO.write_real_i32 ch i; VString (IO.close_out ch) | _ -> error() ); "double_of_bytes", Fun2 (fun s big -> match s, big with | VString s, VBool big when String.length s = 8 -> let ch = IO.input_string s in VFloat (if big then IO.BigEndian.read_double ch else IO.read_double ch) | _ -> error() ); "float_of_bytes", Fun2 (fun s big -> match s, big with | VString s, VBool big when String.length s = 4 -> let ch = IO.input_string s in VFloat (Int32.float_of_bits (if big then IO.BigEndian.read_real_i32 ch else IO.read_real_i32 ch)) | _ -> error() ); (* random *) "random_new", Fun0 (fun() -> VAbstract (ARandom (ref (Random.State.make_self_init())))); "random_set_seed", Fun2 (fun r s -> match r, s with | VAbstract (ARandom r), VInt seed -> r := Random.State.make [|seed|]; VNull | VAbstract (ARandom r), VInt32 seed -> r := Random.State.make [|Int32.to_int seed|]; VNull | _ -> error() ); "random_int", Fun2 (fun r s -> match r, s with | VAbstract (ARandom r), VInt max -> VInt (Random.State.int (!r) (if max <= 0 then 1 else max)) | _ -> error() ); "random_float", Fun1 (fun r -> match r with | VAbstract (ARandom r) -> VFloat (Random.State.float (!r) 1.0) | _ -> error() ); (* file *) "file_open", Fun2 (fun f r -> match f, r with | VString f, VString r -> let perms = 0o666 in VAbstract (match r with | "r" -> AFRead (open_in_gen [Open_rdonly] 0 f,ref false) | "rb" -> AFRead (open_in_gen [Open_rdonly;Open_binary] 0 f,ref false) | "w" -> AFWrite (open_out_gen [Open_wronly;Open_creat;Open_trunc] perms f) | "wb" -> AFWrite (open_out_gen [Open_wronly;Open_creat;Open_trunc;Open_binary] perms f) | "a" -> AFWrite (open_out_gen [Open_append] perms f) | "ab" -> AFWrite (open_out_gen [Open_append;Open_binary] perms f) | _ -> error()) | _ -> error() ); "file_close", Fun1 (fun vf -> (match vf with | VAbstract (AFRead (f,_)) -> close_in f; free_abstract vf; | VAbstract (AFWrite f) -> close_out f; free_abstract vf; | _ -> error()); VNull ); (* file_name *) "file_write", Fun4 (fun f s p l -> match f, s, p, l with | VAbstract (AFWrite f), VString s, VInt p, VInt l -> output f s p l; VInt l | _ -> error() ); "file_read", Fun4 (fun f s p l -> match f, s, p, l with | VAbstract (AFRead (f,r)), VString s, VInt p, VInt l -> let n = input f s p l in if n = 0 then begin r := true; exc (VArray [|VString "file_read"|]); end; VInt n | _ -> error() ); "file_write_char", Fun2 (fun f c -> match f, c with | VAbstract (AFWrite f), VInt c -> output_char f (char_of_int c); VNull | _ -> error() ); "file_read_char", Fun1 (fun f -> match f with | VAbstract (AFRead (f,r)) -> VInt (int_of_char (try input_char f with _ -> r := true; exc (VArray [|VString "file_read_char"|]))) | _ -> error() ); "file_seek", Fun3 (fun f pos mode -> match f, pos, mode with | VAbstract (AFRead (f,r)), VInt pos, VInt mode -> r := false; seek_in f (match mode with 0 -> pos | 1 -> pos_in f + pos | 2 -> in_channel_length f + pos | _ -> error()); VNull; | VAbstract (AFWrite f), VInt pos, VInt mode -> seek_out f (match mode with 0 -> pos | 1 -> pos_out f + pos | 2 -> out_channel_length f + pos | _ -> error()); VNull; | _ -> error() ); "file_tell", Fun1 (fun f -> match f with | VAbstract (AFRead (f,_)) -> VInt (pos_in f) | VAbstract (AFWrite f) -> VInt (pos_out f) | _ -> error() ); "file_eof", Fun1 (fun f -> match f with | VAbstract (AFRead (f,r)) -> VBool !r | _ -> error() ); "file_flush", Fun1 (fun f -> (match f with | VAbstract (AFWrite f) -> flush f | _ -> error()); VNull ); "file_contents", Fun1 (fun f -> match f with | VString f -> VString (Std.input_file ~bin:true f) | _ -> error() ); "file_stdin", Fun0 (fun() -> VAbstract (AFRead (Pervasives.stdin, ref false))); "file_stdout", Fun0 (fun() -> VAbstract (AFWrite Pervasives.stdout)); "file_stderr", Fun0 (fun() -> VAbstract (AFWrite Pervasives.stderr)); (* serialize *) (* TODO *) (* socket *) "socket_init", Fun0 (fun() -> VNull); "socket_new", Fun1 (fun v -> match v with | VBool b -> VAbstract (ASocket (Unix.socket PF_INET (if b then SOCK_DGRAM else SOCK_STREAM) 0)); | _ -> error() ); "socket_close", Fun1 (fun vs -> match vs with | VAbstract (ASocket s) -> Unix.close s; free_abstract vs; VNull | _ -> error() ); "socket_send_char", Fun2 (fun s c -> match s, c with | VAbstract (ASocket s), VInt c when c >= 0 && c <= 255 -> ignore(Unix.send s (String.make 1 (char_of_int c)) 0 1 []); VNull | _ -> error() ); "socket_send", Fun4 (fun s buf pos len -> match s, buf, pos, len with | VAbstract (ASocket s), VString buf, VInt pos, VInt len -> VInt (Unix.send s buf pos len []) | _ -> error() ); "socket_recv", Fun4 (fun s buf pos len -> match s, buf, pos, len with | VAbstract (ASocket s), VString buf, VInt pos, VInt len -> VInt (Unix.recv s buf pos len []) | _ -> error() ); "socket_recv_char", Fun1 (fun s -> match s with | VAbstract (ASocket s) -> let buf = String.make 1 '\000' in ignore(Unix.recv s buf 0 1 []); VInt (int_of_char (String.unsafe_get buf 0)) | _ -> error() ); "socket_write", Fun2 (fun s str -> match s, str with | VAbstract (ASocket s), VString str -> let pos = ref 0 in let len = ref (String.length str) in while !len > 0 do let k = Unix.send s str (!pos) (!len) [] in pos := !pos + k; len := !len - k; done; VNull | _ -> error() ); "socket_read", Fun1 (fun s -> match s with | VAbstract (ASocket s) -> let tmp = String.make 1024 '\000' in let buf = Buffer.create 0 in let rec loop() = let k = (try Unix.recv s tmp 0 1024 [] with Unix_error _ -> 0) in if k > 0 then begin Buffer.add_substring buf tmp 0 k; loop(); end in loop(); VString (Buffer.contents buf) | _ -> error() ); "host_resolve", Fun1 (fun s -> let h = (try Unix.gethostbyname (vstring s) with Not_found -> error()) in let addr = Unix.string_of_inet_addr h.h_addr_list.(0) in let a, b, c, d = Scanf.sscanf addr "%d.%d.%d.%d" (fun a b c d -> a,b,c,d) in VInt32 (Int32.logor (Int32.shift_left (Int32.of_int a) 24) (Int32.of_int (d lor (c lsl 8) lor (b lsl 16)))) ); "host_to_string", Fun1 (fun h -> match h with | VInt32 h -> VString (Unix.string_of_inet_addr (int32_addr h)); | _ -> error() ); "host_reverse", Fun1 (fun h -> match h with | VInt32 h -> VString (gethostbyaddr (int32_addr h)).h_name | _ -> error() ); "host_local", Fun0 (fun() -> VString (Unix.gethostname()) ); "socket_connect", Fun3 (fun s h p -> match s, h, p with | VAbstract (ASocket s), VInt32 h, VInt p -> Unix.connect s (ADDR_INET (int32_addr h,p)); VNull | _ -> error() ); "socket_listen", Fun2 (fun s l -> match s, l with | VAbstract (ASocket s), VInt l -> Unix.listen s l; VNull | _ -> error() ); "socket_set_timeout", Fun2 (fun s t -> match s with | VAbstract (ASocket s) -> let t = (match t with VNull -> 0. | VInt t -> float_of_int t | VFloat f -> f | _ -> error()) in Unix.setsockopt_float s SO_RCVTIMEO t; Unix.setsockopt_float s SO_SNDTIMEO t; VNull | _ -> error() ); "socket_shutdown", Fun3 (fun s r w -> match s, r, w with | VAbstract (ASocket s), VBool r, VBool w -> Unix.shutdown s (match r, w with true, true -> SHUTDOWN_ALL | true, false -> SHUTDOWN_RECEIVE | false, true -> SHUTDOWN_SEND | _ -> error()); VNull | _ -> error() ); (* TODO : select, bind, accept, peer, host *) (* poll_alloc, poll : not planned *) (* system *) "get_env", Fun1 (fun v -> try VString (Unix.getenv (vstring v)) with _ -> VNull ); "put_env", Fun2 (fun e v -> Unix.putenv (vstring e) (vstring v); VNull ); "sys_sleep", Fun1 (fun f -> match f with | VFloat f -> ignore(Unix.select [] [] [] f); VNull | _ -> error() ); "set_time_locale", Fun1 (fun l -> match l with | VString s -> VBool false (* always fail *) | _ -> error() ); "get_cwd", Fun0 (fun() -> let dir = Unix.getcwd() in let l = String.length dir in VString (if l = 0 then "./" else match dir.[l - 1] with '/' | '\\' -> dir | _ -> dir ^ "/") ); "set_cwd", Fun1 (fun s -> Unix.chdir (vstring s); VNull; ); "sys_string", ( let cached_sys_name = ref None in Fun0 (fun() -> VString (match Sys.os_type with | "Unix" -> (match !cached_sys_name with | Some n -> n | None -> let ic = Unix.open_process_in "uname" in let uname = (match input_line ic with | "Darwin" -> "Mac" | n -> n ) in close_in ic; cached_sys_name := Some uname; uname) | "Win32" | "Cygwin" -> "Windows" | s -> s) ) ); "sys_is64", Fun0 (fun() -> VBool (Sys.word_size = 64) ); "sys_command", Fun1 (fun cmd -> VInt (((get_ctx()).curapi.get_com()).run_command (vstring cmd)) ); "sys_exit", Fun1 (fun code -> if (get_ctx()).curapi.use_cache() then raise (Typecore.Fatal_error ("",Ast.null_pos)); raise (Sys_exit(vint code)); ); "sys_exists", Fun1 (fun file -> VBool (Sys.file_exists (vstring file)) ); "file_delete", Fun1 (fun file -> Sys.remove (vstring file); VNull; ); "sys_rename", Fun2 (fun file target -> Sys.rename (vstring file) (vstring target); VNull; ); "sys_stat", Fun1 (fun file -> let s = Unix.stat (vstring file) in VObject (obj (hash_field (get_ctx())) [ "gid", VInt s.st_gid; "uid", VInt s.st_uid; "atime", VInt32 (Int32.of_float s.st_atime); "mtime", VInt32 (Int32.of_float s.st_mtime); "ctime", VInt32 (Int32.of_float s.st_ctime); "dev", VInt s.st_dev; "ino", VInt s.st_ino; "nlink", VInt s.st_nlink; "rdev", VInt s.st_rdev; "size", VInt s.st_size; "mode", VInt s.st_perm; ]) ); "sys_file_type", Fun1 (fun file -> VString (match (Unix.stat (vstring file)).st_kind with | S_REG -> "file" | S_DIR -> "dir" | S_CHR -> "char" | S_BLK -> "block" | S_LNK -> "symlink" | S_FIFO -> "fifo" | S_SOCK -> "sock") ); "sys_create_dir", Fun2 (fun dir mode -> Unix.mkdir (vstring dir) (vint mode); VNull ); "sys_remove_dir", Fun1 (fun dir -> Unix.rmdir (vstring dir); VNull; ); "sys_time", Fun0 (fun() -> VFloat (Unix.gettimeofday()) ); "sys_cpu_time", Fun0 (fun() -> VFloat (Sys.time()) ); "sys_read_dir", Fun1 (fun dir -> let d = Sys.readdir (vstring dir) in let rec loop acc i = if i < 0 then acc else loop (VArray [|VString d.(i);acc|]) (i - 1) in loop VNull (Array.length d - 1) ); "file_full_path", Fun1 (fun file -> VString (try Extc.get_full_path (vstring file) with _ -> error()) ); "sys_exe_path", Fun0 (fun() -> VString (Sys.argv.(0)) ); "sys_env", Fun0 (fun() -> let env = Unix.environment() in let rec loop acc i = if i < 0 then acc else let e, v = ExtString.String.split env.(i) "=" in loop (VArray [|VString e;VString v;acc|]) (i - 1) in loop VNull (Array.length env - 1) ); "sys_getch", Fun1 (fun echo -> match echo with | VBool b -> VInt (Extc.getch b) | _ -> error() ); "sys_get_pid", Fun0 (fun() -> VInt (Unix.getpid()) ); (* utf8 *) "utf8_buf_alloc", Fun1 (fun v -> VAbstract (AUtf8 (UTF8.Buf.create (vint v))) ); "utf8_buf_add", Fun2 (fun b c -> match b with | VAbstract (AUtf8 buf) -> UTF8.Buf.add_char buf (UChar.chr_of_uint (vint c)); VNull | _ -> error() ); "utf8_buf_content", Fun1 (fun b -> match b with | VAbstract (AUtf8 buf) -> VString (UTF8.Buf.contents buf); | _ -> error() ); "utf8_buf_length", Fun1 (fun b -> match b with | VAbstract (AUtf8 buf) -> VInt (UTF8.length (UTF8.Buf.contents buf)); | _ -> error() ); "utf8_buf_size", Fun1 (fun b -> match b with | VAbstract (AUtf8 buf) -> VInt (String.length (UTF8.Buf.contents buf)); | _ -> error() ); "utf8_validate", Fun1 (fun s -> VBool (try UTF8.validate (vstring s); true with UTF8.Malformed_code -> false) ); "utf8_length", Fun1 (fun s -> VInt (UTF8.length (vstring s)) ); "utf8_sub", Fun3 (fun s p l -> let buf = UTF8.Buf.create 0 in let pos = ref (-1) in let p = vint p and l = vint l in UTF8.iter (fun c -> incr pos; if !pos >= p && !pos < p + l then UTF8.Buf.add_char buf c; ) (vstring s); VString (UTF8.Buf.contents buf) ); "utf8_get", Fun2 (fun s p -> VInt (UChar.uint_code (try UTF8.get (vstring s) (vint p) with _ -> error())) ); "utf8_iter", Fun2 (fun s f -> let ctx = get_ctx() in UTF8.iter (fun c -> ignore(ctx.do_call VNull f [VInt (UChar.uint_code c)] p); ) (vstring s); VNull; ); "utf8_compare", Fun2 (fun s1 s2 -> VInt (UTF8.compare (vstring s1) (vstring s2)) ); (* thread *) "thread_create", Fun2 (fun f p -> exc (VString "Can't create thread from within a macro"); ); "tls_create", Fun0 (fun() -> VAbstract (ATls (ref VNull)) ); "tls_get", Fun1 (fun t -> match t with | VAbstract (ATls r) -> !r | _ -> error(); ); "tls_set", Fun2 (fun t v -> match t with | VAbstract (ATls r) -> r := v; VNull | _ -> error(); ); (* lock, mutex, deque : not implemented *) (* process *) "process_run", (Fun2 (fun p args -> match p, args with | VString p, VArray args -> VAbstract (AProcess (Process.run p (Array.map vstring args))) | _ -> error() )); "process_stdout_read", (Fun4 (fun p str pos len -> match p, str, pos, len with | VAbstract (AProcess p), VString str, VInt pos, VInt len -> VInt (Process.read_stdout p str pos len) | _ -> error() )); "process_stderr_read", (Fun4 (fun p str pos len -> match p, str, pos, len with | VAbstract (AProcess p), VString str, VInt pos, VInt len -> VInt (Process.read_stderr p str pos len) | _ -> error() )); "process_stdin_write", (Fun4 (fun p str pos len -> match p, str, pos, len with | VAbstract (AProcess p), VString str, VInt pos, VInt len -> VInt (Process.write_stdin p str pos len) | _ -> error() )); "process_stdin_close", (Fun1 (fun p -> match p with | VAbstract (AProcess p) -> Process.close_stdin p; VNull | _ -> error() )); "process_exit", (Fun1 (fun p -> match p with | VAbstract (AProcess p) -> VInt (Process.exit p) | _ -> error() )); "process_pid", (Fun1 (fun p -> match p with | VAbstract (AProcess p) -> VInt (Process.pid p) | _ -> error() )); "process_close", (Fun1 (fun vp -> match vp with | VAbstract (AProcess p) -> Process.close p; free_abstract vp; VNull | _ -> error() )); (* xml *) "parse_xml", (match neko with | None -> Fun2 (fun str o -> match str, o with | VString str, VObject events -> let ctx = get_ctx() in let p = { psource = "parse_xml"; pline = 0 } in let xml = get_field events (hash "xml") in let don = get_field events (hash "done") in let pcdata = get_field events (hash "pcdata") in (* Since we use the Xml parser, we don't have support for - CDATA - comments, prolog, doctype (allowed but skipped) let cdata = get_field events (hash "cdata") in let comment = get_field events (hash "comment") in *) let rec loop = function | Xml.Element (node, attribs, children) -> ignore(ctx.do_call o xml [VString node;VObject (obj (hash_field ctx) (List.map (fun (a,v) -> a, VString v) attribs))] p); List.iter loop children; ignore(ctx.do_call o don [] p); | Xml.PCData s -> ignore(ctx.do_call o pcdata [VString s] p); in let x = XmlParser.make() in XmlParser.check_eof x false; loop (try XmlParser.parse x (XmlParser.SString str) with Xml.Error e -> failwith ("Parser failure (" ^ Xml.error e ^ ")") | e -> failwith ("Parser failure (" ^ Printexc.to_string e ^ ")")); VNull | _ -> error()) | Some neko -> let parse_xml = neko.load "std@parse_xml" 2 in Fun2 (fun str o -> neko.call parse_xml [str;o]) ); (* memory, module : not planned *) ] (* process *) @ (match neko with | None -> [] | Some neko -> let win_ec = (try Some (neko.load "std@win_env_changed" 0) with _ -> None) in [ "win_env_changed", (Fun0 (fun() -> match win_ec with None -> error() | Some f -> neko.call f [])); ])) (* ---------------------------------------------------------------------- *) (* REGEXP LIBRARY *) let reg_lib = let error() = raise Builtin_error in (* try to load regexp first : we might fail if pcre is not installed *) let neko = (match neko with | None -> None | Some neko -> (try ignore(neko.load "regexp@regexp_new_options" 2); Some neko with _ -> None) ) in match neko with | None -> make_library [ (* regexp_new : deprecated *) "regexp_new_options", Fun2 (fun str opt -> match str, opt with | VString str, VString opt -> let case_sensitive = ref true in List.iter (function | 'm' -> () (* always ON ? *) | 'i' -> case_sensitive := false | c -> failwith ("Unsupported regexp option '" ^ String.make 1 c ^ "'") ) (ExtString.String.explode opt); let buf = Buffer.create 0 in let rec loop prev esc = function | [] -> () | c :: l when esc -> (match c with | 'n' -> Buffer.add_char buf '\n' | 'r' -> Buffer.add_char buf '\r' | 't' -> Buffer.add_char buf '\t' | 'd' -> Buffer.add_string buf "[0-9]" | '\\' -> Buffer.add_string buf "\\\\" | '(' | ')' -> Buffer.add_char buf c | '1'..'9' | '+' | '$' | '^' | '*' | '?' | '.' | '[' | ']' -> Buffer.add_char buf '\\'; Buffer.add_char buf c; | _ -> failwith ("Unsupported escaped char '" ^ String.make 1 c ^ "'")); loop c false l | c :: l -> match c with | '\\' -> loop prev true l | '(' | '|' | ')' -> Buffer.add_char buf '\\'; Buffer.add_char buf c; loop c false l | '?' when prev = '(' && (match l with ':' :: _ -> true | _ -> false) -> failwith "Non capturing groups '(?:' are not supported in macros" | '?' when prev = '*' -> failwith "Ungreedy *? are not supported in macros" | _ -> Buffer.add_char buf c; loop c false l in loop '\000' false (ExtString.String.explode str); let str = Buffer.contents buf in let r = { r = if !case_sensitive then Str.regexp str else Str.regexp_case_fold str; r_string = ""; r_groups = [||]; } in VAbstract (AReg r) | _ -> error() ); "regexp_match", Fun4 (fun r str pos len -> match r, str, pos, len with | VAbstract (AReg r), VString str, VInt pos, VInt len -> let nstr, npos, delta = (if len = String.length str - pos then str, pos, 0 else String.sub str pos len, 0, pos) in (try ignore(Str.search_forward r.r nstr npos); let rec loop n = if n = 9 then [] else try (Some (Str.group_beginning n + delta, Str.group_end n + delta)) :: loop (n + 1) with Not_found -> None :: loop (n + 1) | Invalid_argument _ -> [] in r.r_string <- str; r.r_groups <- Array.of_list (loop 0); VBool true; with Not_found -> VBool false) | _ -> error() ); "regexp_matched", Fun2 (fun r n -> match r, n with | VAbstract (AReg r), VInt n -> (match (try r.r_groups.(n) with _ -> failwith ("Invalid group " ^ string_of_int n)) with | None -> VNull | Some (pos,pend) -> VString (String.sub r.r_string pos (pend - pos))) | _ -> error() ); "regexp_matched_pos", Fun2 (fun r n -> match r, n with | VAbstract (AReg r), VInt n -> (match (try r.r_groups.(n) with _ -> failwith ("Invalid group " ^ string_of_int n)) with | None -> VNull | Some (pos,pend) -> VObject (obj (hash_field (get_ctx())) ["pos",VInt pos;"len",VInt (pend - pos)])) | _ -> error() ); (* regexp_replace : not used by Haxe *) (* regexp_replace_all : not used by Haxe *) (* regexp_replace_fun : not used by Haxe *) ] | Some neko -> let regexp_new_options = neko.load "regexp@regexp_new_options" 2 in let regexp_match = neko.load "regexp@regexp_match" 4 in let regexp_matched = neko.load "regexp@regexp_matched" 2 in let regexp_matched_pos = neko.load "regexp@regexp_matched_pos" 2 in make_library [ "regexp_new_options", Fun2 (fun str opt -> neko.call regexp_new_options [str;opt]); "regexp_match", Fun4 (fun r str pos len -> neko.call regexp_match [r;str;pos;len]); "regexp_matched", Fun2 (fun r n -> neko.call regexp_matched [r;n]); "regexp_matched_pos", Fun2 (fun r n -> neko.call regexp_matched_pos [r;n]); ] (* ---------------------------------------------------------------------- *) (* ZLIB LIBRARY *) let z_lib = let error() = raise Builtin_error in make_library [ "inflate_init", Fun1 (fun f -> let z = Extc.zlib_inflate_init2 (match f with VNull -> 15 | VInt i -> i | _ -> error()) in VAbstract (AZipI { z = z; z_flush = Extc.Z_NO_FLUSH }) ); "deflate_init", Fun1 (fun f -> let z = Extc.zlib_deflate_init (match f with VInt i -> i | _ -> error()) in VAbstract (AZipD { z = z; z_flush = Extc.Z_NO_FLUSH }) ); "deflate_end", Fun1 (fun vz -> match vz with | VAbstract (AZipD z) -> Extc.zlib_deflate_end z.z; free_abstract vz; VNull; | _ -> error() ); "inflate_end", Fun1 (fun vz -> match vz with | VAbstract (AZipI z) -> Extc.zlib_inflate_end z.z; free_abstract vz; VNull; | _ -> error() ); "set_flush_mode", Fun2 (fun z f -> match z, f with | VAbstract (AZipI z | AZipD z), VString s -> z.z_flush <- (match s with | "NO" -> Extc.Z_NO_FLUSH | "SYNC" -> Extc.Z_SYNC_FLUSH | "FULL" -> Extc.Z_FULL_FLUSH | "FINISH" -> Extc.Z_FINISH | "BLOCK" -> Extc.Z_PARTIAL_FLUSH | _ -> error()); VNull; | _ -> error() ); "inflate_buffer", Fun5 (fun z src pos dst dpos -> match z, src, pos, dst, dpos with | VAbstract (AZipI z), VString src, VInt pos, VString dst, VInt dpos -> let r = Extc.zlib_inflate z.z src pos (String.length src - pos) dst dpos (String.length dst - dpos) z.z_flush in VObject (obj (hash_field (get_ctx())) [ "done", VBool r.Extc.z_finish; "read", VInt r.Extc.z_read; "write", VInt r.Extc.z_wrote; ]) | _ -> error() ); "deflate_buffer", Fun5 (fun z src pos dst dpos -> match z, src, pos, dst, dpos with | VAbstract (AZipD z), VString src, VInt pos, VString dst, VInt dpos -> let r = Extc.zlib_deflate z.z src pos (String.length src - pos) dst dpos (String.length dst - dpos) z.z_flush in VObject (obj (hash_field (get_ctx())) [ "done", VBool r.Extc.z_finish; "read", VInt r.Extc.z_read; "write", VInt r.Extc.z_wrote; ]) | _ -> error() ); "deflate_bound", Fun2 (fun z size -> match z, size with | VAbstract (AZipD z), VInt size -> VInt (size + 1024) | _ -> error() ); ] (* ---------------------------------------------------------------------- *) (* MACRO LIBRARY *) (* convert float value to haxe expression, handling inf/-inf/nan *) let haxe_float f p = let std = (Ast.EConst (Ast.Ident "std"), p) in let math = (Ast.EField (std, "Math"), p) in if (f = infinity) then (Ast.EField (math, "POSITIVE_INFINITY"), p) else if (f = neg_infinity) then (Ast.EField (math, "NEGATIVE_INFINITY"), p) else if (f <> f) then (Ast.EField (math, "NaN"), p) else (Ast.EConst (Ast.Float (float_repres f)), p) let macro_lib = let error() = raise Builtin_error in let ccom() = (get_ctx()).curapi.get_com() in make_library [ "curpos", Fun0 (fun() -> VAbstract (APos (get_ctx()).curapi.pos)); "error", Fun2 (fun msg p -> match msg, p with | VString s, VAbstract (APos p) -> (ccom()).Common.error s p; raise Abort | _ -> error() ); "fatal_error", Fun2 (fun msg p -> match msg, p with | VString s, VAbstract (APos p) -> raise (Typecore.Fatal_error (s,p)) | _ -> error() ); "warning", Fun2 (fun msg p -> match msg, p with | VString s, VAbstract (APos p) -> (ccom()).warning s p; VNull; | _ -> error() ); "class_path", Fun0 (fun() -> VArray (Array.of_list (List.map (fun s -> VString s) (ccom()).class_path)); ); "resolve", Fun1 (fun file -> match file with | VString s -> VString (try Common.find_file (ccom()) s with Not_found -> failwith ("File not found '" ^ s ^ "'")) | _ -> error(); ); "define", Fun1 (fun s -> match s with | VString s -> Common.raw_define (ccom()) s; VNull | _ -> error(); ); "defined", Fun1 (fun s -> match s with | VString s -> VBool (Common.raw_defined (ccom()) s) | _ -> error(); ); "defined_value", Fun1 (fun s -> match s with | VString s -> (try VString (Common.raw_defined_value (ccom()) s) with Not_found -> VNull) | _ -> error(); ); "get_defines", Fun0 (fun() -> let defines = (ccom()).defines in let h = Hashtbl.create 0 in PMap.iter (fun n v -> Hashtbl.replace h (VString n) (VString v)) defines; enc_hash h ); "get_type", Fun1 (fun s -> match s with | VString s -> (match (get_ctx()).curapi.get_type s with | None -> failwith ("Type not found '" ^ s ^ "'") | Some t -> encode_type t) | _ -> error() ); "get_module", Fun1 (fun s -> match s with | VString s -> enc_array (List.map encode_type ((get_ctx()).curapi.get_module s)) | _ -> error() ); "on_generate", Fun1 (fun f -> match f with | VFunction (Fun1 _) -> let ctx = get_ctx() in ctx.curapi.on_generate (fun tl -> ignore(catch_errors ctx (fun() -> ctx.do_call VNull f [enc_array (List.map encode_type tl)] null_pos)); ); VNull | _ -> error() ); "after_generate", Fun1 (fun f -> match f with | VFunction (Fun0 _) -> let ctx = get_ctx() in ctx.curapi.after_generate (fun () -> ignore(catch_errors ctx (fun() -> ctx.do_call VNull f [] null_pos)); ); VNull | _ -> error() ); "on_type_not_found", Fun1 (fun f -> match f with | VFunction (Fun1 _) -> let ctx = get_ctx() in ctx.curapi.on_type_not_found (fun path -> match catch_errors ctx (fun () -> ctx.do_call VNull f [enc_string path] null_pos) with | Some v -> v | None -> VNull ); VNull | _ -> error() ); "parse", Fun3 (fun s p b -> match s, p, b with | VString s, VAbstract (APos p), VBool b when s <> "" -> (try encode_expr ((get_ctx()).curapi.parse_string s p b) with Invalid_expr -> error()) | _ -> error() ); "make_expr", Fun2 (fun v p -> match p with | VAbstract (APos p) -> let h_enum = hash "__enum__" and h_et = hash "__et__" and h_ct = hash "__ct__" in let h_tag = hash "tag" and h_args = hash "args" in let h_length = hash "length" in let ctx = get_ctx() in let error v = failwith ("Unsupported value " ^ ctx.do_string v) in let make_path t = let rec loop = function | [] -> assert false | [name] -> (Ast.EConst (Ast.Ident name),p) | name :: l -> (Ast.EField (loop l,name),p) in let t = t_infos t in loop (List.rev (if t.mt_module.m_path = t.mt_path then fst t.mt_path @ [snd t.mt_path] else fst t.mt_module.m_path @ [snd t.mt_module.m_path;snd t.mt_path])) in let rec loop = function | VNull -> (Ast.EConst (Ast.Ident "null"),p) | VBool b -> (Ast.EConst (Ast.Ident (if b then "true" else "false")),p) | VInt i -> (Ast.EConst (Ast.Int (string_of_int i)),p) | VInt32 i -> (Ast.EConst (Ast.Int (Int32.to_string i)),p) | VFloat f -> haxe_float f p | VAbstract (APos p) -> (Ast.EObjectDecl ( ("fileName" , (Ast.EConst (Ast.String p.Ast.pfile) , p)) :: ("lineNumber" , (Ast.EConst (Ast.Int (string_of_int (Lexer.get_error_line p))),p)) :: ("className" , (Ast.EConst (Ast.String ("")),p)) :: [] ), p) | VString _ | VArray _ | VAbstract _ | VFunction _ | VClosure _ as v -> error v | VObject o as v -> match o.oproto with | None -> (match get_field_opt o h_ct with | Some (VAbstract (ATDecl t)) -> make_path t | _ -> let fields = List.fold_left (fun acc (fid,v) -> (field_name ctx fid, loop v) :: acc) [] (Array.to_list o.ofields) in (Ast.EObjectDecl fields, p)) | Some proto -> match get_field_opt proto h_enum, get_field_opt o h_a, get_field_opt o h_s, get_field_opt o h_length with | _, Some (VArray a), _, Some (VInt len) -> (Ast.EArrayDecl (List.map loop (Array.to_list (Array.sub a 0 len))),p) | _, _, Some (VString s), _ -> (Ast.EConst (Ast.String s),p) | Some (VObject en), _, _, _ -> (match get_field en h_et, get_field o h_tag with | VAbstract (ATDecl t), VString tag -> let e = (Ast.EField (make_path t,tag),p) in (match get_field_opt o h_args with | Some (VArray args) -> let args = List.map loop (Array.to_list args) in (Ast.ECall (e,args),p) | _ -> e) | _ -> error v) | _ -> error v in encode_expr (loop v) | _ -> error() ); "signature", Fun1 (fun v -> let cache = ref [] in let cache_count = ref 0 in let hfiles = Hashtbl.create 0 in let get_file f = try Hashtbl.find hfiles f with Not_found -> let ff = Common.unique_full_path f in Hashtbl.add hfiles f ff; ff in let do_cache (v:value) (v2:value) = (* tricky : we need to have a quick not-linear cache based on objects address but we can't use address since the GC might be triggered here. Instead let's mutate the object temporary. *) let vt = Obj.repr v in let old = Obj.tag vt in let old_val = Obj.field vt 0 in let abstract_tag = 7 in Obj.set_tag vt abstract_tag; Obj.set_field vt 0 (Obj.repr (ACacheRef v2)); cache := (vt,old,old_val) :: !cache; incr cache_count in let rec loop v = match v with | VNull | VBool _ | VInt _ | VFloat _ | VString _ | VInt32 _ -> v | VObject o -> let o2 = { ofields = [||]; oproto = None } in let v2 = VObject o2 in do_cache v v2; Array.iter (fun (f,v) -> if f <> h_class then set_field o2 f (loop v)) o.ofields; (match o.oproto with | None -> () | Some p -> (match loop (VObject p) with VObject p2 -> o2.oproto <- Some p2 | _ -> assert false)); v2 | VArray a -> let a2 = Array.create (Array.length a) VNull in let v2 = VArray a2 in do_cache v v2; for i = 0 to Array.length a - 1 do a2.(i) <- loop a.(i); done; v2 | VFunction f -> let v2 = VFunction (Obj.magic !cache_count) in do_cache v v2; v2 | VClosure (vl,f) -> let rl = ref [] in let v2 = VClosure (Obj.magic rl, Obj.magic !cache_count) in (* in ocaml 4.0+ it was reported some stack overflow, related to vl being GC'ed or mutated in do_cache. let's make sure to have a real pointer to it first. The fix will trigger an alloc which might have simply moved the problem away *) let vl = VNull :: vl in do_cache v v2; rl := List.map loop vl; v2 | VAbstract (APos p) -> VAbstract (APos { p with Ast.pfile = get_file p.Ast.pfile }) | VAbstract (ACacheRef v) -> v | VAbstract (AHash h) -> let h2 = Hashtbl.create 0 in let v2 = VAbstract (AHash h2) in do_cache v v2; Hashtbl.iter (fun k v -> Hashtbl.add h2 k (loop v)) h2; v2 | VAbstract _ -> let v2 = VAbstract (Obj.magic !cache_count) in do_cache v v2; v2 in let v = loop v in (* restore *) List.iter (fun (vt,tag,field) -> Obj.set_tag vt tag; Obj.set_field vt 0 field; ) !cache; VString (Digest.to_hex (Digest.string (Marshal.to_string v [Marshal.Closures]))) ); "to_complex", Fun1 (fun v -> try encode_complex_type (make_complex_type (decode_type v)) with Exit -> VNull ); "unify", Fun2 (fun t1 t2 -> let e1 = mk (TObjectDecl []) (decode_type t1) Ast.null_pos in try ignore(((get_ctx()).curapi.cast_or_unify) (decode_type t2) e1 Ast.null_pos); VBool true with Typecore.Error (Typecore.Unify _,_) -> VBool false ); "typeof", Fun1 (fun v -> encode_type ((get_ctx()).curapi.type_expr (decode_expr v)).etype ); "type_expr", Fun1 (fun v -> encode_texpr ((get_ctx()).curapi.type_expr (decode_expr v)) ); "s_type", Fun1 (fun v -> VString (Type.s_type (print_context()) (decode_type v)) ); "s_expr", Fun2 (fun v b -> let f = match b with VBool true -> Type.s_expr_pretty "" | _ -> Type.s_expr_ast true "" in VString (f (Type.s_type (print_context())) (decode_texpr v)) ); "is_fmt_string", Fun1 (fun v -> match v with | VAbstract (APos p) -> VBool(Lexer.is_fmt_string p) | _ -> VNull ); "format_string", Fun2 (fun s p -> match s,p with | VString(s),VAbstract(APos p) -> encode_expr ((get_ctx()).curapi.format_string s p) | _ -> VNull ); "display", Fun1 (fun v -> match v with | VString s -> VString ((get_ctx()).curapi.get_display s) | _ -> error() ); "allow_package", Fun1 (fun v -> match v with | VString s -> (get_ctx()).curapi.allow_package s; VNull | _ -> error()); "type_patch", Fun4 (fun t f s v -> let p = (get_ctx()).curapi.type_patch in (match t, f, s, v with | VString t, VString f, VBool s, VString v -> p t f s (Some v) | VString t, VString f, VBool s, VNull -> p t f s None | _ -> error()); VNull ); "meta_patch", Fun4 (fun m t f s -> let p = (get_ctx()).curapi.meta_patch in (match m, t, f, s with | VString m, VString t, VString f, VBool s -> p m t (Some f) s | VString m, VString t, VNull, VBool s -> p m t None s | _ -> error()); VNull ); "add_global_metadata", Fun5 (fun v1 v2 v3 v4 v5 -> match v1,v2,v3,v4,v5 with | VString s1,VString s2,VBool b1,VBool b2,VBool b3 -> (get_ctx()).curapi.add_global_metadata s1 s2 (b1,b2,b3); VNull | _ -> error() ); "custom_js", Fun1 (fun f -> match f with | VFunction (Fun1 _) -> let ctx = get_ctx() in ctx.curapi.set_js_generator (fun api -> ignore(catch_errors ctx (fun() -> ctx.do_call VNull f [api] null_pos)); ); VNull | _ -> error() ); "get_pos_infos", Fun1 (fun p -> match p with | VAbstract (APos p) -> VObject (obj (hash_field (get_ctx())) ["min",VInt p.Ast.pmin;"max",VInt p.Ast.pmax;"file",VString p.Ast.pfile]) | _ -> error() ); "make_pos", Fun3 (fun min max file -> match min, max, file with | VInt min, VInt max, VString file -> VAbstract (APos { Ast.pmin = min; Ast.pmax = max; Ast.pfile = file }) | _ -> error() ); "add_resource", Fun2 (fun name data -> match name, data with | VString name, VString data -> Hashtbl.replace (ccom()).resources name data; let m = (get_ctx()).curapi.current_module() in m.m_extra.m_binded_res <- PMap.add name data m.m_extra.m_binded_res; VNull | _ -> error() ); "get_resources", Fun0 (fun() -> let res = (ccom()).resources in let h = Hashtbl.create 0 in Hashtbl.iter (fun n v -> Hashtbl.replace h (VString n) (VString v)) res; enc_hash h ); "local_module", Fun0 (fun() -> let m = (get_ctx()).curapi.current_module() in VString (Ast.s_type_path m.m_path); ); "local_type", Fun0 (fun() -> match (get_ctx()).curapi.get_local_type() with | None -> VNull | Some t -> encode_type t ); "expected_type", Fun0 (fun() -> match (get_ctx()).curapi.get_expected_type() with | None -> VNull | Some t -> encode_type t ); "call_arguments", Fun0 (fun() -> match (get_ctx()).curapi.get_call_arguments() with | None -> VNull | Some el -> enc_array (List.map encode_expr el) ); "local_method", Fun0 (fun() -> VString ((get_ctx()).curapi.get_local_method()) ); "local_using", Fun0 (fun() -> enc_array (List.map encode_clref ((get_ctx()).curapi.get_local_using())) ); "local_vars", Fun1 (fun as_var -> let as_var = match as_var with | VNull | VBool false -> false | VBool true -> true | _ -> error() in let vars = (get_ctx()).curapi.get_local_vars() in let h = Hashtbl.create 0 in if as_var then PMap.iter (fun n v -> Hashtbl.replace h (VString n) (encode_tvar v)) vars else PMap.iter (fun n v -> Hashtbl.replace h (VString n) (encode_type v.v_type)) vars; enc_hash h ); "follow", Fun2 (fun v once -> let t = decode_type v in let follow_once t = match t with | TMono r -> (match !r with | None -> t | Some t -> t) | TAbstract _ | TEnum _ | TInst _ | TFun _ | TAnon _ | TDynamic _ -> t | TType (t,tl) -> apply_params t.t_params tl t.t_type | TLazy f -> (!f)() in encode_type (match once with VNull | VBool false -> follow t | VBool true -> follow_once t | _ -> error()) ); "build_fields", Fun0 (fun() -> (get_ctx()).curapi.get_build_fields() ); "define_type", Fun1 (fun v -> (get_ctx()).curapi.define_type v; VNull ); "define_module", Fun4 (fun p v i u -> match p, v, i, u with | VString path, VArray vl, VArray ui, VArray ul -> (get_ctx()).curapi.define_module path (Array.to_list vl) (List.map decode_import (Array.to_list ui)) (List.map decode_path (Array.to_list ul)); VNull | _ -> error() ); "add_class_path", Fun1 (fun v -> match v with | VString cp -> let com = ccom() in com.class_path <- (Common.normalize_path cp) :: com.class_path; Hashtbl.clear com.file_lookup_cache; VNull | _ -> error() ); "add_native_lib", Fun1 (fun v -> match v with | VString file -> let com = ccom() in (match com.platform with | Flash -> Genswf.add_swf_lib com file false | Java -> Genjava.add_java_lib com file false | Cs -> let file, is_std = match ExtString.String.nsplit file "@" with | [file] -> file,false | [file;"std"] -> file,true | _ -> failwith ("unsupported file@`std` format: " ^ file) in Gencs.add_net_lib com file is_std | _ -> failwith "Unsupported platform"); VNull | _ -> error() ); "add_native_arg", Fun1 (fun v -> match v with | VString arg -> let com = ccom() in (match com.platform with | Java | Cs | Cpp -> com.c_args <- arg :: com.c_args | _ -> failwith "Unsupported platform"); VNull | _ -> error() ); "module_dependency", Fun2 (fun m file -> match m, file with | VString m, VString file -> (get_ctx()).curapi.module_dependency m file false; VNull | _ -> error() ); "module_reuse_call", Fun2 (fun m mcall -> match m, mcall with | VString m, VString mcall -> (get_ctx()).curapi.module_dependency m mcall true; VNull | _ -> error() ); "get_typed_expr", Fun1 (fun e -> let e = decode_texpr e in encode_expr (make_ast e) ); "store_typed_expr", Fun1 (fun e -> let e = try decode_texpr e with Invalid_expr -> error() in encode_expr ((get_ctx()).curapi.store_typed_expr e) ); "get_output", Fun0 (fun() -> VString (ccom()).file ); "set_output", Fun1 (fun s -> match s with | VString s -> (ccom()).file <- s; VNull | _ -> error() ); "get_display_pos", Fun0 (fun() -> let p = !Parser.resume_display in if p = Ast.null_pos then VNull else VObject (obj (hash_field (get_ctx())) ["file",VString p.Ast.pfile;"pos",VInt p.Ast.pmin]) ); "pattern_locals", Fun2 (fun e t -> let loc = (get_ctx()).curapi.get_pattern_locals (decode_expr e) (decode_type t) in let h = Hashtbl.create 0 in PMap.iter (fun n (v,_) -> Hashtbl.replace h (VString n) (encode_type v.v_type)) loc; enc_hash h ); "macro_context_reused", Fun1 (fun c -> match c with | VFunction (Fun0 _) -> let ctx = get_ctx() in ctx.on_reused <- (fun() -> catch_errors ctx (fun() -> ctx.do_call VNull c [] null_pos) = Some (VBool true)) :: ctx.on_reused; VNull | _ -> error() ); "apply_params", Fun3 (fun tpl tl t -> let tpl = List.map (fun v -> match v with | VObject o -> let name = match get_field o (hash "name") with VString s -> s | _ -> assert false in let t = decode_type (get_field o (hash "t")) in name,t | _ -> assert false ) (dec_array tpl) in let tl = List.map decode_type (dec_array tl) in let rec map t = match t with | TInst({cl_kind = KTypeParameter _},_) -> begin try (* use non-physical equality check here to make apply_params work *) snd (List.find (fun (_,t2) -> type_iseq t t2) tpl) with Not_found -> Type.map map t end | _ -> Type.map map t in encode_type (apply_params tpl tl (map (decode_type t))) ); ] (* ---------------------------------------------------------------------- *) (* EVAL *) let throw ctx p msg = ctx.callstack <- { cpos = p; cthis = ctx.vthis; cstack = DynArray.length ctx.stack; cenv = ctx.venv } :: ctx.callstack; exc (VString msg) let declare ctx var = ctx.locals_map <- PMap.add var ctx.locals_count ctx.locals_map; ctx.locals_count <- ctx.locals_count + 1 let save_locals ctx = let old, oldcount = ctx.locals_map, ctx.locals_count in (fun() -> let n = ctx.locals_count - oldcount in ctx.locals_count <- oldcount; ctx.locals_map <- old; n; ) let get_ident ctx s = try let index = PMap.find s ctx.locals_map in if index >= ctx.locals_barrier then AccLocal (ctx.locals_count - index) else (try AccEnv (DynArray.index_of (fun s2 -> s = s2) ctx.locals_env) with Not_found -> let index = DynArray.length ctx.locals_env in DynArray.add ctx.locals_env s; AccEnv index ) with Not_found -> try AccGlobal (PMap.find s ctx.globals) with Not_found -> let g = ref VNull in ctx.globals <- PMap.add s g ctx.globals; AccGlobal g let no_env = [||] let rec eval ctx (e,p) = match e with | EConst c -> (match c with | True -> (fun() -> VBool true) | False -> (fun() -> VBool false) | Null -> (fun() -> VNull) | This -> (fun() -> ctx.vthis) | Int i -> (fun() -> VInt i) | Int32 i -> (fun() -> VInt32 i) | Float f -> let f = float_of_string f in (fun() -> VFloat f) | String s -> (fun() -> VString s) | Builtin "loader" -> (fun() -> ctx.loader) | Builtin "exports" -> (fun() -> ctx.exports) | Builtin s -> let b = (try Hashtbl.find builtins s with Not_found -> throw ctx p ("Builtin not found '" ^ s ^ "'")) in (fun() -> b) | Ident s -> acc_get ctx p (get_ident ctx s)) | EBlock el -> let old = save_locals ctx in let el = List.map (eval ctx) el in let n = old() in let rec loop = function | [] -> VNull | [e] -> e() | e :: l -> ignore(e()); loop l in (fun() -> let v = loop el in pop ctx n; v) | EParenthesis e -> eval ctx e | EField (e,f) -> let e = eval ctx e in let h = hash_field ctx f in (fun() -> match e() with | VObject o -> get_field o h | _ -> throw ctx p ("Invalid field access : " ^ f) ) | ECall ((EConst (Builtin "mk_pos"),_),[(ECall (_,[EConst (String file),_]),_);(EConst (Int min),_);(EConst (Int max),_)]) -> let pos = VAbstract (APos { Ast.pfile = file; Ast.pmin = min; Ast.pmax = max }) in (fun() -> pos) | ECall ((EConst (Builtin "typewrap"),_),[t]) -> (fun() -> VAbstract (ATDecl (Obj.magic t))) | ECall ((EConst (Builtin "delay_call"),_),[EConst (Int index),_]) -> let f = ctx.curapi.delayed_macro index in let fbuild = ref None in let old = { ctx with gen = ctx.gen } in let compile_delayed_call() = let oldl, oldc, oldb, olde = ctx.locals_map, ctx.locals_count, ctx.locals_barrier, ctx.locals_env in ctx.locals_map <- old.locals_map; ctx.locals_count <- old.locals_count; ctx.locals_barrier <- old.locals_barrier; ctx.locals_env <- DynArray.copy old.locals_env; let save = save_locals ctx in let e = f() in let n = save() in let e = if DynArray.length ctx.locals_env = DynArray.length old.locals_env then e else let n = DynArray.get ctx.locals_env (DynArray.length ctx.locals_env - 1) in (fun() -> exc (VString ("Macro-in-macro call can't access to closure variable '" ^ n ^ "'"))) in ctx.locals_map <- oldl; ctx.locals_count <- oldc; ctx.locals_barrier <- oldb; ctx.locals_env <- olde; (fun() -> let v = e() in pop ctx n; v ) in (fun() -> let e = (match !fbuild with | Some e -> e | None -> let e = compile_delayed_call() in fbuild := Some e; e ) in e()) | ECall (e,el) -> let el = List.map (eval ctx) el in (match fst e with | EField (e,f) -> let e = eval ctx e in let h = hash_field ctx f in (fun() -> let pl = List.map (fun f -> f()) el in let o = e() in let f = (match o with | VObject o -> get_field o h | _ -> throw ctx p ("Invalid field access : " ^ f) ) in call ctx o f pl p ) | _ -> let e = eval ctx e in (fun() -> let pl = List.map (fun f -> f()) el in call ctx ctx.vthis (e()) pl p )) | EArray (e1,e2) -> let e1 = eval ctx e1 in let e2 = eval ctx e2 in let acc = AccArray (e1,e2) in acc_get ctx p acc | EVars vl -> let vl = List.map (fun (v,eo) -> let eo = (match eo with None -> (fun() -> VNull) | Some e -> eval ctx e) in declare ctx v; eo ) vl in (fun() -> List.iter (fun e -> push ctx (e())) vl; VNull ) | EWhile (econd,e,NormalWhile) -> let econd = eval ctx econd in let e = eval ctx e in let rec loop st = match econd() with | VBool true -> let v = (try ignore(e()); None with | Continue -> pop ctx (DynArray.length ctx.stack - st); None | Break v -> pop ctx (DynArray.length ctx.stack - st); Some v ) in (match v with | None -> loop st | Some v -> v) | _ -> VNull in (fun() -> try loop (DynArray.length ctx.stack) with Sys.Break -> throw ctx p "Ctrl+C") | EWhile (econd,e,DoWhile) -> let e = eval ctx e in let econd = eval ctx econd in let rec loop st = let v = (try ignore(e()); None with | Continue -> pop ctx (DynArray.length ctx.stack - st); None | Break v -> pop ctx (DynArray.length ctx.stack - st); Some v ) in match v with | Some v -> v | None -> match econd() with | VBool true -> loop st | _ -> VNull in (fun() -> loop (DynArray.length ctx.stack)) | EIf (econd,eif,eelse) -> let econd = eval ctx econd in let eif = eval ctx eif in let eelse = (match eelse with None -> (fun() -> VNull) | Some e -> eval ctx e) in (fun() -> match econd() with | VBool true -> eif() | _ -> eelse() ) | ETry (e,exc,ecatch) -> let old = save_locals ctx in let e = eval ctx e in let n1 = old() in declare ctx exc; let ecatch = eval ctx ecatch in let n2 = old() in (fun() -> let vthis = ctx.vthis in let venv = ctx.venv in let stack = ctx.callstack in let csize = ctx.callsize in let size = DynArray.length ctx.stack in try pop_ret ctx e n1 with Runtime v -> let rec loop n l = if n = 0 then List.map (fun s -> s.cpos) l else match l with | [] -> [] | _ :: l -> loop (n - 1) l in ctx.exc <- loop (List.length stack) (List.rev ctx.callstack); ctx.callstack <- stack; ctx.callsize <- csize; ctx.vthis <- vthis; ctx.venv <- venv; pop ctx (DynArray.length ctx.stack - size); push ctx v; pop_ret ctx ecatch n2 ) | EFunction (pl,e) -> let old = save_locals ctx in let oldb, oldenv = ctx.locals_barrier, ctx.locals_env in ctx.locals_barrier <- ctx.locals_count; ctx.locals_env <- DynArray.create(); List.iter (declare ctx) pl; let e = eval ctx e in ignore(old()); let env = ctx.locals_env in ctx.locals_barrier <- oldb; ctx.locals_env <- oldenv; let env = DynArray.to_array (DynArray.map (fun s -> acc_get ctx p (get_ident ctx s)) env ) in let init_env = if Array.length env = 0 then (fun() -> no_env) else (fun() -> Array.map (fun e -> e()) env) in (match pl with | [] -> (fun() -> let env = init_env() in VFunction (Fun0 (fun() -> ctx.venv <- env; e()))) | [a] -> (fun() -> let env = init_env() in VFunction (Fun1 (fun v -> ctx.venv <- env; push ctx v; e(); ))) | [a;b] -> (fun() -> let env = init_env() in VFunction (Fun2 (fun va vb -> ctx.venv <- env; push ctx va; push ctx vb; e(); ))) | [a;b;c] -> (fun() -> let env = init_env() in VFunction (Fun3 (fun va vb vc -> ctx.venv <- env; push ctx va; push ctx vb; push ctx vc; e(); ))) | [a;b;c;d] -> (fun() -> let env = init_env() in VFunction (Fun4 (fun va vb vc vd -> ctx.venv <- env; push ctx va; push ctx vb; push ctx vc; push ctx vd; e(); ))) | [a;b;c;d;pe] -> (fun() -> let env = init_env() in VFunction (Fun5 (fun va vb vc vd ve -> ctx.venv <- env; push ctx va; push ctx vb; push ctx vc; push ctx vd; push ctx ve; e(); ))) | _ -> (fun() -> let env = init_env() in VFunction (FunVar (fun vl -> if List.length vl != List.length pl then exc (VString "Invalid call"); ctx.venv <- env; List.iter (push ctx) vl; e(); ))) ) | EBinop (op,e1,e2) -> eval_op ctx op e1 e2 p | EReturn None -> (fun() -> raise (Return VNull)) | EReturn (Some e) -> let e = eval ctx e in (fun() -> raise (Return (e()))) | EBreak None -> (fun() -> raise (Break VNull)) | EBreak (Some e) -> let e = eval ctx e in (fun() -> raise (Break (e()))) | EContinue -> (fun() -> raise Continue) | ENext (e1,e2) -> let e1 = eval ctx e1 in let e2 = eval ctx e2 in (fun() -> ignore(e1()); e2()) | EObject fl -> let fl = List.map (fun (f,e) -> hash_field ctx f, eval ctx e) fl in let fields = Array.of_list (List.map (fun (f,_) -> f,VNull) fl) in Array.sort (fun (f1,_) (f2,_) -> compare f1 f2) fields; (fun() -> let o = { ofields = Array.copy fields; oproto = None; } in List.iter (fun (f,e) -> set_field o f (e())) fl; VObject o ) | ELabel l -> assert false | ESwitch (e1,el,eo) -> let e1 = eval ctx e1 in let el = List.map (fun (cond,e) -> cond, eval ctx cond, eval ctx e) el in let eo = (match eo with None -> (fun() -> VNull) | Some e -> eval ctx e) in let cases = (try let max = ref (-1) in let ints = List.map (fun (cond,_,e) -> match fst cond with | EConst (Int i) -> if i < 0 then raise Exit; if i > !max then max := i; i, e | _ -> raise Exit ) el in let a = Array.create (!max + 1) eo in List.iter (fun (i,e) -> a.(i) <- e) (List.rev ints); Some a; with Exit -> None ) in let def v = let rec loop = function | [] -> eo() | (_,c,e) :: l -> if ctx.do_compare v (c()) = CEq then e() else loop l in loop el in (match cases with | None -> (fun() -> def (e1())) | Some t -> (fun() -> match e1() with | VInt i -> if i >= 0 && i < Array.length t then t.(i)() else eo() | v -> def v )) | ENeko _ -> throw ctx p "Inline neko code unsupported" and eval_oop ctx p o field (params:value list) = match get_field_opt o field with | None -> None | Some f -> Some (call ctx (VObject o) f params p) and eval_access ctx (e,p) = match e with | EField (e,f) -> let v = eval ctx e in AccField (v,f) | EArray (e,eindex) -> let v = eval ctx e in let idx = eval ctx eindex in AccArray (v,idx) | EConst (Ident s) -> get_ident ctx s | EConst This -> AccThis | _ -> throw ctx p "Invalid assign" and eval_access_get_set ctx (e,p) = match e with | EField (e,f) -> let v = eval ctx e in let cache = ref VNull in AccField ((fun() -> cache := v(); !cache),f), AccField((fun() -> !cache), f) | EArray (e,eindex) -> let v = eval ctx e in let idx = eval ctx eindex in let vcache = ref VNull and icache = ref VNull in AccArray ((fun() -> vcache := v(); !vcache),(fun() -> icache := idx(); !icache)), AccArray ((fun() -> !vcache),(fun() -> !icache)) | EConst (Ident s) -> let acc = get_ident ctx s in acc, acc | EConst This -> AccThis, AccThis | _ -> throw ctx p "Invalid assign" and acc_get ctx p = function | AccField (v,f) -> let h = hash_field ctx f in (fun() -> match v() with | VObject o -> get_field o h | _ -> throw ctx p ("Invalid field access : " ^ f)) | AccArray (e,index) -> (fun() -> let e = e() in let index = index() in (match index, e with | VInt i, VArray a -> (try Array.get a i with _ -> VNull) | VInt32 _, VArray _ -> VNull | _, VObject o -> (match eval_oop ctx p o h_get [index] with | None -> throw ctx p "Invalid array access" | Some v -> v) | _ -> throw ctx p "Invalid array access")) | AccLocal i -> (fun() -> DynArray.get ctx.stack (DynArray.length ctx.stack - i)) | AccGlobal g -> (fun() -> !g) | AccThis -> (fun() -> ctx.vthis) | AccEnv i -> (fun() -> ctx.venv.(i)) and acc_set ctx p acc value = match acc with | AccField (v,f) -> let h = hash_field ctx f in (fun() -> let v = v() in let value = value() in match v with | VObject o -> set_field o h value; value | _ -> throw ctx p ("Invalid field access : " ^ f)) | AccArray (e,index) -> (fun() -> let e = e() in let index = index() in let value = value() in (match index, e with | VInt i, VArray a -> (try Array.set a i value; value with _ -> value) | VInt32 _, VArray _ -> value | _, VObject o -> (match eval_oop ctx p o h_set [index;value] with | None -> throw ctx p "Invalid array access" | Some _ -> value); | _ -> throw ctx p "Invalid array access")) | AccLocal i -> (fun() -> let value = value() in DynArray.set ctx.stack (DynArray.length ctx.stack - i) value; value) | AccGlobal g -> (fun() -> let value = value() in g := value; value) | AccThis -> (fun() -> let value = value() in ctx.vthis <- value; value) | AccEnv i -> (fun() -> let value = value() in ctx.venv.(i) <- value; value) and number_op ctx p sop iop fop oop rop v1 v2 = (fun() -> let v1 = v1() in let v2 = v2() in exc_number_op ctx p sop iop fop oop rop v1 v2) and exc_number_op ctx p sop iop fop oop rop v1 v2 = match v1, v2 with | VInt a, VInt b -> best_int (iop (Int32.of_int a) (Int32.of_int b)) | VInt32 a, VInt b -> best_int (iop a (Int32.of_int b)) | VInt a, VInt32 b -> best_int (iop (Int32.of_int a) b) | VFloat a, VInt b -> VFloat (fop a (float_of_int b)) | VFloat a, VInt32 b -> VFloat (fop a (Int32.to_float b)) | VInt a, VFloat b -> VFloat (fop (float_of_int a) b) | VInt32 a, VFloat b -> VFloat (fop (Int32.to_float a) b) | VFloat a, VFloat b -> VFloat (fop a b) | VInt32 a, VInt32 b -> best_int (iop a b) | VObject o, _ -> (match eval_oop ctx p o oop [v2] with | Some v -> v | None -> match v2 with | VObject o -> (match eval_oop ctx p o rop [v1] with | Some v -> v | None -> throw ctx p sop) | _ -> throw ctx p sop) | _ , VObject o -> (match eval_oop ctx p o rop [v1] with | Some v -> v | None -> throw ctx p sop) | _ -> throw ctx p sop and int_op ctx p op iop v1 v2 = (fun() -> let v1 = v1() in let v2 = v2() in match v1, v2 with | VInt a, VInt b -> best_int (iop (Int32.of_int a) (Int32.of_int b)) | VInt32 a, VInt b -> best_int (iop a (Int32.of_int b)) | VInt a, VInt32 b -> best_int (iop (Int32.of_int a) b) | VInt32 a, VInt32 b -> best_int (iop a b) | _ -> throw ctx p op) and base_op ctx op v1 v2 p = match op with | "+" -> (fun() -> let v1 = v1() in let v2 = v2() in match v1, v2 with | (VInt _ | VInt32 _), (VInt _ | VInt32 _) | (VInt _ | VInt32 _), VFloat _ | VFloat _ , (VInt _ | VInt32 _) | VFloat _ , VFloat _ | VObject _ , _ | _ , VObject _ -> exc_number_op ctx p op Int32.add (+.) h_add h_radd v1 v2 | VString a, _ -> VString (a ^ ctx.do_string v2) | _, VString b -> VString (ctx.do_string v1 ^ b) | _ -> throw ctx p op) | "-" -> number_op ctx p op Int32.sub (-.) h_sub h_rsub v1 v2 | "*" -> number_op ctx p op Int32.mul ( *. ) h_mult h_rmult v1 v2 | "/" -> (fun() -> let v1 = v1() in let v2 = v2() in match v1, v2 with | VInt i, VInt j -> VFloat ((float_of_int i) /. (float_of_int j)) | VInt i, VInt32 j -> VFloat ((float_of_int i) /. (Int32.to_float j)) | VInt32 i, VInt j -> VFloat ((Int32.to_float i) /. (float_of_int j)) | VInt32 i, VInt32 j -> VFloat ((Int32.to_float i) /. (Int32.to_float j)) | _ -> exc_number_op ctx p op Int32.div (/.) h_div h_rdiv v1 v2) | "%" -> number_op ctx p op (fun x y -> if y = 0l then throw ctx p op; Int32.rem x y) mod_float h_mod h_rmod v1 v2 | "&" -> int_op ctx p op Int32.logand v1 v2 | "|" -> int_op ctx p op Int32.logor v1 v2 | "^" -> int_op ctx p op Int32.logxor v1 v2 | "<<" -> int_op ctx p op (fun x y -> Int32.shift_left x (Int32.to_int y)) v1 v2 | ">>" -> int_op ctx p op (fun x y -> Int32.shift_right x (Int32.to_int y)) v1 v2 | ">>>" -> int_op ctx p op (fun x y -> Int32.shift_right_logical x (Int32.to_int y)) v1 v2 | _ -> throw ctx p op and eval_op ctx op e1 e2 p = match op with | "=" -> let acc = eval_access ctx e1 in let v = eval ctx e2 in acc_set ctx p acc v | "==" -> let v1 = eval ctx e1 in let v2 = eval ctx e2 in (fun() -> let v1 = v1() in let v2 = v2() in match ctx.do_compare v1 v2 with | CEq -> VBool true | _ -> VBool false) | "!=" -> let v1 = eval ctx e1 in let v2 = eval ctx e2 in (fun() -> let v1 = v1() in let v2 = v2() in match ctx.do_compare v1 v2 with | CEq -> VBool false | _ -> VBool true) | ">" -> let v1 = eval ctx e1 in let v2 = eval ctx e2 in (fun() -> let v1 = v1() in let v2 = v2() in match ctx.do_compare v1 v2 with | CSup -> VBool true | _ -> VBool false) | ">=" -> let v1 = eval ctx e1 in let v2 = eval ctx e2 in (fun() -> let v1 = v1() in let v2 = v2() in match ctx.do_compare v1 v2 with | CSup | CEq -> VBool true | _ -> VBool false) | "<" -> let v1 = eval ctx e1 in let v2 = eval ctx e2 in (fun() -> let v1 = v1() in let v2 = v2() in match ctx.do_compare v1 v2 with | CInf -> VBool true | _ -> VBool false) | "<=" -> let v1 = eval ctx e1 in let v2 = eval ctx e2 in (fun() -> let v1 = v1() in let v2 = v2() in match ctx.do_compare v1 v2 with | CInf | CEq -> VBool true | _ -> VBool false) | "+" | "-" | "*" | "/" | "%" | "|" | "&" | "^" | "<<" | ">>" | ">>>" -> let v1 = eval ctx e1 in let v2 = eval ctx e2 in base_op ctx op v1 v2 p | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "&=" | "^=" -> let aset, aget = eval_access_get_set ctx e1 in let v1 = acc_get ctx p aget in let v2 = eval ctx e2 in let v = base_op ctx (String.sub op 0 (String.length op - 1)) v1 v2 p in acc_set ctx p aset v | "&&" -> let e1 = eval ctx e1 in let e2 = eval ctx e2 in (fun() -> match e1() with | VBool false as v -> v | _ -> e2()) | "||" -> let e1 = eval ctx e1 in let e2 = eval ctx e2 in (fun() -> match e1() with | VBool true as v -> v | _ -> e2()) | "++=" | "--=" -> let aset, aget = eval_access_get_set ctx e1 in let v1 = acc_get ctx p aget in let v2 = eval ctx e2 in let vcache = ref VNull in let v = base_op ctx (String.sub op 0 1) (fun() -> vcache := v1(); !vcache) v2 p in let set = acc_set ctx p aset v in (fun() -> ignore(set()); !vcache) | _ -> throw ctx p ("Unsupported " ^ op) and call ctx vthis vfun pl p = let oldthis = ctx.vthis in let stackpos = DynArray.length ctx.stack in let oldstack = ctx.callstack in let oldsize = ctx.callsize in let oldenv = ctx.venv in ctx.vthis <- vthis; ctx.callstack <- { cpos = p; cthis = oldthis; cstack = stackpos; cenv = oldenv } :: ctx.callstack; ctx.callsize <- oldsize + 1; if oldsize > 600 then exc (VString "Stack overflow"); let ret = (try (match vfun with | VClosure (vl,f) -> f vl pl | VFunction f -> (match pl, f with | [], Fun0 f -> f() | [a], Fun1 f -> f a | [a;b], Fun2 f -> f a b | [a;b;c], Fun3 f -> f a b c | [a;b;c;d], Fun4 f -> f a b c d | [a;b;c;d;e], Fun5 f -> f a b c d e | _, FunVar f -> f pl | _ -> exc (VString (Printf.sprintf "Invalid call (%d args instead of %d)" (List.length pl) (nargs f)))) | VAbstract (ALazyType f) -> encode_type ((!f)()) | _ -> exc (VString "Invalid call")) with Return v -> v | Stack_overflow -> exc (VString "Compiler Stack overflow") | Sys_error msg | Failure msg -> exc (VString msg) | Unix.Unix_error (_,cmd,msg) -> exc (VString ("Error " ^ cmd ^ " " ^ msg)) (* | Invalid_expr -> exc (VString "Invalid input value") *) | Builtin_error | Invalid_argument _ -> exc (VString "Invalid call")) in ctx.vthis <- oldthis; ctx.venv <- oldenv; ctx.callstack <- oldstack; ctx.callsize <- oldsize; pop ctx (DynArray.length ctx.stack - stackpos); ret (* ---------------------------------------------------------------------- *) (* OTHERS *) let rec to_string ctx n v = if n > 5 then "<...>" else let n = n + 1 in match v with | VNull -> "null" | VBool true -> "true" | VBool false -> "false" | VInt i -> string_of_int i | VInt32 i -> Int32.to_string i | VFloat f -> let s = float_repres f in let len = String.length s in if String.unsafe_get s (len - 1) = '.' then String.sub s 0 (len - 1) else s | VString s -> s | VArray vl -> "[" ^ String.concat "," (Array.to_list (Array.map (to_string ctx n) vl)) ^ "]" | VAbstract a -> (match a with | APos p -> "#pos(" ^ Lexer.get_error_pos (Printf.sprintf "%s:%d:") p ^ ")" | _ -> "#abstract") | VFunction f -> "#function:" ^ string_of_int (nargs f) | VClosure _ -> "#function:-1" | VObject o -> match eval_oop ctx null_pos o h_string [] with | Some (VString s) -> s | _ -> let b = Buffer.create 0 in let first = ref true in Buffer.add_char b '{'; Array.iter (fun (f,v) -> if !first then begin Buffer.add_char b ' '; first := false; end else Buffer.add_string b ", "; Buffer.add_string b (field_name ctx f); Buffer.add_string b " => "; Buffer.add_string b (to_string ctx n v); ) o.ofields; Buffer.add_string b (if !first then "}" else " }"); Buffer.contents b let rec compare ctx a b = let fcmp (a:float) b = if a = b then CEq else if a < b then CInf else CSup in let scmp (a:string) b = if a = b then CEq else if a < b then CInf else CSup in let icmp (a:int32) b = let l = Int32.compare a b in if l = 0 then CEq else if l < 0 then CInf else CSup in match a, b with | VNull, VNull -> CEq | VInt a, VInt b -> if a = b then CEq else if a < b then CInf else CSup | VInt32 a, VInt32 b -> icmp a b | VInt a, VInt32 b -> icmp (Int32.of_int a) b | VInt32 a, VInt b -> icmp a (Int32.of_int b) | VFloat a, VFloat b -> fcmp a b | VFloat a, VInt b -> fcmp a (float_of_int b) | VFloat a, VInt32 b -> fcmp a (Int32.to_float b) | VInt a, VFloat b -> fcmp (float_of_int a) b | VInt32 a, VFloat b -> fcmp (Int32.to_float a) b | VBool a, VBool b -> if a = b then CEq else if a then CSup else CInf | VString a, VString b -> scmp a b | VInt _ , VString s | VInt32 _, VString s | VFloat _ , VString s | VBool _ , VString s -> scmp (to_string ctx 0 a) s | VString s, VInt _ | VString s, VInt32 _ | VString s, VFloat _ | VString s, VBool _ -> scmp s (to_string ctx 0 b) | VObject oa, VObject ob -> if oa == ob then CEq else (match eval_oop ctx null_pos oa h_compare [b] with | Some (VInt i) -> if i = 0 then CEq else if i < 0 then CInf else CSup | _ -> CUndef) | VAbstract a, VAbstract b -> if a == b then CEq else CUndef | VArray a, VArray b -> if a == b then CEq else CUndef | VFunction a, VFunction b -> if a == b then CEq else CUndef | VClosure (la,fa), VClosure (lb,fb) -> if la == lb && fa == fb then CEq else CUndef | _ -> CUndef let select ctx = get_ctx_ref := (fun() -> ctx) let load_prim ctx f n = match f, n with | VString f, VInt n -> let lib, fname = (try ExtString.String.split f "@" with _ -> "", f) in (try let f = (match lib with | "std" -> Hashtbl.find std_lib fname | "macro" -> Hashtbl.find macro_lib fname | "regexp" -> Hashtbl.find reg_lib fname | "zlib" -> Hashtbl.find z_lib fname | _ -> failwith ("You cannot use the library '" ^ lib ^ "' inside a macro"); ) in if nargs f <> n then raise Not_found; VFunction f with Not_found -> VFunction (FunVar (fun _ -> exc (VString ("Primitive not found " ^ f ^ ":" ^ string_of_int n))))) | _ -> exc (VString "Invalid call") let create com api = let loader = obj hash [ "args",VArray (Array.of_list (List.map (fun s -> VString s) com.sys_args)); "loadprim",VFunction (Fun2 (fun a b -> (get_ctx()).do_loadprim a b)); "loadmodule",VFunction (Fun2 (fun a b -> assert false)); ] in let ctx = { gen = Genneko.new_context com 2 true; types = Hashtbl.create 0; error = false; error_proto = { ofields = [||]; oproto = None }; prototypes = Hashtbl.create 0; enums = [||]; (* eval *) locals_map = PMap.empty; locals_count = 0; locals_barrier = 0; locals_env = DynArray.create(); globals = PMap.empty; (* runtime *) callstack = []; callsize = 0; stack = DynArray.create(); exc = []; vthis = VNull; venv = [||]; fields_cache = Hashtbl.copy constants; (* api *) do_call = Obj.magic(); do_string = Obj.magic(); do_loadprim = Obj.magic(); do_compare = Obj.magic(); (* context *) curapi = api; loader = VObject loader; on_reused = []; is_reused = true; exports = VObject { ofields = [||]; oproto = None }; } in ctx.do_call <- call ctx; ctx.do_string <- to_string ctx 0; ctx.do_loadprim <- load_prim ctx; ctx.do_compare <- compare ctx; select ctx; List.iter (fun e -> ignore((eval ctx e)())) (Genneko.header()); ctx let do_reuse ctx api = ctx.is_reused <- false; ctx.curapi <- api let can_reuse ctx types = let has_old_version t = let inf = Type.t_infos t in try Hashtbl.find ctx.types inf.mt_path <> inf.mt_module.m_id with Not_found -> false in if List.exists has_old_version types then false else if ctx.is_reused then true else if not (List.for_all (fun f -> f()) ctx.on_reused) then false else begin ctx.is_reused <- true; true; end let add_types ctx types ready = let types = List.filter (fun t -> let path = Type.t_path t in if Hashtbl.mem ctx.types path then false else begin Hashtbl.add ctx.types path (Type.t_infos t).mt_module.m_id; true; end ) types in List.iter ready types; let e = (EBlock (Genneko.build ctx.gen types), null_pos) in ignore(catch_errors ctx (fun() -> ignore((eval ctx e)()))) let eval_expr ctx e = let e = Genneko.gen_expr ctx.gen e in catch_errors ctx (fun() -> (eval ctx e)()) let get_path ctx path p = let rec loop = function | [] -> assert false | [x] -> (EConst (Ident x),p) | x :: l -> (EField (loop l,x),p) in (eval ctx (loop (List.rev path)))() let set_error ctx e = ctx.error <- e let call_path ctx path f vl api = if ctx.error then None else let old = ctx.curapi in ctx.curapi <- api; let p = Genneko.pos ctx.gen api.pos in catch_errors ctx ~final:(fun() -> ctx.curapi <- old) (fun() -> match get_path ctx path p with | VObject o -> let f = get_field o (hash f) in call ctx (VObject o) f vl p | _ -> assert false ) (* ---------------------------------------------------------------------- *) (* EXPR ENCODING *) type enum_index = | IExpr | IBinop | IUnop | IConst | ITParam | ICType | IField | IType | IFieldKind | IMethodKind | IVarAccess | IAccess | IClassKind | ITypedExpr | ITConstant | IModuleType | IFieldAccess | IAnonStatus let enum_name = function | IExpr -> "ExprDef" | IBinop -> "Binop" | IUnop -> "Unop" | IConst -> "Constant" | ITParam -> "TypeParam" | ICType -> "ComplexType" | IField -> "FieldType" | IType -> "Type" | IFieldKind -> "FieldKind" | IMethodKind -> "MethodKind" | IVarAccess -> "VarAccess" | IAccess -> "Access" | IClassKind -> "ClassKind" | ITypedExpr -> "TypedExprDef" | ITConstant -> "TConstant" | IModuleType -> "ModuleType" | IFieldAccess -> "FieldAccess" | IAnonStatus -> "AnonStatus" let init ctx = let enums = [IExpr;IBinop;IUnop;IConst;ITParam;ICType;IField;IType;IFieldKind;IMethodKind;IVarAccess;IAccess;IClassKind;ITypedExpr;ITConstant;IModuleType;IFieldAccess;IAnonStatus] in let get_enum_proto e = match get_path ctx ["haxe";"macro";enum_name e] null_pos with | VObject e -> (match get_field e h_constructs with | VObject cst -> (match get_field cst h_a with | VArray a -> Array.map (fun s -> match s with | VObject s -> (match get_field s h_s with VString s -> get_field e (hash s),s | _ -> assert false) | _ -> assert false ) a | _ -> assert false) | _ -> assert false) | _ -> failwith ("haxe.macro." ^ enum_name e ^ " does not exists") in ctx.enums <- Array.of_list (List.map get_enum_proto enums); ctx.error_proto <- (match get_path ctx ["haxe";"macro";"Error";"prototype"] null_pos with VObject p -> p | _ -> failwith ("haxe.macro.Error does not exists")) open Ast let null f = function | None -> VNull | Some v -> f v let encode_pos p = VAbstract (APos p) let enc_inst path fields = let ctx = get_ctx() in let p = (try Hashtbl.find ctx.prototypes path with Not_found -> try (match get_path ctx (path@["prototype"]) Nast.null_pos with | VObject o -> Hashtbl.add ctx.prototypes path o; o | _ -> raise (Runtime VNull)) with Runtime _ -> failwith ("Prototype not found " ^ String.concat "." path) ) in let o = obj hash fields in o.oproto <- Some p; VObject o let enc_array l = let a = Array.of_list l in enc_inst ["Array"] [ "__a", VArray a; "length", VInt (Array.length a); ] let enc_string s = enc_inst ["String"] [ "__s", VString s; "length", VInt (String.length s) ] let enc_hash h = enc_inst ["haxe";"ds";"StringMap"] [ "h", VAbstract (AHash h); ] let enc_obj l = VObject (obj hash l) let enc_enum (i:enum_index) index pl = let eindex : int = Obj.magic i in let edef = (get_ctx()).enums.(eindex) in if pl = [] then fst edef.(index) else enc_inst ["haxe";"macro";enum_name i] [ "tag", VString (snd edef.(index)); "index", VInt index; "args", VArray (Array.of_list pl); ] let compiler_error msg pos = exc (enc_inst ["haxe";"macro";"Error"] [("message",enc_string msg);("pos",encode_pos pos)]) let encode_const c = let tag, pl = match c with | Int s -> 0, [enc_string s] | Float s -> 1, [enc_string s] | String s -> 2, [enc_string s] | Ident s -> 3, [enc_string s] | Regexp (s,opt) -> 4, [enc_string s;enc_string opt] in enc_enum IConst tag pl let rec encode_binop op = let tag, pl = match op with | OpAdd -> 0, [] | OpMult -> 1, [] | OpDiv -> 2, [] | OpSub -> 3, [] | OpAssign -> 4, [] | OpEq -> 5, [] | OpNotEq -> 6, [] | OpGt -> 7, [] | OpGte -> 8, [] | OpLt -> 9, [] | OpLte -> 10, [] | OpAnd -> 11, [] | OpOr -> 12, [] | OpXor -> 13, [] | OpBoolAnd -> 14, [] | OpBoolOr -> 15, [] | OpShl -> 16, [] | OpShr -> 17, [] | OpUShr -> 18, [] | OpMod -> 19, [] | OpAssignOp op -> 20, [encode_binop op] | OpInterval -> 21, [] | OpArrow -> 22, [] in enc_enum IBinop tag pl let encode_unop op = let tag = match op with | Increment -> 0 | Decrement -> 1 | Not -> 2 | Neg -> 3 | NegBits -> 4 in enc_enum IUnop tag [] let rec encode_path t = let fields = [ "pack", enc_array (List.map enc_string t.tpackage); "name", enc_string t.tname; "params", enc_array (List.map encode_tparam t.tparams); ] in enc_obj (match t.tsub with | None -> fields | Some s -> ("sub", enc_string s) :: fields) and encode_tparam = function | TPType t -> enc_enum ITParam 0 [encode_ctype t] | TPExpr e -> enc_enum ITParam 1 [encode_expr e] and encode_access a = let tag = match a with | APublic -> 0 | APrivate -> 1 | AStatic -> 2 | AOverride -> 3 | ADynamic -> 4 | AInline -> 5 | AMacro -> 6 in enc_enum IAccess tag [] and encode_meta_entry (m,ml,p) = enc_obj [ "name", enc_string (fst (MetaInfo.to_string m)); "params", enc_array (List.map encode_expr ml); "pos", encode_pos p; ] and encode_meta_content m = enc_array (List.map encode_meta_entry m) and encode_field (f:class_field) = let tag, pl = match f.cff_kind with | FVar (t,e) -> 0, [null encode_ctype t; null encode_expr e] | FFun f -> 1, [encode_fun f] | FProp (get,set, t, e) -> 2, [enc_string get; enc_string set; null encode_ctype t; null encode_expr e] in enc_obj [ "name",enc_string f.cff_name; "doc", null enc_string f.cff_doc; "pos", encode_pos f.cff_pos; "kind", enc_enum IField tag pl; "meta", encode_meta_content f.cff_meta; "access", enc_array (List.map encode_access f.cff_access); ] and encode_ctype t = let tag, pl = match t with | CTPath p -> 0, [encode_path p] | CTFunction (pl,r) -> 1, [enc_array (List.map encode_ctype pl);encode_ctype r] | CTAnonymous fl -> 2, [enc_array (List.map encode_field fl)] | CTParent t -> 3, [encode_ctype t] | CTExtend (tl,fields) -> 4, [enc_array (List.map encode_path tl); enc_array (List.map encode_field fields)] | CTOptional t -> 5, [encode_ctype t] in enc_enum ICType tag pl and encode_tparam_decl tp = enc_obj [ "name", enc_string tp.tp_name; "params", enc_array (List.map encode_tparam_decl tp.tp_params); "constraints", enc_array (List.map encode_ctype tp.tp_constraints); ] and encode_fun f = enc_obj [ "params", enc_array (List.map encode_tparam_decl f.f_params); "args", enc_array (List.map (fun (n,opt,t,e) -> enc_obj [ "name", enc_string n; "opt", VBool opt; "type", null encode_ctype t; "value", null encode_expr e; ] ) f.f_args); "ret", null encode_ctype f.f_type; "expr", null encode_expr f.f_expr ] and encode_expr e = let rec loop (e,p) = let tag, pl = match e with | EConst c -> 0, [encode_const c] | EArray (e1,e2) -> 1, [loop e1;loop e2] | EBinop (op,e1,e2) -> 2, [encode_binop op;loop e1;loop e2] | EField (e,f) -> 3, [loop e;enc_string f] | EParenthesis e -> 4, [loop e] | EObjectDecl fl -> 5, [enc_array (List.map (fun (f,e) -> enc_obj [ "field",enc_string f; "expr",loop e; ]) fl)] | EArrayDecl el -> 6, [enc_array (List.map loop el)] | ECall (e,el) -> 7, [loop e;enc_array (List.map loop el)] | ENew (p,el) -> 8, [encode_path p; enc_array (List.map loop el)] | EUnop (op,flag,e) -> 9, [encode_unop op; VBool (match flag with Prefix -> false | Postfix -> true); loop e] | EVars vl -> 10, [enc_array (List.map (fun (v,t,eo) -> enc_obj [ "name",enc_string v; "type",null encode_ctype t; "expr",null loop eo; ] ) vl)] | EFunction (name,f) -> 11, [null enc_string name; encode_fun f] | EBlock el -> 12, [enc_array (List.map loop el)] | EFor (e,eloop) -> 13, [loop e;loop eloop] | EIn (e1,e2) -> 14, [loop e1;loop e2] | EIf (econd,e,eelse) -> 15, [loop econd;loop e;null loop eelse] | EWhile (econd,e,flag) -> 16, [loop econd;loop e;VBool (match flag with NormalWhile -> true | DoWhile -> false)] | ESwitch (e,cases,eopt) -> 17, [loop e;enc_array (List.map (fun (ecl,eg,e) -> enc_obj [ "values",enc_array (List.map loop ecl); "guard",null loop eg; "expr",null loop e ] ) cases);null encode_null_expr eopt] | ETry (e,catches) -> 18, [loop e;enc_array (List.map (fun (v,t,e) -> enc_obj [ "name",enc_string v; "type",encode_ctype t; "expr",loop e ] ) catches)] | EReturn eo -> 19, [null loop eo] | EBreak -> 20, [] | EContinue -> 21, [] | EUntyped e -> 22, [loop e] | EThrow e -> 23, [loop e] | ECast (e,t) -> 24, [loop e; null encode_ctype t] | EDisplay (e,flag) -> 25, [loop e; VBool flag] | EDisplayNew t -> 26, [encode_path t] | ETernary (econd,e1,e2) -> 27, [loop econd;loop e1;loop e2] | ECheckType (e,t) -> 28, [loop e; encode_ctype t] | EMeta (m,e) -> 29, [encode_meta_entry m;loop e] in enc_obj [ "pos", encode_pos p; "expr", enc_enum IExpr tag pl; ] in loop e and encode_null_expr e = match e with | None -> enc_obj ["pos", VNull;"expr",VNull] | Some e -> encode_expr e (* ---------------------------------------------------------------------- *) (* EXPR DECODING *) let opt f v = match v with | VNull -> None | _ -> Some (f v) let opt_list f v = match v with | VNull -> [] | _ -> f v let decode_pos = function | VAbstract (APos p) -> p | _ -> raise Invalid_expr let field v f = match v with | VObject o -> get_field o (hash f) | _ -> raise Invalid_expr let decode_enum v = match field v "index", field v "args" with | VInt i, VNull -> i, [] | VInt i, VArray a -> i, Array.to_list a | _ -> raise Invalid_expr let dec_bool = function | VBool b -> b | _ -> raise Invalid_expr let dec_string v = match field v "__s" with | VString s -> s | _ -> raise Invalid_expr let dec_array v = match field v "__a", field v "length" with | VArray a, VInt l -> Array.to_list (if Array.length a = l then a else Array.sub a 0 l) | _ -> raise Invalid_expr let decode_const c = match decode_enum c with | 0, [s] -> Int (dec_string s) | 1, [s] -> Float (dec_string s) | 2, [s] -> String (dec_string s) | 3, [s] -> Ident (dec_string s) | 4, [s;opt] -> Regexp (dec_string s, dec_string opt) | 5, [s] -> Ident (dec_string s) (** deprecated CType, keep until 3.0 release **) | _ -> raise Invalid_expr let rec decode_op op = match decode_enum op with | 0, [] -> OpAdd | 1, [] -> OpMult | 2, [] -> OpDiv | 3, [] -> OpSub | 4, [] -> OpAssign | 5, [] -> OpEq | 6, [] -> OpNotEq | 7, [] -> OpGt | 8, [] -> OpGte | 9, [] -> OpLt | 10, [] -> OpLte | 11, [] -> OpAnd | 12, [] -> OpOr | 13, [] -> OpXor | 14, [] -> OpBoolAnd | 15, [] -> OpBoolOr | 16, [] -> OpShl | 17, [] -> OpShr | 18, [] -> OpUShr | 19, [] -> OpMod | 20, [op] -> OpAssignOp (decode_op op) | 21, [] -> OpInterval | 22,[] -> OpArrow | _ -> raise Invalid_expr let decode_unop op = match decode_enum op with | 0, [] -> Increment | 1, [] -> Decrement | 2, [] -> Not | 3, [] -> Neg | 4, [] -> NegBits | _ -> raise Invalid_expr let decode_import_mode t = match decode_enum t with | 0, [] -> INormal | 1, [alias] -> IAsName (dec_string alias) | 2, [] -> IAll | _ -> raise Invalid_expr let decode_import t = (List.map (fun o -> ((dec_string (field o "name")), (decode_pos (field o "pos")))) (dec_array (field t "path")), decode_import_mode (field t "mode")) let rec decode_path t = { tpackage = List.map dec_string (dec_array (field t "pack")); tname = dec_string (field t "name"); tparams = (match field t "params" with VNull -> [] | a -> List.map decode_tparam (dec_array a)); tsub = opt dec_string (field t "sub"); } and decode_tparam v = match decode_enum v with | 0,[t] -> TPType (decode_ctype t) | 1,[e] -> TPExpr (decode_expr e) | _ -> raise Invalid_expr and decode_tparams = function | VNull -> [] | a -> List.map decode_tparam_decl (dec_array a) and decode_tparam_decl v = { tp_name = dec_string (field v "name"); tp_constraints = (match field v "constraints" with VNull -> [] | a -> List.map decode_ctype (dec_array a)); tp_params = decode_tparams (field v "params"); } and decode_fun v = { f_params = decode_tparams (field v "params"); f_args = List.map (fun o -> (dec_string (field o "name"),(match field o "opt" with VNull -> false | v -> dec_bool v),opt decode_ctype (field o "type"),opt decode_expr (field o "value")) ) (dec_array (field v "args")); f_type = opt decode_ctype (field v "ret"); f_expr = opt decode_expr (field v "expr"); } and decode_access v = match decode_enum v with | 0, [] -> APublic | 1, [] -> APrivate | 2, [] -> AStatic | 3, [] -> AOverride | 4, [] -> ADynamic | 5, [] -> AInline | 6, [] -> AMacro | _ -> raise Invalid_expr and decode_meta_entry v = MetaInfo.from_string (dec_string (field v "name")), (match field v "params" with VNull -> [] | a -> List.map decode_expr (dec_array a)), decode_pos (field v "pos") and decode_meta_content = function | VNull -> [] | v -> List.map decode_meta_entry (dec_array v) and decode_field v = let fkind = match decode_enum (field v "kind") with | 0, [t;e] -> FVar (opt decode_ctype t, opt decode_expr e) | 1, [f] -> FFun (decode_fun f) | 2, [get;set; t; e] -> FProp (dec_string get, dec_string set, opt decode_ctype t, opt decode_expr e) | _ -> raise Invalid_expr in { cff_name = dec_string (field v "name"); cff_doc = opt dec_string (field v "doc"); cff_pos = decode_pos (field v "pos"); cff_kind = fkind; cff_access = List.map decode_access (opt_list dec_array (field v "access")); cff_meta = opt_list decode_meta_content (field v "meta"); } and decode_ctype t = match decode_enum t with | 0, [p] -> CTPath (decode_path p) | 1, [a;r] -> CTFunction (List.map decode_ctype (dec_array a), decode_ctype r) | 2, [fl] -> CTAnonymous (List.map decode_field (dec_array fl)) | 3, [t] -> CTParent (decode_ctype t) | 4, [tl;fl] -> CTExtend (List.map decode_path (dec_array tl), List.map decode_field (dec_array fl)) | 5, [t] -> CTOptional (decode_ctype t) | _ -> raise Invalid_expr let rec decode_expr v = let rec loop v = (decode (field v "expr"), decode_pos (field v "pos")) and decode e = match decode_enum e with | 0, [c] -> EConst (decode_const c) | 1, [e1;e2] -> EArray (loop e1, loop e2) | 2, [op;e1;e2] -> EBinop (decode_op op, loop e1, loop e2) | 3, [e;f] -> EField (loop e, dec_string f) | 4, [e] -> EParenthesis (loop e) | 5, [a] -> EObjectDecl (List.map (fun o -> (dec_string (field o "field"), loop (field o "expr")) ) (dec_array a)) | 6, [a] -> EArrayDecl (List.map loop (dec_array a)) | 7, [e;el] -> ECall (loop e,List.map loop (dec_array el)) | 8, [t;el] -> ENew (decode_path t,List.map loop (dec_array el)) | 9, [op;VBool f;e] -> EUnop (decode_unop op,(if f then Postfix else Prefix),loop e) | 10, [vl] -> EVars (List.map (fun v -> (dec_string (field v "name"),opt decode_ctype (field v "type"),opt loop (field v "expr")) ) (dec_array vl)) | 11, [fname;f] -> EFunction (opt dec_string fname,decode_fun f) | 12, [el] -> EBlock (List.map loop (dec_array el)) | 13, [e1;e2] -> EFor (loop e1, loop e2) | 14, [e1;e2] -> EIn (loop e1, loop e2) | 15, [e1;e2;e3] -> EIf (loop e1, loop e2, opt loop e3) | 16, [e1;e2;VBool flag] -> EWhile (loop e1,loop e2,if flag then NormalWhile else DoWhile) | 17, [e;cases;eo] -> let cases = List.map (fun c -> (List.map loop (dec_array (field c "values")),opt loop (field c "guard"),opt loop (field c "expr")) ) (dec_array cases) in ESwitch (loop e,cases,opt decode_null_expr eo) | 18, [e;catches] -> let catches = List.map (fun c -> (dec_string (field c "name"),decode_ctype (field c "type"),loop (field c "expr")) ) (dec_array catches) in ETry (loop e, catches) | 19, [e] -> EReturn (opt loop e) | 20, [] -> EBreak | 21, [] -> EContinue | 22, [e] -> EUntyped (loop e) | 23, [e] -> EThrow (loop e) | 24, [e;t] -> ECast (loop e,opt decode_ctype t) | 25, [e;f] -> EDisplay (loop e,dec_bool f) | 26, [t] -> EDisplayNew (decode_path t) | 27, [e1;e2;e3] -> ETernary (loop e1,loop e2,loop e3) | 28, [e;t] -> ECheckType (loop e, decode_ctype t) | 29, [m;e] -> EMeta (decode_meta_entry m,loop e) | 30, [e;f] -> EField (loop e, dec_string f) (*** deprecated EType, keep until haxe 3 **) | _ -> raise Invalid_expr in try loop v with Stack_overflow -> raise Invalid_expr and decode_null_expr v = match field v "expr" with | VNull -> None | _ -> Some (decode_expr v) (* ---------------------------------------------------------------------- *) (* TYPE ENCODING *) let encode_ref v convert tostr = enc_obj [ "get", VFunction (Fun0 (fun() -> convert v)); "__string", VFunction (Fun0 (fun() -> VString (tostr()))); "toString", VFunction (Fun0 (fun() -> enc_string (tostr()))); "$", VAbstract (AUnsafe (Obj.repr v)); ] let decode_ref v : 'a = match field v "$" with | VAbstract (AUnsafe t) -> Obj.obj t | _ -> raise Invalid_expr let encode_pmap convert m = let h = Hashtbl.create 0 in PMap.iter (fun k v -> Hashtbl.add h (VString k) (convert v)) m; enc_hash h let encode_pmap_array convert m = let l = ref [] in PMap.iter (fun _ v -> l := !l @ [(convert v)]) m; enc_array !l let encode_array convert l = enc_array (List.map convert l) let encode_meta m set = let meta = ref m in enc_obj [ "get", VFunction (Fun0 (fun() -> encode_meta_content (!meta) )); "add", VFunction (Fun3 (fun k vl p -> (try let el = List.map decode_expr (dec_array vl) in meta := (MetaInfo.from_string (dec_string k), el, decode_pos p) :: !meta; set (!meta) with Invalid_expr -> failwith "Invalid expression"); VNull )); "extract", VFunction (Fun1 (fun k -> let k = MetaInfo.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in encode_array encode_meta_entry (List.filter (fun (m,_,_) -> m = k) (!meta)) )); "remove", VFunction (Fun1 (fun k -> let k = MetaInfo.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in meta := List.filter (fun (m,_,_) -> m <> k) (!meta); set (!meta); VNull )); "has", VFunction (Fun1 (fun k -> let k = MetaInfo.from_string (try dec_string k with Invalid_expr -> raise Builtin_error) in VBool (List.exists (fun (m,_,_) -> m = k) (!meta)); )); ] let rec encode_mtype t fields = let i = t_infos t in enc_obj ([ "__t", VAbstract (ATDecl t); "pack", enc_array (List.map enc_string (fst i.mt_path)); "name", enc_string (snd i.mt_path); "pos", encode_pos i.mt_pos; "module", enc_string (s_type_path i.mt_module.m_path); "isPrivate", VBool i.mt_private; "meta", encode_meta i.mt_meta (fun m -> i.mt_meta <- m); "doc", null enc_string i.mt_doc; "params", encode_type_params i.mt_params; ] @ fields) and encode_type_params tl = enc_array (List.map (fun (n,t) -> enc_obj ["name",enc_string n;"t",encode_type t]) tl) and encode_tenum e = encode_mtype (TEnumDecl e) [ "isExtern", VBool e.e_extern; "exclude", VFunction (Fun0 (fun() -> e.e_extern <- true; VNull)); "constructs", encode_pmap encode_efield e.e_constrs; "names", enc_array (List.map enc_string e.e_names); ] and encode_tabstract a = encode_mtype (TAbstractDecl a) [ "type", encode_type a.a_this; "impl", (match a.a_impl with None -> VNull | Some c -> encode_clref c); "binops", enc_array (List.map (fun (op,cf) -> enc_obj [ "op",encode_binop op; "field",encode_cfield cf]) a.a_ops); "unops", enc_array (List.map (fun (op,postfix,cf) -> enc_obj [ "op",encode_unop op; "isPostfix",VBool (match postfix with Postfix -> true | Prefix -> false); "field",encode_cfield cf]) a.a_unops); "from", enc_array ((List.map (fun t -> enc_obj [ "t",encode_type t; "field",VNull]) a.a_from) @ (List.map (fun (t,cf) -> enc_obj [ "t",encode_type t; "field",encode_cfield cf]) a.a_from_field)); "to", enc_array ((List.map (fun t -> enc_obj [ "t",encode_type t; "field",VNull]) a.a_to) @ (List.map (fun (t,cf) -> enc_obj [ "t",encode_type t; "field",encode_cfield cf]) a.a_to_field)); "array", enc_array (List.map encode_cfield a.a_array); ] and encode_efield f = enc_obj [ "name", enc_string f.ef_name; "type", encode_type f.ef_type; "pos", encode_pos f.ef_pos; "index", VInt f.ef_index; "meta", encode_meta f.ef_meta (fun m -> f.ef_meta <- m); "doc", null enc_string f.ef_doc; "params", encode_type_params f.ef_params; ] and encode_cfield f = enc_obj [ "name", enc_string f.cf_name; "type", (match f.cf_kind with Method _ -> encode_lazy_type f.cf_type | _ -> encode_type f.cf_type); "isPublic", VBool f.cf_public; "params", encode_type_params f.cf_params; "meta", encode_meta f.cf_meta (fun m -> f.cf_meta <- m); "expr", (VFunction (Fun0 (fun() -> ignore(follow f.cf_type); (match f.cf_expr with None -> VNull | Some e -> encode_texpr e)))); "kind", encode_field_kind f.cf_kind; "pos", encode_pos f.cf_pos; "doc", null enc_string f.cf_doc; ] and encode_field_kind k = let tag, pl = (match k with | Type.Var v -> 0, [encode_var_access v.v_read; encode_var_access v.v_write] | Method m -> 1, [encode_method_kind m] ) in enc_enum IFieldKind tag pl and encode_var_access a = let tag, pl = (match a with | AccNormal -> 0, [] | AccNo -> 1, [] | AccNever -> 2, [] | AccResolve -> 3, [] | AccCall -> 4, [] | AccInline -> 5, [] | AccRequire (s,msg) -> 6, [enc_string s; null enc_string msg] ) in enc_enum IVarAccess tag pl and encode_method_kind m = let tag, pl = (match m with | MethNormal -> 0, [] | MethInline -> 1, [] | MethDynamic -> 2, [] | MethMacro -> 3, [] ) in enc_enum IMethodKind tag pl and encode_class_kind k = let tag, pl = (match k with | KNormal -> 0, [] | KTypeParameter pl -> 1, [encode_tparams pl] | KExtension (cl, params) -> 2, [encode_clref cl; encode_tparams params] | KExpr e -> 3, [encode_expr e] | KGeneric -> 4, [] | KGenericInstance (cl, params) -> 5, [encode_clref cl; encode_tparams params] | KMacroType -> 6, [] | KAbstractImpl a -> 7, [encode_abref a] | KGenericBuild cfl -> 8, [] ) in enc_enum IClassKind tag pl and encode_tclass c = ignore(c.cl_build()); encode_mtype (TClassDecl c) [ "kind", encode_class_kind c.cl_kind; "isExtern", VBool c.cl_extern; "exclude", VFunction (Fun0 (fun() -> c.cl_extern <- true; c.cl_init <- None; VNull)); "isInterface", VBool c.cl_interface; "superClass", (match c.cl_super with | None -> VNull | Some (c,pl) -> enc_obj ["t",encode_clref c;"params",encode_tparams pl] ); "interfaces", enc_array (List.map (fun (c,pl) -> enc_obj ["t",encode_clref c;"params",encode_tparams pl]) c.cl_implements); "fields", encode_ref c.cl_ordered_fields (encode_array encode_cfield) (fun() -> "class fields"); "statics", encode_ref c.cl_ordered_statics (encode_array encode_cfield) (fun() -> "class fields"); "constructor", (match c.cl_constructor with None -> VNull | Some cf -> encode_cfref cf); "init", (match c.cl_init with None -> VNull | Some e -> encode_texpr e); "overrides", (enc_array (List.map encode_cfref c.cl_overrides)) ] and encode_ttype t = encode_mtype (TTypeDecl t) [ "isExtern", VBool false; "exclude", VFunction (Fun0 (fun() -> VNull)); "type", encode_type t.t_type; ] and encode_tanon a = enc_obj [ "fields", encode_pmap_array encode_cfield a.a_fields; "status", encode_anon_status !(a.a_status); ] and encode_anon_status s = let tag, pl = (match s with | Closed -> 0, [] | Opened -> 1, [] | Type.Const -> 2, [] | Extend tl -> 3, [encode_ref tl (fun tl -> enc_array (List.map encode_type tl)) (fun() -> "")] | Statics cl -> 4, [encode_clref cl] | EnumStatics en -> 5, [encode_enref en] | AbstractStatics ab -> 6, [encode_abref ab] ) in enc_enum IAnonStatus tag pl and encode_tparams pl = enc_array (List.map encode_type pl) and encode_clref c = encode_ref c encode_tclass (fun() -> s_type_path c.cl_path) and encode_enref en = encode_ref en encode_tenum (fun() -> s_type_path en.e_path) and encode_cfref cf = encode_ref cf encode_cfield (fun() -> cf.cf_name) and encode_abref ab = encode_ref ab encode_tabstract (fun() -> s_type_path ab.a_path) and encode_type t = let rec loop = function | TMono r -> (match !r with | None -> 0, [encode_ref r (fun r -> match !r with None -> VNull | Some t -> encode_type t) (fun() -> "")] | Some t -> loop t) | TEnum (e, pl) -> 1 , [encode_ref e encode_tenum (fun() -> s_type_path e.e_path); encode_tparams pl] | TInst (c, pl) -> 2 , [encode_clref c; encode_tparams pl] | TType (t,pl) -> 3 , [encode_ref t encode_ttype (fun() -> s_type_path t.t_path); encode_tparams pl] | TFun (pl,ret) -> let pl = List.map (fun (n,o,t) -> enc_obj [ "name",enc_string n; "opt",VBool o; "t",encode_type t ] ) pl in 4 , [enc_array pl; encode_type ret] | TAnon a -> 5, [encode_ref a encode_tanon (fun() -> "")] | TDynamic tsub as t -> if t == t_dynamic then 6, [VNull] else 6, [encode_type tsub] | TLazy f -> loop (!f()) | TAbstract (a, pl) -> 8, [encode_abref a; encode_tparams pl] in let tag, pl = loop t in enc_enum IType tag pl and encode_lazy_type t = let rec loop = function | TMono r -> (match !r with | Some t -> loop t | _ -> encode_type t) | TLazy f -> enc_enum IType 7 [VAbstract (ALazyType f)] | _ -> encode_type t in loop t and decode_type t = match decode_enum t with | 0, [r] -> TMono (decode_ref r) | 1, [e; pl] -> TEnum (decode_ref e, List.map decode_type (dec_array pl)) | 2, [c; pl] -> TInst (decode_ref c, List.map decode_type (dec_array pl)) | 3, [t; pl] -> TType (decode_ref t, List.map decode_type (dec_array pl)) | 4, [pl; r] -> TFun (List.map (fun p -> dec_string (field p "name"), dec_bool (field p "opt"), decode_type (field p "t")) (dec_array pl), decode_type r) | 5, [a] -> TAnon (decode_ref a) | 6, [VNull] -> t_dynamic | 6, [t] -> TDynamic (decode_type t) | 7, [VAbstract (ALazyType f)] -> TLazy f | 8, [a; pl] -> TAbstract (decode_ref a, List.map decode_type (dec_array pl)) | _ -> raise Invalid_expr let decode_tdecl v = match v with | VObject o -> (match get_field o (hash "__t") with | VAbstract (ATDecl t) -> t | _ -> raise Invalid_expr) | _ -> raise Invalid_expr (* ---------------------------------------------------------------------- *) (* TEXPR Encoding *) let vopt f v = match v with | None -> VNull | Some v -> f v let rec encode_tconst c = let tag, pl = match c with | TInt i -> 0,[best_int i] | TFloat f -> 1,[enc_string f] | TString s -> 2,[enc_string s] | TBool b -> 3,[VBool b] | TNull -> 4,[] | TThis -> 5,[] | TSuper -> 6,[] in enc_enum ITConstant tag pl and encode_tvar v = let f_extra (pl,e) = enc_obj [ "params",encode_type_params pl; "expr",vopt encode_texpr e ] in enc_obj [ "id", VInt v.v_id; "name", enc_string v.v_name; "t", encode_type v.v_type; "capture", VBool v.v_capture; "extra", vopt f_extra v.v_extra; "meta", encode_meta_content v.v_meta; "$", VAbstract (AUnsafe (Obj.repr v)); ] and encode_module_type mt = let tag,pl = match mt with | TClassDecl c -> 0,[encode_clref c] | TEnumDecl e -> 1,[encode_enref e] | TTypeDecl t -> 2,[encode_ref t encode_ttype (fun () -> s_type_path t.t_path)] | TAbstractDecl a -> 3,[encode_abref a] in enc_enum IModuleType tag pl and encode_tfunc func = enc_obj [ "args",enc_array (List.map (fun (v,c) -> enc_obj [ "v",encode_tvar v; "value",match c with None -> VNull | Some c -> encode_tconst c ] ) func.tf_args); "t",encode_type func.tf_type; "expr",encode_texpr func.tf_expr ] and encode_field_access fa = let encode_instance c tl = enc_obj [ "c",encode_clref c; "params",encode_tparams tl ] in let tag,pl = match fa with | FInstance(c,tl,cf) -> 0,[encode_clref c;encode_tparams tl;encode_cfref cf] | FStatic(c,cf) -> 1,[encode_clref c;encode_cfref cf] | FAnon(cf) -> 2,[encode_cfref cf] | FDynamic(s) -> 3,[enc_string s] | FClosure(co,cf) -> 4,[(match co with Some (c,tl) -> encode_instance c tl | None -> VNull);encode_cfref cf] | FEnum(en,ef) -> 5,[encode_enref en;encode_efield ef] in enc_enum IFieldAccess tag pl and encode_texpr e = let rec loop e = let tag, pl = match e.eexpr with | TConst c -> 0,[encode_tconst c] | TLocal v -> 1,[encode_tvar v] | TArray(e1,e2) -> 2,[loop e1; loop e2] | TBinop(op,e1,e2) -> 3,[encode_binop op;loop e1;loop e2] | TField(e1,fa) -> 4,[loop e1;encode_field_access fa] | TTypeExpr mt -> 5,[encode_module_type mt] | TParenthesis e1 -> 6,[loop e1] | TObjectDecl fl -> 7, [enc_array (List.map (fun (f,e) -> enc_obj [ "name",enc_string f; "expr",loop e; ]) fl)] | TArrayDecl el -> 8,[encode_texpr_list el] | TCall(e1,el) -> 9,[loop e1;encode_texpr_list el] | TNew(c,pl,el) -> 10,[encode_clref c;encode_tparams pl;encode_texpr_list el] | TUnop(op,flag,e1) -> 11,[encode_unop op;VBool (flag = Postfix);loop e1] | TFunction func -> 12,[encode_tfunc func] | TVar (v,eo) -> 13,[encode_tvar v;vopt encode_texpr eo] | TBlock el -> 14,[encode_texpr_list el] | TFor(v,e1,e2) -> 15,[encode_tvar v;loop e1;loop e2] | TIf(eif,ethen,eelse) -> 16,[loop eif;loop ethen;vopt encode_texpr eelse] | TWhile(econd,e1,flag) -> 17,[loop econd;loop e1;VBool (flag = NormalWhile)] | TSwitch(e1,cases,edef) -> 18,[ loop e1; enc_array (List.map (fun (el,e) -> enc_obj ["values",encode_texpr_list el;"expr",loop e]) cases); vopt encode_texpr edef ] | TTry(e1,catches) -> 19,[ loop e1; enc_array (List.map (fun (v,e) -> enc_obj [ "v",encode_tvar v; "expr",loop e ]) catches )] | TReturn e1 -> 20,[vopt encode_texpr e1] | TBreak -> 21,[] | TContinue -> 22,[] | TThrow e1 -> 23,[loop e1] | TCast(e1,mt) -> 24,[loop e1;match mt with None -> VNull | Some mt -> encode_module_type mt] | TMeta(m,e1) -> 25,[encode_meta_entry m;loop e1] | TEnumParameter(e1,ef,i) -> 26,[loop e1;encode_efield ef;VInt i] in enc_obj [ "pos", encode_pos e.epos; "expr", enc_enum ITypedExpr tag pl; "t", encode_type e.etype ] in loop e and encode_texpr_list el = enc_array (List.map encode_texpr el) (* ---------------------------------------------------------------------- *) (* TEXPR Decoding *) let decode_tconst c = match decode_enum c with | 0, [s] -> TInt (match s with VInt i -> Int32.of_int i | VInt32 i -> i | _ -> raise Invalid_expr) | 1, [s] -> TFloat (dec_string s) | 2, [s] -> TString (dec_string s) | 3, [s] -> TBool (dec_bool s) | 4, [] -> TNull | 5, [] -> TThis | 6, [] -> TSuper | _ -> raise Invalid_expr let decode_type_params v = List.map (fun v -> dec_string (field v "name"),decode_type (field v "t")) (dec_array v) let decode_tvar v = match field v "$" with | VAbstract (AUnsafe t) -> Obj.obj t | _ -> raise Invalid_expr let decode_var_access v = match decode_enum v with | 0, [] -> AccNormal | 1, [] -> AccNo | 2, [] -> AccNever | 3, [] -> AccResolve | 4, [] -> AccCall | 5, [] -> AccInline | 6, [s1;s2] -> AccRequire(dec_string s1, opt dec_string s2) | _ -> raise Invalid_expr let decode_method_kind v = match decode_enum v with | 0, [] -> MethNormal | 1, [] -> MethInline | 2, [] -> MethDynamic | 3, [] -> MethMacro | _ -> raise Invalid_expr let decode_field_kind v = match decode_enum v with | 0, [vr;vw] -> Type.Var({v_read = decode_var_access vr; v_write = decode_var_access vw}) | 1, [m] -> Method (decode_method_kind m) | _ -> raise Invalid_expr let decode_cfield v = { cf_name = dec_string (field v "name"); cf_type = decode_type (field v "type"); cf_public = dec_bool (field v "isPublic"); cf_pos = decode_pos (field v "pos"); cf_doc = opt dec_string (field v "doc"); cf_meta = []; (* TODO *) cf_kind = decode_field_kind (field v "kind"); cf_params = decode_type_params (field v "params"); cf_expr = None; cf_overloads = []; } let decode_efield v = { ef_name = dec_string (field v "name"); ef_type = decode_type (field v "type"); ef_pos = decode_pos (field v "pos"); ef_index = (match field v "index" with VInt i -> i | _ -> raise Invalid_expr); ef_meta = []; (* TODO *) ef_doc = opt dec_string (field v "doc"); ef_params = decode_type_params (field v "params") } let decode_field_access v = match decode_enum v with | 0, [c;tl;cf] -> let c = decode_ref c in FInstance(c,List.map decode_type (dec_array tl),decode_ref cf) | 1, [c;cf] -> FStatic(decode_ref c,decode_ref cf) | 2, [cf] -> FAnon(decode_ref cf) | 3, [s] -> FDynamic(dec_string s) | 4, [co;cf] -> let co = match co with | VNull -> None | _ -> Some (decode_ref (field co "c"),List.map decode_type (dec_array (field co "params"))) in FClosure(co,decode_ref cf) | 5, [e;ef] -> FEnum(decode_ref e,decode_efield ef) | _ -> raise Invalid_expr let decode_module_type v = match decode_enum v with | 0, [c] -> TClassDecl (decode_ref c) | 1, [en] -> TEnumDecl (decode_ref en) | 2, [t] -> TTypeDecl (decode_ref t) | 3, [a] -> TAbstractDecl (decode_ref a) | _ -> raise Invalid_expr let decode_tfunc v = { tf_args = List.map (fun v -> decode_tvar (field v "v"),opt decode_tconst (field v "value")) (dec_array (field v "args")); tf_type = decode_type (field v "t"); tf_expr = decode_texpr (field v "expr") } let rec decode_texpr v = let rec loop v = mk (decode (field v "expr")) (decode_type (field v "t")) (decode_pos (field v "pos")) and decode e = match decode_enum e with | 0, [c] -> TConst(decode_tconst c) | 1, [v] -> TLocal(decode_tvar v) | 2, [v1;v2] -> TArray(loop v1,loop v2) | 3, [op;v1;v2] -> TBinop(decode_op op,loop v1,loop v2) | 4, [v1;fa] -> TField(loop v1,decode_field_access fa) | 5, [mt] -> TTypeExpr(decode_module_type mt) | 6, [v1] -> TParenthesis(loop v1) | 7, [v] -> TObjectDecl(List.map (fun v -> dec_string (field v "name"),loop (field v "expr")) (dec_array v)) | 8, [vl] -> TArrayDecl(List.map loop (dec_array vl)) | 9, [v1;vl] -> TCall(loop v1,List.map loop (dec_array vl)) | 10, [c;tl;vl] -> TNew(decode_ref c,List.map decode_type (dec_array tl),List.map loop (dec_array vl)) | 11, [op;pf;v1] -> TUnop(decode_unop op,(if dec_bool pf then Postfix else Prefix),loop v1) | 12, [f] -> TFunction(decode_tfunc f) | 13, [v;eo] -> TVar(decode_tvar v,opt loop eo) | 14, [vl] -> TBlock(List.map loop (dec_array vl)) | 15, [v;v1;v2] -> TFor(decode_tvar v,loop v1,loop v2) | 16, [vif;vthen;velse] -> TIf(loop vif,loop vthen,opt loop velse) | 17, [vcond;v1;b] -> TWhile(loop vcond,loop v1,if dec_bool b then NormalWhile else DoWhile) | 18, [v1;cl;vdef] -> TSwitch(loop v1,List.map (fun v -> List.map loop (dec_array (field v "values")),loop (field v "expr")) (dec_array cl),opt loop vdef) | 19, [v1;cl] -> TTry(loop v1,List.map (fun v -> decode_tvar (field v "v"),loop (field v "expr")) (dec_array cl)) | 20, [vo] -> TReturn(opt loop vo) | 21, [] -> TBreak | 22, [] -> TContinue | 23, [v1] -> TThrow(loop v1) | 24, [v1;mto] -> TCast(loop v1,opt decode_module_type mto) | 25, [m;v1] -> TMeta(decode_meta_entry m,loop v1) | 26, [v1;ef;i] -> TEnumParameter(loop v1,decode_efield ef,match i with VInt i -> i | _ -> raise Invalid_expr) | i,el -> Printf.printf "%i %i\n" i (List.length el); raise Invalid_expr in try loop v with Stack_overflow -> raise Invalid_expr (* ---------------------------------------------------------------------- *) (* TYPE DEFINITION *) let decode_type_def v = let pack = List.map dec_string (dec_array (field v "pack")) in let name = dec_string (field v "name") in let meta = decode_meta_content (field v "meta") in let pos = decode_pos (field v "pos") in let isExtern = (match field v "isExtern" with VNull -> false | v -> dec_bool v) in let fields = List.map decode_field (dec_array (field v "fields")) in let mk fl dl = { d_name = name; d_doc = None; d_params = decode_tparams (field v "params"); d_meta = meta; d_flags = fl; d_data = dl; } in let tdef = (match decode_enum (field v "kind") with | 0, [] -> let conv f = let loop (n,opt,t,_) = match t with | None -> raise Invalid_expr | Some t -> n, opt, t in let args, params, t = (match f.cff_kind with | FVar (t,None) -> [], [], t | FFun f -> List.map loop f.f_args, f.f_params, f.f_type | _ -> raise Invalid_expr ) in { ec_name = f.cff_name; ec_doc = f.cff_doc; ec_meta = f.cff_meta; ec_pos = f.cff_pos; ec_args = args; ec_params = params; ec_type = t; } in EEnum (mk (if isExtern then [EExtern] else []) (List.map conv fields)) | 1, [] -> ETypedef (mk (if isExtern then [EExtern] else []) (CTAnonymous fields)) | 2, [ext;impl;interf] -> let flags = if isExtern then [HExtern] else [] in let flags = (match interf with VNull | VBool false -> flags | VBool true -> HInterface :: flags | _ -> raise Invalid_expr) in let flags = (match opt decode_path ext with None -> flags | Some t -> HExtends t :: flags) in let flags = (match opt (fun v -> List.map decode_path (dec_array v)) impl with None -> flags | Some l -> List.map (fun t -> HImplements t) l @ flags) in EClass (mk flags fields) | 3, [t] -> ETypedef (mk (if isExtern then [EExtern] else []) (decode_ctype t)) | 4, [tthis;tfrom;tto] -> let flags = match opt dec_array tfrom with None -> [] | Some ta -> List.map (fun t -> AFromType (decode_ctype t)) ta in let flags = match opt dec_array tto with None -> flags | Some ta -> (List.map (fun t -> AToType (decode_ctype t)) ta) @ flags in let flags = match opt decode_ctype tthis with None -> flags | Some t -> (AIsType t) :: flags in EAbstract(mk flags fields) | _ -> raise Invalid_expr ) in (* if our package ends with an uppercase letter, then it's the module name *) let pack,name = (match List.rev pack with | last :: l when not (is_lower_ident last) -> List.rev l, last | _ -> pack, name ) in (pack, name), tdef, pos (* ---------------------------------------------------------------------- *) (* VALUE-TO-CONSTANT *) let rec make_const e = match e.eexpr with | TConst c -> (match c with | TInt i -> best_int i | TFloat s -> VFloat (float_of_string s) | TString s -> enc_string s | TBool b -> VBool b | TNull -> VNull | TThis | TSuper -> raise Exit) | TParenthesis e | TMeta(_,e) -> make_const e | TObjectDecl el -> VObject (obj (hash_field (get_ctx())) (List.map (fun (f,e) -> f, make_const e) el)) | TArrayDecl al -> enc_array (List.map make_const al) | _ -> raise Exit (* ---------------------------------------------------------------------- *) (* TEXPR-TO-AST-EXPR *) open Ast let tpath p mp pl = if snd mp = snd p then CTPath { tpackage = fst p; tname = snd p; tparams = List.map (fun t -> TPType t) pl; tsub = None; } else CTPath { tpackage = fst mp; tname = snd mp; tparams = List.map (fun t -> TPType t) pl; tsub = Some (snd p); } let rec make_type = function | TMono r -> (match !r with | None -> raise Exit | Some t -> make_type t) | TEnum (e,pl) -> tpath e.e_path e.e_module.m_path (List.map make_type pl) | TInst({cl_kind = KTypeParameter _} as c,pl) -> tpath ([],snd c.cl_path) ([],snd c.cl_path) (List.map make_type pl) | TInst (c,pl) -> tpath c.cl_path c.cl_module.m_path (List.map make_type pl) | TType (t,pl) as tf -> (* recurse on type-type *) if (snd t.t_path).[0] = '#' then make_type (follow tf) else tpath t.t_path t.t_module.m_path (List.map make_type pl) | TAbstract (a,pl) -> tpath a.a_path a.a_module.m_path (List.map make_type pl) | TFun (args,ret) -> CTFunction (List.map (fun (_,_,t) -> make_type t) args, make_type ret) | TAnon a -> begin match !(a.a_status) with | Statics c -> tpath ([],"Class") ([],"Class") [tpath c.cl_path c.cl_path []] | EnumStatics e -> tpath ([],"Enum") ([],"Enum") [tpath e.e_path e.e_path []] | _ -> CTAnonymous (PMap.foldi (fun _ f acc -> { cff_name = f.cf_name; cff_kind = FVar (mk_ot f.cf_type,None); cff_pos = f.cf_pos; cff_doc = f.cf_doc; cff_meta = f.cf_meta; cff_access = []; } :: acc ) a.a_fields []) end | (TDynamic t2) as t -> tpath ([],"Dynamic") ([],"Dynamic") (if t == t_dynamic then [] else [make_type t2]) | TLazy f -> make_type ((!f)()) and mk_ot t = match follow t with | TMono _ -> None | _ -> (try Some (make_type t) with Exit -> None) let rec make_ast e = let full_type_path t = let mp,p = match t with | TClassDecl c -> c.cl_module.m_path,c.cl_path | TEnumDecl en -> en.e_module.m_path,en.e_path | TAbstractDecl a -> a.a_module.m_path,a.a_path | TTypeDecl t -> t.t_module.m_path,t.t_path in if snd mp = snd p then p else (fst mp) @ [snd mp],snd p in let mk_path (pack,name) p = match List.rev pack with | [] -> (EConst (Ident name),p) | pl -> let rec loop = function | [] -> assert false | [n] -> (EConst (Ident n),p) | n :: l -> (EField (loop l, n),p) in (EField (loop pl,name),p) in let mk_const = function | TInt i -> Int (Int32.to_string i) | TFloat s -> Float s | TString s -> String s | TBool b -> Ident (if b then "true" else "false") | TNull -> Ident "null" | TThis -> Ident "this" | TSuper -> Ident "super" in let mk_ident = function | "`trace" -> Ident "trace" | n -> Ident n in let eopt = function None -> None | Some e -> Some (make_ast e) in ((match e.eexpr with | TConst c -> EConst (mk_const c) | TLocal v -> EConst (mk_ident v.v_name) | TArray (e1,e2) -> EArray (make_ast e1,make_ast e2) | TBinop (op,e1,e2) -> EBinop (op, make_ast e1, make_ast e2) | TField (e,f) -> EField (make_ast e, Type.field_name f) | TTypeExpr t -> fst (mk_path (full_type_path t) e.epos) | TParenthesis e -> EParenthesis (make_ast e) | TObjectDecl fl -> EObjectDecl (List.map (fun (f,e) -> f, make_ast e) fl) | TArrayDecl el -> EArrayDecl (List.map make_ast el) | TCall (e,el) -> ECall (make_ast e,List.map make_ast el) | TNew (c,pl,el) -> ENew ((match (try make_type (TInst (c,pl)) with Exit -> make_type (TInst (c,[]))) with CTPath p -> p | _ -> assert false),List.map make_ast el) | TUnop (op,p,e) -> EUnop (op,p,make_ast e) | TFunction f -> let arg (v,c) = v.v_name, false, mk_ot v.v_type, (match c with None -> None | Some c -> Some (EConst (mk_const c),e.epos)) in EFunction (None,{ f_params = []; f_args = List.map arg f.tf_args; f_type = mk_ot f.tf_type; f_expr = Some (make_ast f.tf_expr) }) | TVar (v,eo) -> EVars ([v.v_name, mk_ot v.v_type, eopt eo]) | TBlock el -> EBlock (List.map make_ast el) | TFor (v,it,e) -> let ein = (EIn ((EConst (Ident v.v_name),it.epos),make_ast it),it.epos) in EFor (ein,make_ast e) | TIf (e,e1,e2) -> EIf (make_ast e,make_ast e1,eopt e2) | TWhile (e1,e2,flag) -> EWhile (make_ast e1, make_ast e2, flag) | TSwitch (e,cases,def) -> let cases = List.map (fun (vl,e) -> List.map make_ast vl,None,(match e.eexpr with TBlock [] -> None | _ -> Some (make_ast e)) ) cases in let def = match eopt def with None -> None | Some (EBlock [],_) -> Some None | e -> Some e in ESwitch (make_ast e,cases,def) | TEnumParameter _ -> (* these are considered complex, so the AST is handled in TMeta(Meta.Ast) *) assert false | TTry (e,catches) -> ETry (make_ast e,List.map (fun (v,e) -> v.v_name, (try make_type v.v_type with Exit -> assert false), make_ast e) catches) | TReturn e -> EReturn (eopt e) | TBreak -> EBreak | TContinue -> EContinue | TThrow e -> EThrow (make_ast e) | TCast (e,t) -> let t = (match t with | None -> None | Some t -> let t = (match t with TClassDecl c -> TInst (c,[]) | TEnumDecl e -> TEnum (e,[]) | TTypeDecl t -> TType (t,[]) | TAbstractDecl a -> TAbstract (a,[])) in Some (try make_type t with Exit -> assert false) ) in ECast (make_ast e,t) | TMeta ((Meta.Ast,[e1,_],_),_) -> e1 | TMeta (m,e) -> EMeta(m,make_ast e)) ,e.epos) ;; make_ast_ref := make_ast; make_complex_type_ref := make_type; encode_complex_type_ref := encode_ctype; enc_array_ref := enc_array; dec_array_ref := dec_array; encode_type_ref := encode_type; decode_type_ref := decode_type; encode_expr_ref := encode_expr; decode_expr_ref := decode_expr; encode_clref_ref := encode_clref; enc_string_ref := enc_string; enc_hash_ref := enc_hash; encode_texpr_ref := encode_texpr; decode_texpr_ref := decode_texpr; encode_tvar_ref := encode_tvar; decode_path_ref := decode_path; decode_import_ref := decode_import; haxe_3.2.1+dfsg.orig/lexer.mll0000664000175000017500000003163712607337712016163 0ustar andyandy00000000000000(* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) { open Lexing open Ast type error_msg = | Invalid_character of char | Unterminated_string | Unterminated_regexp | Unclosed_comment | Unclosed_code | Invalid_escape | Invalid_option exception Error of error_msg * pos let error_msg = function | Invalid_character c when int_of_char c > 32 && int_of_char c < 128 -> Printf.sprintf "Invalid character '%c'" c | Invalid_character c -> Printf.sprintf "Invalid character 0x%.2X" (int_of_char c) | Unterminated_string -> "Unterminated string" | Unterminated_regexp -> "Unterminated regular expression" | Unclosed_comment -> "Unclosed comment" | Unclosed_code -> "Unclosed code string" | Invalid_escape -> "Invalid escape sequence" | Invalid_option -> "Invalid regular expression option" type lexer_file = { lfile : string; mutable lline : int; mutable lmaxline : int; mutable llines : (int * int) list; mutable lalines : (int * int) array; mutable lstrings : int list; } let make_file file = { lfile = file; lline = 1; lmaxline = 1; llines = [0,1]; lalines = [|0,1|]; lstrings = []; } let cur = ref (make_file "") let all_files = Hashtbl.create 0 let buf = Buffer.create 100 let error e pos = raise (Error (e,{ pmin = pos; pmax = pos; pfile = !cur.lfile })) let keywords = let h = Hashtbl.create 3 in List.iter (fun k -> Hashtbl.add h (s_keyword k) k) [Function;Class;Static;Var;If;Else;While;Do;For; Break;Return;Continue;Extends;Implements;Import; Switch;Case;Default;Public;Private;Try;Untyped; Catch;New;This;Throw;Extern;Enum;In;Interface; Cast;Override;Dynamic;Typedef;Package; Inline;Using;Null;True;False;Abstract;Macro]; h let init file do_add = let f = make_file file in cur := f; if do_add then Hashtbl.replace all_files file f let save() = !cur let restore c = cur := c let newline lexbuf = let cur = !cur in cur.lline <- cur.lline + 1; cur.llines <- (lexeme_end lexbuf,cur.lline) :: cur.llines let fmt_pos p = p.pmin + (p.pmax - p.pmin) * 1000000 let add_fmt_string p = let file = (try Hashtbl.find all_files p.pfile with Not_found -> let f = make_file p.pfile in Hashtbl.replace all_files p.pfile f; f ) in file.lstrings <- (fmt_pos p) :: file.lstrings let fast_add_fmt_string p = let cur = !cur in cur.lstrings <- (fmt_pos p) :: cur.lstrings let is_fmt_string p = try let file = Hashtbl.find all_files p.pfile in List.mem (fmt_pos p) file.lstrings with Not_found -> false let remove_fmt_string p = try let file = Hashtbl.find all_files p.pfile in file.lstrings <- List.filter ((<>) (fmt_pos p)) file.lstrings with Not_found -> () let find_line p f = (* rebuild cache if we have a new line *) if f.lmaxline <> f.lline then begin f.lmaxline <- f.lline; f.lalines <- Array.of_list (List.rev f.llines); end; let rec loop min max = let med = (min + max) lsr 1 in let lp, line = Array.unsafe_get f.lalines med in if med = min then line, p - lp else if lp > p then loop min med else loop med max in loop 0 (Array.length f.lalines) (* resolve a position within a non-haxe file by counting newlines *) let resolve_pos file = let ch = open_in_bin file in let f = make_file file in let rec loop p = let inc i () = f.lline <- f.lline + 1; f.llines <- (p + i,f.lline) :: f.llines; i in let i = match input_char ch with | '\n' -> inc 1 | '\r' -> ignore(input_char ch); inc 2 | _ -> fun () -> 1 in loop (p + i()) in try loop 0 with End_of_file -> close_in ch; f let find_file file = try Hashtbl.find all_files file with Not_found -> try resolve_pos file with Sys_error _ -> make_file file let find_pos p = find_line p.pmin (find_file p.pfile) let get_error_line p = let l, _ = find_pos p in l let get_error_pos printer p = if p.pmin = -1 then "(unknown)" else let file = find_file p.pfile in let l1, p1 = find_line p.pmin file in let l2, p2 = find_line p.pmax file in if l1 = l2 then begin let s = (if p1 = p2 then Printf.sprintf " %d" p1 else Printf.sprintf "s %d-%d" p1 p2) in Printf.sprintf "%s character%s" (printer p.pfile l1) s end else Printf.sprintf "%s lines %d-%d" (printer p.pfile l1) l1 l2 let reset() = Buffer.reset buf let contents() = Buffer.contents buf let store lexbuf = Buffer.add_string buf (lexeme lexbuf) let add c = Buffer.add_string buf c let mk_tok t pmin pmax = t , { pfile = !cur.lfile; pmin = pmin; pmax = pmax } let mk lexbuf t = mk_tok t (lexeme_start lexbuf) (lexeme_end lexbuf) let mk_ident lexbuf = let s = lexeme lexbuf in mk lexbuf (try Kwd (Hashtbl.find keywords s) with Not_found -> Const (Ident s)) let invalid_char lexbuf = error (Invalid_character (lexeme_char lexbuf 0)) (lexeme_start lexbuf) } let ident = ('_'* ['a'-'z'] ['_' 'a'-'z' 'A'-'Z' '0'-'9']* | '_'+ | '_'+ ['0'-'9'] ['_' 'a'-'z' 'A'-'Z' '0'-'9']* ) let idtype = '_'* ['A'-'Z'] ['_' 'a'-'z' 'A'-'Z' '0'-'9']* let integer = ['1'-'9'] ['0'-'9']* | '0' rule skip_header = parse | "\239\187\191" { skip_header lexbuf } | "#!" [^'\n' '\r']* { skip_header lexbuf } | "" | eof { } and token = parse | eof { mk lexbuf Eof } | [' ' '\t']+ { token lexbuf } | "\r\n" { newline lexbuf; token lexbuf } | '\n' | '\r' { newline lexbuf; token lexbuf } | "0x" ['0'-'9' 'a'-'f' 'A'-'F']+ { mk lexbuf (Const (Int (lexeme lexbuf))) } | integer { mk lexbuf (Const (Int (lexeme lexbuf))) } | integer '.' ['0'-'9']+ { mk lexbuf (Const (Float (lexeme lexbuf))) } | '.' ['0'-'9']+ { mk lexbuf (Const (Float (lexeme lexbuf))) } | integer ['e' 'E'] ['+' '-']? ['0'-'9']+ { mk lexbuf (Const (Float (lexeme lexbuf))) } | integer '.' ['0'-'9']* ['e' 'E'] ['+' '-']? ['0'-'9']+ { mk lexbuf (Const (Float (lexeme lexbuf))) } | integer "..." { let s = lexeme lexbuf in mk lexbuf (IntInterval (String.sub s 0 (String.length s - 3))) } | "//" [^'\n' '\r']* { let s = lexeme lexbuf in mk lexbuf (CommentLine (String.sub s 2 ((String.length s)-2))) } | "++" { mk lexbuf (Unop Increment) } | "--" { mk lexbuf (Unop Decrement) } | "~" { mk lexbuf (Unop NegBits) } | "%=" { mk lexbuf (Binop (OpAssignOp OpMod)) } | "&=" { mk lexbuf (Binop (OpAssignOp OpAnd)) } | "|=" { mk lexbuf (Binop (OpAssignOp OpOr)) } | "^=" { mk lexbuf (Binop (OpAssignOp OpXor)) } | "+=" { mk lexbuf (Binop (OpAssignOp OpAdd)) } | "-=" { mk lexbuf (Binop (OpAssignOp OpSub)) } | "*=" { mk lexbuf (Binop (OpAssignOp OpMult)) } | "/=" { mk lexbuf (Binop (OpAssignOp OpDiv)) } | "<<=" { mk lexbuf (Binop (OpAssignOp OpShl)) } (*//| ">>=" { mk lexbuf (Binop (OpAssignOp OpShr)) } *) (*//| ">>>=" { mk lexbuf (Binop (OpAssignOp OpUShr)) } *) | "==" { mk lexbuf (Binop OpEq) } | "!=" { mk lexbuf (Binop OpNotEq) } | "<=" { mk lexbuf (Binop OpLte) } (*//| ">=" { mk lexbuf (Binop OpGte) }*) | "&&" { mk lexbuf (Binop OpBoolAnd) } | "||" { mk lexbuf (Binop OpBoolOr) } | "<<" { mk lexbuf (Binop OpShl) } | "->" { mk lexbuf Arrow } | "..." { mk lexbuf (Binop OpInterval) } | "=>" { mk lexbuf (Binop OpArrow)} | "!" { mk lexbuf (Unop Not) } | "<" { mk lexbuf (Binop OpLt) } | ">" { mk lexbuf (Binop OpGt) } | ";" { mk lexbuf Semicolon } | ":" { mk lexbuf DblDot } | "," { mk lexbuf Comma } | "." { mk lexbuf Dot } | "%" { mk lexbuf (Binop OpMod) } | "&" { mk lexbuf (Binop OpAnd) } | "|" { mk lexbuf (Binop OpOr) } | "^" { mk lexbuf (Binop OpXor) } | "+" { mk lexbuf (Binop OpAdd) } | "*" { mk lexbuf (Binop OpMult) } | "/" { mk lexbuf (Binop OpDiv) } | "-" { mk lexbuf (Binop OpSub) } | "=" { mk lexbuf (Binop OpAssign) } | "[" { mk lexbuf BkOpen } | "]" { mk lexbuf BkClose } | "{" { mk lexbuf BrOpen } | "}" { mk lexbuf BrClose } | "(" { mk lexbuf POpen } | ")" { mk lexbuf PClose } | "?" { mk lexbuf Question } | "@" { mk lexbuf At } | "/*" { reset(); let pmin = lexeme_start lexbuf in let pmax = (try comment lexbuf with Exit -> error Unclosed_comment pmin) in mk_tok (Comment (contents())) pmin pmax; } | '"' { reset(); let pmin = lexeme_start lexbuf in let pmax = (try string lexbuf with Exit -> error Unterminated_string pmin) in let str = (try unescape (contents()) with Exit -> error Invalid_escape pmin) in mk_tok (Const (String str)) pmin pmax; } | "'" { reset(); let pmin = lexeme_start lexbuf in let pmax = (try string2 lexbuf with Exit -> error Unterminated_string pmin) in let str = (try unescape (contents()) with Exit -> error Invalid_escape pmin) in let t = mk_tok (Const (String str)) pmin pmax in fast_add_fmt_string (snd t); t } | "~/" { reset(); let pmin = lexeme_start lexbuf in let options, pmax = (try regexp lexbuf with Exit -> error Unterminated_regexp pmin) in let str = contents() in mk_tok (Const (Regexp (str,options))) pmin pmax; } | '#' ident { let v = lexeme lexbuf in let v = String.sub v 1 (String.length v - 1) in mk lexbuf (Sharp v) } | '$' ['_' 'a'-'z' 'A'-'Z' '0'-'9']* { let v = lexeme lexbuf in let v = String.sub v 1 (String.length v - 1) in mk lexbuf (Dollar v) } | ident { mk_ident lexbuf } | idtype { mk lexbuf (Const (Ident (lexeme lexbuf))) } | _ { invalid_char lexbuf } and comment = parse | eof { raise Exit } | '\n' | '\r' | "\r\n" { newline lexbuf; store lexbuf; comment lexbuf } | "*/" { lexeme_end lexbuf } | '*' { store lexbuf; comment lexbuf } | [^'*' '\n' '\r']+ { store lexbuf; comment lexbuf } and string = parse | eof { raise Exit } | '\n' | '\r' | "\r\n" { newline lexbuf; store lexbuf; string lexbuf } | "\\\"" { store lexbuf; string lexbuf } | "\\\\" { store lexbuf; string lexbuf } | '\\' { store lexbuf; string lexbuf } | '"' { lexeme_end lexbuf } | [^'"' '\\' '\r' '\n']+ { store lexbuf; string lexbuf } and string2 = parse | eof { raise Exit } | '\n' | '\r' | "\r\n" { newline lexbuf; store lexbuf; string2 lexbuf } | '\\' { store lexbuf; string2 lexbuf } | "\\\\" { store lexbuf; string2 lexbuf } | "\\'" { store lexbuf; string2 lexbuf } | "'" { lexeme_end lexbuf } | "$$" | "\\$" | '$' { store lexbuf; string2 lexbuf } | "${" { let pmin = lexeme_start lexbuf in store lexbuf; (try code_string lexbuf with Exit -> error Unclosed_code pmin); string2 lexbuf; } | [^'\'' '\\' '\r' '\n' '$']+ { store lexbuf; string2 lexbuf } and code_string = parse | eof { raise Exit } | '\n' | '\r' | "\r\n" { newline lexbuf; store lexbuf; code_string lexbuf } | '{' | '/' { store lexbuf; code_string lexbuf } | '}' { store lexbuf; (* stop *) } | '"' { add "\""; let pmin = lexeme_start lexbuf in (try ignore(string lexbuf) with Exit -> error Unterminated_string pmin); add "\""; code_string lexbuf; } | "'" { add "'"; let pmin = lexeme_start lexbuf in let pmax = (try string2 lexbuf with Exit -> error Unterminated_string pmin) in add "'"; fast_add_fmt_string { pfile = !cur.lfile; pmin = pmin; pmax = pmax }; code_string lexbuf; } | "/*" { let pmin = lexeme_start lexbuf in (try ignore(comment lexbuf) with Exit -> error Unclosed_comment pmin); code_string lexbuf; } | "//" [^'\n' '\r']* { store lexbuf; code_string lexbuf; } | [^'/' '"' '\'' '{' '}' '\n' '\r']+ { store lexbuf; code_string lexbuf; } and regexp = parse | eof | '\n' | '\r' { raise Exit } | '\\' '/' { add "/"; regexp lexbuf } | '\\' 'r' { add "\r"; regexp lexbuf } | '\\' 'n' { add "\n"; regexp lexbuf } | '\\' 't' { add "\t"; regexp lexbuf } | '\\' ['\\' '$' '.' '*' '+' '^' '|' '{' '}' '[' ']' '(' ')' '?' '-' '0'-'9'] { add (lexeme lexbuf); regexp lexbuf } | '\\' ['w' 'W' 'b' 'B' 's' 'S' 'd' 'D' 'x'] { add (lexeme lexbuf); regexp lexbuf } | '\\' ['u' 'U'] ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F'] ['0'-'9' 'a'-'f' 'A'-'F'] { add (lexeme lexbuf); regexp lexbuf } | '\\' [^ '\\'] { error (Invalid_character (lexeme lexbuf).[1]) (lexeme_end lexbuf - 1) } | '/' { regexp_options lexbuf, lexeme_end lexbuf } | [^ '\\' '/' '\r' '\n']+ { store lexbuf; regexp lexbuf } and regexp_options = parse | 'g' | 'i' | 'm' | 's' | 'u' { let l = lexeme lexbuf in l ^ regexp_options lexbuf } | ['a' - 'z'] { error Invalid_option (lexeme_start lexbuf) } | "" { "" } haxe_3.2.1+dfsg.orig/main.ml0000664000175000017500000017546312607337712015622 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) (* Conventions: - e: expression (typed or untyped) - c: class - en: enum - td: typedef (tdef) - a: abstract - an: anon - tf: tfunc - cf: class_field - ef: enum_field - t: type (t) - ct: complex_type - v: local variable (tvar) - m: module (module_def) - mt: module_type - p: pos "param" refers to type parameters "arg" refers to function arguments leading s_ means function returns string trailing l means list (but we also use natural plurals such as "metas") semantic suffixes may be used freely (e.g. e1, e_if, e') *) open Printf open Ast open Genswf open Common open Type type context = { com : Common.context; mutable flush : unit -> unit; mutable setup : unit -> unit; mutable messages : string list; mutable has_next : bool; mutable has_error : bool; } type cache = { mutable c_haxelib : (string list, string list) Hashtbl.t; mutable c_files : (string, float * Ast.package) Hashtbl.t; mutable c_modules : (path * string, module_def) Hashtbl.t; } exception Abort exception Completion of string let version = 3201 let version_major = version / 1000 let version_minor = (version mod 1000) / 100 let version_revision = (version mod 100) let version_is_stable = version_minor land 1 = 0 let measure_times = ref false let prompt = ref false let start_time = ref (get_time()) let global_cache = ref None let path_sep = if Sys.os_type = "Unix" then "/" else "\\" let get_real_path p = try Extc.get_real_path p with _ -> p let executable_path() = Extc.executable_path() let is_debug_run() = try Sys.getenv "HAXEDEBUG" = "1" with _ -> false let s_version = Printf.sprintf "%d.%d.%d%s" version_major version_minor version_revision (match Version.version_extra with None -> "" | Some v -> " " ^ v) let format msg p = if p = Ast.null_pos then msg else begin let error_printer file line = sprintf "%s:%d:" file line in let epos = Lexer.get_error_pos error_printer p in let msg = String.concat ("\n" ^ epos ^ " : ") (ExtString.String.nsplit msg "\n") in sprintf "%s : %s" epos msg end let ssend sock str = let rec loop pos len = if len = 0 then () else let s = Unix.send sock str pos len [] in loop (pos + s) (len - s) in loop 0 (String.length str) let message ctx msg p = ctx.messages <- format msg p :: ctx.messages let deprecated = [ "Type not found : IntIter","IntIter was renamed to IntIterator"; "EReg has no field customReplace","EReg.customReplace was renamed to EReg.map"; "#StringTools has no field isEOF","StringTools.isEOF was renamed to StringTools.isEof"; "Type not found : haxe.BaseCode","haxe.BaseCode was moved to haxe.crypto.BaseCode"; "Type not found : haxe.Md5","haxe.Md5 was moved to haxe.crypto.Md5"; "Type not found : haxe.SHA1","haxe.SHA1 was moved to haxe.crypto.SHA1"; "Type not found : Hash","Hash has been removed, use Map instead"; "Type not found : IntHash","IntHash has been removed, use Map instead"; "Type not found : haxe.FastList","haxe.FastList was moved to haxe.ds.GenericStack"; "#Std has no field format","Std.format has been removed, use single quote 'string ${escape}' syntax instead"; "Identifier 'EType' is not part of enum haxe.macro.ExprDef","EType has been removed, use EField instead"; "Identifier 'CType' is not part of enum haxe.macro.Constant","CType has been removed, use CIdent instead"; "Type not found : haxe.rtti.Infos","Use @:rtti instead of implementing haxe.rtti.Infos"; "Type not found : haxe.rtti.Generic","Use @:generic instead of implementing haxe.Generic"; "Type not found : flash.utils.TypedDictionary","flash.utils.TypedDictionary has been removed, use Map instead"; "Type not found : haxe.Stack", "haxe.Stack has been renamed to haxe.CallStack"; "Type not found : neko.zip.Reader", "neko.zip.Reader has been removed, use haxe.zip.Reader instead"; "Type not found : neko.zip.Writer", "neko.zip.Writer has been removed, use haxe.zip.Writer instead"; "Type not found : haxe.Public", "Use @:publicFields instead of implementing or extending haxe.Public"; "#Xml has no field createProlog", "Xml.createProlog was renamed to Xml.createProcessingInstruction" ] let limit_string s offset = let rest = 80 - offset in let words = ExtString.String.nsplit s " " in let rec loop i words = match words with | word :: words -> if String.length word + i + 1 > rest then (Printf.sprintf "\n%*s" offset "") :: word :: loop (String.length word) words else (if i = 0 then "" else " ") :: word :: loop (i + 1 + String.length word) words | [] -> [] in String.concat "" (loop 0 words) let error ctx msg p = let msg = try List.assoc msg deprecated with Not_found -> msg in message ctx msg p; ctx.has_error <- true let htmlescape s = let s = String.concat "&" (ExtString.String.nsplit s "&") in let s = String.concat "<" (ExtString.String.nsplit s "<") in let s = String.concat ">" (ExtString.String.nsplit s ">") in s let reserved_flags = [ "cross";"js";"neko";"flash";"php";"cpp";"cs";"java";"python"; "as3";"swc";"macro";"sys" ] let complete_fields com fields = let b = Buffer.create 0 in let details = Common.raw_defined com "display-details" in Buffer.add_string b "\n"; List.iter (fun (n,t,k,d) -> let s_kind = match k with | Some k -> (match k with | Typer.FKVar -> "var" | Typer.FKMethod -> "method" | Typer.FKType -> "type" | Typer.FKPackage -> "package") | None -> "" in if details then Buffer.add_string b (Printf.sprintf "%s%s\n" n s_kind (htmlescape t) (htmlescape d)) else Buffer.add_string b (Printf.sprintf "%s%s\n" n (htmlescape t) (htmlescape d)) ) (List.sort (fun (a,_,ak,_) (b,_,bk,_) -> compare (ak,a) (bk,b)) fields); Buffer.add_string b "\n"; raise (Completion (Buffer.contents b)) let report_times print = let tot = ref 0. in Hashtbl.iter (fun _ t -> tot := !tot +. t.total) Common.htimers; print (Printf.sprintf "Total time : %.3fs" !tot); if !tot > 0. then begin print "------------------------------------"; let timers = List.sort (fun t1 t2 -> compare t1.name t2.name) (Hashtbl.fold (fun _ t acc -> t :: acc) Common.htimers []) in List.iter (fun t -> print (Printf.sprintf " %s : %.3fs, %.0f%%" t.name t.total (t.total *. 100. /. !tot))) timers end let make_path f = let f = String.concat "/" (ExtString.String.nsplit f "\\") in let cl = ExtString.String.nsplit f "." in let cl = (match List.rev cl with | ["hx";path] -> ExtString.String.nsplit path "/" | _ -> cl ) in let error msg = let msg = "Could not process argument " ^ f ^ "\n" ^ msg in failwith msg in let invalid_char x = for i = 1 to String.length x - 1 do match x.[i] with | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' -> () | c -> error ("invalid character: " ^ (String.make 1 c)) done in let rec loop = function | [] -> error "empty part" | [x] -> if String.length x = 0 then error "empty part" else if not (x.[0] = '_' || (x.[0] >= 'A' && x.[0] <= 'Z')) then error "Class name must start with uppercase character"; invalid_char x; [],x | x :: l -> if String.length x = 0 then error "empty part" else if x.[0] < 'a' || x.[0] > 'z' then error "Package name must start with a lower case character"; invalid_char x; let path,name = loop l in x :: path,name in loop cl let unique l = let rec _unique = function | [] -> [] | x1 :: x2 :: l when x1 = x2 -> _unique (x2 :: l) | x :: l -> x :: _unique l in _unique (List.sort compare l) let rec read_type_path com p = let classes = ref [] in let packages = ref [] in let p = (match p with | x :: l -> (try match PMap.find x com.package_rules with | Directory d -> d :: l | Remap s -> s :: l | _ -> p with Not_found -> p) | _ -> p ) in List.iter (fun path -> let dir = path ^ String.concat "/" p in let r = (try Sys.readdir dir with _ -> [||]) in Array.iter (fun f -> if (try (Unix.stat (dir ^ "/" ^ f)).Unix.st_kind = Unix.S_DIR with _ -> false) then begin if f.[0] >= 'a' && f.[0] <= 'z' then begin if p = ["."] then match read_type_path com [f] with | [] , [] -> () | _ -> try match PMap.find f com.package_rules with | Forbidden -> () | Remap f -> packages := f :: !packages | Directory _ -> raise Not_found with Not_found -> packages := f :: !packages else packages := f :: !packages end; end else if file_extension f = "hx" then begin let c = Filename.chop_extension f in if String.length c < 2 || String.sub c (String.length c - 2) 2 <> "__" then classes := c :: !classes; end; ) r; ) com.class_path; List.iter (fun (_,_,extract) -> Hashtbl.iter (fun (path,name) _ -> if path = p then classes := name :: !classes else let rec loop p1 p2 = match p1, p2 with | [], _ -> () | x :: _, [] -> packages := x :: !packages | a :: p1, b :: p2 -> if a = b then loop p1 p2 in loop path p ) (extract()); ) com.swf_libs; List.iter (fun (path,std,close,all_files,lookup) -> List.iter (fun (path, name) -> if path = p then classes := name :: !classes else let rec loop p1 p2 = match p1, p2 with | [], _ -> () | x :: _, [] -> packages := x :: !packages | a :: p1, b :: p2 -> if a = b then loop p1 p2 in loop path p ) (all_files()) ) com.java_libs; List.iter (fun (path,std,all_files,lookup) -> List.iter (fun (path, name) -> if path = p then classes := name :: !classes else let rec loop p1 p2 = match p1, p2 with | [], _ -> () | x :: _, [] -> packages := x :: !packages | a :: p1, b :: p2 -> if a = b then loop p1 p2 in loop path p ) (all_files()) ) com.net_libs; unique !packages, unique !classes let delete_file f = try Sys.remove f with _ -> () let expand_env ?(h=None) path = let r = Str.regexp "%\\([A-Za-z0-9_]+\\)%" in Str.global_substitute r (fun s -> let key = Str.matched_group 1 s in try Sys.getenv key with Not_found -> try match h with | None -> raise Not_found | Some h -> Hashtbl.find h key with Not_found -> "%" ^ key ^ "%" ) path let unquote v = let len = String.length v in if len > 0 && v.[0] = '"' && v.[len - 1] = '"' then String.sub v 1 (len - 2) else v let parse_hxml_data data = let lines = Str.split (Str.regexp "[\r\n]+") data in List.concat (List.map (fun l -> let l = unquote (ExtString.String.strip l) in if l = "" || l.[0] = '#' then [] else if l.[0] = '-' then try let a, b = ExtString.String.split l " " in [unquote a; unquote (ExtString.String.strip b)] with _ -> [l] else [l] ) lines) let parse_hxml file = let ch = IO.input_channel (try open_in_bin file with _ -> raise Not_found) in let data = IO.read_all ch in IO.close_in ch; parse_hxml_data data let lookup_classes com spath = let rec loop = function | [] -> [] | cp :: l -> let cp = (if cp = "" then "./" else cp) in let c = normalize_path (get_real_path (Common.unique_full_path cp)) in let clen = String.length c in if clen < String.length spath && String.sub spath 0 clen = c then begin let path = String.sub spath clen (String.length spath - clen) in (try let path = make_path path in (match loop l with | [x] when String.length (Ast.s_type_path x) < String.length (Ast.s_type_path path) -> [x] | _ -> [path]) with _ -> loop l) end else loop l in loop com.class_path let add_libs com libs = let call_haxelib() = let t = Common.timer "haxelib" in let cmd = "haxelib path " ^ String.concat " " libs in let pin, pout, perr = Unix.open_process_full cmd (Unix.environment()) in let lines = Std.input_list pin in let err = Std.input_list perr in let ret = Unix.close_process_full (pin,pout,perr) in if ret <> Unix.WEXITED 0 then failwith (match lines, err with | [], [] -> "Failed to call haxelib (command not found ?)" | [], [s] when ExtString.String.ends_with (ExtString.String.strip s) "Module not found : path" -> "The haxelib command has been strip'ed, please install it again" | _ -> String.concat "\n" (lines@err)); t(); lines in match libs with | [] -> [] | _ -> let lines = match !global_cache with | Some cache -> (try (* if we are compiling, really call haxelib since library path might have changed *) if com.display = DMNone then raise Not_found; Hashtbl.find cache.c_haxelib libs with Not_found -> let lines = call_haxelib() in Hashtbl.replace cache.c_haxelib libs lines; lines) | _ -> call_haxelib() in let extra_args = ref [] in let lines = List.fold_left (fun acc l -> let l = ExtString.String.strip l in if l = "" then acc else if l.[0] <> '-' then l :: acc else match (try ExtString.String.split l " " with _ -> l, "") with | ("-L",dir) -> com.neko_libs <- String.sub l 3 (String.length l - 3) :: com.neko_libs; acc | param, value -> extra_args := param :: !extra_args; if value <> "" then extra_args := value :: !extra_args; acc ) [] lines in com.class_path <- lines @ com.class_path; List.rev !extra_args let run_command ctx cmd = let h = Hashtbl.create 0 in Hashtbl.add h "__file__" ctx.com.file; Hashtbl.add h "__platform__" (platform_name ctx.com.platform); let t = Common.timer "command" in let cmd = expand_env ~h:(Some h) cmd in let len = String.length cmd in if len > 3 && String.sub cmd 0 3 = "cd " then begin Sys.chdir (String.sub cmd 3 (len - 3)); 0 end else let binary_string s = if Sys.os_type <> "Win32" && Sys.os_type <> "Cygwin" then s else String.concat "\n" (Str.split (Str.regexp "\r\n") s) in let pout, pin, perr = Unix.open_process_full cmd (Unix.environment()) in let iout = Unix.descr_of_in_channel pout in let ierr = Unix.descr_of_in_channel perr in let berr = Buffer.create 0 in let bout = Buffer.create 0 in let tmp = String.create 1024 in let result = ref None in (* we need to read available content on process out/err if we want to prevent the process from blocking when the pipe is full *) let is_process_running() = let pid, r = Unix.waitpid [Unix.WNOHANG] (-1) in if pid = 0 then true else begin result := Some r; false; end in let rec loop ins = let (ch,_,_), timeout = (try Unix.select ins [] [] 0.02, true with _ -> ([],[],[]),false) in match ch with | [] -> (* make sure we read all *) if timeout && is_process_running() then loop ins else begin Buffer.add_string berr (IO.read_all (IO.input_channel perr)); Buffer.add_string bout (IO.read_all (IO.input_channel pout)); end | s :: _ -> let n = Unix.read s tmp 0 (String.length tmp) in if s == iout && n > 0 then ctx.com.print (String.sub tmp 0 n) else Buffer.add_substring (if s == iout then bout else berr) tmp 0 n; loop (if n = 0 then List.filter ((!=) s) ins else ins) in (try loop [iout;ierr] with Unix.Unix_error _ -> ()); let serr = binary_string (Buffer.contents berr) in let sout = binary_string (Buffer.contents bout) in if serr <> "" then ctx.messages <- (if serr.[String.length serr - 1] = '\n' then String.sub serr 0 (String.length serr - 1) else serr) :: ctx.messages; if sout <> "" then ctx.com.print sout; let r = (match (try Unix.close_process_full (pout,pin,perr) with Unix.Unix_error (Unix.ECHILD,_,_) -> (match !result with None -> assert false | Some r -> r)) with | Unix.WEXITED e -> e | Unix.WSIGNALED s | Unix.WSTOPPED s -> if s = 0 then -1 else s ) in t(); r let display_memory ctx = let verbose = ctx.com.verbose in let print = print_endline in let fmt_size sz = if sz < 1024 then string_of_int sz ^ " B" else if sz < 1024*1024 then string_of_int (sz asr 10) ^ " KB" else Printf.sprintf "%.1f MB" ((float_of_int sz) /. (1024.*.1024.)) in let size v = fmt_size (mem_size v) in Gc.full_major(); Gc.compact(); let mem = Gc.stat() in print ("Total Allocated Memory " ^ fmt_size (mem.Gc.heap_words * (Sys.word_size asr 8))); print ("Free Memory " ^ fmt_size (mem.Gc.free_words * (Sys.word_size asr 8))); (match !global_cache with | None -> print "No cache found"; | Some c -> print ("Total cache size " ^ size c); print (" haxelib " ^ size c.c_haxelib); print (" parsed ast " ^ size c.c_files ^ " (" ^ string_of_int (Hashtbl.length c.c_files) ^ " files stored)"); print (" typed modules " ^ size c.c_modules ^ " (" ^ string_of_int (Hashtbl.length c.c_modules) ^ " modules stored)"); let rec scan_module_deps m h = if Hashtbl.mem h m.m_id then () else begin Hashtbl.add h m.m_id m; PMap.iter (fun _ m -> scan_module_deps m h) m.m_extra.m_deps end in let all_modules = Hashtbl.fold (fun _ m acc -> PMap.add m.m_id m acc) c.c_modules PMap.empty in let modules = Hashtbl.fold (fun (path,key) m acc -> let mdeps = Hashtbl.create 0 in scan_module_deps m mdeps; let deps = ref [] in let out = ref all_modules in Hashtbl.iter (fun _ md -> out := PMap.remove md.m_id !out; if m == md then () else begin deps := Obj.repr md :: !deps; List.iter (fun t -> match t with | TClassDecl c -> deps := Obj.repr c :: !deps; List.iter (fun f -> deps := Obj.repr f :: !deps) c.cl_ordered_statics; List.iter (fun f -> deps := Obj.repr f :: !deps) c.cl_ordered_fields; | TEnumDecl e -> deps := Obj.repr e :: !deps; List.iter (fun n -> deps := Obj.repr (PMap.find n e.e_constrs) :: !deps) e.e_names; | TTypeDecl t -> deps := Obj.repr t :: !deps; | TAbstractDecl a -> deps := Obj.repr a :: !deps; ) md.m_types; end ) mdeps; let chk = Obj.repr Common.memory_marker :: PMap.fold (fun m acc -> Obj.repr m :: acc) !out [] in let inf = Objsize.objsize m !deps chk in (m,Objsize.size_with_headers inf, (inf.Objsize.reached,!deps,!out)) :: acc ) c.c_modules [] in let cur_key = ref "" and tcount = ref 0 and mcount = ref 0 in List.iter (fun (m,size,(reached,deps,out)) -> let key = m.m_extra.m_sign in if key <> !cur_key then begin print (Printf.sprintf (" --- CONFIG %s ----------------------------") (Digest.to_hex key)); cur_key := key; end; let sign md = if md.m_extra.m_sign = key then "" else "(" ^ (try Digest.to_hex md.m_extra.m_sign with _ -> "???" ^ md.m_extra.m_sign) ^ ")" in print (Printf.sprintf " %s : %s" (Ast.s_type_path m.m_path) (fmt_size size)); (if reached then try incr mcount; let lcount = ref 0 in let leak l = incr lcount; incr tcount; print (Printf.sprintf " LEAK %s" l); if !lcount >= 3 && !tcount >= 100 && not verbose then begin print (Printf.sprintf " ..."); raise Exit; end; in if (Objsize.objsize m deps [Obj.repr Common.memory_marker]).Objsize.reached then leak "common"; PMap.iter (fun _ md -> if (Objsize.objsize m deps [Obj.repr md]).Objsize.reached then leak (Ast.s_type_path md.m_path ^ sign md); ) out; with Exit -> ()); if verbose then begin print (Printf.sprintf " %d total deps" (List.length deps)); PMap.iter (fun _ md -> print (Printf.sprintf " dep %s%s" (Ast.s_type_path md.m_path) (sign md)); ) m.m_extra.m_deps; end; flush stdout ) (List.sort (fun (m1,s1,_) (m2,s2,_) -> let k1 = m1.m_extra.m_sign and k2 = m2.m_extra.m_sign in if k1 = k2 then s1 - s2 else if k1 > k2 then 1 else -1 ) modules); if !mcount > 0 then print ("*** " ^ string_of_int !mcount ^ " modules have leaks !"); print "Cache dump complete") let default_flush ctx = List.iter prerr_endline (List.rev ctx.messages); if ctx.has_error && !prompt then begin print_endline "Press enter to exit..."; ignore(read_line()); end; if ctx.has_error then exit 1 let create_context params = let ctx = { com = Common.create version params; flush = (fun()->()); setup = (fun()->()); messages = []; has_next = false; has_error = false; } in ctx.flush <- (fun() -> default_flush ctx); ctx let rec process_params create pl = let each_params = ref [] in let rec loop acc = function | [] -> let ctx = create (!each_params @ (List.rev acc)) in init ctx; ctx.flush() | "--next" :: l when acc = [] -> (* skip empty --next *) loop [] l | "--next" :: l -> let ctx = create (!each_params @ (List.rev acc)) in ctx.has_next <- true; init ctx; ctx.flush(); loop [] l | "--each" :: l -> each_params := List.rev acc; loop [] l | "--cwd" :: dir :: l -> (* we need to change it immediately since it will affect hxml loading *) (try Unix.chdir dir with _ -> raise (Arg.Bad "Invalid directory")); loop acc l | "--connect" :: hp :: l -> (match !global_cache with | None -> let host, port = (try ExtString.String.split hp ":" with _ -> "127.0.0.1", hp) in do_connect host (try int_of_string port with _ -> raise (Arg.Bad "Invalid port")) ((List.rev acc) @ l) | Some _ -> (* already connected : skip *) loop acc l) | "--run" :: cl :: args -> let acc = cl :: "-main" :: "--interp" :: acc in let ctx = create (!each_params @ (List.rev acc)) in ctx.com.sys_args <- args; init ctx; ctx.flush() | arg :: l -> match List.rev (ExtString.String.nsplit arg ".") with | "hxml" :: _ when (match acc with "-cmd" :: _ -> false | _ -> true) -> let acc, l = (try acc, parse_hxml arg @ l with Not_found -> (arg ^ " (file not found)") :: acc, l) in loop acc l | _ -> loop (arg :: acc) l in (* put --display in front if it was last parameter *) let pl = (match List.rev pl with | file :: "--display" :: pl when file <> "memory" -> "--display" :: file :: List.rev pl | "use_rtti_doc" :: "-D" :: file :: "--display" :: pl -> "--display" :: file :: List.rev pl | _ -> pl ) in loop [] pl and wait_loop boot_com host port = let sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in (try Unix.setsockopt sock Unix.SO_REUSEADDR true with _ -> ()); (try Unix.bind sock (Unix.ADDR_INET (Unix.inet_addr_of_string host,port)) with _ -> failwith ("Couldn't wait on " ^ host ^ ":" ^ string_of_int port)); Unix.listen sock 10; Sys.catch_break false; let verbose = boot_com.verbose in let has_parse_error = ref false in if verbose then print_endline ("Waiting on " ^ host ^ ":" ^ string_of_int port); let bufsize = 1024 in let tmp = String.create bufsize in let cache = { c_haxelib = Hashtbl.create 0; c_files = Hashtbl.create 0; c_modules = Hashtbl.create 0; } in global_cache := Some cache; Typer.macro_enable_cache := true; Typeload.parse_hook := (fun com2 file p -> let sign = get_signature com2 in let ffile = Common.unique_full_path file in let ftime = file_time ffile in let fkey = ffile ^ "!" ^ sign in try let time, data = Hashtbl.find cache.c_files fkey in if time <> ftime then raise Not_found; data with Not_found -> has_parse_error := false; let data = Typeload.parse_file com2 file p in if verbose then print_endline ("Parsed " ^ ffile); if not !has_parse_error && ffile <> (!Parser.resume_display).Ast.pfile then Hashtbl.replace cache.c_files fkey (ftime,data); data ); let cache_module m = Hashtbl.replace cache.c_modules (m.m_path,m.m_extra.m_sign) m; in let check_module_path com m p = if m.m_extra.m_file <> Common.unique_full_path (Typeload.resolve_module_file com m.m_path (ref[]) p) then begin if verbose then print_endline ("Module path " ^ s_type_path m.m_path ^ " has been changed"); raise Not_found; end in let compilation_step = ref 0 in let compilation_mark = ref 0 in let mark_loop = ref 0 in Typeload.type_module_hook := (fun (ctx:Typecore.typer) mpath p -> let t = Common.timer "module cache check" in let com2 = ctx.Typecore.com in let sign = get_signature com2 in let dep = ref None in incr mark_loop; let mark = !mark_loop in let start_mark = !compilation_mark in let rec check m = if m.m_extra.m_dirty then begin dep := Some m; false end else if m.m_extra.m_mark = mark then true else try if m.m_extra.m_mark <= start_mark then begin (match m.m_extra.m_kind with | MFake | MSub -> () (* don't get classpath *) | MExtern -> (* if we have a file then this will override our extern type *) let has_file = (try ignore(Typeload.resolve_module_file com2 m.m_path (ref[]) p); true with Not_found -> false) in if has_file then begin if verbose then print_endline ("A file is masking the library file " ^ s_type_path m.m_path); raise Not_found; end; let rec loop = function | [] -> if verbose then print_endline ("No library file was found for " ^ s_type_path m.m_path); raise Not_found (* no extern registration *) | load :: l -> match load m.m_path p with | None -> loop l | Some (file,_) -> if Common.unique_full_path file <> m.m_extra.m_file then begin if verbose then print_endline ("Library file was changed for " ^ s_type_path m.m_path); raise Not_found; end in loop com2.load_extern_type | MCode -> check_module_path com2 m p | MMacro when ctx.Typecore.in_macro -> check_module_path com2 m p | MMacro -> let _, mctx = Typer.get_macro_context ctx p in check_module_path mctx.Typecore.com m p ); if file_time m.m_extra.m_file <> m.m_extra.m_time then begin if verbose then print_endline ("File " ^ m.m_extra.m_file ^ (if m.m_extra.m_time = -1. then " not cached (macro-in-macro)" else " has been modified")); if m.m_extra.m_kind = MFake then Hashtbl.remove Typecore.fake_modules m.m_extra.m_file; raise Not_found; end; end; m.m_extra.m_mark <- mark; PMap.iter (fun _ m2 -> if not (check m2) then begin dep := Some m2; raise Not_found end) m.m_extra.m_deps; true with Not_found -> m.m_extra.m_dirty <- true; false in let rec add_modules m0 m = if m.m_extra.m_added < !compilation_step then begin (match m0.m_extra.m_kind, m.m_extra.m_kind with | MCode, MMacro | MMacro, MCode -> (* this was just a dependency to check : do not add to the context *) () | _ -> if verbose then print_endline ("Reusing cached module " ^ Ast.s_type_path m.m_path); m.m_extra.m_added <- !compilation_step; List.iter (fun t -> match t with | TClassDecl c -> c.cl_restore() | TEnumDecl e -> let rec loop acc = function | [] -> () | (Ast.Meta.RealPath,[Ast.EConst (Ast.String path),_],_) :: l -> e.e_path <- Ast.parse_path path; e.e_meta <- (List.rev acc) @ l; | x :: l -> loop (x::acc) l in loop [] e.e_meta | TAbstractDecl a -> a.a_meta <- List.filter (fun (m,_,_) -> m <> Ast.Meta.ValueUsed) a.a_meta | _ -> () ) m.m_types; if m.m_extra.m_kind <> MSub then Typeload.add_module ctx m p; PMap.iter (Hashtbl.add com2.resources) m.m_extra.m_binded_res; PMap.iter (fun _ m2 -> add_modules m0 m2) m.m_extra.m_deps); List.iter (Typer.call_init_macro ctx) m.m_extra.m_macro_calls end in try let m = Hashtbl.find cache.c_modules (mpath,sign) in if not (check m) then begin if verbose then print_endline ("Skipping cached module " ^ Ast.s_type_path mpath ^ (match !dep with None -> "" | Some m -> "(" ^ Ast.s_type_path m.m_path ^ ")")); raise Not_found; end; add_modules m m; t(); Some m with Not_found -> t(); None ); let run_count = ref 0 in while true do let sin, _ = Unix.accept sock in let t0 = get_time() in Unix.set_nonblock sin; if verbose then print_endline "Client connected"; let b = Buffer.create 0 in let rec read_loop count = let r = try Unix.recv sin tmp 0 bufsize [] with Unix.Unix_error((Unix.EWOULDBLOCK|Unix.EAGAIN),_,_) -> 0 in if verbose then begin if r > 0 then Printf.printf "Reading %d bytes\n" r else print_endline "Waiting for data..."; end; Buffer.add_substring b tmp 0 r; if r > 0 && tmp.[r-1] = '\000' then Buffer.sub b 0 (Buffer.length b - 1) else begin if r = 0 then ignore(Unix.select [] [] [] 0.05); (* wait a bit *) if count = 100 then failwith "Aborting unactive connection" else read_loop (count + 1); end; in let rec cache_context com = if com.display = DMNone then begin List.iter cache_module com.modules; if verbose then print_endline ("Cached " ^ string_of_int (List.length com.modules) ^ " modules"); end; match com.get_macros() with | None -> () | Some com -> cache_context com in let create params = let ctx = create_context params in ctx.flush <- (fun() -> incr compilation_step; compilation_mark := !mark_loop; List.iter (fun s -> ssend sin (s ^ "\n"); if verbose then print_endline ("> " ^ s)) (List.rev ctx.messages); if ctx.has_error then ssend sin "\x02\n" else cache_context ctx.com; ); ctx.setup <- (fun() -> Parser.display_error := (fun e p -> has_parse_error := true; ctx.com.error (Parser.error_msg e) p); if ctx.com.display <> DMNone then begin let file = (!Parser.resume_display).Ast.pfile in let fkey = file ^ "!" ^ get_signature ctx.com in (* force parsing again : if the completion point have been changed *) Hashtbl.remove cache.c_files fkey; (* force module reloading (if cached) *) Hashtbl.iter (fun _ m -> if m.m_extra.m_file = file then m.m_extra.m_dirty <- true) cache.c_modules end ); ctx.com.print <- (fun str -> ssend sin ("\x01" ^ String.concat "\x01" (ExtString.String.nsplit str "\n") ^ "\n")); ctx in (try let data = parse_hxml_data (read_loop 0) in Unix.clear_nonblock sin; if verbose then print_endline ("Processing Arguments [" ^ String.concat "," data ^ "]"); (try Common.display_default := DMNone; Parser.resume_display := Ast.null_pos; Typeload.return_partial_type := false; measure_times := false; close_times(); stats.s_files_parsed := 0; stats.s_classes_built := 0; stats.s_methods_typed := 0; stats.s_macros_called := 0; Hashtbl.clear Common.htimers; let _ = Common.timer "other" in incr compilation_step; compilation_mark := !mark_loop; start_time := get_time(); process_params create data; close_times(); if !measure_times then report_times (fun s -> ssend sin (s ^ "\n")) with Completion str -> if verbose then print_endline ("Completion Response =\n" ^ str); ssend sin str ); if verbose then begin print_endline (Printf.sprintf "Stats = %d files, %d classes, %d methods, %d macros" !(stats.s_files_parsed) !(stats.s_classes_built) !(stats.s_methods_typed) !(stats.s_macros_called)); print_endline (Printf.sprintf "Time spent : %.3fs" (get_time() -. t0)); end with Unix.Unix_error _ -> if verbose then print_endline "Connection Aborted" | e -> let estr = Printexc.to_string e in if verbose then print_endline ("Uncaught Error : " ^ estr); (try ssend sin estr with _ -> ()); ); Unix.close sin; (* prevent too much fragmentation by doing some compactions every X run *) incr run_count; if !run_count mod 10 = 0 then begin let t0 = get_time() in Gc.compact(); if verbose then begin let stat = Gc.quick_stat() in let size = (float_of_int stat.Gc.heap_words) *. 4. in print_endline (Printf.sprintf "Compacted memory %.3fs %.1fMB" (get_time() -. t0) (size /. (1024. *. 1024.))); end end else Gc.minor(); done and do_connect host port args = let sock = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in (try Unix.connect sock (Unix.ADDR_INET (Unix.inet_addr_of_string host,port)) with _ -> failwith ("Couldn't connect on " ^ host ^ ":" ^ string_of_int port)); let args = ("--cwd " ^ Unix.getcwd()) :: args in ssend sock (String.concat "" (List.map (fun a -> a ^ "\n") args) ^ "\000"); let has_error = ref false in let rec print line = match (if line = "" then '\x00' else line.[0]) with | '\x01' -> print_string (String.concat "\n" (List.tl (ExtString.String.nsplit line "\x01"))); flush stdout | '\x02' -> has_error := true; | _ -> prerr_endline line; in let buf = Buffer.create 0 in let process() = let lines = ExtString.String.nsplit (Buffer.contents buf) "\n" in (* the last line ends with \n *) let lines = (match List.rev lines with "" :: l -> List.rev l | _ -> lines) in List.iter print lines; in let tmp = String.create 1024 in let rec loop() = let b = Unix.recv sock tmp 0 1024 [] in Buffer.add_substring buf tmp 0 b; if b > 0 then begin if String.get tmp (b - 1) = '\n' then begin process(); Buffer.reset buf; end; loop(); end in loop(); process(); if !has_error then exit 1 and init ctx = let usage = Printf.sprintf "Haxe Compiler %s - (C)2005-2015 Haxe Foundation\n Usage : haxe%s -main [-swf|-js|-neko|-php|-cpp|-as3] [options]\n Options :" s_version (if Sys.os_type = "Win32" then ".exe" else "") in let com = ctx.com in let classes = ref [([],"Std")] in try let xml_out = ref None in let swf_header = ref None in let cmds = ref [] in let config_macros = ref [] in let cp_libs = ref [] in let added_libs = Hashtbl.create 0 in let no_output = ref false in let did_something = ref false in let force_typing = ref false in let pre_compilation = ref [] in let interp = ref false in let swf_version = ref false in let evals = ref [] in Common.define_value com Define.HaxeVer (float_repres (float_of_int version /. 1000.)); Common.define_value com Define.HxcppApiLevel "321"; Common.raw_define com "haxe3"; Common.define_value com Define.Dce "std"; com.warning <- (fun msg p -> message ctx ("Warning : " ^ msg) p); com.error <- error ctx; if !global_cache <> None then com.run_command <- run_command ctx; Parser.display_error := (fun e p -> com.error (Parser.error_msg e) p); Parser.use_doc := !Common.display_default <> DMNone || (!global_cache <> None); (try let p = Sys.getenv "HAXE_STD_PATH" in let rec loop = function | drive :: path :: l -> if String.length drive = 1 && ((drive.[0] >= 'a' && drive.[0] <= 'z') || (drive.[0] >= 'A' && drive.[0] <= 'Z')) then (drive ^ ":" ^ path) :: loop l else drive :: loop (path :: l) | l -> l in let parts = Str.split_delim (Str.regexp "[;:]") p in com.class_path <- "" :: List.map normalize_path (loop parts) with Not_found -> if Sys.os_type = "Unix" then com.class_path <- ["/usr/lib/haxe/std/";"/usr/share/haxe/std/";"/usr/local/lib/haxe/std/";"/usr/lib/haxe/extraLibs/";"/usr/local/lib/haxe/extraLibs/";""] else let base_path = normalize_path (get_real_path (try executable_path() with _ -> "./")) in com.class_path <- [base_path ^ "std/";base_path ^ "extraLibs/";""]); com.std_path <- List.filter (fun p -> ExtString.String.ends_with p "std/" || ExtString.String.ends_with p "std\\") com.class_path; let set_platform pf file = if com.platform <> Cross then failwith "Multiple targets"; Common.init_platform com pf; com.file <- file; if (pf = Flash) && file_extension file = "swc" then Common.define com Define.Swc; in let define f = Arg.Unit (fun () -> Common.define com f) in let process_ref = ref (fun args -> ()) in let process_libs() = let libs = List.filter (fun l -> not (Hashtbl.mem added_libs l)) (List.rev !cp_libs) in cp_libs := []; List.iter (fun l -> Hashtbl.add added_libs l ()) libs; (* immediately process the arguments to insert them at the place -lib was defined *) match add_libs com libs with | [] -> () | args -> (!process_ref) args in let arg_delays = ref [] in let basic_args_spec = [ ("-cp",Arg.String (fun path -> process_libs(); com.class_path <- normalize_path path :: com.class_path )," : add a directory to find source files"); ("-js",Arg.String (set_platform Js)," : compile code to JavaScript file"); ("-swf",Arg.String (set_platform Flash)," : compile code to Flash SWF file"); ("-as3",Arg.String (fun dir -> set_platform Flash dir; Common.define com Define.As3; Common.define com Define.NoInline; )," : generate AS3 code into target directory"); ("-neko",Arg.String (set_platform Neko)," : compile code to Neko Binary"); ("-php",Arg.String (fun dir -> classes := (["php"],"Boot") :: !classes; set_platform Php dir; )," : generate PHP code into target directory"); ("-cpp",Arg.String (fun dir -> set_platform Cpp dir; )," : generate C++ code into target directory"); ("-cs",Arg.String (fun dir -> cp_libs := "hxcs" :: !cp_libs; set_platform Cs dir; )," : generate C# code into target directory"); ("-java",Arg.String (fun dir -> cp_libs := "hxjava" :: !cp_libs; set_platform Java dir; )," : generate Java code into target directory"); ("-python",Arg.String (fun dir -> set_platform Python dir; )," : generate Python code as target file"); ("-xml",Arg.String (fun file -> Parser.use_doc := true; xml_out := Some file )," : generate XML types description"); ("-main",Arg.String (fun cl -> if com.main_class <> None then raise (Arg.Bad "Multiple -main"); let cpath = make_path cl in com.main_class <- Some cpath; classes := cpath :: !classes )," : select startup class"); ("-lib",Arg.String (fun l -> cp_libs := l :: !cp_libs; Common.raw_define com l; )," : use a haxelib library"); ("-D",Arg.String (fun var -> begin match var with | "no_copt" | "no-copt" -> com.foptimize <- false; | "use_rtti_doc" | "use-rtti-doc" -> Parser.use_doc := true; | _ -> if List.mem var reserved_flags then raise (Arg.Bad (var ^ " is a reserved compiler flag and cannot be defined from command line")); end; Common.raw_define com var; )," : define a conditional compilation flag"); ("-v",Arg.Unit (fun () -> com.verbose <- true ),": turn on verbose mode"); ("-debug", Arg.Unit (fun() -> Common.define com Define.Debug; com.debug <- true; ), ": add debug information to the compiled code"); ] in let adv_args_spec = [ ("-dce", Arg.String (fun mode -> (match mode with | "std" | "full" | "no" -> () | _ -> raise (Arg.Bad "Invalid DCE mode, expected std | full | no")); Common.define_value com Define.Dce mode ),"[std|full|no] : set the dead code elimination mode"); ("-swf-version",Arg.Float (fun v -> if not !swf_version || com.flash_version < v then com.flash_version <- v; swf_version := true; )," : change the SWF version"); ("-swf-header",Arg.String (fun h -> try swf_header := Some (match ExtString.String.nsplit h ":" with | [width; height; fps] -> (int_of_string width,int_of_string height,float_of_string fps,0xFFFFFF) | [width; height; fps; color] -> let color = if ExtString.String.starts_with color "0x" then color else "0x" ^ color in (int_of_string width, int_of_string height, float_of_string fps, int_of_string color) | _ -> raise Exit) with _ -> raise (Arg.Bad "Invalid SWF header format, expected width:height:fps[:color]") ),"
: define SWF header (width:height:fps:color)"); ("-swf-lib",Arg.String (fun file -> process_libs(); (* linked swf order matters, and lib might reference swf as well *) Genswf.add_swf_lib com file false )," : add the SWF library to the compiled SWF"); ("-swf-lib-extern",Arg.String (fun file -> Genswf.add_swf_lib com file true )," : use the SWF library for type checking"); ("-java-lib",Arg.String (fun file -> let std = file = "lib/hxjava-std.jar" in arg_delays := (fun () -> Genjava.add_java_lib com file std) :: !arg_delays; )," : add an external JAR or class directory library"); ("-net-lib",Arg.String (fun file -> let file, is_std = match ExtString.String.nsplit file "@" with | [file] -> file,false | [file;"std"] -> file,true | _ -> raise Exit in arg_delays := (fun () -> Gencs.add_net_lib com file is_std) :: !arg_delays; ),"[@std] : add an external .NET DLL file"); ("-net-std",Arg.String (fun file -> Gencs.add_net_std com file )," : add a root std .NET DLL search path"); ("-c-arg",Arg.String (fun arg -> com.c_args <- arg :: com.c_args )," : pass option to the native Java/C# compiler"); ("-x", Arg.String (fun file -> let neko_file = file ^ ".n" in set_platform Neko neko_file; if com.main_class = None then begin let cpath = make_path file in com.main_class <- Some cpath; classes := cpath :: !classes end; cmds := ("neko " ^ neko_file) :: !cmds; )," : shortcut for compiling and executing a neko file"); ("-resource",Arg.String (fun res -> let file, name = (match ExtString.String.nsplit res "@" with | [file; name] -> file, name | [file] -> file, file | _ -> raise (Arg.Bad "Invalid Resource format, expected file@name") ) in let file = (try Common.find_file com file with Not_found -> file) in let data = (try let s = Std.input_file ~bin:true file in if String.length s > 12000000 then raise Exit; s; with | Sys_error _ -> failwith ("Resource file not found : " ^ file) | _ -> failwith ("Resource '" ^ file ^ "' excess the maximum size of 12MB") ) in if Hashtbl.mem com.resources name then failwith ("Duplicate resource name " ^ name); Hashtbl.add com.resources name data ),"[@name] : add a named resource file"); ("-prompt", Arg.Unit (fun() -> prompt := true),": prompt on error"); ("-cmd", Arg.String (fun cmd -> cmds := unquote cmd :: !cmds ),": run the specified command after successful compilation"); ("--flash-strict", define Define.FlashStrict, ": more type strict flash API"); ("--no-traces", define Define.NoTraces, ": don't compile trace calls in the program"); ("--gen-hx-classes", Arg.Unit (fun() -> force_typing := true; pre_compilation := (fun() -> List.iter (fun (_,_,extract) -> Hashtbl.iter (fun n _ -> classes := n :: !classes) (extract()) ) com.swf_libs; List.iter (fun (_,std,_,all_files,_) -> if not std then List.iter (fun path -> if path <> (["java";"lang"],"String") then classes := path :: !classes) (all_files()) ) com.java_libs; List.iter (fun (_,std,all_files,_) -> if not std then List.iter (fun path -> classes := path :: !classes) (all_files()) ) com.net_libs; ) :: !pre_compilation; xml_out := Some "hx" ),": generate hx headers for all input classes"); ("--next", Arg.Unit (fun() -> assert false), ": separate several haxe compilations"); ("--each", Arg.Unit (fun() -> assert false), ": append preceding parameters to all haxe compilations separated by --next"); ("--display", Arg.String (fun file_pos -> match file_pos with | "classes" -> pre_compilation := (fun() -> raise (Parser.TypePath (["."],None,true))) :: !pre_compilation; | "keywords" -> complete_fields com (Hashtbl.fold (fun k _ acc -> (k,"",None,"") :: acc) Lexer.keywords []) | "memory" -> did_something := true; (try display_memory ctx with e -> prerr_endline (Printexc.get_backtrace ())); | _ -> let file, pos = try ExtString.String.split file_pos "@" with _ -> failwith ("Invalid format : " ^ file_pos) in let file = unquote file in let pos, smode = try ExtString.String.split pos "@" with _ -> pos,"" in let activate_special_display_mode () = Common.define com Define.NoCOpt; Parser.use_parser_resume := false in let mode = match smode with | "position" -> activate_special_display_mode(); DMPosition | "usage" -> activate_special_display_mode(); DMUsage | "type" -> activate_special_display_mode(); DMType | "toplevel" -> activate_special_display_mode(); DMToplevel | "" -> Parser.use_parser_resume := true; DMDefault | _ -> let smode,arg = try ExtString.String.split smode "@" with _ -> pos,"" in match smode with | "resolve" -> activate_special_display_mode(); DMResolve arg | _ -> Parser.use_parser_resume := true; DMDefault in let pos = try int_of_string pos with _ -> failwith ("Invalid format : " ^ pos) in com.display <- mode; Common.display_default := mode; Common.define_value com Define.Display (if smode <> "" then smode else "1"); Parser.use_doc := true; Parser.resume_display := { Ast.pfile = Common.unique_full_path file; Ast.pmin = pos; Ast.pmax = pos; }; ),": display code tips"); ("--no-output", Arg.Unit (fun() -> no_output := true),": compiles but does not generate any file"); ("--times", Arg.Unit (fun() -> measure_times := true),": measure compilation times"); ("--no-inline", define Define.NoInline, ": disable inlining"); ("--no-opt", Arg.Unit (fun() -> com.foptimize <- false; Common.define com Define.NoOpt; ), ": disable code optimizations"); ("--php-front",Arg.String (fun f -> if com.php_front <> None then raise (Arg.Bad "Multiple --php-front"); com.php_front <- Some f; )," : select the name for the php front file"); ("--php-lib",Arg.String (fun f -> if com.php_lib <> None then raise (Arg.Bad "Multiple --php-lib"); com.php_lib <- Some f; )," : select the name for the php lib folder"); ("--php-prefix", Arg.String (fun f -> if com.php_prefix <> None then raise (Arg.Bad "Multiple --php-prefix"); com.php_prefix <- Some f; Common.define com Define.PhpPrefix; )," : prefix all classes with given name"); ("--remap", Arg.String (fun s -> let pack, target = (try ExtString.String.split s ":" with _ -> raise (Arg.Bad "Invalid remap format, expected source:target")) in com.package_rules <- PMap.add pack (Remap target) com.package_rules; )," : remap a package to another one"); ("--interp", Arg.Unit (fun() -> Common.define com Define.Interp; set_platform Neko ""; no_output := true; interp := true; ),": interpret the program using internal macro system"); ("--macro", Arg.String (fun e -> force_typing := true; config_macros := e :: !config_macros )," : call the given macro before typing anything else"); ("--eval", Arg.String (fun s -> force_typing := true; evals := s :: !evals; ), " : evaluates argument as Haxe module code"); ("--wait", Arg.String (fun hp -> let host, port = (try ExtString.String.split hp ":" with _ -> "127.0.0.1", hp) in wait_loop com host (try int_of_string port with _ -> raise (Arg.Bad "Invalid port")) ),"<[host:]port> : wait on the given port for commands to run)"); ("--connect",Arg.String (fun _ -> assert false ),"<[host:]port> : connect on the given port and run commands there)"); ("--cwd", Arg.String (fun dir -> assert false )," : set current working directory"); ("-version",Arg.Unit (fun() -> message ctx s_version Ast.null_pos; did_something := true; ),": print version and exit"); ("--help-defines", Arg.Unit (fun() -> let m = ref 0 in let rec loop i = let d = Obj.magic i in if d <> Define.Last then begin let t, doc = Define.infos d in if String.length t > !m then m := String.length t; ((String.concat "-" (ExtString.String.nsplit t "_")),doc) :: (loop (i + 1)) end else [] in let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" !m n (limit_string doc (!m + 3))) all in List.iter (fun msg -> ctx.com.print (msg ^ "\n")) all; did_something := true ),": print help for all compiler specific defines"); ("--help-metas", Arg.Unit (fun() -> let m = ref 0 in let rec loop i = let d = Obj.magic i in if d <> Meta.Last then begin let t, (doc,flags) = MetaInfo.to_string d in if not (List.mem MetaInfo.Internal flags) then begin let params = ref [] and used = ref [] and pfs = ref [] in List.iter (function | MetaInfo.HasParam s -> params := s :: !params | MetaInfo.Platform f -> pfs := f :: !pfs | MetaInfo.Platforms fl -> pfs := fl @ !pfs | MetaInfo.UsedOn u -> used := u :: !used | MetaInfo.UsedOnEither ul -> used := ul @ !used | MetaInfo.Internal -> assert false ) flags; let params = (match List.rev !params with | [] -> "" | l -> "(" ^ String.concat "," l ^ ")" ) in let pfs = (match List.rev !pfs with | [] -> "" | [p] -> " (" ^ platform_name p ^ " only)" | pl -> " (for " ^ String.concat "," (List.map platform_name pl) ^ ")" ) in let str = "@" ^ t in if String.length str > !m then m := String.length str; (str,params ^ doc ^ pfs) :: loop (i + 1) end else loop (i + 1) end else [] in let all = List.sort (fun (s1,_) (s2,_) -> String.compare s1 s2) (loop 0) in let all = List.map (fun (n,doc) -> Printf.sprintf " %-*s: %s" !m n (limit_string doc (!m + 3))) all in List.iter (fun msg -> ctx.com.print (msg ^ "\n")) all; did_something := true ),": print help for all compiler metadatas"); ] in let args_callback cl = classes := make_path cl :: !classes in let all_args_spec = basic_args_spec @ adv_args_spec in let process args = let current = ref 0 in (try Arg.parse_argv ~current (Array.of_list ("" :: List.map expand_env args)) all_args_spec args_callback usage; List.iter (fun fn -> fn()) !arg_delays with (Arg.Bad msg) as exc -> let r = Str.regexp "unknown option `\\([-A-Za-z]+\\)'" in try ignore(Str.search_forward r msg 0); let s = Str.matched_group 1 msg in let sl = List.map (fun (s,_,_) -> s) all_args_spec in let msg = Typecore.string_error_raise s sl (Printf.sprintf "Invalid command: %s" s) in raise (Arg.Bad msg) with Not_found -> raise exc); arg_delays := [] in process_ref := process; process ctx.com.args; process_libs(); if com.display <> DMNone then begin com.warning <- message ctx; com.error <- error ctx; com.main_class <- None; let real = get_real_path (!Parser.resume_display).Ast.pfile in classes := lookup_classes com real; if !classes = [] then begin if not (Sys.file_exists real) then failwith "Display file does not exist"; (match List.rev (ExtString.String.nsplit real path_sep) with | file :: _ when file.[0] >= 'a' && file.[1] <= 'z' -> failwith ("Display file '" ^ file ^ "' should not start with a lowercase letter") | _ -> ()); failwith "Display file was not found in class path"; end; Common.log com ("Display file : " ^ real); Common.log com ("Classes found : [" ^ (String.concat "," (List.map Ast.s_type_path !classes)) ^ "]"); end; let add_std dir = com.class_path <- List.filter (fun s -> not (List.mem s com.std_path)) com.class_path @ List.map (fun p -> p ^ dir ^ "/_std/") com.std_path @ com.std_path in let ext = (match com.platform with | Cross -> (* no platform selected *) set_platform Cross ""; "?" | Flash -> let rec loop = function | [] -> () | (v,_) :: _ when v > com.flash_version -> () | (v,def) :: l -> Common.raw_define com ("flash" ^ def); loop l in loop Common.flash_versions; Common.raw_define com "flash"; com.package_rules <- PMap.remove "flash" com.package_rules; add_std "flash"; "swf" | Neko -> add_std "neko"; "n" | Js -> add_std "js"; "js" | Php -> add_std "php"; "php" | Cpp -> add_std "cpp"; "cpp" | Cs -> let old_flush = ctx.flush in ctx.flush <- (fun () -> com.net_libs <- []; old_flush() ); Gencs.before_generate com; add_std "cs"; "cs" | Java -> let old_flush = ctx.flush in ctx.flush <- (fun () -> List.iter (fun (_,_,close,_,_) -> close()) com.java_libs; com.java_libs <- []; old_flush() ); Genjava.before_generate com; add_std "java"; "java" | Python -> add_std "python"; "python" ) in (* if we are at the last compilation step, allow all packages accesses - in case of macros or opening another project file *) begin match com.display with | DMNone | DMToplevel -> () | _ -> if not ctx.has_next then com.package_rules <- PMap.foldi (fun p r acc -> match r with Forbidden -> acc | _ -> PMap.add p r acc) com.package_rules PMap.empty; end; com.config <- get_config com; (* make sure to adapt all flags changes defined after platform *) List.iter (fun f -> f()) (List.rev (!pre_compilation)); if !classes = [([],"Std")] && not !force_typing then begin let help_spec = basic_args_spec @ [ ("-help", Arg.Unit (fun () -> ()),": show extended help information"); ("--help", Arg.Unit (fun () -> ()),": show extended help information"); ("--help-defines", Arg.Unit (fun () -> ()),": print help for all compiler specific defines"); ("--help-metas", Arg.Unit (fun () -> ()),": print help for all compiler metadatas"); ("", Arg.Unit (fun () -> ()),": compile the module specified by dot-path"); ] in if !cmds = [] && not !did_something then Arg.usage help_spec usage; end else begin ctx.setup(); Common.log com ("Classpath : " ^ (String.concat ";" com.class_path)); Common.log com ("Defines : " ^ (String.concat ";" (PMap.foldi (fun v _ acc -> v :: acc) com.defines []))); let t = Common.timer "typing" in Typecore.type_expr_ref := (fun ctx e with_type -> Typer.type_expr ctx e with_type); let tctx = Typer.create com in List.iter (Typer.call_init_macro tctx) (List.rev !config_macros); List.iter (Typer.eval tctx) !evals; List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath Ast.null_pos)) (List.rev !classes); Typer.finalize tctx; t(); if ctx.has_error then raise Abort; begin match com.display with | DMNone | DMUsage | DMPosition | DMType | DMResolve _ -> () | _ -> if ctx.has_next then raise Abort; failwith "No completion point was found"; end; let t = Common.timer "filters" in let main, types, modules = Typer.generate tctx in com.main <- main; com.types <- types; com.modules <- modules; Filters.run com tctx main; if ctx.has_error then raise Abort; (* check file extension. In case of wrong commandline, we don't want to accidentaly delete a source file. *) if not !no_output && file_extension com.file = ext then delete_file com.file; (match !xml_out with | None -> () | Some "hx" -> Genxml.generate_hx com | Some file -> Common.log com ("Generating xml : " ^ file); Common.mkdir_from_path file; Genxml.generate com file); if com.platform = Flash || com.platform = Cpp then List.iter (Codegen.fix_overrides com) com.types; if Common.defined com Define.Dump then Codegen.dump_types com; if Common.defined com Define.DumpDependencies then Codegen.dump_dependencies com; t(); if not !no_output then begin match com.platform with | Neko when !interp -> () | Cpp when Common.defined com Define.Cppia -> () | Cpp | Cs | Java | Php -> Common.mkdir_from_path (com.file ^ "/.") | _ -> Common.mkdir_from_path com.file end; (match com.platform with | _ when !no_output -> if !interp then begin let ctx = Interp.create com (Typer.make_macro_api tctx Ast.null_pos) in Interp.add_types ctx com.types (fun t -> ()); (match com.main with | None -> () | Some e -> ignore(Interp.eval_expr ctx e)); end; | Cross -> () | Flash when Common.defined com Define.As3 -> Common.log com ("Generating AS3 in : " ^ com.file); Genas3.generate com; | Flash -> Common.log com ("Generating swf : " ^ com.file); Genswf.generate com !swf_header; | Neko -> Common.log com ("Generating neko : " ^ com.file); Genneko.generate com; | Js -> Common.log com ("Generating js : " ^ com.file); Genjs.generate com | Php -> Common.log com ("Generating PHP in : " ^ com.file); Genphp.generate com; | Cpp -> Common.log com ("Generating Cpp in : " ^ com.file); Gencpp.generate com; | Cs -> Common.log com ("Generating Cs in : " ^ com.file); Gencs.generate com; | Java -> Common.log com ("Generating Java in : " ^ com.file); Genjava.generate com; | Python -> Common.log com ("Generating python in : " ^ com.file); Genpy.generate com; ); end; Sys.catch_break false; List.iter (fun f -> f()) (List.rev com.final_filters); if not !no_output then begin List.iter (fun c -> let r = run_command ctx c in if r <> 0 then failwith ("Command failed with error " ^ string_of_int r) ) (List.rev !cmds) end with | Abort -> () | Ast.Error (m,p) -> error ctx m p | Typecore.Fatal_error (m,p) -> error ctx m p | Common.Abort (m,p) -> error ctx m p | Lexer.Error (m,p) -> error ctx (Lexer.error_msg m) p | Parser.Error (m,p) -> error ctx (Parser.error_msg m) p | Typecore.Forbid_package ((pack,m,p),pl,pf) -> if !Common.display_default <> DMNone && ctx.has_next then begin ctx.has_error <- false; ctx.messages <- []; end else begin error ctx (Printf.sprintf "You cannot access the %s package while %s (for %s)" pack (if pf = "macro" then "in a macro" else "targeting " ^ pf) (Ast.s_type_path m) ) p; List.iter (error ctx " referenced here") (List.rev pl); end | Typecore.Error (m,p) -> error ctx (Typecore.error_msg m) p | Interp.Error (msg,p :: l) -> message ctx msg p; List.iter (message ctx "Called from") l; error ctx "Aborted" Ast.null_pos; | Codegen.Generic_Exception(m,p) -> error ctx m p | Arg.Bad msg -> error ctx ("Error: " ^ msg) Ast.null_pos | Failure msg when not (is_debug_run()) -> error ctx ("Error: " ^ msg) Ast.null_pos | Arg.Help msg -> message ctx msg Ast.null_pos | Typer.DisplayFields fields -> let ctx = print_context() in let fields = List.map (fun (name,t,kind,doc) -> name, s_type ctx t, kind, (match doc with None -> "" | Some d -> d)) fields in let fields = if !measure_times then begin close_times(); let tot = ref 0. in Hashtbl.iter (fun _ t -> tot := !tot +. t.total) Common.htimers; let fields = ("@TOTAL", Printf.sprintf "%.3fs" (get_time() -. !start_time), None, "") :: fields in if !tot > 0. then Hashtbl.fold (fun _ t acc -> ("@TIME " ^ t.name, Printf.sprintf "%.3fs (%.0f%%)" t.total (t.total *. 100. /. !tot), None, "") :: acc ) Common.htimers fields else fields end else fields in complete_fields com fields | Typecore.DisplayTypes tl -> let ctx = print_context() in let b = Buffer.create 0 in List.iter (fun t -> Buffer.add_string b "\n"; Buffer.add_string b (htmlescape (s_type ctx t)); Buffer.add_string b "\n\n"; ) tl; raise (Completion (Buffer.contents b)) | Typecore.DisplayPosition pl -> let b = Buffer.create 0 in let error_printer file line = sprintf "%s:%d:" (Common.unique_full_path file) line in Buffer.add_string b "\n"; List.iter (fun p -> let epos = Lexer.get_error_pos error_printer p in Buffer.add_string b ""; Buffer.add_string b epos; Buffer.add_string b "\n"; ) pl; Buffer.add_string b ""; raise (Completion (Buffer.contents b)) | Typer.DisplayToplevel il -> let b = Buffer.create 0 in Buffer.add_string b "\n"; let ctx = print_context() in let s_type t = htmlescape (s_type ctx t) in List.iter (fun id -> match id with | Typer.ITLocal v -> Buffer.add_string b (Printf.sprintf "%s\n" (s_type v.v_type) v.v_name); | Typer.ITMember(c,cf) -> Buffer.add_string b (Printf.sprintf "%s\n" (s_type cf.cf_type) cf.cf_name); | Typer.ITStatic(c,cf) -> Buffer.add_string b (Printf.sprintf "%s\n" (s_type cf.cf_type) cf.cf_name); | Typer.ITEnum(en,ef) -> Buffer.add_string b (Printf.sprintf "%s\n" (s_type ef.ef_type) ef.ef_name); | Typer.ITGlobal(mt,s,t) -> Buffer.add_string b (Printf.sprintf "%s\n" (s_type_path (t_infos mt).mt_path) (s_type t) s); | Typer.ITType(mt) -> Buffer.add_string b (Printf.sprintf "%s\n" (s_type_path (t_infos mt).mt_path) (snd (t_infos mt).mt_path)); | Typer.ITPackage s -> Buffer.add_string b (Printf.sprintf "%s\n" s) ) il; Buffer.add_string b ""; raise (Completion (Buffer.contents b)) | Parser.TypePath (p,c,is_import) -> (match c with | None -> let packs, classes = read_type_path com p in if packs = [] && classes = [] then error ctx ("No classes found in " ^ String.concat "." p) Ast.null_pos else complete_fields com ( let convert k f = (f,"",Some k,"") in (List.map (convert Typer.FKPackage) packs) @ (List.map (convert Typer.FKType) classes) ) | Some (c,cur_package) -> try let sl_pack,s_module = match List.rev p with | s :: sl when s.[0] >= 'A' && s.[0] <= 'Z' -> List.rev sl,s | _ -> p,c in let ctx = Typer.create com in let rec lookup p = try Typeload.load_module ctx (p,s_module) Ast.null_pos with e -> if cur_package then match List.rev p with | [] -> raise e | _ :: p -> lookup (List.rev p) else raise e in let m = lookup sl_pack in let statics = ref None in let public_types = List.filter (fun t -> let tinfos = t_infos t in let is_module_type = snd tinfos.mt_path = c in if is_import && is_module_type then begin match t with | TClassDecl c -> ignore(c.cl_build()); statics := Some c.cl_ordered_statics | _ -> () end; not tinfos.mt_private ) m.m_types in let types = if c <> s_module then [] else List.map (fun t -> snd (t_path t),"",Some Typer.FKType,"") public_types in let ctx = print_context() in let make_field_doc cf = cf.cf_name, s_type ctx cf.cf_type, Some (match cf.cf_kind with Method _ -> Typer.FKMethod | Var _ -> Typer.FKVar), (match cf.cf_doc with Some s -> s | None -> "") in let types = match !statics with | None -> types | Some cfl -> types @ (List.map make_field_doc (List.filter (fun cf -> cf.cf_public) cfl)) in complete_fields com types with Completion c -> raise (Completion c) | _ -> error ctx ("Could not load module " ^ (Ast.s_type_path (p,c))) Ast.null_pos) | Interp.Sys_exit i -> ctx.flush(); exit i | e when (try Sys.getenv "OCAMLRUNPARAM" <> "b" || !global_cache <> None with _ -> true) && not (is_debug_run()) -> error ctx (Printexc.to_string e) Ast.null_pos ;; let other = Common.timer "other" in Sys.catch_break true; let args = List.tl (Array.to_list Sys.argv) in (try let server = Sys.getenv "HAXE_COMPILATION_SERVER" in let host, port = (try ExtString.String.split server ":" with _ -> "127.0.0.1", server) in do_connect host (try int_of_string port with _ -> failwith "Invalid HAXE_COMPILATION_SERVER port") args with Not_found -> try process_params create_context args with Completion c -> prerr_endline c; exit 0 ); other(); if !measure_times then report_times prerr_endline haxe_3.2.1+dfsg.orig/matcher.ml0000664000175000017500000013210012607337712016276 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Common open Type open Typecore type pvar = tvar * pos type con_def = | CEnum of tenum * tenum_field | CConst of tconstant | CAny | CType of module_type | CArray of int | CFields of int * (string * tclass_field) list | CExpr of texpr and con = { c_def : con_def; c_type : t; c_pos : pos; } and st_def = | SVar of tvar | SField of st * tclass_field | SEnum of st * tenum_field * int | SArray of st * int | STuple of st * int * int and st = { st_def : st_def; st_type : t; st_pos : pos; } and dt = | Switch of st * (con * dt) list | Bind of ((tvar * pos) * st) list * dt | Goto of int | Expr of int | Guard of int * dt * dt option (* Pattern *) type pat_def = | PAny | PVar of pvar | PCon of con * pat list | POr of pat * pat | PBind of pvar * pat | PTuple of pat array and pat = { p_def : pat_def; p_type : t; p_pos : pos; } type out = { mutable o_pos : pos; o_id : int; o_catch_all : bool; mutable o_num_paths : int; } type pat_vec = pat array * out type pat_matrix = pat_vec list (* Context *) type pattern_ctx = { mutable pc_locals : (string, pvar) PMap.t; mutable pc_sub_vars : (string, pvar) PMap.t option; mutable pc_reify : bool; mutable pc_is_complex : bool; } type matcher = { ctx : typer; need_val : bool; dt_lut : dt DynArray.t; dt_cache : (dt,int) Hashtbl.t; mutable dt_count : int; mutable outcomes : out list; mutable toplevel_or : bool; mutable has_extractor : bool; mutable expr_map : (int,texpr * texpr option) PMap.t; mutable is_exhaustive : bool; } type type_finiteness = | Infinite (* type has inifite constructors (e.g. Int, String) *) | CompileTimeFinite (* type is considered finite only at compile-time but has inifite possible run-time values (enum abstracts) *) | RunTimeFinite (* type is truly finite (Bool, enums) *) exception Not_exhaustive of pat * st exception Unrecognized_pattern of Ast.expr let arity con = match con.c_def with | CEnum (_,{ef_type = TFun(args,_)}) -> List.length args | CEnum _ -> 0 | CConst _ -> 0 | CType mt -> 0 | CArray i -> i | CFields (i,_) -> i | CExpr _ -> 0 | CAny -> 0 let mk_st def t p = { st_def = def; st_type = t; st_pos = p; } let mk_out mctx id e eg is_catch_all p = let out = { o_pos = p; o_id = id; o_catch_all = is_catch_all; o_num_paths = 0; } in mctx.outcomes <- out :: mctx.outcomes; mctx.expr_map <- PMap.add id (e,eg) mctx.expr_map; out let clone_out mctx out p = let out = {out with o_pos = p; } in mctx.outcomes <- out :: mctx.outcomes; out let get_guard mctx id = snd (PMap.find id mctx.expr_map) let get_expr mctx id = fst (PMap.find id mctx.expr_map) let mk_pat pdef t p = { p_def = pdef; p_type = t; p_pos = p; } let mk_con cdef t p = { c_def = cdef; c_type = t; c_pos = p; } let mk_con_pat cdef pl t p = mk_pat (PCon(mk_con cdef t p,pl)) t p let mk_any t p = mk_pat PAny t p let any = mk_any t_dynamic Ast.null_pos let fake_tuple_type = TInst(mk_class null_module ([],"-Tuple") null_pos, []) let mk_type_pat ctx mt t p = let rec loop = function | TClassDecl _ -> "Class" | TEnumDecl _ -> "Enum" | TAbstractDecl a when Meta.has Meta.RuntimeValue a.a_meta -> "Class" | TTypeDecl t -> begin match follow (monomorphs t.t_params t.t_type) with | TInst(c,_) -> loop (TClassDecl c) | TEnum(en,_) -> loop (TEnumDecl en) | TAbstract(a,_) -> loop (TAbstractDecl a) | _ -> error "Cannot use this type as a value" p end | _ -> error "Cannot use this type as a value" p in let tcl = Typeload.load_instance ctx {tname=loop mt;tpackage=[];tsub=None;tparams=[]} p true in let t2 = match tcl with TAbstract(a,_) -> TAbstract(a,[mk_mono()]) | _ -> assert false in unify ctx t t2 p; mk_con_pat (CType mt) [] t2 p let mk_subs st con = let map = match follow st.st_type with | TInst(c,pl) -> apply_params c.cl_params pl | TEnum(en,pl) -> apply_params en.e_params pl | TAbstract(a,pl) -> apply_params a.a_params pl | _ -> fun t -> t in match con.c_def with | CFields (_,fl) -> List.map (fun (s,cf) -> mk_st (SField(st,cf)) (map cf.cf_type) st.st_pos) fl | CEnum (en,({ef_type = TFun _} as ef)) -> let rec loop t = match follow t with | TEnum(_,pl) -> pl | TAbstract({a_path = [],"EnumValue"},[]) -> [] | TAbstract(a,pl) -> loop (Abstract.get_underlying_type a pl) | _ -> [] in let pl = loop con.c_type in begin match apply_params en.e_params pl (monomorphs ef.ef_params ef.ef_type) with | TFun(args,r) -> ExtList.List.mapi (fun i (_,_,t) -> mk_st (SEnum(st,ef,i)) t st.st_pos ) args | _ -> assert false end | CArray 0 -> [] | CArray i -> let t = match follow con.c_type with TInst({cl_path=[],"Array"},[t]) -> t | TDynamic _ as t -> t | _ -> assert false in ExtList.List.init i (fun i -> mk_st (SArray(st,i)) t st.st_pos) | CEnum _ | CConst _ | CType _ | CExpr _ | CAny -> [] let get_tuple_params t = match t with | TFun(tl,tr) when tr == fake_tuple_type -> Some tl | _ -> None (* Printing *) let s_type = s_type (print_context()) let rec s_con con = match con.c_def with | CEnum(_,ef) -> ef.ef_name | CAny -> "_" | CConst c -> s_const c | CType mt -> s_type_path (t_path mt) | CArray i -> "[" ^(string_of_int i) ^ "]" | CFields (_,fl) -> String.concat "," (List.map (fun (s,_) -> s) fl) | CExpr e -> s_expr s_type e let rec s_pat pat = match pat.p_def with | PVar (v,_) -> v.v_name | PCon (c,[]) -> s_con c | PCon (c,pl) -> s_con c ^ "(" ^ (String.concat "," (List.map s_pat pl)) ^ ")" | POr (pat1,pat2) -> s_pat pat1 ^ " | " ^ s_pat pat2 | PAny -> "_" | PBind((v,_),pat) -> v.v_name ^ "=" ^ s_pat pat | PTuple pl -> "(" ^ (String.concat " " (Array.to_list (Array.map s_pat pl))) ^ ")" let rec s_pat_vec pl = String.concat " " (Array.to_list (Array.map s_pat pl)) let rec s_pat_matrix pmat = String.concat "\n" (List.map (fun (pl,out) -> (s_pat_vec pl) ^ "->" ^ "") pmat) let st_args l r v = (if l > 0 then (String.concat "," (ExtList.List.make l "_")) ^ "," else "") ^ v ^ (if r > 0 then "," ^ (String.concat "," (ExtList.List.make r "_")) else "") let rec s_st st = (match st.st_def with | SVar v -> v.v_name | SEnum (st,ef,i) -> s_st st ^ "." ^ ef.ef_name ^ "." ^ (string_of_int i) | SArray (st,i) -> s_st st ^ "[" ^ (string_of_int i) ^ "]" | STuple (st,i,a) -> "(" ^ (st_args i (a - i - 1) (s_st st)) ^ ")" | SField (st,cf) -> s_st st ^ "." ^ cf.cf_name) (* Pattern parsing *) let unify_enum_field en pl ef t = let t2 = match follow ef.ef_type with | TFun(_,r) -> r | t2 -> t2 in let t2 = (apply_params en.e_params pl (monomorphs ef.ef_params t2)) in Type.unify t2 t let unify ctx a b p = try unify_raise ctx a b p with Error (Unify l,p) -> error (error_msg (Unify l)) p let rec is_value_type = function | TMono r -> (match !r with None -> false | Some t -> is_value_type t) | TType (t,tl) -> is_value_type (apply_params t.t_params tl t.t_type) | TInst({cl_path=[],"String"},[]) -> true | TAbstract _ -> true | _ -> false (* Determines if a type allows null-matching. This is similar to is_nullable, but it infers Null on monomorphs *) let rec matches_null ctx t = match t with | TMono r -> (match !r with None -> r := Some (ctx.t.tnull (mk_mono())); true | Some t -> matches_null ctx t) | TType ({ t_path = ([],"Null") },[_]) -> true | TLazy f -> matches_null ctx (!f()) | TType (t,tl) -> matches_null ctx (apply_params t.t_params tl t.t_type) | TFun _ -> false | TAbstract (a,_) -> not (Meta.has Meta.NotNull a.a_meta) | _ -> true let to_pattern ctx e t = let perror p = error "Unrecognized pattern" p in let verror n p = error ("Variable " ^ n ^ " must appear exactly once in each sub-pattern") p in let mk_var tctx s t p = let v = match tctx.pc_sub_vars with | Some vmap -> fst (try PMap.find s vmap with Not_found -> verror s p) | None -> alloc_var s t in unify ctx t v.v_type p; if PMap.mem s tctx.pc_locals then verror s p; tctx.pc_locals <- PMap.add s (v,p) tctx.pc_locals; v in let check_texpr_pattern e t p = let ec = match Optimizer.make_constant_expression ctx ~concat_strings:true e with Some e -> e | None -> e in match ec.eexpr with | TField (_,FEnum (en,ef)) -> begin try unify_raise ctx ec.etype t ec.epos with Error (Unify _,_) -> raise Not_found end; begin try unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_params) ef t; with Unify_error l -> error (error_msg (Unify l)) p end; mk_con_pat (CEnum(en,ef)) [] t p | TConst c | TCast({eexpr = TConst c},None) -> begin try unify_raise ctx ec.etype t ec.epos with Error (Unify _,_) -> raise Not_found end; unify ctx ec.etype t p; mk_con_pat (CConst c) [] t p | TTypeExpr mt -> mk_type_pat ctx mt t p | _ -> raise Not_found in let rec loop pctx e t = let p = pos e in match fst e with | ECheckType(e, CTPath({tpackage=["haxe";"macro"]; tname="Expr"})) -> let old = pctx.pc_reify in pctx.pc_reify <- true; let e = loop pctx e t in pctx.pc_reify <- old; e | EParenthesis e -> loop pctx e t | ECast(e1,None) -> loop pctx e1 t | EConst(Ident "null") -> if not (matches_null ctx t) then error ("Null-patterns are only allowed on nullable types (found " ^ (s_type t) ^ ")") p; mk_con_pat (CConst TNull) [] t p | EConst((Ident ("false" | "true") | Int _ | String _ | Float _) as c) -> let e = Codegen.type_constant ctx.com c p in unify ctx e.etype t p; let c = match e.eexpr with TConst c -> c | _ -> assert false in mk_con_pat (CConst c) [] t p | EMeta((Meta.Macro,[],_),(ECall (e1,args),_)) -> let path, field, args = Codegen.get_macro_path ctx e1 args p in begin match ctx.g.do_macro ctx MExpr path field args p with | Some e -> loop pctx e t | None -> error "Macro failure" p end | EField _ -> let e = type_expr ctx e (WithType t) in let e = match Optimizer.make_constant_expression ctx ~concat_strings:true e with Some e -> e | None -> e in (match e.eexpr with | TConst c | TCast({eexpr = TConst c},None) -> mk_con_pat (CConst c) [] t p | TTypeExpr mt -> mk_type_pat ctx mt t p | TField(_, FStatic(_,cf)) when is_value_type cf.cf_type -> ignore (follow cf.cf_type); begin match cf.cf_expr with | Some e -> (try check_texpr_pattern e t p with Not_found -> mk_con_pat (CExpr e) [] cf.cf_type p) | None -> mk_con_pat (CExpr e) [] cf.cf_type p end | TField(_, FEnum(en,ef)) -> begin try unify_enum_field en (List.map (fun _ -> mk_mono()) en.e_params) ef t with Unify_error l -> error (error_msg (Unify l)) p end; mk_con_pat (CEnum(en,ef)) [] t p | _ -> error "Constant expression expected" p) | ECall(ec,el) -> let ec = type_expr ctx ec (WithType t) in (match follow ec.etype with | TEnum(en,pl) | TFun(_,TEnum(en,pl)) -> let ef = match ec.eexpr with | TField (_,FEnum (_,f)) -> f | _ -> error ("Expected constructor for enum " ^ (s_type_path en.e_path)) p in let monos = List.map (fun _ -> mk_mono()) ef.ef_params in let tl,r = match apply_params en.e_params pl (apply_params ef.ef_params monos ef.ef_type) with | TFun(args,r) -> unify ctx r t p; List.map (fun (n,_,t) -> t) args,r | _ -> error "No arguments expected" p in let rec loop2 i el tl = match el,tl with | (EConst(Ident "_"),pany) :: [], t :: tl -> let pat = mk_pat PAny t_dynamic pany in (ExtList.List.make ((List.length tl) + 1) pat) | e :: el, t :: tl -> let pat = loop pctx e t in pat :: loop2 (i + 1) el tl | e :: _, [] -> error "Too many arguments" (pos e); | [],_ :: _ -> error "Not enough arguments" p; | [],[] -> [] in let el = loop2 0 el tl in List.iter2 (fun m (_,t) -> match follow m with TMono _ -> Type.unify m t | _ -> ()) monos ef.ef_params; pctx.pc_is_complex <- true; mk_con_pat (CEnum(en,ef)) el r p | _ -> perror p) | EConst(Ident "_") -> begin match get_tuple_params t with | Some tl -> let pl = List.map (fun (_,_,t) -> mk_any t p) tl in mk_pat (PTuple (Array.of_list pl)) t_dynamic p | None -> mk_any t p end | EConst(Ident s) -> begin try let ec = match follow t with | TEnum(en,pl) -> let ef = try PMap.find s en.e_constrs with Not_found when not (is_lower_ident s) -> error (string_error s en.e_names ("Expected constructor for enum " ^ (s_type_path en.e_path))) p in (match ef.ef_type with | TFun (args,_) -> let msg = Printf.sprintf "Enum constructor %s.%s requires parameters %s" (s_type_path en.e_path) ef.ef_name (String.concat ", " (List.map (fun (n,_,t) -> n ^ ":" ^ (s_type t)) args)) in error msg p | _ -> ()); let et = mk (TTypeExpr (TEnumDecl en)) (TAnon { a_fields = PMap.empty; a_status = ref (EnumStatics en) }) p in mk (TField (et,FEnum (en,ef))) (apply_params en.e_params pl ef.ef_type) p | TAbstract({a_impl = Some c} as a,_) when Meta.has Meta.Enum a.a_meta -> let cf = PMap.find s c.cl_statics in Type.unify (follow cf.cf_type) t; let e = begin match cf.cf_expr with | Some ({eexpr = TConst c | TCast({eexpr = TConst c},None)} as e) -> e | _ -> raise Not_found end in e | _ -> let old = ctx.untyped in ctx.untyped <- true; let e = try type_expr ctx e (WithType t) with _ -> ctx.untyped <- old; raise Not_found in ctx.untyped <- old; e in check_texpr_pattern ec t p with Not_found -> begin match get_tuple_params t with | Some tl -> let s = String.concat "," (List.map (fun (_,_,t) -> s_type t) tl) in error ("Pattern should be tuple [" ^ s ^ "]") p | None -> if not (is_lower_ident s) && s.[0] <> '`' then error "Capture variables must be lower-case" p; let v = mk_var pctx s t p in mk_pat (PVar (v,p)) v.v_type p end end | (EObjectDecl fl) -> let is_matchable cf = match cf.cf_kind with Method _ -> false | _ -> true in let is_valid_field_name fields co n p = try let cf = PMap.find n fields in begin match co with | Some c when not (Typer.can_access ctx c cf false) -> error ("Cannot match against private field " ^ n) p | _ -> () end with Not_found -> error ((s_type t) ^ " has no field " ^ n ^ " that can be matched against") p; in pctx.pc_is_complex <- true; let loop_fields fields = let sl,pl,i = PMap.foldi (fun n cf (sl,pl,i) -> if not (is_matchable cf) then sl,pl,i else let pat = try if pctx.pc_reify && cf.cf_name = "pos" then raise Not_found; loop pctx (List.assoc cf.cf_name fl) cf.cf_type with Not_found -> (mk_any cf.cf_type p) in (n,cf) :: sl,pat :: pl,i + 1 ) fields ([],[],0) in mk_con_pat (CFields(i,sl)) pl t p in let fields = match follow t with | TAnon {a_fields = fields} -> fields | TInst(c,tl) -> let fields = ref PMap.empty in let rec loop c tl = begin match c.cl_super with | Some (csup,tlsup) -> loop csup (List.map (apply_params c.cl_params tl) tlsup) | None -> () end; PMap.iter (fun n cf -> fields := PMap.add n {cf with cf_type = apply_params c.cl_params tl (monomorphs cf.cf_params cf.cf_type)} !fields) c.cl_fields in loop c tl; !fields | TAbstract({a_impl = Some c} as a,tl) -> let fields = List.fold_left (fun acc cf -> if Meta.has Meta.Impl cf.cf_meta then PMap.add cf.cf_name cf acc else acc ) PMap.empty c.cl_ordered_statics in PMap.map (fun cf -> {cf with cf_type = apply_params a.a_params tl (monomorphs cf.cf_params cf.cf_type)}) fields | _ -> error ((s_type t) ^ " cannot be matched against a structure") p in List.iter (fun (n,(_,p)) -> is_valid_field_name fields None n p) fl; loop_fields fields | EArrayDecl [] -> mk_con_pat (CArray 0) [] t p | EArrayDecl el -> pctx.pc_is_complex <- true; begin match follow t with | TInst({cl_path=[],"Array"},[t2]) | (TDynamic _ as t2) -> let pl = ExtList.List.mapi (fun i e -> loop pctx e t2 ) el in mk_con_pat (CArray (List.length el)) pl t p | TFun(tl,tr) when tr == fake_tuple_type -> let pl = try List.map2 (fun e (_,_,t) -> loop pctx e t) el tl with Invalid_argument _ -> error ("Invalid number of arguments: expected " ^ (string_of_int (List.length tl)) ^ ", found " ^ (string_of_int (List.length el))) p in mk_pat (PTuple (Array.of_list pl)) t p | _ -> error ((s_type t) ^ " should be Array") p end | EBinop(OpAssign,(EConst(Ident s),p2),e1) -> let v = mk_var pctx s t p in let pat1 = loop pctx e1 t in mk_pat (PBind((v,p),pat1)) t p2 | EBinop(OpOr,(EBinop(OpOr,e1,e2),p2),e3) -> loop pctx (EBinop(OpOr,e1,(EBinop(OpOr,e2,e3),p2)),p) t | EBinop(OpOr,e1,e2) -> let old = pctx.pc_locals in let pat1 = loop pctx e1 t in begin match pat1.p_def with | PAny | PVar _ -> display_error ctx "This pattern is unused" (pos e2); pat1 | _ -> let pctx2 = { pc_sub_vars = Some pctx.pc_locals; pc_locals = old; pc_reify = pctx.pc_reify; pc_is_complex = pctx.pc_is_complex; } in let pat2 = loop pctx2 e2 t in pctx.pc_is_complex <- pctx2.pc_is_complex; PMap.iter (fun s (_,p) -> if not (PMap.mem s pctx2.pc_locals) then verror s p) pctx.pc_locals; mk_pat (POr(pat1,pat2)) pat2.p_type (punion pat1.p_pos pat2.p_pos); end | _ -> raise (Unrecognized_pattern e) in let pctx = { pc_locals = PMap.empty; pc_sub_vars = None; pc_reify = false; pc_is_complex = false; } in let x = loop pctx e t in x, pctx.pc_locals, pctx.pc_is_complex let get_pattern_locals ctx e t = try let _,locals,_ = to_pattern ctx e t in PMap.foldi (fun n v acc -> PMap.add n v acc) locals PMap.empty with Unrecognized_pattern _ -> PMap.empty (* Match compilation *) let expr_eq e1 e2 = e1 == e2 || match e1.eexpr,e2.eexpr with | TConst ct1,TConst ct2 -> ct1 = ct2 | TField(_,FStatic(c1,cf1)),TField(_,FStatic(c2,cf2)) -> c1 == c2 && cf1.cf_name = cf2.cf_name | _ -> false let unify_con con1 con2 = match con1.c_def,con2.c_def with | CExpr e1, CExpr e2 -> expr_eq e1 e2 | CConst c1,CConst c2 -> c1 = c2 | CEnum(e1,ef1),CEnum(e2,ef2) -> e1 == e2 && ef1.ef_name = ef2.ef_name | CFields (i1,fl1),CFields (i2,fl2) -> (try List.iter (fun (s,_) -> if not (List.mem_assoc s fl1) then raise Not_found) fl2; true with Not_found -> false) | CType mt1,CType mt2 -> t_path mt1 = t_path mt2 | CArray a1, CArray a2 -> a1 == a2 | CAny, CAny -> true | _ -> false let array_tl arr = Array.sub arr 1 (Array.length arr - 1) let spec mctx con pmat = let a = arity con in let r = DynArray.create () in let add pv out = DynArray.add r (pv,out) in let rec loop2 pv out = match pv.(0).p_def with | PCon(c2,pl) when unify_con c2 con -> add (Array.append (Array.of_list pl) (array_tl pv)) out | PCon(c2,pl) -> () | PAny | PVar _-> add (Array.append (Array.make a (mk_any (pv.(0).p_type) (pv.(0).p_pos))) (array_tl pv)) out | PBind(_,pat) -> loop2 (Array.append [|pat|] (array_tl pv)) out | PTuple tl -> loop2 tl out | POr _ -> assert false in let rec loop pmat = match pmat with | (pv,out) :: pl -> loop2 pv out; loop pl | [] -> () in loop pmat; DynArray.to_list r let default mctx pmat = let r = DynArray.create () in let add pv out = DynArray.add r (pv,out) in let rec loop2 pv out = match pv.(0).p_def with | PCon _ -> () | PAny | PVar _-> add (array_tl pv) out | PBind(_,pat) -> loop2 (Array.append [|pat|] (array_tl pv)) out | PTuple tl -> loop2 tl out | POr _ -> assert false in let rec loop pmat = match pmat with | (pv,out) :: pl -> loop2 pv out; loop pl; | [] -> () in loop pmat; DynArray.to_list r let pick_column pmat = let rec loop i pv = if Array.length pv = 0 then -1 else match pv.(0).p_def with | PVar _ | PAny -> loop (i + 1) (array_tl pv) | PTuple pl -> loop i pl | _ -> i in loop 0 (fst (List.hd pmat)) let swap_pmat_columns i pmat = List.map (fun (pv,out) -> let pv = match pv with [|{p_def = PTuple pt}|] -> pt | _ -> pv in let tmp = pv.(i) in Array.set pv i pv.(0); Array.set pv 0 tmp; pv,out ) pmat let swap_columns i (row : 'a list) : 'a list = match row with | rh :: rt -> let rec loop count acc col = match col with | [] -> acc | ch :: cl when i = count -> ch :: (List.rev acc) @ [rh] @ cl | ch :: cl -> loop (count + 1) (ch :: acc) cl in loop 1 [] rt | _ -> [] let expand_or mctx (pmat : pat_matrix) = let rec loop pat = match pat.p_def with | POr(pat1,pat2) -> let pat1 = loop pat1 in let pat2 = loop pat2 in pat1 @ pat2 | PBind(v,pat1) -> let pat1 = loop pat1 in List.map (fun pat1 -> {pat with p_def = PBind(v,pat1)} ) pat1 | PTuple(pl) -> let pat1 = loop pl.(0) in List.map (fun pat1 -> let a1 = Array.copy pl in a1.(0) <- pat1; {pat with p_def = PTuple a1} ) pat1 | _ -> [pat] in let rec loop2 pmat = match pmat with | (pv,out) :: pmat -> let pat = loop pv.(0) in let pat' = ExtList.List.mapi (fun i pat -> (* TODO: This should really be active, but currently causes problems with or-patterns in tuples (issue #2610). We will disable this for the 3.1.0 release, which means issue #2508 is open again. *) (* let out = if i = 0 then out else clone_out mctx out pat.p_pos in *) let a1 = Array.copy pv in a1.(0) <- pat; a1,out ) pat in pat' @ (loop2 pmat) | [] -> [] in loop2 pmat let column_sigma mctx st pmat = let acc = ref [] in let bindings = ref [] in let unguarded = Hashtbl.create 0 in let add c g = if not (List.exists (fun c2 -> unify_con c2 c) !acc) then acc := c :: !acc; if not g then Hashtbl.replace unguarded c.c_def true; in let bind_st out st v = if not (List.exists (fun ((v2,p),_) -> v2.v_id == (fst v).v_id) !bindings) then bindings := (v,st) :: !bindings in let rec loop pmat = match pmat with | (pv,out) :: pr -> let rec loop2 out = function | PCon (c,_) -> add c ((get_guard mctx out.o_id) <> None); | PVar v -> bind_st out st v; | PBind(v,pat) -> bind_st out st v; loop2 out pat.p_def | PAny -> () | PTuple tl -> loop2 out tl.(0).p_def | POr _ -> assert false in loop2 out pv.(0).p_def; loop pr | [] -> () in loop pmat; List.rev_map (fun con -> con,not (Hashtbl.mem unguarded con.c_def)) !acc,!bindings let rec all_ctors mctx t = let h = ref PMap.empty in if is_explicit_null t then h := PMap.add (CConst TNull) Ast.null_pos !h; match follow t with | TAbstract({a_path = [],"Bool"},_) -> h := PMap.add (CConst(TBool true)) Ast.null_pos !h; h := PMap.add (CConst(TBool false)) Ast.null_pos !h; h,RunTimeFinite | TAbstract({a_impl = Some c} as a,pl) when Meta.has Meta.Enum a.a_meta -> List.iter (fun cf -> ignore(follow cf.cf_type); if Meta.has Meta.Impl cf.cf_meta then match cf.cf_expr with | Some {eexpr = TConst c | TCast ({eexpr = TConst c},None)} -> h := PMap.add (CConst c) cf.cf_pos !h | _ -> () ) c.cl_ordered_statics; h,CompileTimeFinite | TAbstract(a,pl) when not (Meta.has Meta.CoreType a.a_meta) -> all_ctors mctx (Abstract.get_underlying_type a pl) | TInst({cl_path=[],"String"},_) | TInst({cl_path=[],"Array"},_) -> h,Infinite | TEnum(en,pl) -> PMap.iter (fun _ ef -> let tc = monomorphs mctx.ctx.type_params t in try unify_enum_field en pl ef tc; h := PMap.add (CEnum(en,ef)) ef.ef_pos !h with Unify_error _ -> () ) en.e_constrs; h,RunTimeFinite | TAnon a -> h,CompileTimeFinite | TInst(_,_) -> h,CompileTimeFinite | _ -> h,Infinite let rec collapse_pattern pl = match pl with | pat :: [] -> pat | pat :: pl -> let pat2 = collapse_pattern pl in mk_pat (POr(pat,pat2)) pat.p_type (punion pat.p_pos pat2.p_pos) | [] -> assert false let bind_remaining out pv stl = let rec loop stl pv = if Array.length pv = 0 then [] else match stl,pv.(0).p_def with | st :: stl,PAny -> loop stl (array_tl pv) | st :: stl,PVar v -> (v,st) :: loop stl (array_tl pv) | stl,PTuple pl -> loop stl pl | _ :: _,_-> loop stl (array_tl pv) | [],_ -> [] in loop stl pv let get_cache mctx dt = match dt with Goto _ -> dt | _ -> try Goto (Hashtbl.find mctx.dt_cache dt) with Not_found -> Hashtbl.replace mctx.dt_cache dt mctx.dt_count; mctx.dt_count <- mctx.dt_count + 1; DynArray.add mctx.dt_lut dt; dt let rec compile mctx stl pmat toplevel = let guard id dt1 dt2 = get_cache mctx (Guard(id,dt1,dt2)) in let expr id = get_cache mctx (Expr id) in let bind bl dt = get_cache mctx (Bind(bl,dt)) in let switch st cl = get_cache mctx (Switch(st,cl)) in get_cache mctx (match pmat with | [] -> (match stl with | st :: stl -> let all,inf = all_ctors mctx st.st_type in let pl = PMap.foldi (fun cd p acc -> (mk_con_pat cd [] t_dynamic p) :: acc) !all [] in begin match pl,inf with | _,Infinite | [],_ -> raise (Not_exhaustive(any,st)) | _ -> raise (Not_exhaustive(collapse_pattern pl,st)) end | _ -> (* This can happen in cases a value is required and all default cases are guarded (issue #3150). Not a particularly elegant solution, may want to revisit this later. *) raise Exit) | ([|{p_def = PTuple pt}|],out) :: pl -> compile mctx stl ((pt,out) :: pl) toplevel | (pv,out) :: pl -> let i = pick_column pmat in if i = -1 then begin out.o_num_paths <- out.o_num_paths + 1; let bl = bind_remaining out pv stl in let dt = match (get_guard mctx out.o_id) with | None -> expr out.o_id | Some _ -> let dt = match pl,mctx.need_val with | [],false -> None | _ -> Some (compile mctx stl pl false) in guard out.o_id (expr out.o_id) dt in (if bl = [] then dt else bind bl dt) end else if i > 0 then begin let pmat = swap_pmat_columns i pmat in let stls = swap_columns i stl in compile mctx stls pmat toplevel end else begin let st_head,st_tail = match stl with st :: stl -> st,stl | _ -> assert false in let pmat = expand_or mctx pmat in let sigma,bl = column_sigma mctx st_head pmat in let all,inf = all_ctors mctx pv.(0).p_type in let cases = List.map (fun (c,g) -> if not g then all := PMap.remove c.c_def !all; let spec = spec mctx c pmat in let hsubs = mk_subs st_head c in let subs = hsubs @ st_tail in let dt = compile mctx subs spec false in c,dt ) sigma in let def = default mctx pmat in let dt = match def,cases with | _ when inf = RunTimeFinite && PMap.is_empty !all -> switch st_head cases | [],_ when inf = CompileTimeFinite && PMap.is_empty !all -> switch st_head cases | [],_ when inf = Infinite && not mctx.need_val && toplevel -> (* ignore exhaustiveness, but mark context so we do not generate @:exhaustive metadata *) mctx.is_exhaustive <- false; switch st_head cases | [],_ when inf = Infinite -> raise (Not_exhaustive(any,st_head)) | [],_ -> let pl = PMap.foldi (fun cd p acc -> (mk_con_pat cd [] t_dynamic p) :: acc) !all [] in (* toplevel null can be omitted because the French dig runtime errors (issue #3054) *) if toplevel && (match pl with | [{p_def = PCon ({c_def = (CConst TNull)},_)}] -> true | _ -> false) then switch st_head cases else raise (Not_exhaustive(collapse_pattern pl,st_head)) | def,[] -> compile mctx st_tail def false | def,_ -> let cdef = mk_con CAny t_dynamic st_head.st_pos in let def = try compile mctx st_tail def false with Exit -> raise (Not_exhaustive(any,st_head)) in let cases = cases @ [cdef,def] in switch st_head cases in if bl = [] then dt else bind bl dt end) let rec collapse_case el = match el with | e :: [] -> e | e :: el -> let e2 = collapse_case el in EBinop(OpOr,e,e2),punion (pos e) (pos e2) | [] -> assert false let mk_const ctx p = function | TString s -> mk (TConst (TString s)) ctx.com.basic.tstring p | TInt i -> mk (TConst (TInt i)) ctx.com.basic.tint p | TFloat f -> mk (TConst (TFloat f)) ctx.com.basic.tfloat p | TBool b -> mk (TConst (TBool b)) ctx.com.basic.tbool p | TNull -> mk (TConst TNull) (ctx.com.basic.tnull (mk_mono())) p | _ -> error "Unsupported constant" p let rec convert_st ctx st = match st.st_def with | SVar v -> mk (TLocal v) v.v_type st.st_pos | SField (sts,cf) -> let e = convert_st ctx sts in Typer.acc_get ctx (Typer.type_field ctx e cf.cf_name st.st_pos Typer.MGet) st.st_pos | SArray (sts,i) -> mk (TArray(convert_st ctx sts,mk_const ctx st.st_pos (TInt (Int32.of_int i)))) st.st_type st.st_pos | STuple (st,_,_) -> convert_st ctx st | SEnum (sts,ef,i) -> mk (TEnumParameter(convert_st ctx sts, ef, i)) st.st_type st.st_pos let convert_con ctx con = match con.c_def with | CConst c -> mk_const ctx con.c_pos c | CType mt -> mk (TTypeExpr mt) t_dynamic con.c_pos | CExpr e -> e | CEnum(e,ef) -> mk_const ctx con.c_pos (TInt (Int32.of_int ef.ef_index)) | CArray i -> mk_const ctx con.c_pos (TInt (Int32.of_int i)) | CAny | CFields _ -> assert false let convert_switch mctx st cases loop = let ctx = mctx.ctx in let e_st = convert_st ctx st in let p = e_st.epos in let mk_index_call () = let ttype = match follow (Typeload.load_instance ctx { tpackage = ["std"]; tname="Type"; tparams=[]; tsub = None} p true) with TInst(c,_) -> c | t -> assert false in let cf = PMap.find "enumIndex" ttype.cl_statics in let ec = (!type_module_type_ref) ctx (TClassDecl ttype) None p in let ef = mk (TField(ec, FStatic(ttype,cf))) (tfun [e_st.etype] ctx.t.tint) p in let e = make_call ctx ef [e_st] ctx.t.tint p in e in let wrap_exhaustive e = if mctx.is_exhaustive then mk (TMeta((Meta.Exhaustive,[],e.epos),e)) e.etype e.epos else e in let e = match follow st.st_type with | TEnum(_) -> wrap_exhaustive (mk_index_call()) | TAbstract(a,pl) when (match Abstract.get_underlying_type a pl with TEnum(_) -> true | _ -> false) -> wrap_exhaustive (mk_index_call()) | TInst({cl_path = [],"Array"},_) as t -> mk (TField (e_st,quick_field t "length")) ctx.t.tint p | TAbstract(a,_) when Meta.has Meta.Enum a.a_meta -> wrap_exhaustive (e_st) | TAbstract({a_path = [],"Bool"},_) -> wrap_exhaustive (e_st) | _ -> let rec loop cases = match cases with | [] -> e_st | (con,_) :: cases -> begin match con.c_def with | CEnum _ -> mk_index_call() | CArray _ -> mk (TField (e_st,FDynamic "length")) ctx.t.tint p | _ -> loop cases end in loop cases in let null = ref None in let def = ref None in let cases = List.filter (fun (con,dt) -> match con.c_def with | CConst TNull -> null := Some (loop dt); false | CAny -> def := Some (loop dt); false | _ -> true ) cases in let dt = match cases with | [{c_def = CFields _},dt] -> loop dt | _ -> DTSwitch(e, List.map (fun (c,dt) -> convert_con ctx c, loop dt) cases, !def) in match !null with | None when is_explicit_null st.st_type && (!def <> None || not mctx.need_val) -> let econd = mk (TBinop(OpNotEq,e_st,mk (TConst TNull) st.st_type p)) ctx.t.tbool p in DTGuard(econd,dt,!def) | None -> dt | Some dt_null -> let t = match ctx.t.tnull ctx.t.tint with | TType(t,_) ->TType(t,[st.st_type]) | t -> t in let e_null = mk (TConst TNull) t p in let econd = mk (TBinop(OpEq,e_st, e_null)) ctx.t.tbool p in DTGuard(econd,dt_null,Some dt) (* Decision tree compilation *) let transform_extractors eval cases p = let efail = (EThrow(EConst(Ident "false"),p)),p in let cfail = [(EConst (Ident "_"),p)],None,Some efail in let has_extractor = ref false in let rec loop cases = match cases with | (epat,eg,e) :: cases -> let ex = ref [] in let exc = ref 0 in let rec find_ex in_or e = match fst e with | EBinop(OpArrow,_,_) when in_or -> error "Extractors in or patterns are not allowed" (pos e) | EBinop(OpArrow, e1, e2) -> let ec = EConst (Ident ("__ex" ^ string_of_int (!exc))),snd e in let rec map_left e = match fst e with | EConst(Ident "_") -> ec | _ -> Ast.map_expr map_left e in let ecall = map_left e1 in ex := (ecall,e2) :: !ex; incr exc; has_extractor := true; ec | EBinop(OpOr,e1,e2) -> let e1 = find_ex true e1 in let e2 = find_ex true e2 in (EBinop(OpOr,e1,e2)),(pos e) | _ -> Ast.map_expr (find_ex in_or) e in let p = match e with None -> p | Some e -> pos e in let epat = match epat with | [epat] -> [find_ex false epat] | _ -> List.map (find_ex true) epat in let cases = loop cases in if !exc = 0 then (epat,eg,e) :: cases else begin let esubjects = EArrayDecl (List.map fst !ex),p in let case1 = [EArrayDecl (List.map snd !ex),p],eg,e in let cases2 = match cases with | [] -> [case1] | [[EConst (Ident "_"),_],_,e] -> case1 :: [[(EConst (Ident "_"),p)],None,e] | _ -> case1 :: [[(EConst (Ident "_"),p)],None,Some (ESwitch(eval,cases,None),p)] in let eswitch = (ESwitch(esubjects,cases2,None)),p in let case = epat,None,Some eswitch in begin match epat with | [EConst(Ident _),_] -> [case;cfail] | _ -> case :: cases end end | [] -> [] in let cases = loop cases in cases,!has_extractor let extractor_depth = ref 0 let match_expr ctx e cases def with_type p = let need_val,with_type,tmono = match with_type with | NoValue -> false,NoValue,None | WithType t | WithTypeResume t when (match follow t with TMono _ -> true | _ -> false) -> (* we don't want to unify with each case individually, but instead at the end after unify_min *) true,Value,Some with_type | t -> true,t,None in (* turn default into case _ *) let cases = match cases,def with | [],None -> [] | cases,Some def -> let p = match def with | None -> p | Some (_,p) -> p in cases @ [[(EConst(Ident "_")),p],None,def] | _ -> cases in let cases,has_extractor = transform_extractors e cases p in (* type subject(s) *) let array_match = ref false in let evals = match fst e with | EArrayDecl el | EParenthesis(EArrayDecl el,_) when (match el with [(EFor _ | EWhile _),_] -> false | _ -> true) -> array_match := true; List.map (fun e -> type_expr ctx e Value) el | _ -> let e = type_expr ctx e Value in begin match follow e.etype with (* TODO: get rid of the XmlType check *) | TEnum(en,_) when (match en.e_path with (["neko" | "php" | "flash" | "cpp"],"XmlType") -> true | _ -> Meta.has Meta.FakeEnum en.e_meta) -> raise Exit | TAbstract({a_path=[],("Int" | "Float" | "Bool")},_) | TInst({cl_path = [],"String"},_) when (Common.defined ctx.com Common.Define.NoPatternMatching) -> raise Exit; | _ -> () end; [e] in let var_inits = ref [] in let save = save_locals ctx in let a = List.length evals in (* turn subjects to subterms and handle variable initialization where necessary *) let stl = ExtList.List.mapi (fun i e -> let rec loop e = match e.eexpr with | TParenthesis e | TMeta(_,e) -> loop e | TLocal v -> mk_st (SVar v) e.etype e.epos | _ -> let v = gen_local ctx e.etype in var_inits := (v, Some e) :: !var_inits; ctx.locals <- PMap.add v.v_name v ctx.locals; mk_st (SVar v) e.etype e.epos in let st = loop e in if a = 1 then st else mk_st (STuple(st,i,a)) st.st_type st.st_pos ) evals in let tl = List.map (fun st -> st.st_type) stl in (* create matcher context *) let mctx = { ctx = ctx; need_val = need_val; outcomes = []; toplevel_or = false; dt_lut = DynArray.create (); dt_cache = Hashtbl.create 0; dt_count = 0; has_extractor = has_extractor; expr_map = PMap.empty; is_exhaustive = true; } in (* flatten cases *) let cases = List.map (fun (el,eg,e) -> List.iter (fun e -> match fst e with EBinop(OpOr,_,_) -> mctx.toplevel_or <- true; | _ -> ()) el; match el with | [] -> let p = match e with None -> p | Some e -> pos e in error "case without a pattern is not allowed" p | _ -> collapse_case el,eg,e ) cases in let is_complex = ref false in if mctx.has_extractor then incr extractor_depth; let add_pattern_locals (pat,locals,complex) = PMap.iter (fun n (v,p) -> ctx.locals <- PMap.add n v ctx.locals) locals; if complex then is_complex := true; pat in (* evaluate patterns *) let pl = ExtList.List.mapi (fun i (ep,eg,e) -> let save = save_locals ctx in (* type case patterns *) let pl,restore,with_type = try (* context type parameters are turned into monomorphs until the pattern has been typed *) let monos = List.map (fun _ -> mk_mono()) ctx.type_params in let t = match tl with [t] when not !array_match -> t | tl -> tfun tl fake_tuple_type in let t = apply_params ctx.type_params monos t in let pl = [add_pattern_locals (to_pattern ctx ep t)] in let old_ret = ctx.ret in ctx.ret <- apply_params ctx.type_params monos ctx.ret; let restore = PMap.fold (fun v acc -> (* apply context monomorphs to locals and replace them back after typing the case body *) let t = v.v_type in v.v_type <- apply_params ctx.type_params monos v.v_type; (fun () -> v.v_type <- t) :: acc ) ctx.locals [fun() -> ctx.ret <- old_ret] in (* turn any still unknown types back to type parameters *) List.iter2 (fun m (_,t) -> match follow m with TMono _ -> Type.unify m t | _ -> ()) monos ctx.type_params; pl,restore,(match with_type with | WithType t -> WithType (apply_params ctx.type_params monos t) | WithTypeResume t -> WithTypeResume (apply_params ctx.type_params monos t) | _ -> with_type); with Unrecognized_pattern (e,p) -> error "Case expression must be a constant value or a pattern, not an arbitrary expression" p in let is_catch_all = match pl with | [{p_def = PAny | PVar _}] -> true | _ -> false in (* type case body *) let e = match e with | None -> mk (TBlock []) ctx.com.basic.tvoid (pos ep) | Some e -> type_expr ctx e with_type in let e = match with_type with | WithType t -> Codegen.AbstractCast.cast_or_unify ctx t e e.epos; | WithTypeResume t -> (try Codegen.AbstractCast.cast_or_unify_raise ctx t e e.epos with Error (Unify l,p) -> raise (Typer.WithTypeError (l,p))); | _ -> e in (* type case guard *) let eg = match eg with | None -> None | Some e -> let eg = type_expr ctx e (WithType ctx.com.basic.tbool) in unify ctx eg.etype ctx.com.basic.tbool eg.epos; Some eg in List.iter (fun f -> f()) restore; save(); let out = mk_out mctx i e eg is_catch_all (pos ep) in Array.of_list pl,out ) cases in let check_unused () = let unused p = display_error ctx "This pattern is unused" p; let old_error = ctx.on_error in ctx.on_error <- (fun ctx s p -> ctx.on_error <- old_error; raise Exit); let check_expr e p = try begin match fst e with | EConst(Ident ("null" | "true" | "false")) -> () | EConst(Ident _) -> ignore (type_expr ctx e Value); display_error ctx "Case expression must be a constant value or a pattern, not an arbitrary expression" (pos e) | _ -> () end with Exit -> () in let rec loop prev cl = match cl with | (_,Some _,_) :: cl -> loop prev cl | ((e,p2),_,_) :: cl -> if p2.pmin >= p.pmin then check_expr prev p else loop (e,p2) cl | [] -> check_expr prev p in (match cases with (e,_,_) :: cl -> loop e cl | [] -> assert false); ctx.on_error <- old_error; in let had_catch_all = ref false in List.iter (fun out -> if out.o_catch_all && not !had_catch_all then had_catch_all := true else if out.o_num_paths = 0 then begin unused out.o_pos; if mctx.toplevel_or then begin match evals with | [{etype = t}] when (match follow t with TAbstract({a_path=[],"Int"},[]) -> true | _ -> false) -> display_error ctx "Note: Int | Int is an or-pattern now" p; | _ -> () end; end ) (List.rev mctx.outcomes); in let dt = try (* compile decision tree *) compile mctx stl pl true with Not_exhaustive(pat,st) -> let rec s_st_r top pre st v = match st.st_def with | SVar v1 -> if not pre then v else begin try let e = match List.assoc v1 !var_inits with Some e -> e | None -> assert false in (Type.s_expr_pretty "" (Type.s_type (print_context())) e) ^ v with Not_found -> v1.v_name ^ v end | STuple(st,i,a) -> let r = a - i - 1 in Printf.sprintf "[%s]" (st_args i r (s_st_r top false st v)) | SArray(st,i) -> s_st_r false true st (Printf.sprintf "[%i]%s" i (if top then " = " ^ v else v)) | SField({st_def = SVar v1},cf) when v1.v_name.[0] = '`' -> cf.cf_name ^ (if top then " = " ^ v else v) | SField(st,cf) -> s_st_r false true st (Printf.sprintf ".%s%s" cf.cf_name (if top then " = " ^ v else v)) | SEnum(st,ef,i) -> let len = match follow ef.ef_type with TFun(args,_) -> List.length args | _ -> 0 in s_st_r false false st (Printf.sprintf "%s(%s)" ef.ef_name (st_args i (len - 1 - i) v)) in let pat = match follow st.st_type with | TAbstract({a_impl = Some cl} as a,_) when Meta.has Meta.Enum a.a_meta -> let rec s_pat pat = match pat.p_def with | PCon ({c_def = CConst c},[]) when c <> TNull -> let cf = List.find (fun cf -> match cf.cf_expr with | Some ({eexpr = TConst c2 | TCast({eexpr = TConst c2},None)}) -> c = c2 | _ -> false ) cl.cl_ordered_statics in cf.cf_name | PVar (v,_) -> v.v_name | PCon (c,[]) -> s_con c | PCon (c,pl) -> s_con c ^ "(" ^ (String.concat "," (List.map s_pat pl)) ^ ")" | POr (pat1,pat2) -> s_pat pat1 ^ " | " ^ s_pat pat2 | PAny -> "_" | PBind((v,_),pat) -> v.v_name ^ "=" ^ s_pat pat | PTuple pl -> "(" ^ (String.concat " " (Array.to_list (Array.map s_pat pl))) ^ ")" in s_pat pat | _ -> s_pat pat in let msg = "Unmatched patterns: " ^ (s_st_r true false st pat) in if !extractor_depth > 0 then begin display_error ctx msg st.st_pos; error "Note: Patterns with extractors may require a default pattern" st.st_pos; end else error msg st.st_pos in save(); (* check for unused patterns *) if !extractor_depth = 0 then check_unused(); if mctx.has_extractor then decr extractor_depth; (* determine type of switch statement *) let t = if not need_val then mk_mono() else match with_type with | WithType t | WithTypeResume t -> t | _ -> try Typer.unify_min_raise ctx (List.rev_map (fun (_,out) -> get_expr mctx out.o_id) (List.rev pl)) with Error (Unify l,p) -> error (error_msg (Unify l)) p in (* unify with expected type if necessary *) begin match tmono with | None -> () | Some (WithType t2) -> unify ctx t2 t p | Some (WithTypeResume t2) -> (try unify_raise ctx t2 t p with Error (Unify l,p) -> raise (Typer.WithTypeError (l,p))) | _ -> assert false end; (* count usage *) let usage = Array.make (DynArray.length mctx.dt_lut) 0 in (* we always want to keep the first part *) let first = (match dt with Goto i -> i | _ -> Hashtbl.find mctx.dt_cache dt) in Array.set usage first 2; let rec loop dt = match dt with | Goto i -> Array.set usage i ((Array.get usage i) + 1) | Switch(st,cl) -> List.iter (fun (_,dt) -> loop dt) cl | Bind(bl,dt) -> loop dt | Expr e -> () | Guard(e,dt1,dt2) -> loop dt1; match dt2 with None -> () | Some dt -> (loop dt) in DynArray.iter loop mctx.dt_lut; (* filter parts that will be inlined and keep a map to them*) let map = Array.make (DynArray.length mctx.dt_lut) 0 in let lut = DynArray.create() in let rec loop i c = if c < DynArray.length mctx.dt_lut then begin let i' = if usage.(c) > 1 then begin DynArray.add lut (DynArray.get mctx.dt_lut c); i + 1 end else i in Array.set map c i; loop i' (c + 1) end in loop 0 0; (* reindex *) let rec loop dt = match dt with | Goto i -> if usage.(i) > 1 then DTGoto (map.(i)) else loop (DynArray.get mctx.dt_lut i) | Switch(st,cl) -> convert_switch mctx st cl loop | Bind(bl,dt) -> DTBind(List.map (fun (v,st) -> v,convert_st ctx st) bl,loop dt) | Expr id -> DTExpr (get_expr mctx id) | Guard(id,dt1,dt2) -> DTGuard((match get_guard mctx id with Some e -> e | None -> assert false),loop dt1, match dt2 with None -> None | Some dt -> Some (loop dt)) in let lut = DynArray.map loop lut in { dt_first = map.(first); dt_dt_lookup = DynArray.to_array lut; dt_type = t; dt_var_init = List.rev !var_inits; dt_is_complex = !is_complex; } ;; match_expr_ref := match_expr; get_pattern_locals_ref := get_pattern_localshaxe_3.2.1+dfsg.orig/optimizer.ml0000664000175000017500000016273512607337712016716 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast open Type open Common open Typecore (* ---------------------------------------------------------------------- *) (* API OPTIMIZATIONS *) (* tells if an expression causes side effects. This does not account for potential null accesses (fields/arrays/ops) *) let has_side_effect e = let rec loop e = match e.eexpr with | TConst _ | TLocal _ | TTypeExpr _ | TFunction _ -> () | TCall ({ eexpr = TField(_,FStatic({ cl_path = ([],"Std") },{ cf_name = "string" })) },args) -> Type.iter loop e | TNew _ | TCall _ | TBinop ((OpAssignOp _ | OpAssign),_,_) | TUnop ((Increment|Decrement),_,_) -> raise Exit | TReturn _ | TBreak | TContinue | TThrow _ | TCast (_,Some _) -> raise Exit | TArray _ | TEnumParameter _ | TCast (_,None) | TBinop _ | TUnop _ | TParenthesis _ | TMeta _ | TWhile _ | TFor _ | TField _ | TIf _ | TTry _ | TSwitch _ | TArrayDecl _ | TBlock _ | TObjectDecl _ | TVar _ -> Type.iter loop e in try loop e; false with Exit -> true let mk_untyped_call name p params = { eexpr = TCall({ eexpr = TLocal(alloc_unbound_var name t_dynamic); etype = t_dynamic; epos = p }, params); etype = t_dynamic; epos = p; } let api_inline ctx c field params p = match c.cl_path, field, params with | ([],"Type"),"enumIndex",[{ eexpr = TField (_,FEnum (en,f)) }] -> (match ctx.com.platform with | Cs when en.e_extern && not (Meta.has Meta.HxGen en.e_meta) -> (* We don't want to optimize enums from external sources; as they might change unexpectedly *) (* and since native C# enums don't have the concept of index - they have rather a value, *) (* which can't be mapped to a native API - this kind of substitution is dangerous *) None | _ -> Some (mk (TConst (TInt (Int32.of_int f.ef_index))) ctx.t.tint p)) | ([],"Type"),"enumIndex",[{ eexpr = TCall({ eexpr = TField (_,FEnum (en,f)) },pl) }] when List.for_all (fun e -> not (has_side_effect e)) pl -> (match ctx.com.platform with | Cs when en.e_extern && not (Meta.has Meta.HxGen en.e_meta) -> (* see comment above *) None | _ -> Some (mk (TConst (TInt (Int32.of_int f.ef_index))) ctx.t.tint p)) | ([],"Std"),"int",[{ eexpr = TConst (TInt _) } as e] -> Some { e with epos = p } | ([],"String"),"fromCharCode",[{ eexpr = TConst (TInt i) }] when i > 0l && i < 128l -> Some (mk (TConst (TString (String.make 1 (char_of_int (Int32.to_int i))))) ctx.t.tstring p) | ([],"Std"),"string",[{ eexpr = TConst c } as e] -> (match c with | TString s -> Some { e with epos = p } | TInt i -> Some { eexpr = TConst (TString (Int32.to_string i)); epos = p; etype = ctx.t.tstring } | TBool b -> Some { eexpr = TConst (TString (if b then "true" else "false")); epos = p; etype = ctx.t.tstring } | _ -> None) | ([],"Std"),"string",[{ eexpr = TIf (_,{ eexpr = TConst (TString _)},Some { eexpr = TConst (TString _) }) } as e] -> Some e | ([],"Std"),"string",[{ eexpr = TLocal _ | TField({ eexpr = TLocal _ },_) } as v] when ctx.com.platform = Js || ctx.com.platform = Flash -> let pos = v.epos in let stringv() = let to_str = mk (TBinop (Ast.OpAdd, mk (TConst (TString "")) ctx.t.tstring pos, v)) ctx.t.tstring pos in if ctx.com.platform = Js || is_nullable v.etype then let chk_null = mk (TBinop (Ast.OpEq, v, mk (TConst TNull) t_dynamic pos)) ctx.t.tbool pos in mk (TIf (chk_null, mk (TConst (TString "null")) ctx.t.tstring pos, Some to_str)) ctx.t.tstring pos else to_str in (match follow v.etype with | TInst ({ cl_path = [],"String" }, []) -> Some (stringv()) | TAbstract ({ a_path = [],"Float" }, []) -> Some (stringv()) | TAbstract ({ a_path = [],"Int" }, []) -> Some (stringv()) | TAbstract ({ a_path = [],"UInt" }, []) -> Some (stringv()) | TAbstract ({ a_path = [],"Bool" }, []) -> Some (stringv()) | _ -> None) | ([],"Std"),"is",[o;t] | (["js"],"Boot"),"__instanceof",[o;t] when ctx.com.platform = Js -> let mk_local ctx n t pos = mk (TLocal (try PMap.find n ctx.locals with _ -> let v = add_local ctx n t in v.v_meta <- [Meta.Unbound,[],p]; v )) t pos in let tstring = ctx.com.basic.tstring in let tbool = ctx.com.basic.tbool in let tint = ctx.com.basic.tint in let is_trivial e = match e.eexpr with | TConst _ | TLocal _ -> true | _ -> false in let typeof t = let tof = mk_local ctx "__typeof__" (tfun [o.etype] tstring) p in let tof = mk (TCall (tof, [o])) tstring p in mk (TBinop (Ast.OpEq, tof, (mk (TConst (TString t)) tstring p))) tbool p in (match t.eexpr with (* generate simple typeof checks for basic types *) | TTypeExpr (TClassDecl ({ cl_path = [],"String" })) -> Some (typeof "string") | TTypeExpr (TAbstractDecl ({ a_path = [],"Bool" })) -> Some (typeof "boolean") | TTypeExpr (TAbstractDecl ({ a_path = [],"Float" })) -> Some (typeof "number") | TTypeExpr (TAbstractDecl ({ a_path = [],"Int" })) when is_trivial o -> (* generate (o|0) === o check *) let teq = mk_local ctx "__strict_eq__" (tfun [tint; tint] tbool) p in let lhs = mk (TBinop (Ast.OpOr, o, mk (TConst (TInt Int32.zero)) tint p)) tint p in Some (mk (TCall (teq, [lhs; o])) tbool p) | TTypeExpr (TClassDecl ({ cl_path = [],"Array" })) -> (* generate (o instanceof Array) && o.__enum__ == null check *) let iof = mk_local ctx "__instanceof__" (tfun [o.etype;t.etype] tbool) p in let iof = mk (TCall (iof, [o; t])) tbool p in let enum = mk (TField (o, FDynamic "__enum__")) (mk_mono()) p in let null = mk (TConst TNull) (mk_mono()) p in let not_enum = mk (TBinop (Ast.OpEq, enum, null)) tbool p in Some (mk (TBinop (Ast.OpBoolAnd, iof, not_enum)) tbool p) | _ -> None) | ([],"Std"),"int",[{ eexpr = TConst (TFloat f) }] -> let f = float_of_string f in (match classify_float f with | FP_infinite | FP_nan -> None | _ when f <= Int32.to_float Int32.min_int -. 1. || f >= Int32.to_float Int32.max_int +. 1. -> None (* out range, keep platform-specific behavior *) | _ -> Some { eexpr = TConst (TInt (Int32.of_float f)); etype = ctx.t.tint; epos = p }) | (["cs"],"Lib"),("fixed" | "checked" | "unsafe"),[e] -> Some (mk_untyped_call ("__" ^ field ^ "__") p [e]) | (["cs"],"Lib"),("lock"),[obj;block] -> Some (mk_untyped_call ("__lock__") p [obj;mk_block block]) | (["java"],"Lib"),("lock"),[obj;block] -> Some (mk_untyped_call ("__lock__") p [obj;mk_block block]) | (["cs" | "java"],"Lib"),("nativeArray"),[{ eexpr = TArrayDecl args } as edecl; _] | (["haxe";"ds";"_Vector"],"Vector_Impl_"),("fromArrayCopy"),[{ eexpr = TArrayDecl args } as edecl] -> (try let platf = match ctx.com.platform with | Cs -> "cs" | Java -> "java" | _ -> raise Exit in let mpath = if field = "fromArrayCopy" then (["haxe";"ds"],"Vector") else ([platf],"NativeArray") in let m = ctx.g.do_load_module ctx mpath null_pos in let main = List.find (function | TClassDecl _ | TAbstractDecl _ -> true | _ -> false) m.m_types in let t = match follow edecl.etype, main with | TInst({ cl_path = [],"Array" }, [t]), TClassDecl(cl) -> TInst(cl,[t]) | TInst({ cl_path = [],"Array" }, [t]), TAbstractDecl(a) -> TAbstract(a,[t]) | _ -> assert false in Some ({ (mk_untyped_call "__array__" p args) with etype = t }) with | Exit -> None) | _ -> None (* ---------------------------------------------------------------------- *) (* INLINING *) type in_local = { i_var : tvar; i_subst : tvar; mutable i_captured : bool; mutable i_write : bool; mutable i_read : int; mutable i_force_temp : bool; } let inline_default_config cf t = (* type substitution on both class and function type parameters *) let rec get_params c pl = match c.cl_super with | None -> c.cl_params, pl | Some (csup,spl) -> let spl = (match apply_params c.cl_params pl (TInst (csup,spl)) with | TInst (_,pl) -> pl | _ -> assert false ) in let ct, cpl = get_params csup spl in c.cl_params @ ct, pl @ cpl in let tparams = (match follow t with | TInst (c,pl) -> get_params c pl | _ -> ([],[])) in let pmonos = List.map (fun _ -> mk_mono()) cf.cf_params in let tmonos = snd tparams @ pmonos in let tparams = fst tparams @ cf.cf_params in tparams <> [], apply_params tparams tmonos let rec type_inline ctx cf f ethis params tret config p ?(self_calling_closure=false) force = (* perform some specific optimization before we inline the call since it's not possible to detect at final optimization time *) try let cl = (match follow ethis.etype with | TInst (c,_) -> c | TAnon a -> (match !(a.a_status) with Statics c -> c | _ -> raise Exit) | _ -> raise Exit ) in (match api_inline ctx cl cf.cf_name params p with | None -> raise Exit | Some e -> Some e) with Exit -> let has_params,map_type = match config with Some config -> config | None -> inline_default_config cf ethis.etype in (* locals substitution *) let locals = Hashtbl.create 0 in let local v = try Hashtbl.find locals v.v_id with Not_found -> let v' = alloc_var v.v_name v.v_type in if Meta.has Meta.Unbound v.v_meta then v'.v_meta <- [Meta.Unbound,[],p]; let i = { i_var = v; i_subst = v'; i_captured = false; i_write = false; i_force_temp = false; i_read = 0; } in i.i_subst.v_meta <- v.v_meta; Hashtbl.add locals v.v_id i; Hashtbl.add locals i.i_subst.v_id i; i in let in_local_fun = ref false in let read_local v = let l = try Hashtbl.find locals v.v_id with Not_found -> (* make sure to duplicate unbound inline variable to prevent dependency leak when unifying monomorph *) if has_meta Meta.Unbound v.v_meta then local v else { i_var = v; i_subst = v; i_captured = false; i_write = false; i_force_temp = false; i_read = 0; } in if !in_local_fun then l.i_captured <- true; l in (* use default values for null/unset arguments *) let rec loop pl al first = match pl, al with | _, [] -> [] | e :: pl, (v, opt) :: al -> (* if we pass a Null var to an inlined method that needs a T. we need to force a local var to be created on some platforms. *) if ctx.com.config.pf_static && not (is_nullable v.v_type) && is_null e.etype then (local v).i_force_temp <- true; (* if we cast from Dynamic, create a local var as well to do the cast once and allow DCE to perform properly. *) if v.v_type != t_dynamic && follow e.etype == t_dynamic then (local v).i_write <- true; (match e.eexpr, opt with | TConst TNull , Some c -> mk (TConst c) v.v_type e.epos (* This is really weird and should be reviewed again. The problem is that we cannot insert a TCast here because the abstract `this` value could be written to, which is not possible if it is wrapped in a cast. The original problem here is that we do not generate a temporary variable and thus mute the type of the `this` variable, which leads to unification errors down the line. See issues #2236 and #3713. *) (* | _ when first && (Meta.has Meta.Impl cf.cf_meta) -> {e with etype = v.v_type} *) | _ -> e) :: loop pl al false | [], (v,opt) :: al -> (mk (TConst (match opt with None -> TNull | Some c -> c)) v.v_type p) :: loop [] al false in (* Build the expr/var subst list *) let ethis = (match ethis.eexpr with TConst TSuper -> { ethis with eexpr = TConst TThis } | _ -> ethis) in let vthis = alloc_var "_this" ethis.etype in let inlined_vars = List.map2 (fun e (v,_) -> let l = local v in if has_side_effect e then l.i_force_temp <- true; (* force tmp var *) l, e ) (ethis :: loop params f.tf_args true) ((vthis,None) :: f.tf_args) in let inlined_vars = List.rev inlined_vars in (* here, we try to eliminate final returns from the expression tree. However, this is not entirely correct since we don't yet correctly propagate the type of returned expressions upwards ("return" expr itself being Dynamic). We also substitute variables with fresh ones that might be renamed at later stage. *) let opt f = function | None -> None | Some e -> Some (f e) in let has_vars = ref false in let in_loop = ref false in let cancel_inlining = ref false in let has_return_value = ref false in let ret_val = (match follow f.tf_type with TAbstract ({ a_path = ([],"Void") },[]) -> false | _ -> true) in let map_pos = if self_calling_closure then (fun e -> e) else (fun e -> { e with epos = p }) in let rec map term e = let po = e.epos in let e = map_pos e in match e.eexpr with | TLocal v -> let l = read_local v in l.i_read <- l.i_read + (if !in_loop then 2 else 1); (* never inline a function which contain a delayed macro because its bound to its variables and not the calling method *) if v.v_name = "__dollar__delay_call" then cancel_inlining := true; let e = { e with eexpr = TLocal l.i_subst } in if Meta.has Meta.This v.v_meta then mk (TCast(e,None)) v.v_type e.epos else e | TConst TThis -> let l = read_local vthis in l.i_read <- l.i_read + (if !in_loop then 2 else 1); { e with eexpr = TLocal l.i_subst } | TVar (v,eo) -> has_vars := true; { e with eexpr = TVar ((local v).i_subst,opt (map false) eo)} | TReturn eo when not !in_local_fun -> if not term then error "Cannot inline a not final return" po; (match eo with | None -> mk (TConst TNull) f.tf_type p | Some e -> has_return_value := true; map term e) | TFor (v,e1,e2) -> let i = local v in let e1 = map false e1 in let old = !in_loop in in_loop := true; let e2 = map false e2 in in_loop := old; { e with eexpr = TFor (i.i_subst,e1,e2) } | TWhile (cond,eloop,flag) -> let cond = map false cond in let old = !in_loop in in_loop := true; let eloop = map false eloop in in_loop := old; { e with eexpr = TWhile (cond,eloop,flag) } | TSwitch (e1,cases,def) when term -> let term = term && def <> None in let cases = List.map (fun (el,e) -> let el = List.map (map false) el in el, map term e ) cases in let def = opt (map term) def in { e with eexpr = TSwitch (map false e1,cases,def); etype = if ret_val then unify_min ctx ((List.map snd cases) @ (match def with None -> [] | Some e -> [e])) else e.etype } | TTry (e1,catches) -> { e with eexpr = TTry (map term e1,List.map (fun (v,e) -> let lv = (local v).i_subst in let e = map term e in lv,e ) catches); etype = if term && ret_val then unify_min ctx (e1::List.map snd catches) else e.etype } | TBlock l -> let old = save_locals ctx in let t = ref e.etype in let has_return e = let rec loop e = match e.eexpr with | TReturn _ -> raise Exit | _ -> Type.iter loop e in try loop e; false with Exit -> true in let rec loop = function | [] when term -> t := mk_mono(); [mk (TConst TNull) (!t) p] | [] -> [] | [e] -> let e = map term e in if term then t := e.etype; [e] | ({ eexpr = TIf (cond,e1,None) } as e) :: l when term && has_return e1 -> loop [{ e with eexpr = TIf (cond,e1,Some (mk (TBlock l) e.etype e.epos)); epos = punion e.epos (match List.rev l with e :: _ -> e.epos | [] -> assert false) }] | e :: l -> let e = map false e in e :: loop l in let l = loop l in old(); { e with eexpr = TBlock l; etype = !t } | TIf (econd,eif,Some eelse) when term -> let econd = map false econd in let eif = map term eif in let eelse = map term eelse in { e with eexpr = TIf(econd,eif,Some eelse); etype = if ret_val then unify_min ctx [eif;eelse] else e.etype } | TParenthesis e1 -> let e1 = map term e1 in mk (TParenthesis e1) e1.etype e.epos | TUnop ((Increment|Decrement) as op,flag,({ eexpr = TLocal v } as e1)) -> let l = read_local v in l.i_write <- true; {e with eexpr = TUnop(op,flag,{e1 with eexpr = TLocal l.i_subst})} | TBinop ((OpAssign | OpAssignOp _) as op,({ eexpr = TLocal v } as e1),e2) -> let l = read_local v in l.i_write <- true; let e2 = map false e2 in {e with eexpr = TBinop(op,{e1 with eexpr = TLocal l.i_subst},e2)} (* | TCall({eexpr = TLocal v} as e1,el) -> let el = List.map (map false) el in let l = read_local v in let edef() = {e with eexpr = TCall({e1 with eexpr = TLocal l.i_subst},el)} in begin try begin match List.assq l inlined_vars with | {eexpr = TField(_, (FStatic(_,cf) | FInstance(_,_,cf)))} as e' when cf.cf_kind = Method MethInline -> make_call ctx e' el e.etype e.epos | _ -> edef() end with Not_found -> edef() end *) | TFunction f -> (match f.tf_args with [] -> () | _ -> has_vars := true); let old = save_locals ctx and old_fun = !in_local_fun in let args = List.map (function(v,c) -> (local v).i_subst, c) f.tf_args in in_local_fun := true; let expr = map false f.tf_expr in in_local_fun := old_fun; old(); { e with eexpr = TFunction { tf_args = args; tf_expr = expr; tf_type = f.tf_type } } | TConst TSuper -> error "Cannot inline function containing super" po | _ -> Type.map_expr (map false) e in let e = map true f.tf_expr in (* if variables are not written and used with a const value, let's substitute with the actual value, either create a temp var *) let subst = ref PMap.empty in let is_constant e = let rec loop e = match e.eexpr with | TLocal _ | TConst TThis (* not really, but should not be move inside a function body *) -> raise Exit | TField (_,FEnum _) | TTypeExpr _ | TConst _ -> () | _ -> Type.iter loop e in try loop e; true with Exit -> false in let is_writable e = match e.eexpr with | TField _ | TEnumParameter _ | TLocal _ | TArray _ -> true | _ -> false in let force = ref force in let vars = List.fold_left (fun acc (i,e) -> let flag = not i.i_force_temp && (match e.eexpr with | TLocal v when Meta.has Meta.This v.v_meta -> true | TLocal _ | TConst _ -> not i.i_write | TFunction _ -> if i.i_write then error "Cannot modify a closure parameter inside inline method" p; true | _ -> not i.i_write && i.i_read <= 1 ) in let flag = flag && (not i.i_captured || is_constant e) in (* force inlining if we modify 'this' *) if i.i_write && (Meta.has Meta.This i.i_var.v_meta) then force := true; (* force inlining of 'this' variable if it is written *) let flag = if not flag && (Meta.has Meta.This i.i_var.v_meta) && i.i_write then begin if not (is_writable e) then error "Cannot modify the abstract value, store it into a local first" p; true end else flag in if flag then begin subst := PMap.add i.i_subst.v_id e !subst; acc end else (i.i_subst,Some e) :: acc ) [] inlined_vars in let subst = !subst in let rec inline_params e = match e.eexpr with | TLocal v -> (try PMap.find v.v_id subst with Not_found -> e) | _ -> Type.map_expr inline_params e in let e = (if PMap.is_empty subst then e else inline_params e) in let init = match vars with [] -> None | l -> Some l in (* If we have local variables and returning a value, then this will result in unoptimized JS code, so let's instead skip inlining. This could be fixed with better post process code cleanup (planed) *) if !cancel_inlining || (not (Common.defined ctx.com Define.Analyzer) && Common.platform ctx.com Js && not !force && (init <> None || !has_vars)) then None else let wrap e = (* we can't mute the type of the expression because it is not correct to do so *) let etype = if has_params then map_type e.etype else e.etype in (* if the expression is "untyped" and we don't want to unify it accidentally ! *) try (match follow e.etype with | TMono _ | TInst ({cl_kind = KTypeParameter _ },_) -> (match follow tret with | TAbstract ({ a_path = [],"Void" },_) -> e | _ -> raise (Unify_error [])) | _ -> type_eq (if ctx.com.config.pf_static then EqDoNotFollowNull else EqStrict) etype tret; e) with Unify_error _ -> mk (TCast (e,None)) tret e.epos in let e = (match e.eexpr, init with | _, None when not !has_return_value -> {e with etype = tret} | TBlock [e] , None -> wrap e | _ , None -> wrap e | TBlock l, Some vl -> let el_v = List.map (fun (v,eo) -> mk (TVar (v,eo)) ctx.t.tvoid e.epos) vl in mk (TBlock (el_v @ l)) tret e.epos | _, Some vl -> let el_v = List.map (fun (v,eo) -> mk (TVar (v,eo)) ctx.t.tvoid e.epos) vl in mk (TBlock (el_v @ [e])) tret e.epos ) in let inline_meta e meta = match meta with | Meta.Deprecated,_,_ -> mk (TMeta(meta,e)) e.etype e.epos | _ -> e in let e = List.fold_left inline_meta e cf.cf_meta in (* we need to replace type-parameters that were used in the expression *) if not has_params then Some e else let mt = map_type cf.cf_type in let unify_func () = unify_raise ctx mt (TFun (List.map (fun e -> "",false,e.etype) params,tret)) p in (match follow ethis.etype with | TAnon a -> (match !(a.a_status) with | Statics {cl_kind = KAbstractImpl a } when Meta.has Meta.Impl cf.cf_meta -> if cf.cf_name <> "_new" then begin (* the first argument must unify with a_this for abstract implementation functions *) let tb = (TFun(("",false,map_type a.a_this) :: List.map (fun e -> "",false,e.etype) (List.tl params),tret)) in unify_raise ctx mt tb p end | _ -> unify_func()) | _ -> unify_func()); (* this is very expensive since we are building the substitution list for every expression, but hopefully in such cases the expression size is small *) let vars = Hashtbl.create 0 in let map_var v = if not (Hashtbl.mem vars v.v_id) then begin Hashtbl.add vars v.v_id (); v.v_type <- map_type v.v_type; end; v in let rec map_expr_type e = Type.map_expr_type map_expr_type map_type map_var e in Some (map_expr_type e) (* ---------------------------------------------------------------------- *) (* LOOPS *) let rec optimize_for_loop ctx (i,pi) e1 e2 p = let t_void = ctx.t.tvoid in let t_int = ctx.t.tint in let lblock el = Some (mk (TBlock el) t_void p) in let mk_field e n = TField (e,try quick_field e.etype n with Not_found -> assert false) in let gen_int_iter pt f_get f_length = let i = add_local ctx i pt in let index = gen_local ctx t_int in let arr, avars = (match e1.eexpr with | TLocal _ -> e1, None | _ -> let atmp = gen_local ctx e1.etype in mk (TLocal atmp) e1.etype e1.epos, (Some (atmp,Some e1)) ) in let iexpr = mk (TLocal index) t_int p in let e2 = type_expr ctx e2 NoValue in let aget = mk (TVar (i,Some (f_get arr iexpr pt p))) t_void pi in let incr = mk (TUnop (Increment,Prefix,iexpr)) t_int p in let block = match e2.eexpr with | TBlock el -> mk (TBlock (aget :: incr :: el)) t_void e2.epos | _ -> mk (TBlock [aget;incr;e2]) t_void p in let ivar = Some (mk (TConst (TInt 0l)) t_int p) in let elength = f_length arr p in let el = [mk (TWhile ( mk (TBinop (OpLt, iexpr, elength)) ctx.t.tbool p, block, NormalWhile )) t_void p; ] in let el = match avars with None -> el | Some (v,eo) -> (mk (TVar (v,eo)) t_void p) :: el in let el = (mk (TVar (index,ivar)) t_void p) :: el in lblock el in let get_next_array_element arr iexpr pt p = (mk (TArray (arr,iexpr)) pt p) in let get_array_length arr p = mk (mk_field arr "length") ctx.com.basic.tint p in match e1.eexpr, follow e1.etype with | TNew ({ cl_path = ([],"IntIterator") },[],[i1;i2]) , _ -> let max = (match i1.eexpr , i2.eexpr with | TConst (TInt a), TConst (TInt b) when Int32.compare b a < 0 -> error "Range operator can't iterate backwards" p | _, TConst _ | _ , TLocal _ -> None | _ -> Some (gen_local ctx t_int) ) in let tmp = gen_local ctx t_int in let i = add_local ctx i t_int in let rec check e = match e.eexpr with | TBinop (OpAssign,{ eexpr = TLocal l },_) | TBinop (OpAssignOp _,{ eexpr = TLocal l },_) | TUnop (Increment,_,{ eexpr = TLocal l }) | TUnop (Decrement,_,{ eexpr = TLocal l }) when l == i -> error "Loop variable cannot be modified" e.epos | _ -> Type.iter check e in let e2 = type_expr ctx e2 NoValue in check e2; let etmp = mk (TLocal tmp) t_int p in let incr = mk (TUnop (Increment,Postfix,etmp)) t_int p in let init = mk (TVar (i,Some incr)) t_void pi in let block = match e2.eexpr with | TBlock el -> mk (TBlock (init :: el)) t_void e2.epos | _ -> mk (TBlock [init;e2]) t_void p in (* force locals to be of Int type (to prevent Int/UInt issues) *) let i2 = match follow i2.etype with | TAbstract ({ a_path = ([],"Int") }, []) -> i2 | _ -> { i2 with eexpr = TCast(i2, None); etype = t_int } in (match max with | None -> lblock [ mk (TVar (tmp,Some i1)) t_void p; mk (TWhile ( mk (TBinop (OpLt, etmp, i2)) ctx.t.tbool p, block, NormalWhile )) t_void p; ] | Some max -> lblock [ mk (TVar (tmp,Some i1)) t_void p; mk (TVar (max,Some i2)) t_void p; mk (TWhile ( mk (TBinop (OpLt, etmp, mk (TLocal max) t_int p)) ctx.t.tbool p, block, NormalWhile )) t_void p; ]) | TArrayDecl el, TInst({ cl_path = [],"Array" },[pt]) when false -> begin try let num_expr = ref 0 in let rec loop e = match fst e with | EContinue | EBreak -> raise Exit | _ -> incr num_expr; Ast.map_expr loop e in ignore(loop e2); let v = add_local ctx i pt in let e2 = type_expr ctx e2 NoValue in let cost = (List.length el) * !num_expr in let max_cost = try int_of_string (Common.defined_value ctx.com Define.LoopUnrollMaxCost) with Not_found -> 250 in if cost > max_cost then raise Exit; let eloc = mk (TLocal v) v.v_type p in let el = List.map (fun e -> let e_assign = mk (TBinop(OpAssign,eloc,e)) e.etype e.epos in concat e_assign e2 ) el in let ev = mk (TVar(v, None)) ctx.t.tvoid p in Some (mk (TBlock (ev :: el)) ctx.t.tvoid p) with Exit -> gen_int_iter pt get_next_array_element get_array_length end | _ , TInst({ cl_path = [],"Array" },[pt]) | _ , TInst({ cl_path = ["flash"],"Vector" },[pt]) -> gen_int_iter pt get_next_array_element get_array_length | _ , TInst({ cl_array_access = Some pt } as c,pl) when (try match follow (PMap.find "length" c.cl_fields).cf_type with TAbstract ({ a_path = [],"Int" },[]) -> true | _ -> false with Not_found -> false) && not (PMap.mem "iterator" c.cl_fields) -> gen_int_iter (apply_params c.cl_params pl pt) get_next_array_element get_array_length | _, TAbstract({a_impl = Some c} as a,tl) -> begin try let cf_length = PMap.find "get_length" c.cl_statics in let get_length e p = make_static_call ctx c cf_length (apply_params a.a_params tl) [e] ctx.com.basic.tint p in begin match follow cf_length.cf_type with | TFun(_,tr) -> begin match follow tr with | TAbstract({a_path = [],"Int"},_) -> () | _ -> raise Not_found end | _ -> raise Not_found end; begin try (* first try: do we have an @:arrayAccess getter field? *) let todo = mk (TConst TNull) ctx.t.tint p in let cf,_,r,_,_ = (!find_array_access_raise_ref) ctx a tl todo None p in let get_next e_base e_index t p = make_static_call ctx c cf (apply_params a.a_params tl) [e_base;e_index] r p in gen_int_iter r get_next get_length with Not_found -> (* second try: do we have @:arrayAccess on the abstract itself? *) if not (Meta.has Meta.ArrayAccess a.a_meta) then raise Not_found; (* let's allow this only for core-type abstracts *) if not (Meta.has Meta.CoreType a.a_meta) then raise Not_found; (* in which case we assume that a singular type parameter is the element type *) let t = match tl with [t] -> t | _ -> raise Not_found in gen_int_iter t get_next_array_element get_length end with Not_found -> None end | _ , TInst ({ cl_kind = KGenericInstance ({ cl_path = ["haxe";"ds"],"GenericStack" },[t]) } as c,[]) -> let tcell = (try (PMap.find "head" c.cl_fields).cf_type with Not_found -> assert false) in let i = add_local ctx i t in let cell = gen_local ctx tcell in let cexpr = mk (TLocal cell) tcell p in let e2 = type_expr ctx e2 NoValue in let evar = mk (TVar (i,Some (mk (mk_field cexpr "elt") t p))) t_void pi in let enext = mk (TBinop (OpAssign,cexpr,mk (mk_field cexpr "next") tcell p)) tcell p in let block = match e2.eexpr with | TBlock el -> mk (TBlock (evar :: enext :: el)) t_void e2.epos | _ -> mk (TBlock [evar;enext;e2]) t_void p in lblock [ mk (TVar (cell,Some (mk (mk_field e1 "head") tcell p))) t_void p; mk (TWhile ( mk (TBinop (OpNotEq, cexpr, mk (TConst TNull) tcell p)) ctx.t.tbool p, block, NormalWhile )) t_void p ] | _ -> None let optimize_for_loop_iterator ctx v e1 e2 p = let c,tl = (match follow e1.etype with TInst (c,pl) -> c,pl | _ -> raise Exit) in let _, _, fhasnext = (try raw_class_field (fun cf -> apply_params c.cl_params tl cf.cf_type) c tl "hasNext" with Not_found -> raise Exit) in if fhasnext.cf_kind <> Method MethInline then raise Exit; let tmp = gen_local ctx e1.etype in let eit = mk (TLocal tmp) e1.etype p in let ehasnext = make_call ctx (mk (TField (eit,FInstance (c, tl, fhasnext))) (TFun([],ctx.t.tbool)) p) [] ctx.t.tbool p in let enext = mk (TVar (v,Some (make_call ctx (mk (TField (eit,quick_field_dynamic eit.etype "next")) (TFun ([],v.v_type)) p) [] v.v_type p))) ctx.t.tvoid p in let eblock = (match e2.eexpr with | TBlock el -> { e2 with eexpr = TBlock (enext :: el) } | _ -> mk (TBlock [enext;e2]) ctx.t.tvoid p ) in mk (TBlock [ mk (TVar (tmp,Some e1)) ctx.t.tvoid p; mk (TWhile (ehasnext,eblock,NormalWhile)) ctx.t.tvoid p ]) ctx.t.tvoid p (* ---------------------------------------------------------------------- *) (* SANITIZE *) (* makes sure that when an AST get generated to source code, it will not generate expressions that evaluate differently. It is then necessary to add parenthesises around some binary expressions when the AST does not correspond to the natural operand priority order for the platform *) (* this is the standard C++ operator precedence, which is also used by both JS and PHP *) let standard_precedence op = let left = true and right = false in match op with | OpMult | OpDiv | OpMod -> 5, left | OpAdd | OpSub -> 6, left | OpShl | OpShr | OpUShr -> 7, left | OpLt | OpLte | OpGt | OpGte -> 8, left | OpEq | OpNotEq -> 9, left | OpAnd -> 10, left | OpXor -> 11, left | OpOr -> 12, left | OpInterval -> 13, right (* haxe specific *) | OpBoolAnd -> 14, left | OpBoolOr -> 15, left | OpArrow -> 16, left | OpAssignOp OpAssign -> 17, right (* mimics ?: *) | OpAssign | OpAssignOp _ -> 18, right let rec need_parent e = match e.eexpr with | TConst _ | TLocal _ | TArray _ | TField _ | TEnumParameter _ | TParenthesis _ | TMeta _ | TCall _ | TNew _ | TTypeExpr _ | TObjectDecl _ | TArrayDecl _ -> false | TCast (e,None) -> need_parent e | TCast _ | TThrow _ | TReturn _ | TTry _ | TSwitch _ | TFor _ | TIf _ | TWhile _ | TBinop _ | TContinue | TBreak | TBlock _ | TVar _ | TFunction _ | TUnop _ -> true let sanitize_expr com e = let parent e = match e.eexpr with | TParenthesis _ -> e | _ -> mk (TParenthesis e) e.etype e.epos in let block e = match e.eexpr with | TBlock _ -> e | _ -> mk (TBlock [e]) e.etype e.epos in let complex e = (* complex expressions are the one that once generated to source consists in several expressions *) match e.eexpr with | TVar _ (* needs to be put into blocks *) | TFor _ (* a temp var is needed for holding iterator *) | TCall ({ eexpr = TLocal { v_name = "__js__" } },_) (* we never know *) -> block e | _ -> e in (* tells if the printed expresssion ends with an if without else *) let rec has_if e = match e.eexpr with | TIf (_,_,None) -> true | TWhile (_,e,NormalWhile) -> has_if e | TFor (_,_,e) -> has_if e | _ -> false in match e.eexpr with | TConst TNull -> if com.config.pf_static && not (is_nullable e.etype) then begin let rec loop t = match follow t with | TMono _ -> () (* in these cases the null will cast to default value *) | TFun _ -> () (* this is a bit a particular case, maybe flash-specific actually *) (* TODO: this should use get_underlying_type, but we do not have access to Codegen here. *) | TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) -> loop (apply_params a.a_params tl a.a_this) | _ -> com.error ("On static platforms, null can't be used as basic type " ^ s_type (print_context()) e.etype) e.epos in loop e.etype end; e | TBinop (op,e1,e2) -> let swap op1 op2 = let p1, left1 = standard_precedence op1 in let p2, _ = standard_precedence op2 in left1 && p1 <= p2 in let rec loop ee left = match ee.eexpr with | TBinop (op2,_,_) -> if left then not (swap op2 op) else swap op op2 | TIf _ -> if left then not (swap (OpAssignOp OpAssign) op) else swap op (OpAssignOp OpAssign) | TCast (e,None) -> loop e left | _ -> false in let e1 = if loop e1 true then parent e1 else e1 in let e2 = if loop e2 false then parent e2 else e2 in { e with eexpr = TBinop (op,e1,e2) } | TUnop (op,mode,e1) -> let rec loop ee = match ee.eexpr with | TBinop _ | TIf _ | TUnop _ -> parent e1 | TCast (e,None) -> loop e | _ -> e1 in { e with eexpr = TUnop (op,mode,loop e1)} | TIf (e1,e2,eelse) -> let e1 = parent e1 in let e2 = (if (eelse <> None && has_if e2) || (match e2.eexpr with TIf _ -> true | _ -> false) then block e2 else complex e2) in let eelse = (match eelse with None -> None | Some e -> Some (complex e)) in { e with eexpr = TIf (e1,e2,eelse) } | TWhile (e1,e2,flag) -> let e1 = parent e1 in let e2 = complex e2 in { e with eexpr = TWhile (e1,e2,flag) } | TFor (v,e1,e2) -> let e2 = complex e2 in { e with eexpr = TFor (v,e1,e2) } | TFunction f -> let f = (match f.tf_expr.eexpr with | TBlock _ -> f | _ -> { f with tf_expr = block f.tf_expr } ) in { e with eexpr = TFunction f } | TCall (e2,args) -> if need_parent e2 then { e with eexpr = TCall(parent e2,args) } else e | TEnumParameter (e2,ef,i) -> if need_parent e2 then { e with eexpr = TEnumParameter(parent e2,ef,i) } else e | TField (e2,f) -> if need_parent e2 then { e with eexpr = TField(parent e2,f) } else e | TArray (e1,e2) -> if need_parent e1 then { e with eexpr = TArray(parent e1,e2) } else e | TTry (e1,catches) -> let e1 = block e1 in let catches = List.map (fun (v,e) -> v, block e) catches in { e with eexpr = TTry (e1,catches) } | TSwitch (e1,cases,def) -> let e1 = parent e1 in let cases = List.map (fun (el,e) -> el, complex e) cases in let def = (match def with None -> None | Some e -> Some (complex e)) in { e with eexpr = TSwitch (e1,cases,def) } | _ -> e let reduce_expr com e = match e.eexpr with | TSwitch (_,cases,_) -> List.iter (fun (cl,_) -> List.iter (fun e -> match e.eexpr with | TCall ({ eexpr = TField (_,FEnum _) },_) -> error "Not-constant enum in switch cannot be matched" e.epos | _ -> () ) cl ) cases; e | TBlock l -> (match List.rev l with | [] -> e | ec :: l -> (* remove all no-ops : not-final constants in blocks *) match List.filter (fun e -> match e.eexpr with | TConst _ | TBlock [] | TObjectDecl [] -> false | _ -> true ) l with | [] -> ec | l -> { e with eexpr = TBlock (List.rev (ec :: l)) }) | TParenthesis ec -> { ec with epos = e.epos } | TTry (e,[]) -> e | _ -> e let rec sanitize com e = sanitize_expr com (reduce_expr com (Type.map_expr (sanitize com) e)) (* ---------------------------------------------------------------------- *) (* REDUCE *) let optimize_binop e op e1 e2 = let is_float t = match follow t with | TAbstract({ a_path = [],"Float" },_) -> true | _ -> false in let is_numeric t = match follow t with | TAbstract({ a_path = [],("Float"|"Int") },_) -> true | _ -> false in let check_float op f1 f2 = let f = op f1 f2 in let fstr = float_repres f in if (match classify_float f with FP_nan | FP_infinite -> false | _ -> float_of_string fstr = f) then { e with eexpr = TConst (TFloat fstr) } else e in (match e1.eexpr, e2.eexpr with | TConst (TInt 0l) , _ when op = OpAdd && is_numeric e2.etype -> e2 | TConst (TInt 1l) , _ when op = OpMult -> e2 | TConst (TFloat v) , _ when op = OpAdd && float_of_string v = 0. && is_float e2.etype -> e2 | TConst (TFloat v) , _ when op = OpMult && float_of_string v = 1. && is_float e2.etype -> e2 | _ , TConst (TInt 0l) when (match op with OpAdd -> is_numeric e1.etype | OpSub | OpShr | OpShl -> true | _ -> false) -> e1 (* bits operations might cause overflow *) | _ , TConst (TInt 1l) when op = OpMult -> e1 | _ , TConst (TFloat v) when (match op with OpAdd | OpSub -> float_of_string v = 0. && is_float e1.etype | _ -> false) -> e1 (* bits operations might cause overflow *) | _ , TConst (TFloat v) when op = OpMult && float_of_string v = 1. && is_float e1.etype -> e1 | TConst TNull, TConst TNull -> (match op with | OpEq -> { e with eexpr = TConst (TBool true) } | OpNotEq -> { e with eexpr = TConst (TBool false) } | _ -> e) | TFunction _, TConst TNull -> (match op with | OpEq -> { e with eexpr = TConst (TBool false) } | OpNotEq -> { e with eexpr = TConst (TBool true) } | _ -> e) | TConst TNull, TFunction _ -> (match op with | OpEq -> { e with eexpr = TConst (TBool false) } | OpNotEq -> { e with eexpr = TConst (TBool true) } | _ -> e) | TConst (TInt a), TConst (TInt b) -> let opt f = try { e with eexpr = TConst (TInt (f a b)) } with Exit -> e in let check_overflow f = opt (fun a b -> let v = f (Int64.of_int32 a) (Int64.of_int32 b) in let iv = Int64.to_int32 v in if Int64.compare (Int64.of_int32 iv) v <> 0 then raise Exit; iv ) in let ebool t = { e with eexpr = TConst (TBool (t (Int32.compare a b) 0)) } in (match op with | OpAdd -> check_overflow Int64.add | OpSub -> check_overflow Int64.sub | OpMult -> check_overflow Int64.mul | OpDiv -> check_float ( /. ) (Int32.to_float a) (Int32.to_float b) | OpAnd -> opt Int32.logand | OpOr -> opt Int32.logor | OpXor -> opt Int32.logxor | OpShl -> opt (fun a b -> Int32.shift_left a (Int32.to_int b)) | OpShr -> opt (fun a b -> Int32.shift_right a (Int32.to_int b)) | OpUShr -> opt (fun a b -> Int32.shift_right_logical a (Int32.to_int b)) | OpEq -> ebool (=) | OpNotEq -> ebool (<>) | OpGt -> ebool (>) | OpGte -> ebool (>=) | OpLt -> ebool (<) | OpLte -> ebool (<=) | _ -> e) | TConst ((TFloat _ | TInt _) as ca), TConst ((TFloat _ | TInt _) as cb) -> let fa = (match ca with | TFloat a -> float_of_string a | TInt a -> Int32.to_float a | _ -> assert false ) in let fb = (match cb with | TFloat b -> float_of_string b | TInt b -> Int32.to_float b | _ -> assert false ) in let fop op = check_float op fa fb in let ebool t = { e with eexpr = TConst (TBool (t (compare fa fb) 0)) } in (match op with | OpAdd -> fop (+.) | OpDiv -> fop (/.) | OpSub -> fop (-.) | OpMult -> fop ( *. ) | OpEq -> ebool (=) | OpNotEq -> ebool (<>) | OpGt -> ebool (>) | OpGte -> ebool (>=) | OpLt -> ebool (<) | OpLte -> ebool (<=) | _ -> e) | TConst (TBool a), TConst (TBool b) -> let ebool f = { e with eexpr = TConst (TBool (f a b)) } in (match op with | OpEq -> ebool (=) | OpNotEq -> ebool (<>) | OpBoolAnd -> ebool (&&) | OpBoolOr -> ebool (||) | _ -> e) | TConst a, TConst b when op = OpEq || op = OpNotEq -> let ebool b = { e with eexpr = TConst (TBool (if op = OpEq then b else not b)) } in (match a, b with | TInt a, TFloat b | TFloat b, TInt a -> ebool (Int32.to_float a = float_of_string b) | _ -> ebool (a = b)) | TConst (TBool a), _ -> (match op with | OpBoolAnd -> if a then e2 else { e with eexpr = TConst (TBool false) } | OpBoolOr -> if a then { e with eexpr = TConst (TBool true) } else e2 | _ -> e) | _ , TConst (TBool a) -> (match op with | OpBoolAnd when a -> e1 | OpBoolOr when not a -> e1 | _ -> e) | TField (_,FEnum (e1,f1)), TField (_,FEnum (e2,f2)) when e1 == e2 -> (match op with | OpEq -> { e with eexpr = TConst (TBool (f1 == f2)) } | OpNotEq -> { e with eexpr = TConst (TBool (f1 != f2)) } | _ -> e) | _, TCall ({ eexpr = TField (_,FEnum _) },_) | TCall ({ eexpr = TField (_,FEnum _) },_), _ -> (match op with | OpAssign -> e | _ -> error "You cannot directly compare enums with arguments. Use either 'switch' or 'Type.enumEq'" e.epos) | _ -> e) let optimize_unop e op flag esub = match op, esub.eexpr with | Not, (TConst (TBool f) | TParenthesis({eexpr = TConst (TBool f)})) -> { e with eexpr = TConst (TBool (not f)) } | Neg, TConst (TInt i) -> { e with eexpr = TConst (TInt (Int32.neg i)) } | NegBits, TConst (TInt i) -> { e with eexpr = TConst (TInt (Int32.lognot i)) } | Neg, TConst (TFloat f) -> let v = 0. -. float_of_string f in let vstr = float_repres v in if float_of_string vstr = v then { e with eexpr = TConst (TFloat vstr) } else e | _ -> e let rec reduce_loop ctx e = let e = Type.map_expr (reduce_loop ctx) e in sanitize_expr ctx.com (match e.eexpr with | TIf ({ eexpr = TConst (TBool t) },e1,e2) -> (if t then e1 else match e2 with None -> { e with eexpr = TBlock [] } | Some e -> e) | TWhile ({ eexpr = TConst (TBool false) },sub,flag) -> (match flag with | NormalWhile -> { e with eexpr = TBlock [] } (* erase sub *) | DoWhile -> e) (* we cant remove while since sub can contain continue/break *) | TBinop (op,e1,e2) -> optimize_binop e op e1 e2 | TUnop (op,flag,esub) -> optimize_unop e op flag esub | TCall ({ eexpr = TField ({ eexpr = TTypeExpr (TClassDecl c) },field) },params) -> (match api_inline ctx c (field_name field) params e.epos with | None -> reduce_expr ctx e | Some e -> reduce_loop ctx e) | TCall ({ eexpr = TFunction func } as ef,el) -> let cf = mk_field "" ef.etype e.epos in let ethis = mk (TConst TThis) t_dynamic e.epos in let rt = (match follow ef.etype with TFun (_,rt) -> rt | _ -> assert false) in let inl = (try type_inline ctx cf func ethis el rt None e.epos ~self_calling_closure:true false with Error (Custom _,_) -> None) in (match inl with | None -> reduce_expr ctx e | Some e -> reduce_loop ctx e) | TCall ({ eexpr = TField (o,FClosure (c,cf)) } as f,el) -> let fmode = (match c with None -> FAnon cf | Some (c,tl) -> FInstance (c,tl,cf)) in { e with eexpr = TCall ({ f with eexpr = TField (o,fmode) },el) } | TSwitch (e1,[[{eexpr = TConst (TBool true)}],{eexpr = TConst (TBool true)}],Some ({eexpr = TConst (TBool false)})) -> (* introduced by extractors in some cases *) e1 | _ -> reduce_expr ctx e) let reduce_expression ctx e = if ctx.com.foptimize then reduce_loop ctx e else e let rec make_constant_expression ctx ?(concat_strings=false) e = let e = reduce_loop ctx e in match e.eexpr with | TConst _ -> Some e | TBinop ((OpAdd|OpSub|OpMult|OpDiv|OpMod) as op,e1,e2) -> (match make_constant_expression ctx e1,make_constant_expression ctx e2 with | Some ({eexpr = TConst (TString s1)}), Some ({eexpr = TConst (TString s2)}) when concat_strings -> Some (mk (TConst (TString (s1 ^ s2))) ctx.com.basic.tstring (punion e1.epos e2.epos)) | Some e1, Some e2 -> Some (mk (TBinop(op, e1, e2)) e.etype e.epos) | _ -> None) | TCast (e1, None) -> (match make_constant_expression ctx e1 with | None -> None | Some e1 -> Some {e with eexpr = TCast(e1,None)}) | TParenthesis e1 -> begin match make_constant_expression ctx ~concat_strings e1 with | None -> None | Some e1 -> Some {e with eexpr = TParenthesis e1} end | TMeta(m,e1) -> begin match make_constant_expression ctx ~concat_strings e1 with | None -> None | Some e1 -> Some {e with eexpr = TMeta(m,e1)} end | TTypeExpr _ -> Some e (* try to inline static function calls *) | TCall ({ etype = TFun(_,ret); eexpr = TField (_,FStatic (c,cf)) },el) -> (try let func = match cf.cf_expr with Some ({eexpr = TFunction func}) -> func | _ -> raise Not_found in let ethis = mk (TConst TThis) t_dynamic e.epos in let inl = (try type_inline ctx cf func ethis el ret None e.epos false with Error (Custom _,_) -> None) in (match inl with | None -> None | Some e -> make_constant_expression ctx e) with Not_found -> None) | _ -> None (* ---------------------------------------------------------------------- *) (* INLINE CONSTRUCTORS *) (* First pass : We will look at local variables in the form var v = new .... we only capture the ones which have constructors marked as inlined then we make sure that these locals are no more referenced except for fields accesses Second pass : We replace the variables by their fields lists, and the corresponding fields accesses as well *) type inline_kind = | IKCtor of tfunc * tclass_field * tclass * t list * texpr list * texpr list | IKArray of texpr list * t | IKStructure of (string * texpr) list | IKNone let inline_constructors ctx e = let vars = ref PMap.empty in let is_valid_ident s = try if String.length s = 0 then raise Exit; begin match String.unsafe_get s 0 with | 'a'..'z' | 'A'..'Z' | '_' -> () | _ -> raise Exit end; for i = 1 to String.length s - 1 do match String.unsafe_get s i with | 'a'..'z' | 'A'..'Z' | '_' -> () | '0'..'9' when i > 0 -> () | _ -> raise Exit done; true with Exit -> false in let rec get_inline_ctor_info e = match e.eexpr with | TNew ({ cl_constructor = Some ({ cf_kind = Method MethInline; cf_expr = Some { eexpr = TFunction f } } as cst) } as c,tl,pl) -> IKCtor (f,cst,c,tl,pl,[]) | TObjectDecl [] | TArrayDecl [] -> IKNone | TArrayDecl el -> begin match follow e.etype with | TInst({cl_path = [],"Array"},[t]) -> IKArray(el,t) | _ -> IKNone end | TObjectDecl fl -> if (List.exists (fun (s,_) -> not (is_valid_ident s)) fl) then IKNone else IKStructure fl | TCast(e,None) | TParenthesis e -> get_inline_ctor_info e | TBlock el -> begin match List.rev el with | e :: el -> begin match get_inline_ctor_info e with | IKCtor(f,cst,c,tl,pl,e_init) -> IKCtor(f,cst,c,tl,pl,(List.rev el) @ e_init) | _ -> IKNone end | [] -> IKNone end | _ -> IKNone in let check_field v s e t = let (a,b,fields,c,d) = PMap.find (-v.v_id) !vars in if not (List.exists (fun (s2,_,_) -> s = s2) fields) then vars := PMap.add (-v.v_id) (a,b,(s,e,t) :: fields,c,d) !vars in let cancel v = v.v_id <- -v.v_id; (* error if the constructor is extern *) (match PMap.find v.v_id !vars with | _,_,_,true,p -> display_error ctx "Extern constructor could not be inlined" p; error "Variable is used here" e.epos | _ -> ()); vars := PMap.remove v.v_id !vars; in let rec skip_to_var e = match e.eexpr with | TLocal v when v.v_id < 0 -> Some v (* | TCast(e1,None) | TMeta(_,e1) | TParenthesis(e1) -> skip_to_var e1 *) | _ -> None in let rec find_locals e = match e.eexpr with | TVar (v,eo) -> Type.iter find_locals e; begin match eo with | Some n -> begin match get_inline_ctor_info n with | IKCtor (f,cst,c,tl,pl,el_init) when type_iseq v.v_type n.etype -> (* inline the constructor *) (match (try type_inline ctx cst f (mk (TLocal v) (TInst (c,tl)) n.epos) pl ctx.t.tvoid None n.epos true with Error (Custom _,_) -> None) with | None -> () | Some ecst -> let assigns = ref [] in (* add field inits here because the filter has not run yet (issue #2336) *) List.iter (fun cf -> match cf.cf_kind,cf.cf_expr with | Var _,Some e -> assigns := (cf.cf_name,e,cf.cf_type) :: !assigns | _ -> () ) c.cl_ordered_fields; (* make sure we only have v.field = expr calls *) let rec get_assigns e = match e.eexpr with | TBlock el -> List.iter get_assigns el | TBinop (OpAssign, { eexpr = TField ({ eexpr = TLocal vv },FInstance(_,_,cf)); etype = t }, e) when v == vv -> assigns := (cf.cf_name,e,t) :: !assigns | _ -> raise Exit in try get_assigns ecst; (* mark variable as candidate for inlining *) vars := PMap.add v.v_id (v,el_init,List.rev !assigns,c.cl_extern || Meta.has Meta.Extern cst.cf_meta,n.epos) !vars; v.v_id <- -v.v_id; (* mark *) (* recurse with the constructor code which will be inlined here *) find_locals ecst with Exit -> ()) | IKArray (el,t) -> vars := PMap.add v.v_id (v,[],ExtList.List.mapi (fun i e -> string_of_int i,e,t) el, false, n.epos) !vars; v.v_id <- -v.v_id; | IKStructure fl -> vars := PMap.add v.v_id (v,[],List.map (fun (s,e) -> s,e,e.etype) fl, false, n.epos) !vars; v.v_id <- -v.v_id; | _ -> () end | _ -> () end | TField(e1, (FInstance(_, _, {cf_kind = Var _; cf_name = s}) | FAnon({cf_kind = Var _; cf_name = s}))) -> (match skip_to_var e1 with None -> find_locals e1 | Some _ -> ()) | TArray (e1,{eexpr = TConst (TInt i)}) -> begin match skip_to_var e1 with | None -> find_locals e1 | Some v -> let (_,_,fields,_,_) = PMap.find (-v.v_id) !vars in let i = Int32.to_int i in if i < 0 || i >= List.length fields then cancel v end | TBinop((OpAssign | OpAssignOp _),e1,e2) -> begin match e1.eexpr with | TArray ({eexpr = TLocal v},{eexpr = TConst (TInt i)}) when v.v_id < 0 -> check_field v (Int32.to_string i) e2 e2.etype | TField({eexpr = TLocal v}, (FInstance(_, _, {cf_kind = Var _; cf_name = s}) | FAnon({cf_kind = Var _; cf_name = s}))) when v.v_id < 0 -> check_field v s e2 e2.etype | _ -> find_locals e1 end; find_locals e2 | TLocal v when v.v_id < 0 -> cancel v | _ -> Type.iter find_locals e in find_locals e; let vars = !vars in if PMap.is_empty vars then e else begin let vfields = PMap.map (fun (v,el_init,assigns,_,_) -> (List.fold_left (fun (acc,map) (name,e,t) -> let vf = alloc_var (v.v_name ^ "_" ^ name) t in ((vf,e) :: acc, PMap.add name vf map) ) ([],PMap.empty) assigns),el_init ) vars in let el_b = ref [] in let append e = el_b := e :: !el_b in let inline_field c cf v = let (_, vars),el_init = PMap.find (-v.v_id) vfields in (try let v = PMap.find cf.cf_name vars in mk (TLocal v) v.v_type e.epos with Not_found -> if (c.cl_path = ([],"Array") && cf.cf_name = "length") then begin (* this can only occur for inlined array declarations, so we can use the statically known length here (issue #2568)*) let l = PMap.fold (fun _ i -> i + 1) vars 0 in mk (TConst (TInt (Int32.of_int l))) ctx.t.tint e.epos end else (* the variable was not set in the constructor, assume null *) mk (TConst TNull) e.etype e.epos) in let inline_anon_field cf v = let (_, vars),_ = PMap.find (-v.v_id) vfields in (try let v = PMap.find cf.cf_name vars in mk (TLocal v) v.v_type e.epos with Not_found -> (* this could happen in untyped code, assume null *) mk (TConst TNull) e.etype e.epos) in let inline_array_access i v = let (_, vars),_ = PMap.find (-v.v_id) vfields in (try let v = PMap.find (Int32.to_string i) vars in mk (TLocal v) v.v_type e.epos with Not_found -> (* probably out-of-bounds, assume null *) mk (TConst TNull) e.etype e.epos) in let rec subst e = match e.eexpr with | TBlock el -> let old = !el_b in el_b := []; List.iter (fun e -> append (subst e)) el; let n = !el_b in el_b := old; {e with eexpr = TBlock (List.rev n)} | TVar (v,Some e) when v.v_id < 0 -> let (vars, _),el_init = PMap.find (-v.v_id) vfields in List.iter (fun e -> append (subst e) ) el_init; let (v_first,e_first),vars = match vars with | v :: vl -> v,vl | [] -> assert false in List.iter (fun (v,e) -> append (mk (TVar(v,Some (subst e))) ctx.t.tvoid e.epos)) (List.rev vars); mk (TVar (v_first, Some (subst e_first))) ctx.t.tvoid e.epos | TField (e1,FInstance (c,_,cf)) -> begin match skip_to_var e1 with | None -> Type.map_expr subst e | Some v -> inline_field c cf v end | TArray (e1,{eexpr = TConst (TInt i)}) -> begin match skip_to_var e1 with | None -> Type.map_expr subst e | Some v -> inline_array_access i v end | TField (e1,FAnon(cf)) -> begin match skip_to_var e1 with | None -> Type.map_expr subst e | Some v -> inline_anon_field cf v end | _ -> Type.map_expr subst e in let e = (try subst e with Not_found -> assert false) in PMap.iter (fun _ (v,_,_,_,_) -> v.v_id <- -v.v_id) vars; e end (* ---------------------------------------------------------------------- *) (* COMPLETION *) exception Return of Ast.expr type compl_locals = { mutable r : (string, (complex_type option * (int * Ast.expr * compl_locals) option)) PMap.t; } let optimize_completion_expr e = let iid = ref 0 in let typing_side_effect = ref false in let locals : compl_locals = { r = PMap.empty } in let save() = let old = locals.r in (fun() -> locals.r <- old) in let get_local n = PMap.find n locals.r in let maybe_typed e = match fst e with | EConst (Ident "null") -> false | _ -> true in let decl n t e = typing_side_effect := true; locals.r <- PMap.add n (t,(match e with Some e when maybe_typed e -> incr iid; Some (!iid,e,{ r = locals.r }) | _ -> None)) locals.r in let rec loop e = let p = snd e in match fst e with | EConst (Ident n) -> (try (match get_local n with | Some _ , _ -> () | _ -> typing_side_effect := true) with Not_found -> ()); e | EBinop (OpAssign,(EConst (Ident n),_),esub) -> (try (match get_local n with | None, None when maybe_typed esub -> decl n None (Some esub) | _ -> ()) with Not_found -> ()); map e | EVars vl -> let vl = List.map (fun (v,t,e) -> let e = (match e with None -> None | Some e -> Some (loop e)) in decl v t e; (v,t,e) ) vl in (EVars vl,p) | EBlock el -> let old = save() in let told = ref (!typing_side_effect) in let el = List.fold_left (fun acc e -> typing_side_effect := false; let e = loop e in if !typing_side_effect then begin told := true; e :: acc end else acc ) [] el in old(); typing_side_effect := !told; (EBlock (List.rev el),p) | EFunction (v,f) -> (match v with | None -> () | Some name -> decl name None (Some e)); let old = save() in List.iter (fun (n,_,t,e) -> decl n t e) f.f_args; let e = map e in old(); e | EFor ((EIn ((EConst (Ident n),_) as id,it),p),efor) -> let it = loop it in let old = save() in let etmp = (EConst (Ident "$tmp"),p) in decl n None (Some (EBlock [ (EVars ["$tmp",None,None],p); (EFor ((EIn (id,it),p),(EBinop (OpAssign,etmp,(EConst (Ident n),p)),p)),p); etmp ],p)); let efor = loop efor in old(); (EFor ((EIn (id,it),p),efor),p) | EReturn _ -> typing_side_effect := true; map e | ESwitch (e,cases,def) -> let e = loop e in let cases = List.map (fun (el,eg,eo) -> match eo with | None -> el,eg,eo | Some e -> let el = List.map loop el in let old = save() in List.iter (fun e -> match fst e with | ECall (_,pl) -> List.iter (fun p -> match fst p with | EConst (Ident i) -> decl i None None (* sadly *) | _ -> () ) pl | _ -> () ) el; let e = loop e in old(); el, eg, Some e ) cases in let def = match def with | None -> None | Some None -> Some None | Some (Some e) -> Some (Some (loop e)) in (ESwitch (e,cases,def),p) | ETry (et,cl) -> let et = loop et in let cl = List.map (fun (n,t,e) -> let old = save() in decl n (Some t) None; let e = loop e in old(); n, t, e ) cl in (ETry (et,cl),p) | EDisplay (s,call) -> typing_side_effect := true; let tmp_locals = ref [] in let tmp_hlocals = ref PMap.empty in let rec subst_locals locals e = match fst e with | EConst (Ident n) -> let p = snd e in (try (match PMap.find n locals.r with | Some t , _ -> (ECheckType ((EConst (Ident "null"),p),t),p) | _, Some (id,e,lc) -> let name = (try PMap.find id (!tmp_hlocals) with Not_found -> let e = subst_locals lc e in let name = "$tmp_" ^ string_of_int id in tmp_locals := (name,None,Some e) :: !tmp_locals; tmp_hlocals := PMap.add id name !tmp_hlocals; name ) in (EConst (Ident name),p) | None, None -> (* we can't replace the var *) raise Exit) with Not_found -> (* not found locals are most likely to be member/static vars *) e) | EFunction (_,f) -> Ast.map_expr (subst_locals { r = PMap.foldi (fun n i acc -> if List.exists (fun (a,_,_,_) -> a = n) f.f_args then acc else PMap.add n i acc) locals.r PMap.empty }) e | _ -> Ast.map_expr (subst_locals locals) e in (try let e = subst_locals locals s in let e = (EBlock [(EVars (List.rev !tmp_locals),p);(EDisplay (e,call),p)],p) in raise (Return e) with Exit -> map e) | EDisplayNew _ -> raise (Return e) | _ -> map e and map e = Ast.map_expr loop e in (try loop e with Return e -> e) (* ---------------------------------------------------------------------- *) haxe_3.2.1+dfsg.orig/parser.ml0000664000175000017500000015020612607337712016156 0ustar andyandy00000000000000(* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *) open Ast type error_msg = | Unexpected of token | Duplicate_default | Missing_semicolon | Unclosed_macro | Unimplemented | Missing_type | Custom of string exception Error of error_msg * pos exception TypePath of string list * (string * bool) option * bool (* in import *) exception Display of expr let error_msg = function | Unexpected t -> "Unexpected "^(s_token t) | Duplicate_default -> "Duplicate default" | Missing_semicolon -> "Missing ;" | Unclosed_macro -> "Unclosed macro" | Unimplemented -> "Not implemented for current platform" | Missing_type -> "Missing type declaration" | Custom s -> s let error m p = raise (Error (m,p)) let display_error : (error_msg -> pos -> unit) ref = ref (fun _ _ -> assert false) let quoted_ident_prefix = "@$__hx__" let quote_ident s = quoted_ident_prefix ^ s let unquote_ident f = let pf = quoted_ident_prefix in let pflen = String.length pf in let is_quoted = String.length f >= pflen && String.sub f 0 pflen = pf in let s = if is_quoted then String.sub f pflen (String.length f - pflen) else f in let is_valid = not is_quoted || try for i = 0 to String.length s - 1 do match String.unsafe_get s i with | 'a'..'z' | 'A'..'Z' | '_' -> () | '0'..'9' when i > 0 -> () | _ -> raise Exit done; if Hashtbl.mem Lexer.keywords s then raise Exit; true with Exit -> false in s,is_quoted,is_valid let cache = ref (DynArray.create()) let last_doc = ref None let use_doc = ref false let use_parser_resume = ref true let resume_display = ref null_pos let in_macro = ref false let last_token s = let n = Stream.count s in DynArray.get (!cache) (if n = 0 then 0 else n - 1) let serror() = raise (Stream.Error "") let do_resume() = !resume_display <> null_pos let display e = raise (Display e) let type_path sl in_import = match sl with | n :: l when n.[0] >= 'A' && n.[0] <= 'Z' -> raise (TypePath (List.rev l,Some (n,false),in_import)); | _ -> raise (TypePath (List.rev sl,None,in_import)) let is_resuming p = let p2 = !resume_display in p.pmax = p2.pmin && !use_parser_resume && Common.unique_full_path p.pfile = p2.pfile let set_resume p = resume_display := { p with pfile = Common.unique_full_path p.pfile } let is_dollar_ident e = match fst e with | EConst (Ident n) when n.[0] = '$' -> true | _ -> false let precedence op = let left = true and right = false in match op with | OpMod -> 0, left | OpMult | OpDiv -> 1, left | OpAdd | OpSub -> 2, left | OpShl | OpShr | OpUShr -> 3, left | OpOr | OpAnd | OpXor -> 4, left | OpEq | OpNotEq | OpGt | OpLt | OpGte | OpLte -> 5, left | OpInterval -> 6, left | OpBoolAnd -> 7, left | OpBoolOr -> 8, left | OpArrow -> 9, right | OpAssign | OpAssignOp _ -> 10, right let is_not_assign = function | OpAssign | OpAssignOp _ -> false | _ -> true let swap op1 op2 = let p1, left1 = precedence op1 in let p2, _ = precedence op2 in left1 && p1 <= p2 let rec make_binop op e ((v,p2) as e2) = match v with | EBinop (_op,_e,_e2) when swap op _op -> let _e = make_binop op e _e in EBinop (_op,_e,_e2) , punion (pos _e) (pos _e2) | ETernary (e1,e2,e3) when is_not_assign op -> let e = make_binop op e e1 in ETernary (e,e2,e3) , punion (pos e) (pos e3) | _ -> EBinop (op,e,e2) , punion (pos e) (pos e2) let rec make_unop op ((v,p2) as e) p1 = match v with | EBinop (bop,e,e2) -> EBinop (bop, make_unop op e p1 , e2) , (punion p1 p2) | ETernary (e1,e2,e3) -> ETernary (make_unop op e1 p1 , e2, e3), punion p1 p2 | _ -> EUnop (op,Prefix,e), punion p1 p2 let rec make_meta name params ((v,p2) as e) p1 = match v with | EBinop (bop,e,e2) -> EBinop (bop, make_meta name params e p1 , e2) , (punion p1 p2) | ETernary (e1,e2,e3) -> ETernary (make_meta name params e1 p1 , e2, e3), punion p1 p2 | _ -> EMeta((name,params,p1),e),punion p1 p2 let reify in_macro = let cur_pos = ref None in let mk_enum ename n vl p = let constr = (EConst (Ident n),p) in match vl with | [] -> constr | _ -> (ECall (constr,vl),p) in let to_const c p = let cst n v = mk_enum "Constant" n [EConst (String v),p] p in match c with | Int i -> cst "CInt" i | String s -> cst "CString" s | Float s -> cst "CFloat" s | Ident s -> cst "CIdent" s | Regexp (r,o) -> mk_enum "Constant" "CRegexp" [(EConst (String r),p);(EConst (String o),p)] p in let rec to_binop o p = let op n = mk_enum "Binop" n [] p in match o with | OpAdd -> op "OpAdd" | OpMult -> op "OpMult" | OpDiv -> op "OpDiv" | OpSub -> op "OpSub" | OpAssign -> op "OpAssign" | OpEq -> op "OpEq" | OpNotEq -> op "OpNotEq" | OpGt -> op "OpGt" | OpGte -> op "OpGte" | OpLt -> op "OpLt" | OpLte -> op "OpLte" | OpAnd -> op "OpAnd" | OpOr -> op "OpOr" | OpXor -> op "OpXor" | OpBoolAnd -> op "OpBoolAnd" | OpBoolOr -> op "OpBoolOr" | OpShl -> op "OpShl" | OpShr -> op "OpShr" | OpUShr -> op "OpUShr" | OpMod -> op "OpMod" | OpAssignOp o -> mk_enum "Binop" "OpAssignOp" [to_binop o p] p | OpInterval -> op "OpInterval" | OpArrow -> op "OpArrow" in let to_string s p = let len = String.length s in if len > 1 && s.[0] = '$' then (EConst (Ident (String.sub s 1 (len - 1))),p) else (EConst (String s),p) in let to_array f a p = (EArrayDecl (List.map (fun s -> f s p) a),p) in let to_null p = (EConst (Ident "null"),p) in let to_opt f v p = match v with | None -> to_null p | Some v -> f v p in let to_bool o p = (EConst (Ident (if o then "true" else "false")),p) in let to_obj fields p = (EObjectDecl fields,p) in let rec to_tparam t p = let n, v = (match t with | TPType t -> "TPType", to_ctype t p | TPExpr e -> "TPExpr", to_expr e p ) in mk_enum "TypeParam" n [v] p and to_tpath t p = let len = String.length t.tname in if t.tpackage = [] && len > 1 && t.tname.[0] = '$' then (EConst (Ident (String.sub t.tname 1 (len - 1))),p) else begin let fields = [ ("pack", to_array to_string t.tpackage p); ("name", to_string t.tname p); ("params", to_array to_tparam t.tparams p); ] in to_obj (match t.tsub with None -> fields | Some s -> fields @ ["sub",to_string s p]) p end and to_ctype t p = let ct n vl = mk_enum "ComplexType" n vl p in match t with | CTPath { tpackage = []; tparams = []; tsub = None; tname = n } when n.[0] = '$' -> to_string n p | CTPath t -> ct "TPath" [to_tpath t p] | CTFunction (args,ret) -> ct "TFunction" [to_array to_ctype args p; to_ctype ret p] | CTAnonymous fields -> ct "TAnonymous" [to_array to_cfield fields p] | CTParent t -> ct "TParent" [to_ctype t p] | CTExtend (tl,fields) -> ct "TExtend" [to_array to_tpath tl p; to_array to_cfield fields p] | CTOptional t -> ct "TOptional" [to_ctype t p] and to_fun f p = let farg (n,o,t,e) p = let fields = [ "name", to_string n p; "opt", to_bool o p; "type", to_opt to_ctype t p; ] in to_obj (match e with None -> fields | Some e -> fields @ ["value",to_expr e p]) p in let rec fparam t p = let fields = [ "name", to_string t.tp_name p; "constraints", to_array to_ctype t.tp_constraints p; "params", to_array fparam t.tp_params p; ] in to_obj fields p in let fields = [ ("args",to_array farg f.f_args p); ("ret",to_opt to_ctype f.f_type p); ("expr",to_opt to_expr f.f_expr p); ("params",to_array fparam f.f_params p); ] in to_obj fields p and to_cfield f p = let p = f.cff_pos in let to_access a p = let n = (match a with | APublic -> "APublic" | APrivate -> "APrivate" | AStatic -> "AStatic" | AOverride -> "AOverride" | ADynamic -> "ADynamic" | AInline -> "AInline" | AMacro -> "AMacro" ) in mk_enum "Access" n [] p in let to_kind k = let n, vl = (match k with | FVar (ct,e) -> "FVar", [to_opt to_ctype ct p;to_opt to_expr e p] | FFun f -> "FFun", [to_fun f p] | FProp (get,set,t,e) -> "FProp", [to_string get p; to_string set p; to_opt to_ctype t p; to_opt to_expr e p] ) in mk_enum "FieldType" n vl p in let fields = [ Some ("name", to_string f.cff_name p); (match f.cff_doc with None -> None | Some s -> Some ("doc", to_string s p)); (match f.cff_access with [] -> None | l -> Some ("access", to_array to_access l p)); Some ("kind", to_kind f.cff_kind); Some ("pos", to_pos f.cff_pos); (match f.cff_meta with [] -> None | l -> Some ("meta", to_meta f.cff_meta p)); ] in let fields = List.rev (List.fold_left (fun acc v -> match v with None -> acc | Some e -> e :: acc) [] fields) in to_obj fields p and to_meta m p = to_array (fun (m,el,p) _ -> let fields = [ "name", to_string (fst (Common.MetaInfo.to_string m)) p; "params", to_expr_array el p; "pos", to_pos p; ] in to_obj fields p ) m p and to_pos p = match !cur_pos with | Some p -> p | None -> let file = (EConst (String p.pfile),p) in let pmin = (EConst (Int (string_of_int p.pmin)),p) in let pmax = (EConst (Int (string_of_int p.pmax)),p) in if in_macro then (EUntyped (ECall ((EConst (Ident "__dollar__mk_pos"),p),[file;pmin;pmax]),p),p) else to_obj [("file",file);("min",pmin);("max",pmax)] p and to_expr_array a p = match a with | [EMeta ((Meta.Dollar "a",[],_),e1),_] -> (match fst e1 with EArrayDecl el -> to_expr_array el p | _ -> e1) | _ -> to_array to_expr a p and to_expr e _ = let p = snd e in let expr n vl = let e = mk_enum "ExprDef" n vl p in to_obj [("expr",e);("pos",to_pos p)] p in let loop e = to_expr e (snd e) in match fst e with | EConst (Ident n) when n.[0] = '$' && String.length n > 1 -> to_string n p | EConst c -> expr "EConst" [to_const c p] | EArray (e1,e2) -> expr "EArray" [loop e1;loop e2] | EBinop (op,e1,e2) -> expr "EBinop" [to_binop op p; loop e1; loop e2] | EField (e,s) -> expr "EField" [loop e; to_string s p] | EParenthesis e -> expr "EParenthesis" [loop e] | EObjectDecl fl -> expr "EObjectDecl" [to_array (fun (f,e) -> to_obj [("field",to_string f p);("expr",loop e)]) fl p] | EArrayDecl el -> expr "EArrayDecl" [to_expr_array el p] | ECall (e,el) -> expr "ECall" [loop e;to_expr_array el p] | ENew (t,el) -> expr "ENew" [to_tpath t p;to_expr_array el p] | EUnop (op,flag,e) -> let op = mk_enum "Unop" (match op with | Increment -> "OpIncrement" | Decrement -> "OpDecrement" | Not -> "OpNot" | Neg -> "OpNeg" | NegBits -> "OpNegBits" ) [] p in expr "EUnop" [op;to_bool (flag = Postfix) p;loop e] | EVars vl -> expr "EVars" [to_array (fun (v,t,e) p -> let fields = [ "name", to_string v p; "type", to_opt to_ctype t p; "expr", to_opt to_expr e p; ] in to_obj fields p ) vl p] | EFunction (name,f) -> let name = match name with | None -> to_null p | Some name -> if ExtString.String.starts_with name "inline_$" then begin let real_name = (String.sub name 7 (String.length name - 7)) in let e_name = to_string real_name p in let e_inline = to_string "inline_" p in let e_add = (EBinop(OpAdd,e_inline,e_name),p) in e_add end else to_string name p in expr "EFunction" [name; to_fun f p] | EBlock el -> expr "EBlock" [to_expr_array el p] | EFor (e1,e2) -> expr "EFor" [loop e1;loop e2] | EIn (e1,e2) -> expr "EIn" [loop e1;loop e2] | EIf (e1,e2,eelse) -> expr "EIf" [loop e1;loop e2;to_opt to_expr eelse p] | EWhile (e1,e2,flag) -> expr "EWhile" [loop e1;loop e2;to_bool (flag = NormalWhile) p] | ESwitch (e1,cases,def) -> let scase (el,eg,e) p = to_obj [("values",to_expr_array el p);"guard",to_opt to_expr eg p;"expr",to_opt to_expr e p] p in expr "ESwitch" [loop e1;to_array scase cases p;to_opt (to_opt to_expr) def p] | ETry (e1,catches) -> let scatch (n,t,e) p = to_obj [("name",to_string n p);("type",to_ctype t p);("expr",loop e)] p in expr "ETry" [loop e1;to_array scatch catches p] | EReturn eo -> expr "EReturn" [to_opt to_expr eo p] | EBreak -> expr "EBreak" [] | EContinue -> expr "EContinue" [] | EUntyped e -> expr "EUntyped" [loop e] | EThrow e -> expr "EThrow" [loop e] | ECast (e,ct) -> expr "ECast" [loop e; to_opt to_ctype ct p] | EDisplay (e,flag) -> expr "EDisplay" [loop e; to_bool flag p] | EDisplayNew t -> expr "EDisplayNew" [to_tpath t p] | ETernary (e1,e2,e3) -> expr "ETernary" [loop e1;loop e2;loop e3] | ECheckType (e1,ct) -> expr "ECheckType" [loop e1; to_ctype ct p] | EMeta ((m,ml,p),e1) -> match m, ml with | Meta.Dollar ("" | "e"), _ -> e1 | Meta.Dollar "a", _ -> expr "EArrayDecl" (match fst e1 with EArrayDecl el -> [to_expr_array el p] | _ -> [e1]) | Meta.Dollar "b", _ -> expr "EBlock" [e1] (* TODO: can $v and $i be implemented better? *) | Meta.Dollar "v", _ -> begin match fst e1 with | EParenthesis (ECheckType (e2, CTPath{tname="String";tpackage=[]}),_) -> expr "EConst" [mk_enum "Constant" "CString" [e2] (pos e2)] | EParenthesis (ECheckType (e2, CTPath{tname="Int";tpackage=[]}),_) -> expr "EConst" [mk_enum "Constant" "CInt" [e2] (pos e2)] | EParenthesis (ECheckType (e2, CTPath{tname="Float";tpackage=[]}),_) -> expr "EConst" [mk_enum "Constant" "CFloat" [e2] (pos e2)] | _ -> (ECall ((EField ((EField ((EField ((EConst (Ident "haxe"),p),"macro"),p),"Context"),p),"makeExpr"),p),[e; to_pos (pos e)]),p) end | Meta.Dollar "i", _ -> expr "EConst" [mk_enum "Constant" "CIdent" [e1] (pos e1)] | Meta.Dollar "p", _ -> (ECall ((EField ((EField ((EField ((EConst (Ident "haxe"),p),"macro"),p),"MacroStringTools"),p),"toFieldExpr"),p),[e]),p) | Meta.Custom ":pos", [pexpr] -> let old = !cur_pos in cur_pos := Some pexpr; let e = loop e1 in cur_pos := old; e | _ -> expr "EMeta" [to_obj [("name",to_string (fst (Common.MetaInfo.to_string m)) p);("params",to_expr_array ml p);("pos",to_pos p)] p;loop e1] and to_tparam_decl p t = to_obj [ "name", to_string t.tp_name p; "params", (EArrayDecl (List.map (to_tparam_decl p) t.tp_params),p); "constraints", (EArrayDecl (List.map (fun t -> to_ctype t p) t.tp_constraints),p) ] p and to_type_def (t,p) = match t with | EClass d -> let ext = ref None and impl = ref [] and interf = ref false in List.iter (function | HExtern | HPrivate -> () | HInterface -> interf := true; | HExtends t -> ext := Some (to_tpath t p) | HImplements i -> impl := (to_tpath i p) :: !impl ) d.d_flags; to_obj [ "pack", (EArrayDecl [],p); "name", to_string d.d_name p; "pos", to_pos p; "meta", to_meta d.d_meta p; "params", (EArrayDecl (List.map (to_tparam_decl p) d.d_params),p); "isExtern", to_bool (List.mem HExtern d.d_flags) p; "kind", mk_enum "TypeDefKind" "TDClass" [(match !ext with None -> (EConst (Ident "null"),p) | Some t -> t);(EArrayDecl (List.rev !impl),p);to_bool !interf p] p; "fields", (EArrayDecl (List.map (fun f -> to_cfield f p) d.d_data),p) ] p | _ -> assert false in (fun e -> to_expr e (snd e)), to_ctype, to_type_def let popt f = parser | [< v = f >] -> Some v | [< >] -> None let rec plist f = parser | [< v = f; l = plist f >] -> v :: l | [< >] -> [] let rec psep sep f = parser | [< v = f; s >] -> let rec loop = parser | [< '(sep2,_) when sep2 = sep; v = f; l = loop >] -> v :: l | [< >] -> [] in v :: loop s | [< >] -> [] let ident = parser | [< '(Const (Ident i),p) >] -> i,p let dollar_ident = parser | [< '(Const (Ident i),p) >] -> i,p | [< '(Dollar i,p) >] -> ("$" ^ i),p let dollar_ident_macro pack = parser | [< '(Const (Ident i),p) >] -> i,p | [< '(Dollar i,p) >] -> ("$" ^ i),p | [< '(Kwd Macro,p) when pack <> [] >] -> "macro", p | [< '(Kwd Extern,p) when pack <> [] >] -> "extern", p let lower_ident_or_macro = parser | [< '(Const (Ident i),p) when is_lower_ident i >] -> i | [< '(Kwd Macro,_) >] -> "macro" | [< '(Kwd Extern,_) >] -> "extern" let any_enum_ident = parser | [< i = ident >] -> i | [< '(Kwd k,p) when Filename.basename p.pfile = "StdTypes.hx" >] -> s_keyword k, p let property_ident = parser | [< i, _ = ident >] -> i | [< '(Kwd Dynamic,_) >] -> "dynamic" | [< '(Kwd Default,_) >] -> "default" | [< '(Kwd Null,_) >] -> "null" let get_doc s = (* do the peek first to make sure we fetch the doc *) match Stream.peek s with | None -> None | Some (tk,p) -> match !last_doc with | None -> None | Some (d,pos) -> last_doc := None; if pos = p.pmin then Some d else None let comma = parser | [< '(Comma,_) >] -> () let semicolon s = if fst (last_token s) = BrClose then match s with parser | [< '(Semicolon,p) >] -> p | [< >] -> snd (last_token s) else match s with parser | [< '(Semicolon,p) >] -> p | [< s >] -> let pos = snd (last_token s) in if do_resume() then pos else error Missing_semicolon pos let rec parse_file s = last_doc := None; match s with parser | [< '(Kwd Package,_); pack = parse_package; s >] -> begin match s with parser | [< '(Const(Ident _),p) when pack = [] >] -> error (Custom "Package name must start with a lowercase character") p | [< _ = semicolon; l = parse_type_decls pack []; '(Eof,_) >] -> pack , l end | [< l = parse_type_decls [] []; '(Eof,_) >] -> [] , l and parse_type_decls pack acc s = try match s with parser | [< v = parse_type_decl; l = parse_type_decls pack (v :: acc) >] -> l | [< >] -> List.rev acc with TypePath ([],Some (name,false),b) -> (* resolve imports *) List.iter (fun d -> match fst d with | EImport (t,_) -> (match List.rev t with | (n,_) :: path when n = name && List.for_all (fun (i,_) -> is_lower_ident i) path -> raise (TypePath (List.map fst (List.rev path),Some (name,false),b)) | _ -> ()) | _ -> () ) acc; raise (TypePath (pack,Some(name,true),b)) and parse_type_decl s = match s with parser | [< '(Kwd Import,p1) >] -> parse_import s p1 | [< '(Kwd Using,p1); t = parse_type_path; p2 = semicolon >] -> EUsing t, punion p1 p2 | [< doc = get_doc; meta = parse_meta; c = parse_common_flags; s >] -> match s with parser | [< n , p1 = parse_enum_flags; name = type_name; tl = parse_constraint_params; '(BrOpen,_); l = plist parse_enum; '(BrClose,p2) >] -> (EEnum { d_name = name; d_doc = doc; d_meta = meta; d_params = tl; d_flags = List.map snd c @ n; d_data = l }, punion p1 p2) | [< n , p1 = parse_class_flags; name = type_name; tl = parse_constraint_params; hl = plist parse_class_herit; '(BrOpen,_); fl, p2 = parse_class_fields false p1 >] -> (EClass { d_name = name; d_doc = doc; d_meta = meta; d_params = tl; d_flags = List.map fst c @ n @ hl; d_data = fl; }, punion p1 p2) | [< '(Kwd Typedef,p1); name = type_name; tl = parse_constraint_params; '(Binop OpAssign,p2); t = parse_complex_type; s >] -> (match s with parser | [< '(Semicolon,_) >] -> () | [< >] -> ()); (ETypedef { d_name = name; d_doc = doc; d_meta = meta; d_params = tl; d_flags = List.map snd c; d_data = t; }, punion p1 p2) | [< '(Kwd Abstract,p1); name = type_name; tl = parse_constraint_params; st = parse_abstract_subtype; sl = plist parse_abstract_relations; '(BrOpen,_); fl, p2 = parse_class_fields false p1 >] -> let flags = List.map (fun (_,c) -> match c with EPrivate -> APrivAbstract | EExtern -> error (Custom "extern abstract not allowed") p1) c in let flags = (match st with None -> flags | Some t -> AIsType t :: flags) in (EAbstract { d_name = name; d_doc = doc; d_meta = meta; d_params = tl; d_flags = flags @ sl; d_data = fl; },punion p1 p2) and parse_class doc meta cflags need_name s = let opt_name = if need_name then type_name else (fun s -> match popt type_name s with None -> "" | Some n -> n) in match s with parser | [< n , p1 = parse_class_flags; name = opt_name; tl = parse_constraint_params; hl = psep Comma parse_class_herit; '(BrOpen,_); fl, p2 = parse_class_fields (not need_name) p1 >] -> (EClass { d_name = name; d_doc = doc; d_meta = meta; d_params = tl; d_flags = List.map fst cflags @ n @ hl; d_data = fl; }, punion p1 p2) and parse_import s p1 = let rec loop acc = match s with parser | [< '(Dot,p) >] -> let resume() = type_path (List.map fst acc) true in if is_resuming p then resume(); (match s with parser | [< '(Const (Ident k),p) >] -> loop ((k,p) :: acc) | [< '(Kwd Macro,p) >] -> loop (("macro",p) :: acc) | [< '(Kwd Extern,p) >] -> loop (("extern",p) :: acc) | [< '(Binop OpMult,_); '(Semicolon,p2) >] -> p2, List.rev acc, IAll | [< '(Binop OpOr,_) when do_resume() >] -> set_resume p; resume() | [< >] -> serror()); | [< '(Semicolon,p2) >] -> p2, List.rev acc, INormal | [< '(Kwd In,_); '(Const (Ident name),_); '(Semicolon,p2) >] -> p2, List.rev acc, IAsName name | [< '(Const (Ident "as"),_); '(Const (Ident name),_); '(Semicolon,p2) >] -> p2, List.rev acc, IAsName name | [< >] -> serror() in let p2, path, mode = (match s with parser | [< '(Const (Ident name),p) >] -> loop [name,p] | [< >] -> serror() ) in (EImport (path,mode),punion p1 p2) and parse_abstract_relations s = match s with parser | [< '(Const (Ident "to"),_); t = parse_complex_type >] -> AToType t | [< '(Const (Ident "from"),_); t = parse_complex_type >] -> AFromType t and parse_abstract_subtype s = match s with parser | [< '(POpen, _); t = parse_complex_type; '(PClose,_) >] -> Some t | [< >] -> None and parse_package s = psep Dot lower_ident_or_macro s and parse_class_fields tdecl p1 s = let l = parse_class_field_resume tdecl s in let p2 = (match s with parser | [< '(BrClose,p2) >] -> p2 | [< >] -> if do_resume() then p1 else serror() ) in l, p2 and parse_class_field_resume tdecl s = if not (do_resume()) then plist parse_class_field s else try let c = parse_class_field s in c :: parse_class_field_resume tdecl s with Stream.Error _ | Stream.Failure -> (* look for next variable/function or next type declaration *) let rec junk k = if k <= 0 then () else begin Stream.junk s; junk (k - 1); end in (* walk back tokens which are prefixing a type/field declaration *) let rec junk_tokens k = if k = 0 then () else match List.rev_map fst (Stream.npeek k s) with | Kwd Private :: _ -> junk_tokens (k - 1) | (Const (Ident _) | Kwd _) :: DblDot :: At :: l | (Const (Ident _) | Kwd _) :: At :: l -> junk_tokens (List.length l) | PClose :: l -> (* count matching parenthesises for metadata call *) let rec loop n = function | [] -> [] | POpen :: l -> if n = 0 then l else loop (n - 1) l | PClose :: l -> loop (n + 1) l | _ :: l -> loop n l in (match loop 0 l with | (Const (Ident _) | Kwd _) :: At :: l | (Const (Ident _) | Kwd _) :: DblDot :: At :: l -> junk_tokens (List.length l) | _ -> junk k) | _ -> junk k in let rec loop k = match List.rev_map fst (Stream.npeek k s) with (* metadata *) | Kwd _ :: At :: _ | Kwd _ :: DblDot :: At :: _ -> loop (k + 1) (* field declaration *) | Const _ :: Kwd Function :: _ | Kwd New :: Kwd Function :: _ -> junk_tokens (k - 2); parse_class_field_resume tdecl s | Kwd Macro :: _ | Kwd Public :: _ | Kwd Static :: _ | Kwd Var :: _ | Kwd Override :: _ | Kwd Dynamic :: _ | Kwd Inline :: _ -> junk_tokens (k - 1); parse_class_field_resume tdecl s | BrClose :: _ when tdecl -> junk_tokens (k - 1); [] (* type declaration *) | Eof :: _ | Kwd Import :: _ | Kwd Using :: _ | Kwd Extern :: _ | Kwd Class :: _ | Kwd Interface :: _ | Kwd Enum :: _ | Kwd Typedef :: _ | Kwd Abstract :: _-> junk_tokens (k - 1); [] | [] -> [] | _ -> loop (k + 1) in loop 1 and parse_common_flags = parser | [< '(Kwd Private,_); l = parse_common_flags >] -> (HPrivate, EPrivate) :: l | [< '(Kwd Extern,_); l = parse_common_flags >] -> (HExtern, EExtern) :: l | [< >] -> [] and parse_meta_argument_expr s = try expr s with Display e -> match fst e with | EDisplay(e,_) -> begin try type_path (string_list_of_expr_path_raise e) false with Exit -> e end | _ -> e and parse_meta_params pname s = match s with parser | [< '(POpen,p) when p.pmin = pname.pmax; params = psep Comma parse_meta_argument_expr; '(PClose,_); >] -> params | [< >] -> [] and parse_meta_entry = parser [< '(At,_); name,p = meta_name; params = parse_meta_params p; s >] -> (name,params,p) and parse_meta = parser | [< entry = parse_meta_entry; s >] -> entry :: parse_meta s | [< >] -> [] and meta_name = parser | [< '(Const (Ident i),p) >] -> (Meta.Custom i), p | [< '(Kwd k,p) >] -> (Meta.Custom (s_keyword k)),p | [< '(DblDot,_); s >] -> match s with parser | [< '(Const (Ident i),p) >] -> (Common.MetaInfo.parse i), p | [< '(Kwd k,p) >] -> (Common.MetaInfo.parse (s_keyword k)),p and parse_enum_flags = parser | [< '(Kwd Enum,p) >] -> [] , p and parse_class_flags = parser | [< '(Kwd Class,p) >] -> [] , p | [< '(Kwd Interface,p) >] -> [HInterface] , p and parse_type_hint = parser | [< '(DblDot,_); t = parse_complex_type >] -> t and parse_type_opt = parser | [< t = parse_type_hint >] -> Some t | [< >] -> None and parse_complex_type s = let t = parse_complex_type_inner s in parse_complex_type_next t s and parse_structural_extension = parser | [< '(Binop OpGt,_); t = parse_type_path; '(Comma,_); s >] -> t and parse_complex_type_inner = parser | [< '(POpen,_); t = parse_complex_type; '(PClose,_) >] -> CTParent t | [< '(BrOpen,p1); s >] -> (match s with parser | [< l = parse_type_anonymous false >] -> CTAnonymous l | [< t = parse_structural_extension; s>] -> let tl = t :: plist parse_structural_extension s in (match s with parser | [< l = parse_type_anonymous false >] -> CTExtend (tl,l) | [< l, _ = parse_class_fields true p1 >] -> CTExtend (tl,l)) | [< l, _ = parse_class_fields true p1 >] -> CTAnonymous l | [< >] -> serror()) | [< '(Question,_); t = parse_complex_type_inner >] -> CTOptional t | [< t = parse_type_path >] -> CTPath t and parse_type_path s = parse_type_path1 [] s and parse_type_path1 pack = parser | [< name, p = dollar_ident_macro pack; s >] -> if is_lower_ident name then (match s with parser | [< '(Dot,p) >] -> if is_resuming p then raise (TypePath (List.rev (name :: pack),None,false)) else parse_type_path1 (name :: pack) s | [< '(Semicolon,_) >] -> error (Custom "Type name should start with an uppercase letter") p | [< >] -> serror()) else let sub = (match s with parser | [< '(Dot,p); s >] -> (if is_resuming p then raise (TypePath (List.rev pack,Some (name,false),false)) else match s with parser | [< '(Const (Ident name),_) when not (is_lower_ident name) >] -> Some name | [< '(Binop OpOr,_) when do_resume() >] -> set_resume p; raise (TypePath (List.rev pack,Some (name,false),false)) | [< >] -> serror()) | [< >] -> None ) in let params = (match s with parser | [< '(Binop OpLt,_); l = psep Comma parse_type_path_or_const; '(Binop OpGt,_) >] -> l | [< >] -> [] ) in { tpackage = List.rev pack; tname = name; tparams = params; tsub = sub; } | [< '(Binop OpOr,_) when do_resume() >] -> raise (TypePath (List.rev pack,None,false)) and type_name = parser | [< '(Const (Ident name),p) >] -> if is_lower_ident name then error (Custom "Type name should start with an uppercase letter") p else name | [< '(Dollar name,_) >] -> "$" ^ name and parse_type_path_or_const = parser (* we can't allow (expr) here *) | [< '(BkOpen,p1); l = parse_array_decl; '(BkClose,p2); s >] -> TPExpr (EArrayDecl l, punion p1 p2) | [< t = parse_complex_type >] -> TPType t | [< '(Const c,p) >] -> TPExpr (EConst c,p) | [< e = expr >] -> TPExpr e | [< >] -> serror() and parse_complex_type_next t = parser | [< '(Arrow,_); t2 = parse_complex_type >] -> (match t2 with | CTFunction (args,r) -> CTFunction (t :: args,r) | _ -> CTFunction ([t] , t2)) | [< >] -> t and parse_type_anonymous opt = parser | [< '(Question,_) when not opt; s >] -> parse_type_anonymous true s | [< name, p1 = ident; t = parse_type_hint; s >] -> let next p2 acc = { cff_name = name; cff_meta = if opt then [Meta.Optional,[],p1] else []; cff_access = []; cff_doc = None; cff_kind = FVar (Some t,None); cff_pos = punion p1 p2; } :: acc in match s with parser | [< '(BrClose,p2) >] -> next p2 [] | [< '(Comma,p2) >] -> (match s with parser | [< '(BrClose,_) >] -> next p2 [] | [< l = parse_type_anonymous false >] -> next p2 l | [< >] -> serror()); | [< >] -> serror() and parse_enum s = let doc = get_doc s in let meta = parse_meta s in match s with parser | [< name, p1 = any_enum_ident; params = parse_constraint_params; s >] -> let args = (match s with parser | [< '(POpen,_); l = psep Comma parse_enum_param; '(PClose,_) >] -> l | [< >] -> [] ) in let t = parse_type_opt s in let p2 = (match s with parser | [< p = semicolon >] -> p | [< >] -> serror() ) in { ec_name = name; ec_doc = doc; ec_meta = meta; ec_args = args; ec_params = params; ec_type = t; ec_pos = punion p1 p2; } and parse_enum_param = parser | [< '(Question,_); name, _ = ident; t = parse_type_hint >] -> (name,true,t) | [< name, _ = ident; t = parse_type_hint >] -> (name,false,t) and parse_class_field s = let doc = get_doc s in match s with parser | [< meta = parse_meta; al = parse_cf_rights true []; s >] -> let name, pos, k = (match s with parser | [< '(Kwd Var,p1); name, _ = dollar_ident; s >] -> (match s with parser | [< '(POpen,_); i1 = property_ident; '(Comma,_); i2 = property_ident; '(PClose,_) >] -> let t = parse_type_opt s in let e , p2 = (match s with parser | [< '(Binop OpAssign,_); e = toplevel_expr; p2 = semicolon >] -> Some e , p2 | [< '(Semicolon,p2) >] -> None , p2 | [< >] -> serror() ) in name, punion p1 p2, FProp (i1,i2,t, e) | [< t = parse_type_opt; s >] -> let e , p2 = (match s with parser | [< '(Binop OpAssign,_); e = toplevel_expr; p2 = semicolon >] -> Some e , p2 | [< '(Semicolon,p2) >] -> None , p2 | [< >] -> serror() ) in name, punion p1 p2, FVar (t,e)) | [< '(Kwd Function,p1); name = parse_fun_name; pl = parse_constraint_params; '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; s >] -> let e, p2 = (match s with parser | [< e = toplevel_expr; s >] -> (try ignore(semicolon s) with Error (Missing_semicolon,p) -> !display_error Missing_semicolon p); Some e, pos e | [< '(Semicolon,p) >] -> None, p | [< >] -> serror() ) in let f = { f_params = pl; f_args = al; f_type = t; f_expr = e; } in name, punion p1 p2, FFun f | [< >] -> if al = [] then raise Stream.Failure else serror() ) in { cff_name = name; cff_doc = doc; cff_meta = meta; cff_access = al; cff_pos = pos; cff_kind = k; } and parse_cf_rights allow_static l = parser | [< '(Kwd Static,_) when allow_static; l = parse_cf_rights false (AStatic :: l) >] -> l | [< '(Kwd Macro,_) when not(List.mem AMacro l); l = parse_cf_rights allow_static (AMacro :: l) >] -> l | [< '(Kwd Public,_) when not(List.mem APublic l || List.mem APrivate l); l = parse_cf_rights allow_static (APublic :: l) >] -> l | [< '(Kwd Private,_) when not(List.mem APublic l || List.mem APrivate l); l = parse_cf_rights allow_static (APrivate :: l) >] -> l | [< '(Kwd Override,_) when not (List.mem AOverride l); l = parse_cf_rights false (AOverride :: l) >] -> l | [< '(Kwd Dynamic,_) when not (List.mem ADynamic l); l = parse_cf_rights allow_static (ADynamic :: l) >] -> l | [< '(Kwd Inline,_); l = parse_cf_rights allow_static (AInline :: l) >] -> l | [< >] -> l and parse_fun_name = parser | [< name,_ = dollar_ident >] -> name | [< '(Kwd New,_) >] -> "new" and parse_fun_param = parser | [< '(Question,_); name, _ = dollar_ident; t = parse_type_opt; c = parse_fun_param_value >] -> (name,true,t,c) | [< name, _ = dollar_ident; t = parse_type_opt; c = parse_fun_param_value >] -> (name,false,t,c) and parse_fun_param_value = parser | [< '(Binop OpAssign,_); e = toplevel_expr >] -> Some e | [< >] -> None and parse_fun_param_type = parser | [< '(Question,_); name = ident; t = parse_type_hint >] -> (name,true,t) | [< name = ident; t = parse_type_hint >] -> (name,false,t) and parse_constraint_params = parser | [< '(Binop OpLt,_); l = psep Comma parse_constraint_param; '(Binop OpGt,_) >] -> l | [< >] -> [] and parse_constraint_param = parser | [< name = type_name; s >] -> let params = (match s with parser | [< >] -> [] ) in let ctl = (match s with parser | [< '(DblDot,_); s >] -> (match s with parser | [< '(POpen,_); l = psep Comma parse_complex_type; '(PClose,_) >] -> l | [< t = parse_complex_type >] -> [t] | [< >] -> serror()) | [< >] -> [] ) in { tp_name = name; tp_params = params; tp_constraints = ctl; } and parse_class_herit = parser | [< '(Kwd Extends,_); t = parse_type_path >] -> HExtends t | [< '(Kwd Implements,_); t = parse_type_path >] -> HImplements t and block1 = parser | [< name,p = dollar_ident; s >] -> block2 name (Ident name) p s | [< '(Const (String name),p); s >] -> block2 (quote_ident name) (String name) p s | [< b = block [] >] -> EBlock b and block2 name ident p s = match s with parser | [< '(DblDot,_); e = expr; l = parse_obj_decl >] -> EObjectDecl ((name,e) :: l) | [< >] -> let e = expr_next (EConst ident,p) s in try let _ = semicolon s in let b = block [e] s in EBlock b with | Error (err,p) -> (!display_error) err p; EBlock (block [e] s) and block acc s = try (* because of inner recursion, we can't put Display handling in errors below *) let e = try parse_block_elt s with Display e -> display (EBlock (List.rev (e :: acc)),snd e) in block (e :: acc) s with | Stream.Failure -> List.rev acc | Stream.Error _ -> let tk , pos = (match Stream.peek s with None -> last_token s | Some t -> t) in (!display_error) (Unexpected tk) pos; block acc s | Error (e,p) -> (!display_error) e p; block acc s and parse_block_elt = parser | [< '(Kwd Var,p1); vl = parse_var_decls p1; p2 = semicolon >] -> (EVars vl,punion p1 p2) | [< '(Kwd Inline,p1); '(Kwd Function,_); e = parse_function p1 true; _ = semicolon >] -> e | [< e = expr; _ = semicolon >] -> e and parse_obj_decl = parser | [< '(Comma,_); s >] -> (match s with parser | [< name, _ = ident; '(DblDot,_); e = expr; l = parse_obj_decl >] -> (name,e) :: l | [< '(Const (String name),_); '(DblDot,_); e = expr; l = parse_obj_decl >] -> (quote_ident name,e) :: l | [< >] -> []) | [< >] -> [] and parse_array_decl = parser | [< e = expr; s >] -> (match s with parser | [< '(Comma,_); l = parse_array_decl >] -> e :: l | [< >] -> [e]) | [< >] -> [] and parse_var_decl_head = parser | [< name, _ = dollar_ident; t = parse_type_opt >] -> (name,t) and parse_var_assignment = parser | [< '(Binop OpAssign,p1); s >] -> begin match s with parser | [< e = expr >] -> Some e | [< >] -> error (Custom "expression expected after =") p1 end | [< >] -> None and parse_var_decls_next vl = parser | [< '(Comma,p1); name,t = parse_var_decl_head; s >] -> begin try let eo = parse_var_assignment s in parse_var_decls_next ((name,t,eo) :: vl) s with Display e -> let v = (name,t,Some e) in let e = (EVars(List.rev (v :: vl)),punion p1 (pos e)) in display e end | [< >] -> vl and parse_var_decls p1 = parser | [< name,t = parse_var_decl_head; s >] -> let eo = parse_var_assignment s in List.rev (parse_var_decls_next [name,t,eo] s) | [< s >] -> error (Custom "Missing variable identifier") p1 and parse_var_decl = parser | [< name,t = parse_var_decl_head; eo = parse_var_assignment >] -> (name,t,eo) and inline_function = parser | [< '(Kwd Inline,_); '(Kwd Function,p1) >] -> true, p1 | [< '(Kwd Function,p1) >] -> false, p1 and reify_expr e = let to_expr,_,_ = reify !in_macro in let e = to_expr e in (ECheckType (e,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = None; tparams = [] })),pos e) and parse_macro_expr p = parser | [< '(DblDot,_); t = parse_complex_type >] -> let _, to_type, _ = reify !in_macro in let t = to_type t p in (ECheckType (t,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = Some "ComplexType"; tparams = [] })),p) | [< '(Kwd Var,p1); vl = psep Comma parse_var_decl >] -> reify_expr (EVars vl,p1) | [< d = parse_class None [] [] false >] -> let _,_,to_type = reify !in_macro in (ECheckType (to_type d,(CTPath { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = Some "TypeDefinition"; tparams = [] })),p) | [< e = secure_expr >] -> reify_expr e and parse_function p1 inl = parser | [< name = popt dollar_ident; pl = parse_constraint_params; '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; s >] -> let make e = let f = { f_params = pl; f_type = t; f_args = al; f_expr = Some e; } in EFunction ((match name with None -> None | Some (name,_) -> Some (if inl then "inline_" ^ name else name)),f), punion p1 (pos e) in (try expr_next (make (secure_expr s)) s with Display e -> display (make e)) and expr = parser | [< (name,params,p) = parse_meta_entry; s >] -> (try make_meta name params (secure_expr s) p with Display e -> display (make_meta name params e p)) | [< '(BrOpen,p1); b = block1; '(BrClose,p2); s >] -> let e = (b,punion p1 p2) in (match b with | EObjectDecl _ -> expr_next e s | _ -> e) | [< '(Kwd Macro,p); s >] -> parse_macro_expr p s | [< '(Kwd Var,p1); v = parse_var_decl >] -> (EVars [v],p1) | [< '(Const c,p); s >] -> expr_next (EConst c,p) s | [< '(Kwd This,p); s >] -> expr_next (EConst (Ident "this"),p) s | [< '(Kwd True,p); s >] -> expr_next (EConst (Ident "true"),p) s | [< '(Kwd False,p); s >] -> expr_next (EConst (Ident "false"),p) s | [< '(Kwd Null,p); s >] -> expr_next (EConst (Ident "null"),p) s | [< '(Kwd Cast,p1); s >] -> (match s with parser | [< '(POpen,pp); e = expr; s >] -> (match s with parser | [< '(Comma,_); t = parse_complex_type; '(PClose,p2); s >] -> expr_next (ECast (e,Some t),punion p1 p2) s | [< t = parse_type_hint; '(PClose,p2); s >] -> let ep = EParenthesis (ECheckType(e,t),punion p1 p2), punion p1 p2 in expr_next (ECast (ep,None),punion p1 (pos ep)) s | [< '(PClose,p2); s >] -> let ep = expr_next (EParenthesis(e),punion pp p2) s in expr_next (ECast (ep,None),punion p1 (pos ep)) s | [< >] -> serror()) | [< e = secure_expr >] -> expr_next (ECast (e,None),punion p1 (pos e)) s) | [< '(Kwd Throw,p); e = expr >] -> (EThrow e,p) | [< '(Kwd New,p1); t = parse_type_path; '(POpen,p); s >] -> if is_resuming p then display (EDisplayNew t,punion p1 p); (match s with parser | [< al = psep Comma expr; '(PClose,p2); s >] -> expr_next (ENew (t,al),punion p1 p2) s | [< >] -> serror()) | [< '(POpen,p1); e = expr; s >] -> (match s with parser | [< '(PClose,p2); s >] -> expr_next (EParenthesis e, punion p1 p2) s | [< t = parse_type_hint; '(PClose,p2); s >] -> expr_next (EParenthesis (ECheckType(e,t),punion p1 p2), punion p1 p2) s | [< >] -> serror()) | [< '(BkOpen,p1); l = parse_array_decl; '(BkClose,p2); s >] -> expr_next (EArrayDecl l, punion p1 p2) s | [< '(Kwd Function,p1); e = parse_function p1 false; >] -> e | [< '(Unop op,p1) when is_prefix op; e = expr >] -> make_unop op e p1 | [< '(Binop OpSub,p1); e = expr >] -> let neg s = if s.[0] = '-' then String.sub s 1 (String.length s - 1) else "-" ^ s in (match make_unop Neg e p1 with | EUnop (Neg,Prefix,(EConst (Int i),pc)),p -> EConst (Int (neg i)),p | EUnop (Neg,Prefix,(EConst (Float j),pc)),p -> EConst (Float (neg j)),p | e -> e) (*/* removed unary + : this cause too much syntax errors go unnoticed, such as "a + + 1" (missing 'b') without adding anything to the language | [< '(Binop OpAdd,p1); s >] -> (match s with parser | [< '(Const (Int i),p); e = expr_next (EConst (Int i),p) >] -> e | [< '(Const (Float f),p); e = expr_next (EConst (Float f),p) >] -> e | [< >] -> serror()) */*) | [< '(Kwd For,p); '(POpen,_); it = expr; '(PClose,_); s >] -> (try let e = secure_expr s in (EFor (it,e),punion p (pos e)) with Display e -> display (EFor (it,e),punion p (pos e))) | [< '(Kwd If,p); '(POpen,_); cond = expr; '(PClose,_); e1 = expr; s >] -> let e2 = (match s with parser | [< '(Kwd Else,_); e2 = expr; s >] -> Some e2 | [< >] -> match Stream.npeek 2 s with | [(Semicolon,_); (Kwd Else,_)] -> Stream.junk s; Stream.junk s; Some (secure_expr s) | _ -> None ) in (EIf (cond,e1,e2), punion p (match e2 with None -> pos e1 | Some e -> pos e)) | [< '(Kwd Return,p); e = popt expr >] -> (EReturn e, match e with None -> p | Some e -> punion p (pos e)) | [< '(Kwd Break,p) >] -> (EBreak,p) | [< '(Kwd Continue,p) >] -> (EContinue,p) | [< '(Kwd While,p1); '(POpen,_); cond = expr; '(PClose,_); s >] -> (try let e = secure_expr s in (EWhile (cond,e,NormalWhile),punion p1 (pos e)) with Display e -> display (EWhile (cond,e,NormalWhile),punion p1 (pos e))) | [< '(Kwd Do,p1); e = expr; '(Kwd While,_); '(POpen,_); cond = expr; '(PClose,_); s >] -> (EWhile (cond,e,DoWhile),punion p1 (pos e)) | [< '(Kwd Switch,p1); e = expr; '(BrOpen,_); cases , def = parse_switch_cases e []; '(BrClose,p2); s >] -> (ESwitch (e,cases,def),punion p1 p2) | [< '(Kwd Try,p1); e = expr; cl = plist (parse_catch e); >] -> (ETry (e,cl),p1) | [< '(IntInterval i,p1); e2 = expr >] -> make_binop OpInterval (EConst (Int i),p1) e2 | [< '(Kwd Untyped,p1); e = expr >] -> (EUntyped e,punion p1 (pos e)) | [< '(Dollar v,p); s >] -> expr_next (EConst (Ident ("$"^v)),p) s and expr_next e1 = parser | [< '(BrOpen,p1) when is_dollar_ident e1; eparam = expr; '(BrClose,p2); s >] -> (match fst e1 with | EConst(Ident n) -> expr_next (EMeta((Common.MetaInfo.from_string n,[],snd e1),eparam), punion p1 p2) s | _ -> assert false) | [< '(Dot,p); s >] -> if is_resuming p then display (EDisplay (e1,false),p); (match s with parser | [< '(Kwd Macro,p2) when p.pmax = p2.pmin; s >] -> expr_next (EField (e1,"macro") , punion (pos e1) p2) s | [< '(Kwd New,p2) when p.pmax = p2.pmin; s >] -> expr_next (EField (e1,"new") , punion (pos e1) p2) s | [< '(Const (Ident f),p2) when p.pmax = p2.pmin; s >] -> expr_next (EField (e1,f) , punion (pos e1) p2) s | [< '(Dollar v,p2); s >] -> expr_next (EField (e1,"$"^v) , punion (pos e1) p2) s | [< '(Binop OpOr,p2) when do_resume() >] -> set_resume p; display (EDisplay (e1,false),p) (* help for debug display mode *) | [< >] -> (* turn an integer followed by a dot into a float *) match e1 with | (EConst (Int v),p2) when p2.pmax = p.pmin -> expr_next (EConst (Float (v ^ ".")),punion p p2) s | _ -> serror()) | [< '(POpen,p1); s >] -> if is_resuming p1 then display (EDisplay (e1,true),p1); (match s with parser | [< '(Binop OpOr,p2) when do_resume() >] -> set_resume p1; display (EDisplay (e1,true),p1) (* help for debug display mode *) | [< params = parse_call_params e1; '(PClose,p2); s >] -> expr_next (ECall (e1,params) , punion (pos e1) p2) s | [< >] -> serror()) | [< '(BkOpen,_); e2 = expr; '(BkClose,p2); s >] -> expr_next (EArray (e1,e2), punion (pos e1) p2) s | [< '(Binop OpGt,p1); s >] -> (match s with parser | [< '(Binop OpGt,p2) when p1.pmax = p2.pmin; s >] -> (match s with parser | [< '(Binop OpGt,p3) when p2.pmax = p3.pmin >] -> (match s with parser | [< '(Binop OpAssign,p4) when p3.pmax = p4.pmin; e2 = expr >] -> make_binop (OpAssignOp OpUShr) e1 e2 | [< e2 = secure_expr >] -> make_binop OpUShr e1 e2) | [< '(Binop OpAssign,p3) when p2.pmax = p3.pmin; e2 = expr >] -> make_binop (OpAssignOp OpShr) e1 e2 | [< e2 = secure_expr >] -> make_binop OpShr e1 e2) | [< '(Binop OpAssign,p2) when p1.pmax = p2.pmin; s >] -> make_binop OpGte e1 (secure_expr s) | [< e2 = secure_expr >] -> make_binop OpGt e1 e2) | [< '(Binop op,_); s >] -> (try (match s with parser | [< e2 = expr >] -> make_binop op e1 e2 | [< >] -> serror()) with Display e2 -> raise (Display (make_binop op e1 e2))) | [< '(Unop op,p) when is_postfix e1 op; s >] -> expr_next (EUnop (op,Postfix,e1), punion (pos e1) p) s | [< '(Question,_); e2 = expr; '(DblDot,_); e3 = expr >] -> (ETernary (e1,e2,e3),punion (pos e1) (pos e3)) | [< '(Kwd In,_); e2 = expr >] -> (EIn (e1,e2), punion (pos e1) (pos e2)) | [< >] -> e1 and parse_guard = parser | [< '(Kwd If,p1); '(POpen,_); e = expr; '(PClose,_); >] -> e and parse_switch_cases eswitch cases = parser | [< '(Kwd Default,p1); '(DblDot,_); s >] -> let b = (try block [] s with Display e -> display (ESwitch (eswitch,cases,Some (Some e)),punion (pos eswitch) (pos e))) in let b = match b with | [] -> None | _ -> Some ((EBlock b,p1)) in let l , def = parse_switch_cases eswitch cases s in (match def with None -> () | Some _ -> error Duplicate_default p1); l , Some b | [< '(Kwd Case,p1); el = psep Comma expr; eg = popt parse_guard; '(DblDot,_); s >] -> (match el with | [] -> error (Custom "case without a pattern is not allowed") p1 | _ -> let b = (try block [] s with Display e -> display (ESwitch (eswitch,List.rev ((el,eg,Some e) :: cases),None),punion (pos eswitch) (pos e))) in let b = match b with | [] -> None | _ -> Some ((EBlock b,p1)) in parse_switch_cases eswitch ((el,eg,b) :: cases) s ) | [< >] -> List.rev cases , None and parse_catch etry = parser | [< '(Kwd Catch,p); '(POpen,_); name, _ = dollar_ident; s >] -> match s with parser | [< t = parse_type_hint; '(PClose,_); s >] -> (try (name,t,secure_expr s) with Display e -> display (ETry (etry,[name,t,e]),punion (pos etry) (pos e))) | [< '(_,p) >] -> error Missing_type p and parse_call_params ec s = let e = (try match s with parser | [< e = expr >] -> Some e | [< >] -> None with Display e -> display (ECall (ec,[e]),punion (pos ec) (pos e)) ) in let rec loop acc = try match s with parser | [< '(Comma,_); e = expr >] -> loop (e::acc) | [< >] -> List.rev acc with Display e -> display (ECall (ec,List.rev (e::acc)),punion (pos ec) (pos e)) in match e with | None -> [] | Some e -> loop [e] and parse_macro_cond allow_op s = match s with parser | [< '(Const (Ident t),p) >] -> parse_macro_ident allow_op t p s | [< '(Const (String s),p) >] -> None, (EConst (String s),p) | [< '(Const (Int i),p) >] -> None, (EConst (Int i),p) | [< '(Const (Float f),p) >] -> None, (EConst (Float f),p) | [< '(Kwd k,p) >] -> parse_macro_ident allow_op (s_keyword k) p s | [< '(POpen, p1); _,e = parse_macro_cond true; '(PClose, p2) >] -> let e = (EParenthesis e,punion p1 p2) in if allow_op then parse_macro_op e s else None, e | [< '(Unop op,p); tk, e = parse_macro_cond allow_op >] -> tk, make_unop op e p and parse_macro_ident allow_op t p s = let e = (EConst (Ident t),p) in if not allow_op then None, e else parse_macro_op e s and parse_macro_op e s = match Stream.peek s with | Some (Binop op,_) -> Stream.junk s; let op = match Stream.peek s with | Some (Binop OpAssign,_) when op = OpGt -> Stream.junk s; OpGte | _ -> op in let tk, e2 = (try parse_macro_cond true s with Stream.Failure -> serror()) in tk, make_binop op e e2 | tk -> tk, e and toplevel_expr s = try expr s with Display e -> e and secure_expr s = match s with parser | [< e = expr >] -> e | [< >] -> serror() (* eval *) type small_type = | TNull | TBool of bool | TFloat of float | TString of string let is_true = function | TBool false | TNull | TFloat 0. | TString "" -> false | _ -> true let cmp v1 v2 = match v1, v2 with | TNull, TNull -> 0 | TFloat a, TFloat b -> compare a b | TString a, TString b -> compare a b | TBool a, TBool b -> compare a b | TString a, TFloat b -> compare (float_of_string a) b | TFloat a, TString b -> compare a (float_of_string b) | _ -> raise Exit (* always false *) let rec eval ctx (e,p) = match e with | EConst (Ident i) -> (try TString (Common.raw_defined_value ctx i) with Not_found -> TNull) | EConst (String s) -> TString s | EConst (Int i) -> TFloat (float_of_string i) | EConst (Float f) -> TFloat (float_of_string f) | EBinop (OpBoolAnd, e1, e2) -> TBool (is_true (eval ctx e1) && is_true (eval ctx e2)) | EBinop (OpBoolOr, e1, e2) -> TBool (is_true (eval ctx e1) || is_true(eval ctx e2)) | EUnop (Not, _, e) -> TBool (not (is_true (eval ctx e))) | EParenthesis e -> eval ctx e | EBinop (op, e1, e2) -> let v1 = eval ctx e1 in let v2 = eval ctx e2 in let compare op = TBool (try op (cmp v1 v2) 0 with _ -> false) in (match op with | OpEq -> compare (=) | OpNotEq -> compare (<>) | OpGt -> compare (>) | OpGte -> compare (>=) | OpLt -> compare (<) | OpLte -> compare (<=) | _ -> error (Custom "Unsupported operation") p) | _ -> error (Custom "Invalid condition expression") p (* parse main *) let parse ctx code = let old = Lexer.save() in let old_cache = !cache in let mstack = ref [] in cache := DynArray.create(); last_doc := None; in_macro := Common.defined ctx Common.Define.Macro; Lexer.skip_header code; let sraw = Stream.from (fun _ -> Some (Lexer.token code)) in let rec next_token() = process_token (Lexer.token code) and process_token tk = match fst tk with | Comment s -> let tk = next_token() in if !use_doc then begin let l = String.length s in if l > 0 && s.[0] = '*' then last_doc := Some (String.sub s 1 (l - (if l > 1 && s.[l-1] = '*' then 2 else 1)), (snd tk).pmin); end; tk | CommentLine s -> next_token() | Sharp "end" -> (match !mstack with | [] -> tk | _ :: l -> mstack := l; next_token()) | Sharp "else" | Sharp "elseif" -> (match !mstack with | [] -> tk | _ :: l -> mstack := l; process_token (skip_tokens (snd tk) false)) | Sharp "if" -> process_token (enter_macro (snd tk)) | Sharp "error" -> (match Lexer.token code with | (Const (String s),p) -> error (Custom s) p | _ -> error Unimplemented (snd tk)) | Sharp "line" -> let line = (match next_token() with | (Const (Int s),_) -> int_of_string s | (t,p) -> error (Unexpected t) p ) in !(Lexer.cur).Lexer.lline <- line - 1; next_token(); | _ -> tk and enter_macro p = let tk, e = parse_macro_cond false sraw in let tk = (match tk with None -> Lexer.token code | Some tk -> tk) in if is_true (eval ctx e) || (match fst e with EConst (Ident "macro") when Common.unique_full_path p.pfile = (!resume_display).pfile -> true | _ -> false) then begin mstack := p :: !mstack; tk end else skip_tokens_loop p true tk and skip_tokens_loop p test tk = match fst tk with | Sharp "end" -> Lexer.token code | Sharp "elseif" | Sharp "else" when not test -> skip_tokens p test | Sharp "else" -> mstack := snd tk :: !mstack; Lexer.token code | Sharp "elseif" -> enter_macro (snd tk) | Sharp "if" -> skip_tokens_loop p test (skip_tokens p false) | Eof -> if do_resume() then tk else error Unclosed_macro p | _ -> skip_tokens p test and skip_tokens p test = skip_tokens_loop p test (Lexer.token code) in let s = Stream.from (fun _ -> let t = next_token() in DynArray.add (!cache) t; Some t ) in try let l = parse_file s in (match !mstack with p :: _ when not (do_resume()) -> error Unclosed_macro p | _ -> ()); cache := old_cache; Lexer.restore old; l with | Stream.Error _ | Stream.Failure -> let last = (match Stream.peek s with None -> last_token s | Some t -> t) in Lexer.restore old; cache := old_cache; error (Unexpected (fst last)) (pos last) | e -> Lexer.restore old; cache := old_cache; raise e haxe_3.2.1+dfsg.orig/std/Array.hx0000664000175000017500000002202112607337712016532 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** An Array is a storage for values. You can access it using indexes or with its API. **/ extern class Array { /** The length of `this` Array. **/ var length(default,null) : Int; /** Creates a new Array. **/ function new() : Void; /** Returns a new Array by appending the elements of `a` to the elements of `this` Array. This operation does not modify `this` Array. If `a` is the empty Array `[]`, a copy of `this` Array is returned. The length of the returned Array is equal to the sum of `this.length` and `a.length`. If `a` is `null`, the result is unspecified. **/ function concat( a : Array ) : Array; /** Returns a string representation of `this` Array, with `sep` separating each element. The result of this operation is equal to `Std.string(this[0]) + sep + Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1])` If `this` is the empty Array `[]`, the result is the empty String `""`. If `this` has exactly one element, the result is equal to a call to `Std.string(this[0])`. If `sep` is null, the result is unspecified. **/ function join( sep : String ) : String; /** Removes the last element of `this` Array and returns it. This operation modifies `this` Array in place. If `this` has at least one element, `this.length` will decrease by 1. If `this` is the empty Array `[]`, null is returned and the length remains 0. **/ function pop() : Null; /** Adds the element `x` at the end of `this` Array and returns the new length of `this` Array. This operation modifies `this` Array in place. `this.length` increases by 1. **/ function push(x : T) : Int; /** Reverse the order of elements of `this` Array. This operation modifies `this` Array in place. If `this.length < 2`, `this` remains unchanged. **/ function reverse() : Void; /** Removes the first element of `this` Array and returns it. This operation modifies `this` Array in place. If `this` has at least one element, `this`.length and the index of each remaining element is decreased by 1. If `this` is the empty Array `[]`, `null` is returned and the length remains 0. **/ function shift() : Null; /** Creates a shallow copy of the range of `this` Array, starting at and including `pos`, up to but not including `end`. This operation does not modify `this` Array. The elements are not copied and retain their identity. If `end` is omitted or exceeds `this.length`, it defaults to the end of `this` Array. If `pos` or `end` are negative, their offsets are calculated from the end of `this` Array by `this.length + pos` and `this.length + end` respectively. If this yields a negative value, 0 is used instead. If `pos` exceeds `this.length` or if `end` exceeds or equals `pos`, the result is `[]`. **/ function slice( pos : Int, ?end : Int ) : Array; /** Sorts `this` Array according to the comparison function `f`, where `f(x,y)` returns 0 if x == y, a positive Int if x > y and a negative Int if x < y. This operation modifies `this` Array in place. The sort operation is not guaranteed to be stable, which means that the order of equal elements may not be retained. For a stable Array sorting algorithm, `haxe.ds.ArraySort.sort()` can be used instead. If `f` is null, the result is unspecified. **/ function sort( f : T -> T -> Int ) : Void; /** Removes `len` elements from `this` Array, starting at and including `pos`, an returns them. This operation modifies `this` Array in place. If `len` is < 0 or `pos` exceeds `this`.length, the result is the empty Array []. If `pos` is negative, its value is calculated from the end of `this` Array by `this.length + pos`. If this yields a negative value, 0 is used instead. If the sum of the resulting values for `len` and `pos` exceed `this.length`, this operation will affect the elements from `pos` to the end of `this` Array. The length of the returned Array is equal to the new length of `this` Array subtracted from the original length of `this` Array. In other words, each element of the original `this` Array either remains in `this` Array or becomes an element of the returned Array. **/ function splice( pos : Int, len : Int ) : Array; /** Returns a string representation of `this` Array. The result will include the individual elements' String representations separated by comma. The enclosing [ ] may be missing on some platforms, use Std.string() to get a String representation that is consistent across platforms. **/ function toString() : String; /** Adds the element `x` at the start of `this` Array. This operation modifies `this` Array in place. `this.length` and the index of each Array element increases by 1. **/ function unshift( x : T ) : Void; /** Inserts the element `x` at the position `pos`. This operation modifies `this` Array in place. The offset is calculated like so: - If `pos` exceeds `this.length`, the offset is `this.length`. - If `pos` is negative, the offset is calculated from the end of `this` Array, i.e. `this.length + pos`. If this yields a negative value, the offset is 0. - Otherwise, the offset is `pos`. If the resulting offset does not exceed `this.length`, all elements from and including that offset to the end of `this` Array are moved one index ahead. **/ function insert( pos : Int, x : T ) : Void; /** Removes the first occurence of `x` in `this` Array. This operation modifies `this` Array in place. If `x` is found by checking standard equality, it is removed from `this` Array and all following elements are reindexed acoordingly. The function then returns true. If `x` is not found, `this` Array is not changed and the function returns false. **/ function remove( x : T ) : Bool; /** Returns position of the first occurense of `x` in `this` Array, searching front to back. If `x` is found by checking standard equality, the function returns its index. If `x` is not found, the function returns -1. If `fromIndex` is specified, it will be used as the starting index to search from, otherwise search starts with zero index. If it is negative, it will be taken as the offset from the end of `this` Array to compute the starting index. If given or computed starting index is less than 0, the whole array will be searched, if it is greater than or equal to the length of `this` Array, the function returns -1. **/ function indexOf( x : T, ?fromIndex:Int ) : Int; /** Returns position of the last occurense of `x` in `this` Array, searching back to front. If `x` is found by checking standard equality, the function returns its index. If `x` is not found, the function returns -1. If `fromIndex` is specified, it will be used as the starting index to search from, otherwise search starts with the last element index. If it is negative, it will be taken as the offset from the end of `this` Array to compute the starting index. If given or computed starting index is greater than or equal to the length of `this` Array, the whole array will be searched, if it is less than 0, the function returns -1. **/ function lastIndexOf( x : T, ?fromIndex:Int ) : Int; /** Returns a shallow copy of `this` Array. The elements are not copied and retain their identity, so `a[i] == a.copy()[i]` is true for any valid `i`. However, `a == a.copy()` is always false. **/ function copy() : Array; /** Returns an iterator of the Array values. **/ function iterator() : Iterator; /** Creates a new Array by applying function `f` to all elements of `this`. The order of elements is preserved. If `f` is null, the result is unspecified. **/ function map( f : T -> S ) : Array; /** Returns an Array containing those elements of `this` for which `f` returned true. The individual elements are not duplicated and retain their identity. If `f` is null, the result is unspecified. **/ function filter( f : T -> Bool ) : Array; } haxe_3.2.1+dfsg.orig/std/Class.hx0000664000175000017500000000236112607337712016526 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** An abstract type that represents a Class. See `Type` for the Haxe Reflection API. **/ @:coreType @:runtimeValue abstract Class { } haxe_3.2.1+dfsg.orig/std/Date.hx0000664000175000017500000001142112607337712016333 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** The Date class provides a basic structure for date and time related information. Date instances can be created by - `new Date()` for a specific date, - `Date.now()` to obtain information about the current time, - `Date.fromTime()` with a given timestamp or - `Date.fromString()` by parsing from a String. There is some extra functions available in the `DateTools` class. In the context of haxe dates, a timestamp is defined as the number of milliseconds elapsed since 1st January 1970. **/ extern class Date { /** Creates a new date object from the given arguments. The behaviour of a Date instance is only consistent across platforms if the the arguments describe a valid date. - month: 0 to 11 - day: 1 to 31 - hour: 0 to 23 - min: 0 to 59 - sec: 0 to 59 **/ function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void; /** Returns the timestamp of the date. It might only have a per-second precision depending on the platforms. **/ function getTime() : Float; /** Returns the hours of `this` Date (0-23 range). **/ function getHours() : Int; /** Returns the minutes of `this` Date (0-59 range). **/ function getMinutes() : Int; /** Returns the seconds of the `this` Date (0-59 range). **/ function getSeconds() : Int; /** Returns the full year of `this` Date (4-digits). **/ function getFullYear() : Int; /** Returns the month of `this` Date (0-11 range). **/ function getMonth() : Int; /** Returns the day of `this` Date (1-31 range). **/ function getDate() : Int; /** Returns the day of the week of `this` Date (0-6 range). **/ function getDay() : Int; /** Returns a string representation of `this` Date, by using the standard format [YYYY-MM-DD HH:MM:SS]. See `DateTools.format` for other formating rules. **/ function toString():String; /** Returns a Date representing the current local time. **/ static function now() : Date; /** Returns a Date from timestamp `t`. **/ static function fromTime( t : Float ) : Date; /** Returns a Date from a formated string `s`, with the following accepted formats: - `"YYYY-MM-DD hh:mm:ss"` - `"YYYY-MM-DD"` - `"hh:mm:ss"` The first two formats are expressed in local time, the third in UTC Epoch. **/ static function fromString( s : String ) : Date; #if flash private static function __init__() : Void untyped { var d : Dynamic = Date; d.now = function() { return __new__(Date); }; d.fromTime = function(t){ var d : Date = __new__(Date); d.setTime(t); return d; }; d.fromString = function(s : String) { switch( s.length ) { case 8: // hh:mm:ss var k = s.split(":"); var d : Date = __new__(Date); d.setTime(0); d.setUTCHours(k[0]); d.setUTCMinutes(k[1]); d.setUTCSeconds(k[2]); return d; case 10: // YYYY-MM-DD var k = s.split("-"); return new Date(cast k[0],cast k[1] - 1,cast k[2],0,0,0); case 19: // YYYY-MM-DD hh:mm:ss var k = s.split(" "); var y = k[0].split("-"); var t = k[1].split(":"); return new Date(cast y[0],cast y[1] - 1,cast y[2],cast t[0],cast t[1],cast t[2]); default: throw "Invalid date format : " + s; } }; d.prototype[#if (as3 || no_flash_override) "toStringHX" #else "toString" #end] = function() { var date : Date = __this__; var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); var mi = date.getMinutes(); var s = date.getSeconds(); return date.getFullYear() +"-"+(if( m < 10 ) "0"+m else ""+m) +"-"+(if( d < 10 ) "0"+d else ""+d) +" "+(if( h < 10 ) "0"+h else ""+h) +":"+(if( mi < 10 ) "0"+mi else ""+mi) +":"+(if( s < 10 ) "0"+s else ""+s); }; } #end } haxe_3.2.1+dfsg.orig/std/DateTools.hx0000664000175000017500000001454112607337712017362 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** The DateTools class contains some extra functionalities for handling `Date` instances and timestamps. In the context of haxe dates, a timestamp is defined as the number of milliseconds elapsed since 1st January 1970. **/ class DateTools { #if php #elseif (neko && !(macro || interp)) static var date_format = neko.Lib.load("std","date_format",2); #else private static function __format_get( d : Date, e : String ) : String { return switch( e ){ case "%": "%"; case "C": untyped StringTools.lpad(Std.string(Std.int(d.getFullYear()/100)),"0",2); case "d": untyped StringTools.lpad(Std.string(d.getDate()),"0",2); case "D": __format(d,"%m/%d/%y"); case "e": untyped Std.string(d.getDate()); case "F": __format(d,"%Y-%m-%d"); case "H","k": untyped StringTools.lpad(Std.string(d.getHours()),if( e == "H" ) "0" else " ",2); case "I","l": var hour = d.getHours()%12; untyped StringTools.lpad(Std.string(hour == 0 ? 12 : hour),if( e == "I" ) "0" else " ",2); case "m": untyped StringTools.lpad(Std.string(d.getMonth()+1),"0",2); case "M": untyped StringTools.lpad(Std.string(d.getMinutes()),"0",2); case "n": "\n"; case "p": untyped if( d.getHours() > 11 ) "PM"; else "AM"; case "r": __format(d,"%I:%M:%S %p"); case "R": __format(d,"%H:%M"); case "s": Std.string(Std.int(d.getTime()/1000)); case "S": untyped StringTools.lpad(Std.string(d.getSeconds()),"0",2); case "t": "\t"; case "T": __format(d,"%H:%M:%S"); case "u": untyped{ var t = d.getDay(); if( t == 0 ) "7"; else Std.string(t); } case "w": untyped Std.string(d.getDay()); case "y": untyped StringTools.lpad(Std.string(d.getFullYear()%100),"0",2); case "Y": untyped Std.string(d.getFullYear()); default: throw "Date.format %"+e+"- not implemented yet."; } } private static function __format( d : Date, f : String ) : String { var r = new StringBuf(); var p = 0; while( true ){ var np = f.indexOf("%", p); if( np < 0 ) break; r.addSub(f,p,np-p); r.add( __format_get(d, f.substr(np+1,1) ) ); p = np+2; } r.addSub(f,p,f.length-p); return r.toString(); } #end /** Format the date `d` according to the format `f`. The format is compatible with the `strftime` standard format, except that there is no support in Flash and JS for day and months names (due to lack of proper internationalization API). On Haxe/Neko/Windows, some formats are not supported. **/ public static function format( d : Date, f : String ) : String { #if (neko && !(macro || interp)) return new String(untyped date_format(d.__t, f.__s)); #elseif php return untyped __call__("strftime",f,d.__t); #else return __format(d,f); #end } /** Returns the result of adding timestamp `t` to Date `d`. This is a convenience function for calling `Date.fromTime(d.getTime() + t)`. **/ public static inline function delta( d : Date, t : Float ) : Date { return Date.fromTime( d.getTime() + t ); } static var DAYS_OF_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; /** Returns the number of days in the month of Date `d`. This method handles leap years. **/ public static function getMonthDays( d : Date ) : Int { var month = d.getMonth(); var year = d.getFullYear(); if (month != 1) return DAYS_OF_MONTH[month]; var isB = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0); return if (isB) 29 else 28; } /** Converts a number of seconds to a timestamp. **/ public static inline function seconds( n : Float ) : Float { return n * 1000.0; } /** Converts a number of minutes to a timestamp. **/ public static inline function minutes( n : Float ) : Float { return n * 60.0 * 1000.0; } /** Converts a number of hours to a timestamp. **/ public static inline function hours( n : Float ) : Float { return n * 60.0 * 60.0 * 1000.0; } /** Converts a number of days to a timestamp. **/ public static inline function days( n : Float ) : Float { return n * 24.0 * 60.0 * 60.0 * 1000.0; } /** Separate a date-time into several components **/ public static function parse( t : Float ) { var s = t / 1000; var m = s / 60; var h = m / 60; return { ms : t % 1000, seconds : Std.int(s % 60), minutes : Std.int(m % 60), hours : Std.int(h % 24), days : Std.int(h / 24), }; } /** Build a date-time from several components **/ public static function make( o : { ms : Float, seconds : Int, minutes : Int, hours : Int, days : Int } ) { return o.ms + 1000.0 * (o.seconds + 60.0 * (o.minutes + 60.0 * (o.hours + 24.0 * o.days))); } #if (js || flash || php || cpp || python) /** Retrieve Unix timestamp value from Date components. Takes same argument sequence as the Date constructor. **/ public static #if (js || flash || php) inline #end function makeUtc(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ):Float { #if (js || flash || python) return untyped Date.UTC(year, month, day, hour, min, sec); #elseif php return untyped __call__("gmmktime", hour, min, sec, month + 1, day, year) * 1000; #elseif cpp return untyped __global__.__hxcpp_utc_date(year,month,day,hour,min,sec)*1000.0 ; #else //TODO return 0.; #end } #end } haxe_3.2.1+dfsg.orig/std/EReg.hx0000664000175000017500000001447312607337712016312 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** The EReg class represents regular expressions. While basic usage and patterns consistently work across platforms, some more complex operations may yield different results. This is a necessary trade- off to retain a certain level of performance. EReg instances can be created by calling the constructor, or with the special syntax ~/pattern/modifier EReg instances maintain an internal state, which is affected by several of its methods. A detailed explanation of the supported operations is available at http://haxe.org/manual/std-regex.html **/ class EReg { /** Creates a new regular expression with pattern `r` and modifiers `opt`. This is equivalent to the shorthand syntax `~/r/opt` If `r` or `opt` are null, the result is unspecified. **/ public function new( r : String, opt : String ) { throw "Regular expressions are not implemented for this platform"; } /** Tells if `this` regular expression matches String `s`. This method modifies the internal state. If `s` is `null`, the result is unspecified. **/ public function match( s : String ) : Bool { return false; } /** Returns the matched sub-group `n` of `this` EReg. This method should only be called after `this.match` or `this.matchSub`, and then operates on the String of that operation. The index `n` corresponds to the n-th set of parentheses in the pattern of `this` EReg. If no such sub-group exists, an exception is thrown. If `n` equals 0, the whole matched substring is returned. **/ public function matched( n : Int ) : String { return null; } /** Returns the part to the left of the last matched substring. If the most recent call to `this.match` or `this.matchSub` did not match anything, the result is unspecified. If the global g modifier was in place for the matching, only the substring to the left of the leftmost match is returned. The result does not include the matched part. **/ public function matchedLeft() : String { return null; } /** Returns the part to the right of the last matched substring. If the most recent call to `this.match` or `this.matchSub` did not match anything, the result is unspecified. If the global g modifier was in place for the matching, only the substring to the right of the leftmost match is returned. The result does not include the matched part. **/ public function matchedRight() : String { return null; } /** Returns the position and length of the last matched substring, within the String which was last used as argument to `this.match` or `this.matchSub`. If the most recent call to `this.match` or `this.matchSub` did not match anything, the result is unspecified. If the global g modifier was in place for the matching, the position and length of the leftmost substring is returned. **/ public function matchedPos() : { pos : Int, len : Int } { return null; } /** Tells if `this` regular expression matches a substring of String `s`. This function expects `pos` and `len` to describe a valid substring of `s`, or else the result is unspecified. To get more robust behavior, `this.match(s.substr(pos,len))` can be used instead. This method modifies the internal state. If `s` is null, the result is unspecified. **/ public function matchSub( s : String, pos : Int, len : Int = -1):Bool { return false; } /** Splits String `s` at all substrings `this` EReg matches. If a match is found at the start of `s`, the result contains a leading empty String "" entry. If a match is found at the end of `s`, the result contains a trailing empty String "" entry. If two matching substrings appear next to each other, the result contains the empty String "" between them. By default, this method splits `s` into two parts at the first matched substring. If the global g modifier is in place, `s` is split at each matched substring. If `s` is null, the result is unspecified. **/ public function split( s : String ) : Array { return null; } /** Replaces the first substring of `s` which `this` EReg matches with `by`. If `this` EReg does not match any substring, the result is `s`. By default, this method replaces only the first matched substring. If the global g modifier is in place, all matched substrings are replaced. If `by` contains `$1` to `$9`, the digit corresponds to number of a matched sub-group and its value is used instead. If no such sub-group exists, the replacement is unspecified. The string `$$` becomes `$`. If `s` or `by` are null, the result is unspecified. **/ public function replace( s : String, by : String ) : String { return null; } /** Calls the function `f` for the substring of `s` which `this` EReg matches and replaces that substring with the result of `f` call. The `f` function takes `this` EReg object as its first argument and should return a replacement string for the substring matched. If `this` EReg does not match any substring, the result is `s`. By default, this method replaces only the first matched substring. If the global g modifier is in place, all matched substrings are replaced. If `s` or `f` are null, the result is unspecified. **/ public function map( s : String, f : EReg -> String ) : String { return null; } } haxe_3.2.1+dfsg.orig/std/Enum.hx0000664000175000017500000000245512607337712016371 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** An abstract type that represents an Enum type. The corresponding enum instance type is `EnumValue`. See `Type` for the Haxe Reflection API. **/ @:coreType @:runtimeValue abstract Enum { } haxe_3.2.1+dfsg.orig/std/EnumValue.hx0000664000175000017500000000235212607337712017362 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** An abstract type that represents any enum value. See `Type` for the Haxe Reflection API. **/ @:coreType abstract EnumValue { } haxe_3.2.1+dfsg.orig/std/IntIterator.hx0000664000175000017500000000406412607337712017727 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** IntIterator is used for implementing interval iterations. It is usually not used explicitly, but through its special syntax: `min...max` While it is possible to assign an instance of IntIterator to a variable or field, it is worth noting that IntIterator does not reset after being used in a for-loop. Subsequent uses of the same instance will then have no effect. **/ class IntIterator { var min : Int; var max : Int; /** Iterates from `min` (inclusive) to `max` (exclusive). If `max <= min`, the iterator will not act as a countdown. **/ public inline function new( min : Int, max : Int ) { this.min = min; this.max = max; } /** Returns true if the iterator has other items, false otherwise. **/ public inline function hasNext() { return min < max; } /** Moves to the next item of the iterator. If this is called while hasNext() is false, the result is unspecified. **/ public inline function next() { return min++; } } haxe_3.2.1+dfsg.orig/std/Lambda.hx0000664000175000017500000001507512607337712016647 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** The `Lambda` class is a collection of methods to support functional programming. It is ideally used with 'using Lambda' and then acts as an extension to Iterable types. On static platforms, working with the Iterable structure might be slower than performing the operations directly on known types, such as Array and List. If the first argument to any of the methods is null, the result is unspecified. **/ class Lambda { /** Creates an Array from Iterable `it`. If `it` is an Array, this function returns a copy of it. **/ public static function array( it : Iterable ) : Array { var a = new Array(); for(i in it) a.push(i); return a; } /** Creates a List form Iterable `it`. If `it` is a List, this function returns a copy of it. **/ public static function list( it : Iterable ) : List { var l = new List(); for(i in it) l.add(i); return l; } /** Creates a new List by applying function `f` to all elements of `it`. The order of elements is preserved. If `f` is null, the result is unspecified. **/ public static function map( it : Iterable, f : A -> B ) : List { var l = new List(); for( x in it ) l.add(f(x)); return l; } /** Similar to map, but also passes the index of each element to `f`. The order of elements is preserved. If `f` is null, the result is unspecified. **/ public static function mapi( it : Iterable, f : Int -> A -> B ) : List { var l = new List(); var i = 0; for( x in it ) l.add(f(i++,x)); return l; } /** Tells if `it` contains `elt`. This function returns true as soon as an element is found which is equal to `elt` according to the `==` operator. If no such element is found, the result is false. **/ public static function has( it : Iterable, elt : A ) : Bool { for( x in it ) if( x == elt ) return true; return false; } /** Tells if `it` contains an element for which `f` is true. This function returns true as soon as an element is found for which a call to `f` returns true. If no such element is found, the result is false. If `f` is null, the result is unspecified. **/ public static function exists( it : Iterable, f : A -> Bool ) { for( x in it ) if( f(x) ) return true; return false; } /** Tells if `f` is true for all elements of `it`. This function returns false as soon as an element is found for which a call to `f` returns false. If no such element is found, the result is true. In particular, this function always returns true if `it` is empty. If `f` is null, the result is unspecified. **/ public static function foreach( it : Iterable, f : A -> Bool ) { for( x in it ) if( !f(x) ) return false; return true; } /** Calls `f` on all elements of `it`, in order. If `f` is null, the result is unspecified. **/ public static function iter( it : Iterable, f : A -> Void ) { for( x in it ) f(x); } /** Returns a List containing those elements of `it` for which `f` returned true. If `it` is empty, the result is the empty List even if `f` is null. Otherwise if `f` is null, the result is unspecified. **/ public static function filter( it : Iterable, f : A -> Bool ) { var l = new List(); for( x in it ) if( f(x) ) l.add(x); return l; } /** Functional fold on Iterable `it`, using function `f` with start argument `first`. If `it` has no elements, the result is `first`. Otherwise the first element of `it` is passed to `f` alongside `first`. The result of that call is then passed to `f` with the next element of `it`, and so on until `it` has no more elements. If `it` or `f` are null, the result is unspecified. **/ public static function fold( it : Iterable, f : A -> B -> B, first : B ) : B { for( x in it ) first = f(x,first); return first; } /** Returns the number of elements in `it` for which `pred` is true, or the total number of elements in `it` if `pred` is null. This function traverses all elements. **/ public static function count( it : Iterable, ?pred : A -> Bool ) { var n = 0; if( pred == null ) for( _ in it ) n++; else for( x in it ) if( pred(x) ) n++; return n; } /** Tells if Iterable `it` does not contain any element. **/ public static function empty( it : Iterable ) : Bool { return !it.iterator().hasNext(); } /** Returns the index of the first element `v` within Iterable `it`. This function uses operator `==` to check for equality. If `v` does not exist in `it`, the result is -1. **/ public static function indexOf( it : Iterable, v : T ) : Int { var i = 0; for( v2 in it ) { if( v == v2 ) return i; i++; } return -1; } /** Returns the first element of `it` for which `f` is true. This function returns as soon as an element is found for which a call to `f` returns true. If no such element is found, the result is null. If `f` is null, the result is unspecified. **/ public static function find( it : Iterable, f : T -> Bool ) : Null { for( v in it ) { if(f(v)) return v; } return null; } /** Returns a new List containing all elements of Iterable `a` followed by all elements of Iterable `b`. If `a` or `b` are null, the result is unspecified. **/ public static function concat( a : Iterable, b : Iterable ) : List { var l = new List(); for( x in a ) l.add(x); for( x in b ) l.add(x); return l; } } haxe_3.2.1+dfsg.orig/std/List.hx0000664000175000017500000001263512607337712016401 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** A linked-list of elements. The list is composed of two-elements arrays that are chained together. It is optimized so that adding or removing an element does not imply copying the whole array content every time. **/ class List { private var h : Array; private var q : Array; /** The length of `this` List. **/ public var length(default,null) : Int; /** Creates a new empty list. **/ public function new() { length = 0; } /** Adds element `item` at the end of `this` List. `this.length` increases by 1. **/ public function add( item : T ) { var x:Array = #if neko untyped __dollar__array(item,null) #else [item] #end; if( h == null ) h = x; else q[1] = x; q = x; length++; } /** Adds element `item` at the beginning of `this` List. `this.length` increases by 1. **/ public function push( item : T ) { var x : Array = #if neko untyped __dollar__array(item,h) #else [item,h] #end; h = x; if( q == null ) q = x; length++; } /** Returns the first element of `this` List, or null if no elements exist. This function does not modify `this` List. **/ public function first() : Null { return if( h == null ) null else h[0]; } /** Returns the last element of `this` List, or null if no elements exist. This function does not modify `this` List. **/ public function last() : Null { return if( q == null ) null else q[0]; } /** Returns the first element of `this` List, or null if no elements exist. The element is removed from `this` List. **/ public function pop() : Null { if( h == null ) return null; var x = h[0]; h = h[1]; if( h == null ) q = null; length--; return x; } /** Tells if `this` List is empty. **/ public function isEmpty() : Bool { return (h == null); } /** Empties `this` List. This function does not traverse the elements, but simply sets the internal references to null and `this.length` to 0. **/ public function clear() : Void { h = null; q = null; length = 0; } /** Removes the first occurence of `v` in `this` List. If `v` is found by checking standard equality, it is removed from `this` List and the function returns true. Otherwise, false is returned. **/ public function remove( v : T ) : Bool { var prev = null; var l = h; while( l != null ) { if( l[0] == v ) { if( prev == null ) h = l[1]; else prev[1] = l[1]; if( q == l ) q = prev; length--; return true; } prev = l; l = l[1]; } return false; } /** Returns an iterator on the elements of the list. **/ public inline function iterator() : ListIterator { return new ListIterator(h); } /** Returns a string representation of `this` List. The result is enclosed in { } with the individual elements being separated by a comma. **/ public function toString() { var s = new StringBuf(); var first = true; var l = h; s.add("{"); while( l != null ) { if( first ) first = false; else s.add(", "); s.add(Std.string(l[0])); l = l[1]; } s.add("}"); return s.toString(); } /** Returns a string representation of `this` List, with `sep` separating each element. **/ public function join(sep : String) { var s = new StringBuf(); var first = true; var l = h; while( l != null ) { if( first ) first = false; else s.add(sep); s.add(l[0]); l = l[1]; } return s.toString(); } /** Returns a list filtered with `f`. The returned list will contain all elements for which `f(x) == true`. **/ public function filter( f : T -> Bool ) { var l2 = new List(); var l = h; while( l != null ) { var v = l[0]; l = l[1]; if( f(v) ) l2.add(v); } return l2; } /** Returns a new list where all elements have been converted by the function `f`. **/ public function map(f : T -> X) : List { var b = new List(); var l = h; while( l != null ) { var v = l[0]; l = l[1]; b.add(f(v)); } return b; } } private class ListIterator { var head:Array; var val:Dynamic; public inline function new(head:Array) { this.head = head; this.val = null; } public inline function hasNext():Bool { return head != null; } public inline function next():T { val = head[0]; head = head[1]; return val; } } haxe_3.2.1+dfsg.orig/std/Map.hx0000664000175000017500000001151412607337712016176 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import haxe.ds.StringMap; import haxe.ds.IntMap; import haxe.ds.HashMap; import haxe.ds.ObjectMap; import haxe.ds.WeakMap; import haxe.ds.EnumValueMap; import haxe.Constraints.IMap; /** Map allows key to value mapping for arbitrary value types, and many key types. This is a multi-type abstract, it is instantiated as one of its specialization types depending on its type parameters. A Map can be instantiated without explicit type parameters. Type inference will then determine the type parameters from the usage. Maps can also be created with `key1 => value1, key2 => value2` syntax. Map is an abstract type, it is not available at runtime. **/ @:multiType(K) abstract Map(IMap ) { /** Creates a new Map. This becomes a constructor call to one of the specialization types in the output. The rules for that are as follows: 1. if K is a `String`, `haxe.ds.StringMap` is used 2. if K is an `Int`, `haxe.ds.IntMap` is used 3. if K is an `EnumValue`, `haxe.ds.EnumValueMap` is used 4. if K is any other class or structure, `haxe.ds.ObjectMap` is used 5. if K is any other type, it causes a compile-time error (Cpp) Map does not use weak keys on ObjectMap by default. **/ public function new(); /** Maps `key` to `value`. If `key` already has a mapping, the previous value disappears. If `key` is null, the result is unspecified. **/ public inline function set(key:K, value:V) this.set(key, value); /** Returns the current mapping of `key`. If no such mapping exists, null is returned. Note that a check like `map.get(key) == null` can hold for two reasons: 1. the map has no mapping for `key` 2. the map has a mapping with a value of `null` If it is important to distinguish these cases, `exists()` should be used. If `key` is null, the result is unspecified. **/ @:arrayAccess public inline function get(key:K) return this.get(key); /** Returns true if `key` has a mapping, false otherwise. If `key` is null, the result is unspecified. **/ public inline function exists(key:K) return this.exists(key); /** Removes the mapping of `key` and returns true if such a mapping existed, false otherwise. If `key` is null, the result is unspecified. **/ public inline function remove(key:K) return this.remove(key); /** Returns an Iterator over the keys of `this` Map. The order of keys is undefined. **/ public inline function keys():Iterator { return this.keys(); } /** Returns an Iterator over the values of `this` Map. The order of values is undefined. **/ public inline function iterator():Iterator { return this.iterator(); } /** Returns a String representation of `this` Map. The exact representation depends on the platform and key-type. **/ public inline function toString():String { return this.toString(); } @:arrayAccess @:noCompletion public inline function arrayWrite(k:K, v:V):V { this.set(k, v); return v; } @:to static inline function toStringMap(t:IMap):StringMap { return new StringMap(); } @:to static inline function toIntMap(t:IMap):IntMap { return new IntMap(); } @:to static inline function toEnumValueMapMap(t:IMap):EnumValueMap { return new EnumValueMap(); } @:to static inline function toObjectMap(t:IMap):ObjectMap { return new ObjectMap(); } @:from static inline function fromStringMap(map:StringMap):Map< String, V > { return cast map; } @:from static inline function fromIntMap(map:IntMap):Map< Int, V > { return cast map; } @:from static inline function fromObjectMap(map:ObjectMap):Map { return cast map; } } @:deprecated typedef IMap = haxe.Constraints.IMap;haxe_3.2.1+dfsg.orig/std/Math.hx0000664000175000017500000002203212607337712016347 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** This class defines mathematical functions and constants. **/ #if cpp @:include("hxMath.h") #end extern class Math { /** Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π. `PI` is approximately 3.141592653589793. **/ static var PI(default,null) : Float; /** A special `Float` constant which denotes negative infinity. For example, this is the result of -1.0 / 0.0. Operations with `NEGATIVE_INFINITY` as an operand may result in `NEGATIVE_INFINITY`, `POSITIVE_INFINITY` or `NaN`. If this constant is converted to an `Int`, e.g. through `Std.int()`, the result is unspecified. **/ static var NEGATIVE_INFINITY(default, null) : Float; /** A special `Float` constant which denotes negative infinity. For example, this is the result of 1.0 / 0.0. Operations with `POSITIVE_INFINITY` as an operand may result in `NEGATIVE_INFINITY`, `POSITIVE_INFINITY` or `NaN`. If this constant is converted to an `Int`, e.g. through `Std.int()`, the result is unspecified. **/ static var POSITIVE_INFINITY(default,null) : Float; /** A special `Float` constant which denotes an invalid number. NaN stands for "Not a Number". It occurs when a mathematically incorrect operation is executed, such as taking the square root of a negative number: Math.sqrt(-1). All further operations with `NaN` as an operand will result in `NaN`. If this constant is converted to an `Int`, e.g. through `Std.int()`, the result is unspecified. In order to test if a value is `NaN`, you should use `Math.isNaN()` function. @php In PHP versions prior to 5.3.1 VC 9 there may be unexpected results when performing arithmetic operations with `NaN` on Windows, see [https://bugs.php.net/bug.php?id=42143] **/ static var NaN(default, null) : Float; /** Returns the absolute value of `v`. If `v` is positive or 0, the result is unchanged. Otherwise the result is -`v`. If `v` is `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. If `v` is `NaN`, the result is `NaN`. **/ static function abs(v:Float):Float; /** Returns the smaller of values `a` and `b`. If `a` or `b` are `NaN`, the result is `NaN`. If `a` or `b` are `NEGATIVE_INFINITY`, the result is `NEGATIVE_INFINITY`. If `a` and `b` are `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. **/ static function min(a:Float, b:Float):Float; /** Returns the greater of values `a` and `b`. If `a` or `b` are `NaN`, the result is `NaN`. If `a` or `b` are `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. If `a` and `b` are `NEGATIVE_INFINITY`, the result is `NEGATIVE_INFINITY`. **/ static function max(a:Float, b:Float):Float; /** Returns the trigonometric sine of the specified angle `v`, in radians. If `v` is `NaN` or infinite, the result is `NaN`. **/ static function sin(v:Float):Float; /** Returns the trigonometric cosine of the specified angle `v`, in radians. If `v` is `NaN` or infinite, the result is `NaN`. **/ static function cos(v:Float):Float; /** Returns the trigonometric tangent of the specified angle `v`, in radians. If `v` is `NaN` or infinite, the result is `NaN`. **/ static function tan(v:Float):Float; /** Returns the trigonometric arc of the specified angle `v`, in radians. If `v` is `NaN` or infinite, the result is `NaN`. **/ static function asin(v:Float):Float; /** Returns the trigonometric arc cosine of the specified angle `v`, in radians. If `v` is `NaN` or infinite, the result is `NaN`. **/ static function acos(v:Float):Float; /** Returns the trigonometric arc tangent of the specified angle `v`, in radians. If `v` is `NaN` or infinite, the result is `NaN`. **/ static function atan(v:Float):Float; /** Returns the trigonometric arc tangent whose tangent is the quotient of two specified numbers, in radians. If parameter `x` or `y` is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is `NaN`. **/ static function atan2(y:Float, x:Float):Float; /** Returns Euler's number, raised to the power of `v`. exp(1.0) is approximately 2.718281828459. If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. If `v` is `NEGATIVE_INFINITY`, the result is `0.0`. If `v` is `NaN`, the result is `NaN`. **/ static function exp(v:Float):Float; /** Returns the natural logarithm of `v`. This is the mathematical inverse operation of exp, i.e. `log(exp(v)) == v` always holds. If `v` is negative (including `NEGATIVE_INFINITY`) or `NaN`, the result is `NaN`. If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. If `v` is `0.0`, the result is `NEGATIVE_INFINITY`. **/ static function log(v:Float):Float; /** Returns a specified base `v` raised to the specified power `exp`. **/ static function pow(v:Float, exp:Float):Float; /** Returns the square root of `v`. If `v` is negative (including `NEGATIVE_INFINITY`) or `NaN`, the result is `NaN`. If `v` is `POSITIVE_INFINITY`, the result is `POSITIVE_INFINITY`. If `v` is `0.0`, the result is `0.0`. **/ static function sqrt(v:Float):Float; /** Rounds `v` to the nearest integer value. If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function round(v:Float):Int; /** Returns the largest integer value that is not greater than `v`. If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function floor(v:Float):Int; /** Returns the smallest integer value that is not less than `v`. If `v` is outside of the signed `Int32` range, or is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function ceil(v:Float):Int; /** Returns a pseudo-random number which is greater than or equal to 0.0, and less than 1.0. **/ static function random() : Float; #if ((flash && !as3) || cpp) /** Returns the largest integer value that is not greater than `v`, as a `Float`. If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function ffloor( v : Float ) : Float; /** Returns the smallest integer value that is not less than `v`, as a `Float`. If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function fceil( v : Float ) : Float; /** Rounds `v` to the nearest integer value, as a Float. If `v` is is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ static function fround( v : Float ) : Float; #else static inline function ffloor( v : Float ) : Float { return floor(v); } static inline function fceil( v : Float ) : Float { return ceil(v); } static inline function fround( v : Float ) : Float { return round(v); } #end /** Tells if `f` is a finite number. If `f` is `POSITIVE_INFINITY`, `NEGATIVE_INFINITY` or `NaN`, the result is `false`, otherwise the result is `true`. **/ static function isFinite( f : Float ) : Bool; /** Tells if `f` is not a valid number. If `f` is `NaN`, the result is `true`, otherwise the result is `false`. In particular, both `POSITIVE_INFINITY` and `NEGATIVE_INFINITY` are not considered `NaN`. **/ static function isNaN( f : Float ) : Bool; private static function __init__() : Void untyped { #if flash NaN = __global__["Number"].NaN; NEGATIVE_INFINITY = __global__["Number"].NEGATIVE_INFINITY; POSITIVE_INFINITY = __global__["Number"].POSITIVE_INFINITY; #else Math.__name__ = ["Math"]; Math.NaN = Number["NaN"]; Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"]; Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"]; #end Math.isFinite = function(i) { return #if flash __global__["isFinite"](i); #else false; #end }; Math.isNaN = function(i) { return #if flash __global__["isNaN"](i); #else false; #end }; } } haxe_3.2.1+dfsg.orig/std/Reflect.hx0000664000175000017500000001422612607337712017050 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** The Reflect API is a way to manipulate values dynamically through an abstract interface in an untyped manner. Use with care. **/ extern class Reflect { /** Tells if structure `o` has a field named `field`. This is only guaranteed to work for anonymous structures. Refer to `Type.getInstanceFields` for a function supporting class instances. If `o` or `field` are null, the result is unspecified. **/ public static function hasField( o : Dynamic, field : String ) : Bool; /** Returns the value of the field named `field` on object `o`. If `o` is not an object or has no field named `field`, the result is null. If the field is defined as a property, its accessors are ignored. Refer to `Reflect.getProperty` for a function supporting property accessors. If `field` is null, the result is unspecified. (As3) If used on a property field, the getter will be invoked. It is not possible to obtain the value directly. **/ public static function field( o : Dynamic, field : String ) : Dynamic; /** Sets the field named `field` of object `o` to value `value`. If `o` has no field named `field`, this function is only guaranteed to work for anonymous structures. If `o` or `field` are null, the result is unspecified. (As3) If used on a property field, the setter will be invoked. It is not possible to set the value directly. **/ public static function setField( o : Dynamic, field : String, value : Dynamic ) : Void; /** Returns the value of the field named `field` on object `o`, taking property getter functions into account. If the field is not a property, this function behaves like `Reflect.field`, but might be slower. If `o` or `field` are null, the result is unspecified. **/ public static function getProperty( o : Dynamic, field : String ) : Dynamic; /** Sets the field named `field` of object `o` to value `value`, taking property setter functions into account. If the field is not a property, this function behaves like `Reflect.setField`, but might be slower. If `field` is null, the result is unspecified. **/ public static function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void; /** Call a method with the given object and arguments. **/ public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array ) : Dynamic; /** Returns the fields of structure `o`. This method is only guaranteed to work on anonymous structures. Refer to `Type.getInstanceFields` for a function supporting class instances. If `o` is null, the result is unspecified. **/ public static function fields( o : Dynamic ) : Array; /** Returns true if `f` is a function, false otherwise. If `f` is null, the result is false. **/ public static function isFunction( f : Dynamic ) : Bool; /** Compares `a` and `b`. If `a` is less than `b`, the result is negative. If `b` is less than `a`, the result is positive. If `a` and `b` are equal, the result is 0. This function is only defined if `a` and `b` are of the same type. If that type is a function, the result is unspecified and `Reflect.compareMethods` should be used instead. For all other types, the result is 0 if `a` and `b` are equal. If they are not equal, the result depends on the type and is negative if: - Numeric types: a is less than b - String: a is lexicographically less than b - Other: unspecified If `a` and `b` are null, the result is 0. If only one of them is null, the result is unspecified. **/ public static function compare( a : T, b : T ) : Int; /** Compares the functions `f1` and `f2`. If `f1` or `f2` are not functions, the result is unspecified. Otherwise the result is true if `f1` and the `f2` are physically equal, false otherwise. **/ public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool; /** Tells if `v` is an object. The result is true if `v` is one of the following: - class instance - structure - Class - Enum Otherwise, including if `v` is null, the result is false. **/ public static function isObject( v : Dynamic ) : Bool; /** Tells if `v` is an enum value. The result is true if `v` is of type EnumValue, i.e. an enum constructor. Otherwise, including if `v` is null, the result is false. **/ public static function isEnumValue( v : Dynamic ) : Bool; /** Removes the field named `field` from structure `o`. This method is only guaranteed to work on anonymous structures. If `o` or `field` are null, the result is unspecified. **/ public static function deleteField( o : Dynamic, field : String ) : Bool; /** Copies the fields of structure `o`. This is only guaranteed to work on anonymous structures. If `o` is null, the result is unspecified. **/ public static function copy( o : T ) : T; /** Transform a function taking an array of arguments into a function that can be called with any number of arguments. **/ @:overload(function( f : Array -> Void ) : Dynamic {}) public static function makeVarArgs( f : Array -> Dynamic ) : Dynamic; } haxe_3.2.1+dfsg.orig/std/Std.hx0000664000175000017500000001052112607337712016210 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #if !(core_api || cross) #error "Please don't add haxe/std to your classpath, instead set HAXE_STD_PATH env var" #end /** The Std class provides standard methods for manipulating basic types. **/ extern class Std { /** Tells if a value `v` is of the type `t`. Returns `false` if `v` or `t` are null. **/ public static function is( v : Dynamic, t : Dynamic ) : Bool; /** Checks if object `value` is an instance of class `c`. Compiles only if the class specified by `c` can be assigned to the type of `value`. This method checks if a downcast is possible. That is, if the runtime type of `value` is assignable to the class specified by `c`, `value` is returned. Otherwise null is returned. This method is not guaranteed to work with interfaces or core types such as `String`, `Array` and `Date`. If `value` is null, the result is null. If `c` is null, the result is unspecified. **/ public static function instance( value : T, c : Class ) : S; /** Converts any value to a String. If `s` is of `String`, `Int`, `Float` or `Bool`, its value is returned. If `s` is an instance of a class and that class or one of its parent classes has a `toString` method, that method is called. If no such method is present, the result is unspecified. If `s` is an enum constructor without argument, the constructor's name is returned. If arguments exists, the constructor's name followed by the String representations of the arguments is returned. If `s` is a structure, the field names along with their values are returned. The field order and the operator separating field names and values are unspecified. If s is null, "null" is returned. **/ public static function string( s : Dynamic ) : String; /** Converts a `Float` to an `Int`, rounded towards 0. If `x` is outside of the signed Int32 range, or is `NaN`, `NEGATIVE_INFINITY` or `POSITIVE_INFINITY`, the result is unspecified. **/ public static function int( x : Float ) : Int; /** Converts a `String` to an `Int`. Leading whitespaces are ignored. If `x` starts with 0x or 0X, hexadecimal notation is recognized where the following digits may contain 0-9 and A-F. Otherwise `x` is read as decimal number with 0-9 being allowed characters. `x` may also start with a - to denote a negative value. In decimal mode, parsing continues until an invalid character is detected, in which case the result up to that point is returned. For hexadecimal notation, the effect of invalid characters is unspecified. Leading 0s that are not part of the 0x/0X hexadecimal notation are ignored, which means octal notation is not supported. If the input cannot be recognized, the result is `null`. **/ public static function parseInt( x : String ) : Null; /** Converts a `String` to a `Float`. The parsing rules for `parseInt` apply here as well, with the exception of invalid input resulting in a `NaN` value instead of null. Additionally, decimal notation may contain a single `.` to denote the start of the fractions. **/ public static function parseFloat( x : String ) : Float; /** Return a random integer between 0 included and `x` excluded. If `x <= 1`, the result is always 0. **/ public static function random( x : Int ) : Int; } haxe_3.2.1+dfsg.orig/std/StdTypes.hx0000664000175000017500000000754012607337712017244 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // standard Haxe types /** The standard Void type. Only `null` values can be of the type `Void`. **/ @:coreType abstract Void { } /** The standard Float type, this is a double-precision IEEE 64bit float. On static targets, null cannot be assigned to Float. If this is necessary, `Null` can be used instead. **/ @:coreType @:notNull @:runtimeValue abstract Float { } /** The standard Int type. Its precision depends on the platform. On static targets, null cannot be assigned to Int. If this is necessary, `Null` can be used instead. **/ @:coreType @:notNull @:runtimeValue abstract Int to Float { } #if (java || cs) @:coreType @:notNull @:runtimeValue abstract Single to Float from Float {} #end /** `Null` can be useful in two cases. In order to document some methods that accepts or can return a `null` value, or for the Flash compiler and AS3 generator to distinguish between base values that can be null and others that can't. **/ typedef Null = T /** The standard Boolean type, which can either be true or false. On static targets, null cannot be assigned to Bool. If this is necessary, `Null` can be used instead. **/ @:coreType @:notNull @:runtimeValue abstract Bool { } /** Dynamic is a special type which is compatible with all other types. Use of Dynamic should be minimized as it prevents several compiler checks and optimizations. **/ @:coreType @:runtimeValue abstract Dynamic { } /** An Iterator is a structure that permits iteration over elements of type T. Any class with matching hasNext and next fields is considered an Iterator and can then be used e.g. in for-loops. This makes it easy to implement custom iterators. **/ typedef Iterator = { /** Returns false if the iteration is complete, true otherwise. Usually iteration is considered to be complete if all elements of the underlying data structure were handled through calls to next(). However, in custom iterators any logic may be used to determine the completion state. **/ function hasNext() : Bool; /** Returns the current item of the Iterator and advances to the next one. This method is not required to check `hasNext` first. A call to this method while `hasNext` is false yields unspecified behavior. On the other hand iterators should not require a call to `hasNext` before the first call to `next` if an element is available. **/ function next() : T; } /** An Iterable is a data structure which has an iterator() method. See `Lambda` for generic functions on iterable structures. **/ typedef Iterable = { function iterator() : Iterator; } /** ArrayAccess is used to indicate a class that can be accessed using brackets. The type parameter represents the type of the elements stored. **/ extern interface ArrayAccess { } haxe_3.2.1+dfsg.orig/std/String.hx0000664000175000017500000001334512607337712016733 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** The basic String class. A haxe String is immutable, it is not possible to modify individual characters. No method of this class changes the state of `this` String. Strings can be constructed using the string literal syntax "string value". String can be concatenated by using the + operator. If an operand is not a String, it is passed through Std.string() first. **/ extern class String { /** The number of characters in `this` String. **/ var length(default,null) : Int; /** Creates a copy from a given String. **/ function new(string:String) : Void; /** Returns a String where all characters of `this` String are upper case. Affects the characters `a-z`. Other characters remain unchanged. **/ function toUpperCase() : String; /** Returns a String where all characters of `this` String are lower case. Affects the characters `A-Z`. Other characters remain unchanged. **/ function toLowerCase() : String; /** Returns the character at position `index` of `this` String. If `index` is negative or exceeds `this.length`, the empty String "" is returned. **/ function charAt(index : Int) : String; /** Returns the character code at position `index` of `this` String. If `index` is negative or exceeds `this.length`, null is returned. To obtain the character code of a single character, "x".code can be used instead to inline the character code at compile time. Note that this only works on String literals of length 1. **/ function charCodeAt( index : Int) : Null; /** Returns the position of the leftmost occurence of `str` within `this` String. If `startIndex` is given, the search is performed within the substring of `this` String starting from `startIndex`. Otherwise the search is performed within `this` String. In either case, the returned position is relative to the beginning of `this` String. If `str` cannot be found, -1 is returned. **/ function indexOf( str : String, ?startIndex : Int ) : Int; /** Returns the position of the rightmost occurence of `str` within `this` String. If `startIndex` is given, the search is performed within the substring of `this` String from 0 to `startIndex`. Otherwise the search is performed within `this` String. In either case, the returned position is relative to the beginning of `this` String. If `str` cannot be found, -1 is returned. **/ function lastIndexOf( str : String, ?startIndex : Int ) : Int; /** Splits `this` String at each occurence of `delimiter`. If `this` String is the empty String "", the result is not consistent across targets and may either be `[]` (on Js, Cpp) or `[""]`. If `delimiter` is the empty String "", `this` String is split into an Array of `this.length` elements, where the elements correspond to the characters of `this` String. If `delimiter` is not found within `this` String, the result is an Array with one element, which equals `this` String. If `delimiter` is null, the result is unspecified. Otherwise, `this` String is split into parts at each occurence of `delimiter`. If `this` String starts (or ends) with [delimiter}, the result Array contains a leading (or trailing) empty String "" element. Two subsequent delimiters also result in an empty String "" element. **/ function split( delimiter : String ) : Array; /** Returns `len` characters of `this` String, starting at position `pos`. If `len` is omitted, all characters from position `pos` to the end of `this` String are included. If `pos` is negative, its value is calculated from the end of `this` String by `this.length + pos`. If this yields a negative value, 0 is used instead. If the calculated position + `len` exceeds `this.length`, the characters from that position to the end of `this` String are returned. If `len` is negative, the result is unspecified. **/ function substr( pos : Int, ?len : Int ) : String; /** Returns the part of `this` String from `startIndex` to but not including `endIndex`. If `startIndex` or `endIndex` are negative, 0 is used instead. If `startIndex` exceeds `endIndex`, they are swapped. If the (possibly swapped) `endIndex` is omitted or exceeds `this.length`, `this.length` is used instead. If the (possibly swapped) `startIndex` exceeds `this.length`, the empty String "" is returned. **/ function substring( startIndex : Int, ?endIndex : Int ) : String; /** Returns the String itself. **/ function toString() : String; /** Returns the String corresponding to the character code `code`. If `code` is negative or has another invalid value, the result is unspecified. **/ static function fromCharCode( code : Int ) : String; }haxe_3.2.1+dfsg.orig/std/StringBuf.hx0000664000175000017500000000617212607337712017370 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** A String buffer is an efficient way to build a big string by appending small elements together. Its cross-platform implementation uses String concatenation internally, but StringBuf may be optimized for different targets. Unlike String, an instance of StringBuf is not immutable in the sense that it can be passed as argument to functions which modify it by appending more values. However, the internal buffer cannot be modified. **/ class StringBuf { var b:String; /** The length of `this` StringBuf in characters. **/ public var length(get,never) : Int; /** Creates a new StringBuf instance. This may involve initialization of the internal buffer. **/ public inline function new() { b = ""; } inline function get_length() : Int { return b.length; } /** Appends the representation of `x` to `this` StringBuf. The exact representation of `x` may vary per platform. To get more consistent behavior, this function should be called with Std.string(x). If `x` is null, the String "null" is appended. **/ public inline function add( x : T ) : Void { b += x; } /** Appends the character identified by `c` to `this` StringBuf. If `c` is negative or has another invalid value, the result is unspecified. **/ public inline function addChar( c : Int ) : Void { b += String.fromCharCode(c); } /** Appends a substring of `s` to `this` StringBuf. This function expects `pos` and `len` to describe a valid substring of `s`, or else the result is unspecified. To get more robust behavior, `this.add(s.substr(pos,len))` can be used instead. If `s` or `pos` are null, the result is unspecified. If `len` is omitted or null, the substring ranges from `pos` to the end of `s`. **/ public inline function addSub( s : String, pos : Int, ?len : Int) : Void { b += (len == null ? s.substr(pos) : s.substr(pos, len)); } /** Returns the content of `this` StringBuf as String. The buffer is not emptied by this operation. **/ public inline function toString() : String { return b; } } haxe_3.2.1+dfsg.orig/std/StringTools.hx0000664000175000017500000002607212607337712017755 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** This class provides advanced methods on Strings. It is ideally used with 'using StringTools' and then acts as an extension to the String class. If the first argument to any of the methods is null, the result is unspecified. **/ #if cpp using cpp.NativeString; #end class StringTools { /** Encode an URL by using the standard format. **/ #if (!java && !cpp) inline #end public static function urlEncode( s : String ) : String { #if flash return untyped __global__["encodeURIComponent"](s); #elseif neko return untyped new String(_urlEncode(s.__s)); #elseif js return untyped encodeURIComponent(s); #elseif cpp return untyped s.__URLEncode(); #elseif java try return untyped __java__("java.net.URLEncoder.encode(s, \"UTF-8\")") catch (e:Dynamic) throw e; #elseif cs return untyped cs.system.Uri.EscapeDataString(s); #elseif python return python.lib.urllib.Parse.quote(s, ""); #else return null; #end } /** Decode an URL using the standard format. **/ #if (!java && !cpp) inline #end public static function urlDecode( s : String ) : String { #if flash return untyped __global__["decodeURIComponent"](s.split("+").join(" ")); #elseif neko return untyped new String(_urlDecode(s.__s)); #elseif js return untyped decodeURIComponent(s.split("+").join(" ")); #elseif cpp return untyped s.__URLDecode(); #elseif java try return untyped __java__("java.net.URLDecoder.decode(s, \"UTF-8\")") catch (e:Dynamic) throw e; #elseif cs return untyped cs.system.Uri.UnescapeDataString(s); #elseif python return python.lib.urllib.Parse.unquote(s); #else return null; #end } /** Escapes HTML special characters of the string `s`. The following replacements are made: - `&` becomes `&`; - `<` becomes `<`; - `>` becomes `>`; If `quotes` is true, the following characters are also replaced: - `"` becomes `"`; - `'` becomes `'`; **/ public static function htmlEscape( s : String, ?quotes : Bool ) : String { s = s.split("&").join("&").split("<").join("<").split(">").join(">"); return quotes ? s.split('"').join(""").split("'").join("'") : s; } /** Unescapes HTML special characters of the string `s`. This is the inverse operation to htmlEscape, i.e. the following always holds: htmlUnescape(htmlEscape(s)) == s The replacements follow: - `&` becomes `&` - `<` becomes `<` - `>` becomes `>` - `"` becomes `"` - `'` becomes `'` **/ public static function htmlUnescape( s : String ) : String { return s.split(">").join(">").split("<").join("<").split(""").join('"').split("'").join("'").split("&").join("&"); } /** Tells if the string `s` starts with the string `start`. If `start` is null, the result is unspecified. If `start` is the empty String "", the result is true. **/ public static #if (cs || java) inline #end function startsWith( s : String, start : String ) : Bool { #if java return untyped s.startsWith(start); #elseif cs return untyped s.StartsWith(start); #elseif cpp if (s.length= start.length && s.substr(0, start.length) == start ); #end } /** Tells if the string `s` ends with the string `end`. If `end` is null, the result is unspecified. If `end` is the empty String "", the result is true. **/ public static #if (cs || java) inline #end function endsWith( s : String, end : String ) : Bool { #if java return untyped s.endsWith(end); #elseif cs return untyped s.EndsWith(end); #elseif cpp if (s.length= elen && s.substr(slen - elen, elen) == end ); #end } /** Tells if the character in the string `s` at position `pos` is a space. A character is considered to be a space character if its character code is 9,10,11,12,13 or 32. If `s` is the empty String "", or if pos is not a valid position within `s`, the result is false. **/ public static function isSpace( s : String, pos : Int ) : Bool { #if python if (s.length == 0 || pos < 0 || pos >= s.length) return false; #end var c = s.charCodeAt( pos ); return (c > 8 && c < 14) || c == 32; } /** Removes leading space characters of `s`. This function internally calls isSpace() to decide which characters to remove. If `s` is the empty String "" or consists only of space characters, the result is the empty String "". **/ public #if cs inline #end static function ltrim( s : String ) : String { #if cs return untyped s.TrimStart(); #else var l = s.length; var r = 0; while( r < l && isSpace(s,r) ){ r++; } if( r > 0 ) return s.substr(r, l-r); else return s; #end } /** Removes trailing space characters of `s`. This function internally calls isSpace() to decide which characters to remove. If `s` is the empty String "" or consists only of space characters, the result is the empty String "". **/ public #if cs inline #end static function rtrim( s : String ) : String { #if cs return untyped s.TrimEnd(); #else var l = s.length; var r = 0; while( r < l && isSpace(s,l-r-1) ){ r++; } if( r > 0 ){ return s.substr(0, l-r); }else{ return s; } #end } /** Removes leading and trailing space characters of `s`. This is a convenience function for ltrim(rtrim(s)). **/ public #if (cs || java) inline #end static function trim( s : String ) : String { #if cs return untyped s.Trim(); #elseif java return untyped s.trim(); #else return ltrim(rtrim(s)); #end } /** Concatenates `c` to `s` until `s.length` is at least `l`. If `c` is the empty String "" or if `l` does not exceed `s.length`, `s` is returned unchanged. If `c.length` is 1, the resulting String length is exactly `l`. Otherwise the length may exceed `l`. If `c` is null, the result is unspecified. **/ public static function lpad( s : String, c : String, l : Int ) : String { if (c.length <= 0) return s; while (s.length < l) { s = c + s; } return s; } /** Appends `c` to `s` until `s.length` is at least `l`. If `c` is the empty String "" or if `l` does not exceed `s.length`, `s` is returned unchanged. If `c.length` is 1, the resulting String length is exactly `l`. Otherwise the length may exceed `l`. If `c` is null, the result is unspecified. **/ public static function rpad( s : String, c : String, l : Int ) : String { if (c.length <= 0) return s; while (s.length < l) { s = s + c; } return s; } /** Replace all occurences of the String `sub` in the String `s` by the String `by`. If `sub` is the empty String "", `by` is inserted after each character of `s`. If `by` is also the empty String "", `s` remains unchanged. This is a convenience function for `s.split(sub).join(by)`. If `sub` or `by` are null, the result is unspecified. **/ public static function replace( s : String, sub : String, by : String ) : String { #if java if (sub.length == 0) return s.split(sub).join(by); else return untyped s.replace(sub, by); #elseif cs if (sub.length == 0) return s.split(sub).join(by); else return untyped s.Replace(sub, by); #else return s.split(sub).join(by); #end } /** Encodes `n` into a hexadecimal representation. If `digits` is specified, the resulting String is padded with "0" until its length equals `digits`. **/ public static function hex( n : Int, ?digits : Int ) { #if flash var n : UInt = n; var s : String = untyped n.toString(16); s = s.toUpperCase(); #else var s = ""; var hexChars = "0123456789ABCDEF"; do { s = hexChars.charAt(n&15) + s; n >>>= 4; } while( n > 0 ); #end #if python if (digits != null && s.length < digits) { var diff = digits - s.length; for (_ in 0...diff) { s = "0" + s; } } #else if( digits != null ) while( s.length < digits ) s = "0"+s; #end return s; } /** Returns the character code at position `index` of String `s`, or an end-of-file indicator at if `position` equals `s.length`. This method is faster than String.charCodeAt() on some platforms, but the result is unspecified if `index` is negative or greater than `s.length`. End of file status can be checked by calling `StringTools.isEof` with the returned value as argument. This operation is not guaranteed to work if `s` contains the \0 character. **/ public static inline function fastCodeAt( s : String, index : Int ) : Int { #if neko return untyped __dollar__sget(s.__s, index); #elseif cpp return untyped s.cca(index); #elseif flash return untyped s.cca(index); #elseif java return ( index < s.length ) ? cast(_charAt(s, index), Int) : -1; #elseif cs return ( cast(index, UInt) < s.length ) ? cast(s[index], Int) : -1; #elseif js return (untyped s).charCodeAt(index); #elseif python return if (index >= s.length) -1 else python.internal.UBuiltins.ord(python.Syntax.arrayAccess(s, index)); #else return untyped s.cca(index); #end } /* Tells if `c` represents the end-of-file (EOF) character. */ @:noUsing public static inline function isEof( c : Int ) : Bool { #if (flash || cpp) return c == 0; #elseif js return c != c; // fast NaN #elseif neko return c == null; #elseif cs return c == -1; #elseif java return c == -1; #elseif python return c == -1; #else return false; #end } #if java private static inline function _charAt(str:String, idx:Int):java.StdTypes.Char16 return untyped str._charAt(idx); #end #if neko private static var _urlEncode = neko.Lib.load("std","url_encode",1); private static var _urlDecode = neko.Lib.load("std","url_decode",1); #end } haxe_3.2.1+dfsg.orig/std/Sys.hx0000664000175000017500000001037512607337712016243 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** This class gives you access to many base functionalities of system platforms. Looks in [sys] sub packages for more system APIs. **/ @:require(sys) extern class Sys { /** Print any value on the standard output. **/ static function print( v : Dynamic ) : Void; /** Print any value on the standard output, followed by a newline **/ static function println( v : Dynamic ) : Void; /** Returns all the arguments that were passed by the commandline. **/ static function args() : Array; /** Returns the value of the given environment variable. **/ static function getEnv( s : String ) : String; /** Set the value of the given environment variable. **/ static function putEnv( s : String, v : String ) : Void; /** Returns the whole environement variables. **/ static function environment() : Map; /** Suspend the current execution for the given time (in seconds). **/ static function sleep( seconds : Float ) : Void; /** Change the current time locale, which will affect [DateTools.format] date formating. Returns true if the locale was successfully changed **/ static function setTimeLocale( loc : String ) : Bool; /** Get the current working directory (usually the one in which the program was started) **/ static function getCwd() : String; /** Change the current working directory. **/ static function setCwd( s : String ) : Void; /** Returns the name of the system you are running on. For instance : "Windows", "Linux", "BSD" and "Mac" depending on your desktop OS. **/ static function systemName() : String; /** Run the given command with the list of arguments. The command output will be printed on the same output as the current process. The current process will block until the command terminates and it will return the command result (0 if there was no error). Read the [sys.io.Process] api for a more complete way to start background processes. **/ static function command( cmd : String, ?args : Array ) : Int; /** Exit the current process with the given error code. **/ static function exit( code : Int ) : Void; /** Gives the most precise timestamp value (in seconds). **/ static function time() : Float; /** Gives the most precise timestamp value (in seconds) but only account for the actual time spent running on the CPU for the current thread/process. **/ static function cpuTime() : Float; /** Returns the path to the current executable that we are running. **/ static function executablePath() : String; /** Read a single input character from the standard input (without blocking) and returns it. Setting [echo] to true will also display it on the output. **/ static function getChar( echo : Bool ) : Int; /** Returns the process standard input, from which you can read what user enters. Usually it will block until the user send a full input line. See [getChar] for an alternative. **/ static function stdin() : haxe.io.Input; /** Returns the process standard output on which you can write. **/ static function stdout() : haxe.io.Output; /** Returns the process standard error on which you can write. **/ static function stderr() : haxe.io.Output; }haxe_3.2.1+dfsg.orig/std/Type.hx0000664000175000017500000002217412607337712016406 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ /** The diffent possible runtime types of a value. **/ enum ValueType { TNull; TInt; TFloat; TBool; TObject; TFunction; TClass( c : Class ); TEnum( e : Enum ); TUnknown; } /** The haxe Reflection API allows retrieval of type information at runtime. This class complements the more lightweight Reflect class, with a focus on class and enum instances. **/ extern class Type { /** Returns the class of `o`, if `o` is a class instance. If `o` is null or of a different type, null is returned. In general, type parameter information cannot be obtained at runtime. **/ public static function getClass( o : T ) : Class; /** Returns the enum of enum instance `o`. An enum instance is the result of using an enum constructor. Given an `enum Color { Red; }`, `getEnum(Red)` returns `Enum`. If `o` is null, null is returned. In general, type parameter information cannot be obtained at runtime. **/ public static function getEnum( o : EnumValue ) : Enum; /** Returns the super-class of class `c`. If `c` has no super class, null is returned. If `c` is null, the result is unspecified. In general, type parameter information cannot be obtained at runtime. **/ public static function getSuperClass( c : Class ) : Class; /** Returns the name of class `c`, including its path. If `c` is inside a package, the package structure is returned dot- separated, with another dot separating the class name: `pack1.pack2.(...).packN.ClassName` If `c` is a sub-type of a haxe module, that module is not part of the package structure. If `c` has no package, the class name is returned. If `c` is null, the result is unspecified. The class name does not include any type parameters. **/ public static function getClassName( c : Class ) : String; /** Returns the name of enum `e`, including its path. If `e` is inside a package, the package structure is returned dot- separated, with another dot separating the enum name: `pack1.pack2.(...).packN.EnumName` If `e` is a sub-type of a haxe module, that module is not part of the package structure. If `e` has no package, the enum name is returned. If `e` is null, the result is unspecified. The enum name does not include any type parameters. **/ public static function getEnumName( e : Enum ) : String; /** Resolves a class by name. If `name` is the path of an existing class, that class is returned. Otherwise null is returned. If `name` is null or the path to a different type, the result is unspecified. The class name must not include any type parameters. **/ public static function resolveClass( name : String ) : Class; /** Resolves an enum by name. If `name` is the path of an existing enum, that enum is returned. Otherwise null is returned. If `name` is null the result is unspecified. If `name` is the path to a different type, null is returned. The enum name must not include any type parameters. **/ public static function resolveEnum( name : String ) : Enum; /** Creates an instance of class `cl`, using `args` as arguments to the class constructor. This function guarantees that the class constructor is called. Default values of constructors arguments are not guaranteed to be taken into account. If `cl` or `args` are null, or if the number of elements in `args` does not match the expected number of constructor arguments, or if any argument has an invalid type, or if `cl` has no own constructor, the result is unspecified. In particular, default values of constructor arguments are not guaranteed to be taken into account. **/ public static function createInstance( cl : Class, args : Array ) : T; /** Creates an instance of class `cl`. This function guarantees that the class constructor is not called. If `cl` is null, the result is unspecified. **/ public static function createEmptyInstance( cl : Class ) : T; /** Creates an instance of enum `e` by calling its constructor `constr` with arguments `params`. If `e` or `constr` is null, or if enum `e` has no constructor named `constr`, or if the number of elements in `params` does not match the expected number of constructor arguments, or if any argument has an invalid type, the result is unspecified. **/ public static function createEnum( e : Enum, constr : String, ?params : Array ) : T; /** Creates an instance of enum `e` by calling its constructor number `index` with arguments `params`. The constructor indices are preserved from haxe syntax, so the first declared is index 0, the next index 1 etc. If `e` or `constr` is null, or if enum `e` has no constructor named `constr`, or if the number of elements in `params` does not match the expected number of constructor arguments, or if any argument has an invalid type, the result is unspecified. **/ public static function createEnumIndex( e : Enum, index : Int, ?params : Array ) : T; /** Returns a list of the instance fields of class `c`. This only includes fields which are known at compile-time. In particular, using getInstanceFields(getClass(obj)) will not include any fields which were added to obj at runtime. The order of the fields in the returned Array is unspecified. If `c` is null, the result is unspecified. (As3) This method only returns instance fields that are public. **/ public static function getInstanceFields( c : Class ) : Array; /** Returns a list of static fields of class `c`. This does not include static fields of parent classes. The order of the fields in the returned Array is unspecified. If `c` is null, the result is unspecified. (As3) This method only returns class fields that are public. **/ public static function getClassFields( c : Class ) : Array; /** Returns a list of the names of all constructors of enum `e`. The order of the constructor names in the returned Array is preserved from the original syntax. If `c` is null, the result is unspecified. **/ public static function getEnumConstructs( e : Enum ) : Array; /** Returns the runtime type of value `v`. The result corresponds to the type `v` has at runtime, which may vary per platform. Assumptions regarding this should be minimized to avoid surprises. **/ public static function typeof( v : Dynamic ) : ValueType; /** Recursively compares two enum instances `a` and `b` by value. Unlike `a == b`, this function performs a deep equality check on the arguments of the constructors, if exists. If `a` or `b` are null, the result is unspecified. **/ public static function enumEq( a : T, b : T ) : Bool; /** Returns the constructor name of enum instance `e`. The result String does not contain any constructor arguments. If `e` is null, the result is unspecified. **/ public static function enumConstructor( e : EnumValue ) : String; /** Returns a list of the constructor arguments of enum instance `e`. If `e` has no arguments, the result is []. Otherwise the result are the values that were used as arguments to `e`, in the order of their declaration. If `e` is null, the result is unspecified. **/ public static function enumParameters( e : EnumValue ) : Array; /** Returns the index of enum instance `e`. This corresponds to the original syntactic position of `e`. The index of the first declared constructor is 0, the next one is 1 etc. If `e` is null, the result is unspecified. **/ public static function enumIndex( e : EnumValue ) : Int; /** Returns a list of all constructors of enum `e` that require no arguments. This may return the empty Array [] if all constructors of `e` require arguments. Otherwise an instance of `e` constructed through each of its non- argument constructors is returned, in the order of the constructor declaration. If `e` is null, the result is unspecified. **/ public static function allEnums( e : Enum ) : Array; } haxe_3.2.1+dfsg.orig/std/UInt.hx0000664000175000017500000002272012607337712016341 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #if ((flash || flash9doc || cs) && !doc_gen) /** The unsigned Int type is only defined for Flash and C#. It's currently handled the same as a normal Int. **/ @:coreType @:notNull @:runtimeValue @:analyzer(no_const_propagation) abstract UInt to Int from Int { @:commutative @:op(A+B) private static function addI(lhs:UInt, rhs:Int):UInt; @:commutative @:op(A+B) private static function addF(lhs:UInt, rhs:Float):Float; @:op(A+B) private static function add(lhs:UInt, rhs:UInt):UInt; @:commutative @:op(A*B) private static function mulI(lhs:UInt, rhs:Int):UInt; @:commutative @:op(A*B) private static function mulF(lhs:UInt, rhs:Float):Float; @:op(A*B) private static function mul(lhs:UInt, rhs:UInt):UInt; @:op(A%B) private static function modI(lhs:UInt, rhs:Int):UInt; @:op(A%B) private static function modF(lhs:UInt, rhs:Float):Float; @:op(A%B) private static function mod(lhs:UInt, rhs:UInt):UInt; @:op(A-B) private static function subI(lhs:UInt, rhs:Int):UInt; @:op(A-B) private static function subF(lhs:UInt, rhs:Float):Float; @:op(A-B) private static function sub(lhs:UInt, rhs:UInt):UInt; @:op(A/B) private static function divI(lhs:UInt, rhs:Int):Float; @:op(A/B) private static function divF(lhs:UInt, rhs:Float):Float; @:op(A/B) private static function div(lhs:UInt, rhs:UInt):Float; @:commutative @:op(A|B) private static function orI(lhs:UInt, rhs:Int):UInt; @:op(A|B) private static function or(lhs:UInt, rhs:UInt):UInt; @:commutative @:op(A^B) private static function xorI(lhs:UInt, rhs:Int):UInt; @:op(A^B) private static function xor(lhs:UInt, rhs:UInt):UInt; @:commutative @:op(A&B) private static function andI(lhs:UInt, rhs:Int):UInt; @:op(A&B) private static function and(lhs:UInt, rhs:UInt):UInt; @:op(A<>B) private static function shr(lhs:UInt, rhs:Int):UInt; @:op(A>>>B) private static function ushr(lhs:UInt, rhs:Int):UInt; @:op(A>B) private static function gt(lhs:UInt, rhs:UInt):Bool; @:op(A>=B) private static function gte(lhs:UInt, rhs:UInt):Bool; @:op(AB) private static function gtf(lhs:UInt, rhs:Float):Bool; @:op(A>B) private static function gtf(lhs:Float, rhs:UInt):Bool; @:op(A>=B) private static function gtef(lhs:UInt, rhs:Float):Bool; @:op(A>=B) private static function gtef(lhs:Float, rhs:UInt):Bool; @:op(A(a:UInt, b:T):Bool; @:commutative @:op(A != B) private static function notEqualsInt(a:UInt, b:T):Bool; @:commutative @:op(A == B) private static function equalsFloat(a:UInt, b:T):Bool; @:commutative @:op(A != B) private static function notEqualsFloat(a:UInt, b:T):Bool; @:op(++A) private function prefixIncrement():UInt; @:op(A++) private function postfixIncrement():UInt; @:op(--A) private function prefixDecrement():UInt; @:op(A--) private function postfixDecrement():UInt; } #else /** The unsigned Int type is only defined for Flash and C#. Simulate it for other platforms. **/ abstract UInt(Int) from Int to Int { @:op(A + B) private static inline function add(a:UInt, b:UInt):UInt { return a.toInt() + b.toInt(); } @:op(A / B) private static inline function div(a:UInt, b:UInt):Float { return a.toFloat() / b.toFloat(); } @:op(A * B) private static inline function mul(a:UInt, b:UInt):UInt { return a.toInt() * b.toInt(); } @:op(A - B) private static inline function sub(a:UInt, b:UInt):UInt { return a.toInt() - b.toInt(); } @:op(A > B) private static #if !js inline #end function gt(a:UInt, b:UInt):Bool { var aNeg = a.toInt() < 0; var bNeg = b.toInt() < 0; return if( aNeg != bNeg ) aNeg; else a.toInt() > b.toInt(); } @:op(A >= B) private static #if !js inline #end function gte(a:UInt, b:UInt):Bool { var aNeg = a.toInt() < 0; var bNeg = b.toInt() < 0; return if( aNeg != bNeg ) aNeg; else a.toInt() >= b.toInt(); } @:op(A < B) private static inline function lt(a:UInt, b:UInt):Bool { return gt(b, a); } @:op(A <= B) private static inline function lte(a:UInt, b:UInt):Bool { return gte(b, a); } @:op(A & B) private static inline function and(a:UInt, b:UInt):UInt { return a.toInt() & b.toInt(); } @:op(A | B) private static inline function or(a:UInt, b:UInt):UInt { return a.toInt() | b.toInt(); } @:op(A ^ B) private static inline function xor(a:UInt, b:UInt):UInt { return a.toInt() ^ b.toInt(); } @:op(A << B) private static inline function shl(a:UInt, b:Int):UInt { return a.toInt() << b; } @:op(A >> B) private static inline function shr(a:UInt, b:Int):UInt { return a.toInt() >> b; } @:op(A >>> B) private static inline function ushr(a:UInt, b:Int):UInt { return a.toInt() >>> b; } @:op(A % B) private static inline function mod(a:UInt, b:UInt):UInt { return Std.int( a.toFloat() % b.toFloat() ); } @:commutative @:op(A + B) private static inline function addWithFloat(a:UInt, b:Float):Float { return a.toFloat() + b; } @:commutative @:op(A * B) private static inline function mulWithFloat(a:UInt, b:Float):Float { return a.toFloat() * b; } @:op(A / B) private static inline function divFloat(a:UInt, b:Float):Float { return a.toFloat() / b; } @:op(A / B) private static inline function floatDiv(a:Float, b:UInt):Float { return a / b.toFloat(); } @:op(A - B) private static inline function subFloat(a:UInt, b:Float):Float { return a.toFloat() - b; } @:op(A - B) private static inline function floatSub(a:Float, b:UInt):Float { return a - b.toFloat(); } @:op(A > B) private static inline function gtFloat(a:UInt, b:Float):Bool { return a.toFloat() > b; } @:commutative @:op(A == B) private static inline function equalsInt(a:UInt, b:T):Bool { return a.toInt() == b; } @:commutative @:op(A != B) private static inline function notEqualsInt(a:UInt, b:T):Bool { return a.toInt() != b; } @:commutative @:op(A == B) private static inline function equalsFloat(a:UInt, b:T):Bool { return a.toFloat() == b; } @:commutative @:op(A != B) private static inline function notEqualsFloat(a:UInt, b:T):Bool { return a.toFloat() != b; } @:op(A >= B) private static inline function gteFloat(a:UInt, b:Float):Bool { return a.toFloat() >= b; } @:op(A > B) private static inline function floatGt(a:Float, b:UInt):Bool { return a > b.toFloat(); } @:op(A >= B) private static inline function floatGte(a:Float, b:UInt):Bool { return a >= b.toFloat(); } @:op(A < B) private static inline function ltFloat(a:UInt, b:Float):Bool { return a.toFloat() < b; } @:op(A <= B) private static inline function lteFloat(a:UInt, b:Float):Bool { return a.toFloat() <= b; } @:op(A < B) private static inline function floatLt(a:Float, b:UInt):Bool { return a < b.toFloat(); } @:op(A <= B) private static inline function floatLte(a:Float, b:UInt):Bool { return a <= b.toFloat(); } @:op(A % B) private static inline function modFloat(a:UInt, b:Float):Float { return a.toFloat() % b; } @:op(A % B) private static inline function floatMod(a:Float, b:UInt):Float { return a % b.toFloat(); } @:op(~A) private inline function negBits():UInt { return ~this; } @:op(++A) private inline function prefixIncrement():UInt { return ++this; } @:op(A++) private inline function postfixIncrement():UInt { return this++; } @:op(--A) private inline function prefixDecrement():UInt { return --this; } @:op(A--) private inline function postfixDecrement():UInt { return this--; } // TODO: radix is just defined to deal with doc_gen issues private inline function toString(?radix:Int):String { return Std.string(toFloat()); } private inline function toInt():Int { return this; } @:to private #if (!js || analyzer) inline #end function toFloat():Float { var int = toInt(); if (int < 0) { return 4294967296.0 + int; } else { // + 0.0 here to make sure we promote to Float on some platforms // In particular, PHP was having issues when comparing to Int in the == op. return int + 0.0; } } } #end haxe_3.2.1+dfsg.orig/std/Xml.hx0000664000175000017500000002142412607337712016222 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:enum abstract XmlType(Int) { var Element = 0; var PCData = 1; var CData = 2; var Comment = 3; var DocType = 4; var ProcessingInstruction = 5; var Document = 6; } class Xml { static public var Element(default,null) = XmlType.Element; static public var PCData(default,null) = XmlType.PCData; static public var CData(default,null) = XmlType.CData; static public var Comment(default,null) = XmlType.Comment; static public var DocType(default,null) = XmlType.DocType; static public var ProcessingInstruction(default,null) = XmlType.ProcessingInstruction; static public var Document(default,null) = XmlType.Document; static public function parse( str : String ) : Xml { return haxe.xml.Parser.parse(str); } /** Returns the type of the Xml Node. This should be used before accessing other functions since some might raise an exception if the node type is not correct. **/ public var nodeType(default, null) : XmlType; /** Returns the node name of an Element. **/ @:isVar public var nodeName(get, set) : String; /** Returns the node value. Only works if the Xml node is not an Element or a Document. **/ @:isVar public var nodeValue(get, set) : String; /** Returns the parent object in the Xml hierarchy. The parent can be [null], an Element or a Document. **/ public var parent(default, null) : Xml; var children:Array; var attributeMap:Map; inline function get_nodeName() { if (nodeType != Element) { throw 'Bad node type, expected Element but found $nodeType'; } return nodeName; } inline function set_nodeName(v) { if (nodeType != Element) { throw 'Bad node type, expected Element but found $nodeType'; } return this.nodeName = v; } inline function get_nodeValue() { if (nodeType == Document || nodeType == Element) { throw 'Bad node type, unexpected $nodeType'; } return nodeValue; } inline function set_nodeValue(v) { if (nodeType == Document || nodeType == Element) { throw 'Bad node type, unexpected $nodeType'; } return this.nodeValue = v; } /** Creates a node of the given type. **/ static public function createElement( name : String ) : Xml { var xml = new Xml(Element); xml.nodeName = name; return xml; } /** Creates a node of the given type. **/ static public function createPCData( data : String ) : Xml { var xml = new Xml(PCData); xml.nodeValue = data; return xml; } /** Creates a node of the given type. **/ static public function createCData( data : String ) : Xml { var xml = new Xml(CData); xml.nodeValue = data; return xml; } /** Creates a node of the given type. **/ static public function createComment( data : String ) : Xml { var xml = new Xml(Comment); xml.nodeValue = data; return xml; } /** Creates a node of the given type. **/ static public function createDocType( data : String ) : Xml { var xml = new Xml(DocType); xml.nodeValue = data; return xml; } /** Creates a node of the given type. **/ static public function createProcessingInstruction( data : String ) : Xml { var xml = new Xml(ProcessingInstruction); xml.nodeValue = data; return xml; } /** Creates a node of the given type. **/ static public function createDocument() : Xml { return new Xml(Document); } /** Get the given attribute of an Element node. Returns [null] if not found. Attributes are case-sensitive. **/ public function get( att : String ) : String { if (nodeType != Element) { throw 'Bad node type, expected Element but found $nodeType'; } return attributeMap[att]; } /** Set the given attribute value for an Element node. Attributes are case-sensitive. **/ public function set( att : String, value : String ) : Void { if (nodeType != Element) { throw 'Bad node type, expected Element but found $nodeType'; } attributeMap.set(att, value); } /** Removes an attribute for an Element node. Attributes are case-sensitive. **/ public function remove( att : String ) : Void { if (nodeType != Element) { throw 'Bad node type, expected Element but found $nodeType'; } attributeMap.remove(att); } /** Tells if the Element node has a given attribute. Attributes are case-sensitive. **/ public function exists( att : String ) : Bool { if (nodeType != Element) { throw 'Bad node type, expected Element but found $nodeType'; } return attributeMap.exists(att); } /** Returns an [Iterator] on all the attribute names. **/ public function attributes() : Iterator { if (nodeType != Element) { throw 'Bad node type, expected Element but found $nodeType'; } return attributeMap.keys(); } /** Returns an iterator of all child nodes. Only works if the current node is an Element or a Document. **/ public inline function iterator() : Iterator { ensureElementType(); return children.iterator(); } /** Returns an iterator of all child nodes which are Elements. Only works if the current node is an Element or a Document. **/ public function elements() : Iterator { ensureElementType(); var ret = [for (child in children) if (child.nodeType == Element) child]; return ret.iterator(); } /** Returns an iterator of all child nodes which are Elements with the given nodeName. Only works if the current node is an Element or a Document. **/ public function elementsNamed( name : String ) : Iterator { ensureElementType(); var ret = [for (child in children) if (child.nodeType == Element && child.nodeName == name) child]; return ret.iterator(); } /** Returns the first child node. **/ public inline function firstChild() : Xml { ensureElementType(); return children[0]; } /** Returns the first child node which is an Element. **/ public function firstElement() : Xml { ensureElementType(); for (child in children) { if (child.nodeType == Element) { return child; } } return null; } /** Adds a child node to the Document or Element. A child node can only be inside one given parent node, which is indicated by the [parent] property. If the child is already inside this Document or Element, it will be moved to the last position among the Document or Element's children. If the child node was previously inside a different node, it will be moved to this Document or Element. **/ public function addChild( x : Xml ) : Void { ensureElementType(); if (x.parent != null) { x.parent.removeChild(x); } children.push(x); x.parent = this; } /** Removes a child from the Document or Element. Returns true if the child was successfuly removed. **/ public function removeChild( x : Xml ) : Bool { ensureElementType(); if (children.remove(x)) { x.parent = null; return true; } return false; } /** Inserts a child at the given position among the other childs. A child node can only be inside one given parent node, which is indicated by the [parent] property. If the child is already inside this Document or Element, it will be moved to the new position among the Document or Element's children. If the child node was previously inside a different node, it will be moved to this Document or Element. **/ public function insertChild( x : Xml, pos : Int ) : Void { ensureElementType(); if (x.parent != null) { x.parent.children.remove(x); } children.insert(pos, x); x.parent = this; } /** Returns a String representation of the Xml node. **/ public inline function toString() : String { return haxe.xml.Printer.print(this); } function new(nodeType:XmlType) { this.nodeType = nodeType; children = []; attributeMap = new Map(); } inline function ensureElementType() { if (nodeType != Document && nodeType != Element) { throw 'Bad node type, expected Element or Document but found $nodeType'; } } } haxe_3.2.1+dfsg.orig/std/cpp/ArrayBase.hx0000664000175000017500000000036412607337712020115 0ustar andyandy00000000000000package cpp; extern class ArrayBase { // Length is number of elements public var length(default,null):Int; public function getElementSize():Int; public function getByteCount():Int; public function getBase():RawPointer; } haxe_3.2.1+dfsg.orig/std/cpp/Callable.hx0000664000175000017500000000042112607337712017735 0ustar andyandy00000000000000package cpp; #if cpp typedef Callable = Function #else @:noPackageRestrict abstract Callable(T) { public var call(get,never):T; inline public function new(inValue:T) this = inValue; inline function get_call():T return this; } #end haxe_3.2.1+dfsg.orig/std/cpp/CastCharStar.hx0000664000175000017500000000045112607337712020563 0ustar andyandy00000000000000package cpp; abstract CastCharStar( RawPointer ) to(RawPointer) { inline function new(s:String) this = cast untyped s.__s; @:from static public inline function fromString(s:String) return new CastCharStar(s); @:to public inline function toPointer() return this; } haxe_3.2.1+dfsg.orig/std/cpp/Char.hx0000664000175000017500000000012312607337712017112 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract Char from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/ConstCharStar.hx0000664000175000017500000000063012607337712020756 0ustar andyandy00000000000000package cpp; abstract ConstCharStar( RawConstPointer ) to(RawConstPointer) { inline function new(s:String) this = untyped s.__s; @:from static public inline function fromString(s:String) return new ConstCharStar(s); @:to @:extern public inline function toString():String return new String(untyped this); @:to @:extern public inline function toPointer() return this; } haxe_3.2.1+dfsg.orig/std/cpp/ConstPointer.hx0000664000175000017500000000235412607337712020674 0ustar andyandy00000000000000package cpp; @:coreType @:include("cpp/Pointer.h") @:native("cpp.Pointer") @:analyzer(no_simplification) extern class ConstPointer { // ptr actually returns the pointer - not strictly a 'T' - for pointers to smart pointers // Use value or ref to get dereferenced value public var ptr:T; @:analyzer(no_simplification) public var value(get,never):T; public var raw(get,never):RawConstPointer; @:analyzer(no_simplification) public function get_value() : T; public function lt(inOther:Pointer):Bool; public function leq(inOther:Pointer):Bool; public function gt(inOther:Pointer):Bool; public function geq(inOther:Pointer):Bool; public static function fromRaw(ptr:RawConstPointer) : ConstPointer; public static function fromPointer(inNativePointer:Dynamic) : ConstPointer; public function reinterpret():Pointer; public function rawCast():RawPointer; @:analyzer(no_simplification) public function at(inIndex:Int):T; public function inc():ConstPointer; public function dec():ConstPointer; @:analyzer(no_simplification) public function postIncVal():T; public function incBy(inT:Int):ConstPointer; public function add(inT:Int):ConstPointer; } haxe_3.2.1+dfsg.orig/std/cpp/FastIterator.hx0000664000175000017500000000232012607337712020645 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp; extern class FastIterator { public function hasNext():Bool; public function next():T; } haxe_3.2.1+dfsg.orig/std/cpp/Float32.hx0000664000175000017500000000013212607337712017447 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract Float32 from Float to Float {} haxe_3.2.1+dfsg.orig/std/cpp/Float64.hx0000664000175000017500000000013212607337712017454 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract Float64 from Float to Float {} haxe_3.2.1+dfsg.orig/std/cpp/Function.hx0000664000175000017500000000126612607337712020033 0ustar andyandy00000000000000package cpp; @:coreType @:structAccess @:include("cpp/Pointer.h") @:analyzer(no_simplification) extern class Function { public function new(d:Dynamic); // Actually a function pointer, but can be called using haxe notation public var call(default,null):T; public static function getProcAddress(inModule:String, inFunction:String) : Function; public static function fromStaticFunction(inStaticFunction:T) : Callable; public function lt(inOther:Function):Bool; public function leq(inOther:Function):Bool; public function gt(inOther:Function):Bool; public function geq(inOther:Function):Bool; } haxe_3.2.1+dfsg.orig/std/cpp/Int16.hx0000664000175000017500000000012412607337712017137 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract Int16 from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/Int32.hx0000664000175000017500000000012412607337712017135 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract Int32 from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/Int64.hx0000664000175000017500000000012412607337712017142 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract Int64 from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/Int8.hx0000664000175000017500000000012312607337712017057 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract Int8 from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/Lib.hx0000664000175000017500000001144412607337712016753 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp; class Lib { /** Load and return a Cpp primitive from a DLL library. **/ public static function load( lib : String, prim : String, nargs : Int ) : Dynamic { #if (iphone || emscripten) return loadLazy(lib,prim,nargs); #else return untyped __global__.__loadprim(lib,prim,nargs); #end } /** Unloaded all dynamic libraries in reverse order of loading. Returns the number of libraries unloaded. **/ public static function unloadAllLibraries() : Int { return untyped __global__.__hxcpp_unload_all_libraries(); } @:analyzer(no_simplification) public static function _loadPrime( lib : String, prim : String, signature : String, quietFail = false ) : Dynamic { var factory:Callable< ConstCharStar -> Object > = untyped __global__.__hxcpp_cast_get_proc_address(lib, prim + "__prime", quietFail); if (factory!=null) { var func:Dynamic = factory.call(signature); if (func==null && !quietFail) throw '$prim does not have signature $signature'; return func; } return null; } /** Tries to load, and always returns a valid function, but the function may throw if called. **/ public static function loadLazy(lib,prim,nargs) : Dynamic { try { return untyped __global__.__loadprim(lib,prim,nargs); } catch( e : Dynamic ) { switch(nargs) { case 0 : return function() { throw e; }; case 2 : return function(_1,_2) { throw e; }; case 3 : return function(_1,_2,_3) { throw e; }; case 4 : return function(_1,_2,_3,_4) { throw e; }; case 5 : return function(_1,_2,_3,_4,_5) { throw e; }; default : return function(_1) { throw e; }; } } return null; } public static function rethrow(inExp:Dynamic) { throw inExp; } public static function stringReference(inBytes:haxe.io.Bytes) : String { var result:String = ""; untyped __global__.__hxcpp_string_of_bytes(inBytes.b, result, 0, 0, true); return result; } public static function pushDllSearchPath(inPath:String) : Void untyped __global__.__hxcpp_push_dll_path(inPath); public static function getDllExtension() : String return untyped __global__.__hxcpp_get_dll_extension(); public static function getBinDirectory() : String return untyped __global__.__hxcpp_get_bin_dir(); /** Returns bytes referencing the content of a string. Use with extreme caution - changing constant strings will crash. Changing one string can cause others to change unexpectedly. Only really safe if you are using it read-only or if it comes from stringReference above **/ public inline static function bytesReference( s : String ) : haxe.io.Bytes { var bytes = new haxe.io.BytesData(); untyped bytes.__unsafeStringReference(s); return haxe.io.Bytes.ofData(bytes); } /** Print the specified value on the default output. **/ public static function print( v : Dynamic ) : Void { untyped __global__.__hxcpp_print(v); } /** This function is used to make porting from neko to cpp easy. It does not need to do anything because the c-code can work with any Dynamic **/ public static function haxeToNeko( v : Dynamic ) : Dynamic { return v; } /** This function is used to make porting from neko to cpp easy. It does not need to do anything because the c-code can work with any Dynamic **/ public static function nekoToHaxe( v : Dynamic ) : Dynamic { return v; } /** Print the specified value on the default output followed by a newline character. **/ public static function println( v : Dynamic ) : Void { untyped __global__.__hxcpp_println(v); } public static function setFloatFormat(inFormat:String):Void { untyped __global__.__hxcpp_set_float_format(inFormat); } } haxe_3.2.1+dfsg.orig/std/cpp/NativeArray.hx0000664000175000017500000000317012607337712020467 0ustar andyandy00000000000000package cpp; extern class NativeArray { public static inline function blit( ioDestArray:Array, inDestElement:Int, inSourceArray:Array, inSourceElement:Int, inElementCount:Int ): Void { untyped ioDestArray.blit(inDestElement, inSourceArray, inSourceElement, inElementCount); }; public static inline function getBase( inArray:Array ) : ArrayBase { return untyped inArray; } public static inline function address( inArray:Array,inIndex:Int ) : Pointer { return Pointer.arrayElem(inArray,inIndex); } public static inline function setData( inArray:Array,inData:Pointer,inElementCount:Int ) : Void { untyped inArray.setData(inData.raw,inElementCount); } public static inline function setUnmanagedData( inArray:Array,inData:Pointer,inElementCount:Int ) : Void { untyped inArray.setUnmanagedData(inData.raw,inElementCount); } public static inline function zero( ioDestArray:Array, ?inFirst:Int, ?inElements:Int ) : Void { untyped ioDestArray.zero(inFirst, inElements); }; public static inline function unsafeGet( inDestArray:Array, inIndex:Int) : T { return untyped inDestArray.__unsafe_get(inIndex); } public static inline function unsafeSet( ioDestArray:Array, inIndex:Int, inValue:T) : T { return untyped ioDestArray.__unsafe_set(inIndex,inValue); } public static inline function memcmp( inArrayA:Array, inArrayB:Array) : Int { return untyped inArrayA.memcmp(inArrayB); } public static inline function setSize( ioArray:Array, inSize:Int) : Array { return untyped ioArray.__SetSizeExact(inSize); } } haxe_3.2.1+dfsg.orig/std/cpp/NativeString.hx0000664000175000017500000000070012607337712020653 0ustar andyandy00000000000000package cpp; extern class NativeString { public static inline function raw( inString:String ) : RawConstPointer { return untyped inString.__s; } public static inline function c_str( inString:String ) : ConstPointer { return cpp.ConstPointer.fromPointer(untyped inString.__s); } public static inline function fromPointer(inPtr:ConstPointer ) : String { return untyped __global__.String(inPtr.ptr); } } haxe_3.2.1+dfsg.orig/std/cpp/NativeXml.hx0000664000175000017500000002511612607337712020155 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp; enum XmlType { } typedef NativeXml = Xml; class Xml { public static var Element(default,null) : XmlType; public static var PCData(default,null) : XmlType; public static var CData(default,null) : XmlType; public static var Comment(default,null) : XmlType; public static var DocType(default,null) : XmlType; public static var ProcessingInstruction(default,null) : XmlType; public static var Document(default,null) : XmlType; private var _nodeName : String; private var _nodeValue : String; private var _attributes : Dynamic; private var _children : Array; private var _parent : Xml; function new() : Void { } private static var _parse = cpp.Lib.load("std","parse_xml",2); @:analyzer(ignore) public static function parse( str : String ) : Xml { var x = new Xml(); x._children = new Array(); var parser = { cur : x, xml : function(name,att) { var x = new Xml(); x._parent = untyped __this__.cur; x.nodeType = Xml.Element; x._nodeName = new String(name); x._attributes = att; x._children = new Array(); untyped { var i = 0; __this__.cur.addChild(x); __this__.cur = x; } }, cdata : function(text) { var x = new Xml(); x._parent = untyped __this__.cur; x.nodeType = Xml.CData; x._nodeValue = new String(text); untyped __this__.cur.addChild(x); }, pcdata : function(text) { var x = new Xml(); x._parent = untyped __this__.cur; x.nodeType = Xml.PCData; x._nodeValue = new String(text); untyped __this__.cur.addChild(x); }, comment : function(text:String) { var x = new Xml(); x._parent = untyped __this__.cur; if( untyped text.cca(0) == 63 ) { x.nodeType = Xml.ProcessingInstruction; text = new String(text); text = text.substr(1, text.length - 2); } else { x.nodeType = Xml.Comment; text = new String(text); } x._nodeValue = text; untyped __this__.cur.addChild(x); }, doctype : function(text) { var x = new Xml(); x._parent = untyped __this__.cur; x.nodeType = Xml.DocType; x._nodeValue = (new String(text)).substr(1); var p : Xml = untyped __this__.cur; p.addChild(x); }, done : function() { untyped __this__.cur = __this__.cur._parent; } }; untyped _parse(str,parser); x.nodeType = Xml.Document; return x; } public static function createElement( name : String ) : Xml { var r = new Xml(); r.nodeType = Xml.Element; r._nodeName = name; r._attributes = null; r._children = new Array(); return r; } public static function createPCData( data : String ) : Xml { var r = new Xml(); r.nodeType = Xml.PCData; r._nodeValue = data; return r; } public static function createCData( data : String ) : Xml { var r = new Xml(); r.nodeType = Xml.CData; r._nodeValue = data; return r; } public static function createComment( data : String ) : Xml { var r = new Xml(); r.nodeType = Xml.Comment; r._nodeValue = data; return r; } public static function createDocType( data : String ) : Xml { var r = new Xml(); r.nodeType = Xml.DocType; r._nodeValue = data; return r; } public static function createProcessingInstruction( data : String ) : Xml { var r = new Xml(); r.nodeType = Xml.ProcessingInstruction; r._nodeValue = data; return r; } public static function createDocument() : Xml { var r = new Xml(); r.nodeType = Xml.Document; r._children = new Array(); return r; } public var nodeType(default,null) : XmlType; public var nodeName(get,set) : String; public var nodeValue(get,set) : String; private function get_nodeName() : String { if( nodeType != Xml.Element ) throw "bad nodeType"; return _nodeName; } private function set_nodeName( n : String ) : String { if( nodeType != Xml.Element ) throw "bad nodeType"; return _nodeName = n; } private function get_nodeValue() : String { if( nodeType == Xml.Element || nodeType == Xml.Document ) throw "bad nodeType"; return _nodeValue; } private function set_nodeValue( v : String ) : String { if( nodeType == Xml.Element || nodeType == Xml.Document ) throw "bad nodeType"; return _nodeValue = v; } public var parent(get,null) : Xml; private function get_parent() : Xml { return _parent; } public function get( att : String ) : String { if( nodeType != Xml.Element ) throw "bad nodeType"; return Reflect.field( _attributes, att ); } public function set( att : String, value : String ) : Void { if( nodeType != Xml.Element ) throw "bad nodeType"; if (_attributes==null) _attributes = {}; Reflect.setField (_attributes, att, value ); return null; } public function remove( att : String ) : Void{ if( nodeType != Xml.Element ) throw "bad nodeType"; Reflect.deleteField( _attributes, att ); return null; } public function exists( att : String ) : Bool { if( nodeType != Xml.Element ) throw "bad nodeType"; return Reflect.hasField( _attributes, att ); } public function attributes() : Iterator { if( nodeType != Xml.Element ) throw "bad nodeType"; return Reflect.fields( _attributes ).iterator(); } public function iterator() : Iterator { if( _children == null ) throw "bad nodetype"; return untyped _children.iterator(); } @:analyzer(ignore) public function elements(): Iterator { if( _children == null ) throw "bad nodetype"; var children = _children; return untyped { cur: 0, hasNext : function() { var k:Int = __this__.cur; var l = children.length; while( k < l ) { if( children[k].nodeType == Xml.Element ) break; k += 1; } __this__.cur = k; return k < l; }, next : function() { var k = __this__.cur; var l = children.length; while( k < l ) { var n = children[k]; k += 1; if( n.nodeType == Xml.Element ) { __this__.cur = k; return n; } } return null; } } } @:analyzer(ignore) public function elementsNamed( name : String ) : Iterator { if( _children == null ) throw "bad nodetype"; var children = _children; return untyped { cur: 0, hasNext : function() { var k = __this__.cur; var l = children.length; while( k < l ) { var n = children[k]; if( n.nodeType == Xml.Element && n._nodeName == name ) break; k++; } __this__.cur = k; return k < l; }, next : function() { var k = __this__.cur; var l = children.length; while( k < l ) { var n = children[k]; k++; if( n.nodeType == Xml.Element && n._nodeName == name ) { __this__.cur = k; return n; } } return null; } } } public function firstChild() : Xml { if( _children == null ) throw "bad nodetype"; return _children[0]; } public function firstElement() : Xml { if( _children == null ) throw "bad nodetype"; for( cur in 0..._children.length ) { var n:Xml = _children[cur]; if( n.nodeType == Xml.Element ) return n; } return null; } public function addChild( x : Xml ) : Void { if( _children == null ) throw "bad nodetype"; if( x._parent != null ) x._parent._children.remove(x); x._parent = this; _children.push( x ); return null; } public function removeChild( x : Xml ) : Bool { if( _children == null ) throw "bad nodetype"; var b = _children.remove( x ); if( b ) x._parent = null; return b; } public function insertChild( x : Xml, pos : Int ) : Void { if( _children == null ) throw "bad nodetype"; if( x._parent != null ) x._parent._children.remove(x); x._parent = this; _children.insert( pos, x ); return null; } public function toString() : String { var s = new StringBuf(); toStringRec(s); return s.toString(); } private function toStringRec(s: StringBuf) : Void { switch( nodeType ) { case Xml.Document: for( x in _children ) x.toStringRec(s); case Xml.Element: s.addChar("<".code); s.add(_nodeName); for( k in Reflect.fields(_attributes) ) { s.addChar(" ".code); s.add(k); s.addChar("=".code); s.addChar("\"".code); s.add(Reflect.field(_attributes,k)); s.addChar("\"".code); } if( _children.length == 0 ) { s.addChar("/".code); s.addChar(">".code); return; } s.addChar(">".code); for( x in _children ) x.toStringRec(s); s.addChar("<".code); s.addChar("/".code); s.add(_nodeName); s.addChar(">".code); case Xml.PCData: s.add(StringTools.htmlEscape(_nodeValue)); case Xml.CData: s.add(""); case Xml.Comment: s.add(""); case Xml.DocType: s.add(""); case Xml.ProcessingInstruction: s.add(""); } } static function __init__() : Void untyped { PCData = Type.createEnum(XmlType,"__"); Element = Type.createEnum(XmlType,"__"); CData = Type.createEnum(XmlType,"__"); Comment = Type.createEnum(XmlType,"__"); DocType = Type.createEnum(XmlType,"__"); ProcessingInstruction = Type.createEnum(XmlType,"__"); Document = Type.createEnum(XmlType,"__"); __global__.__hxcpp_enum_force(PCData , "pcdata", 0); __global__.__hxcpp_enum_force(Element , "element", 1); __global__.__hxcpp_enum_force(CData , "cdata", 2); __global__.__hxcpp_enum_force(Comment , "comment", 3); __global__.__hxcpp_enum_force(DocType , "doctype", 4); __global__.__hxcpp_enum_force(ProcessingInstruction , "processingInstruction", 5); __global__.__hxcpp_enum_force(Document , "document", 6); } }haxe_3.2.1+dfsg.orig/std/cpp/Object.hx0000664000175000017500000000071712607337712017454 0ustar andyandy00000000000000package cpp; @:native("::hx::Object *") extern class HxObjectPtr { @:native("hx::DynamicPtr") static function fromDynamic(x:Dynamic):Object; @:native("Dynamic") static function toDynamic(x:Object):Dynamic; } @:extern abstract Object(HxObjectPtr) { @:from public inline static function from(x:Dynamic):Object return HxObjectPtr.fromDynamic(x); @:to public inline static function to(inVal:HxObjectPtr):Dynamic return HxObjectPtr.toDynamic(inVal); } haxe_3.2.1+dfsg.orig/std/cpp/Pointer.hx0000664000175000017500000000211312607337712017656 0ustar andyandy00000000000000package cpp; @:coreType @:analyzer(no_simplification) extern class Pointer extends ConstPointer implements ArrayAccess { @:analyzer(no_simplification) public var ref(get,set):T; @:analyzer(no_simplification) public function get_ref() : T; @:analyzer(no_simplification) public function set_ref(t:T) : T; public static function fromRaw(ptr:RawPointer) : Pointer; public static function fromHandle(inHandle:Dynamic,?inKind:String) : Pointer; public static function fromPointer(inNativePointer:Dynamic) : Pointer; public static function addressOf(inVariable:T) : Pointer; public static function arrayElem(array:Array, inElem:Int):Pointer; public function get_raw() : RawPointer; override public function inc():Pointer; override public function dec():Pointer; override public function incBy(inT:Int):Pointer; override public function add(inT:Int):Pointer; @:analyzer(no_simplification) public function postIncRef():T; public function destroy():Void; public function destroyArray():Void; } haxe_3.2.1+dfsg.orig/std/cpp/Prime.hx0000664000175000017500000000772612607337712017331 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp; #if macro import haxe.macro.Context; import haxe.macro.Type; import haxe.macro.Expr; #end @:noPackageRestrict class Prime { #if (!macro && cpp) @:analyzer(no_simplification) public static function _loadPrime( lib : String, prim : String, signature : String, quietFail = false ) : Dynamic { var factory:Callable< ConstCharStar -> Object > = untyped __global__.__hxcpp_cast_get_proc_address(lib, prim + "__prime", quietFail); if (factory!=null) { var func:Dynamic = factory.call(signature); if (func==null && !quietFail) throw '$prim does not have signature $signature'; return func; } return null; } #end #if (macro) static function codeToType(code:String,forCpp:Bool) : String { var isCpp = Context.defined("cpp"); switch(code) { case "b" : return "Bool"; case "i" : return "Int"; case "d" : return "Float"; case "s" : return "String"; case "f" : return forCpp ? "cpp.Float32" : "Float"; case "o" : return forCpp ? "cpp.Object" : "Dynamic"; case "v" : return forCpp ? "cpp.Void" : "Dynamic"; case "c" : if (forCpp) return "cpp.ConstCharStar"; throw "const char * type only supported in cpp mode"; default: throw "Unknown signature type :" + code; } } #end public static function nekoInit(inModuleName:String) : Bool { #if neko var init = neko.Lib.load(inModuleName, "neko_init", 5); if (init != null) { init( function(s) return new String(s), function(len:Int) { var r = []; if (len > 0) r[len - 1] = null; return r; }, null, true, false); return true; } #end return false; } public static macro function load(inModule:String, inName:String, inSig:String,inAllowFail:Bool = false) { var parts = inSig.split(""); if (parts.length<1) throw "Invalid function signature " + inSig; var cppMode = Context.defined("cpp"); var typeString = parts.length==1 ? codeToType("v",cppMode) : codeToType(parts.shift(),cppMode); for(p in parts) typeString += "->" + codeToType(p,cppMode); if (cppMode) { typeString = "cpp.Callable<" + typeString + ">"; var expr = 'new $typeString(cpp.Prime._loadPrime("$inModule","$inName","$inSig",$inAllowFail))'; return Context.parse( expr, Context.currentPos() ); } else { var len = parts.length; if (len>5) len = -1; var lazy = inAllowFail ? "loadLazy" : "load"; var expr = 'new cpp.Callable<$typeString>(neko.Lib.$lazy("$inModule","$inName",$len))'; return Context.parse( expr, Context.currentPos() ); } } } haxe_3.2.1+dfsg.orig/std/cpp/Random.hx0000664000175000017500000000321012607337712017455 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp; class Random { var r : Dynamic; public function new() { r = random_new(); } public function setSeed( s : Int ) { random_set_seed(r,s); } public function int( max : Int ) : Int { return random_int(r,max); } public function float() : Float { return random_float(r); } static var random_new = Lib.load("std","random_new",0); static var random_set_seed = Lib.load("std","random_set_seed",2); static var random_int = Lib.load("std","random_int",2); static var random_float = Lib.load("std","random_float",1); } haxe_3.2.1+dfsg.orig/std/cpp/RawConstPointer.hx0000664000175000017500000000010112607337712021332 0ustar andyandy00000000000000package cpp; @:unreflective extern class RawConstPointer { } haxe_3.2.1+dfsg.orig/std/cpp/RawPointer.hx0000664000175000017500000000012712607337712020333 0ustar andyandy00000000000000package cpp; @:unreflective extern class RawPointer extends RawConstPointer { } haxe_3.2.1+dfsg.orig/std/cpp/UInt16.hx0000664000175000017500000000012512607337712017265 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract UInt16 from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/UInt32.hx0000664000175000017500000000012512607337712017263 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract UInt32 from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/UInt64.hx0000664000175000017500000000012512607337712017270 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract UInt64 from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/UInt8.hx0000664000175000017500000000012412607337712017205 0ustar andyandy00000000000000package cpp; @:coreType @:notNull @:runtimeValue abstract UInt8 from Int to Int {} haxe_3.2.1+dfsg.orig/std/cpp/Void.hx0000664000175000017500000000006612607337712017144 0ustar andyandy00000000000000package cpp; @:native("void") extern class Void { } haxe_3.2.1+dfsg.orig/std/cpp/_std/Date.hx0000664000175000017500000000624512607337712020056 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class Date { private var mSeconds:Float; public function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void { mSeconds = untyped __global__.__hxcpp_new_date(year,month,day,hour,min,sec); } public function getTime() : Float { return mSeconds * 1000.0; } public function getHours() : Int { return untyped __global__.__hxcpp_get_hours(mSeconds); } public function getMinutes() : Int { return untyped __global__.__hxcpp_get_minutes(mSeconds); } public function getSeconds() : Int { return untyped __global__.__hxcpp_get_seconds(mSeconds); } public function getFullYear() : Int { return untyped __global__.__hxcpp_get_year(mSeconds); } public function getMonth() : Int { return untyped __global__.__hxcpp_get_month(mSeconds); } public function getDate() : Int { return untyped __global__.__hxcpp_get_date(mSeconds); } public function getDay() : Int { return untyped __global__.__hxcpp_get_day(mSeconds); } public function toString():String { return untyped __global__.__hxcpp_to_string(mSeconds); } public static function now() : Date { return fromTime( untyped __global__.__hxcpp_date_now()*1000.0); } private static function new1(t : Dynamic) : Date { return new Date(2005,1,1,0,0,0); } public static function fromTime( t : Float ) : Date { var result = new Date(0,0,0,0,0,0); result.mSeconds = t*0.001; return result; } public static function fromString( s : String ) : Date { switch( s.length ) { case 8: // hh:mm:ss var k = s.split(":"); var d : Date = new Date(0,0,0,Std.parseInt(k[0]),Std.parseInt(k[1]),Std.parseInt(k[2])); return d; case 10: // YYYY-MM-DD var k = s.split("-"); return new Date(Std.parseInt(k[0]),Std.parseInt(k[1])-1,Std.parseInt(k[2]),0,0,0); case 19: // YYYY-MM-DD hh:mm:ss var k = s.split(" "); var y = k[0].split("-"); var t = k[1].split(":"); return new Date(Std.parseInt(y[0]),Std.parseInt(y[1]) - 1,Std.parseInt(y[2]), Std.parseInt(t[0]),Std.parseInt(t[1]),Std.parseInt(t[2])); default: throw "Invalid date format : " + s; } } } haxe_3.2.1+dfsg.orig/std/cpp/_std/EReg.hx0000664000175000017500000001151012607337712020012 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class EReg { var r : Dynamic; var last : String; var global : Bool; public function new( r : String, opt : String ) : Void { var a = opt.split("g"); global = a.length > 1; if( global ) opt = a.join(""); this.r = regexp_new_options(r, opt); } public function match( s : String ) : Bool { var p = regexp_match(r,s,0,s.length); if( p ) last = s; else last = null; return p; } public function matched( n : Int ) : String { var m = regexp_matched(r,n); return m; } public function matchedLeft() : String { var p = regexp_matched_pos(r,0); return last.substr(0,p.pos); } public function matchedRight() : String { var p = regexp_matched_pos(r,0); var sz = p.pos+p.len; return last.substr(sz,last.length-sz); } public function matchedPos() : { pos : Int, len : Int } { return regexp_matched_pos(r,0); } public function matchSub( s : String, pos : Int, len : Int = -1):Bool { var p = regexp_match(r, s, pos, len < 0 ? s.length - pos : len); if (p) last = s; else last = null; return p; } public function split( s : String ) : Array { var pos = 0; var len = s.length; var a = new Array(); var first = true; do { if( !regexp_match(r,s,pos,len) ) break; var p = regexp_matched_pos(r,0); if( p.len == 0 && !first ) { if( p.pos == s.length ) break; p.pos += 1; } a.push(s.substr(pos,p.pos - pos)); var tot = p.pos + p.len - pos; pos += tot; len -= tot; first = false; } while( global ); a.push(s.substr(pos,len)); return a; } public function replace( s : String, by : String ) : String { var b = new StringBuf(); var pos = 0; var len = s.length; var a = by.split("$"); var first = true; do { if( !regexp_match(r,s,pos,len) ) break; var p = regexp_matched_pos(r,0); if( p.len == 0 && !first ) { if( p.pos == s.length ) break; p.pos += 1; } b.addSub(s,pos,p.pos-pos); if( a.length > 0 ) b.add(a[0]); var i = 1; while( i < a.length ) { var k = a[i]; var c = k.charCodeAt(0); // 1...9 if( c >= 49 && c <= 57 ) { var p = try regexp_matched_pos(r,Std.int(c)-48) catch( e : String ) null; if( p == null ){ b.add("$"); b.add(k); }else{ b.addSub(s,p.pos,p.len); b.addSub(k,1,k.length - 1); } } else if( c == null ) { b.add("$"); i++; var k2 = a[i]; if( k2 != null && k2.length > 0 ) b.add(k2); } else b.add("$"+k); i++; } var tot = p.pos + p.len - pos; pos += tot; len -= tot; first = false; } while( global ); b.addSub(s,pos,len); return b.toString(); } public function map( s : String, f : EReg -> String ) : String { var offset = 0; var buf = new StringBuf(); do { if (offset >= s.length) break; else if (!matchSub(s, offset)) { buf.add(s.substr(offset)); break; } var p = regexp_matched_pos(r,0); buf.add(s.substr(offset, p.pos - offset)); buf.add(f(this)); if (p.len == 0) { buf.add(s.substr(p.pos, 1)); offset = p.pos + 1; } else offset = p.pos + p.len; } while (global); if (!global && offset > 0 && offset < s.length) buf.add(s.substr(offset)); return buf.toString(); } static var regexp_new_options : String -> String -> Dynamic = cpp.Lib.load("regexp","regexp_new_options",2); static var regexp_match : Dynamic -> String -> Int -> Int -> Dynamic = cpp.Lib.load("regexp","regexp_match",4); static var regexp_matched : Dynamic -> Int -> Dynamic = cpp.Lib.load("regexp","regexp_matched",2); static var regexp_matched_pos : Dynamic -> Int -> { pos : Int, len : Int } = cpp.Lib.load("regexp","regexp_matched_pos",2); } haxe_3.2.1+dfsg.orig/std/cpp/_std/Reflect.hx0000664000175000017500000000777412607337712020575 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class Reflect { public static function hasField( o : Dynamic, field : String ) : Bool untyped { return o!=null && o.__HasField(field); } public static function field( o : Dynamic, field : String ) : Dynamic untyped { return (o==null) ? null : o.__Field(field,untyped __cpp__("hx::paccNever") ); } public static function setField( o : Dynamic, field : String, value : Dynamic ) : Void untyped { if (o!=null) o.__SetField(field,value,untyped __cpp__("hx::paccNever") ); } public static function getProperty( o : Dynamic, field : String ) : Dynamic { return (o==null) ? null : o.__Field(field,untyped __cpp__("hx::paccAlways") ); } public static function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void { if (o!=null) o.__SetField(field,value,untyped __cpp__("hx::paccAlways") ); } public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array ) : Dynamic untyped { if (func!=null && func.__GetType()==__global__.vtString) func = o.__Field(func,untyped __cpp__("hx::paccDynamic")); untyped func.__SetThis(o); return untyped func.__Run(args); } public static function fields( o : Dynamic ) : Array untyped { if( o == null ) return new Array(); var a : Array = []; o.__GetFields(a); return a; } public static function isFunction( f : Dynamic ) : Bool untyped { return f!=null && f.__GetType() == __global__.vtFunction; } public static function compare( a : T, b : T ) : Int { return ( a == b ) ? 0 : (((a:Dynamic) > (b:Dynamic)) ? 1 : -1); } public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool { if( f1 == f2 ) return true; if( !isFunction(f1) || !isFunction(f2) ) return false; return untyped __global__.__hxcpp_same_closure(f1,f2); } public static function isObject( v : Dynamic ) : Bool untyped { if (v==null) return false; var t:Int = v.__GetType(); return t == __global__.vtObject || t==__global__.vtClass || t==__global__.vtString || t==__global__.vtArray; } public static function isEnumValue( v : Dynamic ) : Bool untyped { return v!=null && v.__GetType() == __global__.vtEnum; } public static function deleteField( o : Dynamic, field : String ) : Bool untyped { if (o==null) return false; return untyped __global__.__hxcpp_anon_remove(o,field); } public static function copy( o : T ) : T { if (o==null) return null; if(untyped o.__GetType()==__global__.vtString ) return o; if(untyped o.__GetType()==__global__.vtArray ) return untyped o.__Field("copy", untyped __cpp__("hx::paccDynamic"))(); var o2 : Dynamic = {}; for( f in Reflect.fields(o) ) Reflect.setField(o2,f,Reflect.field(o,f)); return o2; } @:overload(function( f : Array -> Void ) : Dynamic {}) public static function makeVarArgs( f : Array -> Dynamic ) : Dynamic { return untyped __global__.__hxcpp_create_var_args(f); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/Std.hx0000664000175000017500000000371412607337712017731 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class Std { @:keep public static function is( v : Dynamic, t : Dynamic ) : Bool { return untyped __global__.__instanceof(v,t); } @:keep public static function instance( value : T, c : Class ) : S { return Std.is(value, c) ? cast value : null; } @:keep public static function string( s : Dynamic ) : String { return untyped s==null ? "null" : s.toString(); } @:keep public static function int( x : Float ) : Int { return untyped __global__.__int__(x); } @:keep public static function parseInt( x : String ) : Null { return untyped __global__.__hxcpp_parse_int(x); } @:keep public static function parseFloat( x : String ) : Float { return untyped __global__.__hxcpp_parse_float(x); } @:keep public static function random( x : Int ) : Int { if (x <= 0) return 0; return untyped __global__.__hxcpp_irand(x); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/StringBuf.hx0000664000175000017500000000331712607337712021101 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class StringBuf { private var b : Array; public var length(get,never) : Int; public function new() : Void { b = new Array(); } function get_length() : Int { var len = 0; for(s in b) len += s==null ? 4 : s.length; return len; } public function add( x : T ) : Void { b.push(Std.string(x)); } public inline function addSub( s : String, pos : Int, ?len : Int ) : Void { b.push(s.substr(pos,len)); } public inline function addChar( c : Int ) : Void untyped { b.push(String.fromCharCode(c)); } public inline function toString() : String { return b.join(""); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/Sys.hx0000664000175000017500000001143212607337712017751 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class Sys { public static function print( v : Dynamic ) : Void { untyped __global__.__hxcpp_print(v); } public static function println( v : Dynamic ) : Void { print(v); print("\n"); } public static function stdin() : haxe.io.Input { return untyped new sys.io.FileInput(file_stdin()); } public static function stdout() : haxe.io.Output { return untyped new sys.io.FileOutput(file_stdout()); } public static function stderr() : haxe.io.Output { return untyped new sys.io.FileOutput(file_stderr()); } public static function getChar( echo : Bool ) : Int { return getch(echo); } public static function args() : Array untyped { return __global__.__get_args(); } public static function getEnv( s : String ):String { var v = get_env(s); if( v == null ) return null; return v; } public static function putEnv( s : String, v : String ) : Void { put_env(s,v); } public static function sleep( seconds : Float ) : Void { _sleep(seconds); } public static function setTimeLocale( loc : String ) : Bool { return set_time_locale(loc); } public static function getCwd() : String { return new String(get_cwd()); } public static function setCwd( s : String ) : Void { set_cwd(s); } public static function systemName() : String { return sys_string(); } static function escapeArgument( arg : String ) : String { var ok = true; for( i in 0...arg.length ) switch( arg.charCodeAt(i) ) { case ' '.code, '\t'.code, '"'.code, '&'.code, '|'.code, '<'.code, '>'.code, '#'.code , ';'.code, '*'.code, '?'.code, '('.code, ')'.code, '{'.code, '}'.code, '$'.code: ok = false; case 0, 13, 10: // [eof] [cr] [lf] arg = arg.substr(0,i); } if( ok ) return arg; return '"'+arg.split('\\').join("\\\\").split('"').join('\\"')+'"'; } public static function command( cmd : String, ?args : Array ) : Int { if( args != null ) { cmd = escapeArgument(cmd); for( a in args ) cmd += " "+escapeArgument(a); } if (systemName() == "Windows") cmd = '"$cmd"'; return sys_command(cmd); } public static function exit( code : Int ) : Void { untyped __global__.__hxcpp_exit(code); } public static function time() : Float { return sys_time(); } public static function cpuTime() : Float { return sys_cpu_time(); } public static function executablePath() : String { return new String(sys_exe_path()); } public static function environment() : Map { var vars:Array = sys_env(); var result = new haxe.ds.StringMap(); var i = 0; while(i ); TEnum( e : Enum ); TUnknown; } @:coreApi class Type { public static function getClass( o : T ) : Class untyped { if (o==null || !Reflect.isObject(o)) return null; var c = o.__GetClass(); switch(c.toString()) { case "__Anon" : return null; case "Class" : return null; } return c; } public static function getEnum( o : EnumValue ) : Enum untyped { if (o==null) return null; return untyped o.__GetClass(); } public static function getSuperClass( c : Class ) : Class untyped { return c.GetSuper(); } public static function getClassName( c : Class ) : String { if( c == null ) return null; return untyped c.mName; } public static function getEnumName( e : Enum ) : String { return untyped e.__ToString(); } public static function resolveClass( name : String ) : Class untyped { var result:Class = Class.Resolve(name); if (result!=null && result.__IsEnum() ) return null; return result; } public static function resolveEnum( name : String ) : Enum untyped { var result:Class = Class.Resolve(name); if (result!=null && !result.__IsEnum() ) return null; return result; } public static function createInstance( cl : Class, args : Array ) : T untyped { if (cl!=null) return cl.ConstructArgs(args); return null; } public static function createEmptyInstance( cl : Class ) : T untyped { return cl.ConstructEmpty(); } public static function createEnum( e : Enum, constr : String, ?params : Array ) : T { return untyped e.ConstructEnum(constr,params); } public static function createEnumIndex( e : Enum, index : Int, ?params : Array ) : T { var c = Type.getEnumConstructs(e)[index]; if( c == null ) throw index+" is not a valid enum constructor index"; return createEnum(e,c,params); } public static function getInstanceFields( c : Class ) : Array { return untyped c.GetInstanceFields(); } public static function getClassFields( c : Class ) : Array { return untyped c.GetClassFields(); } public static function getEnumConstructs( e : Enum ) : Array untyped { return untyped e.GetClassFields(); } public static function typeof( v : Dynamic ) : ValueType untyped { if (v==null) return TNull; var t:Int = untyped v.__GetType(); switch(t) { case 2 : return TBool; case 0xFF : return TInt; case 1 : return TFloat; case 6 : return TFunction; case 4 : return TObject; case 7 : return TEnum(v.__GetClass()); default: return untyped TClass(v.__GetClass()); } } public static function enumEq( a : T, b : T ) : Bool untyped { return a==b; } public static function enumConstructor( e : EnumValue ) : String { return untyped e.__Tag(); } public static function enumParameters( e : EnumValue ) : Array { var result : Array = untyped e.__EnumParams(); return result==null ? [] : result; } public inline static function enumIndex( e : EnumValue ) : Int { return untyped e.__Index(); } public static function allEnums( e : Enum ) : Array { var names:Array = untyped e.GetClassFields(); var enums = new Array(); for(name in names) { try { var result:T = untyped e.ConstructEnum(name,null); if (result!=null) enums.push( result ); } catch ( invalidArgCount:String) { } } return enums; } } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/Int64.hx0000664000175000017500000002637412607337712021037 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; @:notNull @:native("cpp::Int64Struct") private extern class ___Int64 { public function get():cpp.Int64; } private typedef __Int64 = ___Int64; @:coreApi abstract Int64( __Int64 ) from __Int64 to __Int64 { /** Makes a copy of `this` Int64. **/ public #if !cppua inline #end function copy():Int64 return this; public static #if !cppia inline #end function make( high : Int32, low : Int32 ) : Int64 { return untyped __cpp__("cpp::Int64Struct(( ( (cpp::Int64)((unsigned int){0}) ) << 32 ) | ((unsigned int){1}))",high, low); } @:from public static function ofInt( x : Int ) : Int64 { return untyped __cpp__("((cpp::Int64)({0}))", x); } /** Returns an Int with the value of the Int64 `x`. Throws an exception if `x` cannot be represented in 32 bits. **/ public static #if !cppia inline #end function toInt( x : Int64 ) : Int { if( x.high != x.low >> 31 ) throw "Overflow"; return x.low; } /** Returns whether the value `val` is of type `haxe.Int64` **/ public static #if !cppia inline #end function is( val : Dynamic ) : Bool return untyped __cpp__("(cpp::Int64Struct::is({0}))",val); /** Returns the high 32-bit word of `x`. **/ @:deprecated("Use high instead") public static #if !cppia inline #end function getHigh( x : Int64 ) : Int32 return x.high; /** Returns the low 32-bit word of `x`. **/ @:deprecated("Use low instead") public static #if !cppia inline #end function getLow( x : Int64 ) : Int32 return x.low; /** Returns `true` if `x` is less than zero. **/ public static #if !cppia inline #end function isNeg( x : Int64) : Bool return untyped __cpp__("(({0}.get()) < 0)", x); /** Returns `true` if `x` is exactly zero. **/ public static #if !cppia inline #end function isZero( x : Int64 ) : Bool return untyped __cpp__("(({0}.get()) == 0)", x); /** Compares `a` and `b` in signed mode. Returns a negative value if `a < b`, positive if `a > b`, or 0 if `a == b`. **/ public static #if !cppia inline #end function compare( a : Int64, b : Int64 ) : Int { return untyped __cpp__("( ({0}.get()) < ({1}.get()) ? -1 : ({0})==({1}) ? 0 : 1)", a, b, a, b); } /** Compares `a` and `b` in unsigned mode. Returns a negative value if `a < b`, positive if `a > b`, or 0 if `a == b`. **/ public static #if !cppia inline #end function ucompare( a : Int64, b : Int64 ) : Int { return untyped __cpp__("( (cpp::UInt64)({0}.get()) < (cpp::UInt64)({1}.get()) ? -1 : ({0}.get())==({1}.get()) ? 0 : 1)", a, b, a, b); } /** Returns a signed decimal `String` representation of `x`. **/ public static #if !cppia inline #end function toStr(x:Int64) : String return x.toString(); private function toString() : String { return untyped __cpp__("String( ({0}).get() )", this); } /** Performs signed integer divison of `dividend` by `divisor`. Returns `{ quotient : Int64, modulus : Int64 }`. **/ public static function divMod( dividend : Int64, divisor : Int64 ) : { quotient : Int64, modulus : Int64 } { var q = dividend/divisor; if (isZero(divisor)) throw "divide by zero"; var m = dividend - q*divisor; return { quotient : q, modulus : m }; } /** Returns the negative of `x`. **/ @:op(-A) public static #if !cppia inline #end function neg( x : Int64 ) : Int64 { return untyped __cpp__("(-({0}.get()))",x); } @:op(++A) private inline function preIncrement() : Int64 { #if cppia this = this + make(0,1); return this; #else return untyped __cpp__("(++({0}.get()))",this); #end } @:op(A++) private inline function postIncrement() : Int64 { #if cppia var result = this; this = this + make(0,1); return result; #else return untyped __cpp__("(({0}.get())++)",this); #end } @:op(--A) private inline function preDecrement() : Int64 { #if cppia untyped this = this - make(0,1); return this; #else return untyped __cpp__("(--({0}.get()))",this); #end } @:op(A--) private inline function postDecrement() : Int64 { #if cppia var result = this; this = this - make(0,1); return result; #else return untyped __cpp__("(({0}.get())--)",this); #end } /** Returns the sum of `a` and `b`. **/ @:op(A + B) public static #if !cppia inline #end function add( a : Int64, b : Int64 ) : Int64 { return untyped __cpp__("(({0}.get()) + ({1}.get()))", a, b); } @:op(A + B) @:commutative private static #if !cppia inline #end function addInt( a : Int64, b : Int ) : Int64 return add( a, b ); /** Returns `a` minus `b`. **/ @:op(A - B) public static #if !cppia inline #end function sub( a : Int64, b : Int64 ) : Int64 { return untyped __cpp__("(({0}.get()) - ({1}.get()))", a, b); } @:op(A - B) private static #if !cppia inline #end function subInt( a : Int64, b : Int ) : Int64 return sub( a, b ); @:op(A - B) private static #if !cppia inline #end function intSub( a : Int, b : Int64 ) : Int64 return sub( a, b ); /** Returns the product of `a` and `b`. **/ @:op(A * B) public static #if !cppia inline #end function mul( a : Int64, b : Int64 ) : Int64 { return untyped __cpp__("(({0}.get()) * ({1}.get()))", a, b); } @:op(A * B) @:commutative private static #if !cppia inline #end function mulInt( a : Int64, b : Int ) : Int64 return mul( a, b ); /** Returns the quotient of `a` divided by `b`. **/ @:op(A / B) public static function div( a : Int64, b : Int64 ) : Int64 { if (untyped __cpp__("(({0}.get()) == 0)",b) ) throw "divide by zero"; return untyped __cpp__("(({0}.get()) / ({1}.get()))", a, b); } @:op(A / B) private static #if !cppia inline #end function divInt( a : Int64, b : Int ) : Int64 return div( a, b ); @:op(A / B) private static #if !cppia inline #end function intDiv( a : Int, b : Int64 ) : Int64 return toInt(div( a, b )); /** Returns the modulus of `a` divided by `b`. **/ @:op(A % B) public static #if !cppia inline #end function mod( a : Int64, b : Int64 ) : Int64 { if (untyped __cpp__("(({0}.get()) == 0)",b) ) throw "divide by zero"; return untyped __cpp__("(({0}.get()) % ({1}.get()))", a, b); } @:op(A % B) private static #if !cppia inline #end function modInt( a : Int64, b : Int ) : Int64 return toInt(mod( a, b )); @:op(A % B) private static #if !cppia inline #end function intMod( a : Int, b : Int64 ) : Int64 return toInt(mod( a, b )); /** Returns `true` if `a` is equal to `b`. **/ @:op(A == B) public static #if !cppia inline #end function eq( a : Int64, b : Int64 ) : Bool return untyped __cpp__("(({0}.get()) == ({1}.get()))", a, b); @:op(A == B) @:commutative private static #if !cppia inline #end function eqInt( a : Int64, b : Int ) : Bool return eq( a, b ); /** Returns `true` if `a` is not equal to `b`. **/ @:op(A != B) public static #if !cppia inline #end function neq( a : Int64, b : Int64 ) : Bool return untyped __cpp__("(({0}.get()) != ({1}.get()))", a, b); @:op(A != B) @:commutative private static #if !cppia inline #end function neqInt( a : Int64, b : Int ) : Bool return neq(a, b); @:op(A < B) private static #if !cppia inline #end function lt( a : Int64, b : Int64 ) : Bool return compare(a, b) < 0; @:op(A < B) private static #if !cppia inline #end function ltInt( a : Int64, b : Int ) : Bool return lt(a, b); @:op(A < B) private static #if !cppia inline #end function intLt( a : Int, b : Int64 ) : Bool return lt(a, b); @:op(A <= B) private static #if !cppia inline #end function lte( a : Int64, b : Int64 ) : Bool return compare(a, b) <= 0; @:op(A <= B) private static #if !cppia inline #end function lteInt( a : Int64, b : Int ) : Bool return lte(a, b); @:op(A <= B) private static #if !cppia inline #end function intLte( a : Int, b : Int64 ) : Bool return lte(a, b); @:op(A > B) private static #if !cppia inline #end function gt( a : Int64, b : Int64 ) : Bool return compare(a, b) > 0; @:op(A > B) private static #if !cppia inline #end function gtInt( a : Int64, b : Int ) : Bool return gt(a, b); @:op(A > B) private static #if !cppia inline #end function intGt( a : Int, b : Int64 ) : Bool return gt( a, b ); @:op(A >= B) private static #if !cppia inline #end function gte( a : Int64, b : Int64 ) : Bool return compare(a, b) >= 0; @:op(A >= B) private static #if !cppia inline #end function gteInt( a : Int64, b : Int ) : Bool return gte(a, b); @:op(A >= B) private static #if !cppia inline #end function intGte( a : Int, b : Int64 ) : Bool return gte(a, b); /** Returns the bitwise NOT of `a`. **/ @:op(~A) private static #if !cppia inline #end function complement( a : Int64 ) : Int64 return untyped __cpp__("(~({0}.get()))", a); /** Returns the bitwise AND of `a` and `b`. **/ @:op(A & B) public static #if !cppia inline #end function and( a : Int64, b : Int64 ) : Int64 return untyped __cpp__("(({0}) & ({1}))", a, b); /** Returns the bitwise OR of `a` and `b`. **/ @:op(A | B) public static #if !cppia inline #end function or( a : Int64, b : Int64 ) : Int64 return untyped __cpp__("(({0}) | ({1}))", a, b); /** Returns the bitwise XOR of `a` and `b`. **/ @:op(A ^ B) public static #if !cppia inline #end function xor( a : Int64, b : Int64 ) : Int64 return untyped __cpp__("(({0}) ^ ({1}))", a, b); /** Returns `a` left-shifted by `b` bits. **/ @:op(A << B) public static #if !cppia inline #end function shl( a : Int64, b : Int ) : Int64 return untyped __cpp__("(({0}) << ({1}))", a, (b&63)); /** Returns `a` right-shifted by `b` bits in signed mode. `a` is sign-extended. **/ @:op(A >> B) public static #if !cppia inline #end function shr( a : Int64, b : Int) : Int64 return untyped __cpp__("(({0}) >> ({1}))", a, (b&63)); /** Returns `a` right-shifted by `b` bits in unsigned mode. `a` is padded with zeroes. **/ @:op(A >>> B) public static #if !cppia inline #end function ushr( a : Int64, b : Int ) : Int64 return untyped __cpp__("(((cpp::UInt64)({0})) >> ({1}))", a, (b&63)); public var high(get, never) : Int32; private #if !cppia inline #end function get_high() : Int32 return untyped __cpp__("(int)(((cpp::Int64)({0}))>>32)",this); public var low(get, never) : Int32; private #if !cppia inline #end function get_low() : Int32 return untyped __cpp__("(int)(({0})&0xffffffff)", this); } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/Resource.hx0000664000175000017500000000312312607337712021705 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; @:coreApi class Resource { public static function listNames() : Array { return untyped __global__.__hxcpp_resource_names(); } public static function getString(name:String) : String { return untyped __global__.__hxcpp_resource_string(name); } public static function getBytes(name:String) : haxe.io.Bytes { var array:haxe.io.BytesData = untyped __global__.__hxcpp_resource_bytes(name); if (array==null) return null; return haxe.io.Bytes.ofData(array); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/Utf8.hx0000664000175000017500000000714412607337712020753 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; @:coreApi class Utf8 { var __s:Array; public function new( ?size : Null ) : Void { __s = new Array(); if (size!=null && size>0) __s[size-1] = 0; } public function addChar( c : Int ) : Void { __s.push(c); } public function toString() : String { return untyped __global__.__hxcpp_char_array_to_utf8_string(__s); } // Incoming string is array of bytes containing possibly invalid utf8 chars // Result is the same string with the bytes expanded into utf8 sequences public static function encode( s : String ) : String { return untyped __global__.__hxcpp_char_bytes_to_utf8_string(s); } // Incoming string is array of bytes representing valid utf8 chars // Result is a string containing the compressed bytes public static function decode( s : String ) : String { return untyped __global__.__hxcpp_utf8_string_to_char_bytes(s); } public static function iter( s : String, chars : Int -> Void ) : Void { var array:Array = untyped __global__.__hxcpp_utf8_string_to_char_array(s); for(a in array) chars(a); } public static function charCodeAt( s : String, index : Int ) : Int { var array:Array = untyped __global__.__hxcpp_utf8_string_to_char_array(s); return array[index]; } public static function validate( s : String ) : Bool { try { untyped __global__.__hxcpp_utf8_string_to_char_array(s); return true; } catch(e:Dynamic) { } return false; } public static function length( s : String ) : Int { var array:Array = untyped __global__.__hxcpp_utf8_string_to_char_array(s); return array.length; } public static function compare( a : String, b : String ) : Int { var a_:Array = untyped __global__.__hxcpp_utf8_string_to_char_array(a); var b_:Array = untyped __global__.__hxcpp_utf8_string_to_char_array(b); var min = a_.length < b_.length ? a_.length : b_.length; for(i in 0...min) { if (a_[i] < b_[i]) return -1; if (a_[i] > b_[i]) return 1; } return a_.length==b_.length ? 0 : a_.length = untyped __global__.__hxcpp_utf8_string_to_char_array(s); var last = len < 0 ? array.length : pos+len; if (last>array.length) last = array.length; var sub = array.slice(pos,last); return untyped __global__.__hxcpp_char_array_to_utf8_string(sub); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/ds/IntMap.hx0000664000175000017500000000674012607337712021724 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; @:headerClassCode(" inline void set(int key, ::null value) { __int_hash_set(h,key,value); } inline void set(int key, bool value) { __int_hash_set(h,key,value); } inline void set(int key, char value) { __int_hash_set_int(h,key,value); } inline void set(int key, unsigned char value) { __int_hash_set_int(h,key,value); } inline void set(int key, signed char value) { __int_hash_set_int(h,key,value); } inline void set(int key, short value) { __int_hash_set_int(h,key,value); } inline void set(int key, unsigned short value) { __int_hash_set_int(h,key,value); } inline void set(int key, int value) { __int_hash_set_int(h,key,value); } inline void set(int key, unsigned int value) { __int_hash_set_int(h,key,value); } inline void set(int key, float value) { __int_hash_set_float(h,key,value); } inline void set(int key, double value) { __int_hash_set_float(h,key,value); } inline void set(int key, ::String value) { __int_hash_set_string(h,key,value); } template inline void set(int key, const ::cpp::Struct &value) {__int_hash_set(h,key,value); } template inline void set(int key, const ::cpp::Function &value) {__int_hash_set(h,key,value); } template inline void set(int key, const ::cpp::Pointer &value) {__int_hash_set(h,key,(Dynamic)value ); } template inline Void set(Dynamic &key, const VALUE &value) { set( (int)key, value ); return null(); } ") @:coreApi class IntMap implements haxe.Constraints.IMap { @:ifFeature("haxe.ds.IntMap.*") private var h : Dynamic; public function new() : Void { } public function set( key : Int, value : T ) : Void { untyped __global__.__int_hash_set(h,key,value); } public function get( key : Int ) : Null { return untyped __global__.__int_hash_get(h,key); } public function exists( key : Int ) : Bool { return untyped __global__.__int_hash_exists(h,key); } public function remove( key : Int ) : Bool { return untyped __global__.__int_hash_remove(h,key); } public function keys() : Iterator { var a:Array = untyped __global__.__int_hash_keys(h); return a.iterator(); } public function iterator() : Iterator { var a:Array = untyped __global__.__int_hash_values(h); return a.iterator(); } public function toString() : String { return untyped __global__.__int_hash_to_string(h); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/ds/ObjectMap.hx0000664000175000017500000000671012607337712022375 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; @:headerClassCode(" inline void set(Dynamic key, ::null value) { __object_hash_set(h,key,value); } inline void set(Dynamic key, bool value) { __object_hash_set(h,key,value); } inline void set(Dynamic key, char value) { __object_hash_set_int(h,key,value); } inline void set(Dynamic key, unsigned char value) { __object_hash_set_int(h,key,value); } inline void set(Dynamic key, signed char value) { __object_hash_set_int(h,key,value); } inline void set(Dynamic key, short value) { __object_hash_set_int(h,key,value); } inline void set(Dynamic key, unsigned short value) { __object_hash_set_int(h,key,value); } inline void set(Dynamic key, int value) { __object_hash_set_int(h,key,value); } inline void set(Dynamic key, unsigned int value) { __object_hash_set_int(h,key,value); } inline void set(Dynamic key, float value) { __object_hash_set_float(h,key,value); } inline void set(Dynamic key, double value) { __object_hash_set_float(h,key,value); } inline void set(Dynamic key, ::String value) { __object_hash_set_string(h,key,value); } template inline void set(Dynamic key, const ::cpp::Struct &value) {__object_hash_set(h,key,value); } template inline void set(Dynamic key, const ::cpp::Function &value) {__object_hash_set(h,key,(Dynamic)value ); } template inline void set(Dynamic key, const ::cpp::Pointer &value) {__object_hash_set(h,key,(Dynamic)value ); } ") @:coreApi class ObjectMap implements haxe.Constraints.IMap { private var h : Dynamic; public function new() : Void { } public function set( key : K, value : V ) : Void { untyped __global__.__object_hash_set(h,key,value); } public function get( key : K ) : Null { return untyped __global__.__object_hash_get(h,key); } public function exists( key : K ) : Bool { return untyped __global__.__object_hash_exists(h,key); } public function remove( key : K ) : Bool { return untyped __global__.__object_hash_remove(h,key); } public function keys() : Iterator { var a:Array = untyped __global__.__object_hash_keys(h); return a.iterator(); } public function iterator() : Iterator { var a:Array = untyped __global__.__object_hash_values(h); return a.iterator(); } public function toString() : String { return untyped __global__.__object_hash_to_string(h); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/ds/StringMap.hx0000664000175000017500000000716712607337712022444 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; @:headerClassCode(" inline void set(String key, ::null value) { __string_hash_set(h,key,value); } inline void set(String key, bool value) { __string_hash_set(h,key,value); } inline void set(String key, char value) { __string_hash_set_int(h,key,value); } inline void set(String key, unsigned char value) { __string_hash_set_int(h,key,value); } inline void set(String key, signed char value) { __string_hash_set_int(h,key,value); } inline void set(String key, short value) { __string_hash_set_int(h,key,value); } inline void set(String key, unsigned short value) { __string_hash_set_int(h,key,value); } inline void set(String key, int value) { __string_hash_set_int(h,key,value); } inline void set(String key, unsigned int value) { __string_hash_set_int(h,key,value); } inline void set(String key, float value) { __string_hash_set_float(h,key,value); } inline void set(String key, double value) { __string_hash_set_float(h,key,value); } inline void set(String key, ::String value) { __string_hash_set_string(h,key,value); } template inline void set(String key, const ::cpp::Struct &value) {__string_hash_set(h,key,value); } template inline void set(String key, const ::cpp::Function &value) {__string_hash_set(h,key,(Dynamic)value ); } template inline void set(String key, const ::cpp::Pointer &value) {__string_hash_set(h,key,(Dynamic)value ); } template inline Void set(Dynamic &key, const VALUE &value) { set( (String)key, value ); return null(); } ") @:coreApi class StringMap implements haxe.Constraints.IMap { @:ifFeature("haxe.ds.StringMap.*") private var h : Dynamic; public function new() : Void { } public function set( key : String, value : T ) : Void { untyped __global__.__string_hash_set(h,key,value); } public function get( key : String ) : Null { return untyped __global__.__string_hash_get(h,key); } public function exists( key : String ) : Bool { return untyped __global__.__string_hash_exists(h,key); } public function remove( key : String ) : Bool { return untyped __global__.__string_hash_remove(h,key); } public function keys() : Iterator { var a:Array = untyped __global__.__string_hash_keys(h); return a.iterator(); } public function iterator() : Iterator { var a:Array = untyped __global__.__string_hash_values(h); return a.iterator(); } public function toString() : String { return untyped __global__.__string_hash_to_string(h); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/ds/WeakMap.hx0000664000175000017500000000702412607337712022055 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; @:headerClassCode(" inline void set(Dynamic key, ::null value) { __object_hash_set(h,key,value,true); } inline void set(Dynamic key, bool value) { __object_hash_set(h,key,value,true); } inline void set(Dynamic key, char value) { __object_hash_set_int(h,key,value,true); } inline void set(Dynamic key, unsigned char value) { __object_hash_set_int(h,key,value,true); } inline void set(Dynamic key, signed char value) { __object_hash_set_int(h,key,value,true); } inline void set(Dynamic key, short value) { __object_hash_set_int(h,key,value,true); } inline void set(Dynamic key, unsigned short value) { __object_hash_set_int(h,key,value,true); } inline void set(Dynamic key, int value) { __object_hash_set_int(h,key,value,true); } inline void set(Dynamic key, unsigned int value) { __object_hash_set_int(h,key,value,true); } inline void set(Dynamic key, float value) { __object_hash_set_float(h,key,value,true); } inline void set(Dynamic key, double value) { __object_hash_set_float(h,key,value,true); } inline void set(Dynamic key, ::String value) { __object_hash_set_string(h,key,value,true); } template inline void set(Dynamic key, const ::cpp::Struct &value) {__object_hash_set(h,key,value,true); } template inline void set(Dynamic key, const ::cpp::Pointer &value) {__object_hash_set(h,key,(Dynamic)value,true ); } template inline void set(Dynamic key, const ::cpp::Function &value) {__object_hash_set(h,key,(Dynamic)value,true ); } ") @:coreApi class WeakMap implements haxe.Constraints.IMap { private var h : Dynamic; public function new() : Void { } public function set( key : K, value : V ) : Void { untyped __global__.__object_hash_set(h,key,value,true); } public function get( key : K ) : Null { return untyped __global__.__object_hash_get(h,key); } public function exists( key : K ) : Bool { return untyped __global__.__object_hash_exists(h,key); } public function remove( key : K ) : Bool { return untyped __global__.__object_hash_remove(h,key); } public function keys() : Iterator { var a:Array = untyped __global__.__object_hash_keys(h); return a.iterator(); } public function iterator() : Iterator { var a:Array = untyped __global__.__object_hash_values(h); return a.iterator(); } public function toString() : String { return untyped __global__.__object_hash_to_string(h); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/zip/Compress.hx0000664000175000017500000000444412607337712022522 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; @:coreApi class Compress { var s : Dynamic; public function new( level : Int ) : Void { s = _deflate_init(level); } public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } { return _deflate_buffer(s,src.getData(),srcPos,dst.getData(),dstPos); } public function setFlushMode( f : FlushMode ) : Void { _set_flush_mode(s,Std.string(f)); } public function close() : Void { _deflate_end(s); } public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes { var c = new Compress(level); c.setFlushMode(FlushMode.FINISH); var out = haxe.io.Bytes.alloc(_deflate_bound(c.s,s.length)); var r = c.execute(s,0,out,0); c.close(); if( !r.done || r.read != s.length ) throw "Compression failed"; return out.sub(0,r.write); } static var _deflate_init = cpp.Lib.load("zlib","deflate_init",1); static var _deflate_bound = cpp.Lib.load("zlib","deflate_bound",2); static var _deflate_buffer = cpp.Lib.load("zlib","deflate_buffer",5); static var _deflate_end = cpp.Lib.load("zlib","deflate_end",1); static var _set_flush_mode = cpp.Lib.load("zlib","set_flush_mode",2); } haxe_3.2.1+dfsg.orig/std/cpp/_std/haxe/zip/Uncompress.hx0000664000175000017500000000453712607337712023070 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; @:coreApi class Uncompress { var s : Dynamic; public function new( ?windowBits : Int ) : Void { s = _inflate_init(windowBits); } public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } { return _inflate_buffer(s,src.getData(),srcPos,dst.getData(),dstPos); } public function setFlushMode( f : FlushMode ) : Void { _set_flush_mode(s,untyped f.__Tag()); } public function close() : Void { _inflate_end(s); } public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes { var u = new Uncompress(null); if( bufsize == null ) bufsize = 1 << 16; // 64K var tmp = haxe.io.Bytes.alloc(bufsize); var b = new haxe.io.BytesBuffer(); var pos = 0; u.setFlushMode(FlushMode.SYNC); while( true ) { var r = u.execute(src,pos,tmp,0); b.addBytes(tmp,0,r.write); pos += r.read; if( r.done ) break; } u.close(); return b.getBytes(); } static var _inflate_init = cpp.Lib.load("zlib","inflate_init",1); static var _inflate_buffer = cpp.Lib.load("zlib","inflate_buffer",5); static var _inflate_end = cpp.Lib.load("zlib","inflate_end",1); static var _set_flush_mode = cpp.Lib.load("zlib","set_flush_mode",2); } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/FileSystem.hx0000664000175000017500000000775612607337712022113 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys; private enum FileKind { kdir; kfile; kother( k : String ); } @:coreApi class FileSystem { public static function exists( path : String ) : Bool { return sys_exists(haxe.io.Path.removeTrailingSlashes(path)); } public static function rename( path : String, newPath : String ) : Void { if (sys_rename(path,newPath)==null) throw "Could not rename:" + path + " to " + newPath; } public static function stat( path : String ) : FileStat { var s : FileStat = sys_stat(path); if (s==null) return { gid:0, uid:0, atime:Date.fromTime(0), mtime:Date.fromTime(0), ctime:Date.fromTime(0), dev:0, ino:0, nlink:0, rdev:0, size:0, mode:0 }; s.atime = Date.fromTime(1000.0*(untyped s.atime)); s.mtime = Date.fromTime(1000.0*(untyped s.mtime)); s.ctime = Date.fromTime(1000.0*(untyped s.ctime)); return s; } public static function fullPath( relPath : String ) : String { return new String(file_full_path(relPath)); } public static function absolutePath ( relPath : String ) : String { if (haxe.io.Path.isAbsolute(relPath)) return relPath; return haxe.io.Path.join([Sys.getCwd(), relPath]); } static function kind( path : String ) : FileKind { var k:String = sys_file_type(haxe.io.Path.removeTrailingSlashes(path)); return switch(k) { case "file": kfile; case "dir": kdir; default: kother(k); } } public static function isDirectory( path : String ) : Bool { return kind(path) == kdir; } public static function createDirectory( path : String ) : Void { var path = haxe.io.Path.addTrailingSlash(path); var _p = null; var parts = []; while (path != (_p = haxe.io.Path.directory(path))) { parts.unshift(path); path = _p; } for (part in parts) { if (part.charCodeAt(part.length - 1) != ":".code && !exists(part) && sys_create_dir( part, 493 )==null) throw "Could not create directory:" + part; } } public static function deleteFile( path : String ) : Void { if (file_delete(path)==null) throw "Could not delete file:" + path; } public static function deleteDirectory( path : String ) : Void { if (sys_remove_dir(path)==null) throw "Could not delete directory:" + path; } public static function readDirectory( path : String ) : Array { return sys_read_dir(path); } private static var sys_exists = cpp.Lib.load("std","sys_exists",1); private static var file_delete = cpp.Lib.load("std","file_delete",1); private static var sys_rename = cpp.Lib.load("std","sys_rename",2); private static var sys_stat = cpp.Lib.load("std","sys_stat",1); private static var sys_file_type = cpp.Lib.load("std","sys_file_type",1); private static var sys_create_dir = cpp.Lib.load("std","sys_create_dir",2); private static var sys_remove_dir = cpp.Lib.load("std","sys_remove_dir",1); private static var sys_read_dir = cpp.Lib.load("std","sys_read_dir",1); private static var file_full_path = cpp.Lib.load("std","file_full_path",1); } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/db/Mysql.hx0000664000175000017500000001205512607337712021505 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.db; private class D { static function load(fun,args) : Dynamic { return cpp.Lib.load(lib,fun,args); } static var lib = "mysql5"; public static var connect = load("mysql_connect",1); public static var select_db = load("select_db",2); public static var request = load("request",2); public static var close = load("close",1); public static var escape = load("escape", 2); public static var set_conv_funs = load("set_conv_funs", 4); public static var result_get_length = load("result_get_length",1); public static var result_get_nfields = load("result_get_nfields",1); public static var result_next = load("result_next",1); public static var result_get = load("result_get",2); public static var result_get_int = load("result_get_int",2); public static var result_get_float = load("result_get_float",2); public static var result_fields_names = cpp.Lib.loadLazy(lib,"result_get_fields_names",1); } private class MysqlResultSet implements sys.db.ResultSet { public var length(get,null) : Int; public var nfields(get,null) : Int; private var __r : Dynamic; private var cache : Dynamic; public function new(r) { __r = r; } private function get_length() { return D.result_get_length(__r); } private function get_nfields() { return D.result_get_nfields(__r); } public function hasNext() { if( cache == null ) cache = next(); return (cache != null); } public function next() : Dynamic { var c = cache; if( c != null ) { cache = null; return c; } c = D.result_next(__r); return c; } public function results() : List { var l = new List(); while( hasNext() ) l.add(next()); return l; } public function getResult( n : Int ) { return new String(D.result_get(__r,n)); } public function getIntResult( n : Int ) : Int { return D.result_get_int(__r,n); } public function getFloatResult( n : Int ) : Float { return D.result_get_float(__r,n); } public function getFieldsNames() : Array { var a = D.result_fields_names(__r); return a; } } private class MysqlConnection implements sys.db.Connection { private var __c : Dynamic; public function new(c) { __c = c; D.set_conv_funs(c, function(s) return new String(s), function(d) return untyped Date.new1(d), function(b) return haxe.io.Bytes.ofData(b)); } public function request( s : String ) : sys.db.ResultSet { var r = D.request(this.__c, s); return new MysqlResultSet(r); } public function close() { D.close(__c); } public function escape( s : String ) { return new String(D.escape(__c,s)); } public function quote( s : String ) { return "'"+escape(s)+"'"; } public function addValue( s : StringBuf, v : Dynamic ) { if (v == null) { s.add(v); } else if (Std.is(v,Bool)) { s.add( v ? 1 : 0 ); } else { var t:Int = untyped v.__GetType(); if( t == 0xff ) s.add(v); else if( t == 2 ) s.add( untyped v.__GetInt() ? "1".code : "0".code ); else { s.addChar("'".code); s.add(escape(Std.string(v))); s.addChar("'".code); } } } public function lastInsertId() { return request("SELECT LAST_INSERT_ID()").getIntResult(0); } public function dbName() { return "MySQL"; } public function startTransaction() { request("START TRANSACTION"); } public function commit() { request("COMMIT"); } public function rollback() { request("ROLLBACK"); } private static var __use_date = Date; } @:coreApi class Mysql { public static function connect( params : { host : String, ?port : Int, user : String, pass : String, ?socket : String, database : String } ) : sys.db.Connection { var o = { host : params.host, port : if( params.port == null ) 3306 else params.port, user : params.user, pass : params.pass, socket : if( params.socket == null ) null else params.socket }; var c = D.connect(o); try { D.select_db(c,params.database); } catch( e : Dynamic ) { D.close(c); cpp.Lib.rethrow(e); } return new MysqlConnection(c); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/db/Sqlite.hx0000664000175000017500000001106012607337712021634 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.db; private class SqliteConnection implements Connection { var c : Dynamic; public function new( file : String ) { c = _connect(file); } public function close() { _close(c); } public function request( s : String ) : ResultSet { try { return new SqliteResultSet(_request(c,s)); } catch( e : String ) { throw "Error while executing "+s+" ("+e+")"; } } public function escape( s : String ) { return s.split("'").join("''"); } public function quote( s : String ) { if( s.indexOf("\000") >= 0 ) return "x'"+new String(_encode(s,"0123456789ABCDEF"))+"'"; return "'"+s.split("'").join("''")+"'"; } public function addValue( s : StringBuf, v : Dynamic ) { if (v == null) { s.add(v); } else if (Std.is(v,Bool)) { s.add( v ? 1 : 0 ); } else { var t:Int = untyped v.__GetType(); if( t == 0xff ) s.add(v); else if( t == 2 ) s.add( untyped v.__GetInt() ); else s.add(quote(Std.string(v))); } } public function lastInsertId() { return _last_id(c); } public function dbName() { return "SQLite"; } public function startTransaction() { request("BEGIN TRANSACTION"); } public function commit() { request("COMMIT"); startTransaction(); // match mysql usage } public function rollback() { request("ROLLBACK"); startTransaction(); // match mysql usage } static var _encode = cpp.Lib.load("std","base_encode",2); static var _connect = cpp.Lib.load("sqlite","sqlite_connect",1); static var _close = cpp.Lib.load("sqlite","close",1); static var _request = cpp.Lib.load("sqlite","request",2); static var _last_id = cpp.Lib.load("sqlite","last_insert_id",1); } private class SqliteResultSet implements ResultSet { public var length(get,null) : Int; public var nfields(get,null) : Int; var r : Dynamic; var cache : List; public function new( r ) { cache = new List(); this.r = r; hasNext(); // execute the request } function get_length() { if( nfields != 0 ) { while( true ) { var c = result_next(r); if( c == null ) break; cache.add(c); } return cache.length; } return result_get_length(r); } function get_nfields() { return result_get_nfields(r); } public function hasNext() { var c = next(); if( c == null ) return false; cache.push(c); return true; } public function next() : Dynamic { var c = cache.pop(); if( c != null ) return c; return result_next(r); } public function results() : List { var l = new List(); while( true ) { var c = next(); if( c == null ) break; l.add(c); } return l; } public function getResult( n : Int ) { return new String(result_get(r,n)); } public function getIntResult( n : Int ) : Int { return result_get_int(r,n); } public function getFloatResult( n : Int ) : Float { return result_get_float(r,n); } public function getFieldsNames() : Array { return null; } static var result_next = cpp.Lib.load("sqlite","result_next",1); static var result_get_length = cpp.Lib.load("sqlite","result_get_length",1); static var result_get_nfields = cpp.Lib.load("sqlite","result_get_nfields",1); static var result_get = cpp.Lib.load("sqlite","result_get",2); static var result_get_int = cpp.Lib.load("sqlite","result_get_int",2); static var result_get_float = cpp.Lib.load("sqlite","result_get_float",2); } @:coreApi class Sqlite { public static function open( file : String ) : Connection { return new SqliteConnection(file); } } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/io/File.hx0000664000175000017500000000500012607337712021271 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; @:coreApi class File { public static function getContent( path : String ) : String { var b = getBytes(path); return b.toString(); } public static function getBytes( path : String ) : haxe.io.Bytes { var data:haxe.io.BytesData = file_contents(path); return haxe.io.Bytes.ofData(data); } public static function saveContent( path : String, content : String ) : Void { var f = write(path); f.writeString(content); f.close(); } public static function saveBytes( path : String, bytes : haxe.io.Bytes ) : Void { var f = write(path); f.write(bytes); f.close(); } public static function read( path : String, binary : Bool = true ) : FileInput { return untyped new FileInput(file_open(path,(if( binary ) "rb" else "r"))); } public static function write( path : String, binary : Bool = true ) : FileOutput { return untyped new FileOutput(file_open(path,(if( binary ) "wb" else "w"))); } public static function append( path : String, binary : Bool = true ) : FileOutput { return untyped new FileOutput(file_open(path,(if( binary ) "ab" else "a"))); } public static function copy( srcPath : String, dstPath : String ) : Void { var s = read(srcPath,true); var d = write(dstPath,true); d.writeInput(s); s.close(); d.close(); } private static var file_contents = cpp.Lib.load("std","file_contents",1); private static var file_open = cpp.Lib.load("std","file_open",2); } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/io/FileInput.hx0000664000175000017500000000474712607337712022332 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; import sys.io.FileSeek; @:coreApi class FileInput extends haxe.io.Input { private var __f : Dynamic; function new(f:Dynamic) : Void { __f = f; } public override function readByte() : Int { return try { file_read_char(__f); } catch( e : Dynamic ) { if( untyped e.__IsArray() ) throw new haxe.io.Eof(); else throw haxe.io.Error.Custom(e); } } public override function readBytes( s : haxe.io.Bytes, p : Int, l : Int ) : Int { return try { file_read(__f,s.getData(),p,l); } catch( e : Dynamic ) { if( untyped e.__IsArray() ) throw new haxe.io.Eof(); else throw haxe.io.Error.Custom(e); } } public override function close() : Void { super.close(); file_close(__f); } public function seek( p : Int, pos : FileSeek ) : Void { file_seek(__f,p,pos==SeekBegin ? 0 : pos==SeekCur ? 1 : 2 ); } public function tell() : Int { return file_tell(__f); } public function eof() : Bool { return file_eof(__f); } private static var file_eof = cpp.Lib.load("std","file_eof",1); private static var file_read = cpp.Lib.load("std","file_read",4); private static var file_read_char = cpp.Lib.load("std","file_read_char",1); private static var file_close = cpp.Lib.load("std","file_close",1); private static var file_seek = cpp.Lib.load("std","file_seek",3); private static var file_tell = cpp.Lib.load("std","file_tell",1); } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/io/FileOutput.hx0000664000175000017500000000452212607337712022522 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; import sys.io.FileSeek; @:coreApi class FileOutput extends haxe.io.Output { private var __f : Dynamic; function new(f:Dynamic) : Void { __f = f; } public override function writeByte( c : Int ) : Void { try file_write_char(__f,c) catch( e : Dynamic ) throw haxe.io.Error.Custom(e); } public override function writeBytes( s : haxe.io.Bytes, p : Int, l : Int ) : Int { return try file_write(__f,s.getData(),p,l) catch( e : Dynamic ) throw haxe.io.Error.Custom(e); } public override function flush() : Void { file_flush(__f); } public override function close() : Void { super.close(); file_close(__f); } public function seek( p : Int, pos : FileSeek ) : Void { file_seek(__f,p, pos == SeekBegin ? 0 : pos == SeekCur ? 1 : 2); } public function tell() : Int { return file_tell(__f); } private static var file_close = cpp.Lib.load("std","file_close",1); private static var file_seek = cpp.Lib.load("std","file_seek",3); private static var file_tell = cpp.Lib.load("std","file_tell",1); private static var file_flush = cpp.Lib.load("std","file_flush",1); private static var file_write = cpp.Lib.load("std","file_write",4); private static var file_write_char = cpp.Lib.load("std","file_write_char",2); } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/io/Process.hx0000664000175000017500000000671712607337712022050 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; private class Stdin extends haxe.io.Output { var p : Dynamic; var buf : haxe.io.Bytes; public function new(p) { this.p = p; buf = haxe.io.Bytes.alloc(1); } public override function close() { super.close(); _stdin_close(p); } public override function writeByte(c) { buf.set(0,c); writeBytes(buf,0,1); } public override function writeBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) : Int { try { return _stdin_write(p,buf.getData(),pos,len); } catch( e : Dynamic ) { throw new haxe.io.Eof(); } return 0; } static var _stdin_write = cpp.Lib.load("std","process_stdin_write",4); static var _stdin_close = cpp.Lib.load("std","process_stdin_close",1); } private class Stdout extends haxe.io.Input { var p : Dynamic; var out : Bool; var buf : haxe.io.Bytes; public function new(p,out) { this.p = p; this.out = out; buf = haxe.io.Bytes.alloc(1); } public override function readByte() { if( readBytes(buf,0,1) == 0 ) throw haxe.io.Error.Blocked; return buf.get(0); } public override function readBytes( str : haxe.io.Bytes, pos : Int, len : Int ) : Int { var result:Int; try { result = (out?_stdout_read:_stderr_read)(p,str.getData(),pos,len); } catch( e : Dynamic ) { throw new haxe.io.Eof(); } if (result==0)throw new haxe.io.Eof(); return result; } static var _stdout_read = cpp.Lib.load("std","process_stdout_read",4); static var _stderr_read = cpp.Lib.load("std","process_stderr_read",4); } @:coreApi class Process { var p : Dynamic; public var stdout(default,null) : haxe.io.Input; public var stderr(default,null) : haxe.io.Input; public var stdin(default,null) : haxe.io.Output; public function new( cmd : String, args : Array ) : Void { p = try _run(cmd,args) catch( e : Dynamic ) throw "Process creation failure : "+cmd; stdin = new Stdin(p); stdout = new Stdout(p,true); stderr = new Stdout(p,false); } public function getPid() : Int { return _pid(p); } public function exitCode() : Int { return _exit(p); } public function close() : Void { _close(p); } public function kill() : Void { throw "Not implemented"; } static var _run = cpp.Lib.load("std","process_run",2); static var _exit = cpp.Lib.load("std","process_exit",1); static var _pid = cpp.Lib.load("std","process_pid",1); static var _close = cpp.Lib.loadLazy("std","process_close",1); } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/net/Host.hx0000664000175000017500000000356512607337712021524 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.net; @:coreApi class Host { public var ip(default,null) : Int; public function new( name : String ) : Void { ip = host_resolve(name); } public function toString() : String { return new String(host_to_string(ip)); } public function reverse() : String { return new String(host_reverse(ip)); } public static function localhost() : String { return new String(host_local()); } static function __init__() : Void { cpp.Lib.load("std","socket_init",0)(); } private static var host_resolve = cpp.Lib.load("std","host_resolve",1); private static var host_reverse = cpp.Lib.load("std","host_reverse",1); private static var host_to_string = cpp.Lib.load("std","host_to_string",1); private static var host_local = cpp.Lib.load("std","host_local",0); } haxe_3.2.1+dfsg.orig/std/cpp/_std/sys/net/Socket.hx0000664000175000017500000001551312607337712022033 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.net; import haxe.io.Error; private class SocketInput extends haxe.io.Input { var __s : Dynamic; public function new(s) { __s = s; } public override function readByte() { return try { socket_recv_char(__s); } catch( e : Dynamic ) { if( e == "Blocking" ) throw Blocked; else if( __s == null ) throw Custom(e); else throw new haxe.io.Eof(); } } public override function readBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) : Int { var r; if (__s==null) throw "Invalid handle"; try { r = socket_recv(__s,buf.getData(),pos,len); } catch( e : Dynamic ) { if( e == "Blocking" ) throw Blocked; else throw Custom(e); } if( r == 0 ) throw new haxe.io.Eof(); return r; } public override function close() { super.close(); if( __s != null ) socket_close(__s); } private static var socket_recv = cpp.Lib.load("std","socket_recv",4); private static var socket_recv_char = cpp.Lib.load("std","socket_recv_char",1); private static var socket_close = cpp.Lib.load("std","socket_close",1); } private class SocketOutput extends haxe.io.Output { var __s : Dynamic; public function new(s) { __s = s; } public override function writeByte( c : Int ) { if (__s==null) throw "Invalid handle"; try { socket_send_char(__s, c); } catch( e : Dynamic ) { if( e == "Blocking" ) throw Blocked; else throw Custom(e); } } public override function writeBytes( buf : haxe.io.Bytes, pos : Int, len : Int) : Int { return try { socket_send(__s, buf.getData(), pos, len); } catch( e : Dynamic ) { if( e == "Blocking" ) throw Blocked; else throw Custom(e); } } public override function close() { super.close(); if( __s != null ) socket_close(__s); } private static var socket_close = cpp.Lib.load("std","socket_close",1); private static var socket_send_char = cpp.Lib.load("std","socket_send_char",2); private static var socket_send = cpp.Lib.load("std","socket_send",4); } @:coreApi class Socket { private var __s : Dynamic; public var input(default,null) : haxe.io.Input; public var output(default,null) : haxe.io.Output; public var custom : Dynamic; public function new() : Void { __s = socket_new(false); input = new SocketInput(__s); output = new SocketOutput(__s); } public function close() : Void { socket_close(__s); untyped { var input : SocketInput = cast input; var output : SocketOutput = cast output; input.__s = null; output.__s = null; } input.close(); output.close(); } public function read() : String { var bytes:haxe.io.BytesData = socket_read(__s); if (bytes==null) return ""; return bytes.toString(); } public function write( content : String ) : Void { socket_write(__s, haxe.io.Bytes.ofString(content).getData() ); } public function connect(host : Host, port : Int) : Void { try { socket_connect(__s, host.ip, port); } catch( s : String ) { if( s == "std@socket_connect" ) throw "Failed to connect on "+host.toString()+":"+port; else cpp.Lib.rethrow(s); } } public function listen(connections : Int) : Void { socket_listen(__s, connections); } public function shutdown( read : Bool, write : Bool ) : Void { socket_shutdown(__s,read,write); } public function bind(host : Host, port : Int) : Void { socket_bind(__s, host.ip, port); } public function accept() : Socket { var c = socket_accept(__s); var s = Type.createEmptyInstance(Socket); s.__s = c; s.input = new SocketInput(c); s.output = new SocketOutput(c); return s; } public function peer() : { host : Host, port : Int } { var a : Dynamic = socket_peer(__s); var h = new Host("127.0.0.1"); untyped h.ip = a[0]; return { host : h, port : a[1] }; } public function host() : { host : Host, port : Int } { var a : Dynamic = socket_host(__s); var h = new Host("127.0.0.1"); untyped h.ip = a[0]; return { host : h, port : a[1] }; } public function setTimeout( timeout : Float ) : Void { socket_set_timeout(__s, timeout); } public function waitForRead() : Void { select([this],null,null,null); } public function setBlocking( b : Bool ) : Void { socket_set_blocking(__s,b); } public function setFastSend( b : Bool ) : Void { socket_set_fast_send(__s,b); } public static function select(read : Array, write : Array, others : Array, ?timeout : Float ) : {read: Array,write: Array,others: Array} { var neko_array = socket_select(read,write,others, timeout); if (neko_array==null) throw "Select error"; return { read: neko_array[0], write: neko_array[1], others: neko_array[2] }; } private static var socket_new = cpp.Lib.load("std","socket_new",1); private static var socket_close = cpp.Lib.load("std","socket_close",1); private static var socket_write = cpp.Lib.load("std","socket_write",2); private static var socket_read = cpp.Lib.load("std","socket_read",1); private static var socket_connect = cpp.Lib.load("std","socket_connect",3); private static var socket_listen = cpp.Lib.load("std","socket_listen",2); private static var socket_select = cpp.Lib.load("std","socket_select",4); private static var socket_bind = cpp.Lib.load("std","socket_bind",3); private static var socket_accept = cpp.Lib.load("std","socket_accept",1); private static var socket_peer = cpp.Lib.load("std","socket_peer",1); private static var socket_host = cpp.Lib.load("std","socket_host",1); private static var socket_set_timeout = cpp.Lib.load("std","socket_set_timeout",2); private static var socket_shutdown = cpp.Lib.load("std","socket_shutdown",3); private static var socket_set_blocking = cpp.Lib.load("std","socket_set_blocking",2); private static var socket_set_fast_send = cpp.Lib.loadLazy("std","socket_set_fast_send",2); } haxe_3.2.1+dfsg.orig/std/cpp/abi/Abi.hx0000664000175000017500000000014312607337712017465 0ustar andyandy00000000000000package cpp.abi; // Base case, for calling conventions - means "use default" extern class Abi { } haxe_3.2.1+dfsg.orig/std/cpp/abi/CDecl.hx0000664000175000017500000000010612607337712017743 0ustar andyandy00000000000000package cpp.abi; @:abi("__cdecl") extern class CDecl extends Abi { } haxe_3.2.1+dfsg.orig/std/cpp/abi/FastCall.hx0000664000175000017500000000011412607337712020461 0ustar andyandy00000000000000package cpp.abi; @:abi("__fastcall") extern class FastCall extends Abi { } haxe_3.2.1+dfsg.orig/std/cpp/abi/StdCall.hx0000664000175000017500000000011212607337712020314 0ustar andyandy00000000000000package cpp.abi; @:abi("__stdcall") extern class StdCall extends Abi { } haxe_3.2.1+dfsg.orig/std/cpp/abi/ThisCall.hx0000664000175000017500000000011412607337712020473 0ustar andyandy00000000000000package cpp.abi; @:abi("__thiscall") extern class ThisCall extends Abi { } haxe_3.2.1+dfsg.orig/std/cpp/abi/Winapi.hx0000664000175000017500000000011112607337712020214 0ustar andyandy00000000000000package cpp.abi; @:abi("__stdcall") extern class Winapi extends Abi { } haxe_3.2.1+dfsg.orig/std/cpp/cppia/Host.hx0000664000175000017500000000106112607337712020250 0ustar andyandy00000000000000package cpp.cppia; @:build(cpp.cppia.HostClasses.include()) class Host { public static function run(source:String) { untyped __global__.__scriptable_load_cppia(source); } public static function main() { var script = Sys.args()[0]; #if (!scriptable && !doc_gen) #error "Please define scriptable to use cppia" #end if (script==null) { Sys.println("Usage : Cppia scriptname"); } else { var source = sys.io.File.getContent(script); run(source); } } } haxe_3.2.1+dfsg.orig/std/cpp/cppia/HostClasses.hx0000664000175000017500000001200312607337712021564 0ustar andyandy00000000000000package cpp.cppia; import haxe.macro.Compiler; import haxe.macro.Context; import haxe.macro.Type; #if !macro #if cppia @:build(cpp.cppia.HostClasses.exclude()) #end class HostClasses { } #else import Sys; import haxe.Constraints; @:noPackageRestrict class HostClasses { static var classes = [ "cpp.Lib", "cpp.NativeArray", "cpp.NativeString", "cpp.vm.Debugger", "cpp.vm.Deque", "cpp.vm.ExecutionTrace", "cpp.vm.Gc", "cpp.vm.Lock", "cpp.vm.Mutex", "cpp.vm.Profiler", "cpp.vm.Thread", "cpp.vm.Tls", "cpp.vm.Unsafe", "cpp.vm.WeakRef", "cpp.Object", "cpp.Int64", "Std", "StringBuf", "sys.db.Mysql", "sys.db.Sqlite", "sys.db.Object", "sys.db.Manager", "sys.db.Connection", "sys.FileSystem", "sys.io.File", "sys.io.FileInput", "sys.net.Socket", "Enum", "EnumValue", //"Sys", "Type", "Xml", "Date", "DateTools", "List", "Math", "Reflect", "StringBuf", "StringTools", "haxe.ds.IntMap", "haxe.ds.ObjectMap", "haxe.ds.StringMap", "haxe.CallStack", "haxe.Serializer", "haxe.Unserializer", "haxe.Resource", "haxe.Template", "haxe.Utf8", "haxe.Log", "haxe.zip.Uncompress", "haxe.crypto.BaseCode", "haxe.crypto.Sha256", "haxe.crypto.Hmac", "haxe.crypto.Crc32", "haxe.crypto.Base64", "haxe.crypto.Adler32", "haxe.crypto.Md5", "haxe.crypto.Sha1", "haxe.io.BufferInput", "haxe.io.Bytes", "haxe.io.BytesBuffer", "haxe.io.BytesData", "haxe.io.BytesInput", "haxe.io.BytesOutput", "haxe.io.Eof", "haxe.io.Error", "haxe.io.FPHelper", "haxe.io.Input", "haxe.io.Output", "haxe.io.Path", "haxe.io.StringInput", "haxe.xml.Parser", "haxe.Json", "haxe.CallStack", "haxe.Resource", "haxe.Utf8", "haxe.Int64", "haxe.Int32", "haxe.Serializer", "haxe.Unserializer", "haxe.ds.ArraySort", "haxe.ds.GenericStack", "haxe.ds.ObjectMap", "haxe.ds.Vector", "haxe.ds.BalancedTree", "haxe.ds.HashMap", "haxe.ds.Option", "haxe.ds.WeakMap", "haxe.ds.EnumValueMap", "haxe.ds.IntMap", "haxe.ds.StringMap", "StdTypes", "Array", "Class", "Date", "EReg", "Enum", "EnumValue", "IntIterator", "List", "Map", "String", ]; static function parseClassInfo(externs:Map, filename:String) { if (sys.FileSystem.exists(filename)) { var file = sys.io.File.read(filename); try { while(true) { var line = file.readLine(); var parts = line.split(" "); if (parts[0]=="class" || parts[0]=="interface" || parts[0]=="enum") externs.set(parts[1],true); } } catch( e : Dynamic ) { } if (file!=null) file.close(); } } static function onGenerateCppia(types:Array):Void { var externs = new Map(); externs.set("Sys",true); externs.set("haxe.IMap",true); externs.set("haxe.crypto.HashMethod",true); externs.set("haxe._Int64.Int64_Impl_",true); externs.set("haxe._Int64.___Int64",true); externs.set("haxe._Int32.Int32_Impl_",true); externs.set("haxe._Int32.___Int32",true); for(e in classes) externs.set(e,true); var define = Context.defined("dll_import") ? Context.definedValue("dll_import") : "1"; if (define!="1") parseClassInfo(externs,define); else { var tried = new Map(); for(path in Context.getClassPath()) if (!tried.exists(path)) { tried.set(path,true); parseClassInfo(externs,path + "/export_classes.info"); } } for(type in types) { switch(type) { case TInst(classRef, params): if (externs.exists(classRef.toString())) classRef.get().exclude(); case TEnum(enumRef, params): if (externs.exists(enumRef.toString())) enumRef.get().exclude(); default: } } } // Exclude the standard classes, and any described in 'export_classes.info' files found in the classpath public static function exclude() { if (Context.defined("cppia")) Context.onGenerate(onGenerateCppia); else Context.error("cpp.cppia.excludeHostFiles is only for cppia code", Context.currentPos()); return Context.getBuildFields(); } // Ensure that the standard classes are included in the host public static function include() { Compiler.keep("haxe.IMap"); Compiler.keep("haxe.crypto.HashMethod"); Compiler.keep("haxe._Int64.Int64_Impl_"); Compiler.keep("haxe._Int32.Int32_Impl_"); Compiler.keep("haxe._Int64.___Int64"); Compiler.keep("haxe._Int32.___Int32"); for(cls in classes) { Context.getModule(cls); Compiler.keep(cls); } return Context.getBuildFields(); } } #end haxe_3.2.1+dfsg.orig/std/cpp/link/StaticMysql.hx0000664000175000017500000000053512607337712021456 0ustar andyandy00000000000000package cpp.link; @:cppFileCode( 'extern "C" int mysql_register_prims();') @:buildXml(" ") @:keep class StaticMysql { static function __init__() { untyped __cpp__("mysql_register_prims();"); } } haxe_3.2.1+dfsg.orig/std/cpp/link/StaticRegexp.hx0000664000175000017500000000047012607337712021601 0ustar andyandy00000000000000package cpp.link; @:cppFileCode( 'extern "C" int regexp_register_prims();') @:buildXml(" ") @:keep class StaticRegexp { static function __init__() { untyped __cpp__("regexp_register_prims();"); } } haxe_3.2.1+dfsg.orig/std/cpp/link/StaticSqlite.hx0000664000175000017500000000053512607337712021612 0ustar andyandy00000000000000package cpp.link; @:cppFileCode( 'extern "C" int sqlite_register_prims();') @:buildXml(" ") @:keep class StaticSqlite { static function __init__() { untyped __cpp__("sqlite_register_prims();"); } } haxe_3.2.1+dfsg.orig/std/cpp/link/StaticStd.hx0000664000175000017500000000052512607337712021102 0ustar andyandy00000000000000package cpp.link; @:cppFileCode( 'extern "C" int std_register_prims();') @:buildXml(" ") @:keep class StaticStd { static function __init__() { untyped __cpp__("std_register_prims();"); } } haxe_3.2.1+dfsg.orig/std/cpp/link/StaticZlib.hx0000664000175000017500000000046012607337712021246 0ustar andyandy00000000000000package cpp.link; @:cppFileCode( 'extern "C" int zlib_register_prims();') @:buildXml(" ") @:keep class StaticZlib { static function __init__() { untyped __cpp__("zlib_register_prims();"); } } haxe_3.2.1+dfsg.orig/std/cpp/net/Poll.hx0000664000175000017500000000450212607337712017736 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.net; import sys.net.Socket; class Poll { var mPollHandle : Dynamic; public var readIndexes : Array; public var writeIndexes : Array; public function new( n : Int ) { mPollHandle = socket_poll_alloc(n); readIndexes = []; writeIndexes = []; } public function prepare( read : Array, write : Array ) { var k = socket_poll_prepare(mPollHandle,read,write); readIndexes = k[0]; writeIndexes = k[1]; } public function events( ?t : Float ) { if (t==null) t=-1.0; socket_poll_events(mPollHandle,t); } public function poll( a : Array, ?t : Float ) : Array { if (t==null) t=-1.0; var read:Array = socket_poll(a,mPollHandle,t); // Convert to array of sockets... var result = new Array(); if (read!=null && read.length>0) { result[read.length-1]=null; for(i in 0...read.length) result[i] = read[i]; } return result; } static var socket_poll_alloc = cpp.Lib.load("std","socket_poll_alloc",1); static var socket_poll = cpp.Lib.load("std","socket_poll",3); static var socket_poll_prepare = cpp.Lib.loadLazy("std","socket_poll_prepare",3); static var socket_poll_events = cpp.Lib.loadLazy("std","socket_poll_events",2); } haxe_3.2.1+dfsg.orig/std/cpp/net/ThreadServer.hx0000664000175000017500000002466212607337712021437 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.net; import cpp.vm.Thread; import cpp.net.Poll; import cpp.vm.Lock; private typedef ThreadInfos = { var id : Int; var t : Thread; var p : Poll; var socks : Array; } private typedef ClientInfos = { var client : Client; var sock : sys.net.Socket; var thread : ThreadInfos; var buf : haxe.io.Bytes; var bufpos : Int; } class ThreadServer { var threads : Array; var sock : sys.net.Socket; var worker : Thread; var timer : Thread; public var listen : Int; public var nthreads : Int; public var connectLag : Float; public var errorOutput : haxe.io.Output; public var initialBufferSize : Int; public var maxBufferSize : Int; public var messageHeaderSize : Int; public var updateTime : Float; public var maxSockPerThread : Int; public function new() { threads = new Array(); nthreads = if( Sys.systemName() == "Windows" ) 150 else 10; messageHeaderSize = 1; listen = 10; connectLag = 0.5; errorOutput = Sys.stderr(); initialBufferSize = (1 << 10); maxBufferSize = (1 << 16); maxSockPerThread = 64; updateTime = 1; } function runThread(t) { while( true ) { try { loopThread(t); } catch( e : Dynamic ) { logError(e); } } } function readClientData( c : ClientInfos ) { var available = c.buf.length - c.bufpos; if( available == 0 ) { var newsize = c.buf.length * 2; if( newsize > maxBufferSize ) { newsize = maxBufferSize; if( c.buf.length == maxBufferSize ) throw "Max buffer size reached"; } var newbuf = haxe.io.Bytes.alloc(newsize); newbuf.blit(0,c.buf,0,c.bufpos); c.buf = newbuf; available = newsize - c.bufpos; } var bytes = c.sock.input.readBytes(c.buf,c.bufpos,available); var pos = 0; var len = c.bufpos + bytes; while( len >= messageHeaderSize ) { var m = readClientMessage(c.client,c.buf,pos,len); if( m == null ) break; pos += m.bytes; len -= m.bytes; work(clientMessage.bind(c.client,m.msg)); } if( pos > 0 ) c.buf.blit(0,c.buf,pos,len); c.bufpos = len; } function loopThread( t : ThreadInfos ) { if( t.socks.length > 0 ) for( s in t.p.poll(t.socks,connectLag) ) { var infos : ClientInfos = s.custom; try { readClientData(infos); } catch( e : Dynamic ) { t.socks.remove(s); if( !Std.is(e,haxe.io.Eof) && !Std.is(e,haxe.io.Error) ) logError(e); work(doClientDisconnected.bind(s,infos.client)); } } while( true ) { var m : { s : sys.net.Socket, cnx : Bool } = Thread.readMessage(t.socks.length == 0); if( m == null ) break; if( m.cnx ) t.socks.push(m.s); else if( t.socks.remove(m.s) ) { var infos : ClientInfos = m.s.custom; work(doClientDisconnected.bind(m.s,infos.client)); } } } function doClientDisconnected(s,c) { try s.close() catch( e : Dynamic ) {}; clientDisconnected(c); } function runWorker() { while( true ) { var f = Thread.readMessage(true); try { f(); } catch( e : Dynamic ) { logError(e); } try { afterEvent(); } catch( e : Dynamic ) { logError(e); } } } public function work( f : Void -> Void ) { worker.sendMessage(f); } function logError( e : Dynamic ) { var stack = haxe.CallStack.exceptionStack(); if( Thread.current() == worker ) onError(e,stack); else work(onError.bind(e,stack)); } function addClient( sock : sys.net.Socket ) { var start = Std.random(nthreads); for( i in 0...nthreads ) { var t = threads[(start + i)%nthreads]; if( t.socks.length < maxSockPerThread ) { var infos : ClientInfos = { thread : t, client : clientConnected(sock), sock : sock, buf : haxe.io.Bytes.alloc(initialBufferSize), bufpos : 0, }; sock.custom = infos; infos.thread.t.sendMessage({ s : sock, cnx : true }); return; } } refuseClient(sock); } function refuseClient( sock : sys.net.Socket) { // we have reached maximum number of active clients sock.close(); } function runTimer() { var l = new Lock(); while( true ) { l.wait(updateTime); work(update); } } function init() { worker = Thread.create(runWorker); timer = Thread.create(runTimer); for( i in 0...nthreads ) { var t = { id : i, t : null, socks : new Array(), p : new Poll(maxSockPerThread), }; threads.push(t); t.t = Thread.create(runThread.bind(t)); } } public function addSocket( s : sys.net.Socket ) { s.setBlocking(false); work(addClient.bind(s)); } public function run( host, port ) { sock = new sys.net.Socket(); sock.bind(new sys.net.Host(host),port); sock.listen(listen); init(); while( true ) { try { addSocket(sock.accept()); } catch( e : Dynamic ) { logError(e); } } } public function sendData( s : sys.net.Socket, data : String ) { try { s.write(data); } catch( e : Dynamic ) { stopClient(s); } } public function stopClient( s : sys.net.Socket ) { var infos : ClientInfos = s.custom; try s.shutdown(true,true) catch( e : Dynamic ) { }; infos.thread.t.sendMessage({ s : s, cnx : false }); } // --- CUSTOMIZABLE API --- public dynamic function onError( e : Dynamic, stack ) { var estr = try Std.string(e) catch( e2 : Dynamic ) "???" + try "["+Std.string(e2)+"]" catch( e : Dynamic ) ""; errorOutput.writeString( estr + "\n" + haxe.CallStack.toString(stack) ); errorOutput.flush(); } public dynamic function clientConnected( s : sys.net.Socket ) : Client { return null; } public dynamic function clientDisconnected( c : Client ) { } public dynamic function readClientMessage( c : Client, buf : haxe.io.Bytes, pos : Int, len : Int ) : { msg : Message, bytes : Int } { return { msg : null, bytes : len, }; } public dynamic function clientMessage( c : Client, msg : Message ) { } public dynamic function update() { } public dynamic function afterEvent() { } } haxe_3.2.1+dfsg.orig/std/cpp/rtti/FieldIntegerLookup.hx0000664000175000017500000000250012607337712022753 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.rtti; /** If you implement this interface, then the backend will generate code that allows fast dynamic access to fields by integer id. This should speed up the CFFI. **/ interface FieldIntegerLookup { } haxe_3.2.1+dfsg.orig/std/cpp/rtti/FieldNumericIntegerLookup.hx0000664000175000017500000000250712607337712024305 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.rtti; /** If you implement this interface, then the backend will generate code that allows fast numeric access to fields by integer id. This should speed up the CFFI. **/ interface FieldNumericIntegerLookup { } haxe_3.2.1+dfsg.orig/std/cpp/vm/Debugger.hx0000664000175000017500000004016512607337712020415 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; /** * Parameter describes a function parameter. Instances of this class are * embedded in stack frame objects to describe the function parameters that * were used in the invocation of the function that defines that stack frame. **/ class Parameter { public var name(default, null) : String; public var value(default, null) : Dynamic; public function new(name : String, value : Dynamic) { this.name = name; this.value = value; } } /** * StackFrame describes one call stack frame. **/ class StackFrame { public var fileName(default, null) : String; public var lineNumber(default, null) : Int; public var className(default, null) : String; public var functionName(default, null) : String; public var parameters(default, null) : Array; public function new(fileName : String, lineNumber : Int, className : String, functionName : String) { this.fileName = fileName; this.lineNumber = lineNumber; this.className = className; this.functionName = functionName; this.parameters = new Array(); } } /** * ThreadInfo describes the state of a single thread. **/ class ThreadInfo { public static inline var STATUS_RUNNING = 1; public static inline var STATUS_STOPPED_BREAK_IMMEDIATE = 2; public static inline var STATUS_STOPPED_BREAKPOINT = 3; public static inline var STATUS_STOPPED_UNCAUGHT_EXCEPTION = 4; public static inline var STATUS_STOPPED_CRITICAL_ERROR = 5; // 0 is never a valid thread number public var number(default, null) : Int; public var status(default, null) : Int; // If status is "stopped breakpoint", this is the breakpoint number public var breakpoint(default, null) : Int; // If status is "critical error", this describes the error public var criticalErrorDescription(default, null) : String; // Stack will be listed with the lowest frame first public var stack(default, null) : Array; public function new(number : Int, status : Int, breakpoint : Int = -1, criticalErrorDescription : String = null) { this.number = number; this.status = status; this.breakpoint = breakpoint; this.criticalErrorDescription = criticalErrorDescription; this.stack = new Array(); } } /** * This class wraps the hxcpp C++ implementation to provide a Haxe interface * to the low level debugging features **/ class Debugger { public static inline var THREAD_CREATED = 1; public static inline var THREAD_TERMINATED = 2; public static inline var THREAD_STARTED = 3; public static inline var THREAD_STOPPED = 4; public static inline var STEP_INTO = 1; public static inline var STEP_OVER = 2; public static inline var STEP_OUT = 3; // This tagging value is returned by getStackVariableValue() and // setStackVariableValue if the requested value does not exist at the // requested stack frame public static var NONEXISTENT_VALUE = new String("NONEXISTENT_VALUE"); // This tagging value is returned by getStackVariableValue and // setStackVariableValue if the stack variable that is being set is on a // thread that is running, in which case the set does not take place. public static var THREAD_NOT_STOPPED = new String("THREAD_NOT_STOPPED"); /** * Sets the handler callback to be made when asynchronous events occur, * specifically, when threads are created, terminated, started, or * stopped. The calling thread becomes the "debugger" thread, which means * that it will be discluded from any breakpoints and will not be reported * on by any thread reporting requests. * * Be aware that this callback is made asynchronously and possibly by * multiple threads simultaneously. * * Setting this to null prevents further callbacks. * * Throws a string exception if the program does not support debugging * because it was not compiled with the HXCPP_DEBUGGER flag set. * * @param handler is a function that will be called back by asynchronous * thread events. Note that this function is called directly from * the thread experiencing the event and the handler should return * quickly to avoid blocking the calling thread unnecessarily. * The paramaters to handler are: * - threadNumber, the thread number of the event * - event, one of THREAD_CREATED, THREAD_TERMINATED, * THREAD_STARTED, or THREAD_STOPPED * - stackFrame, the stack frame number at which the thread is stopped, * undefined if event is not THREAD_STOPPED * - className, the class name at which the thread is stopped, * undefined if event is not THREAD_STOPPED * - functionName, the function name at which the thread is * stopped, undefined if event is not THREAD_STOPPED * - fileName, the file name at which the thread is stopped, * undefined if event is not THREAD_STOPPED * - lineNumber, the line number at which the thread is stopped, * undefined if event is not THREAD_STOPPED **/ public static function setEventNotificationHandler( handler : Int -> Int -> Int -> String -> String -> String -> Int -> Void) { untyped __global__.__hxcpp_dbg_setEventNotificationHandler(handler); } /** * This can be called to turn off (and then back on) all stopping of * debugged threads temporarily. It should only be used by classes that * actually implement the debugger to hide themselves from the debugger as * necessary. **/ public static function enableCurrentThreadDebugging(enabled : Bool) { untyped __global__.__hxcpp_dbg_enableCurrentThreadDebugging(enabled); } /** * Returns the thread number of the calling thread. * * @return the thread number of the calling thread. **/ public static function getCurrentThreadNumber() : Int { return untyped __global__.__hxcpp_dbg_getCurrentThreadNumber(); } /** * Returns the set of source files known to the debugger. This is a copy * of the original array and could be quite large. The caller should * cache this value to avoid multiple copies needing to be made. * * @return the set of source files known to the debugger. **/ public static function getFiles() : Array { return untyped __global__.__hxcpp_dbg_getFiles(); } /** * Returns the full paths of the set of source files known to the debugger. * This is a copy of the original array and could be quite large. * It is possible that this set will be empty, in which case the full paths are not known. * The index of these files matches the index from "getFiles", so the full path for * a given short path can be calculated. * * @return the known full paths of the set of source files **/ public static function getFilesFullPath() : Array { return untyped __global__.__hxcpp_dbg_getFilesFullPath(); } /** * Returns the set of class names of all classes known to the debugger. * This is a copy of the original array and could be quite large. The * caller should cache this value to avoid multiple copies needing to be * made. * * @return the set of class names of all classes known to the debugger. **/ public static function getClasses() : Array { return untyped __global__.__hxcpp_dbg_getClasses(); } /** * Returns a ThreadInfo object describing every thread that existed at the * moment that the call was made, except for the debugger thread. **/ public static function getThreadInfos() : Array { return untyped __global__.__hxcpp_dbg_getThreadInfos(); } /** * Returns a ThreadInfo object describing a single thread, or null if * there is no such thread or the thread queried about was the debugger * thread and unsafe was not true. **/ public static function getThreadInfo(threadNumber : Int, unsafe : Bool) : ThreadInfo { return untyped __global__.__hxcpp_dbg_getThreadInfo (threadNumber, unsafe); } /** * Adds a new file:line breakpoint. The breakpoint number of the newly * added breakpoint is returned. **/ public static function addFileLineBreakpoint(file : String, line : Int) : Int { return untyped __global__.__hxcpp_dbg_addFileLineBreakpoint (file, line); } /** * Adds a new class:function breakpoint. The breakpoint number of the * newly added breakpoint is returned. **/ public static function addClassFunctionBreakpoint(className : String, functionName : String) : Int { return untyped __global__.__hxcpp_dbg_addClassFunctionBreakpoint (className, functionName); } /** * Deletes a breakpoint, or all breakpoints. **/ public static function deleteBreakpoint(number : Null) { if (number == null) { untyped __global__.__hxcpp_dbg_deleteAllBreakpoints(); } else { untyped __global__.__hxcpp_dbg_deleteBreakpoint (cast (number, Int)); } } /** * Breaks all threads except the debugger thread (which should be the same * as the calling thread!). * * If [wait] is true, waits up to 2 seconds for all threads to be broken. * Threads which are in blocking system calls and cannot break after 2 * seconds remain running when this function returns. **/ public static function breakNow(wait : Bool = true) { untyped __global__.__hxcpp_dbg_breakNow(wait); } /** * Continue execution of all stopped threads. If specialThreadNumber * is a valid thread number, then it will be continued past * [continueCount] breakpoints instead of just 1 like all of the other * threads. **/ public static function continueThreads(specialThreadNumber : Int, continueCount : Int) { untyped __global__.__hxcpp_dbg_continueThreads (specialThreadNumber, continueCount); } /** * Single steps the given thread. **/ public static function stepThread(threadNumber : Int, stepType : Int, stepCount : Int = 1) { untyped __global__.__hxcpp_dbg_stepThread (threadNumber, stepType, stepCount); } /** * Returns the list of local variables (including "this", function * arguments, and local variables) visible to the given thread at the * given stack frame. * * Returns a list with a single entry, THREAD_NOT_STOPPED, if the * thread is not stopped and thus variables cannot be fetched and * unsafe is not true. * * @return the list of local variables (including "this", function * arguments, and local variables) visible to the given thread at * the given stack frame. **/ public static function getStackVariables(threadNumber : Int, stackFrameNumber : Int, unsafe : Bool) : Array { return untyped __global__.__hxcpp_dbg_getStackVariables (threadNumber, stackFrameNumber, unsafe, THREAD_NOT_STOPPED); } /** * Returns the value of a stack variable, or NONEXISTENT_VALUE if the * requested value does not exist. If the thread is actively running * and unsafe is not true, returns THREAD_NOT_STOPPED. **/ public static function getStackVariableValue(threadNumber : Int, stackFrameNumber : Int, name : String, unsafe : Bool) : Dynamic { return untyped __global__.__hxcpp_dbg_getStackVariableValue (threadNumber, stackFrameNumber, name, unsafe, NONEXISTENT_VALUE, THREAD_NOT_STOPPED); } /** * Sets the value of a stack variable and returns that value. If the * variable does not exist, on the stack, this function returns * NONEXISTENT_VALUE. If the thread is actively running and unsafe is not * true, returns THREAD_NOT_STOPPED, and the value is not set. **/ public static function setStackVariableValue(threadNumber : Int, stackFrameNumber : Int, name : String, value : Dynamic, unsafe : Bool) : Dynamic { return untyped __global__.__hxcpp_dbg_setStackVariableValue (threadNumber, stackFrameNumber, name, value, unsafe, NONEXISTENT_VALUE, THREAD_NOT_STOPPED); } // The hxcpp runtime calls back through these functions to create Haxe // objects as needed, which allows the C++ implementation code to create // Haxe objects without having to actually know the structure of those // objects private static function __init__() { untyped __global__.__hxcpp_dbg_setNewParameterFunction ( function (name : String, value : Dynamic) : Dynamic { return new Parameter(name, value); } ); untyped __global__.__hxcpp_dbg_setNewStackFrameFunction ( function (fileName : String, lineNumber : Int, className : String, functionName : String) { return new StackFrame(fileName, lineNumber, className, functionName); } ); untyped __global__.__hxcpp_dbg_setNewThreadInfoFunction ( function (number : Int, status : Int, breakpoint : Int, criticalErrorDescription : String) : Dynamic { return new ThreadInfo(number, status, breakpoint, criticalErrorDescription); } ); untyped __global__.__hxcpp_dbg_setAddParameterToStackFrameFunction ( function(inStackFrame : Dynamic, inParameter : Dynamic) { var stackFrame : StackFrame = cast inStackFrame; var parameter : Parameter = cast inParameter; stackFrame.parameters.push(parameter); } ); untyped __global__.__hxcpp_dbg_setAddStackFrameToThreadInfoFunction ( function(inThreadInfo : Dynamic, inStackFrame : Dynamic) { var threadInfo : ThreadInfo = cast inThreadInfo; var stackFrame : StackFrame = cast inStackFrame; threadInfo.stack.push(stackFrame); } ); } } haxe_3.2.1+dfsg.orig/std/cpp/vm/Deque.hx0000664000175000017500000000276712607337712017742 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; class Deque { var q : Dynamic; public function new() { q = untyped __global__.__hxcpp_deque_create(); } public function add( i : T ) { untyped __global__.__hxcpp_deque_add(q,i); } public function push( i : T ) { untyped __global__.__hxcpp_deque_push(q,i); } public function pop( block : Bool ) : Null { return untyped __global__.__hxcpp_deque_pop(q,block); } } haxe_3.2.1+dfsg.orig/std/cpp/vm/ExecutionTrace.hx0000664000175000017500000000047512607337712021613 0ustar andyandy00000000000000package cpp.vm; class ExecutionTrace { public static function traceOff() { untyped __hxcpp_execution_trace(0); } public static function traceFunctions() { untyped __hxcpp_execution_trace(1); } public static function traceLines() { untyped __hxcpp_execution_trace(2); } } haxe_3.2.1+dfsg.orig/std/cpp/vm/Gc.hx0000664000175000017500000000653012607337712017220 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; class Gc { public static inline var MEM_INFO_USAGE = 0; public static inline var MEM_INFO_RESERVED = 1; public static inline var MEM_INFO_CURRENT = 2; public static inline var MEM_INFO_LARGE = 3; static public function enable(inEnable:Bool) : Void { untyped __global__.__hxcpp_enable(inEnable); } static public function run(major:Bool) : Void { untyped __global__.__hxcpp_collect(major); } static public function compact() : Void { untyped __global__.__hxcpp_gc_compact(); } // Introduced hxcpp_api_level 310 // Returns stats on memory usage: // MEM_INFO_USAGE - estimate of how much is needed by program (at last collect) // MEM_INFO_RESERVED - memory allocated for possible use // MEM_INFO_CURRENT - memory in use, includes uncollected garbage. // This will generally saw-tooth between USAGE and RESERVED // MEM_INFO_LARGE - Size of separate pool used for large allocs. Included in all the above. static public function memInfo(inWhatInfo:Int) : Int { return untyped __global__.__hxcpp_gc_mem_info(inWhatInfo); } static public function memUsage() : Int { return untyped __global__.__hxcpp_gc_mem_info(MEM_INFO_USAGE); } static public function trace(sought:Class,printInstances:Bool=true) : Int { return untyped __global__.__hxcpp_gc_trace(sought,printInstances); } static public function versionCheck() { return true; } static public function doNotKill(inObject:Dynamic) : Void { untyped __global__.__hxcpp_gc_do_not_kill(inObject); } static public function getNextZombie() : Dynamic { return untyped __global__.__hxcpp_get_next_zombie(); } static public function safePoint() : Void { untyped __global__.__hxcpp_gc_safe_point(); } static public function enterGCFreeZone() : Void { untyped __global__.__hxcpp_enter_gc_free_zone(); } static public function exitGCFreeZone() : Void { untyped __global__.__hxcpp_exit_gc_free_zone(); } @:unreflective inline static public function setFinalizer(inObject:T, inFinalizer:cpp.CallableVoid> ) : Void { untyped __global__.__hxcpp_set_finalizer(inObject, inFinalizer); } } haxe_3.2.1+dfsg.orig/std/cpp/vm/Lock.hx0000664000175000017500000000264612607337712017563 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; class Lock { var l : Dynamic; public function new() { l = untyped __global__.__hxcpp_lock_create(); } public function wait( ?timeout : Float = -1) : Bool { return untyped __global__.__hxcpp_lock_wait(l,timeout); } public function release() { untyped __global__.__hxcpp_lock_release(l); } } haxe_3.2.1+dfsg.orig/std/cpp/vm/Mutex.hx0000664000175000017500000000274012607337712017770 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; class Mutex { var m : Dynamic; public function new() { m = untyped __global__.__hxcpp_mutex_create(); } public function acquire() { untyped __global__.__hxcpp_mutex_acquire(m); } public function tryAcquire() : Bool { return untyped __global__.__hxcpp_mutex_try(m); } public function release() { untyped __global__.__hxcpp_mutex_release(m); } } haxe_3.2.1+dfsg.orig/std/cpp/vm/Profiler.hx0000664000175000017500000000256312607337712020453 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; class Profiler { static public function start(?inDumpFile:String) : Void { untyped __global__.__hxcpp_start_profiler(inDumpFile); } static public function stop() : Void { untyped __global__.__hxcpp_stop_profiler(); } } haxe_3.2.1+dfsg.orig/std/cpp/vm/Thread.hx0000664000175000017500000000432412607337712020075 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; typedef ThreadHandle = Dynamic; class Thread { public var handle(default,null) : ThreadHandle; function new(h) { handle = h; } /** Send a message to the thread queue. This message can be readed by using [readMessage]. **/ public function sendMessage( msg : Dynamic ) { untyped __global__.__hxcpp_thread_send(handle,msg); } /** Returns the current thread. **/ public static function current() { return new Thread(untyped __global__.__hxcpp_thread_current()); } /** Creates a new thread that will execute the [callb] function, then exit. **/ public static function create( callb : Void -> Void ) { return new Thread(untyped __global__.__hxcpp_thread_create(callb)); } /** Reads a message from the thread queue. If [block] is true, the function blocks until a message is available. If [block] is false, the function returns [null] if no message is available. **/ public static function readMessage( block : Bool ) : Dynamic { return untyped __global__.__hxcpp_thread_read_message(block); } @:keep function __compare(t) : Int { return handle == t.handle ? 0 : 1; } } haxe_3.2.1+dfsg.orig/std/cpp/vm/Tls.hx0000664000175000017500000000270012607337712017424 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; class Tls { static var sFreeSlot = 0; var mTLSID : Int; public var value(get,set) : T; public function new() { mTLSID = sFreeSlot++; } function get_value() : T { return untyped __global__.__hxcpp_tls_get(mTLSID); } function set_value( v : T ) { untyped __global__.__hxcpp_tls_set(mTLSID,v); return v; } } haxe_3.2.1+dfsg.orig/std/cpp/vm/Unsafe.hx0000664000175000017500000000030212607337712020077 0ustar andyandy00000000000000package cpp.vm; class Unsafe { public static inline function unsafeSet(outForced:Dynamic,inValue:Dynamic) : Void { untyped __global__.__hxcpp_unsafe_set(outForced,inValue); } } haxe_3.2.1+dfsg.orig/std/cpp/vm/WeakRef.hx0000664000175000017500000000334312607337712020212 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cpp.vm; class WeakRef { var ref:Dynamic; var hardRef:Bool; public function new(inObject:T, inHard:Bool = false) { hardRef = inHard; if (hardRef) ref = inObject; else ref = untyped __global__.__hxcpp_weak_ref_create(inObject); } public function get():T { if (hardRef) return ref; return untyped __global__.__hxcpp_weak_ref_get(ref); } public function set(inObject:T):T { if (hardRef) ref = inObject; else ref = untyped __global__.__hxcpp_weak_ref_create(inObject); return inObject; } public function toString():String { return "WeakRef(" + get() + ")"; } } haxe_3.2.1+dfsg.orig/std/cpp/zip/Compress.hx0000664000175000017500000000012112607337712020630 0ustar andyandy00000000000000package cpp.zip; #if (haxe_ver < 3.4) typedef Compress = haxe.zip.Compress; #endhaxe_3.2.1+dfsg.orig/std/cpp/zip/Flush.hx0000664000175000017500000000011712607337712020123 0ustar andyandy00000000000000package cpp.zip; #if (haxe_ver < 3.4) typedef Flush = haxe.zip.FlushMode; #endhaxe_3.2.1+dfsg.orig/std/cpp/zip/Uncompress.hx0000664000175000017500000000012512607337712021177 0ustar andyandy00000000000000package cpp.zip; #if (haxe_ver < 3.4) typedef Uncompress = haxe.zip.Uncompress; #endhaxe_3.2.1+dfsg.orig/std/cs/Boot.hx0000664000175000017500000000310412607337712016765 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs; import cs.internal.Exceptions; import cs.internal.FieldLookup; import cs.internal.Function; import cs.internal.HxObject; import cs.internal.Runtime; import cs.internal.Iterator; #if !erase_generics import cs.internal.Null; #end import cs.internal.StringExt; #if unsafe import cs.internal.BoxedPointer; #end import cs.StdTypes; import haxe.ds.StringMap; import Reflect; class Boot { @:keep public static function init():Void { cs.Lib.applyCultureChanges(); } } haxe_3.2.1+dfsg.orig/std/cs/Flags.hx0000664000175000017500000000552112607337712017123 0ustar andyandy00000000000000package cs; /** Use this type to have access to the bitwise operators of C# enums that have a `cs.system.FlagsAttribute` attribute. Usage example: ```haxe import cs.system.reflection.BindingFlags; var binding = new Flags(BindingFlags.Public) | BindingFlags.Static | BindingFlags.NonPublic; ``` **/ abstract Flags(T) from T to T { /** Creates a new `Flags` type with an optional initial value. If no initial value was specified, the default enum value for an empty flags attribute is specified **/ @:extern inline public function new(?initial:T) this = initial; /** Accessible through the bitwise OR operator (`|`). Returns a new `Flags` type with the flags passed at `flags` added to it. **/ @:op(A|B) @:extern inline public function add(flags:Flags):Flags { return new Flags(underlying() | flags.underlying()); } /** Accessible through the bitwise AND operator (`&`). Returns a new `Flags` type with the flags that are set on both `this` and `flags` **/ @:op(A&B) @:extern inline public function bitAnd(flags:Flags):Flags { return new Flags(underlying() & flags.underlying()); } /** Accessible through the bitwise XOR operator (`^`). **/ @:op(A^B) @:extern inline public function bitXor(flags:Flags):Flags { return new Flags(underlying() & flags.underlying()); } /** Accesible through the bitwise negation operator (`~`). Returns a new `Flags` type with all unset flags as set - but the ones that are set already. **/ @:op(~A) @:extern inline public function bitNeg():Flags { return new Flags(~underlying()); } /** Returns a new `Flags` type with all flags set by `flags` unset **/ @:extern inline public function remove(flags:Flags):Flags { return new Flags(underlying() & ~flags.underlying()); } /** Returns whether `flag` is present on `this` type **/ @:extern inline public function has(flag:T):Bool { return underlying() & new Flags(flag).underlying() != null; } /** Returns whether `this` type has any flag set by `flags` also set **/ @:extern inline public function hasAny(flags:Flags):Bool { return underlying() & flags.underlying() != null; } /** Returns whether `this` type has all flags set by `flags` also set **/ @:extern inline public function hasAll(flags:Flags):Bool { return underlying() & flags.underlying() == flags.underlying(); } @:extern inline private function underlying():EnumUnderlying return this; } @:coreType private abstract EnumUnderlying from T to T { @:op(A|B) public static function or(lhs:EnumUnderlying, rhs:EnumUnderlying):T; @:op(A^B) public static function xor(lhs:EnumUnderlying, rhs:EnumUnderlying):T; @:op(A&B) public static function and(lhs:EnumUnderlying, rhs:EnumUnderlying):T; @:op(~A) public static function bneg(t:EnumUnderlying):T; } haxe_3.2.1+dfsg.orig/std/cs/Lib.hx0000664000175000017500000002272312607337712016600 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs; import cs.system.Type; /** Platform-specific C# Library. Provides some platform-specific functions for the C# target, such as conversion from haxe types to native types and vice-versa. **/ class Lib { @:keep private static var decimalSeparator:String; /** Changes the current culture settings to allow a consistent cross-target behavior. Currently the only change made is in regard to the decimal separator, which is always set to "." **/ @:keep public static function applyCultureChanges():Void { var ci = new cs.system.globalization.CultureInfo(cs.system.threading.Thread.CurrentThread.CurrentCulture.Name, true); decimalSeparator = ci.NumberFormat.NumberDecimalSeparator; ci.NumberFormat.NumberDecimalSeparator = "."; cs.system.threading.Thread.CurrentThread.CurrentCulture = ci; } /** Reverts the culture changes to the default settings. **/ public static function revertDefaultCulture():Void { var ci = new cs.system.globalization.CultureInfo(cs.system.threading.Thread.CurrentThread.CurrentCulture.Name, true); cs.system.threading.Thread.CurrentThread.CurrentCulture = ci; } /** Returns a native array from the supplied Array. This native array is unsafe to be written on, as it may or may not be linked to the actual Array implementation. If equalLengthRequired is true, the result might be a copy of an array with the correct size. **/ @:extern inline public static function nativeArray(arr:Array, equalLengthRequired:Bool):NativeArray { var ret = new cs.NativeArray(arr.length); #if erase_generics for (i in 0...arr.length) ret[i] = arr[i]; #else p_nativeArray(arr,ret); #end return ret; } #if !erase_generics static function p_nativeArray(arr:Array, ret:cs.system.Array):Void { var native:NativeArray = untyped arr.__a; var len = arr.length; cs.system.Array.Copy(native, 0, ret, 0, len); } #end /** Provides support for the "as" keyword in C#. If the object is not of the supplied type "T", it will return null instead of rasing an exception. This function will not work with Value Types (such as Int, Float, Bool...) **/ @:extern public static inline function as(obj:Dynamic, cl:Class):T { return untyped __as__(obj); } /** Returns a Class<> equivalent to the native System.Type type. Currently Haxe's Class<> is equivalent to System.Type, but this is an implementation detail. This may change in the future, so use this function whenever you need to perform such conversion. **/ public static inline function fromNativeType(t:cs.system.Type):Class { return untyped t; } /** Returns a System.Type equivalent to the Haxe Class<> type. Currently Haxe's Class<> is equivalent to System.Type, but this is an implementation detail. This may change in the future, so use this function whenever you need to perform such conversion. **/ public static inline function toNativeType(cl:Class):Type { return untyped cl; } /** Returns a System.Type equivalent to the Haxe Enum<> type. **/ public static inline function toNativeEnum(cl:Enum):Type { return untyped cl; } /** Gets the native System.Type from the supplied object. Will throw an exception in case of null being passed. [deprecated] - use `getNativeType` instead **/ @:deprecated('The function `nativeType` is deprecated and will be removed in later versions. Please use `getNativeType` instead') public static function nativeType(obj:Dynamic):Type { return untyped obj.GetType(); } /** Gets the native System.Type from the supplied object. Will throw an exception in case of null being passed. **/ public static function getNativeType(obj:Dynamic):Type { return untyped obj.GetType(); } #if erase_generics inline private static function mkDynamic(native:NativeArray):NativeArray { var ret = new cs.NativeArray(native.Length); for (i in 0...native.Length) ret[i] = native[i]; return ret; } #end /** Returns a Haxe Array of a native Array. Unless `erase_generics` is defined, it won't copy the contents of the native array, so unless any operation triggers an array resize, all changes made to the Haxe array will affect the native array argument. **/ inline public static function array(native:cs.NativeArray):Array { #if erase_generics var dyn:NativeArray = mkDynamic(native); return @:privateAccess Array.ofNative(dyn); #else return @:privateAccess Array.ofNative(native); #end } /** Allocates a new Haxe Array with a predetermined size **/ inline public static function arrayAlloc(size:Int):Array { return @:privateAccess Array.alloc(size); } /** Rethrow an exception. This is useful when manually filtering an exception in order to keep the previous exception stack. **/ @:extern inline public static function rethrow(e:Dynamic):Void { untyped __rethrow__(); } /** Creates a "checked" block, which throws exceptions for overflows. Usage: cs.Lib.checked({ var x = 1000; while(true) { x *= x; } }); This method only exists at compile-time, so it can't be called via reflection. **/ @:extern public static inline function checked(block:V):Void { untyped __checked__(block); } /** Ensures that one thread does not enter a critical section of code while another thread is in the critical section. If another thread attempts to enter a locked code, it will wait, block, until the object is released. This method only exists at compile-time, so it can't be called via reflection. **/ @:extern public static inline function lock(obj:O, block:V):Void { untyped __lock__(obj, block); } //Unsafe code manipulation #if unsafe /** Marks its parameters as fixed objects inside the defined block. The first variable declarations that use cs.Lib.pointerOfArray() will be the fixed definitions. Usage: cs.Lib.fixed({ var obj1 = cs.Lib.pointerOfArray(someArray); var obj2 = cs.Lib.pointerOfArray(someArray2); var obj3 = cs.Lib.pointerOfArray(someArray3); //from now on, obj1, obj2 and obj3 are fixed //we cannot change obj1, obj2 or obj3 variables like this: //obj1++; }); This method only exists at compile-time, so it can't be called via reflection. **/ @:extern public static inline function fixed(block:V):Void { untyped __fixed__(block); } /** Marks the contained block as an unsafe block, meaning that it can contain unsafe code. Usage: cs.Lib.unsafe({ //unsafe code is allowed inside here }); This method only exists at compile-time, so it can't be called via reflection. **/ @:extern public static inline function unsafe(block:V):Void { untyped __unsafe__(block); } /** Gets the pointer to the address of current local. Equivalent to the "&" operator in C# Usage: var x:Int = 0; cs.Lib.unsafe({ var addr = cs.Lib.addressOf(x); x[0] = 42; }); trace(x); //42 This method only exists at compile-time, so it can't be called via reflection. Warning: This method will only work if a local variable is passed as an argument. **/ @:extern public static inline function addressOf(variable:T):cs.Pointer { return untyped __addressOf__(variable); } /** Gets the value of the pointer address. Usage: var x:Int = 0; cs.Lib.unsafe({ var addr = cs.Lib.addressOf(x); trace(cs.Lib.valueOf(addr)); //0 addr[0] = 42; trace(cs.Lib.valueOf(addr)); //42 }); trace(x); //42 This method only exists at compile-time, so it can't be called via reflection. **/ @:extern public static inline function valueOf(pointer:cs.Pointer):T { return untyped __valueOf__(pointer); } /** Transforms a managed native array into a Pointer. Must be inside a fixed statement Usage: var x:cs.NativeArray = new cs.NativeArray(1); cs.Lib.unsafe({ cs.Lib.fixed({ var addr = cs.Lib.pointerOfArray(x); trace(cs.Lib.valueOf(addr)); //0 addr[0] = 42; trace(cs.Lib.valueOf(addr)); //42 }); }); trace(x[0]); //42 This method only exists at compile-time, so it can't be called via reflection. **/ @:extern public static inline function pointerOfArray(array:cs.NativeArray):cs.Pointer { return untyped __ptr__(array); } /** Returns the byte size of the given struct. Only works with structs and basic types. **/ @:extern public static inline function sizeof(struct:Class):Int { return untyped __sizeof__(struct); } #end } haxe_3.2.1+dfsg.orig/std/cs/NativeArray.hx0000664000175000017500000000450412607337712020314 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs; import haxe.extern.Rest; /** Represents a C# fixed-size Array (`T[]`) **/ extern class NativeArray extends cs.system.Array implements ArrayAccess { /** Creates a new array with the specified elements. Usage: ```haxe var elements = NativeArray.make(1,2,3,4,5,6); ``` **/ public static function make(elements:Rest):NativeArray; /** Allocates a new array with size `len` **/ public function new(len:Int):Void; /** Alias to array's `Length` property. Returns the size of the array **/ public var length(get,never):Int; @:extern inline private function get_length():Int return this.Length; static function Reverse(arr:cs.system.Array):Void; /** Returns an iterator so it's possible to use `for` with C#'s `NativeArray` **/ @:extern inline public function iterator():NativeArrayIterator return new NativeArrayIterator(this); } @:dce private class NativeArrayIterator { public var arr(default,null):NativeArray; public var idx(default,null):UInt; inline public function new(arr) { this.arr = arr; this.idx = 0; } inline public function hasNext():Bool return this.idx < this.arr.Length; inline public function next():T { return this.arr[this.idx++]; } } haxe_3.2.1+dfsg.orig/std/cs/Out.hx0000664000175000017500000000272112607337712016635 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs; /** This type represents "out" types for C# function parameters. It only has effect on function parameters, and conversion to/from the referenced type is automatic. Note: Using this type should be considered a bad practice unless overriding a native function is needed. **/ @:analyzer(no_simplification) @:analyzer(no_local_dce) typedef Out = T;haxe_3.2.1+dfsg.orig/std/cs/Pointer.hx0000664000175000017500000001125112607337712017504 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs; import cs.StdTypes.Int64; /** This type represents pointer types for C# function parameters. It should only be used inside an unsafe context (not checked by the Haxe compiler) C# code: int[] src; fixed (int* pSrc = src) { ... } Haxe code: var src:NativeArray; cs.Lib.fixed({ var pSrc:cs.Pointer = cs.Lib.pointerOfArray(src); ... }); **/ #if !unsafe #error "You need to define 'unsafe' to be able to use unsafe code in hxcs" #else @:runtimeValue @:coreType abstract Pointer from Int64 from PointerAccess to PointerAccess { @:op(A+B) public static function addIp(lhs:Pointer, rhs:Int):Pointer; @:op(A+B) public static function addp(lhs:Pointer, rhs:Int64):Pointer; @:op(A*B) public static function mulIp(lhs:Pointer, rhs:Int):Pointer; @:op(A*B) public static function mulp(lhs:Pointer, rhs:Int64):Pointer; @:op(A%B) public static function modIp(lhs:Pointer, rhs:Int):Pointer; @:op(A%B) public static function modp(lhs:Pointer, rhs:Int64):Pointer; @:op(A-B) public static function subIp(lhs:Pointer, rhs:Int):Pointer; @:op(A-B) public static function subp(lhs:Pointer, rhs:Int64):Pointer; @:op(A/B) public static function divIp(lhs:Pointer, rhs:Int):Pointer; @:op(A/B) public static function divp(lhs:Pointer, rhs:Int64):Pointer; @:op(A|B) public static function orIp(lhs:Pointer, rhs:Int):Pointer; @:op(A|B) public static function orp(lhs:Pointer, rhs:Int64):Pointer; @:op(A^B) public static function xorIp(lhs:Pointer, rhs:Int):Pointer; @:op(A^B) public static function xorp(lhs:Pointer, rhs:Int64):Pointer; @:op(A&B) public static function andIp(lhs:Pointer, rhs:Int):Pointer; @:op(A&B) public static function andp(lhs:Pointer, rhs:Int64):Pointer; @:op(A<(lhs:Pointer, rhs:Int):Pointer; @:op(A<(lhs:Pointer, rhs:Int64):Pointer; @:op(A>>B) public static function shrIp(lhs:Pointer, rhs:Int):Pointer; @:op(A>>B) public static function shrp(lhs:Pointer, rhs:Int64):Pointer; @:op(A>B) public static function gtp(lhs:Pointer, rhs:Pointer):Bool; @:op(A>=B) public static function gtep(lhs:Pointer, rhs:Pointer):Bool; @:op(A(lhs:Pointer, rhs:Pointer):Bool; @:op(A<=B) public static function ltep(lhs:Pointer, rhs:Pointer):Bool; @:op(~A) public static function bnegp(t:Pointer):Pointer; @:op(A++) public static function prepp(t:Pointer):Pointer; @:op(A--) public static function prenn(t:Pointer):Pointer; @:op(++A) public static function postpp(t:Pointer):Pointer; @:op(--A) public static function postnn(t:Pointer):Pointer; /** Returns a `cs.PointerAccess` type, which in turn allows the underlying Pointer's fields to be accessed. **/ // @:analyzer(no_simplification) public var acc(get,never):PointerAccess; // @:analyzer(no_simplification) @:extern inline private function get_acc():PointerAccess return (cast this : PointerAccess); // backwards compatibility inline public function add(i:Int):Pointer { return this + i; } @:arrayAccess public static function getIp(p:Pointer, at:Int):T; @:arrayAccess public static function setIp(p:Pointer, at:Int, val:T):T; @:arrayAccess public static function getp(p:Pointer, at:Int64):T; @:arrayAccess public static function setp(p:Pointer, at:Int64, val:T):T; } @:forward abstract PointerAccess(T) { } #end haxe_3.2.1+dfsg.orig/std/cs/Ref.hx0000664000175000017500000000267012607337712016605 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs; /** This type represents "ref" types for C# function parameters. It only has effect on function parameters, and conversion to/from the referenced type is automatic. Note: Using this type should be considered a bad practice unless overriding a native function is needed. **/ @:analyzer(no_simplification) typedef Ref = T;haxe_3.2.1+dfsg.orig/std/cs/StdTypes.hx0000664000175000017500000001276612607337712017657 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs; @:notNull @:runtimeValue @:coreType abstract Int8 to Int {} @:notNull @:runtimeValue @:coreType abstract Int16 to Int {} @:notNull @:runtimeValue @:coreType abstract Char16 from Int {} @:notNull @:runtimeValue @:coreType abstract UInt8 to Int from Int {} @:notNull @:runtimeValue @:coreType abstract UInt16 to Int {} @:notNull @:runtimeValue @:coreType abstract Int64 from Int from Float { @:op(A+B) public static function addI(lhs:Int64, rhs:Int):Int64; @:op(A+B) public static function add(lhs:Int64, rhs:Int64):Int64; @:op(A*B) public static function mulI(lhs:Int64, rhs:Int):Int64; @:op(A*B) public static function mul(lhs:Int64, rhs:Int64):Int64; @:op(A%B) public static function modI(lhs:Int64, rhs:Int):Int64; @:op(A%B) public static function mod(lhs:Int64, rhs:Int64):Int64; @:op(A-B) public static function subI(lhs:Int64, rhs:Int):Int64; @:op(A-B) public static function sub(lhs:Int64, rhs:Int64):Int64; @:op(A/B) public static function divI(lhs:Int64, rhs:Int):Int64; @:op(A/B) public static function div(lhs:Int64, rhs:Int64):Int64; @:op(A|B) public static function orI(lhs:Int64, rhs:Int):Int64; @:op(A|B) public static function or(lhs:Int64, rhs:Int64):Int64; @:op(A^B) public static function xorI(lhs:Int64, rhs:Int):Int64; @:op(A^B) public static function xor(lhs:Int64, rhs:Int64):Int64; @:op(A&B) public static function andI(lhs:Int64, rhs:Int):Int64; @:op(A&B) public static function and(lhs:Int64, rhs:Int64):Int64; @:op(A<>B) public static function shrI(lhs:Int64, rhs:Int):Int64; @:op(A>>B) public static function shr(lhs:Int64, rhs:Int64):Int64; @:op(A>B) public static function gt(lhs:Int64, rhs:Int64):Bool; @:op(A>=B) public static function gte(lhs:Int64, rhs:Int64):Bool; @:op(A>B) public static function shrI(lhs:UInt64, rhs:Int):UInt64; @:op(A>>B) public static function shr(lhs:UInt64, rhs:UInt64):UInt64; @:op(A>B) public static function gt(lhs:UInt64, rhs:UInt64):Bool; @:op(A>=B) public static function gte(lhs:UInt64, rhs:UInt64):Bool; @:op(A implements ArrayAccess { public var length(default,null) : Int; private var __a:NativeArray; #if erase_generics inline private static function ofNative(native:NativeArray):Array { return new Array(native); } #else inline private static function ofNative(native:NativeArray):Array { return new Array(native); } #end inline private static function alloc(size:Int):Array { return new Array(new NativeArray(size)); } @:overload public function new() : Void { this.length = 0; this.__a = new NativeArray(0); } #if erase_generics @:overload private function new(native:NativeArray) { this.length = native.Length; this.__a = untyped native; } #else @:overload private function new(native:NativeArray) { this.length = native.Length; this.__a = native; } #end public function concat( a : Array ) : Array { var len = length + a.length; var retarr = new NativeArray(len); cs.system.Array.Copy(__a, 0, retarr, 0, length); cs.system.Array.Copy(a.__a, 0, retarr, length, a.length); return ofNative(retarr); } private function concatNative( a : NativeArray ) : Void { var __a = __a; var len = length + a.Length; if (__a.Length >= len) { cs.system.Array.Copy(a, 0, __a, length, length); } else { var newarr = new NativeArray(len); cs.system.Array.Copy(__a, 0, newarr, 0, length); cs.system.Array.Copy(a, 0, newarr, length, a.Length); this.__a = newarr; } this.length = len; } public function indexOf( x : T, ?fromIndex:Int ) : Int { var len = length, i:Int = (fromIndex == null) ? 0 : fromIndex; if (i < 0) { i += len; if (i < 0) i = 0; } else if (i >= len) { return -1; } return cs.system.Array.IndexOf(__a, x, i, len - i); } public function lastIndexOf( x : T, ?fromIndex:Int ) : Int { var len = length, i:Int = (fromIndex == null) ? len - 1 : fromIndex; if (i >= len) { i = len - 1; } else if (i < 0) { i += len; if (i < 0) return -1; } return cs.system.Array.LastIndexOf(__a, x, i, i + 1); } public function join( sep : String ) : String { var buf = new StringBuf(); var i = -1; var first = true; var length = length; while (++i < length) { if (first) first = false; else buf.add(sep); buf.add(__a[i]); } return buf.toString(); } public function pop() : Null { var __a = __a; var length = length; if (length > 0) { var val = __a[--length]; __a[length] = null; this.length = length; return val; } else { return null; } } public function push(x : T) : Int { if (length >= __a.Length) { var newLen = (length << 1) + 1; var newarr = new NativeArray(newLen); __a.CopyTo(newarr, 0); this.__a = newarr; } __a[length] = x; return ++length; } public function reverse() : Void { var i = 0; var l = this.length; var a = this.__a; var half = l >> 1; l -= 1; while ( i < half ) { var tmp = a[i]; a[i] = a[l-i]; a[l-i] = tmp; i += 1; } } public function shift() : Null { var l = this.length; if( l == 0 ) return null; var a = this.__a; var x = a[0]; l -= 1; cs.system.Array.Copy(a, 1, a, 0, length-1); a[l] = null; this.length = l; return x; } public function slice( pos : Int, ?end : Int ) : Array { if( pos < 0 ){ pos = this.length + pos; if( pos < 0 ) pos = 0; } if( end == null ) end = this.length; else if( end < 0 ) end = this.length + end; if( end > this.length ) end = this.length; var len = end - pos; if ( len < 0 ) return new Array(); var newarr = new NativeArray(len); cs.system.Array.Copy(__a, pos, newarr, 0, len); return ofNative(newarr); } public function sort( f : T -> T -> Int ) : Void { if (length == 0) return; quicksort(0, length - 1, f); } private function quicksort( lo : Int, hi : Int, f : T -> T -> Int ) : Void { var buf = __a; var i = lo, j = hi; var p = buf[(i + j) >> 1]; while ( i <= j ) { while ( i < hi && f(buf[i], p) < 0 ) i++; while ( j > lo && f(buf[j], p) > 0 ) j--; if ( i <= j ) { var t = buf[i]; buf[i++] = buf[j]; buf[j--] = t; } } if( lo < j ) quicksort( lo, j, f ); if( i < hi ) quicksort( i, hi, f ); } public function splice( pos : Int, len : Int ) : Array { if( len < 0 ) return new Array(); if( pos < 0 ) { pos = this.length + pos; if( pos < 0 ) pos = 0; } if( pos > this.length ) { pos = 0; len = 0; } else if( pos + len > this.length ) { len = this.length - pos; if( len < 0 ) len = 0; } var a = this.__a; var ret = new NativeArray(len); cs.system.Array.Copy(a, pos, ret, 0, len); var ret = ofNative(ret); var end = pos + len; cs.system.Array.Copy(a, end, a, pos, this.length - end); this.length -= len; while( --len >= 0 ) a[this.length + len] = null; return ret; } private function spliceVoid( pos : Int, len : Int ) : Void { if( len < 0 ) return; if( pos < 0 ) { pos = this.length + pos; if( pos < 0 ) pos = 0; } if( pos > this.length ) { pos = 0; len = 0; } else if( pos + len > this.length ) { len = this.length - pos; if( len < 0 ) len = 0; } var a = this.__a; var end = pos + len; cs.system.Array.Copy(a, end, a, pos, this.length - end); this.length -= len; while( --len >= 0 ) a[this.length + len] = null; } public function toString() : String { var ret = new StringBuf(); var a = __a; ret.add("["); var first = true; for (i in 0...length) { if (first) first = false; else ret.add(","); ret.add(a[i]); } ret.add("]"); return ret.toString(); } public function unshift( x : T ) : Void { var __a = __a; var length = length; if (length >= __a.Length) { var newLen = (length << 1) + 1; var newarr = new NativeArray(newLen); cs.system.Array.Copy(__a, 0, newarr, 1, length); this.__a = newarr; } else { cs.system.Array.Copy(__a, 0, __a, 1, length); } this.__a[0] = x; ++this.length; } public function insert( pos : Int, x : T ) : Void { var l = this.length; if( pos < 0 ) { pos = l + pos; if( pos < 0 ) pos = 0; } if ( pos >= l ) { this.push(x); return; } else if (pos == 0) { this.unshift(x); return; } if (l >= __a.Length) { var newLen = (length << 1) + 1; var newarr = new NativeArray(newLen); cs.system.Array.Copy(__a, 0, newarr, 0, pos); newarr[pos] = x; cs.system.Array.Copy(__a, pos, newarr, pos + 1, l - pos); this.__a = newarr; ++this.length; } else { var __a = __a; cs.system.Array.Copy(__a, pos, __a, pos + 1, l - pos); cs.system.Array.Copy(__a, 0, __a, 0, pos); __a[pos] = x; ++this.length; } } public function remove( x : T ) : Bool { var __a = __a; var i = -1; var length = length; while (++i < length) { if (__a[i] == x) { cs.system.Array.Copy(__a, i + 1, __a, i, length - i - 1); __a[--this.length] = null; return true; } } return false; } public function map( f : T -> S ) : Array { var ret = []; for (elt in this) ret.push(f(elt)); return ret; } public function filter( f : T -> Bool ) : Array { var ret = []; for (elt in this) if (f(elt)) ret.push(elt); return ret; } public function copy() : Array { var len = length; var __a = __a; var newarr = new NativeArray(len); cs.system.Array.Copy(__a, 0, newarr, 0, len); return ofNative(newarr); } public inline function iterator() : Iterator { return new ArrayIterator(this); } private function __get(idx:Int):T { return if ((cast idx : UInt) >= length) null else __a[idx]; } private function __set(idx:Int, v:T):T { var idx:UInt = idx; var __a = __a; if (idx >= __a.Length) { var len = idx + 1; if (idx == __a.Length) len = (idx << 1) + 1; var newArr = new NativeArray(len); __a.CopyTo(newArr, 0); this.__a = __a = newArr; } if (idx >= length) this.length = idx + 1; return __a[idx] = v; } private inline function __unsafe_get(idx:Int):T { return __a[idx]; } private inline function __unsafe_set(idx:Int, val:T):T { return __a[idx] = val; } } @:final private class ArrayIterator { var arr:Array; var len:Int; var i:Int; public inline function new(a:Array) { arr = a; len = a.length; i = 0; } public inline function hasNext():Bool return i < len; public inline function next():T return arr[i++]; } haxe_3.2.1+dfsg.orig/std/cs/_std/Date.hx0000664000175000017500000000721012607337712017672 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package; import cs.system.DateTime; import cs.system.TimeSpan; import haxe.Int64; #if core_api_serialize @:meta(System.Serializable) #end @:coreApi class Date { private var date:DateTime; public function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void { if (day <= 0) day = 1; if (year <= 0) year = 1; date = new DateTime(year, month + 1, day, hour, min, sec); } public inline function getTime() : Float { return (cast(date.Ticks, Float) / cast(TimeSpan.TicksPerMillisecond, Float)); } public inline function getHours() : Int { return date.Hour; } public inline function getMinutes() : Int { return date.Minute; } public inline function getSeconds() : Int { return date.Second; } public inline function getFullYear() : Int { return date.Year; } public inline function getMonth() : Int { return date.Month - 1; } public inline function getDate() : Int { return date.Day; } public inline function getDay() : Int { return cast(date.DayOfWeek, Int); } public function toString():String { var m = getMonth() + 1; var d = getDate(); var h = getHours(); var mi = getMinutes(); var s = getSeconds(); return (getFullYear()) +"-"+(if( m < 10 ) "0"+m else ""+m) +"-"+(if( d < 10 ) "0"+d else ""+d) +" "+(if( h < 10 ) "0"+h else ""+h) +":"+(if( mi < 10 ) "0"+mi else ""+mi) +":"+(if( s < 10 ) "0"+s else ""+s); } static public function now() : Date { var d = new Date(0, 0, 0, 0, 0, 0); d.date = DateTime.Now; return d; } static public function fromTime( t : Float ) : Date { var d = new Date(0, 0, 0, 0, 0, 0); d.date = new DateTime(cast(t * cast(TimeSpan.TicksPerMillisecond, Float), Int64)); return d; } static public function fromString( s : String ) : Date { switch( s.length ) { case 8: // hh:mm:ss var k = s.split(":"); var d : Date = new Date(1, 1, 1, Std.parseInt(k[0]), Std.parseInt(k[1]), Std.parseInt(k[2])); return d; case 10: // YYYY-MM-DD var k = s.split("-"); return new Date(Std.parseInt(k[0]),Std.parseInt(k[1]) - 1,Std.parseInt(k[2]),0,0,0); case 19: // YYYY-MM-DD hh:mm:ss var k = s.split(" "); var y = k[0].split("-"); var t = k[1].split(":"); return new Date(Std.parseInt(y[0]),Std.parseInt(y[1]) - 1,Std.parseInt(y[2]),Std.parseInt(t[0]),Std.parseInt(t[1]),Std.parseInt(t[2])); default: throw "Invalid date format : " + s; } } private static function fromNative( d : cs.system.DateTime ) : Date { var date = new Date(0, 0, 0, 0, 0, 0); date.date = d; return date; } } haxe_3.2.1+dfsg.orig/std/cs/_std/EReg.hx0000664000175000017500000000740312607337712017643 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import cs.system.text.regularexpressions.Regex; import cs.system.text.regularexpressions.Match; import cs.system.text.regularexpressions.RegexOptions; import cs.system.text.regularexpressions.*; @:coreApi @:final class EReg { private var regex : Regex; private var m : Match; private var isGlobal : Bool; private var cur : String; public function new( r : String, opt : String ) : Void { var opts:Int = cast CultureInvariant; for (i in 0...opt.length) untyped { switch(cast(opt[i], Int)) { case 'i'.code: opts |= cast(IgnoreCase, Int); case 'g'.code: isGlobal = true; case 'm'.code: opts |= cast(Multiline, Int); #if (!unity && !unity_std_target) case 'c'.code: opts |= cast(Compiled, Int); #end } } this.regex = new Regex(r, cast(opts, RegexOptions)); } public function match( s : String ) : Bool { m = regex.Match(s); cur = s; return m.Success; } public function matched( n : Int ) : String { if (m == null || cast(n, UInt) > m.Groups.Count) throw "EReg::matched"; if (!m.Groups[n].Success) return null; return m.Groups[n].Value; } public function matchedLeft() : String { return untyped cur.Substring(0, m.Index); } public function matchedRight() : String { return untyped cur.Substring(m.Index + m.Length); } public function matchedPos() : { pos : Int, len : Int } { return { pos : m.Index, len : m.Length }; } public function matchSub( s : String, pos : Int, len : Int = -1):Bool { m= if (len<0) regex.Match(s,pos) else regex.Match(s, pos, len); cur = s; return m.Success; } public function split( s : String ) : Array { if (isGlobal) return cs.Lib.array(regex.Split(s)); var m = regex.Match(s); if (!m.Success) return [s]; return untyped [s.Substring(0, m.Index), s.Substring(m.Index + m.Length)]; } inline function start(group:Int) : Int { return m.Groups[group].Index; } inline function len(group:Int) : Int { return m.Groups[group].Length; } public function replace( s : String, by : String ) : String { return (isGlobal) ? regex.Replace(s, by): regex.Replace(s,by,1); } public function map( s : String, f : EReg -> String ) : String { var offset = 0; var buf = new StringBuf(); do { if (offset >= s.length) break; else if (!matchSub(s, offset)) { buf.add(s.substr(offset)); break; } var p = matchedPos(); buf.add(s.substr(offset, p.pos - offset)); buf.add(f(this)); if (p.len == 0) { buf.add(s.substr(p.pos, 1)); offset = p.pos + 1; } else offset = p.pos + p.len; } while (isGlobal); if (!isGlobal && offset > 0 && offset < s.length) buf.add(s.substr(offset)); return buf.toString(); } } haxe_3.2.1+dfsg.orig/std/cs/_std/Math.hx0000664000175000017500000000753112607337712017714 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi @:nativeGen class Math { @:readOnly private static var rand = new cs.system.Random(); @:readOnly public static var PI(default,null) = cs.system.Math.PI; @:readOnly public static var NaN(default,null) = cs.system.Double.NaN; @:readOnly public static var NEGATIVE_INFINITY(default,null) = cs.system.Double.NegativeInfinity; @:readOnly public static var POSITIVE_INFINITY(default,null) = cs.system.Double.PositiveInfinity; public static inline function abs(v:Float):Float { return cs.system.Math.Abs(v); } public static inline function min(a:Float, b:Float):Float { return cs.system.Math.Min(a,b); } public static inline function max(a:Float, b:Float):Float { return cs.system.Math.Max(a,b); } public static inline function sin(v:Float):Float { return cs.system.Math.Sin(v); } public static inline function cos(v:Float):Float { return cs.system.Math.Cos(v); } public static inline function atan2(y:Float, x:Float):Float { return cs.system.Math.Atan2(y, x); } public static inline function tan(v:Float):Float { return cs.system.Math.Tan(v); } public static inline function exp(v:Float):Float { return cs.system.Math.Exp(v); } public static inline function log(v:Float):Float { return cs.system.Math.Log(v); } public static inline function sqrt(v:Float):Float { return cs.system.Math.Sqrt(v); } public static inline function fround(v:Float):Float { return cs.system.Math.Floor(v + 0.5); } public static inline function ffloor(v:Float):Float { return cs.system.Math.Floor(v); } public static inline function fceil(v:Float):Float { return cs.system.Math.Ceiling(v); } public static function round(v:Float):Int { var vint = Std.int(v); var dec = v - vint; if (dec >= 1 || dec <= -1) return vint; //overflow if (dec >= .5) return vint + 1; if (dec < -.5) return vint - 1; return vint; } public static inline function floor(v:Float):Int { return Std.int(cs.system.Math.Floor(v)); } public static inline function ceil(v:Float):Int { return Std.int(cs.system.Math.Ceiling(v)); } public static inline function atan(v:Float):Float { return cs.system.Math.Atan(v); } public static inline function asin(v:Float):Float { return cs.system.Math.Asin(v); } public static inline function acos(v:Float):Float { return cs.system.Math.Acos(v); } public static inline function pow(v:Float, exp:Float):Float { return cs.system.Math.Pow(v, exp); } public static inline function random() : Float { return rand.NextDouble(); } public static inline function isFinite( f : Float ) : Bool { return !cs.system.Double.IsInfinity(f) && !cs.system.Double.IsNaN(f); } public static inline function isNaN( f : Float ) : Bool { return cs.system.Double.IsNaN(f); } } haxe_3.2.1+dfsg.orig/std/cs/_std/Reflect.hx0000664000175000017500000001227012607337712020403 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import cs.internal.Function; import cs.system.reflection.*; import cs.internal.*; import cs.internal.HxObject; import cs.internal.Runtime; import cs.Flags; import cs.Lib; import cs.system.Object; import cs.system.reflection.*; @:keep @:coreApi class Reflect { public static function hasField( o : Dynamic, field : String ) : Bool { var ihx:IHxObject = Lib.as(o,IHxObject); if (ihx != null) return untyped ihx.__hx_getField(field, FieldLookup.hash(field), false, true, false) != Runtime.undefined; return Runtime.slowHasField(o,field); } public static function field( o : Dynamic, field : String ) : Dynamic { var ihx:IHxObject = Lib.as(o,IHxObject); if (ihx != null) return untyped ihx.__hx_getField(field, FieldLookup.hash(field), false, false, false); return Runtime.slowGetField(o,field,false); } public static function setField( o : Dynamic, field : String, value : Dynamic ) : Void { var ihx:IHxObject = Lib.as(o,IHxObject); if (ihx != null) untyped ihx.__hx_setField(field, FieldLookup.hash(field), value, false); else Runtime.slowSetField(o,field,value); } public static function getProperty( o : Dynamic, field : String ) : Dynamic { var ihx:IHxObject = Lib.as(o,IHxObject); if (ihx != null) return untyped ihx.__hx_getField(field, FieldLookup.hash(field), false, false, true); if (Runtime.slowHasField(o, "get_" + field)) return Runtime.slowCallField(o, "get_" + field, null); return Runtime.slowGetField(o, field, false); } public static function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void { var ihx:IHxObject = Lib.as(o,IHxObject); if (ihx != null) untyped ihx.__hx_setField(field, FieldLookup.hash(field), value, true); else if (Runtime.slowHasField(o, 'set_$field')) Runtime.slowCallField(o, 'set_$field', [value]); else Runtime.slowSetField(o,field,value); } public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array ) : Dynamic { return untyped cast(func, Function).__hx_invokeDynamic(args); } public static function fields( o : Dynamic ) : Array { var ihx = Lib.as(o,IHxObject); if (o != null) { var ret = []; untyped ihx.__hx_getFields(ret); return ret; } else if (Std.is(o, cs.system.Type)) { return Type.getClassFields(o); } else { return instanceFields( untyped o.GetType() ); } } private static function instanceFields( c : Class ) : Array { var c = cs.Lib.toNativeType(c); var ret = []; var mis = c.GetFields(new cs.Flags(BindingFlags.Public) | BindingFlags.Instance | BindingFlags.FlattenHierarchy); for (i in 0...mis.Length) { var i = mis[i]; ret.push(i.Name); } return ret; } inline public static function isFunction( f : Dynamic ) : Bool { return Std.is(f, Function); } public static function compare( a : T, b : T ) : Int { return cs.internal.Runtime.compare(a, b); } @:access(cs.internal.Closure) public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool { if (f1 == f2) return true; if (Std.is(f1, Closure) && Std.is(f2, Closure)) { var f1c:Closure = cast f1; var f2c:Closure = cast f2; return Runtime.refEq(f1c.obj, f2c.obj) && f1c.field == f2c.field; } return false; } public static function isObject( v : Dynamic ) : Bool { return v != null && !(Std.is(v, HxEnum) || Std.is(v, Function) || Std.is(v, cs.system.ValueType)); } public static function isEnumValue( v : Dynamic ) : Bool { return v != null && (Std.is(v, HxEnum) || Std.is(v, cs.system.Enum)); } public static function deleteField( o : Dynamic, field : String ) : Bool { var ihx = Lib.as(o,DynamicObject); if (ihx != null) return untyped ihx.__hx_deleteField(field, FieldLookup.hash(field)); return false; } public static function copy( o : T ) : T { var o2 : Dynamic = {}; for( f in Reflect.fields(o) ) Reflect.setField(o2,f,Reflect.field(o,f)); return cast o2; } @:overload(function( f : Array -> Void ) : Dynamic {}) public static function makeVarArgs( f : Array -> Dynamic ) : Dynamic { return new VarArgsFunction(f); } } haxe_3.2.1+dfsg.orig/std/cs/_std/Std.hx0000664000175000017500000001103612607337712017550 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import cs.Boot; import cs.Lib; import cs.internal.Exceptions; @:coreApi @:nativeGen class Std { public static function is( v : Dynamic, t : Dynamic ) : Bool { if (v == null) return t == Dynamic; if (t == null) return false; var clt:cs.system.Type = cast t; if (clt == null) return false; var name:String = cast clt; switch(name) { case "System.Double": return untyped __cs__('v is double || v is int'); case "System.Int32": return untyped __cs__('haxe.lang.Runtime.isInt(v)'); case "System.Boolean": return untyped __cs__('v is bool'); case "System.Object": return true; } return clt.IsAssignableFrom(cs.Lib.getNativeType(v)); } public static function string( s : Dynamic ) : String { if (s == null) return "null"; if (Std.is(s, Bool)) return cast(s, Bool) ? "true" : "false"; return s.ToString(); } public static inline function int( x : Float ) : Int { return cast x; } public static function parseInt( x : String ) : Null { if (x == null) return null; var ret = 0; var base = 10; var i = -1; var len = x.length; if (StringTools.startsWith(x, "0") && len > 2) { var c:Int = cast untyped x[1]; if (c == 'x'.code || c == 'X'.code) { i = 1; base = 16; } } var foundAny = i != -1; var isNeg = false; while (++i < len) { var c = cast(untyped x[i], Int); //fastCodeAt if (!foundAny) { switch(c) { case '-'.code: isNeg = true; continue; case ' '.code, '\t'.code, '\n'.code, '\r'.code, '+'.code: if (isNeg) return null; continue; } } if (c >= '0'.code && c <= '9'.code) { if (!foundAny && c == '0'.code) { foundAny = true; continue; } ret *= base; foundAny = true; ret += c - '0'.code; } else if (base == 16) { if (c >= 'a'.code && c <= 'f'.code) { ret *= base; foundAny = true; ret += c - 'a'.code + 10; } else if (c >= 'A'.code && c <= 'F'.code) { ret *= base; foundAny = true; ret += c - 'A'.code + 10; } else { break; } } else { break; } } if (foundAny) return isNeg ? -ret : ret; else return null; } public static function parseFloat( x : String ) : Float { if (x == null) return Math.NaN; x = StringTools.ltrim(x); var found = false, hasDot = false, hasSign = false, hasE = false, hasESign = false, hasEData = false; var i = -1; inline function getch(i:Int):Int return cast ((untyped x : cs.system.String)[i]); while (++i < x.length) { var chr = getch(i); if (chr >= '0'.code && chr <= '9'.code) { if (hasE) { hasEData = true; } found = true; } else switch (chr) { case 'e'.code | 'E'.code if(!hasE): hasE = true; case '.'.code if (!hasDot): hasDot = true; case '-'.code, '+'.code if (!found && !hasSign): hasSign = true; case '-'.code | '+'.code if (found && !hasESign && hasE && !hasEData): hasESign = true; case _: break; } } if (hasE && !hasEData) { i--; if (hasESign) i--; } if (i != x.length) { x = x.substr(0,i); } return try cs.system.Double.Parse(x, (null : cs.system.IFormatProvider)) catch(e:Dynamic) Math.NaN; } @:extern inline public static function instance( value : T, c : Class ) : S { return cs.Lib.as(value,c); } public static function random( x : Int ) : Int { if (x <= 0) return 0; return untyped Math.rand.Next(x); } } haxe_3.2.1+dfsg.orig/std/cs/_std/String.hx0000664000175000017500000000476012607337712020272 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import cs.StdTypes; @:coreApi extern class String implements ArrayAccess { @:overload private static function Compare(s1:String, s2:String):Int; @:overload private static function Compare(s1:String, s2:String, kind:cs.system.StringComparison):Int; var length(default,null) : Int; function new(string:String) : Void; function toUpperCase() : String; function toLowerCase() : String; function charAt( index : Int) : String; function charCodeAt( index : Int) : Null; function indexOf( str : String, ?startIndex : Int ) : Int; function lastIndexOf( str : String, ?startIndex : Int ) : Int; function split( delimiter : String ) : Array; function substr( pos : Int, ?len : Int ) : String; function substring( startIndex : Int, ?endIndex : Int ) : String; function toString() : String; static function fromCharCode( code : Int ) : String; private function IndexOf(value:String, startIndex:Int, comparisonType:cs.system.StringComparison):Int; private function Replace(oldValue:String, newValue:String):String; private function StartsWith(value:String):Bool; private function EndsWith(value:String):Bool; private function TrimStart():String; private function TrimEnd():String; private function Trim():String; private function CompareTo(obj:Dynamic):Int; @:overload(function(startIndex:Int):String {}) private function Substring(startIndex:Int, length:Int):String; } haxe_3.2.1+dfsg.orig/std/cs/_std/StringBuf.hx0000664000175000017500000000340112607337712020716 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import cs.system.text.StringBuilder; @:coreApi class StringBuf { private var b : StringBuilder; public var length(get,never) : Int; public inline function new() : Void { b = new StringBuilder(); } inline function get_length() : Int { return b.Length; } public inline function add( x : T ) : Void { b.Append(Std.string(x)); } public inline function addSub( s : String, pos : Int, ?len : Int ) : Void { b.Append(s, pos, (len == null) ? (s.length - pos) : len); } public inline function addChar( c : Int ) : Void untyped { b.Append(cast(c, cs.StdTypes.Char16)); } public inline function toString() : String { return b.ToString(); } }haxe_3.2.1+dfsg.orig/std/cs/_std/Sys.hx0000664000175000017500000001057012607337712017576 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import sys.io.Process; import cs.system.Environment; import cs.system.threading.Thread; @:coreApi class Sys { private static var _env:haxe.ds.StringMap; private static var _args:Array; public static function print( v : Dynamic ) : Void { cs.system.Console.Write(v); } public static function println( v : Dynamic ) : Void { cs.system.Console.WriteLine(v); } public static function args() : Array { if (_args == null) { var ret = cs.Lib.array(Environment.GetCommandLineArgs()); ret.shift(); _args = ret; } return _args.copy(); } public static function getEnv( s : String ) : String { return Environment.GetEnvironmentVariable(s); } public static function putEnv( s : String, v : String ) : Void { Environment.SetEnvironmentVariable(s, v); if (_env != null) _env.set(s, v); } public static function environment() : Map { if (_env == null) { var e = _env = new haxe.ds.StringMap(); var nenv = Environment.GetEnvironmentVariables().GetEnumerator(); while (nenv.MoveNext()) { e.set(nenv.Key, nenv.Value); } } return _env; } public static function sleep( seconds : Float ) : Void { Thread.Sleep( Std.int(seconds * 1000) ); } public static function setTimeLocale( loc : String ) : Bool { //TODO C# return false; } public static function getCwd() : String { return cs.system.io.Directory.GetCurrentDirectory(); } public static function setCwd( s : String ) : Void { cs.system.io.Directory.SetCurrentDirectory(s); } public static function systemName() : String { //doing a switch with strings since MacOS might not be available switch(Environment.OSVersion.Platform + "") { case "Unix": return "Linux"; case "Xbox": return "Xbox"; case "MacOSX": return "Mac"; default: var ver = cast(Environment.OSVersion.Platform, Int); if (ver == 4 || ver == 6 || ver == 128) return "Linux"; return "Windows"; } } public static function command( cmd : String, ?args : Array ) : Int { var proc:Process = new Process(cmd, args == null ? [] : args); var ret = proc.exitCode(); proc.close(); return ret; } public static function exit( code : Int ) : Void { Environment.Exit(code); } public static function time() : Float { return Date.now().getTime() / 1000; } public static function cpuTime() : Float { return Environment.TickCount / 1000; } public static inline function executablePath() : String { return cs.system.reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; } public static function getChar( echo : Bool ) : Int { #if !(Xbox || CF || MF) //Xbox, Compact Framework, Micro Framework return cast(cs.system.Console.ReadKey(!echo).KeyChar, Int); #else return -1; #end } public static function stdin() : haxe.io.Input { #if !(Xbox || CF || MF) return new cs.io.NativeInput(cs.system.Console.OpenStandardInput()); #else return null; #end } public static function stdout() : haxe.io.Output { #if !(Xbox || CF || MF) return new cs.io.NativeOutput(cs.system.Console.OpenStandardOutput()); #else return null; #end } public static function stderr() : haxe.io.Output { #if !(Xbox || CF || MF) return new cs.io.NativeOutput(cs.system.Console.OpenStandardError()); #else return null; #end } } haxe_3.2.1+dfsg.orig/std/cs/_std/Type.hx0000664000175000017500000002331512607337712017742 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import cs.Lib; import cs.internal.HxObject; import cs.internal.Runtime; import cs.internal.Function; import cs.Flags; import cs.system.Object; import cs.system.reflection.*; using StringTools; @:keep enum ValueType { TNull; TInt; TFloat; TBool; TObject; TFunction; TClass( c : Class ); TEnum( e : Enum ); TUnknown; } @:keep @:coreApi class Type { public static function getClass( o : T ) : Class untyped { if (Object.ReferenceEquals(o,null) || Std.is(o,DynamicObject) || Std.is(o,cs.system.Type)) return null; return untyped o.GetType(); } public static function getEnum( o : EnumValue ) : Enum untyped { if (Std.is(o, cs.system.Enum) || Std.is(o,HxEnum)) return untyped o.GetType(); return null; } public static function getSuperClass( c : Class ) : Class { var t:cs.system.Type = Lib.toNativeType(c); var base = t.BaseType; if (base == null || base.ToString() == "haxe.lang.HxObject" || base.ToString() == "System.Object") return null; return Lib.fromNativeType(base); } public static function getClassName( c : Class ) : String { var ret:String = cast Lib.toNativeType(c); #if no_root if (ret.length > 10 && StringTools.startsWith(ret, "haxe.root.")) ret = ret.substr(10); #end return switch(ret) { case "System.Int32": "Int"; case "System.Double": "Float"; case "System.String": "String"; case "System.Object": "Dynamic"; case "System.Type": "Class"; default: ret.split("`")[0]; } } public static function getEnumName( e : Enum ) : String { var ret:String = cast Lib.toNativeType(untyped e); #if no_root if (ret.length > 10 && StringTools.startsWith(ret, "haxe.root.")) ret = ret.substr(10); #end if (ret.length == 14 && ret == "System.Boolean") return "Bool"; return ret; } public static function resolveClass( name : String ) : Class { #if no_root if (name.indexOf(".") == -1) name = "haxe.root." + name; #end var t:cs.system.Type = cs.system.Type._GetType(name); #if !CF if (t == null) { var all = cs.system.AppDomain.CurrentDomain.GetAssemblies().GetEnumerator(); while (all.MoveNext()) { var t2:cs.system.reflection.Assembly = all.Current; t = t2.GetType(name); if (t != null) break; } } #end if (t == null) { switch(name) { case #if no_root "haxe.root.Int" #else "Int" #end: return cast Int; case #if no_root "haxe.root.Float" #else "Float" #end: return cast Float; case #if no_root "haxe.root.Class" #else "Class" #end: return cast Class; case #if no_root "haxe.root.Dynamic" #else "Dynamic" #end: return cast Dynamic; case #if no_root "haxe.root.String" #else "String" #end: return cast String; default: return null; } #if !erase_generics } else if (t.IsInterface && cast(untyped __typeof__(IGenericObject), cs.system.Type).IsAssignableFrom(t)) { for (attr in t.GetCustomAttributes(true)) { var g = cs.Lib.as(attr, cs.internal.HxObject.GenericInterface); if (g != null) return Lib.fromNativeType(g.generic); } return Lib.fromNativeType(t); #end } else { return Lib.fromNativeType(t); } } public static function resolveEnum( name : String ) : Enum untyped { if (name == "Bool") return Bool; var t = Lib.toNativeType(resolveClass(name)); if (t != null && t.BaseType.Equals( Lib.toNativeType(cs.system.Enum) ) || Lib.toNativeType(HxEnum).IsAssignableFrom(t)) return t; return null; } public static function createInstance( cl : Class, args : Array ) : T { if (untyped cl == String) return args[0]; var t:cs.system.Type = Lib.toNativeType(cl); if (t.IsInterface) { //may be generic t = Lib.toNativeType(resolveClass(getClassName(cl))); } var ctors = t.GetConstructors(); return Runtime.callMethod(null, cast ctors, ctors.Length, args); } public static function createEmptyInstance( cl : Class ) : T { var t:cs.system.Type = Lib.toNativeType(cl); if (t.IsInterface) { //may be generic t = Lib.toNativeType(resolveClass(getClassName(cl))); } if (Reflect.hasField(cl, "__hx_createEmpty")) return untyped cl.__hx_createEmpty(); if (untyped cl == String) return cast ""; var t:cs.system.Type = Lib.toNativeType(cl); var ctors = t.GetConstructors(); for (c in 0...ctors.Length) { if (ctors[c].GetParameters().Length == 0) { var arr = new cs.NativeArray(1); arr[0] = ctors[c]; return Runtime.callMethod(null, cast arr, arr.Length, []); } } return cs.system.Activator.CreateInstance(t); } public static function createEnum( e : Enum, constr : String, ?params : Array ) : T { if (params == null || params.length == 0) { var ret = cs.internal.Runtime.slowGetField(e, constr, true); if (Reflect.isFunction(ret)) throw 'Constructor $constr needs parameters'; return ret; } else { return cs.internal.Runtime.slowCallField(e,constr,params); } } public static function createEnumIndex( e : Enum, index : Int, ?params : Array ) : T { var constr = getEnumConstructs(e); return createEnum(e, constr[index], params); } public static function getInstanceFields( c : Class ) : Array { if (c == String) return cs.internal.StringExt.StringRefl.fields; var c = cs.Lib.toNativeType(c); var ret = []; var mis = c.GetMembers(new cs.Flags(BindingFlags.Public) | BindingFlags.Instance | BindingFlags.FlattenHierarchy); for (i in 0...mis.Length) { var i = mis[i]; if (Std.is(i, PropertyInfo)) continue; var n = i.Name; if (!n.startsWith('__hx_') && n.fastCodeAt(0) != '.'.code) { switch(n) { case 'Equals' | 'ToString' | 'GetHashCode' | 'GetType': case _: ret.push(n); } } } return ret; } public static function getClassFields( c : Class ) : Array { if (Object.ReferenceEquals(c, String)) { return ['fromCharCode']; } var ret = []; var infos = Lib.toNativeType(c).GetMembers(new Flags(BindingFlags.Public) | BindingFlags.Static); for (i in 0...infos.Length) { var name = infos[i].Name; if (!name.startsWith('__hx_')) { ret.push(name); } } return ret; } public static function getEnumConstructs( e : Enum ) : Array { if (Reflect.hasField(e, "__hx_constructs")) { var ret:Array = cs.Lib.array(untyped e.__hx_constructs); return ret.copy(); } return cs.Lib.array(cs.system.Enum.GetNames(untyped e)); } public static function typeof( v : Dynamic ) : ValueType { if (v == null) return ValueType.TNull; var t:cs.system.Type = cs.Lib.as(v, cs.system.Type); if (t != null) { //class type return ValueType.TObject; } t = v.GetType(); if (t.IsEnum || Std.is(v, HxEnum)) return ValueType.TEnum(cast t); if (t.IsValueType) { var vc:cs.system.IConvertible = cast v; if (vc != null) { switch (vc.GetTypeCode()) { case cs.system.TypeCode.Boolean: return ValueType.TBool; case cs.system.TypeCode.Double: var d:Float = vc.ToDouble(null); if (d >= cs.system.Int32.MinValue && d <= cs.system.Int32.MaxValue && d == vc.ToInt32(null)) return ValueType.TInt; else return ValueType.TFloat; case cs.system.TypeCode.Int32: return ValueType.TInt; default: return ValueType.TClass(cast t); } } else { return ValueType.TClass(cast t); } } if (Std.is(v, IHxObject)) { if (Std.is(v, DynamicObject)) return ValueType.TObject; else if (Std.is(v, HxEnum)) return ValueType.TEnum(cast t); return ValueType.TClass(cast t); } else if (Std.is(v, Function)) { return ValueType.TFunction; } else { return ValueType.TClass(cast t); } } public static function enumEq( a : T, b : T ) : Bool { if (a == null) return b == null; else if (b == null) return false; else return untyped a.Equals(b); } public static function enumConstructor( e : EnumValue ) : String untyped { return Std.is(e, cs.system.Enum) ? e+'' : cast(e,HxEnum).getTag(); } public static function enumParameters( e : EnumValue ) : Array untyped { return Std.is(e, cs.system.Enum) ? [] : cast(e,HxEnum).getParams(); } public static function enumIndex( e : EnumValue ) : Int untyped { if (Std.is(e, cs.system.Enum)) { var values = cs.system.Enum.GetValues(Lib.getNativeType(e)); return cs.system.Array.IndexOf(values, e); } else { return cast(e, HxEnum).index; } } public static function allEnums( e : Enum ) : Array { var ctors = getEnumConstructs(e); var ret = []; for (ctor in ctors) { var v = Reflect.field(e, ctor); if (Std.is(v, e)) ret.push(v); } return ret; } } haxe_3.2.1+dfsg.orig/std/cs/_std/haxe/Int64.hx0000664000175000017500000001637012607337712020655 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; using haxe.Int64; private typedef __Int64 = cs.StdTypes.Int64; @:coreApi abstract Int64(__Int64) from __Int64 to __Int64 { public static inline function make( high : Int32, low : Int32 ) : Int64 return new Int64( (cast(high, __Int64) << 32) | (cast(low, __Int64)& untyped __cs__('0xffffffffL')) ); private inline function new(x : __Int64) this = x; private var val( get, set ) : __Int64; inline function get_val() : __Int64 return this; inline function set_val( x : __Int64 ) : __Int64 return this = x; public var high( get, never ):Int32; public inline function get_high():Int32 return cast(this >> 32); public var low( get, never ):Int32; public inline function get_low():Int32 return cast this; public inline function copy():Int64 return new Int64( this ); @:from public static inline function ofInt( x : Int ) : Int64 return cast x; public static inline function toInt( x : Int64 ) : Int { if( x.val < 0x80000000 || x.val > 0x7FFFFFFF ) throw "Overflow"; return cast x.val; } inline public static function is( val : Dynamic ) : Bool return Std.is(val,cs.system.Int64); public static inline function getHigh( x : Int64 ) : Int32 return cast( x.val >> 32 ); public static inline function getLow( x : Int64 ) : Int32 return cast( x.val ); public static inline function isNeg( x : Int64 ) : Bool return x.val < 0; public static inline function isZero( x : Int64 ) : Bool return x.val == 0; public static inline function compare( a : Int64, b : Int64 ) : Int { if( a.val < b.val ) return -1; if( a.val > b.val ) return 1; return 0; } public static inline function ucompare( a : Int64, b : Int64 ) : Int { if( a.val < 0 ) return ( b.val < 0 ) ? compare( a, b ) : 1; return ( b.val < 0 ) ? -1 : compare( a, b ); } public static inline function toStr( x : Int64 ) : String return '${x.val}'; public static inline function divMod( dividend : Int64, divisor : Int64 ) : { quotient : Int64, modulus : Int64 } return { quotient: dividend / divisor, modulus: dividend % divisor }; private inline function toString() : String return '$this'; @:op(-A) public static function neg( x : Int64 ) : Int64 return -x.val; @:op(++A) private inline function preIncrement() : Int64 return ++this; @:op(A++) private inline function postIncrement() : Int64 return this++; @:op(--A) private inline function preDecrement() : Int64 return --this; @:op(A--) private inline function postDecrement() : Int64 return this--; @:op(A + B) public static inline function add( a : Int64, b : Int64 ) : Int64 return a.val + b.val; @:op(A + B) @:commutative private static inline function addInt( a : Int64, b : Int ) : Int64 return a.val + b; @:op(A - B) public static inline function sub( a : Int64, b : Int64 ) : Int64 return a.val - b.val; @:op(A - B) private static inline function subInt( a : Int64, b : Int ) : Int64 return a.val - b; @:op(A - B) private static inline function intSub( a : Int, b : Int64 ) : Int64 return a - b.val; @:op(A * B) public static inline function mul( a : Int64, b : Int64 ) : Int64 return a.val * b.val; @:op(A * B) @:commutative private static inline function mulInt( a : Int64, b : Int ) : Int64 return a.val * b; @:op(A / B) public static inline function div( a : Int64, b : Int64 ) : Int64 return a.val / b.val; @:op(A / B) private static inline function divInt( a : Int64, b : Int ) : Int64 return a.val / b; @:op(A / B) private static inline function intDiv( a : Int, b : Int64 ) : Int64 return a / b.val; @:op(A % B) public static inline function mod( a : Int64, b : Int64 ) : Int64 return a.val % b.val; @:op(A % B) private static inline function modInt( a : Int64, b : Int ) : Int64 return a.val % b; @:op(A % B) private static inline function intMod( a : Int, b : Int64 ) : Int64 return a % b.val; @:op(A == B) public static inline function eq( a : Int64, b : Int64 ) : Bool return a.val == b.val; @:op(A == B) @:commutative private static inline function eqInt( a : Int64, b : Int ) : Bool return a.val == b; @:op(A != B) public static inline function neq( a : Int64, b : Int64 ) : Bool return a.val != b.val; @:op(A != B) @:commutative private static inline function neqInt( a : Int64, b : Int ) : Bool return a.val != b; @:op(A < B) private static inline function lt( a : Int64, b : Int64 ) : Bool return a.val < b.val; @:op(A < B) private static inline function ltInt( a : Int64, b : Int ) : Bool return a.val < b; @:op(A < B) private static inline function intLt( a : Int, b : Int64 ) : Bool return a < b.val; @:op(A <= B) private static inline function lte( a : Int64, b : Int64 ) : Bool return a.val <= b.val; @:op(A <= B) private static inline function lteInt( a : Int64, b : Int ) : Bool return a.val <= b; @:op(A <= B) private static inline function intLte( a : Int, b : Int64 ) : Bool return a <= b.val; @:op(A > B) private static inline function gt( a : Int64, b : Int64 ) : Bool return a.val > b.val; @:op(A > B) private static inline function gtInt( a : Int64, b : Int ) : Bool return a.val > b; @:op(A > B) private static inline function intGt( a : Int, b : Int64 ) : Bool return a > b.val; @:op(A >= B) private static inline function gte( a : Int64, b : Int64 ) : Bool return a.val >= b.val; @:op(A >= B) private static inline function gteInt( a : Int64, b : Int ) : Bool return a.val >= b; @:op(A >= B) private static inline function intGte( a : Int, b : Int64 ) : Bool return a >= b.val; @:op(~A) private static inline function complement( x : Int64 ) : Int64 return ~x.val; @:op(A & B) public static inline function and( a : Int64, b : Int64 ) : Int64 return a.val & b.val; @:op(A | B) public static inline function or( a : Int64, b : Int64 ) : Int64 return a.val | b.val; @:op(A ^ B) public static inline function xor( a : Int64, b : Int64 ) : Int64 return a.val ^ b.val; @:op(A << B) public static inline function shl( a : Int64, b : Int ) : Int64 return a.val << b; @:op(A >> B) public static inline function shr( a : Int64, b : Int ) : Int64 return a.val >> b; @:op(A >>> B) public static inline function ushr( a : Int64, b : Int ) : Int64 return cast ( (a.val : cs.StdTypes.UInt64) >> b ); } haxe_3.2.1+dfsg.orig/std/cs/_std/haxe/Resource.hx0000664000175000017500000000455412607337712021541 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; @:coreApi class Resource { @:keep static var content : Array; static var paths : Map; @:keep static function getPaths():Map { if (paths != null) return paths; var p = new Map(); var all = cs.Lib.toNativeType(haxe.Resource).Assembly.GetManifestResourceNames(); for (i in 0...all.Length) { var path = all[i]; var name = path.substr(path.indexOf("Resources.") + 10); p.set(name, path); } return paths = p; } public static inline function listNames() : Array { return content.copy(); } @:access(haxe.io.Path.escape) public static function getString( name : String ) : String { name = haxe.io.Path.escape(name, true); var path = getPaths().get(name); var str = cs.Lib.toNativeType(haxe.Resource).Assembly.GetManifestResourceStream(path); if (str != null) return new cs.io.NativeInput(str).readAll().toString(); return null; } @:access(haxe.io.Path.escape) public static function getBytes( name : String ) : haxe.io.Bytes { name = haxe.io.Path.escape(name, true); var path = getPaths().get(name); var str = cs.Lib.toNativeType(haxe.Resource).Assembly.GetManifestResourceStream(path); if (str != null) return new cs.io.NativeInput(str).readAll(); return null; } } haxe_3.2.1+dfsg.orig/std/cs/_std/haxe/ds/IntMap.hx0000664000175000017500000002637312607337712021553 0ustar andyandy00000000000000/* * Copyright (c) 2005, The Haxe Project Contributors * 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. * * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT 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 HAXE PROJECT 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. */ package haxe.ds; import cs.NativeArray; /* * This IntMap implementation is based on khash (https://github.com/attractivechaos/klib/blob/master/khash.h) * Copyright goes to Attractive Chaos and his contributors * * Thanks also to Jonas Malaco Filho for his Haxe-written IntMap code inspired by Python tables. * (https://jonasmalaco.com/fossil/test/jonas-haxe/artifact/887b53126e237d6c68951111d594033403889304) */ @:coreApi class IntMap implements haxe.Constraints.IMap { private static inline var HASH_UPPER = 0.7; private var flags:NativeArray; private var _keys:NativeArray; private var vals:NativeArray; private var nBuckets:Int; private var size:Int; private var nOccupied:Int; private var upperBound:Int; #if !no_map_cache private var cachedKey:Int; private var cachedIndex:Int; #end public function new() : Void { #if !no_map_cache cachedIndex = -1; #end } public function set( key : Int, value : T ) : Void { var x:Int; if (nOccupied >= upperBound) { if (nBuckets > (size << 1)) resize(nBuckets - 1); //clear "deleted" elements else resize(nBuckets + 1); } var flags = flags, _keys = _keys; { var mask = nBuckets - 1; var site = x = nBuckets; var k = hash(key); var i = k & mask; var delKey = -1; //for speed up if (flagIsEmpty(flags, i)) { x = i; } else { var inc = getInc(k, mask); var last = i; while (! (flagIsEmpty(flags, i) || _keys[i] == key) ) { if (delKey == -1 && flagIsDel(flags,i)) delKey = i; i = (i + inc) & mask; #if DEBUG_HASHTBL if (i == last) { throw "assert"; } #end } if (flagIsEmpty(flags,i) && delKey != -1) x = delKey; else x = i; } } if (flagIsEmpty(flags, x)) { _keys[x] = key; vals[x] = value; setIsBothFalse(flags, x); size++; nOccupied++; } else if (flagIsDel(flags, x)) { _keys[x] = key; vals[x] = value; setIsBothFalse(flags, x); size++; } else { assert(_keys[x] == key); vals[x] = value; } } @:final private function lookup( key : Int ) : Int { if (nBuckets != 0) { var flags = flags, _keys = _keys; var mask = nBuckets - 1, k = hash(key); var i = k & mask; var inc = getInc(k, mask); /* inc == 1 for linear probing */ var last = i; while (!flagIsEmpty(flags, i) && (flagIsDel(flags, i) || _keys[i] != key)) { i = (i + inc) & mask; if (i == last) return -1; } return isEither(flags, i) ? -1 : i; } return -1; } public function get( key : Int ) : Null { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return vals[idx]; } return null; } private function getDefault( key : Int, def : T ) : T { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return vals[idx]; } return def; } public function exists( key : Int ) : Bool { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return true; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return true; } return false; } public function remove( key : Int ) : Bool { var idx = -1; #if !no_map_cache if (! (cachedKey == key && ( (idx = cachedIndex) != -1 ))) #end { idx = lookup(key); } if (idx == -1) { return false; } else { #if !no_map_cache if (cachedKey == key) cachedIndex = -1; #end if (!isEither(flags, idx)) { setIsDelTrue(flags, idx); --size; vals[idx] = null; _keys[idx] = 0; } return true; } } @:final private function resize(newNBuckets:Int) : Void { //This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. var newFlags = null; var j = 1; { newNBuckets = roundUp(newNBuckets); if (newNBuckets < 4) newNBuckets = 4; if (size >= (newNBuckets * HASH_UPPER + 0.5)) /* requested size is too small */ { j = 0; } else { /* hash table size to be changed (shrink or expand); rehash */ var nfSize = flagsSize(newNBuckets); newFlags = new NativeArray( nfSize ); for (i in 0...nfSize) newFlags[i] = 0xaaaaaaaa; if (nBuckets < newNBuckets) //expand { var k = new NativeArray(newNBuckets); if (_keys != null) arrayCopy(_keys, 0, k, 0, nBuckets); _keys = k; var v = new NativeArray(newNBuckets); if (vals != null) arrayCopy(vals, 0, v, 0, nBuckets); vals = v; } //otherwise shrink } } if (j != 0) { //rehashing is required #if !no_map_cache //resetting cache cachedKey = 0; cachedIndex = -1; #end j = -1; var nBuckets = nBuckets, _keys = _keys, vals = vals, flags = flags; var newMask = newNBuckets - 1; while (++j < nBuckets) { if (!isEither(flags, j)) { var key = _keys[j]; var val = vals[j]; setIsDelTrue(flags, j); while (true) /* kick-out process; sort of like in Cuckoo hashing */ { var k = hash(key); var inc = getInc(k, newMask); var i = k & newMask; while (!flagIsEmpty(newFlags, i)) i = (i + inc) & newMask; setIsEmptyFalse(newFlags, i); if (i < nBuckets && !isEither(flags, i)) /* kick out the existing element */ { { var tmp = _keys[i]; _keys[i] = key; key = tmp; } { var tmp = vals[i]; vals[i] = val; val = tmp; } setIsDelTrue(flags, i); /* mark it as deleted in the old hash table */ } else { /* write the element and jump out of the loop */ _keys[i] = key; vals[i] = val; break; } } } } if (nBuckets > newNBuckets) /* shrink the hash table */ { { var k = new NativeArray(newNBuckets); arrayCopy(_keys, 0, k, 0, newNBuckets); this._keys = k; } { var v = new NativeArray(newNBuckets); arrayCopy(vals, 0, v, 0, newNBuckets); this.vals = v; } } this.flags = newFlags; this.nBuckets = newNBuckets; this.nOccupied = size; this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5); } } /** Returns an iterator of all keys in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public inline function keys() : Iterator { return new IntMapKeyIterator(this); } /** Returns an iterator of all values in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public inline function iterator() : Iterator { return new IntMapValueIterator(this); } /** Returns an displayable representation of the hashtable content. **/ public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(i); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } private static inline function assert(x:Bool):Void { #if debug if (!x) throw "assert failed"; #end } private static inline function defaultK():Int return 0; private static inline function arrayCopy(sourceArray:cs.system.Array, sourceIndex:Int, destinationArray:cs.system.Array, destinationIndex:Int, length:Int):Void cs.system.Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); private static inline function getInc(k:Int, mask:Int):Int return (((k) >> 3 ^ (k) << 3) | 1) & (mask); private static inline function hash(i:Int):Int return i; private static inline function flagIsEmpty(flag:NativeArray, i:Int):Bool return ( (flag[i >> 4] >>> ((i & 0xf) << 1)) & 2 ) != 0; private static inline function flagIsDel(flag:NativeArray, i:Int):Bool return ((flag[i >> 4] >>> ((i & 0xf) << 1)) & 1) != 0; private static inline function isEither(flag:NativeArray, i:Int):Bool return ((flag[i >> 4] >>> ((i & 0xf) << 1)) & 3) != 0; private static inline function setIsDelFalse(flag:NativeArray, i:Int):Void flag[i >> 4] &= ~(1 << ((i & 0xf) << 1)); private static inline function setIsEmptyFalse(flag:NativeArray, i:Int):Void flag[i >> 4] &= ~(2 << ((i & 0xf) << 1)); private static inline function setIsBothFalse(flag:NativeArray, i:Int):Void flag[i >> 4] &= ~(3 << ((i & 0xf) << 1)); private static inline function setIsDelTrue(flag:NativeArray, i:Int):Void flag[i >> 4] |= 1 << ((i & 0xf) << 1); private static inline function roundUp(x:Int):Int { --x; x |= (x) >>> 1; x |= (x) >>> 2; x |= (x) >>> 4; x |= (x) >>> 8; x |= (x) >>> 16; return ++x; } private static inline function flagsSize(m:Int):Int return ((m) < 16? 1 : (m) >> 4); } @:access(haxe.ds.IntMap) @:final private class IntMapKeyIterator { var m:IntMap; var i:Int; var len:Int; public function new(m:IntMap) { this.i = 0; this.m = m; this.len = m.nBuckets; } public function hasNext():Bool { for (j in i...len) { if (!IntMap.isEither(m.flags, j)) { i = j; return true; } } return false; } public function next():Int { var ret = m._keys[i]; #if !no_map_cache m.cachedIndex = i; m.cachedKey = ret; #end i++; return ret; } } @:access(haxe.ds.IntMap) @:final private class IntMapValueIterator { var m:IntMap; var i:Int; var len:Int; public function new(m:IntMap) { this.i = 0; this.m = m; this.len = m.nBuckets; } public function hasNext():Bool { for (j in i...len) { if (!IntMap.isEither(m.flags, j)) { i = j; return true; } } return false; } public inline function next():T { return m.vals[i++]; } } haxe_3.2.1+dfsg.orig/std/cs/_std/haxe/ds/ObjectMap.hx0000664000175000017500000002674212607337712022227 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; import cs.NativeArray; @:coreApi class ObjectMap implements haxe.Constraints.IMap { @:extern private static inline var HASH_UPPER = 0.77; @:extern private static inline var FLAG_EMPTY = 0; @:extern private static inline var FLAG_DEL = 1; /** * This is the most important structure here and the reason why it's so fast. * It's an array of all the hashes contained in the table. These hashes cannot be 0 nor 1, * which stand for "empty" and "deleted" states. * * The lookup algorithm will keep looking until a 0 or the key wanted is found; * The insertion algorithm will do the same but will also break when FLAG_DEL is found; */ private var hashes:NativeArray; private var _keys:NativeArray; private var vals:NativeArray; private var nBuckets:Int; private var size:Int; private var nOccupied:Int; private var upperBound:Int; #if !no_map_cache private var cachedKey:K; private var cachedIndex:Int; #end #if DEBUG_HASHTBL private var totalProbes:Int; private var probeTimes:Int; private var sameHash:Int; private var maxProbe:Int; #end public function new() : Void { #if !no_map_cache cachedIndex = -1; #end } public function set( key : K, value : V ) : Void { var x:Int, k:Int; if (nOccupied >= upperBound) { if (nBuckets > (size << 1)) resize(nBuckets - 1); //clear "deleted" elements else resize(nBuckets + 2); } var hashes = hashes, keys = _keys, hashes = hashes; { var mask = (nBuckets == 0) ? 0 : nBuckets - 1; var site = x = nBuckets; k = hash(key); var i = k & mask, nProbes = 0; var delKey = -1; //for speed up if (isEmpty(hashes[i])) { x = i; } else { //var inc = getInc(k, mask); var last = i, flag; while(! (isEmpty(flag = hashes[i]) || (flag == k && _keys[i] == key)) ) { if (isDel(flag) && delKey == -1) delKey = i; i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } if (isEmpty(flag) && delKey != -1) x = delKey; else x = i; } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end } var flag = hashes[x]; if (isEmpty(flag)) { keys[x] = key; vals[x] = value; hashes[x] = k; size++; nOccupied++; } else if (isDel(flag)) { keys[x] = key; vals[x] = value; hashes[x] = k; size++; } else { assert(_keys[x] == key); vals[x] = value; } #if !no_map_cache cachedIndex = x; cachedKey = key; #end } @:final private function lookup( key : K ) : Int { if (nBuckets != 0) { var hashes = hashes, keys = _keys; var mask = nBuckets - 1, hash = hash(key), k = hash, nProbes = 0; var i = k & mask; var last = i, flag; //var inc = getInc(k, mask); while (!isEmpty(flag = hashes[i]) && (isDel(flag) || flag != k || keys[i] != key)) { i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end return isEither(flag) ? -1 : i; } return -1; } @:final @:private function resize(newNBuckets:Int) : Void { //This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. var newHash = null; var j = 1; { newNBuckets = roundUp(newNBuckets); if (newNBuckets < 4) newNBuckets = 4; if (size >= (newNBuckets * HASH_UPPER + 0.5)) /* requested size is too small */ { j = 0; } else { /* hash table size to be changed (shrink or expand); rehash */ var nfSize = newNBuckets; newHash = new NativeArray( nfSize ); if (nBuckets < newNBuckets) //expand { var k = new NativeArray(newNBuckets); if (_keys != null) arrayCopy(_keys, 0, k, 0, nBuckets); _keys = k; var v = new NativeArray(newNBuckets); if (vals != null) arrayCopy(vals, 0, v, 0, nBuckets); vals = v; } //otherwise shrink } } if (j != 0) { //rehashing is required #if !no_map_cache //resetting cache cachedKey = null; cachedIndex = -1; #end j = -1; var nBuckets = nBuckets, _keys = _keys, vals = vals, hashes = hashes; var newMask = newNBuckets - 1; while (++j < nBuckets) { var k; if (!isEither(k = hashes[j])) { var key = _keys[j]; var val = vals[j]; hashes[j] = FLAG_DEL; while (true) /* kick-out process; sort of like in Cuckoo hashing */ { var nProbes = 0; //var inc = getInc(k, newMask); var i = k & newMask; while (!isEmpty(newHash[i])) i = (i + ++nProbes) & newMask; newHash[i] = k; if (i < nBuckets && !isEither(k = hashes[i])) /* kick out the existing element */ { { var tmp = _keys[i]; _keys[i] = key; key = tmp; } { var tmp = vals[i]; vals[i] = val; val = tmp; } hashes[i] = FLAG_DEL; /* mark it as deleted in the old hash table */ } else { /* write the element and jump out of the loop */ _keys[i] = key; vals[i] = val; break; } } } } if (nBuckets > newNBuckets) /* shrink the hash table */ { { var k = new NativeArray(newNBuckets); arrayCopy(_keys, 0, k, 0, newNBuckets); this._keys = k; } { var v = new NativeArray(newNBuckets); arrayCopy(vals, 0, v, 0, newNBuckets); this.vals = v; } } this.hashes = newHash; this.nBuckets = newNBuckets; this.nOccupied = size; this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5); } } public function get( key : K ) : Null { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return vals[idx]; } return null; } private function getDefault( key : K, def : V ) : V { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return vals[idx]; } return def; } public function exists( key : K ) : Bool { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return true; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return true; } return false; } public function remove( key : K ) : Bool { var idx = -1; #if !no_map_cache if (! (cachedKey == key && ( (idx = cachedIndex) != -1 ))) #end { idx = lookup(key); } if (idx == -1) { return false; } else { #if !no_map_cache if (cachedKey == key) cachedIndex = -1; #end hashes[idx] = FLAG_DEL; _keys[idx] = null; vals[idx] = null; --size; return true; } } /** Returns an iterator of all keys in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function keys() : Iterator { return new ObjectMapKeyIterator(this); } /** Returns an iterator of all values in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function iterator() : Iterator { return new ObjectMapValueIterator(this); } /** Returns an displayable representation of the hashtable content. **/ public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(Std.string(i)); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } @:extern private static inline function roundUp(x:Int):Int { --x; x |= (x) >>> 1; x |= (x) >>> 2; x |= (x) >>> 4; x |= (x) >>> 8; x |= (x) >>> 16; return ++x; } @:extern private static inline function getInc(k:Int, mask:Int):Int //return 1 for linear probing return (((k) >> 3 ^ (k) << 3) | 1) & (mask); @:extern private static inline function isEither(v:HashType):Bool return (v & 0xFFFFFFFE) == 0; @:extern private static inline function isEmpty(v:HashType):Bool return v == FLAG_EMPTY; @:extern private static inline function isDel(v:HashType):Bool return v == FLAG_DEL; //guarantee: Whatever this function is, it will never return 0 nor 1 @:extern private static inline function hash(s:K):HashType { var k:Int = untyped s.GetHashCode(); //k *= 357913941; //k ^= k << 24; //k += ~357913941; //k ^= k >> 31; //k ^= k << 31; k = (k+0x7ed55d16) + (k<<12); k = (k^0xc761c23c) ^ (k>>19); k = (k+0x165667b1) + (k<<5); k = (k+0xd3a2646c) ^ (k<<9); k = (k+0xfd7046c5) + (k<<3); k = (k^0xb55a4f09) ^ (k>>16); var ret = k; if (isEither(ret)) { if (ret == 0) ret = 2; else ret = 0xFFFFFFFF; } return ret; } @:extern private static inline function arrayCopy(sourceArray:cs.system.Array, sourceIndex:Int, destinationArray:cs.system.Array, destinationIndex:Int, length:Int):Void cs.system.Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); @:extern private static inline function assert(x:Bool):Void { #if DEBUG_HASHTBL if (!x) throw "assert failed"; #end } } @:access(haxe.ds.ObjectMap) @:final @:keep private class ObjectMapKeyIterator { var m:ObjectMap; var i:Int; var len:Int; public function new(m:ObjectMap) { this.i = 0; this.m = m; this.len = m.nBuckets; } public function hasNext():Bool { for (j in i...len) { if (!ObjectMap.isEither(m.hashes[j])) { i = j; return true; } } return false; } public function next() : T { var ret = m._keys[i]; #if !no_map_cache m.cachedIndex = i; m.cachedKey = ret; #end i = i + 1; return ret; } } @:access(haxe.ds.ObjectMap) @:final @:keep private class ObjectMapValueIterator { var m:ObjectMap; var i:Int; var len:Int; public function new(m:ObjectMap) { this.i = 0; this.m = m; this.len = m.nBuckets; } public function hasNext() : Bool { for (j in i...len) { if (!ObjectMap.isEither(m.hashes[j])) { i = j; return true; } } return false; } public inline function next():T { var ret = m.vals[i]; i = i + 1; return ret; } } private typedef HashType = Int; haxe_3.2.1+dfsg.orig/std/cs/_std/haxe/ds/StringMap.hx0000664000175000017500000002663712607337712022272 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; import cs.NativeArray; @:coreApi class StringMap implements haxe.Constraints.IMap { @:extern private static inline var HASH_UPPER = 0.77; @:extern private static inline var FLAG_EMPTY = 0; @:extern private static inline var FLAG_DEL = 1; /** * This is the most important structure here and the reason why it's so fast. * It's an array of all the hashes contained in the table. These hashes cannot be 0 nor 1, * which stand for "empty" and "deleted" states. * * The lookup algorithm will keep looking until a 0 or the key wanted is found; * The insertion algorithm will do the same but will also break when FLAG_DEL is found; */ private var hashes:NativeArray; private var _keys:NativeArray; private var vals:NativeArray; private var nBuckets:Int; private var size:Int; private var nOccupied:Int; private var upperBound:Int; #if !no_map_cache private var cachedKey:String; private var cachedIndex:Int; #end #if DEBUG_HASHTBL private var totalProbes:Int; private var probeTimes:Int; private var sameHash:Int; private var maxProbe:Int; #end public function new() : Void { #if !no_map_cache cachedIndex = -1; #end } public function set( key : String, value : T ) : Void { var x:Int, k:Int; if (nOccupied >= upperBound) { if (nBuckets > (size << 1)) resize(nBuckets - 1); //clear "deleted" elements else resize(nBuckets + 2); } var hashes = hashes, keys = _keys, hashes = hashes; { var mask = (nBuckets == 0) ? 0 : nBuckets - 1; var site = x = nBuckets; k = hash(key); var i = k & mask, nProbes = 0; var delKey = -1; //for speed up if (isEmpty(hashes[i])) { x = i; } else { var last = i, flag; while(! (isEmpty(flag = hashes[i]) || (flag == k && _keys[i] == key)) ) { if (isDel(flag) && delKey == -1) delKey = i; i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } if (isEmpty(flag) && delKey != -1) x = delKey; else x = i; } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end } var flag = hashes[x]; if (isEmpty(flag)) { keys[x] = key; vals[x] = value; hashes[x] = k; size++; nOccupied++; } else if (isDel(flag)) { keys[x] = key; vals[x] = value; hashes[x] = k; size++; } else { assert(_keys[x] == key); vals[x] = value; } #if !no_map_cache cachedIndex = x; cachedKey = key; #end } @:final private function lookup( key : String ) : Int { if (nBuckets != 0) { var hashes = hashes, keys = _keys; var mask = nBuckets - 1, hash = hash(key), k = hash, nProbes = 0; var i = k & mask; var last = i, flag; //var inc = getInc(k, mask); while (!isEmpty(flag = hashes[i]) && (isDel(flag) || flag != k || keys[i] != key)) { i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end return isEither(flag) ? -1 : i; } return -1; } @:final @:private function resize(newNBuckets:Int) : Void { //This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. var newHash = null; var j = 1; { newNBuckets = roundUp(newNBuckets); if (newNBuckets < 4) newNBuckets = 4; if (size >= (newNBuckets * HASH_UPPER + 0.5)) /* requested size is too small */ { j = 0; } else { /* hash table size to be changed (shrink or expand); rehash */ var nfSize = newNBuckets; newHash = new NativeArray( nfSize ); if (nBuckets < newNBuckets) //expand { var k = new NativeArray(newNBuckets); if (_keys != null) arrayCopy(_keys, 0, k, 0, nBuckets); _keys = k; var v = new NativeArray(newNBuckets); if (vals != null) arrayCopy(vals, 0, v, 0, nBuckets); vals = v; } //otherwise shrink } } if (j != 0) { //rehashing is required //resetting cache #if !no_map_cache cachedKey = null; cachedIndex = -1; #end j = -1; var nBuckets = nBuckets, _keys = _keys, vals = vals, hashes = hashes; var newMask = newNBuckets - 1; while (++j < nBuckets) { var k; if (!isEither(k = hashes[j])) { var key = _keys[j]; var val = vals[j]; hashes[j] = FLAG_DEL; while (true) /* kick-out process; sort of like in Cuckoo hashing */ { var nProbes = 0; //var inc = getInc(k, newMask); var i = k & newMask; while (!isEmpty(newHash[i])) i = (i + ++nProbes) & newMask; newHash[i] = k; if (i < nBuckets && !isEither(k = hashes[i])) /* kick out the existing element */ { { var tmp = _keys[i]; _keys[i] = key; key = tmp; } { var tmp = vals[i]; vals[i] = val; val = tmp; } hashes[i] = FLAG_DEL; /* mark it as deleted in the old hash table */ } else { /* write the element and jump out of the loop */ _keys[i] = key; vals[i] = val; break; } } } } if (nBuckets > newNBuckets) /* shrink the hash table */ { { var k = new NativeArray(newNBuckets); arrayCopy(_keys, 0, k, 0, newNBuckets); this._keys = k; } { var v = new NativeArray(newNBuckets); arrayCopy(vals, 0, v, 0, newNBuckets); this.vals = v; } } this.hashes = newHash; this.nBuckets = newNBuckets; this.nOccupied = size; this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5); } } public function get( key : String ) : Null { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return vals[idx]; } return null; } private function getDefault( key : String, def : T ) : T { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return vals[idx]; } return def; } public function exists( key : String ) : Bool { var idx = -1; #if !no_map_cache if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return true; } #end idx = lookup(key); if (idx != -1) { #if !no_map_cache cachedKey = key; cachedIndex = idx; #end return true; } return false; } public function remove( key : String ) : Bool { var idx = -1; #if !no_map_cache if (! (cachedKey == key && ( (idx = cachedIndex) != -1 ))) #end { idx = lookup(key); } if (idx == -1) { return false; } else { #if !no_map_cache if (cachedKey == key) cachedIndex = -1; #end hashes[idx] = FLAG_DEL; _keys[idx] = null; vals[idx] = null; --size; return true; } } /** Returns an iterator of all keys in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public inline function keys() : Iterator { return new StringMapKeyIterator(this); } /** Returns an iterator of all values in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public inline function iterator() : Iterator { return new StringMapValueIterator(this); } /** Returns an displayable representation of the hashtable content. **/ public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(i); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } @:extern private static inline function roundUp(x:Int):Int { --x; x |= (x) >>> 1; x |= (x) >>> 2; x |= (x) >>> 4; x |= (x) >>> 8; x |= (x) >>> 16; return ++x; } @:extern private static inline function getInc(k:Int, mask:Int):Int //return 1 for linear probing return (((k) >> 3 ^ (k) << 3) | 1) & (mask); @:extern private static inline function isEither(v:HashType):Bool return (v & 0xFFFFFFFE) == 0; @:extern private static inline function isEmpty(v:HashType):Bool return v == FLAG_EMPTY; @:extern private static inline function isDel(v:HashType):Bool return v == FLAG_DEL; //guarantee: Whatever this function is, it will never return 0 nor 1 @:extern private static inline function hash(s:String):HashType { var k:Int = untyped s.GetHashCode(); //k *= 357913941; //k ^= k << 24; //k += ~357913941; //k ^= k >> 31; //k ^= k << 31; k = (k+0x7ed55d16) + (k<<12); k = (k^0xc761c23c) ^ (k>>19); k = (k+0x165667b1) + (k<<5); k = (k+0xd3a2646c) ^ (k<<9); k = (k+0xfd7046c5) + (k<<3); k = (k^0xb55a4f09) ^ (k>>16); var ret = k; if (isEither(ret)) { if (ret == 0) ret = 2; else ret = 0xFFFFFFFF; } return ret; } @:extern private static inline function arrayCopy(sourceArray:cs.system.Array, sourceIndex:Int, destinationArray:cs.system.Array, destinationIndex:Int, length:Int):Void cs.system.Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); @:extern private static inline function assert(x:Bool):Void { #if DEBUG_HASHTBL if (!x) throw "assert failed"; #end } } private typedef HashType = Int; @:final @:access(haxe.ds.StringMap) private class StringMapKeyIterator { var m:StringMap; var i:Int; var len:Int; public function new(m:StringMap) { this.m = m; this.i = 0; this.len = m.nBuckets; } public function hasNext():Bool { for (j in i...len) { if (!StringMap.isEither(m.hashes[j])) { i = j; return true; } } return false; } public function next():String { var ret = m._keys[i]; #if !no_map_cache m.cachedIndex = i; m.cachedKey = ret; #end i++; return ret; } } @:final @:access(haxe.ds.StringMap) private class StringMapValueIterator { var m:StringMap; var i:Int; var len:Int; public function new(m:StringMap) { this.m = m; this.i = 0; this.len = m.nBuckets; } public function hasNext():Bool { for (j in i...len) { if (!StringMap.isEither(m.hashes[j])) { i = j; return true; } } return false; } public inline function next():T { return m.vals[i++]; } } haxe_3.2.1+dfsg.orig/std/cs/_std/haxe/ds/WeakMap.hx20000664000175000017500000003127712607337712021771 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; import cs.NativeArray; import cs.system.WeakReference; // This implementation works by lazily evaluating the weak references, and only cleaning them up when needed. @:coreApi class WeakMap implements haxe.Constraints.IMap { @:extern private static inline var HASH_UPPER = 0.77; @:extern private static inline var FLAG_EMPTY = 0; @:extern private static inline var FLAG_DEL = 1; /** * This is the most important structure here and the reason why it's so fast. * It's an array of all the hashes contained in the table. These hashes cannot be 0 nor 1, * which stand for "empty" and "deleted" states. * * The lookup algorithm will keep looking until a 0 or the key wanted is found; * The insertion algorithm will do the same but will also break when FLAG_DEL is found; */ private var hashes:NativeArray; private var entries:NativeArray>; private var nBuckets:Int; private var size:Int; private var nOccupied:Int; private var upperBound:Int; private var cachedEntry:Entry; private var cachedIndex:Int; #if DEBUG_HASHTBL private var totalProbes:Int; private var probeTimes:Int; private var sameHash:Int; private var maxProbe:Int; #end public function new() : Void { cachedIndex = -1; } @:final private function checkSize():Void { //iterate over the hashes and remove dead references var size = size, entries = entries, hashes = hashes; if (entries == null) return; for (i in 0...entries.Length) { var e = entries[i]; if (e != null && e.Target == null) { --size; hashes[i] = FLAG_DEL; entries[i] = null; } } this.size = size; } public function set( key : K, value : V ) : Void { var x:Int, k:Int; if (nOccupied >= upperBound) { if (nBuckets > (size << 1)) resize(nBuckets - 1); //clear "deleted" elements else resize(nBuckets + 2); } k = hash(key); var hashes = hashes, entries = entries; { var mask = (nBuckets == 0) ? 0 : nBuckets - 1; var site = x = nBuckets; var i = k & mask, nProbes = 0; //for speed up var delKey = -1; if (isEmpty(hashes[i])) { x = i; } else { //var inc = getInc(k, mask); var last = i, flag; while(! (isEmpty(flag = hashes[i]) || (flag == k && entries[i].keyEquals(key) )) ) { if (delKey == -1 && isDel(flag)) delKey = i; var entry = entries[i]; if (entry.Target == null) { hashes[i] = FLAG_DEL; entries[i] = null; --size; if (delKey == -1) delKey = i; } i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } if (isEmpty(flag) && delKey != -1) x = delKey; else x = i; } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end } var flag = hashes[x], entry = new Entry(key,value,k); if (isEmpty(flag)) { entries[x] = entry; hashes[x] = k; size++; nOccupied++; } else if (isDel(flag)) { entries[x] = entry; hashes[x] = k; size++; } else { assert(entries[x].keyEquals(key)); entries[x] = entry; } cachedIndex = x; cachedEntry = entry; } @:final private function lookup( key : K ) : Int { if (nBuckets != 0) { var hashes = hashes, entries = entries; var mask = nBuckets - 1, hash = hash(key), k = hash, nProbes = 0; var i = k & mask; var last = i, flag; //var inc = getInc(k, mask); while (!isEmpty(flag = hashes[i]) && (isDel(flag) || flag != k || !entries[i].keyEquals(key))) { if (!isDel(flag)) { var entry = entries[i]; if (entry.Target == null) { entries[i] = null; hashes[i] = FLAG_DEL; --size; } } i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end return isEither(flag) ? -1 : i; } return -1; } @:final @:private function resize(newNBuckets:Int) : Void { //This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. var newHash = null; var j = 1; { newNBuckets = roundUp(newNBuckets); if (newNBuckets < 4) newNBuckets = 4; if (size >= (newNBuckets * HASH_UPPER + 0.5)) /* requested size is too small */ { j = 0; } else { /* hash table size to be changed (shrink or expand); rehash */ var nfSize = newNBuckets; newHash = new NativeArray( nfSize ); if (nBuckets < newNBuckets) //expand { var e = new NativeArray(newNBuckets); if (entries != null) arrayCopy(entries, 0, e, 0, nBuckets); entries = e; } //otherwise shrink } } if (j != 0) { //rehashing is required //resetting cache cachedEntry = null; cachedIndex = -1; j = -1; var nBuckets = nBuckets, entries = entries, hashes = hashes; var newMask = newNBuckets - 1; while (++j < nBuckets) { var k; if (!isEither(k = hashes[j])) { var entry = entries[j]; if (entry.Target != null) { hashes[j] = FLAG_DEL; while (true) /* kick-out process; sort of like in Cuckoo hashing */ { var nProbes = 0; var i = k & newMask; while (!isEmpty(newHash[i])) i = (i + ++nProbes) & newMask; newHash[i] = k; if (i < nBuckets && !isEither(k = hashes[i])) /* kick out the existing element */ { { var tmp = entries[i]; entries[i] = entry; entry = tmp; } hashes[i] = FLAG_DEL; /* mark it as deleted in the old hash table */ } else { /* write the element and jump out of the loop */ entries[i] = entry; break; } } } } } if (nBuckets > newNBuckets) /* shrink the hash table */ { { var e = new NativeArray(newNBuckets); arrayCopy(entries, 0, e, 0, newNBuckets); this.entries = e; } } this.hashes = newHash; this.nBuckets = newNBuckets; this.nOccupied = size; this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5); } } public function get( key : K ) : Null { var idx = -1; if (cachedEntry != null && cachedEntry.keyEquals(key) && ( (idx = cachedIndex) != -1 )) { return cachedEntry.value; } idx = lookup(key); if (idx != -1) { var entry = entries[idx]; cachedEntry = entry; cachedIndex = idx; return entry.value; } return null; } private function getDefault( key : K, def : V ) : V { var idx = -1; if (cachedEntry != null && cachedEntry.keyEquals(key) && ( (idx = cachedIndex) != -1 )) { return cachedEntry.value; } idx = lookup(key); if (idx != -1) { var entry = entries[idx]; cachedEntry = entry; cachedIndex = idx; return entry.value; } return def; } public function exists( key : K ) : Bool { var idx = -1; if (cachedEntry != null && cachedEntry.keyEquals(key) && ( (idx = cachedIndex) != -1 )) { return true; } idx = lookup(key); if (idx != -1) { var entry = entries[idx]; cachedEntry = entry; cachedIndex = idx; return true; } return false; } public function remove( key : K ) : Bool { var idx = -1; if ( !(cachedEntry != null && cachedEntry.keyEquals(key) && ( (idx = cachedIndex) != -1 )) ) { idx = lookup(key); } if (idx == -1) { return false; } else { if (cachedEntry != null && cachedEntry.keyEquals(key)) { cachedIndex = -1; cachedEntry = null; } hashes[idx] = FLAG_DEL; entries[idx] = null; --size; return true; } } /** Returns an iterator of all keys in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function keys() : Iterator { var i = 0; var len = nBuckets; var lastKey = null; //keep a strong reference to the key while iterating, so it can't be collected while iterating return { hasNext: function() { for (j in i...len) { if (!isEither(hashes[j])) { var entry = entries[j]; var last = entry.Target; if (last != null) { lastKey = last; cachedIndex = i; cachedEntry = entry; i = j; return true; } else { --size; hashes[j] = FLAG_DEL; entries[j] = null; } } } return false; }, next: function() { i = i + 1; return lastKey; } }; } /** Returns an iterator of all values in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function iterator() : Iterator { var i = 0; var len = nBuckets; var lastKey = null; //keep a strong reference to the key while iterating, so it can't be collected while iterating return { hasNext: function() { for (j in i...len) { if (!isEither(hashes[j])) { var entry = entries[j]; var last = entry.Target; if (last != null) { lastKey = last; cachedIndex = i; cachedEntry = entry; i = j; return true; } else { --size; hashes[j] = FLAG_DEL; entries[j] = null; } } } return false; }, next: function() { var ret = entries[i].value; i = i + 1; return ret; } }; } /** Returns an displayable representation of the hashtable content. **/ public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(Std.string(i)); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } @:extern private static inline function roundUp(x:Int):Int { --x; x |= (x) >>> 1; x |= (x) >>> 2; x |= (x) >>> 4; x |= (x) >>> 8; x |= (x) >>> 16; return ++x; } @:extern private static inline function getInc(k:Int, mask:Int):Int //return 1 for linear probing return (((k) >> 3 ^ (k) << 3) | 1) & (mask); @:extern private static inline function isEither(v:HashType):Bool return (v & 0xFFFFFFFE) == 0; @:extern private static inline function isEmpty(v:HashType):Bool return v == FLAG_EMPTY; @:extern private static inline function isDel(v:HashType):Bool return v == FLAG_DEL; //guarantee: Whatever this function is, it will never return 0 nor 1 @:extern private static inline function hash(s:Dynamic):HashType { var k:Int = untyped s.GetHashCode(); //k *= 357913941; //k ^= k << 24; //k += ~357913941; //k ^= k >> 31; //k ^= k << 31; // k = (k+0x7ed55d16) + (k<<12); // k = (k^0xc761c23c) ^ (k>>19); // k = (k+0x165667b1) + (k<<5); // k = (k+0xd3a2646c) ^ (k<<9); // k = (k+0xfd7046c5) + (k<<3); // k = (k^0xb55a4f09) ^ (k>>16); var ret = k; if (isEither(ret)) { if (ret == 0) ret = 2; else ret = 0xFFFFFFFF; } return ret; } @:extern private static inline function arrayCopy(sourceArray:cs.system.Array, sourceIndex:Int, destinationArray:cs.system.Array, destinationIndex:Int, length:Int):Void cs.system.Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); @:extern private static inline function assert(x:Bool):Void { #if DEBUG_HASHTBL if (!x) throw "assert failed"; #end } } private class Entry extends WeakReference { public var value:V; public var hash(default, null):Int; public function new(key:K, value:V, hash:Int) { super(key, false); this.value = value; this.hash = hash; } public function reuse(key,hash) { this.Target = key; this.hash = hash; } @:final inline public function keyEquals(k:K):Bool { return k != null && untyped k.Equals(Target); } } private typedef HashType = Int; haxe_3.2.1+dfsg.orig/std/cs/_std/sys/FileSystem.hx0000664000175000017500000000770612607337712021731 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys; import cs.system.io.DirectoryInfo; import cs.system.io.File; import cs.system.io.Directory; import cs.system.io.FileInfo; @:coreApi class FileSystem { public static function exists( path : String ) : Bool { return (File.Exists(path) || Directory.Exists(path)); } public static function rename( path : String, newPath : String ) : Void { Directory.Move(path, newPath); } public static function stat( path : String ) : FileStat { if (File.Exists(path)) { var fi = new FileInfo(path); return { gid: 0, //C# doesn't let you get this info uid: 0, //same atime: untyped Date.fromNative(fi.LastAccessTime), mtime: untyped Date.fromNative(fi.LastWriteTime), ctime: untyped Date.fromNative(fi.CreationTime), size: cast(fi.Length, Int), //TODO: maybe change to Int64 for Haxe 3? dev: 0, //FIXME: not sure what that is ino: 0, //FIXME: not sure what that is nlink: 0, //FIXME: not sure what that is rdev: 0, //FIXME: not sure what that is mode: 0 //FIXME: not sure what that is }; } else if (Directory.Exists(path)) { var fi = new DirectoryInfo(path); return { gid: 0, //C# doesn't let you get this info uid: 0, //same atime: untyped Date.fromNative(fi.LastAccessTime), mtime: untyped Date.fromNative(fi.LastWriteTime), ctime: untyped Date.fromNative(fi.CreationTime), size: 0, //TODO: maybe change to Int64 for Haxe 3? dev: 0, //FIXME: not sure what that is ino: 0, //FIXME: not sure what that is nlink: 0, //FIXME: not sure what that is rdev: 0, //FIXME: not sure what that is mode: 0 //FIXME: not sure what that is }; } else { throw "Path '" + path + "' doesn't exist"; } } public static function fullPath( relPath : String ) : String { return new FileInfo(relPath).FullName; } public static function absolutePath ( relPath : String ) : String { if (haxe.io.Path.isAbsolute(relPath)) return relPath; return haxe.io.Path.join([Sys.getCwd(), relPath]); } public static function isDirectory( path : String ) : Bool { var isdir = Directory.Exists(path); if (isdir != File.Exists(path)) return isdir; throw "Path '" + path + "' doesn't exist"; } public static function createDirectory( path : String ) : Void { Directory.CreateDirectory(path); } public static function deleteFile( path : String ) : Void { File.Delete(path); } public static function deleteDirectory( path : String ) : Void { Directory.Delete(path); } public static function readDirectory( path : String ) : Array { var ret = Directory.GetFileSystemEntries(path); if (ret.Length > 0) { var fst = ret[0]; var sep = "/"; if (fst.lastIndexOf(sep) < fst.lastIndexOf("\\")) sep = "\\"; for (i in 0...ret.Length) { var path = ret[i]; ret[i] = path.substr(path.lastIndexOf(sep) + 1); } } return cs.Lib.array( ret ); } } haxe_3.2.1+dfsg.orig/std/cs/_std/sys/db/Sqlite.hx0000664000175000017500000000235112607337712021462 0ustar andyandy00000000000000package sys.db; class Sqlite { static var type:Class; /** Opens a new SQLite connection on the specified path. Note that you will need a SQLite ADO.NET Provider (see http://www.mono-project.com/docs/database-access/providers/sqlite/). Also note that this will try to open an assembly named `Mono.Data.Sqlite` if it wasn't loaded yet. **/ public static function open(file:String):sys.db.Connection { var cnxString = 'Data Source=$file'; if (type == null) { var t = null; var assemblies = cs.system.AppDomain.CurrentDomain.GetAssemblies(); for (i in 0...assemblies.Length) { var a = assemblies[i]; t = a.GetType('Mono.Data.Sqlite.SqliteConnection'); if (t == null) t = a.GetType('System.Data.SQLite.SQLiteConnection'); if (t != null) { break; } } if (t == null) { var asm = cs.system.reflection.Assembly.Load('Mono.Data.Sqlite'); t = asm.GetType('Mono.Data.Sqlite.SqliteConnection'); } if (t != null) type = cast cs.Lib.fromNativeType(t); } if (type == null) { throw "No ADO.NET SQLite provider was found!"; } var ret = Type.createInstance(type,[cnxString]); ret.Open(); return cs.db.AdoNet.create(ret,'SQLite'); } } haxe_3.2.1+dfsg.orig/std/cs/_std/sys/io/File.hx0000664000175000017500000000556612607337712021135 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; @:coreApi class File { public static function getContent( path : String ) : String { var f = read(path, false); var ret = f.readAll().toString(); f.close(); return ret; } public static function saveContent( path : String, content : String ) : Void { var f = write(path, false); f.writeString(content); f.close(); } public static function getBytes( path : String ) : haxe.io.Bytes { var f = read(path, true); var ret = f.readAll(); f.close(); return ret; } public static function saveBytes( path : String, bytes : haxe.io.Bytes ) : Void { var f = write(path, true); f.writeBytes(bytes, 0, bytes.length); f.close(); } public static function read( path : String, binary : Bool = true ) : FileInput { #if std_buffer //standardize 4kb buffers var stream = new cs.system.io.FileStream(path, Open, Read, ReadWrite, 4096); #else var stream = new cs.system.io.FileStream(path, Open, Read, ReadWrite); #end return new FileInput(stream); } public static function write( path : String, binary : Bool = true ) : FileOutput { #if std_buffer //standardize 4kb buffers var stream = new cs.system.io.FileStream(path, Create, Write, ReadWrite, 4096); #else var stream = new cs.system.io.FileStream(path, Create, Write, ReadWrite); #end return new FileOutput(stream); } public static function append( path : String, binary : Bool = true ) : FileOutput { #if std_buffer //standardize 4kb buffers var stream = new cs.system.io.FileStream(path, Append, Write, ReadWrite, 4096); #else var stream = new cs.system.io.FileStream(path, Append, Write, ReadWrite); #end return new FileOutput(stream); } public static function copy( srcPath : String, dstPath : String ) : Void { cs.system.io.File.Copy(srcPath, dstPath); } } haxe_3.2.1+dfsg.orig/std/cs/_std/sys/io/FileInput.hx0000664000175000017500000000235712607337712022150 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; class FileInput extends cs.io.NativeInput { public function new(stream:cs.system.io.FileStream) { super(stream); } } haxe_3.2.1+dfsg.orig/std/cs/_std/sys/io/FileOutput.hx0000664000175000017500000000236112607337712022344 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; class FileOutput extends cs.io.NativeOutput { public function new(stream:cs.system.io.FileStream) { super(stream); } } haxe_3.2.1+dfsg.orig/std/cs/_std/sys/io/Process.hx0000664000175000017500000000510612607337712021662 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; import haxe.io.BytesInput; import cs.system.io.StreamReader; import cs.system.io.StreamWriter; import cs.system.diagnostics.Process as NativeProcess; import cs.system.diagnostics.ProcessStartInfo as NativeStartInfo; @:coreApi class Process { public var stdout(default,null) : haxe.io.Input; public var stderr(default,null) : haxe.io.Input; public var stdin(default, null) : haxe.io.Output; private var native:NativeProcess; public function new( cmd : String, args : Array ) : Void { this.native = new NativeProcess(); native.StartInfo.FileName = cmd; native.StartInfo.CreateNoWindow = true; var buf = new StringBuf(); for (arg in args) { buf.add("\""); buf.add(StringTools.replace(arg, "\"", "\\\"")); buf.add("\" "); } native.StartInfo.Arguments = buf.toString(); native.StartInfo.RedirectStandardError = native.StartInfo.RedirectStandardInput = native.StartInfo.RedirectStandardOutput = true; native.StartInfo.UseShellExecute = false; native.Start(); this.stdout = new cs.io.NativeInput(native.StandardOutput.BaseStream); this.stderr = new cs.io.NativeInput(native.StandardError.BaseStream); this.stdin = new cs.io.NativeOutput(native.StandardInput.BaseStream); } public function getPid() : Int { return native.Id; } public function exitCode() : Int { native.WaitForExit(); return native.ExitCode; } public function close() : Void { native.Close(); } public function kill() : Void { native.Kill(); } } haxe_3.2.1+dfsg.orig/std/cs/_std/sys/net/Host.hx0000664000175000017500000000273612607337712021346 0ustar andyandy00000000000000 package sys.net; import cs.system.Array; import cs.system.net.Dns; import cs.system.net.IPAddress; import cs.system.net.IPHostEntry; import cs.system.net.sockets.AddressFamily; import haxe.io.Bytes; import haxe.io.BytesInput; /** A given IP host name. **/ @:coreapi class Host { public var hostEntry(default, null) : IPHostEntry; public var ipAddress(default, null) : IPAddress; /** The actual IP corresponding to the host. **/ public var ip(get, null) : Int; private function get_ip() : Int { return new BytesInput(Bytes.ofData( ipAddress.GetAddressBytes() )).readInt32(); } /** Creates a new Host : the name can be an IP in the form "127.0.0.1" or an host name such as "google.com", in which case the corresponding IP address is resolved using DNS. An exception occur if the host name could not be found. **/ public function new( name : String ) : Void { hostEntry = Dns.GetHostEntry(name); for (i in 0...hostEntry.AddressList.Length) { if (hostEntry.AddressList[i].AddressFamily == InterNetwork) { ipAddress = hostEntry.AddressList[i]; break; } } } /** Returns the IP representation of the host **/ public function toString() : String { return ipAddress.ToString(); } /** Perform a reverse-DNS query to resolve a host name from an IP. **/ public function reverse() : String { return hostEntry.HostName; } /** Returns the local computer host name **/ static public function localhost() : String { return Dns.GetHostName(); } } haxe_3.2.1+dfsg.orig/std/cs/_std/sys/net/Socket.hx0000664000175000017500000001431012607337712021650 0ustar andyandy00000000000000 package sys.net; import cs.system.net.IPEndPoint; import cs.system.net.sockets.AddressFamily; import cs.system.net.sockets.NetworkStream; import cs.system.net.sockets.ProtocolType; import cs.system.net.sockets.SocketFlags; import cs.system.net.sockets.SocketShutdown; import cs.system.net.sockets.SocketType; import cs.system.threading.Thread; import haxe.io.Bytes; import haxe.io.Error; import haxe.io.Input; import haxe.io.Output; /** A TCP socket class : allow you to both connect to a given server and exchange messages or start your own server and wait for connections. **/ @:coreapi class Socket { private var sock : cs.system.net.sockets.Socket = null; /** The stream on which you can read available data. By default the stream is blocking until the requested data is available, use [setBlocking(false)] or [setTimeout] to prevent infinite waiting. **/ public var input(default,null) : haxe.io.Input; /** The stream on which you can send data. Please note that in case the output buffer you will block while writing the data, use [setBlocking(false)] or [setTimeout] to prevent that. **/ public var output(default,null) : haxe.io.Output; /** A custom value that can be associated with the socket. Can be used to retreive your custom infos after a [select]. ***/ public var custom : Dynamic; /** Creates a new unconnected socket. **/ public function new() : Void { sock = new cs.system.net.sockets.Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ); sock.Blocking = true; } /** Closes the socket : make sure to properly close all your sockets or you will crash when you run out of file descriptors. **/ public function close() : Void { sock.Close(); input = null; output = null; } /** Read the whole data available on the socket. **/ public function read() : String { return input.readAll().toString(); } /** Write the whole data to the socket output. **/ public function write( content : String ) : Void { output.writeString( content ); } /** Connect to the given server host/port. Throw an exception in case we couldn't sucessfully connect. **/ public function connect( host : Host, port : Int ) : Void { sock.Connect( host.ipAddress, port ); if (sock.Connected) { this.output = new cs.io.NativeOutput( new NetworkStream(sock) ); this.input = new cs.io.NativeInput( new NetworkStream(sock) ); } else { throw "Connection failed."; } } /** Allow the socket to listen for incoming questions. The parameter tells how many pending connections we can have until they get refused. Use [accept()] to accept incoming connections. **/ public function listen( connections : Int ) : Void { sock.Listen( connections ); } /** Shutdown the socket, either for reading or writing. **/ public function shutdown( read : Bool, write : Bool ) : Void { if ( read && write ) { sock.Shutdown( SocketShutdown.Both ); input = null; output = null; } else if ( read ) { sock.Shutdown( SocketShutdown.Receive ); input = null; } else if ( write ) { sock.Shutdown( SocketShutdown.Send ); output = null; } } /** Bind the socket to the given host/port so it can afterwards listen for connections there. **/ public function bind( host : Host, port : Int ) : Void { sock = new cs.system.net.sockets.Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ); sock.Bind( new IPEndPoint(host.ipAddress, port) ); } /** Accept a new connected client. This will return a connected socket on which you can read/write some data. **/ public function accept() : Socket { var r = new Socket(); r.sock = sock.Accept(); r.output = new cs.io.NativeOutput( new NetworkStream(r.sock) ); r.input = new cs.io.NativeInput( new NetworkStream(r.sock) ); return r; } /** Return the informations about the other side of a connected socket. **/ public function peer() : { host : Host, port : Int } { var remoteIP = cast(sock.RemoteEndPoint, IPEndPoint); return { host: new Host(remoteIP.Address.ToString()), port: remoteIP.Port }; } /** Return the informations about our side of a connected socket. **/ public function host() : { host : Host, port : Int } { var localIP = cast(sock.LocalEndPoint, IPEndPoint); return { host: new Host(localIP.Address.ToString()), port: localIP.Port }; } /** Gives a timeout after which blocking socket operations (such as reading and writing) will abort and throw an exception. **/ public function setTimeout( timeout : Float ) : Void { sock.ReceiveTimeout = sock.SendTimeout = Math.round(timeout * 1000); } /** Block until some data is available for read on the socket. **/ public function waitForRead() : Void { var end = Date.now().getTime() + ((sock.ReceiveTimeout <= 0) ? Math.POSITIVE_INFINITY : sock.ReceiveTimeout); while ( sock.Available == 0 && Date.now().getTime() < end) { Thread.Sleep(5); } } /** Change the blocking mode of the socket. A blocking socket is the default behavior. A non-blocking socket will abort blocking operations immediatly by throwing a haxe.io.Error.Blocking value. **/ public function setBlocking( b : Bool ) : Void { sock.Blocking = b; } /** Allows the socket to immediatly send the data when written to its output : this will cause less ping but might increase the number of packets / data size, especially when doing a lot of small writes. **/ public function setFastSend( b : Bool ) : Void { sock.NoDelay = b; } /** Wait until one of the sockets groups is ready for the given operation : [read] contains sockets on which we want to wait for available data to be read, [write] contains sockets on which we want to wait until we are allowed to write some data to their output buffers, [others] contains sockets on which we want to wait for exceptional conditions. [select] will block until one of the condition is met, in which case it will return the sockets for which the condition was true. In case a [timeout] (in seconds) is specified, select might wait at worse until the timeout expires. **/ static public function select(read : Array, write : Array, others : Array, ?timeout : Float) : { read: Array,write: Array,others: Array } { throw "Not implemented yet."; return null; } } haxe_3.2.1+dfsg.orig/std/cs/db/AdoNet.hx0000664000175000017500000001737412607337712017637 0ustar andyandy00000000000000package cs.db; import sys.db.*; import cs.system.data.*; class AdoNet { public static function create(cnx:IDbConnection, dbName:String):Connection { return new AdoConnection(cnx,dbName); } } private class AdoConnection implements Connection { private static var ids = 0; private var id:Int; private var cnx:IDbConnection; //escape handling private var escapeRegex:EReg; private var escapes:Array; private var name:String; private var command:IDbCommand; private var transaction:IDbTransaction; public function new(cnx,name:String) { this.id = cs.system.threading.Interlocked.Increment(ids); this.cnx = cnx; this.name = name; this.escapes = []; this.command = cnx.CreateCommand(); this.escapeRegex = ~/@HX_ESCAPE(\d+)_(\d+)/; } public function close() : Void { cnx.Close(); } public function escape(s:String):String { var param = command.CreateParameter(); var name = "@HX_ESCAPE" + id + "_" +escapes.push(param) + ""; param.ParameterName = name; param.Value = s; return name; } public function quote(s:String):String { var param = command.CreateParameter(); var name = "@HX_ESCAPE" + id + "_" +escapes.push(param) + ""; param.ParameterName = name; param.Value = s; return name; } public function addValue(s:StringBuf, v:Dynamic) { if (Std.is(v, Date)) { v = Std.string(v); } else if (Std.is(v, haxe.io.Bytes)) { var bt:haxe.io.Bytes = v; v = bt.getData(); } var param = command.CreateParameter(); var name = "@HX_ESCAPE" + id + "_" +escapes.push(param) + ""; param.ParameterName = name; param.Value = v; s.add(name); } public function lastInsertId():Int { var ret = cnx.CreateCommand(); ret.CommandText = switch(name) { case 'SQLite': 'SELECT last_insert_rowid()'; case _: 'SELECT @@IDENTITY'; } ret.CommandType = CommandType.Text; var r = cast ret.ExecuteScalar(); ret.Dispose(); return r; } public function dbName() : String { return name; } public function startTransaction() : Void { if (this.transaction != null) throw 'Transaction already active'; this.transaction = cnx.BeginTransaction(); } public function commit() : Void { if (this.transaction == null) throw 'No transaction was initiated'; this.transaction.Commit(); } public function rollback() : Void { if (this.transaction == null) throw 'No transaction was initiated'; this.transaction.Rollback(); } private static function getFirstStatement(s:String) { var buf = new StringBuf(); var hasData = false; var chr = 0, i = 0; inline function getch() return chr = StringTools.fastCodeAt(s,i++); while ( !StringTools.isEof(getch()) ) { inline function peek() { var c = StringTools.fastCodeAt(s,i); if (StringTools.isEof(c)) break; return c; } switch(chr) { case ' '.code | '\t'.code | '\n'.code: if (hasData) return buf.toString(); case '-'.code if (peek() == '-'.code): if (hasData) return buf.toString(); while (!StringTools.isEof(getch())) { if (chr == '\n'.code) break; } case '#'.code: if (hasData) return buf.toString(); while (!StringTools.isEof(getch())) { if (chr == '\n'.code) break; } case '/'.code if (peek() == '*'.code): i++; if (hasData) return buf.toString(); while (!StringTools.isEof(getch())) { if (chr == '*'.code && peek() == '/'.code) { i++; break; } } case _: hasData = true; buf.addChar(chr); } } return buf.toString(); } public function request( s : String ) : ResultSet { var newst = new StringBuf(); //cycle through the request string, adding any @HX_ESCAPE reference to the command var ret:ResultSet = null; var r = escapeRegex; var myid = id + "", escapes = escapes, elen = escapes.length; var cmd = this.command; try { while (r.match(s)) { var id = r.matched(1); #if debug if (id != myid) throw "Request quotes are only valid for one single request; They can't be cached."; #end newst.add(r.matchedLeft()); var eid = Std.parseInt(r.matched(2)); #if debug if (eid == null || eid > elen) throw "Invalid request quote ID " + eid; #end cmd.Parameters.Add(escapes[eid - 1]); newst.add(escapes[eid-1].ParameterName); s = r.matchedRight(); } newst.add(s); s = newst.toString(); cmd.CommandText = s; var stmt = getFirstStatement(s).toLowerCase(); if (stmt == 'select') { ret = new AdoResultSet( cmd.ExecuteReader() ); } else { cmd.ExecuteNonQuery(); ret = EmptyResultSet.empty; } if (escapes.length != 0) this.escapes = []; this.id = cs.system.threading.Interlocked.Increment(ids); cmd.Dispose(); this.command = cnx.CreateCommand(); return ret; } catch(e:Dynamic) { if (escapes.length != 0) this.escapes = []; this.id = cs.system.threading.Interlocked.Increment(ids); try { cmd.Dispose(); } catch(e:Dynamic) {} this.command = cnx.CreateCommand(); cs.Lib.rethrow(e); } return null; } } private class AdoResultSet implements ResultSet { public var length(get,null) : Int; public var nfields(get,null) : Int; private var reader:IDataReader; private var didNext:Bool; private var names:Array; private var types:Array>; public function new(reader) { this.reader = reader; this.names = [ for (i in 0...reader.FieldCount) reader.GetName(i) ]; this.types = [ for (i in 0...names.length) cs.Lib.fromNativeType(reader.GetFieldType(i)) ]; } private function get_length() { return reader.Depth; } private function get_nfields() { return names.length; } public function hasNext() : Bool { didNext = true; return reader.Read(); } public function next() : Dynamic { if (!didNext && !hasNext()) return null; didNext = false; var ret = {}, names = names, types = types; for (i in 0...names.length) { var name = names[i], t = types[i], val:Dynamic = null; if (t == cs.system.Single) { val = reader.GetDouble(i); } else if (t == cs.system.DateTime || t == cs.system.TimeSpan) { var d = reader.GetDateTime(i); if (d != null) val = Date.fromTime(cast(d.Ticks,Float) / cast(cs.system.TimeSpan.TicksPerMillisecond,Float)); } else if (t == cs.system.DBNull) { val = null; } else if (t == cs.system.Byte) { var v2:cs.StdTypes.UInt8 = reader.GetValue(i); val = cast(v2,Int); } else if (Std.string(t) == 'System.Byte[]') { val = haxe.io.Bytes.ofData(reader.GetValue(i)); } else { val = reader.GetValue(i); } if (Std.is(val,cs.system.DBNull)) val = null; Reflect.setField(ret, name, val); } return ret; } public function results() : List { var l = new List(); while (hasNext()) l.add(next()); return l; } public function getResult( n : Int ) : String { return reader.GetString(n); } public function getIntResult( n : Int ) : Int { return reader.GetInt32(n); } public function getFloatResult( n : Int ) : Float { return reader.GetDouble(n); } public function getFieldsNames() : Null> { return names; } } private class EmptyResultSet implements ResultSet { public static var empty = new EmptyResultSet(); public function new() { } public var length(get,null) : Int; public var nfields(get,null) : Int; private function get_length() { return 0; } private function get_nfields() { return 0; } public function hasNext() : Bool return false; public function next() : Dynamic return null; public function results() : List return new List(); public function getResult( n : Int ) : String return null; public function getIntResult( n : Int ) : Int return 0; public function getFloatResult( n : Int ) : Float return 0; public function getFieldsNames() : Null> return null; } haxe_3.2.1+dfsg.orig/std/cs/internal/BoxedPointer.hx0000664000175000017500000000033712607337712022305 0ustar andyandy00000000000000package cs.internal; @:unsafe @:keep @:native('haxe.lang.BoxedPointer') @:nativeGen class BoxedPointer { @:readonly public var value(default,null):Pointer; public function new(val) { this.value = val; } } haxe_3.2.1+dfsg.orig/std/cs/internal/Exceptions.hx0000664000175000017500000000400312607337712022016 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.internal; import cs.system.Exception; @:nativeGen @:keep @:native("haxe.lang.Exceptions") class Exceptions { @:allow(haxe.CallStack) @:meta(System.ThreadStaticAttribute) static var exception:cs.system.Exception; } //should NOT be usable inside haxe code @:classCode('override public string Message { get { return this.toString(); } }\n\n') @:nativeGen @:keep @:native("haxe.lang.HaxeException") private class HaxeException extends Exception { private var obj:Dynamic; public function new(obj:Dynamic) { super(); if (Std.is(obj, HaxeException)) { var _obj:HaxeException = cast obj; obj = _obj.getObject(); } this.obj = obj; } public function getObject():Dynamic { return obj; } public function toString():String { return Std.string(obj); } public static function wrap(obj:Dynamic):Exception { if (Std.is(obj, Exception)) return obj; return new HaxeException(obj); } } haxe_3.2.1+dfsg.orig/std/cs/internal/FieldLookup.hx0000664000175000017500000002040012607337712022111 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.internal; @:native('haxe.lang.FieldLookup') @:final @:nativeGen @:classCode("#pragma warning disable 628\n") @:keep @:static class FieldLookup { @:protected private static var fieldIds:cs.NativeArray; @:protected private static var fields:cs.NativeArray; @:protected private static var length:Int; static function __init__() { length = fieldIds.Length; } private static function addFields(nids:cs.NativeArray, nfields:cs.NativeArray):Void { // first see if we need to add anything var cids = fieldIds, cfields = fields; var nlen = nids.Length; var clen = length; if (nfields.Length != nlen) throw 'Different fields length: $nlen and ${nfields.Length}'; //TODO optimize var needsChange = false; for (i in nids) { if (findHash(i, cids, clen) < 0) { needsChange = true; break; } } // if we do, lock and merge if (needsChange) { cs.Lib.lock(FieldLookup, { // trace(cs.Lib.array(nids), cs.Lib.array(cids)); var ansIds = new cs.NativeArray(clen + nlen), ansFields = new cs.NativeArray(clen + nlen); var ci = 0, ni = 0, ansi = 0; while (ci < clen && ni < nlen) { if (cids[ci] < nids[ni]) { ansIds[ansi] = cids[ci]; ansFields[ansi] = cfields[ci]; ++ci; } else { ansIds[ansi] = nids[ni]; ansFields[ansi] = nfields[ni]; ++ni; } ++ansi; } if (ci < clen) { cs.system.Array.Copy(cids, ci, ansIds, ansi, clen - ci); cs.system.Array.Copy(cfields, ci, ansFields, ansi, clen - ci); ansi += clen - ci; } if (ni < nlen) { cs.system.Array.Copy(nids, ni, ansIds, ansi, nlen - ni); cs.system.Array.Copy(nfields, ni, ansFields, ansi, nlen - ni); ansi += nlen - ni; } // trace(cs.Lib.array(ansIds)); fieldIds = ansIds; fields = ansFields; length = ansi; }); } } //s cannot be null here private static inline function doHash(s:String):Int { var acc = 0; //alloc_int for (i in 0...s.length) { acc = (( 223 * (acc >> 1) + cast(s[i], Int)) << 1); } return acc >>> 1; //always positive } public static function lookupHash(key:Int):String { //start of binary search algorithm var ids = fieldIds; var min = 0; var max = length; while (min < max) { var mid = min + Std.int((max - min) / 2); var imid = ids[mid]; if (key < imid) { max = mid; } else if (key > imid) { min = mid + 1; } else { return fields[mid]; } } //if not found, it's definitely an error throw "Field not found for hash " + key; } public static function hash(s:String):Int { if (s == null) return 0; var key = doHash(s); //start of binary search algorithm var ids = fieldIds, fld = fields; var min = 0; var max = length; var len = length; while (min < max) { var mid = Std.int(min + (max - min) / 2); //overflow safe var imid = ids[mid]; if (key < imid) { max = mid; } else if (key > imid) { min = mid + 1; } else { var field = fld[mid]; if (field != s) return ~key; //special case return key; } } //if not found, min holds the value where we should insert the key //ensure thread safety: cs.Lib.lock(FieldLookup, { if (len != length) //race condition which will very rarely happen - other thread modified sooner. return hash(s); //since we already own the lock, this second try will always succeed #if erase_generics fieldIds = insertInt(fieldIds, length, min, key); fields = insertString(fields, length, min, s); #else insert(fieldIds, length, min, key); insert(fields, length, min, s); // ids.insert(min, key); // fields.insert(min, s); #end ++length; }); return key; } public static function findHash(hash:Int, hashs:cs.NativeArray, length:Int):Int { var min = 0; var max = length; while (min < max) { var mid = Std.int((max + min) / 2); //overflow safe var imid = hashs[mid]; if (hash < imid) { max = mid; } else if (hash > imid) { min = mid + 1; } else { return mid; } } //if not found, return a negative value of where it should be inserted return ~min; } #if !erase_generics static function remove(a:cs.NativeArray, length:Int, pos:Int) { cs.system.Array.Copy(a, pos + 1, a, pos, length - pos - 1); a[length - 1] = null; } static function insert(a:cs.Ref>, length:Int, pos:Int, x:T) { var capacity = a.Length; if (pos == length) { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); a.CopyTo(newarr, 0); a = newarr; } } else if (pos == 0) { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); cs.system.Array.Copy(a, 0, newarr, 1, length); a = newarr; } else { cs.system.Array.Copy(a, 0, a, 1, length); } } else { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); cs.system.Array.Copy(a, 0, newarr, 0, pos); cs.system.Array.Copy(a, pos, newarr, pos + 1, length - pos); a = newarr; } else { cs.system.Array.Copy(a, pos, a, pos + 1, length - pos); cs.system.Array.Copy(a, 0, a, 0, pos); } } a[pos] = x; } #else static function removeInt(a:cs.NativeArray, length:Int, pos:Int) { cs.system.Array.Copy(a, pos + 1, a, pos, length - pos - 1); a[length - 1] = 0; } static function removeFloat(a:cs.NativeArray, length:Int, pos:Int) { cs.system.Array.Copy(a, pos + 1, a, pos, length - pos - 1); a[length - 1] = 0; } static function removeDynamic(a:cs.NativeArray, length:Int, pos:Int) { cs.system.Array.Copy(a, pos + 1, a, pos, length - pos - 1); a[length - 1] = null; } @:extern static inline function __insert(a:cs.NativeArray, length:Int, pos:Int, x:T):cs.NativeArray { var capacity = a.Length; if (pos == length) { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); a.CopyTo(newarr, 0); a = newarr; } } else if (pos == 0) { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); cs.system.Array.Copy(a, 0, newarr, 1, length); a = newarr; } else { cs.system.Array.Copy(a, 0, a, 1, length); } } else { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); cs.system.Array.Copy(a, 0, newarr, 0, pos); cs.system.Array.Copy(a, pos, newarr, pos + 1, length - pos); a = newarr; } else { cs.system.Array.Copy(a, pos, a, pos + 1, length - pos); cs.system.Array.Copy(a, 0, a, 0, pos); } } a[pos] = x; return a; } static function insertInt(a:cs.NativeArray, length:Int, pos:Int, x:Int):cs.NativeArray return __insert(a, length, pos, x); static function insertFloat(a:cs.NativeArray, length:Int, pos:Int, x:Float):cs.NativeArray return __insert(a, length, pos, x); static function insertDynamic(a:cs.NativeArray, length:Int, pos:Int, x:Dynamic):cs.NativeArray return __insert(a, length, pos, x); static function insertString(a:cs.NativeArray, length:Int, pos:Int, x:Dynamic):cs.NativeArray return __insert(a, length, pos, x); #end } haxe_3.2.1+dfsg.orig/std/cs/internal/Function.hx0000664000175000017500000000520412607337712021466 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.internal; /** These classes are automatically generated by the compiler. They are only here so there is an option for e.g. defining them as externs if you are compiling in modules (untested). **/ @:keep @:abstract @:nativeGen @:native("haxe.lang.Function") class Function { function new(arity:Int, type:Int) { } } @:keep @:nativeGen @:native("haxe.lang.VarArgsBase") private class VarArgsBase extends Function { public function __hx_invokeDynamic(dynArgs:Array):Dynamic { throw "Abstract implementation"; } } @:keep @:nativeGen @:native('haxe.lang.VarArgsFunction') class VarArgsFunction extends VarArgsBase { private var fun:Array->Dynamic; public function new(fun) { super(-1, -1); this.fun = fun; } override public function __hx_invokeDynamic(dynArgs:Array):Dynamic { return fun(dynArgs); } } @:keep @:nativeGen @:native('haxe.lang.Closure') class Closure extends VarArgsBase { private var obj:Dynamic; private var field:String; private var hash:Int; public function new(obj:Dynamic, field, hash) { super(-1, -1); this.obj = obj; this.field = field; this.hash = hash; } override public function __hx_invokeDynamic(dynArgs:Array):Dynamic { return Runtime.callField(obj, field, hash, dynArgs); } public function Equals(obj:Dynamic):Bool { if (obj == null) return false; var c:Closure = cast obj; return (c.obj == this.obj && c.field == this.field); } public function GetHashCode():Int { return obj.GetHashCode() ^ untyped field.GetHashCode(); } } haxe_3.2.1+dfsg.orig/std/cs/internal/HxObject.hx0000664000175000017500000001030112607337712021401 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.internal; import cs.system.Type; import haxe.ds.Vector; private typedef StdType = std.Type; @:keep @:native('haxe.lang.HxObject') class HxObject implements IHxObject { } @:keep @:native('haxe.lang.IHxObject') interface IHxObject { } #if core_api_serialize @:meta(System.Serializable) #end @:keep @:native('haxe.lang.DynamicObject') class DynamicObject extends HxObject implements Dynamic { @:skipReflection public function toString():String { var ts = Reflect.field(this, "toString"); if (ts != null) return ts(); var ret = new StringBuf(); ret.add("{"); var first = true; for (f in Reflect.fields(this)) { if( first ) first = false; else ret.add(","); ret.add(" "); ret.add(f); ret.add(" : "); ret.add(Reflect.field(this, f)); } if (!first) ret.add(" "); ret.add("}"); return ret.toString(); } } #if !erase_generics @:keep @:native('haxe.lang.IGenericObject') interface IGenericObject { } @:nativeGen @:keep @:native('haxe.lang.GenericInterface') class GenericInterface extends cs.system.Attribute { @:readOnly public var generic(default,never):cs.system.Type; public function new(generic) { super(); untyped this.generic = generic; } } #end @:keep @:native('haxe.lang.Enum') @:nativeGen #if core_api_serialize @:meta(System.Serializable) #end class HxEnum { @:readOnly private var index(default,never):Int; public function new(index:Int) { untyped this.index = index; } public function getTag():String { return throw 'Not Implemented'; } public function getParams():Array<{}> { return []; } public function toString():String { return getTag(); } } @:keep @:native('haxe.lang.ParamEnum') @:nativeGen private class ParamEnum extends HxEnum { @:readOnly private var params(default,never):Vector; public function new(index:Int, params:Vector) { super(index); untyped this.params = params; } override public function getParams():Array<{}> { return params == null ? [] : cs.Lib.array(cast params.toData()); } override public function toString():String { if (params == null || params.length == 0) return getTag(); var ret = new StringBuf(); ret.add(getTag()); ret.add("("); var first = true; for (p in params) { if (first) first = false; else ret.add(","); ret.add(p); } ret.add(")"); return ret.toString(); } public function Equals(obj:Dynamic) { if (obj == this) //we cannot use == as .Equals ! return true; var obj:ParamEnum = Std.instance(obj, ParamEnum); var ret = obj != null && Std.is(obj, StdType.getClass(this)) && obj.index == this.index; if (!ret) return false; if (obj.params == this.params) return true; var len = 0; if (obj.params == null || this.params == null || (len = this.params.length) != obj.params.length) return false; for (i in 0...len) { if (!StdType.enumEq(obj.params[i], this.params[i])) return false; } return true; } public function GetHashCode():Int { var h:Int = 19; if (params != null) for (p in params) { h = h * 31; if (p != null) untyped h += p.GetHashCode(); } h += index; return h; } } haxe_3.2.1+dfsg.orig/std/cs/internal/Iterator.hx0000664000175000017500000000254412607337712021476 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.internal; @:keep @:native('haxe.lang.Iterator') interface Iterator { public function hasNext():Bool; public function next():T; } @:keep @:native('haxe.lang.Iterable') interface Iterable { public function iterator():Iterator; }haxe_3.2.1+dfsg.orig/std/cs/internal/Null.hx0000664000175000017500000000612212607337712020613 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.internal; @:classCode(' static public readonly System.Type Type = typeof(T); static public readonly bool IsValueType = haxe.lang.NullMetadata.Type.IsValueType; ') @:keep @:nativeGen @:native("haxe.lang.NullMetadata") private class NullMetadata { } @:classCode(' //This function is here to be used with Reflection, when the haxe.lang.Null type is known public static haxe.lang.Null _ofDynamic(object obj) { if (obj == null) { return new haxe.lang.Null(default(T), false); } else if (typeof(T).Equals(typeof(double))) { return new haxe.lang.Null((T) (object) haxe.lang.Runtime.toDouble(obj), true); } else if (typeof(T).Equals(typeof(int))) { return new haxe.lang.Null((T) (object) haxe.lang.Runtime.toInt(obj), true); } else { return new haxe.lang.Null((T) obj, true); } } ') #if core_api_serialize @:meta(System.Serializable) #end @:keep @:struct @:nativeGen @:native("haxe.lang.Null") private class Nullable { @:readOnly public var value(default,never):T; @:readOnly public var hasValue(default,never):Bool; @:functionCode(' if (!haxe.lang.NullMetadata.IsValueType && System.Object.ReferenceEquals(v, default(T))) { hasValue = false; } this.@value = v; this.hasValue = hasValue; ') public function new(v:T, hasValue:Bool) { untyped this.value = v; untyped this.hasValue = hasValue; } @:functionCode(' if (obj == null) { return new haxe.lang.Null(default(D), false); } else if (typeof(D).Equals(typeof(double))) { return new haxe.lang.Null((D) (object) haxe.lang.Runtime.toDouble(obj), true); } else if (typeof(D).Equals(typeof(int))) { return new haxe.lang.Null((D) (object) haxe.lang.Runtime.toInt(obj), true); } else { return new haxe.lang.Null((D) obj, true); } ') public static function ofDynamic(obj:Dynamic):Nullable { return null; } @:functionCode(' if (this.hasValue) return value; return null; ') public function toDynamic():Dynamic { return null; } } haxe_3.2.1+dfsg.orig/std/cs/internal/Runtime.hx0000664000175000017500000005725612607337712021342 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.internal; import cs.Lib; import cs.Lib.*; import cs.NativeArray; import cs.NativeArray; import cs.system.Activator; import cs.system.IConvertible; import cs.system.IComparable; import cs.system.reflection.MethodBase; import cs.system.reflection.MethodInfo; import cs.system.reflection.*; import cs.system.Type; import cs.system.Object; /** This class is meant for internal compiler use only. It provides the Haxe runtime compatibility to the host language. **/ @:nativeGen @:native('haxe.lang.Runtime') @:access(String) @:classCode(' public static object getField(haxe.lang.HxObject obj, string field, int fieldHash, bool throwErrors) { if (obj == null && !throwErrors) return null; return obj.__hx_getField(field, (fieldHash == 0) ? haxe.lang.FieldLookup.hash(field) : fieldHash, throwErrors, false, false); } public static double getField_f(haxe.lang.HxObject obj, string field, int fieldHash, bool throwErrors) { if (obj == null && !throwErrors) return 0.0; return obj.__hx_getField_f(field, (fieldHash == 0) ? haxe.lang.FieldLookup.hash(field) : fieldHash, throwErrors, false); } public static object setField(haxe.lang.HxObject obj, string field, int fieldHash, object value) { return obj.__hx_setField(field, (fieldHash == 0) ? haxe.lang.FieldLookup.hash(field) : fieldHash, value, false); } public static double setField_f(haxe.lang.HxObject obj, string field, int fieldHash, double value) { return obj.__hx_setField_f(field, (fieldHash == 0) ? haxe.lang.FieldLookup.hash(field) : fieldHash, value, false); } public static object callField(haxe.lang.HxObject obj, string field, int fieldHash, Array args) { return obj.__hx_invokeField(field, (fieldHash == 0) ? haxe.lang.FieldLookup.hash(field) : fieldHash, args); } ') @:keep class Runtime { @:readOnly public static var undefined(default, never):Dynamic = new cs.system.Object(); public static function closure(obj:Dynamic, hash:Int, field:String):Dynamic { return new cs.internal.Function.Closure(obj, field, hash); } public static function eq(v1:Dynamic, v2:Dynamic):Bool { if (Object.ReferenceEquals(v1, v2)) return true; if (Object.ReferenceEquals(v1,null) || Object.ReferenceEquals(v2,null)) return false; var v1c = Lib.as(v1, IConvertible); if (v1c != null) { var v2c = Lib.as(v2, IConvertible); if (v2c == null) { return false; } var t1 = v1c.GetTypeCode(), t2 = v2c.GetTypeCode(); if (t1 == t2) return Object._Equals(v1c,v2c); if (t1 == cs.system.TypeCode.String || t2 == cs.system.TypeCode.String) return false; switch [t1,t2] { case [Decimal, _] | [_, Decimal]: return v1c.ToDecimal(null) == v2c.ToDecimal(null); case [UInt64 | Int64 | DateTime, _] | [_, UInt64 | Int64 | DateTime]: return v1c.ToUInt64(null) == v2c.ToUInt64(null); case [Double | Single, _] | [_, Double | Single]: return v1c.ToDouble(null) == v2c.ToDouble(null); case _: return v1c.ToInt32(null) == v2c.ToInt32(null); } } var v1v = Lib.as(v1, cs.system.ValueType); if (v1v != null) { return v1.Equals(v2); #if !erase_generics } else { var v1t = Lib.as(v1, Type); if (v1t != null) { var v2t = Lib.as(v2, Type); if (v2t != null) return typeEq(v1t, v2t); return false; } #end } return false; } public static function refEq(v1: { }, v2: { } ):Bool { #if !erase_generics if (Std.is(v1, Type)) return typeEq(Lib.as(v1,Type), Lib.as(v2,Type)); #end return Object.ReferenceEquals(v1,v2); } public static function toDouble(obj:Dynamic):Float { return (obj == null) ? .0 : Std.is(obj,Float) ? cast obj : Lib.as(obj,IConvertible).ToDouble(null); } public static function toInt(obj:Dynamic):Int { return (obj == null) ? 0 : Std.is(obj,Int) ? cast obj : Lib.as(obj,IConvertible).ToInt32(null); } public static function isInt(obj:Dynamic):Bool { var cv1 = Lib.as(obj, IConvertible); if (cv1 != null) { switch (cv1.GetTypeCode()) { case Double: var d:Float = cast obj; return d >= cs.system.Int32.MinValue && d <= cs.system.Int32.MaxValue && d == ( cast(d,Int) ); case UInt32, Int32: return true; default: return false; } } return false; } public static function isUInt(obj:Dynamic):Bool { var cv1 = Lib.as(obj, IConvertible); if (cv1 != null) { switch (cv1.GetTypeCode()) { case Double: var d:Float = cast obj; return d >= cs.system.UInt32.MinValue && d <= cs.system.UInt32.MaxValue && d == ( cast(d,UInt) ); case UInt32: return true; default: return false; } } return false; } public static function compare(v1:Dynamic, v2:Dynamic):Int { if (Object.ReferenceEquals(v1,v2)) return 0; if (Object.ReferenceEquals(v1,null)) return -1; if (Object.ReferenceEquals(v2,null)) return 1; var cv1 = Lib.as(v1, IConvertible); if (cv1 != null) { var cv2 = Lib.as(v2, IConvertible); if (cv2 == null) { throw new cs.system.ArgumentException("Cannot compare " + getNativeType(v1).ToString() + " and " + getNativeType(v2).ToString()); } switch(cv1.GetTypeCode()) { case cs.system.TypeCode.String: if (cv2.GetTypeCode() != cs.system.TypeCode.String) throw new cs.system.ArgumentException("Cannot compare " + getNativeType(v1).ToString() + " and " + getNativeType(v2).ToString()); var s1 = Lib.as(v1,String); var s2 = Lib.as(v2,String); return String.Compare(s1,s2, cs.system.StringComparison.Ordinal); case cs.system.TypeCode.Double: var d1:Float = cast v1, d2:Float = cv2.ToDouble(null); return (d1 < d2) ? -1 : (d1 > d2) ? 1 : 0; default: var d1d = cv1.ToDouble(null); var d2d = cv2.ToDouble(null); return (d1d < d2d) ? -1 : (d1d > d2d) ? 1 : 0; } } var c1 = Lib.as(v1, IComparable); var c2 = Lib.as(v2, IComparable); if (c1 == null || c2 == null) { throw new cs.system.ArgumentException("Cannot compare " + getNativeType(v1).ToString() + " and " + getNativeType(v2).ToString()); } return c1.CompareTo(c2); } public static function plus(v1:Dynamic, v2:Dynamic):Dynamic { if (Std.is(v1,String) || Std.is(v2,String)) return Std.string(v1) + Std.string(v2); if (v1 == null) { if (v2 == null) return null; v1 = 0; } else if (v2 == null) v2 = 0; var cv1 = Lib.as(v1, IConvertible); if (cv1 != null) { var cv2 = Lib.as(v2, IConvertible); if (cv2 == null) { throw new cs.system.ArgumentException("Cannot dynamically add " + cs.Lib.getNativeType(v1).ToString() + " and " + cs.Lib.getNativeType(v2).ToString()); } return cv1.ToDouble(null) + cv2.ToDouble(null); } throw new cs.system.ArgumentException("Cannot dynamically add " + v1 + " and " + v2); } public static function slowGetField(obj:Dynamic, field:String, throwErrors:Bool):Dynamic { if (obj == null) if (throwErrors) throw new cs.system.NullReferenceException("Cannot access field \'" + field + "\' of null."); else return null; var t = Lib.as(obj, cs.system.Type); var bf = if (t == null) { var s = Lib.as(obj, String); if (s != null) return cs.internal.StringExt.StringRefl.handleGetField(s, field, throwErrors); t = obj.GetType(); new cs.Flags(BindingFlags.Instance) | BindingFlags.Public | BindingFlags.FlattenHierarchy; } else { if (t == Lib.toNativeType(String) && field == "fromCharCode") return new cs.internal.Function.Closure(StringExt, field, 0); obj = null; new cs.Flags(BindingFlags.Static) | BindingFlags.Public; } var f = t.GetField(field, bf); if (f != null) { return unbox(f.GetValue(obj)); } else { var prop = t.GetProperty(field, bf); if (prop == null) { var m = t.GetMember(field, bf); if (m.length == 0 && (field == "__get" || field == "__set")) m = t.GetMember(field == "__get" ? "get_Item" : "set_Item", bf); if (m.Length > 0) { return new cs.internal.Function.Closure(obj != null ? obj : t, field, 0); } else { // COM object handling if (t.IsCOMObject) { try { return t.InvokeMember(field, BindingFlags.GetProperty, null, obj, new cs.NativeArray(0)); } catch (e:cs.system.Exception) { //Closures of COM objects not supported currently } } if (throwErrors) throw "Cannot access field \'" + field + "\'."; else return null; } } return unbox(prop.GetValue(obj, null)); } } public static function slowHasField(obj:Dynamic, field:String):Bool { if (obj == null) return false; var t = Lib.as(obj, cs.system.Type); var bf = if (t == null) { var s = Lib.as(obj, String); if (s != null) return cs.internal.StringExt.StringRefl.handleGetField(s, field, false) != null; t = obj.GetType(); new cs.Flags(BindingFlags.Instance) | BindingFlags.Public | BindingFlags.FlattenHierarchy; } else { if (t == Lib.toNativeType(String)) return field == "fromCharCode"; obj = null; new cs.Flags(BindingFlags.Static) | BindingFlags.Public; } var mi = t.GetMember(field, bf); return mi != null && mi.length > 0; } public static function slowSetField(obj:Dynamic, field:String, value:Dynamic):Dynamic { if (obj == null) throw new cs.system.NullReferenceException("Cannot access field \'" + field + "\' of null."); var t = Lib.as(obj, cs.system.Type); var bf = if (t == null) { t = obj.GetType(); new cs.Flags(BindingFlags.Instance) | BindingFlags.Public | BindingFlags.FlattenHierarchy; } else { obj = null; new cs.Flags(BindingFlags.Static) | BindingFlags.Public; } var f = t.GetField(field, bf); if (f != null) { if (f.FieldType.ToString().StartsWith("haxe.lang.Null")) { value = mkNullable(value, f.FieldType); } if (Object.ReferenceEquals(Lib.toNativeType(cs.system.Double), Lib.getNativeType(value)) && !Object.ReferenceEquals(t, f.FieldType)) { var ic = Lib.as(value, IConvertible); value = ic.ToType(f.FieldType, null); } f.SetValue(obj, value); return value; } else { var prop = t.GetProperty(field, bf); if (prop == null) { // COM object handling if (t.IsCOMObject) { try { return t.InvokeMember(field, BindingFlags.SetProperty, null, obj, cs.NativeArray.make(value)); } catch (e:cs.system.Exception) { //Closures of COM objects not supported currently } } throw "Field \'" + field + "\' not found for writing from Class " + t; } if (prop.PropertyType.ToString().StartsWith("haxe.lang.Null")) { value = mkNullable(value, prop.PropertyType); } if (Object.ReferenceEquals(Lib.toNativeType(cs.system.Double), Lib.getNativeType(value)) && !Object.ReferenceEquals(t, f.FieldType)) { var ic = Lib.as(value, IConvertible); value = ic.ToType(f.FieldType, null); } prop.SetValue(obj, value, null); return value; } } public static function callMethod(obj:Dynamic, methods:NativeArray, methodLength:Int, args:Array):Dynamic { if (methodLength == 0) throw "No available methods"; var length = args.length; var oargs:NativeArray = new NativeArray(length); var ts:NativeArray = new NativeArray(length); var rates:NativeArray = new NativeArray(methods.Length); for (i in 0...length) { oargs[i] = args[i]; if (args[i] != null) ts[i] = Lib.getNativeType(args[i]); } var last = 0; //first filter by number of parameters and if it is assignable if (methodLength > 1) { for (i in 0...methodLength) { var params = methods[i].GetParameters(); if (params.Length != length) { continue; } else { var fits = true, crate = 0; for (i in 0...params.Length) { var param = params[i].ParameterType; var strParam = param + ""; if (param.IsAssignableFrom(ts[i]) || (ts[i] == null && !param.IsValueType)) { //if it is directly assignable, we'll give it top rate continue; } else if (untyped strParam.StartsWith("haxe.lang.Null") || ( (oargs[i] == null || Std.is(oargs[i], IConvertible) ) && cast(untyped __typeof__(IConvertible), Type).IsAssignableFrom(param) )) { //if it needs conversion, give a penalty. TODO rate penalty crate++; continue; } else if (!param.ContainsGenericParameters) { //generics don't appear as assignable, but may be in the end. no rate there. fits = false; break; } } if (fits) { rates[last] = crate; methods[last++] = methods[i]; } } } methodLength = last; } else if (methodLength == 1 && methods[0].GetParameters().Length != length) { methodLength = 0; } //At this time, we should be left with only one method. //Of course, realistically, we can be left with plenty of methods, if there are lots of variants with IConvertible //But at this time we still aren't rating the best methods //FIXME rate best methods if (methodLength == 0) throw "Invalid calling parameters for method " + methods[0].Name; var best = cs.system.Double.PositiveInfinity; var bestMethod = 0; for(i in 0...methodLength) { if (rates[i] < best) { bestMethod = i; best = rates[i]; } } methods[0] = methods[bestMethod]; var params = methods[0].GetParameters(); for (i in 0...params.Length) { var param = params[i].ParameterType; var strParam = param + "", arg = oargs[i]; if (StringTools.startsWith(strParam, "haxe.lang.Null")) { oargs[i] = mkNullable(arg, param); } else if (cast(untyped __typeof__(IConvertible), Type).IsAssignableFrom(param)) { if (arg == null) { if (param.IsValueType) oargs[i] = Activator.CreateInstance(param); } else if (!cs.Lib.getNativeType(arg).IsAssignableFrom(param)) { oargs[i] = cast(arg, IConvertible).ToType(param, null); } } } if (methods[0].ContainsGenericParameters && Std.is(methods[0], cs.system.reflection.MethodInfo)) { var m:MethodInfo = cast methods[0]; var tgs = m.GetGenericArguments(); for (i in 0...tgs.Length) { tgs[i] = untyped __typeof__(Dynamic); } m = m.MakeGenericMethod(tgs); var retg = m.Invoke(obj, oargs); return cs.internal.Runtime.unbox(retg); } var m = methods[0]; if (obj == null && Std.is(m, cs.system.reflection.ConstructorInfo)) { var ret = cast(m, cs.system.reflection.ConstructorInfo).Invoke(oargs); return unbox(ret); } var ret = m.Invoke(obj, oargs); return unbox(ret); } public static function unbox(dyn:Dynamic):Dynamic { if (dyn != null && untyped (Lib.getNativeType(dyn) + "").StartsWith("haxe.lang.Null")) { return dyn.toDynamic(); } else { return dyn; } } #if !erase_generics @:functionCode(' if (nullableType.ContainsGenericParameters) return haxe.lang.Null.ofDynamic(obj); return nullableType.GetMethod("_ofDynamic").Invoke(null, new object[] { obj }); ') public static function mkNullable(obj:Dynamic, nullableType:Type):Dynamic { return null; } #else public static function mkNullable(obj:Dynamic, nullable:Type):Dynamic { return obj; //do nothing } #end // @:functionCode(' // if (field == "toString") // { // if (args == null) // return obj.ToString(); // field = "ToString"; // } // if (args == null) args = new Array(); // System.Reflection.BindingFlags bf; // System.Type t = obj as System.Type; // if (t == null) // { // string s = obj as string; // if (s != null) // return haxe.lang.StringRefl.handleCallField(s, field, args); // t = obj.GetType(); // bf = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy; // } else { // if (t == typeof(string) && field.Equals("fromCharCode")) // return haxe.lang.StringExt.fromCharCode(toInt(args[0])); // obj = null; // bf = System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public; // } // System.Reflection.MethodInfo[] mis = t.GetMethods(bf); // int last = 0; // for (int i = 0; i < mis.Length; i++) // { // string name = mis[i].Name; // if (name.Equals(field)) // { // mis[last++] = mis[i]; // } // } // if (last == 0 && (field == "__get" || field == "__set")) // { // field = field == "__get" ? "get_Item" : "set_Item"; // for (int i = 0; i < mis.Length; i++) // { // string name = mis[i].Name; // if (name.Equals(field)) // { // mis[last++] = mis[i]; // } // } // } // if (last == 0 && t.IsCOMObject) // { // object[] oargs = new object[arrLen(args)]; // for (int i = 0; i < oargs.Length; i++) // { // oargs[i] = args[i]; // } // return t.InvokeMember(field, System.Reflection.BindingFlags.InvokeMethod, null, obj, oargs); // } // if (last == 0) // { // throw haxe.lang.HaxeException.wrap("Method \'" + field + "\' not found on type " + t); // } // return haxe.lang.Runtime.callMethod(obj, mis, last, args); // ') public static function slowCallField(obj:Dynamic, field:String, args:Array):Dynamic { if (field == "toString" && (args == null || args.length == 0)) { return obj.ToString(); } if (args == null) args = []; var bf:BindingFlags; var t = Lib.as(obj,cs.system.Type); if (t == null) { var s = Lib.as(obj,String); if (s != null) return cs.internal.StringExt.StringRefl.handleCallField(untyped s, untyped field, args); t = untyped obj.GetType(); bf = new Flags(BindingFlags.Instance) | BindingFlags.Public | BindingFlags.FlattenHierarchy; } else { if (t == Lib.toNativeType(String) && field == 'fromCharCode') return cs.internal.StringExt.fromCharCode(toInt(args[0])); obj = null; bf = new Flags(BindingFlags.Static) | BindingFlags.Public; } var mis:NativeArray = untyped t.GetMethods(bf); var last = 0; for (i in 0...mis.Length) { var name = mis[i].Name; if (name == field) mis[last++] = mis[i]; } if (last == 0 && (field == "__get" || field == "__set")) { field = field == "__get" ? "get_Item" : "set_Item"; for (i in 0...mis.Length) { var name = mis[i].Name; if (name == field) { mis[last++] = mis[i]; } } } if (last == 0 && t.IsCOMObject) { var oargs = new NativeArray(args.length); for (i in 0...oargs.Length) { oargs[i] = args[i]; } return t.InvokeMember(field, BindingFlags.InvokeMethod, null, obj, oargs); } if (last == 0) { throw 'Method "$field" not found on type $t'; } return Runtime.callMethod(obj, mis, last, args); } public static function callField(obj:Dynamic, field:String, fieldHash:Int, args:Array):Dynamic { var hxObj = Lib.as(obj, HxObject); if (hxObj != null) return untyped hxObj.__hx_invokeField(field, (fieldHash == 0) ? FieldLookup.hash(field) : fieldHash, args); return slowCallField(obj, field, args); } public static function getField(obj:Dynamic, field:String, fieldHash:Int, throwErrors:Bool):Dynamic { var hxObj = Lib.as(obj, HxObject); if (hxObj != null) return untyped hxObj.__hx_getField(field, (fieldHash == 0) ? FieldLookup.hash(field) : fieldHash, throwErrors, false, false); return slowGetField(obj, field, throwErrors); } public static function getField_f(obj:Dynamic, field:String, fieldHash:Int, throwErrors:Bool):Float { var hxObj = Lib.as(obj, HxObject); if (hxObj != null) return untyped hxObj.__hx_getField_f(field, (fieldHash == 0) ? FieldLookup.hash(field) : fieldHash, throwErrors, false); return toDouble(slowGetField(obj, field, throwErrors)); } public static function setField(obj:Dynamic, field:String, fieldHash:Int, value:Dynamic):Dynamic { var hxObj = Lib.as(obj, HxObject); if (hxObj != null) return untyped hxObj.__hx_setField(field, (fieldHash == 0) ? FieldLookup.hash(field) : fieldHash, value, false); return slowSetField(obj, field, value); } public static function setField_f(obj:Dynamic, field:String, fieldHash:Int, value:Float):Float { var hxObj = Lib.as(obj, HxObject); if (hxObj != null) return untyped hxObj.__hx_setField_f(field, (fieldHash == 0) ? FieldLookup.hash(field) : fieldHash, value, false); return toDouble(slowSetField(obj, field, value)); } public static function toString(obj:Dynamic):String { if (obj == null) return null; if (Std.is(obj, Bool)) if(obj) return "true"; else return "false"; return untyped obj.ToString(); } #if erase_generics inline #end public static function typeEq(t1:Type, t2:Type):Bool { if (t1 == null || t2 == null) return t1 == t2; #if !erase_generics var t1i = t1.IsInterface, t2i = t2.IsInterface; if (t1i != t2i) { if (t1i) { var g = getGenericAttr(t1); if (g != null) t1 = g.generic; } else { var g = getGenericAttr(t2); if (g != null) t2 = g.generic; } } #end if (t1.GetGenericArguments().Length > 0) t1 = t1.GetGenericTypeDefinition(); if (t2.GetGenericArguments().Length > 0) t2 = t2.GetGenericTypeDefinition(); return Object.ReferenceEquals(t1,t2); } #if !erase_generics private static function getGenericAttr(t:cs.system.Type):cs.internal.HxObject.GenericInterface { for (attr in t.GetCustomAttributes(true)) if (Std.is(attr,cs.internal.HxObject.GenericInterface)) return cast attr; return null; } #end #if !erase_generics @:functionCode(' if (obj is To) return (To) obj; else if (obj == null) return default(To); if (typeof(To) == typeof(double)) return (To)(object) toDouble(obj); else if (typeof(To) == typeof(int)) return (To)(object) toInt(obj); else if (typeof(To) == typeof(float)) return (To)(object)(float)toDouble(obj); else if (typeof(To) == typeof(long)) return (To)(object)(long)toDouble(obj); else return (To) obj; ') public static function genericCast(obj:Dynamic):To { return null; } #end @:functionCode(' return (s1 == null ? "null" : s1) + (s2 == null ? "null" : s2); ') public static function concat(s1:String, s2:String):String { return null; } public static function toBool(dyn:Dynamic):Bool { return if (dyn == null) false else untyped __cs__("(bool){0}", dyn); } //TODO: change from genericCast to getConverter, so we don't need to handle extra boxing associated with it /*@:functionCode(' if (typeof(To).TypeHandle == typeof(double).TypeHandle) return (System.Converter) new System.Converter(toDouble); else if (typeof(To).TypeHandle == typeof(double).TypeHandle) return (System.Converter) new System.Converter(toDouble); else return (System.Converter) delegate(object obj) { return (To) obj; }; ') public static function getConverter():cs.system.Converter { return null; }*/ } @:nativeGen @:keep @:native("haxe.lang.EmptyObject") private enum EmptyObject { EMPTY; } haxe_3.2.1+dfsg.orig/std/cs/internal/StringExt.hx0000664000175000017500000001275112607337712021635 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.internal; import cs.internal.Function; private typedef NativeString = cs.system.String; @:keep @:nativeGen @:native("haxe.lang.StringExt") class StringExt { @:readOnly static var empty(default,never) = new NativeString(cast 0,0); public static function charAt(me:NativeString, index:Int):NativeString { if (cast(index,UInt) >= me.Length) return empty; else return new NativeString(me[index], 1); } public static function charCodeAt(me:NativeString, index:Int):Null { if (cast(index,UInt) >= me.Length) return null; else return cast(me[index], Int); } public static function indexOf(me:NativeString, str:String, ?startIndex:Int):Int { var sIndex:Int = startIndex != null ? startIndex : 0; if (sIndex >= me.Length) return -1; return @:privateAccess me.IndexOf(str, sIndex, cs.system.StringComparison.Ordinal); } public static function lastIndexOf(me:NativeString, str:NativeString, ?startIndex:Int):Int { var sIndex:Int = startIndex == null ? me.Length - 1 : startIndex; if (sIndex >= me.Length) sIndex = me.Length - 1; else if (sIndex < 0) return -1; //TestBaseTypes.hx@133 fix if (startIndex != null) { var i = sIndex + 1; while (i --> 0) { var found = true; for (j in 0...str.Length) { if(me[i + j] != str[j]) { found = false; break; } } if (found) return i; } return -1; } else { return me.LastIndexOf(untyped str, sIndex, cs.system.StringComparison.Ordinal); } return -1; } public static function split(me:NativeString, delimiter:NativeString):Array { var native:NativeArray; if (delimiter.Length == 0) { var len = me.Length; native = new NativeArray(len); for (i in 0...len) native[i] = untyped new NativeString(me[i],1); } else { var str = new NativeArray(1); str[0] = cast delimiter; native = me.Split(str, cs.system.StringSplitOptions.None); } return cs.Lib.array(native); } public static function substr(me:NativeString, pos:Int, ?len:Int):String { var meLen = me.Length; var targetLen = meLen; if (len != null) { targetLen = len; if (targetLen == 0 || (pos != 0 && targetLen < 0)) return ""; } if (pos < 0) { pos = meLen + pos; if (pos < 0) pos = 0; } else if (targetLen < 0) { targetLen = meLen + targetLen - pos; } if (pos + targetLen > meLen) { targetLen = meLen - pos; } if (pos < 0 || targetLen <= 0) return ""; return me.Substring(pos, targetLen); } public static function substring(me:NativeString, startIndex:Int, ?endIndex:Int):String { var len = me.Length; var endIdx:Int; if (endIndex == null) endIdx = len; else if ( (endIdx = endIndex) < 0 ) endIdx = 0; else if (endIdx > len) endIdx = len; if (startIndex < 0) startIndex = 0; else if (startIndex > len) startIndex = len; if (startIndex > endIdx) { var tmp = startIndex; startIndex = endIdx; endIdx = tmp; } return me.Substring(startIndex, endIdx - startIndex); } public static function toString(me:NativeString):NativeString { return me; } public static function toLowerCase(me:NativeString):String { return me.ToLowerInvariant(); } public static function toUpperCase(me:NativeString):String { return me.ToUpperInvariant(); } public static function toNativeString(me:NativeString):NativeString { return me; } public static function fromCharCode(code:Int):NativeString { return new NativeString( cast(code,cs.StdTypes.Char16), 1 ); } } @:keep @:nativeGen @:native('haxe.lang.StringRefl') class StringRefl { public static var fields = ["length", "toUpperCase", "toLowerCase", "charAt", "charCodeAt", "indexOf", "lastIndexOf", "split", "substr", "substring"]; public static function handleGetField(str:String, f:String, throwErrors:Bool):Dynamic { switch(f) { case "length": return str.length; case "toUpperCase", "toLowerCase", "charAt", "charCodeAt", "indexOf", "lastIndexOf", "split", "substr", "substring": return new Closure(str, f, 0); default: if (throwErrors) throw "Field not found: '" + f + "' in String"; else return null; } } public static function handleCallField(str:NativeString, f:String, args:Array):Dynamic { var _args:Array = [str]; if (args == null) args = _args; else args = _args.concat(args); return Runtime.slowCallField(StringExt, f, args); } } haxe_3.2.1+dfsg.orig/std/cs/io/NativeInput.hx0000664000175000017500000000470512607337712020747 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.io; import haxe.Int64; import haxe.io.Bytes; import haxe.io.Eof; import haxe.io.Error; import haxe.io.Input; class NativeInput extends Input { public var canSeek(get_canSeek, null):Bool; var stream:cs.system.io.Stream; var _eof:Bool; public function new(stream) { this.stream = stream; this._eof = false; if (!stream.CanRead) throw "Write-only stream"; } override public function readByte():Int { var ret = stream.ReadByte(); if (ret == -1) { _eof = true; throw new Eof(); } return ret; } override public function readBytes(s:Bytes, pos:Int, len:Int):Int { if( pos < 0 || len < 0 || pos + len > s.length ) throw Error.OutsideBounds; var ret = stream.Read(s.getData(), pos, len); if (ret == 0) { _eof = true; throw new Eof(); } return ret; } override public function close():Void { stream.Close(); } private function get_canSeek():Bool { return stream.CanSeek; } public function seek( p : Int, pos : sys.io.FileSeek ) : Void { _eof = false; var pos = switch(pos) { case SeekBegin: cs.system.io.SeekOrigin.Begin; case SeekCur: cs.system.io.SeekOrigin.Current; case SeekEnd: cs.system.io.SeekOrigin.End; }; stream.Seek(cast(p, Int64), pos); } public function tell() : Int { return cast(stream.Position, Int); } public inline function eof() : Bool { return _eof; } }haxe_3.2.1+dfsg.orig/std/cs/io/NativeOutput.hx0000664000175000017500000000426612607337712021152 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package cs.io; import haxe.Int64; import haxe.io.Bytes; import haxe.io.Output; class NativeOutput extends Output { var canSeek(get_canSeek, null):Bool; var stream:cs.system.io.Stream; public function new(stream) { this.stream = stream; if (!stream.CanWrite) throw "Read-only stream"; } override public function writeByte(c:Int):Void { stream.WriteByte(cast c); } override public function close():Void { stream.Close(); } override public function flush():Void { stream.Flush(); } override public function prepare(nbytes:Int):Void { //TODO see if implementation is correct stream.SetLength(haxe.Int64.add(stream.Length, cast(nbytes, Int64))); } private function get_canSeek():Bool { return stream.CanSeek; } public function seek( p : Int, pos : sys.io.FileSeek ) : Void { var p = switch(pos) { case SeekBegin: cs.system.io.SeekOrigin.Begin; case SeekCur: cs.system.io.SeekOrigin.Current; case SeekEnd: cs.system.io.SeekOrigin.End; }; stream.Seek(cast(p, Int64), p); } public function tell() : Int { return cast(stream.Position, Int); } } haxe_3.2.1+dfsg.orig/std/cs/types/Char16.hx0000664000175000017500000000007012607337712020251 0ustar andyandy00000000000000package cs.types; typedef Char16 = cs.StdTypes.Char16; haxe_3.2.1+dfsg.orig/std/cs/types/Int16.hx0000664000175000017500000000006612607337712020133 0ustar andyandy00000000000000package cs.types; typedef Int16 = cs.StdTypes.Int16; haxe_3.2.1+dfsg.orig/std/cs/types/Int64.hx0000664000175000017500000000006712607337712020137 0ustar andyandy00000000000000package cs.types; typedef Int64 = cs.StdTypes.Int64; haxe_3.2.1+dfsg.orig/std/cs/types/Int8.hx0000664000175000017500000000006412607337712020052 0ustar andyandy00000000000000package cs.types; typedef Int8 = cs.StdTypes.Int8; haxe_3.2.1+dfsg.orig/std/cs/types/UInt16.hx0000664000175000017500000000007012607337712020253 0ustar andyandy00000000000000package cs.types; typedef UInt16 = cs.StdTypes.UInt16; haxe_3.2.1+dfsg.orig/std/cs/types/UInt64.hx0000664000175000017500000000007012607337712020256 0ustar andyandy00000000000000package cs.types; typedef UInt64 = cs.StdTypes.UInt64; haxe_3.2.1+dfsg.orig/std/cs/types/UInt8.hx0000664000175000017500000000006612607337712020201 0ustar andyandy00000000000000package cs.types; typedef UInt8 = cs.StdTypes.UInt8; haxe_3.2.1+dfsg.orig/std/flash/Boot.hx0000664000175000017500000001745612607337712017474 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package flash; #if !as3 @:keep private class RealBoot extends Boot implements Dynamic { #if swc public function new() { super(); } public static function initSwc(mc) { flash.Lib.current = mc; new RealBoot().init(); } #else function new() { super(); if( flash.Lib.current == null ) flash.Lib.current = this; start(); } #end } #end @:keep class Boot extends flash.display.MovieClip { static var tf : flash.text.TextField; static var lines : Array; static var lastError : flash.errors.Error; public static var skip_constructor = false; function start() { #if dontWaitStage init(); #else var c = flash.Lib.current; try { untyped if( c == this && c.stage != null && c.stage.align == "" ) c.stage.align = "TOP_LEFT"; } catch( e : Dynamic ) { // security error when loading from different domain } if( c.stage == null ) c.addEventListener(flash.events.Event.ADDED_TO_STAGE, doInitDelay); else if( c.stage.stageWidth == 0 || c.stage.stageHeight == 0 ) untyped __global__["flash.utils.setTimeout"](start,1); else init(); #end } function doInitDelay(_) { flash.Lib.current.removeEventListener(flash.events.Event.ADDED_TO_STAGE, doInitDelay); start(); } #if (swc && swf_protected) public #end function init() { throw "assert"; } public static function enum_to_string( e : { tag : String, params : Array } ) { if( e.params == null ) return e.tag; var pstr = []; for( p in e.params ) pstr.push(__string_rec(p,"")); return e.tag+"("+pstr.join(",")+")"; } public static function __instanceof( v : Dynamic, t : Dynamic ) { try { if( t == Dynamic ) return true; return untyped __is__(v,t); } catch( e : Dynamic ) { } return false; } public static function __clear_trace() { if( tf == null ) return; tf.parent.removeChild(tf); tf = null; lines = null; } public static function __set_trace_color(rgb) { var tf = getTrace(); tf.textColor = rgb; tf.filters = []; } public static function getTrace() { var mc = flash.Lib.current; if( tf == null ) { tf = new flash.text.TextField(); #if flash10_2 var color = 0xFFFFFF, glow = 0; if( mc.stage != null ) { glow = mc.stage.color; color = 0xFFFFFF - glow; } tf.textColor = color; tf.filters = [new flash.filters.GlowFilter(glow, 1, 2, 2, 20)]; #end var format = tf.getTextFormat(); format.font = "_sans"; tf.defaultTextFormat = format; tf.selectable = false; tf.width = if( mc.stage == null ) 800 else mc.stage.stageWidth; tf.autoSize = flash.text.TextFieldAutoSize.LEFT; tf.mouseEnabled = false; } if( mc.stage == null ) mc.addChild(tf); else mc.stage.addChild(tf); // on top return tf; } public static function __trace( v : Dynamic, pos : haxe.PosInfos ) { var tf = getTrace(); var pstr = if( pos == null ) "(null)" else pos.fileName+":"+pos.lineNumber; if( lines == null ) lines = []; var str = pstr +": "+__string_rec(v, ""); if( pos != null && pos.customParams != null ) for( v in pos.customParams ) str += ","+__string_rec(v, ""); lines = lines.concat(str.split("\n")); tf.text = lines.join("\n"); var stage = flash.Lib.current.stage; if( stage == null ) return; while( lines.length > 1 && tf.height > stage.stageHeight ) { lines.shift(); tf.text = lines.join("\n"); } } public static function __string_rec( v : Dynamic, str : String ) { var cname = untyped __global__["flash.utils.getQualifiedClassName"](v); switch( cname ) { case "Object": var k : Array = untyped __keys__(v); var s = "{"; var first = true; for( i in 0...k.length ) { var key = k[i]; if( key == "toString" ) try return v.toString() catch( e : Dynamic ) {} if( first ) first = false; else s += ","; s += " "+key+" : "+__string_rec(v[untyped key],str); } if( !first ) s += " "; s += "}"; return s; case "Array": if( v == Array ) return "#Array"; var s = "["; var i; var first = true; var a : Array = v; for( i in 0...a.length ) { if( first ) first = false; else s += ","; s += __string_rec(a[i],str); } return s + "]"; default: switch( untyped __typeof__(v) ) { case "function": return ""; case "undefined": return "null"; } } return new String(v); } static function __unprotect__( s : String ) { return s; } static public function mapDynamic(d:Dynamic, f:Dynamic) { if (Std.is(d, Array)) { return untyped d["mapHX"](f); } else { return untyped d["map"](f); } } static public function filterDynamic(d:Dynamic, f:Dynamic) { if (Std.is(d, Array)) { return untyped d["filterHX"](f); } else { return untyped d["filter"](f); } } static function __init__() untyped { var aproto = Array.prototype; aproto.copy = function() { return __this__.slice(); }; aproto.insert = function(i,x) { __this__.splice(i,0,x); }; aproto.remove = function(obj) { var idx = __this__.indexOf(obj); if( idx == -1 ) return false; __this__.splice(idx,1); return true; } aproto.iterator = function() { var cur = 0; var arr : Array = __this__; return { hasNext : function() { return cur < arr.length; }, next : function() { return arr[cur++]; } } }; aproto.setPropertyIsEnumerable("copy", false); aproto.setPropertyIsEnumerable("insert", false); aproto.setPropertyIsEnumerable("remove", false); aproto.setPropertyIsEnumerable("iterator", false); #if (as3 || no_flash_override) aproto.filterHX = function(f) { var ret = []; var i = 0; var l = __this__.length; while ( i < l ) { if (f(__this__[i])) ret.push(__this__[i]); i++; } return ret; }; aproto.mapHX = function(f) { var ret = []; var i = 0; var l = __this__.length; while( i < l ) { ret.push(f(__this__[i])); i++; } return ret; }; aproto.setPropertyIsEnumerable("mapHX", false); aproto.setPropertyIsEnumerable("filterHX", false); String.prototype.charCodeAtHX = function(i) : Null { #else aproto["filter"] = function(f) { var ret = []; var i = 0; var l = __this__.length; while ( i < l ) { if (f(__this__[i])) ret.push(__this__[i]); i++; } return ret; }; aproto["map"] = function(f) { var ret = []; var i = 0; var l = __this__.length; while( i < l ) { ret.push(f(__this__[i])); i++; } return ret; }; aproto.setPropertyIsEnumerable("map", false); aproto.setPropertyIsEnumerable("filter", false); String.prototype.charCodeAt = function(i) : Null { #end var s : String = __this__; var x : Float = s.cca(i); if( __global__["isNaN"](x) ) return null; return Std.int(x); }; } } haxe_3.2.1+dfsg.orig/std/flash/Lib.hx0000664000175000017500000000641412607337712017267 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package flash; class Lib { public static var current : flash.display.MovieClip; public inline static function getTimer() : Int { return untyped __global__["flash.utils.getTimer"](); } public static function eval( path : String ) : Dynamic { var p = path.split("."); var fields = new Array(); var o : Dynamic = null; while( p.length > 0 ) { try { o = untyped __global__["flash.utils.getDefinitionByName"](p.join(".")); } catch( e : Dynamic ) { fields.unshift(p.pop()); } if( o != null ) break; } for( f in fields ) { if( o == null ) return null; o = untyped o[f]; } return o; } public static function getURL( url : flash.net.URLRequest, ?target : String ) { var f = untyped __global__["flash.net.navigateToURL"]; if( target == null ) f(url); else (cast f)(url,target); } public static function fscommand( cmd : String, ?param : String ) { untyped __global__["flash.system.fscommand"](cmd,if( param == null ) "" else param); } public static function trace( arg : Dynamic ) { untyped __global__["trace"](arg); } public static function describeType( value : Dynamic ) : flash.xml.XML { return untyped __global__["flash.utils.describeType"](value); } public static function attach( name : String ) : flash.display.MovieClip { var cl = untyped __as__(__global__["flash.utils.getDefinitionByName"](name),Class); return untyped __new__(cl); } public inline static function as( v : Dynamic, c : Class ) : Null { return untyped __as__(v,c); } public static function redirectTraces() { if (flash.external.ExternalInterface.available) haxe.Log.trace = traceToConsole; } static function traceToConsole(v : Dynamic, ?inf : haxe.PosInfos ) { var type = if( inf != null && inf.customParams != null ) inf.customParams[0] else null; if( type != "warn" && type != "info" && type != "debug" && type != "error" ) type = if( inf == null ) "error" else "log"; var str = if( inf == null ) "" else inf.fileName + ":" + inf.lineNumber + " : "; try str += Std.string(v) catch( e : Dynamic ) str += "????"; str = str.split("\\").join("\\\\"); flash.external.ExternalInterface.call("console."+type,str); } } haxe_3.2.1+dfsg.orig/std/flash/Memory.hx0000664000175000017500000000520712607337712020030 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package flash; extern class Memory { public static inline function select( b : flash.utils.ByteArray ) : Void { flash.system.ApplicationDomain.currentDomain.domainMemory = b; } public static inline function setByte( addr : Int, v : Int ) : Void { untyped __vmem_set__(0,addr,v); } public static inline function setI16( addr : Int, v : Int ) : Void { untyped __vmem_set__(1,addr,v); } public static inline function setI32( addr : Int, v : Int ) : Void { untyped __vmem_set__(2,addr,v); } public static inline function setFloat( addr : Int, v : Float ) : Void { untyped __vmem_set__(3,addr,v); } public static inline function setDouble( addr : Int, v : Float ) : Void { untyped __vmem_set__(4,addr,v); } public static inline function getByte( addr : Int ) : Int { return untyped __vmem_get__(0,addr); } public static inline function getUI16( addr : Int ) : Int { return untyped __vmem_get__(1,addr); } public static inline function getI32( addr : Int ) : Int { return untyped __vmem_get__(2,addr); } public static inline function getFloat( addr : Int ) : Float { return untyped __vmem_get__(3,addr); } public static inline function getDouble( addr : Int ) : Float { return untyped __vmem_get__(4,addr); } public static inline function signExtend1( v : Int ) : Int { return untyped __vmem_sign__(0,v); } public static inline function signExtend8( v : Int ) : Int { return untyped __vmem_sign__(1,v); } public static inline function signExtend16( v : Int ) : Int { return untyped __vmem_sign__(2,v); } }haxe_3.2.1+dfsg.orig/std/flash/NativeXml.hx0000664000175000017500000002761412607337712020475 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package flash; import flash.xml.XML; import flash.xml.XMLList; extern enum XmlType { } typedef NativeXml = Xml; class Xml { public static var Element(default,null) : XmlType; public static var PCData(default,null) : XmlType; public static var CData(default,null) : XmlType; public static var Comment(default,null) : XmlType; public static var DocType(default,null) : XmlType; public static var ProcessingInstruction(default,null) : XmlType; public static var Document(default,null) : XmlType; public var nodeType(default,null) : XmlType; public var nodeName(get,set) : String; public var nodeValue(get,set) : String; public var parent(get,null) : Xml; var _node : flash.xml.XML; public static function parse( str : String ) : Xml { XML.ignoreWhitespace = false; XML.ignoreProcessingInstructions = false; XML.ignoreComments = false; var prefix = "<__document"; var root = null; while( root == null ) { try { root = new flash.xml.XML(prefix+">" + str + ""); } catch( e : flash.errors.TypeError ) { // if we miss a namespace, let's add it ! var r = ~/"([^"]+)"/; //" if( e.errorID == 1083 && r.match(e.message) ) { var ns = r.matched(1); prefix += " xmlns:" + ns + '="@' + ns + '"'; } else throw e; } } return wrap( root, Xml.Document ); } @:keep #if as3 @:hack public #end static function compare( a : Xml, b : Xml ) : Bool { return a == null ? b == null : (b == null ? false : a._node == b._node); } private function new() : Void {} public static function createElement( name : String ) : Xml { return wrap( new flash.xml.XML("<"+name+"/>"), Xml.Element ); } public static function createPCData( data : String ) : Xml { XML.ignoreWhitespace = false; return wrap( new flash.xml.XML(data), Xml.PCData ); } public static function createCData( data : String ) : Xml { return wrap( new flash.xml.XML(""), Xml.CData ); } public static function createComment( data : String ) : Xml { XML.ignoreComments = false; return wrap( new flash.xml.XML(""), Xml.Comment ); } public static function createDocType( data : String ) : Xml { return wrap( new flash.xml.XML(""), Xml.DocType ); } public static function createProcessingInstruction( data : String ) : Xml { XML.ignoreProcessingInstructions = false; return wrap( new flash.xml.XML(""), Xml.ProcessingInstruction ); } public static function createDocument() : Xml { return wrap( new flash.xml.XML("<__document/>"), Xml.Document ); } private static function getNodeType( node : flash.xml.XML ) : XmlType { switch( node.nodeKind() ) { case "element": return Xml.Element; case "text": return Xml.PCData; case "processing-instruction": return Xml.ProcessingInstruction; case "comment": return Xml.Comment; default : throw "unimplemented node type: " + node.nodeType; } } private function get_nodeName() : String { if( nodeType != Xml.Element ) throw "bad nodeType"; var ns = _node.namespace(); return (ns.prefix == "") ? _node.localName() : ns.prefix+":"+_node.localName(); } private function set_nodeName( n : String ) : String { if( nodeType != Xml.Element ) throw "bad nodeType"; var ns = n.split(":"); if( ns.length == 1 ) _node.setLocalName(n); else { _node.setLocalName(ns[1]); _node.setNamespace(_node.namespace(ns[0])); } return n; } private function get_nodeValue() : String { var nodeType = nodeType; if( nodeType == Xml.Element || nodeType == Xml.Document ) throw "bad nodeType"; if( nodeType == Xml.Comment ) return _node.toString().substr(4,-7); return _node.toString(); } private function set_nodeValue( v : String ) : String { var nodeType = nodeType; var x = null; if( nodeType == Xml.Element || nodeType == Xml.Document ) throw "bad nodeType"; else if( nodeType == Xml.PCData ) x = createPCData(v); else if( nodeType == Xml.CData ) x = createCData(v); else if( nodeType == Xml.Comment ) x = createComment(v); else if( nodeType == Xml.DocType ) x = createDocType(v); else x = createProcessingInstruction(v); var p = _node.parent(); if( p != null ) { p.insertChildAfter(_node, x._node); var i = _node.childIndex(); var children = p.children(); untyped __delete__(children, Reflect.fields(children)[i]); } _node = x._node; return v; } private function get_parent() :Xml { var p = _node.parent(); return p == null ? null : wrap( p ); } private static function wrap( node : XML, ?type : XmlType ) : Xml { var x = new Xml(); x._node = node; x.nodeType = (type != null) ? type : getNodeType( node ); return x; } private function wraps( xList : XMLList ) : Array { var out = new Array(); for( i in 0...xList.length() ) out.push( wrap(xList[i]) ); return out; } function getAttribNS( cur : XML, ns : Array ) : XMLList { var n = cur.namespace(ns[0]); if( n == null ) { var parent = cur.parent(); if( parent == null ) { n = new flash.utils.Namespace(ns[0], "@"+ns[0]); cur.addNamespace(n); } else return getAttribNS(parent, ns); } return _node.attribute(new flash.utils.QName(n,ns[1])); } public function get( att : String ) : String { if( nodeType != Xml.Element ) throw "bad nodeType"; var ns = att.split(":"); if( ns[0] == "xmlns" ) { var n = _node.namespace((ns[1] == null) ? "" : ns[1]); return (n == null) ? null : n.uri; } if( ns.length == 1 ) { if( !Reflect.hasField(_node,"@"+att) ) return null; return Reflect.field(_node, "@"+att); } var a = getAttribNS(_node,ns); return (a.length() == 0) ? null : a.toString(); } public function set( att : String, value : String ) : Void { if( nodeType != Xml.Element ) throw "bad nodeType"; var ns = att.split(":"); if( ns[0] == "xmlns" ) { var n = _node.namespace((ns[1] == null) ? "" : ns[1]); if( n != null ) throw "Can't modify namespace"; if( ns[1] == null ) throw "Can't set default namespace"; _node.addNamespace(new flash.utils.Namespace(ns[1], value)); return; } if( ns.length == 1 ) Reflect.setField(_node, "@"+att, value); else { var a = getAttribNS(_node,ns); untyped a[0] = value; } } public function remove( att : String ) : Void{ if( nodeType != Xml.Element ) throw "bad nodeType"; var ns = att.split(":"); if( ns.length == 1 ) Reflect.deleteField(_node, "@"+att); else untyped __delete__(getAttribNS(_node,ns),0); } public function exists( att : String ) : Bool { if( nodeType != Xml.Element ) throw "bad nodeType"; var ns = att.split(":"); if( ns[0] == "xmlns" ) return _node.namespace((ns[1] == null) ? "" : ns[1]) != null; if( ns.length == 1 ) return Reflect.hasField(_node, "@"+att); return getAttribNS(_node,ns).length() > 0; } public function attributes() : Iterator { if( nodeType != Xml.Element ) throw "bad nodeType"; var attributes :XMLList = _node.attributes(); var names = Reflect.fields(attributes); var cur = 0; var nss = _node.namespaceDeclarations(); return { hasNext : function(){ return cur < names.length + nss.length; }, next : function() { if(cur { if( nodeType != Xml.Element && nodeType != Xml.Document ) throw "bad nodeType"; var children:XMLList = _node.children(); var wrappers :Array = wraps(children); var cur = 0; return { hasNext : function(){ return cur < wrappers.length; }, next : function(){ return wrappers[cur++]; } }; } public function elements() : Iterator { if( nodeType != Xml.Element && nodeType != Xml.Document ) throw "bad nodeType"; var elements:XMLList = _node.elements(); var wrappers :Array = wraps(elements); var cur = 0; return { hasNext : function(){ return cur < wrappers.length; }, next : function(){ return wrappers[cur++]; } }; } public function elementsNamed( name : String ) : Iterator { if( nodeType != Xml.Element && nodeType != Xml.Document ) throw "bad nodeType"; var ns = name.split(":"); var elements:XMLList; if( ns.length == 1 ) elements = _node.elements(name); else elements = _node.elements(); var wrappers :Array = wraps(elements); if( ns.length != 1 ) for( w in wrappers.copy() ) if( w._node.localName() != ns[1] || w._node.namespace().prefix != ns[0] ) wrappers.remove(w); var cur = 0; return { hasNext : function(){ return cur < wrappers.length; }, next : function(){ return wrappers[cur++]; } }; } public function firstChild() : Xml { if( nodeType != Xml.Element && nodeType != Xml.Document ) throw "bad nodeType"; var children:XMLList = _node.children(); if( children.length() == 0 ) return null; return wrap( children[0] ); } public function firstElement() : Xml { if( nodeType != Xml.Element && nodeType != Xml.Document ) throw "bad nodeType"; var elements:XMLList = _node.elements(); if( elements.length() == 0 ) return null; return wrap( elements[0] ); } public function addChild( x : Xml ) : Void { if( nodeType != Xml.Element && nodeType != Xml.Document ) throw "bad nodeType"; if (x.parent != null) x.parent.removeChild(x); var children:XMLList = _node.children(); _node.appendChild(x._node); } public function removeChild( x : Xml ) : Bool { if( nodeType != Xml.Element && nodeType != Xml.Document ) throw "bad nodeType"; var children:XMLList = _node.children(); if( _node != x._node.parent() ) return false; var i = x._node.childIndex(); untyped __delete__(children, Reflect.fields(children)[i]); return true; } public function insertChild( x : Xml, pos : Int ) : Void { if( nodeType != Xml.Element && nodeType != Xml.Document ) throw "bad nodeType"; if (x.parent != null) x.parent.removeChild(x); var children:XMLList = _node.children(); if( pos < children.length() ) _node.insertChildBefore(children[pos], x._node); else _node.appendChild(x._node); } public function toString() : String { XML.prettyPrinting = false; if( nodeType == Xml.Document ) { var str = _node.toXMLString(); // remove <__document xmlns....>STR wrapper str = str.substr(str.indexOf(">") + 1); str = str.substr(0, str.length - 13); return str; } return _node.toXMLString(); } static function __init__() : Void untyped { Element = "element"; PCData = "pcdata"; CData = "cdata"; Comment = "comment"; DocType = "doctype"; ProcessingInstruction = "processingInstruction"; Document = "document"; } }haxe_3.2.1+dfsg.orig/std/flash/Vector.hx0000664000175000017500000000413712607337712020023 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package flash; /** The Vector class is very similar to Array but is only supported by the Flash Player 10+ **/ @:require(flash10) extern class Vector implements ArrayAccess { var length : Int; var fixed : Bool; function new( ?length : UInt, ?fixed : Bool ) : Void; function concat( ?a : Vector ) : Vector; function join( sep : String ) : String; function pop() : Null; function push(x : T) : Int; function reverse() : Void; function shift() : Null; function unshift( x : T ) : Void; function slice( ?pos : Int, ?end : Int ) : Vector; function sort( f : T -> T -> Int ) : Void; function splice( pos : Int, len : Int ) : Vector; function toString() : String; function indexOf( x : T, ?from : Int ) : Int; function lastIndexOf( x : T, ?from : Int ) : Int; public inline static function ofArray( v : Array ) : Vector { return untyped __vector__(v); } public inline static function convert( v : Vector ) : Vector { return untyped __vector__(v); } } haxe_3.2.1+dfsg.orig/std/flash/_std/EReg.hx0000664000175000017500000000702612607337712020334 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class EReg { var r : flash.utils.RegExp; var result : Dynamic; public function new( r : String, opt : String ) : Void { this.r = new flash.utils.RegExp(r,opt); } public function match( s : String ) : Bool { if( r.global ) r.lastIndex = 0; result = r.exec(s); return (result != null); } public function matched( n : Int ) : String { return if( result != null && n >= 0 && n < (result : Array).length ) result[n] else throw "EReg::matched"; } public function matchedLeft() : String { if( result == null ) throw "No string matched"; var s : String = untyped result.input; return s.substr(0,untyped result["index"]); } public function matchedRight() : String { if( result == null ) throw "No string matched"; var rl = (result[untyped "index"] : Int) + (result[0] : String).length; var s : String = untyped result.input; return s.substr(rl,s.length - rl); } public function matchedPos() : { pos : Int, len : Int } { if( result == null ) throw "No string matched"; return { pos : result[untyped "index"], len : (result[0] : String).length }; } public function matchSub( s : String, pos : Int, len : Int = -1):Bool { return if (r.global) { r.lastIndex = pos; result = r.exec(len < 0 ? s : s.substr(0, pos + len)); var b = result != null; if (b) { untyped result.input = s; } b; } else { var b = match( len < 0 ? s.substr(pos) : s.substr(pos,len) ); if (b) { untyped result.input = s; untyped result["index"] += pos; } b; } } public function split( s : String ) : Array { // we can't use directly s.split because it's ignoring the 'g' flag var d = "#__delim__#"; var s : String = untyped s.replace(r, d); return s.split(d); } public function replace( s : String, by : String ) : String { return untyped s.replace(r,by); } public function map( s : String, f : EReg -> String ) : String { var offset = 0; var buf = new StringBuf(); var first = true; do { if (offset >= s.length) break; else if (!matchSub(s, offset)) { buf.add(s.substr(offset)); break; } var p = matchedPos(); buf.add(s.substr(offset, p.pos - offset)); buf.add(f(this)); if (p.len == 0) { buf.add(s.substr(p.pos, 1)); offset = p.pos + 1; } else offset = p.pos + p.len; first = false; } while (r.global); if (!r.global && offset > 0 && offset < s.length) buf.add(s.substr(offset)); return buf.toString(); } } haxe_3.2.1+dfsg.orig/std/flash/_std/Reflect.hx0000664000175000017500000000763712607337712021106 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class Reflect { public static function hasField( o : Dynamic, field : String ) : Bool untyped { return o.hasOwnProperty( field ); } public static function field( o : Dynamic, field : String ) : Dynamic untyped { // sealed classes will throw an exception return try o[field] catch( e : Dynamic ) null; } public inline static function setField( o : Dynamic, field : String, value : Dynamic ) : Void untyped { o[field] = value; } public static function getProperty( o : Dynamic, field : String ) : Dynamic untyped { try { return o["get_" + field](); } catch( e : Dynamic ) try { return o[field]; } catch( e : Dynamic ) { return null; } } public static function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void untyped { try { o["set_" + field](value); } catch( e : Dynamic ) { o[field] = value; } } public inline static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array ) : Dynamic untyped { return func.apply(o,args); } public static function fields( o : Dynamic ) : Array untyped { if( o == null ) return new Array(); #if as3 var a : Array = __keys__(o); var i = 0; while( i < a.length ){ if( !o.hasOwnProperty(a[i]) ) a.splice(i,1); else ++i; } #else var i = 0; var a = []; while( untyped __has_next__(o,i) ) { var prop = untyped __forin__(o,i); if( o.hasOwnProperty(prop) ) a.push(prop); } #end return a; } public static function isFunction( f : Dynamic ) : Bool untyped { return __typeof__(f) == "function"; } public static function compare( a : T, b : T ) : Int { var a : Dynamic = a; var b : Dynamic = b; return ( a == b ) ? 0 : ((a > b) ? 1 : -1); } public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool { return f1 == f2; // VM-level closures } public static function isObject( v : Dynamic ) : Bool untyped { if( v == null ) return false; var t = __typeof__(v); if ( t == "object" ) { return !isEnumValue(v); } return (t == "string"); } public static function isEnumValue( v : Dynamic ) : Bool { #if as3 return try Type.getEnum(v) != null catch ( e: Dynamic) false; #else return try v.__enum__ == true catch ( e : Dynamic) false; #end } public static function deleteField( o : Dynamic, field : String ) : Bool untyped { if( o.hasOwnProperty(field) != true ) return false; __delete__(o,field); return true; } public static function copy( o : T ) : T { var o2 : Dynamic = {}; for( f in Reflect.fields(o) ) Reflect.setField(o2,f,Reflect.field(o,f)); return o2; } @:overload(function( f : Array -> Void ) : Dynamic {}) public static function makeVarArgs( f : Array -> Dynamic ) : Dynamic { return function(__arguments__) { return f(__arguments__); }; } } haxe_3.2.1+dfsg.orig/std/flash/_std/Std.hx0000664000175000017500000000371012607337712020240 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import flash.Boot; @:coreApi class Std { public static function is( v : Dynamic, t : Dynamic ) : Bool { return untyped flash.Boot.__instanceof(v,t); } public static inline function instance( value : T, c : Class ) : S { return flash.Lib.as(value, c); } public static function string( s : Dynamic ) : String { return untyped flash.Boot.__string_rec(s,""); } public inline static function int( x : Float ) : Int { return untyped __int__(x); } public static function parseInt( x : String ) : Null untyped { var v = __global__["parseInt"](x); if( __global__["isNaN"](v) ) return null; return v; } public static function parseFloat( x : String ) : Float { return untyped __global__["parseFloat"](x); } public static function random( x : Int ) : Int { return untyped x <= 0 ? 0 : Math.floor(Math.random()*x); } } haxe_3.2.1+dfsg.orig/std/flash/_std/Type.hx0000664000175000017500000002217512607337712020435 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ enum ValueType { TNull; TInt; TFloat; TBool; TObject; TFunction; TClass( c : Class ); TEnum( e : Enum ); TUnknown; } @:coreApi class Type { public static function getClass( o : T ) : Class untyped { var cname = __global__["flash.utils.getQualifiedClassName"](o); if( cname == "null" || cname == "Object" || cname == "int" || cname == "Number" || cname == "Boolean" ) return null; if( o.hasOwnProperty("prototype") ) return null; var c = __as__(__global__["flash.utils.getDefinitionByName"](cname),Class); if( c.__isenum ) return null; return c; } public static function getEnum( o : EnumValue ) : Enum untyped { var cname = __global__["flash.utils.getQualifiedClassName"](o); if( cname == "null" || cname.substr(0,8) == "builtin." ) return null; // getEnum(Enum) should be null if( o.hasOwnProperty("prototype") ) return null; var c = __as__(__global__["flash.utils.getDefinitionByName"](cname),Class); if( !c.__isenum ) return null; return c; } public static function getSuperClass( c : Class ) : Class untyped { var cname = __global__["flash.utils.getQualifiedSuperclassName"](c); if( cname == null || cname == "Object" ) return null; return __as__(__global__["flash.utils.getDefinitionByName"](cname),Class); } public static function getClassName( c : Class ) : String { if( c == null ) return null; var str : String = untyped __global__["flash.utils.getQualifiedClassName"](c); switch( str ) { case "int": return "Int"; case "Number": return "Float"; case "Boolean": return "Bool"; #if as3 case "Object": return "Dynamic"; #end default: } return str.split("::").join("."); } public static function getEnumName( e : Enum ) : String { return getClassName(cast e); } public static function resolveClass( name : String ) : Class untyped { var cl : Class; try { cl = __as__(__global__["flash.utils.getDefinitionByName"](name),Class); if( cl.__isenum ) return null; return cl; // skip test below } catch( e : Dynamic ) { switch( name ) { case "Int": return Int; case "Float": return Float; #if as3 case "Dynamic": return Dynamic; #end } return null; } // ensure that this is a class if( cl == null || cl.__name__ == null ) return null; return cl; } public static function resolveEnum( name : String ) : Enum untyped { var e : Dynamic; try { e = __global__["flash.utils.getDefinitionByName"](name); if( !e.__isenum ) return null; return e; } catch( e : Dynamic ) { if( name == "Bool" ) return Bool; return null; } // ensure that this is an enum if( e == null || e.__ename__ == null ) return null; return e; } public static function createInstance( cl : Class, args : Array ) : T untyped { return switch( args.length ) { case 0: __new__(cl); case 1: __new__(cl,args[0]); case 2: __new__(cl,args[0],args[1]); case 3: __new__(cl,args[0],args[1],args[2]); case 4: __new__(cl,args[0],args[1],args[2],args[3]); case 5: __new__(cl,args[0],args[1],args[2],args[3],args[4]); case 6: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5]); case 7: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6]); case 8: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]); case 9: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]); case 10: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9]); case 11: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10]); case 12: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11]); case 13: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12]); case 14: __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10],args[11],args[12],args[13]); default: throw "Too many arguments"; } } public static function createEmptyInstance( cl : Class ) : T untyped { try { flash.Boot.skip_constructor = true; var i = __new__(cl); flash.Boot.skip_constructor = false; return i; } catch( e : Dynamic ) { flash.Boot.skip_constructor = false; throw e; } return null; } public static function createEnum( e : Enum, constr : String, ?params : Array ) : T { var f:Dynamic = untyped e[constr]; if( f == null ) throw "No such constructor "+constr; if( Reflect.isFunction(f) ) { if( params == null ) throw "Constructor "+constr+" need parameters"; return Reflect.callMethod(e,f,params); } if( params != null && params.length != 0 ) throw "Constructor "+constr+" does not need parameters"; return f; } public static function createEnumIndex( e : Enum, index : Int, ?params : Array ) : T { var c : String = (untyped e.__constructs__)[index]; if( c == null ) throw index+" is not a valid enum constructor index"; return createEnum(e,c,params); } static function describe( t : Dynamic, fact : Bool ) : Array untyped { var fields = new Array(); var xml : flash.xml.XML = __global__["flash.utils.describeType"](t); if( fact ) xml = xml.factory[0]; var methods = xml.child("method"); for( i in 0...methods.length() ) fields.push( Std.string(methods[i].attribute("name")) ); var vars = xml.child("variable"); for( i in 0...vars.length() ) fields.push( Std.string(vars[i].attribute("name")) ); var accs = xml.child("accessor"); for( i in 0...accs.length() ) fields.push( Std.string(accs[i].attribute("name")) ); return fields; } public static function getInstanceFields( c : Class ) : Array { return describe(c,true); } public static function getClassFields( c : Class ) : Array { var a = describe(c,false); a.remove("__construct__"); a.remove("prototype"); return a; } public static function getEnumConstructs( e : Enum ) : Array { var a : Array = untyped e.__constructs__; return a.copy(); } public static function typeof( v : Dynamic ) : ValueType untyped { var cname = __global__["flash.utils.getQualifiedClassName"](v); switch(cname) { case "null": return TNull; case "void": return TNull; // undefined case "int": return TInt; case "Number": // integers >28 bits are stored as Numbers in avm2 if( (v < -0x10000000 || v >= 0x10000000) && Std.int(v) == v ) return TInt; return TFloat; case "Boolean": return TBool; case "Object": return TObject; case "Function": return TFunction; default: var c : Dynamic = null; try { c = __global__["flash.utils.getDefinitionByName"](cname); if( v.hasOwnProperty("prototype") ) return TObject; if( c.__isenum ) return TEnum(c); return TClass(c); } catch( e : Dynamic ) { if( cname == "builtin.as$0::MethodClosure" || cname.indexOf("-") != -1 ) return TFunction; return if( c == null ) TFunction else TClass(c); } } return null; } public static function enumEq( a : T, b : T ) : Bool untyped { if( a == b ) return true; try { if( a.index != b.index ) return false; var ap : Array = a.params; var bp : Array = b.params; for( i in 0...ap.length ) if( !enumEq(ap[i],bp[i]) ) return false; } catch( e : Dynamic ) { return false; } return true; } public static function enumConstructor( e : EnumValue ) : String { return untyped e.tag; } public static function enumParameters( e : EnumValue ) : Array { return untyped if( e.params == null ) [] else e.params; } public inline static function enumIndex( e : EnumValue ) : Int { return untyped e.index; } public static function allEnums( e : Enum ) : Array { var all = []; var cst : Array = untyped e.__constructs__; for( c in cst ) { var v = Reflect.field(e,c); if( !Reflect.isFunction(v) ) all.push(v); } return all; } } haxe_3.2.1+dfsg.orig/std/flash/_std/haxe/Json.hx0000664000175000017500000000307412607337712021347 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; @:coreApi #if (!haxeJSON && flash11) @:native("JSON") extern #end class Json { #if (haxeJSON || !flash11) inline #end public static function parse( text : String ) : Dynamic { return haxe.format.JsonParser.parse(text); } #if (haxeJSON || !flash11) inline #end public static function stringify( value : Dynamic, ?replacer:Dynamic -> Dynamic -> Dynamic, ?space:String ) : String { return haxe.format.JsonPrinter.print(value, replacer, space); } } haxe_3.2.1+dfsg.orig/std/flash/_std/haxe/Resource.hx0000664000175000017500000000521112607337712022220 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; #if as3 @:coreApi class Resource { public static function listNames() : Array untyped { return __keys__(__resources__.list); } public static function getString( name : String ) : String { var b = resolve(name); return b == null ? null : b.readUTFBytes(b.length); } public static function getBytes( name : String ) : haxe.io.Bytes { var b = resolve(name); return b == null ? null : haxe.io.Bytes.ofData(b); } static function resolve( name : String) :flash.utils.ByteArray untyped { var n = __resources__.list[name]; if (n == null) return null; return untyped __new__(n); } static function __init__() : Void { untyped __resources__.__init__(); } } #else @:coreApi class Resource { static var content : Array<{ name : String }>; public static function listNames() : Array { var names = new Array(); for( x in content ) names.push(x.name); return names; } public static function getString( name : String ) : String { var b = resolve(name); return b == null ? null : b.readUTFBytes(b.length); } public static function getBytes( name : String ) : haxe.io.Bytes { var b = resolve(name); return b == null ? null : haxe.io.Bytes.ofData(b); } static function resolve( name : String ) : flash.utils.ByteArray { try untyped { var c = __as__(__global__["flash.utils.getDefinitionByName"]("_res._"+name.split(".").join("_")),Class); return __new__(c); } catch( e : Dynamic ) { return null; } } static function __init__() : Void { content = untyped __resources__(); } } #endhaxe_3.2.1+dfsg.orig/std/flash/_std/haxe/ds/IntMap.hx0000664000175000017500000000442512607337712022235 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; @:coreApi class IntMap implements haxe.Constraints.IMap { private var h : flash.utils.Dictionary; public function new() : Void { h = new flash.utils.Dictionary(); } public inline function set( key : Int, value : T ) : Void { untyped h[key] = value; } public inline function get( key : Int ) : Null { return untyped h[key]; } public inline function exists( key : Int ) : Bool { return untyped __in__(key,h); } public function remove( key : Int ) : Bool { if( !exists(key) ) return false; untyped __delete__(h,key); return true; } public function keys() : Iterator { return untyped (__keys__(h)).iterator(); } @:analyzer(ignore) public function iterator() : Iterator { return untyped { ref : h, it : keys(), hasNext : function() { return __this__.it.hasNext(); }, next : function() { var i = __this__.it.next(); return __this__.ref[i]; } }; } public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(i); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } } haxe_3.2.1+dfsg.orig/std/flash/_std/haxe/ds/ObjectMap.hx0000664000175000017500000000453712607337712022715 0ustar andyandy00000000000000package haxe.ds; @:coreApi class ObjectMap extends flash.utils.Dictionary implements haxe.Constraints.IMap { public function new() { super(false); } public inline function get( key : K ) : Null { return untyped this[key]; } public inline function set( key : K, value : V ):Void { untyped this[key] = value; } public inline function exists( key : K ) : Bool { return untyped this[key] != null; } public function remove( key : K ):Bool { var has = exists(key); untyped __delete__(this, key); return has; } #if as3 public function keys() : Iterator { return untyped __keys__(this).iterator(); } public function iterator() : Iterator { var ret = []; for (i in keys()) ret.push(get(i)); return ret.iterator(); } #else public function keys() : Iterator { return NativePropertyIterator.iterator(this); } public function iterator() : Iterator { return NativeValueIterator.iterator(this); } #end public function toString() : String { var s = ""; var it = keys(); for( i in it ) { s += (s == "" ? "" : ",") + Std.string(i); s += " => "; s += Std.string(get(i)); } return s + "}"; } } private class NativePropertyIterator { var collection:Dynamic; var index:Int = 0; public static inline function iterator(collection:Dynamic):NativePropertyIterator { var result = new NativePropertyIterator(); result.collection = collection; return result; } function new() {} public inline function hasNext():Bool { var c = collection; var i = index; var result = untyped __has_next__(c, i); collection = c; index = i; return result; } public inline function next():Dynamic { var i = index; var result = untyped __forin__(collection, i); index = i; return result; } } private class NativeValueIterator { var collection:Dynamic; var index:Int = 0; public static inline function iterator(collection:Dynamic):NativeValueIterator { var result = new NativeValueIterator(); result.collection = collection; return result; } function new() {} public inline function hasNext():Bool { var c = collection; var i = index; var result = untyped __has_next__(c, i); collection = c; index = i; return result; } public inline function next():Dynamic { var i = index; var result = untyped __foreach__(collection, i); index = i; return result; } } haxe_3.2.1+dfsg.orig/std/flash/_std/haxe/ds/StringMap.hx0000664000175000017500000001176612607337712022757 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; @:coreApi class StringMap implements haxe.Constraints.IMap { private var h : Dynamic; private var rh : Dynamic; static var reserved = { }; public function new() : Void { h = {}; } inline function isReserved(key:String) : Bool { return untyped __in__(key,reserved); } public inline function set( key : String, value : T ) : Void { if( isReserved(key) ) setReserved(key, value); else untyped h[key] = value; } public inline function get( key : String ) : Null { if( isReserved(key) ) return getReserved(key); return untyped h[key]; } public inline function exists( key : String ) : Bool { if( isReserved(key) ) return existsReserved(key); return untyped __in__(key,h); } function setReserved( key : String, value : T ) : Void { if( rh == null ) rh = {}; untyped rh["$"+key] = value; } function getReserved( key : String ) : Null { return rh == null ? null : untyped rh["$"+key]; } function existsReserved( key : String ) : Bool { if( rh == null ) return false; return untyped __in__("$"+key,rh); } public function remove( key : String ) : Bool { if( isReserved(key) ) { key = "$" + key; if( rh == null || !untyped __in__(key,rh) ) return false; untyped __delete__(rh,key); return true; } else { if( !untyped __in__(key,h) ) return false; untyped __delete__(h,key); return true; } } #if as3 // unoptimized version public function keys() : Iterator { var out : Array = untyped __keys__(h); if( rh != null ) out = out.concat(untyped __hkeys__(rh)); return out.iterator(); } public function iterator() : Iterator { return untyped { it : keys(), hasNext : function() { return __this__.it.hasNext(); }, next : function() { return get(__this__.it.next()); } }; } #else public inline function keys() : Iterator { return new StringMapKeysIterator(h, rh); } public inline function iterator() : Iterator { return new StringMapValuesIterator(h, rh); } #end public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(i); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } } #if !as3 // this version uses __has_next__/__forin__ special SWF opcodes for iteration with no allocation @:allow(haxe.ds.StringMap) private class StringMapKeysIterator { var h:Dynamic; var rh:Dynamic; var index : Int; var nextIndex : Int; var isReserved : Bool; inline function new(h:Dynamic, rh:Dynamic):Void { this.h = h; this.rh = rh; this.index = 0; isReserved = false; hasNext(); } public inline function hasNext():Bool { var h = h, index = index; // tmp vars required for __has_next var n = untyped __has_next__(h, index); if( !n && rh != null ) { h = this.h = rh; index = this.index = 0; rh = null; isReserved = true; n = untyped __has_next__(h, index); } this.nextIndex = index; // store next index return n; } public inline function next():String { var r : String = untyped __forin__(h, nextIndex); index = nextIndex; if( isReserved ) r = r.substr(1); return r; } } @:allow(haxe.ds.StringMap) private class StringMapValuesIterator { var h:Dynamic; var rh:Dynamic; var index : Int; var nextIndex : Int; inline function new(h:Dynamic, rh:Dynamic):Void { this.h = h; this.rh = rh; this.index = 0; hasNext(); } public inline function hasNext():Bool { var h = h, index = index; // tmp vars required for __has_next var n = untyped __has_next__(h, index); if( !n && rh != null ) { h = this.h = rh; index = this.index = 0; rh = null; n = untyped __has_next__(h, index); } this.nextIndex = index; // store next index return n; } public inline function next():T { var r = untyped __foreach__(h, nextIndex); index = nextIndex; return r; } } #end haxe_3.2.1+dfsg.orig/std/flash/_std/haxe/ds/UnsafeStringMap.hx0000664000175000017500000000504312607337712024110 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** This is similar to `StringMap` excepts that it does not sanitize the keys. As a result, it will be faster to access the map for reading, but it might fail with some reserved keys such as `constructor` or `prototype`. **/ class UnsafeStringMap implements haxe.Constraints.IMap { private var h : flash.utils.Dictionary; public function new() : Void { h = new flash.utils.Dictionary(); } public inline function set( key : String, value : T ) : Void { untyped h[key] = value; } public inline function get( key : String ) : Null { return untyped h[key]; } public inline function exists( key : String ) : Bool { return untyped __in__(key,h); } public function remove( key : String ) : Bool { if( untyped !h.hasOwnProperty(key) ) return false; untyped __delete__(h,key); return true; } public function keys() : Iterator { return untyped (__keys__(h)).iterator(); } public function iterator() : Iterator { return untyped { ref : h, it : __keys__(h).iterator(), hasNext : function() { return __this__.it.hasNext(); }, next : function() { var i : Dynamic = __this__.it.next(); return __this__.ref[i]; } }; } public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(i); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } } haxe_3.2.1+dfsg.orig/std/flash/_std/haxe/ds/WeakMap.hx0000664000175000017500000000453412607337712022373 0ustar andyandy00000000000000package haxe.ds; @:coreApi class WeakMap extends flash.utils.Dictionary implements haxe.Constraints.IMap { public function new() { super(true); } public inline function get( key : K ) : Null { return untyped this[key]; } public inline function set( key : K, value : V ):Void { untyped this[key] = value; } public inline function exists( key : K ) : Bool { return untyped this[key] != null; } public function remove( key : K ):Bool { var has = exists(key); untyped __delete__(this, key); return has; } #if as3 public function keys() : Iterator { return untyped __keys__(this).iterator(); } public function iterator() : Iterator { var ret = []; for (i in keys()) ret.push(get(i)); return ret.iterator(); } #else public function keys() : Iterator { return NativePropertyIterator.iterator(this); } public function iterator() : Iterator { return NativeValueIterator.iterator(this); } #end public function toString() : String { var s = ""; var it = keys(); for( i in it ) { s += (s == "" ? "" : ",") + Std.string(i); s += " => "; s += Std.string(get(i)); } return s + "}"; } } private class NativePropertyIterator { var collection:Dynamic; var index:Int = 0; public static inline function iterator(collection:Dynamic):NativePropertyIterator { var result = new NativePropertyIterator(); result.collection = collection; return result; } function new() {} public inline function hasNext():Bool { var c = collection; var i = index; var result = untyped __has_next__(c, i); collection = c; index = i; return result; } public inline function next():Dynamic { var i = index; var result = untyped __forin__(collection, i); index = i; return result; } } private class NativeValueIterator { var collection:Dynamic; var index:Int = 0; public static inline function iterator(collection:Dynamic):NativeValueIterator { var result = new NativeValueIterator(); result.collection = collection; return result; } function new() {} public inline function hasNext():Bool { var c = collection; var i = index; var result = untyped __has_next__(c, i); collection = c; index = i; return result; } public inline function next():Dynamic { var i = index; var result = untyped __foreach__(collection, i); index = i; return result; } } haxe_3.2.1+dfsg.orig/std/flash/_std/haxe/zip/Compress.hx0000664000175000017500000000370012607337712023027 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; @:coreApi class Compress { public function new( level : Int ) : Void { throw "Not implemented for this platform"; } public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } { return null; } public function setFlushMode( f : FlushMode ) : Void { } public function close() : Void { } public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes { if( s.length == 0 ) { // Flash returns 0 bytes for 0 length compress (which can't be decoded on other platforms...) var b = haxe.io.Bytes.alloc(8); b.set(0,0x78);b.set(1,0xDA);b.set(2,0x03); b.set(7,0x01); return b; } var tmp = new flash.utils.ByteArray(); tmp.writeBytes(s.getData(),0,s.length); tmp.compress(); return haxe.io.Bytes.ofData(tmp); } } haxe_3.2.1+dfsg.orig/std/flash/_std/haxe/zip/Uncompress.hx0000664000175000017500000000334612607337712023400 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; @:coreApi class Uncompress { public function new( ?windowBits : Int ) : Void { throw "Not implemented for this platform"; } public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } { return null; } public function setFlushMode( f : FlushMode ) : Void { } public function close() : Void { } public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes { var tmp = new flash.utils.ByteArray(); tmp.writeBytes(src.getData(),0,src.length); tmp.uncompress(); return haxe.io.Bytes.ofData(tmp); } } haxe_3.2.1+dfsg.orig/std/flash/accessibility/Accessibility.hx0000664000175000017500000000042512607337712024173 0ustar andyandy00000000000000package flash.accessibility; extern class Accessibility { static var active(default,null) : Bool; static function sendEvent(source : flash.display.DisplayObject, childID : UInt, eventType : UInt, nonHTML : Bool = false) : Void; static function updateProperties() : Void; } haxe_3.2.1+dfsg.orig/std/flash/accessibility/AccessibilityImplementation.hx0000664000175000017500000000150312607337712027077 0ustar andyandy00000000000000package flash.accessibility; extern class AccessibilityImplementation { var errno : UInt; var stub : Bool; function new() : Void; function accDoDefaultAction(childID : UInt) : Void; function accLocation(childID : UInt) : Dynamic; function accSelect(operation : UInt, childID : UInt) : Void; function getChildIDArray() : Array; function get_accDefaultAction(childID : UInt) : String; function get_accFocus() : UInt; function get_accName(childID : UInt) : String; function get_accRole(childID : UInt) : UInt; function get_accSelection() : Array; function get_accState(childID : UInt) : UInt; function get_accValue(childID : UInt) : String; function get_selectionActiveIndex() : Dynamic; function get_selectionAnchorIndex() : Dynamic; function isLabeledBy(labelBounds : flash.geom.Rectangle) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/accessibility/AccessibilityProperties.hx0000664000175000017500000000035712607337712026254 0ustar andyandy00000000000000package flash.accessibility; extern class AccessibilityProperties { var description : String; var forceSimple : Bool; var name : String; var noAutoLabeling : Bool; var shortcut : String; var silent : Bool; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/accessibility/ISearchableText.hx0000664000175000017500000000020012607337712024402 0ustar andyandy00000000000000package flash.accessibility; @:require(flash10_1) extern interface ISearchableText { var searchText(default,null) : String; } haxe_3.2.1+dfsg.orig/std/flash/accessibility/ISimpleTextSelection.hx0000664000175000017500000000027312607337712025462 0ustar andyandy00000000000000package flash.accessibility; @:require(flash10_1) extern interface ISimpleTextSelection { var selectionActiveIndex(default,null) : Int; var selectionAnchorIndex(default,null) : Int; } haxe_3.2.1+dfsg.orig/std/flash/automation/ActionGenerator.hx0000664000175000017500000000033312607337712024017 0ustar andyandy00000000000000package flash.automation; @:require(flash10_1) extern class ActionGenerator { function new() : Void; function generateAction(action : AutomationAction) : Void; function generateActions(a : Array) : Void; } haxe_3.2.1+dfsg.orig/std/flash/automation/AutomationAction.hx0000664000175000017500000000017612607337712024216 0ustar andyandy00000000000000package flash.automation; @:require(flash10_1) extern class AutomationAction { var type : String; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/automation/Configuration.hx0000664000175000017500000000027112607337712023543 0ustar andyandy00000000000000package flash.automation; @:require(flash10_1) extern class Configuration { static var deviceConfiguration : String; static var testAutomationConfiguration(default,null) : String; } haxe_3.2.1+dfsg.orig/std/flash/automation/KeyboardAutomationAction.hx0000664000175000017500000000037512607337712025700 0ustar andyandy00000000000000package flash.automation; @:require(flash10_1) extern class KeyboardAutomationAction extends AutomationAction { var keyCode : UInt; function new(type : String, keyCode : UInt = 0) : Void; static var KEY_DOWN : String; static var KEY_UP : String; } haxe_3.2.1+dfsg.orig/std/flash/automation/MouseAutomationAction.hx0000664000175000017500000000104712607337712025225 0ustar andyandy00000000000000package flash.automation; @:require(flash10_1) extern class MouseAutomationAction extends AutomationAction { var delta : Int; var stageX : Float; var stageY : Float; function new(type : String, stageX : Float = 0, stageY : Float = 0, delta : Int = 0) : Void; static var MIDDLE_MOUSE_DOWN : String; static var MIDDLE_MOUSE_UP : String; static var MOUSE_DOWN : String; static var MOUSE_MOVE : String; static var MOUSE_UP : String; static var MOUSE_WHEEL : String; static var RIGHT_MOUSE_DOWN : String; static var RIGHT_MOUSE_UP : String; } haxe_3.2.1+dfsg.orig/std/flash/automation/StageCapture.hx0000664000175000017500000000102612607337712023322 0ustar andyandy00000000000000package flash.automation; @:require(flash10_1) extern class StageCapture extends flash.events.EventDispatcher { var captureSource : String; var clipRect : flash.geom.Rectangle; var fileNameBase : String; function new() : Void; function cancel() : Void; function capture(type : String) : Void; function captureBitmapData() : flash.display.BitmapData; static var CURRENT : String; static var MULTIPLE : String; static var NEXT : String; static var RASTER : String; static var SCREEN : String; static var STAGE : String; } haxe_3.2.1+dfsg.orig/std/flash/automation/StageCaptureEvent.hx0000664000175000017500000000051512607337712024326 0ustar andyandy00000000000000package flash.automation; @:require(flash10_1) extern class StageCaptureEvent extends flash.events.Event { var checksum(default,null) : UInt; var url(default,null) : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?url : String, checksum : UInt = 0) : Void; static var CAPTURE : String; } haxe_3.2.1+dfsg.orig/std/flash/concurrent/Condition.hx0000664000175000017500000000045612607337712022671 0ustar andyandy00000000000000package flash.concurrent; @:final @:require(flash11_4) extern class Condition { var mutex(default,null) : Mutex; function new(mutex : Mutex) : Void; function notify() : Void; function notifyAll() : Void; function wait(timeout : Float = -1) : Bool; static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/concurrent/Mutex.hx0000664000175000017500000000034512607337712022042 0ustar andyandy00000000000000package flash.concurrent; @:final @:require(flash11_4) extern class Mutex { function new() : Void; function lock() : Void; function tryLock() : Bool; function unlock() : Void; static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/desktop/Clipboard.hx0000664000175000017500000000121212607337712022120 0ustar andyandy00000000000000package flash.desktop; @:require(flash10) extern class Clipboard { var formats(default,null) : Array; function clear() : Void; function clearData(format : ClipboardFormats) : Void; function getData(format : ClipboardFormats, ?transferMode : ClipboardTransferMode) : flash.utils.Object; function hasFormat(format : ClipboardFormats) : Bool; function setData(format : ClipboardFormats, data : flash.utils.Object, serializable : Bool = true) : Bool; function setDataHandler(format : ClipboardFormats, handler : flash.utils.Function, serializable : Bool = true) : Bool; static var generalClipboard(default,null) : Clipboard; } haxe_3.2.1+dfsg.orig/std/flash/desktop/ClipboardFormats.hx0000664000175000017500000000043712607337712023464 0ustar andyandy00000000000000package flash.desktop; @:fakeEnum(String) @:require(flash10) extern enum ClipboardFormats { AIR_PREFIX; BITMAP_FORMAT; FILE_LIST_FORMAT; FILE_PROMISE_LIST_FORMAT; FLASH_PREFIX; HTML_FORMAT; REFERENCE_PREFIX; RICH_TEXT_FORMAT; SERIALIZATION_PREFIX; TEXT_FORMAT; URL_FORMAT; } haxe_3.2.1+dfsg.orig/std/flash/desktop/ClipboardTransferMode.hx0000664000175000017500000000025012607337712024433 0ustar andyandy00000000000000package flash.desktop; @:fakeEnum(String) @:require(flash10) extern enum ClipboardTransferMode { CLONE_ONLY; CLONE_PREFERRED; ORIGINAL_ONLY; ORIGINAL_PREFERRED; } haxe_3.2.1+dfsg.orig/std/flash/display/AVM1Movie.hx0000664000175000017500000000046212607337712021727 0ustar andyandy00000000000000package flash.display; extern class AVM1Movie extends DisplayObject { function new() : Void; function addCallback(functionName : String, closure : flash.utils.Function) : Void; function call(functionName : String, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Dynamic; } haxe_3.2.1+dfsg.orig/std/flash/display/ActionScriptVersion.hx0000664000175000017500000000015512607337712024172 0ustar andyandy00000000000000package flash.display; @:fakeEnum(UInt) extern enum ActionScriptVersion { ACTIONSCRIPT2; ACTIONSCRIPT3; } haxe_3.2.1+dfsg.orig/std/flash/display/Bitmap.hx0000664000175000017500000000041112607337712021431 0ustar andyandy00000000000000package flash.display; extern class Bitmap extends DisplayObject { var bitmapData : BitmapData; var pixelSnapping : PixelSnapping; var smoothing : Bool; function new(?bitmapData : BitmapData, ?pixelSnapping : PixelSnapping, smoothing : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/BitmapCompressColorSpace.hx0000664000175000017500000000023012607337712025117 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) enum BitmapCompressColorSpace { COLORSPACE_4_2_0; COLORSPACE_4_2_2; COLORSPACE_4_4_4; COLORSPACE_AUTO; } haxe_3.2.1+dfsg.orig/std/flash/display/BitmapData.hx0000664000175000017500000001055712607337712022237 0ustar andyandy00000000000000package flash.display; extern class BitmapData implements IBitmapDrawable { var height(default,null) : Int; var rect(default,null) : flash.geom.Rectangle; var transparent(default,null) : Bool; var width(default,null) : Int; function new(width : Int, height : Int, transparent : Bool = true, fillColor : UInt = 0xFFFFFFFF) : Void; function applyFilter(sourceBitmapData : BitmapData, sourceRect : flash.geom.Rectangle, destPoint : flash.geom.Point, filter : flash.filters.BitmapFilter) : Void; function clone() : BitmapData; function colorTransform(rect : flash.geom.Rectangle, colorTransform : flash.geom.ColorTransform) : Void; function compare(otherBitmapData : BitmapData) : flash.utils.Object; function copyChannel(sourceBitmapData : BitmapData, sourceRect : flash.geom.Rectangle, destPoint : flash.geom.Point, sourceChannel : UInt, destChannel : UInt) : Void; function copyPixels(sourceBitmapData : BitmapData, sourceRect : flash.geom.Rectangle, destPoint : flash.geom.Point, ?alphaBitmapData : BitmapData, ?alphaPoint : flash.geom.Point, mergeAlpha : Bool = false) : Void; @:require(flash11_4) function copyPixelsToByteArray(rect : flash.geom.Rectangle, data : flash.utils.ByteArray) : Void; function dispose() : Void; function draw(source : IBitmapDrawable, ?matrix : flash.geom.Matrix, ?colorTransform : flash.geom.ColorTransform, ?blendMode : BlendMode, ?clipRect : flash.geom.Rectangle, smoothing : Bool = false) : Void; @:require(flash11_3) function drawWithQuality(source : IBitmapDrawable, ?matrix : flash.geom.Matrix, ?colorTransform : flash.geom.ColorTransform, ?blendMode : BlendMode, ?clipRect : flash.geom.Rectangle, smoothing : Bool = false, ?quality : StageQuality) : Void; @:require(flash11_3) function encode(rect : flash.geom.Rectangle, compressor : flash.utils.Object, ?byteArray : flash.utils.ByteArray) : flash.utils.ByteArray; function fillRect(rect : flash.geom.Rectangle, color : UInt) : Void; function floodFill(x : Int, y : Int, color : UInt) : Void; function generateFilterRect(sourceRect : flash.geom.Rectangle, filter : flash.filters.BitmapFilter) : flash.geom.Rectangle; function getColorBoundsRect(mask : UInt, color : UInt, findColor : Bool = true) : flash.geom.Rectangle; function getPixel(x : Int, y : Int) : UInt; function getPixel32(x : Int, y : Int) : UInt; function getPixels(rect : flash.geom.Rectangle) : flash.utils.ByteArray; @:require(flash10) function getVector(rect : flash.geom.Rectangle) : flash.Vector; @:require(flash10) function histogram(?hRect : flash.geom.Rectangle) : flash.Vector>; function hitTest(firstPoint : flash.geom.Point, firstAlphaThreshold : UInt, secondObject : flash.utils.Object, ?secondBitmapDataPoint : flash.geom.Point, secondAlphaThreshold : UInt = 1) : Bool; function lock() : Void; function merge(sourceBitmapData : BitmapData, sourceRect : flash.geom.Rectangle, destPoint : flash.geom.Point, redMultiplier : UInt, greenMultiplier : UInt, blueMultiplier : UInt, alphaMultiplier : UInt) : Void; function noise(randomSeed : Int, low : UInt = 0, high : UInt = 255, channelOptions : UInt = 7, grayScale : Bool = false) : Void; function paletteMap(sourceBitmapData : BitmapData, sourceRect : flash.geom.Rectangle, destPoint : flash.geom.Point, ?redArray : Array, ?greenArray : Array, ?blueArray : Array, ?alphaArray : Array) : Void; function perlinNoise(baseX : Float, baseY : Float, numOctaves : UInt, randomSeed : Int, stitch : Bool, fractalNoise : Bool, channelOptions : UInt = 7, grayScale : Bool = false, ?offsets : Array) : Void; function pixelDissolve(sourceBitmapData : BitmapData, sourceRect : flash.geom.Rectangle, destPoint : flash.geom.Point, randomSeed : Int = 0, numPixels : Int = 0, fillColor : UInt = 0) : Int; function scroll(x : Int, y : Int) : Void; function setPixel(x : Int, y : Int, color : UInt) : Void; function setPixel32(x : Int, y : Int, color : UInt) : Void; function setPixels(rect : flash.geom.Rectangle, inputByteArray : flash.utils.ByteArray) : Void; @:require(flash10) function setVector(rect : flash.geom.Rectangle, inputVector : flash.Vector) : Void; function threshold(sourceBitmapData : BitmapData, sourceRect : flash.geom.Rectangle, destPoint : flash.geom.Point, operation : String, threshold : UInt, color : UInt = 0, mask : UInt = 0xFFFFFFFF, copySource : Bool = false) : UInt; function unlock(?changeRect : flash.geom.Rectangle) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/BitmapDataChannel.hx0000664000175000017500000000031412607337712023516 0ustar andyandy00000000000000package flash.display; extern class BitmapDataChannel { public static inline var ALPHA = 8; public static inline var BLUE = 4; public static inline var GREEN = 2; public static inline var RED = 1; } haxe_3.2.1+dfsg.orig/std/flash/display/BitmapEncodingColorSpace.hx0000664000175000017500000000023712607337712025061 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum BitmapEncodingColorSpace { COLORSPACE_4_2_0; COLORSPACE_4_2_2; COLORSPACE_4_4_4; COLORSPACE_AUTO; } haxe_3.2.1+dfsg.orig/std/flash/display/BlendMode.hx0000664000175000017500000000032312607337712022050 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum BlendMode { ADD; ALPHA; DARKEN; DIFFERENCE; ERASE; HARDLIGHT; INVERT; LAYER; LIGHTEN; MULTIPLY; NORMAL; OVERLAY; SCREEN; SHADER; SUBTRACT; } haxe_3.2.1+dfsg.orig/std/flash/display/CapsStyle.hx0000664000175000017500000000013512607337712022127 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum CapsStyle { NONE; ROUND; SQUARE; } haxe_3.2.1+dfsg.orig/std/flash/display/ColorCorrection.hx0000664000175000017500000000016512607337712023331 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) @:require(flash10_1) extern enum ColorCorrection { DEFAULT; OFF; ON; } haxe_3.2.1+dfsg.orig/std/flash/display/ColorCorrectionSupport.hx0000664000175000017500000000022012607337712024716 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) @:require(flash10_1) extern enum ColorCorrectionSupport { DEFAULT_OFF; DEFAULT_ON; UNSUPPORTED; } haxe_3.2.1+dfsg.orig/std/flash/display/DisplayObject.hx0000664000175000017500000000342412607337712022760 0ustar andyandy00000000000000package flash.display; extern class DisplayObject extends flash.events.EventDispatcher implements IBitmapDrawable { var accessibilityProperties : flash.accessibility.AccessibilityProperties; var alpha : Float; var blendMode : BlendMode; @:require(flash10) var blendShader(null,default) : Shader; var cacheAsBitmap : Bool; var filters : Array; var height : Float; var loaderInfo(default,null) : LoaderInfo; var mask : DisplayObject; var mouseX(default,null) : Float; var mouseY(default,null) : Float; var name : String; var opaqueBackground : Null; var parent(default,null) : DisplayObjectContainer; var root(default,null) : DisplayObject; var rotation : Float; @:require(flash10) var rotationX : Float; @:require(flash10) var rotationY : Float; @:require(flash10) var rotationZ : Float; var scale9Grid : flash.geom.Rectangle; var scaleX : Float; var scaleY : Float; @:require(flash10) var scaleZ : Float; var scrollRect : flash.geom.Rectangle; var stage(default,null) : Stage; var transform : flash.geom.Transform; var visible : Bool; var width : Float; var x : Float; var y : Float; @:require(flash10) var z : Float; function getBounds(targetCoordinateSpace : DisplayObject) : flash.geom.Rectangle; function getRect(targetCoordinateSpace : DisplayObject) : flash.geom.Rectangle; function globalToLocal(point : flash.geom.Point) : flash.geom.Point; @:require(flash10) function globalToLocal3D(point : flash.geom.Point) : flash.geom.Vector3D; function hitTestObject(obj : DisplayObject) : Bool; function hitTestPoint(x : Float, y : Float, shapeFlag : Bool = false) : Bool; @:require(flash10) function local3DToGlobal(point3d : flash.geom.Vector3D) : flash.geom.Point; function localToGlobal(point : flash.geom.Point) : flash.geom.Point; } haxe_3.2.1+dfsg.orig/std/flash/display/DisplayObjectContainer.hx0000664000175000017500000000234412607337712024623 0ustar andyandy00000000000000package flash.display; extern class DisplayObjectContainer extends InteractiveObject { var mouseChildren : Bool; var numChildren(default,null) : Int; var tabChildren : Bool; var textSnapshot(default,null) : flash.text.TextSnapshot; function new() : Void; function addChild(child : DisplayObject) : DisplayObject; function addChildAt(child : DisplayObject, index : Int) : DisplayObject; function areInaccessibleObjectsUnderPoint(point : flash.geom.Point) : Bool; function contains(child : DisplayObject) : Bool; function getChildAt(index : Int) : DisplayObject; function getChildByName(name : String) : DisplayObject; function getChildIndex(child : DisplayObject) : Int; function getObjectsUnderPoint(point : flash.geom.Point) : Array; function removeChild(child : DisplayObject) : DisplayObject; function removeChildAt(index : Int) : DisplayObject; @:require(flash11) function removeChildren(beginIndex : Int = 0, endIndex : Int = 2147483647) : Void; function setChildIndex(child : DisplayObject, index : Int) : Void; @:require(flash11_8) function stopAllMovieClips() : Void; function swapChildren(child1 : DisplayObject, child2 : DisplayObject) : Void; function swapChildrenAt(index1 : Int, index2 : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/FocusDirection.hx0000664000175000017500000000016512607337712023143 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) @:require(flash10_1) extern enum FocusDirection { BOTTOM; NONE; TOP; } haxe_3.2.1+dfsg.orig/std/flash/display/FrameLabel.hx0000664000175000017500000000032512607337712022213 0ustar andyandy00000000000000package flash.display; @:final extern class FrameLabel extends flash.events.EventDispatcher { var frame(default,null) : Int; var name(default,null) : String; function new(name : String, frame : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/GradientType.hx0000664000175000017500000000013212607337712022614 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum GradientType { LINEAR; RADIAL; } haxe_3.2.1+dfsg.orig/std/flash/display/Graphics.hx0000664000175000017500000000550612607337712021767 0ustar andyandy00000000000000package flash.display; @:final extern class Graphics { function new() : Void; function beginBitmapFill(bitmap : BitmapData, ?matrix : flash.geom.Matrix, repeat : Bool = true, smooth : Bool = false) : Void; function beginFill(color : UInt, alpha : Float = 1) : Void; function beginGradientFill(type : GradientType, colors : Array, alphas : Array, ratios : Array, ?matrix : flash.geom.Matrix, ?spreadMethod : SpreadMethod, ?interpolationMethod : InterpolationMethod, focalPointRatio : Float = 0) : Void; @:require(flash10) function beginShaderFill(shader : Shader, ?matrix : flash.geom.Matrix) : Void; function clear() : Void; @:require(flash10) function copyFrom(sourceGraphics : Graphics) : Void; @:require(flash11) function cubicCurveTo(controlX1 : Float, controlY1 : Float, controlX2 : Float, controlY2 : Float, anchorX : Float, anchorY : Float) : Void; function curveTo(controlX : Float, controlY : Float, anchorX : Float, anchorY : Float) : Void; function drawCircle(x : Float, y : Float, radius : Float) : Void; function drawEllipse(x : Float, y : Float, width : Float, height : Float) : Void; @:require(flash10) function drawGraphicsData(graphicsData : flash.Vector) : Void; @:require(flash10) function drawPath(commands : flash.Vector, data : flash.Vector, ?winding : GraphicsPathWinding) : Void; function drawRect(x : Float, y : Float, width : Float, height : Float) : Void; function drawRoundRect(x : Float, y : Float, width : Float, height : Float, ellipseWidth : Float, ?ellipseHeight : Float) : Void; function drawRoundRectComplex(x : Float, y : Float, width : Float, height : Float, topLeftRadius : Float, topRightRadius : Float, bottomLeftRadius : Float, bottomRightRadius : Float) : Void; @:require(flash10) function drawTriangles(vertices : flash.Vector, ?indices : flash.Vector, ?uvtData : flash.Vector, ?culling : TriangleCulling) : Void; function endFill() : Void; @:require(flash10) function lineBitmapStyle(bitmap : BitmapData, ?matrix : flash.geom.Matrix, repeat : Bool = true, smooth : Bool = false) : Void; function lineGradientStyle(type : GradientType, colors : Array, alphas : Array, ratios : Array, ?matrix : flash.geom.Matrix, ?spreadMethod : SpreadMethod, ?interpolationMethod : InterpolationMethod, focalPointRatio : Float = 0) : Void; @:require(flash10) function lineShaderStyle(shader : Shader, ?matrix : flash.geom.Matrix) : Void; function lineStyle(?thickness : Float, color : UInt = 0, alpha : Float = 1, pixelHinting : Bool = false, ?scaleMode : LineScaleMode, ?caps : CapsStyle, ?joints : JointStyle, miterLimit : Float = 3) : Void; function lineTo(x : Float, y : Float) : Void; function moveTo(x : Float, y : Float) : Void; @:require(flash11_6) function readGraphicsData(recurse : Bool = true) : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsBitmapFill.hx0000664000175000017500000000052712607337712023731 0ustar andyandy00000000000000package flash.display; @:final extern class GraphicsBitmapFill implements IGraphicsData implements IGraphicsFill { var bitmapData : BitmapData; var matrix : flash.geom.Matrix; var repeat : Bool; var smooth : Bool; function new(?bitmapData : BitmapData, ?matrix : flash.geom.Matrix, repeat : Bool = true, smooth : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsEndFill.hx0000664000175000017500000000020312607337712023212 0ustar andyandy00000000000000package flash.display; extern class GraphicsEndFill implements IGraphicsData implements IGraphicsFill { function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsGradientFill.hx0000664000175000017500000000115512607337712024250 0ustar andyandy00000000000000package flash.display; @:final extern class GraphicsGradientFill implements IGraphicsData implements IGraphicsFill { var alphas : Array; var colors : Array; var focalPointRatio : Float; var interpolationMethod : InterpolationMethod; var matrix : flash.geom.Matrix; var ratios : Array; var spreadMethod : SpreadMethod; var type : GradientType; function new(?type : GradientType, ?colors : Array, ?alphas : Array, ?ratios : Array, ?matrix : flash.geom.Matrix, ?spreadMethod : SpreadMethod, ?interpolationMethod : InterpolationMethod, focalPointRatio : Float = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsPath.hx0000664000175000017500000000141612607337712022600 0ustar andyandy00000000000000package flash.display; @:final extern class GraphicsPath implements IGraphicsData implements IGraphicsPath { var commands : flash.Vector; var data : flash.Vector; var winding : GraphicsPathWinding; function new(?commands : flash.Vector, ?data : flash.Vector, ?winding : GraphicsPathWinding) : Void; @:require(flash11) function cubicCurveTo(controlX1 : Float, controlY1 : Float, controlX2 : Float, controlY2 : Float, anchorX : Float, anchorY : Float) : Void; function curveTo(controlX : Float, controlY : Float, anchorX : Float, anchorY : Float) : Void; function lineTo(x : Float, y : Float) : Void; function moveTo(x : Float, y : Float) : Void; function wideLineTo(x : Float, y : Float) : Void; function wideMoveTo(x : Float, y : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsPathCommand.hx0000664000175000017500000000056112607337712024077 0ustar andyandy00000000000000package flash.display; extern class GraphicsPathCommand { public static inline var LINE_TO = 2; public static inline var MOVE_TO = 1; public static inline var CURVE_TO = 3; @:require(flash11) public static inline var CUBIC_CURVE_TO = 6; public static inline var WIDE_LINE_TO = 5; public static inline var WIDE_MOVE_TO = 4; public static inline var NO_OP = 0; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsPathWinding.hx0000664000175000017500000000014512607337712024116 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum GraphicsPathWinding { EVEN_ODD; NON_ZERO; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsShaderFill.hx0000664000175000017500000000036212607337712023720 0ustar andyandy00000000000000package flash.display; @:final extern class GraphicsShaderFill implements IGraphicsData implements IGraphicsFill { var matrix : flash.geom.Matrix; var shader : Shader; function new(?shader : Shader, ?matrix : flash.geom.Matrix) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsSolidFill.hx0000664000175000017500000000032712607337712023565 0ustar andyandy00000000000000package flash.display; @:final extern class GraphicsSolidFill implements IGraphicsData implements IGraphicsFill { var alpha : Float; var color : UInt; function new(color : UInt = 0, alpha : Float = 1) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsStroke.hx0000664000175000017500000000076112607337712023155 0ustar andyandy00000000000000package flash.display; @:final extern class GraphicsStroke implements IGraphicsData implements IGraphicsStroke { var caps : CapsStyle; var fill : IGraphicsFill; var joints : JointStyle; var miterLimit : Float; var pixelHinting : Bool; var scaleMode : LineScaleMode; var thickness : Float; function new(thickness : Float = 0./*NaN*/, pixelHinting : Bool = false, ?scaleMode : LineScaleMode, ?caps : CapsStyle, ?joints : JointStyle, miterLimit : Float = 3, ?fill : IGraphicsFill) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/GraphicsTrianglePath.hx0000664000175000017500000000062412607337712024266 0ustar andyandy00000000000000package flash.display; @:final extern class GraphicsTrianglePath implements IGraphicsData implements IGraphicsPath { var culling : TriangleCulling; var indices : flash.Vector; var uvtData : flash.Vector; var vertices : flash.Vector; function new(?vertices : flash.Vector, ?indices : flash.Vector, ?uvtData : flash.Vector, ?culling : TriangleCulling) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/IBitmapCompressOptions.hx0000664000175000017500000000010412607337712024631 0ustar andyandy00000000000000package flash.display; extern interface IBitmapCompressOptions { } haxe_3.2.1+dfsg.orig/std/flash/display/IBitmapDrawable.hx0000664000175000017500000000007512607337712023212 0ustar andyandy00000000000000package flash.display; extern interface IBitmapDrawable { } haxe_3.2.1+dfsg.orig/std/flash/display/IDrawCommand.hx0000664000175000017500000000007212607337712022525 0ustar andyandy00000000000000package flash.display; extern interface IDrawCommand { } haxe_3.2.1+dfsg.orig/std/flash/display/IGraphicsData.hx0000664000175000017500000000007312607337712022664 0ustar andyandy00000000000000package flash.display; extern interface IGraphicsData { } haxe_3.2.1+dfsg.orig/std/flash/display/IGraphicsFill.hx0000664000175000017500000000007312607337712022701 0ustar andyandy00000000000000package flash.display; extern interface IGraphicsFill { } haxe_3.2.1+dfsg.orig/std/flash/display/IGraphicsPath.hx0000664000175000017500000000007312607337712022707 0ustar andyandy00000000000000package flash.display; extern interface IGraphicsPath { } haxe_3.2.1+dfsg.orig/std/flash/display/IGraphicsStroke.hx0000664000175000017500000000007512607337712023264 0ustar andyandy00000000000000package flash.display; extern interface IGraphicsStroke { } haxe_3.2.1+dfsg.orig/std/flash/display/InteractiveObject.hx0000664000175000017500000000104412607337712023624 0ustar andyandy00000000000000package flash.display; extern class InteractiveObject extends DisplayObject { var accessibilityImplementation : flash.accessibility.AccessibilityImplementation; var contextMenu : flash.ui.ContextMenu; var doubleClickEnabled : Bool; var focusRect : Dynamic; var mouseEnabled : Bool; @:require(flash11) var needsSoftKeyboard : Bool; @:require(flash11) var softKeyboardInputAreaOfInterest : flash.geom.Rectangle; var tabEnabled : Bool; var tabIndex : Int; function new() : Void; @:require(flash11) function requestSoftKeyboard() : Bool; } haxe_3.2.1+dfsg.orig/std/flash/display/InterpolationMethod.hx0000664000175000017500000000014212607337712024206 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum InterpolationMethod { LINEAR_RGB; RGB; } haxe_3.2.1+dfsg.orig/std/flash/display/JPEGCompressOptions.hx0000664000175000017500000000024712607337712024041 0ustar andyandy00000000000000package flash.display; @:final extern class JPEGCompressOptions implements IBitmapCompressOptions { var quality : UInt; function new(quality : UInt = 80) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/JPEGEncoderOptions.hx0000664000175000017500000000020412607337712023616 0ustar andyandy00000000000000package flash.display; @:final extern class JPEGEncoderOptions { var quality : UInt; function new(quality : UInt = 80) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/JPEGXRCompressOptions.hx0000664000175000017500000000042612607337712024312 0ustar andyandy00000000000000package flash.display; @:final extern class JPEGXRCompressOptions implements IBitmapCompressOptions { var colorSpace : String; var quantization : UInt; var trimFlexBits : UInt; function new(quantization : UInt = 20, ?colorSpace : String, trimFlexBits : UInt = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/JPEGXREncoderOptions.hx0000664000175000017500000000042712607337712024077 0ustar andyandy00000000000000package flash.display; @:final extern class JPEGXREncoderOptions { var colorSpace : BitmapEncodingColorSpace; var quantization : UInt; var trimFlexBits : UInt; function new(quantization : UInt = 20, ?colorSpace : BitmapEncodingColorSpace, trimFlexBits : UInt = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/JointStyle.hx0000664000175000017500000000013612607337712022325 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum JointStyle { BEVEL; MITER; ROUND; } haxe_3.2.1+dfsg.orig/std/flash/display/LineScaleMode.hx0000664000175000017500000000016112607337712022663 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum LineScaleMode { HORIZONTAL; NONE; NORMAL; VERTICAL; } haxe_3.2.1+dfsg.orig/std/flash/display/Loader.hx0000664000175000017500000000114012607337712021423 0ustar andyandy00000000000000package flash.display; extern class Loader extends DisplayObjectContainer { var content(default,null) : DisplayObject; var contentLoaderInfo(default,null) : LoaderInfo; @:require(flash10_1) var uncaughtErrorEvents(default,null) : flash.events.UncaughtErrorEvents; function new() : Void; function close() : Void; function load(request : flash.net.URLRequest, ?context : flash.system.LoaderContext) : Void; function loadBytes(bytes : flash.utils.ByteArray, ?context : flash.system.LoaderContext) : Void; function unload() : Void; @:require(flash10) function unloadAndStop(gc : Bool = true) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/LoaderInfo.hx0000664000175000017500000000237212607337712022247 0ustar andyandy00000000000000package flash.display; extern class LoaderInfo extends flash.events.EventDispatcher { var actionScriptVersion(default,null) : ActionScriptVersion; var applicationDomain(default,null) : flash.system.ApplicationDomain; var bytes(default,null) : flash.utils.ByteArray; var bytesLoaded(default,null) : UInt; var bytesTotal(default,null) : UInt; var childAllowsParent(default,null) : Bool; @:require(flash11_4) var childSandboxBridge : Dynamic; var content(default,null) : DisplayObject; var contentType(default,null) : String; var frameRate(default,null) : Float; var height(default,null) : Int; @:require(flash10_1) var isURLInaccessible(default,null) : Bool; var loader(default,null) : Loader; var loaderURL(default,null) : String; var parameters(default,null) : Dynamic; var parentAllowsChild(default,null) : Bool; @:require(flash11_4) var parentSandboxBridge : Dynamic; var sameDomain(default,null) : Bool; var sharedEvents(default,null) : flash.events.EventDispatcher; var swfVersion(default,null) : UInt; @:require(flash10_1) var uncaughtErrorEvents(default,null) : flash.events.UncaughtErrorEvents; var url(default,null) : String; var width(default,null) : Int; static function getLoaderInfoByDefinition(object : Dynamic) : LoaderInfo; } haxe_3.2.1+dfsg.orig/std/flash/display/MorphShape.hx0000664000175000017500000000011212607337712022261 0ustar andyandy00000000000000package flash.display; extern class MorphShape extends DisplayObject { } haxe_3.2.1+dfsg.orig/std/flash/display/MovieClip.hx0000664000175000017500000000177712607337712022124 0ustar andyandy00000000000000package flash.display; extern class MovieClip extends Sprite #if !flash_strict implements Dynamic #end { var currentFrame(default,null) : Int; @:require(flash10) var currentFrameLabel(default,null) : String; var currentLabel(default,null) : String; var currentLabels(default,null) : Array; var currentScene(default,null) : Scene; var enabled : Bool; var framesLoaded(default,null) : Int; @:require(flash11) var isPlaying(default,null) : Bool; var scenes(default,null) : Array; var totalFrames(default,null) : Int; var trackAsMenu : Bool; function new() : Void; function addFrameScript(?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; function gotoAndPlay(frame : flash.utils.Object, ?scene : String) : Void; function gotoAndStop(frame : flash.utils.Object, ?scene : String) : Void; function nextFrame() : Void; function nextScene() : Void; function play() : Void; function prevFrame() : Void; function prevScene() : Void; function stop() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/NativeMenu.hx0000664000175000017500000000020612607337712022272 0ustar andyandy00000000000000package flash.display; @:require(flash10_1) extern class NativeMenu extends flash.events.EventDispatcher { function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/NativeMenuItem.hx0000664000175000017500000000023712607337712023115 0ustar andyandy00000000000000package flash.display; @:require(flash10_1) extern class NativeMenuItem extends flash.events.EventDispatcher { var enabled : Bool; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/PNGCompressOptions.hx0000664000175000017500000000016612607337712023740 0ustar andyandy00000000000000package flash.display; extern class PNGCompressOptions implements IBitmapCompressOptions { function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/PNGEncoderOptions.hx0000664000175000017500000000022612607337712023521 0ustar andyandy00000000000000package flash.display; @:final extern class PNGEncoderOptions { var fastCompression : Bool; function new(fastCompression : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/PixelSnapping.hx0000664000175000017500000000014112607337712022776 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum PixelSnapping { ALWAYS; AUTO; NEVER; } haxe_3.2.1+dfsg.orig/std/flash/display/SWFVersion.hx0000664000175000017500000000057312607337712022233 0ustar andyandy00000000000000package flash.display; extern class SWFVersion { static var FLASH1 : UInt; static var FLASH10 : UInt; static var FLASH11 : UInt; static var FLASH12 : UInt; static var FLASH2 : UInt; static var FLASH3 : UInt; static var FLASH4 : UInt; static var FLASH5 : UInt; static var FLASH6 : UInt; static var FLASH7 : UInt; static var FLASH8 : UInt; static var FLASH9 : UInt; } haxe_3.2.1+dfsg.orig/std/flash/display/Scene.hx0000664000175000017500000000037612607337712021264 0ustar andyandy00000000000000package flash.display; @:final extern class Scene { var labels(default,null) : Array; var name(default,null) : String; var numFrames(default,null) : Int; function new(name : String, labels : Array, numFrames : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/Shader.hx0000664000175000017500000000035312607337712021430 0ustar andyandy00000000000000package flash.display; @:require(flash10) extern class Shader { var byteCode(null,default) : flash.utils.ByteArray; var data : ShaderData; var precisionHint : ShaderPrecision; function new(?code : flash.utils.ByteArray) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/ShaderData.hx0000664000175000017500000000017712607337712022226 0ustar andyandy00000000000000package flash.display; extern class ShaderData implements Dynamic { function new(byteCode : flash.utils.ByteArray) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/ShaderInput.hx0000664000175000017500000000034612607337712022452 0ustar andyandy00000000000000package flash.display; @:final extern class ShaderInput implements Dynamic { var channels(default,null) : Int; var height : Int; var index(default,null) : Int; var input : Dynamic; var width : Int; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/ShaderJob.hx0000664000175000017500000000060212607337712022060 0ustar andyandy00000000000000package flash.display; extern class ShaderJob extends flash.events.EventDispatcher { var height : Int; var progress(default,null) : Float; var shader : Shader; var target : Dynamic; var width : Int; function new(?shader : Shader, ?target : Dynamic, width : Int = 0, height : Int = 0) : Void; function cancel() : Void; function start(waitForCompletion : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/ShaderParameter.hx0000664000175000017500000000030012607337712023261 0ustar andyandy00000000000000package flash.display; @:final extern class ShaderParameter implements Dynamic { var index(default,null) : Int; var type(default,null) : ShaderParameterType; var value : Array; } haxe_3.2.1+dfsg.orig/std/flash/display/ShaderParameterType.hx0000664000175000017500000000032012607337712024125 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum ShaderParameterType { BOOL; BOOL2; BOOL3; BOOL4; FLOAT; FLOAT2; FLOAT3; FLOAT4; INT; INT2; INT3; INT4; MATRIX2X2; MATRIX3X3; MATRIX4X4; } haxe_3.2.1+dfsg.orig/std/flash/display/ShaderPrecision.hx0000664000175000017500000000013112607337712023276 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum ShaderPrecision { FAST; FULL; } haxe_3.2.1+dfsg.orig/std/flash/display/Shape.hx0000664000175000017500000000020512607337712021256 0ustar andyandy00000000000000package flash.display; extern class Shape extends DisplayObject { var graphics(default,null) : Graphics; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/SimpleButton.hx0000664000175000017500000000072312607337712022650 0ustar andyandy00000000000000package flash.display; extern class SimpleButton extends InteractiveObject { var downState : DisplayObject; var enabled : Bool; var hitTestState : DisplayObject; var overState : DisplayObject; var soundTransform : flash.media.SoundTransform; var trackAsMenu : Bool; var upState : DisplayObject; var useHandCursor : Bool; function new(?upState : DisplayObject, ?overState : DisplayObject, ?downState : DisplayObject, ?hitTestState : DisplayObject) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/SpreadMethod.hx0000664000175000017500000000014112607337712022574 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum SpreadMethod { PAD; REFLECT; REPEAT; } haxe_3.2.1+dfsg.orig/std/flash/display/Sprite.hx0000664000175000017500000000117412607337712021472 0ustar andyandy00000000000000package flash.display; extern class Sprite extends DisplayObjectContainer { var buttonMode : Bool; var dropTarget(default,null) : DisplayObject; var graphics(default,null) : Graphics; var hitArea : Sprite; var soundTransform : flash.media.SoundTransform; var useHandCursor : Bool; function new() : Void; function startDrag(lockCenter : Bool = false, ?bounds : flash.geom.Rectangle) : Void; @:require(flash10_1) function startTouchDrag(touchPointID : Int, lockCenter : Bool = false, ?bounds : flash.geom.Rectangle) : Void; function stopDrag() : Void; @:require(flash10_1) function stopTouchDrag(touchPointID : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/Stage.hx0000664000175000017500000000265312607337712021272 0ustar andyandy00000000000000package flash.display; extern class Stage extends DisplayObjectContainer { var align : StageAlign; @:require(flash10_2) var allowsFullScreen(default,null) : Bool; @:require(flash11_3) var allowsFullScreenInteractive(default,null) : Bool; @:require(flash15) var browserZoomFactor(default,null) : Float; @:require(flash10_2) var color : UInt; @:require(flash10) var colorCorrection : ColorCorrection; @:require(flash10) var colorCorrectionSupport(default,null) : ColorCorrectionSupport; @:require(flash11_4) var contentsScaleFactor(default,null) : Float; @:require(flash11) var displayContextInfo(default,null) : String; var displayState : StageDisplayState; var focus : InteractiveObject; var frameRate : Float; var fullScreenHeight(default,null) : UInt; var fullScreenSourceRect : flash.geom.Rectangle; var fullScreenWidth(default,null) : UInt; @:require(flash11_2) var mouseLock : Bool; var quality : StageQuality; var scaleMode : StageScaleMode; var showDefaultContextMenu : Bool; @:require(flash11) var softKeyboardRect(default,null) : flash.geom.Rectangle; @:require(flash11) var stage3Ds(default,null) : flash.Vector; var stageFocusRect : Bool; var stageHeight : Int; @:require(flash10_2) var stageVideos(default,null) : flash.Vector; var stageWidth : Int; @:require(flash10_1) var wmodeGPU(default,null) : Bool; function invalidate() : Void; function isFocusInaccessible() : Bool; } haxe_3.2.1+dfsg.orig/std/flash/display/Stage3D.hx0000664000175000017500000000071312607337712021454 0ustar andyandy00000000000000package flash.display; @:require(flash11) extern class Stage3D extends flash.events.EventDispatcher { var context3D(default,null) : flash.display3D.Context3D; var visible : Bool; var x : Float; var y : Float; function requestContext3D(?context3DRenderMode : flash.display3D.Context3DRenderMode, ?profile : flash.display3D.Context3DProfile) : Void; @:require(flash12) function requestContext3DMatchingProfiles(profiles : flash.Vector) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/StageAlign.hx0000664000175000017500000000023012607337712022232 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum StageAlign { BOTTOM; BOTTOM_LEFT; BOTTOM_RIGHT; LEFT; RIGHT; TOP; TOP_LEFT; TOP_RIGHT; } haxe_3.2.1+dfsg.orig/std/flash/display/StageDisplayState.hx0000664000175000017500000000017612607337712023617 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum StageDisplayState { FULL_SCREEN; FULL_SCREEN_INTERACTIVE; NORMAL; } haxe_3.2.1+dfsg.orig/std/flash/display/StageQuality.hx0000664000175000017500000000024312607337712022634 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum StageQuality { BEST; HIGH; HIGH_16X16; HIGH_16X16_LINEAR; HIGH_8X8; HIGH_8X8_LINEAR; LOW; MEDIUM; } haxe_3.2.1+dfsg.orig/std/flash/display/StageScaleMode.hx0000664000175000017500000000017012607337712023037 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum StageScaleMode { EXACT_FIT; NO_BORDER; NO_SCALE; SHOW_ALL; } haxe_3.2.1+dfsg.orig/std/flash/display/StageWorker.hx0000664000175000017500000000027012607337712022455 0ustar andyandy00000000000000package flash.display; @:require(flash11_2) @:final extern class StageWorker extends Sprite { var scaleMode : String; var viewport : flash.geom.Rectangle; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display/TriangleCulling.hx0000664000175000017500000000015012607337712023300 0ustar andyandy00000000000000package flash.display; @:fakeEnum(String) extern enum TriangleCulling { NEGATIVE; NONE; POSITIVE; } haxe_3.2.1+dfsg.orig/std/flash/display/Worker.hx0000664000175000017500000000044612607337712021476 0ustar andyandy00000000000000package flash.display; @:require(flash11_2) @:final extern class Worker extends flash.events.EventDispatcher { var running(default,null) : Bool; var view(default,null) : StageWorker; function new() : Void; function load(request : flash.net.URLRequest) : Void; function unload() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3D.hx0000664000175000017500000001007312607337712022224 0ustar andyandy00000000000000package flash.display3D; @:final extern class Context3D extends flash.events.EventDispatcher { @:require(flash15) var backBufferHeight(default,null) : Int; @:require(flash15) var backBufferWidth(default,null) : Int; var driverInfo(default,null) : String; var enableErrorChecking : Bool; @:require(flash15) var maxBackBufferHeight : Int; @:require(flash15) var maxBackBufferWidth : Int; @:require(flash12) var profile(default,null) : String; function clear(red : Float = 0, green : Float = 0, blue : Float = 0, alpha : Float = 1, depth : Float = 1, stencil : UInt = 0, mask : UInt = 0xFFFFFFFF) : Void; function configureBackBuffer(width : Int, height : Int, antiAlias : Int, enableDepthAndStencil : Bool = true, wantsBestResolution : Bool = false, wantsBestResolutionOnBrowserZoom : Bool = false) : Void; function createCubeTexture(size : Int, format : Context3DTextureFormat, optimizeForRenderToTexture : Bool, streamingLevels : Int = 0) : flash.display3D.textures.CubeTexture; function createIndexBuffer(numIndices : Int, ?bufferUsage : Context3DBufferUsage) : IndexBuffer3D; function createProgram() : Program3D; @:require(flash11_8) function createRectangleTexture(width : Int, height : Int, format : Context3DTextureFormat, optimizeForRenderToTexture : Bool) : flash.display3D.textures.RectangleTexture; function createTexture(width : Int, height : Int, format : Context3DTextureFormat, optimizeForRenderToTexture : Bool, streamingLevels : Int = 0) : flash.display3D.textures.Texture; function createVertexBuffer(numVertices : Int, data32PerVertex : Int, ?bufferUsage : Context3DBufferUsage) : VertexBuffer3D; @:require(flash15) function createVideoTexture() : flash.display3D.textures.VideoTexture; function dispose(recreate : Bool = true) : Void; function drawToBitmapData(destination : flash.display.BitmapData) : Void; function drawTriangles(indexBuffer : IndexBuffer3D, firstIndex : Int = 0, numTriangles : Int = -1) : Void; function present() : Void; function setBlendFactors(sourceFactor : Context3DBlendFactor, destinationFactor : Context3DBlendFactor) : Void; function setColorMask(red : Bool, green : Bool, blue : Bool, alpha : Bool) : Void; function setCulling(triangleFaceToCull : Context3DTriangleFace) : Void; function setDepthTest(depthMask : Bool, passCompareMode : Context3DCompareMode) : Void; @:require(flash16) function setFillMode( fillMode : Context3DFillMode ) : Void; function setProgram(program : Program3D) : Void; @:require(flash11_2) function setProgramConstantsFromByteArray(programType : Context3DProgramType, firstRegister : Int, numRegisters : Int, data : flash.utils.ByteArray, byteArrayOffset : UInt) : Void; function setProgramConstantsFromMatrix(programType : Context3DProgramType, firstRegister : Int, matrix : flash.geom.Matrix3D, transposedMatrix : Bool = false) : Void; function setProgramConstantsFromVector(programType : Context3DProgramType, firstRegister : Int, data : flash.Vector, numRegisters : Int = -1) : Void; function setRenderToBackBuffer() : Void; function setRenderToTexture(texture : flash.display3D.textures.TextureBase, enableDepthAndStencil : Bool = false, antiAlias : Int = 0, surfaceSelector : Int = 0, colorOutputIndex : Int = 0) : Void; @:require(flash11_6) function setSamplerStateAt(sampler : Int, wrap : Context3DWrapMode, filter : Context3DTextureFilter, mipfilter : Context3DMipFilter) : Void; function setScissorRectangle(rectangle : flash.geom.Rectangle) : Void; function setStencilActions(?triangleFace : Context3DTriangleFace, ?compareMode : Context3DCompareMode, ?actionOnBothPass : Context3DStencilAction, ?actionOnDepthFail : Context3DStencilAction, ?actionOnDepthPassStencilFail : Context3DStencilAction) : Void; function setStencilReferenceValue(referenceValue : UInt, readMask : UInt = 255, writeMask : UInt = 255) : Void; function setTextureAt(sampler : Int, texture : flash.display3D.textures.TextureBase) : Void; function setVertexBufferAt(index : Int, buffer : VertexBuffer3D, bufferOffset : Int = 0, ?format : Context3DVertexBufferFormat) : Void; @:require(flash15) static var supportsVideoTexture(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DBlendFactor.hx0000664000175000017500000000042312607337712024326 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DBlendFactor { DESTINATION_ALPHA; DESTINATION_COLOR; ONE; ONE_MINUS_DESTINATION_ALPHA; ONE_MINUS_DESTINATION_COLOR; ONE_MINUS_SOURCE_ALPHA; ONE_MINUS_SOURCE_COLOR; SOURCE_ALPHA; SOURCE_COLOR; ZERO; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DBufferUsage.hx0000664000175000017500000000020212607337712024334 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) @:require(flash12) extern enum Context3DBufferUsage { DYNAMIC_DRAW; STATIC_DRAW; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DClearMask.hx0000664000175000017500000000024212607337712024004 0ustar andyandy00000000000000package flash.display3D; extern class Context3DClearMask { static var ALL : Int; static var COLOR : Int; static var DEPTH : Int; static var STENCIL : Int; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DCompareMode.hx0000664000175000017500000000024512607337712024340 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DCompareMode { ALWAYS; EQUAL; GREATER; GREATER_EQUAL; LESS; LESS_EQUAL; NEVER; NOT_EQUAL; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DFillMode.hx0000664000175000017500000000016612607337712023642 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) @:require(flash16) extern enum Context3DFillMode { SOLID; WIREFRAME; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DMipFilter.hx0000664000175000017500000000016312607337712024037 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DMipFilter { MIPLINEAR; MIPNEAREST; MIPNONE; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DProfile.hx0000664000175000017500000000024612607337712023546 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DProfile { BASELINE; BASELINE_CONSTRAINED; BASELINE_EXTENDED; STANDARD; STANDARD_CONSTRAINED; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DProgramType.hx0000664000175000017500000000014612607337712024416 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DProgramType { FRAGMENT; VERTEX; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DRenderMode.hx0000664000175000017500000000014312607337712024166 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DRenderMode { AUTO; SOFTWARE; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DStencilAction.hx0000664000175000017500000000027512607337712024707 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DStencilAction { DECREMENT_SATURATE; DECREMENT_WRAP; INCREMENT_SATURATE; INCREMENT_WRAP; INVERT; KEEP; SET; ZERO; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DTextureFilter.hx0000664000175000017500000000025012607337712024747 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DTextureFilter { ANISOTROPIC16X; ANISOTROPIC2X; ANISOTROPIC4X; ANISOTROPIC8X; LINEAR; NEAREST; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DTextureFormat.hx0000664000175000017500000000025012607337712024752 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DTextureFormat { BGRA; BGRA_PACKED; BGR_PACKED; COMPRESSED; COMPRESSED_ALPHA; RGBA_HALF_FLOAT; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DTriangleFace.hx0000664000175000017500000000017212607337712024470 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DTriangleFace { BACK; FRONT; FRONT_AND_BACK; NONE; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DVertexBufferFormat.hx0000664000175000017500000000021312607337712025720 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DVertexBufferFormat { BYTES_4; FLOAT_1; FLOAT_2; FLOAT_3; FLOAT_4; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Context3DWrapMode.hx0000664000175000017500000000020612607337712023660 0ustar andyandy00000000000000package flash.display3D; @:fakeEnum(String) extern enum Context3DWrapMode { CLAMP; CLAMP_U_REPEAT_V; REPEAT; REPEAT_U_CLAMP_V; } haxe_3.2.1+dfsg.orig/std/flash/display3D/IndexBuffer3D.hx0000664000175000017500000000046612607337712023006 0ustar andyandy00000000000000package flash.display3D; @:final extern class IndexBuffer3D { function dispose() : Void; function uploadFromByteArray(data : flash.utils.ByteArray, byteArrayOffset : Int, startOffset : Int, count : Int) : Void; function uploadFromVector(data : flash.Vector, startOffset : Int, count : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display3D/Program3D.hx0000664000175000017500000000030212607337712022201 0ustar andyandy00000000000000package flash.display3D; @:final extern class Program3D { function dispose() : Void; function upload(vertexProgram : flash.utils.ByteArray, fragmentProgram : flash.utils.ByteArray) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display3D/VertexBuffer3D.hx0000664000175000017500000000047412607337712023213 0ustar andyandy00000000000000package flash.display3D; extern class VertexBuffer3D { function dispose() : Void; function uploadFromByteArray(data : flash.utils.ByteArray, byteArrayOffset : Int, startVertex : Int, numVertices : Int) : Void; function uploadFromVector(data : flash.Vector, startVertex : Int, numVertices : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display3D/textures/CubeTexture.hx0000664000175000017500000000071112607337712024531 0ustar andyandy00000000000000package flash.display3D.textures; @:final extern class CubeTexture extends TextureBase { function uploadCompressedTextureFromByteArray(data : flash.utils.ByteArray, byteArrayOffset : UInt, async : Bool = false) : Void; function uploadFromBitmapData(source : flash.display.BitmapData, side : UInt, miplevel : UInt = 0) : Void; function uploadFromByteArray(data : flash.utils.ByteArray, byteArrayOffset : UInt, side : UInt, miplevel : UInt = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display3D/textures/RectangleTexture.hx0000664000175000017500000000043712607337712025564 0ustar andyandy00000000000000package flash.display3D.textures; @:final extern class RectangleTexture extends TextureBase { function new() : Void; function uploadFromBitmapData(source : flash.display.BitmapData) : Void; function uploadFromByteArray(data : flash.utils.ByteArray, byteArrayOffset : UInt) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display3D/textures/Texture.hx0000664000175000017500000000065312607337712023737 0ustar andyandy00000000000000package flash.display3D.textures; @:final extern class Texture extends TextureBase { function uploadCompressedTextureFromByteArray(data : flash.utils.ByteArray, byteArrayOffset : UInt, async : Bool = false) : Void; function uploadFromBitmapData(source : flash.display.BitmapData, miplevel : UInt = 0) : Void; function uploadFromByteArray(data : flash.utils.ByteArray, byteArrayOffset : UInt, miplevel : UInt = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/display3D/textures/TextureBase.hx0000664000175000017500000000020112607337712024517 0ustar andyandy00000000000000package flash.display3D.textures; extern class TextureBase extends flash.events.EventDispatcher { function dispose() : Void; } haxe_3.2.1+dfsg.orig/std/flash/display3D/textures/VideoTexture.hx0000664000175000017500000000050212607337712024717 0ustar andyandy00000000000000package flash.display3D.textures; @:final extern class VideoTexture extends TextureBase { var videoHeight(default,null) : Int; var videoWidth(default,null) : Int; function new() : Void; function attachCamera(theCamera : flash.media.Camera) : Void; function attachNetStream(netStream : flash.net.NetStream) : Void; } haxe_3.2.1+dfsg.orig/std/flash/errors/ArgumentError.hx0000664000175000017500000000013612607337712022664 0ustar andyandy00000000000000package flash.errors; @:native("ArgumentError") extern class ArgumentError extends Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/DRMManagerError.hx0000664000175000017500000000034312607337712023017 0ustar andyandy00000000000000package flash.errors; @:require(flash10_1) extern class DRMManagerError extends Error { var subErrorID(default,null) : Int; function new(message : String, id : Int, subErrorID : Int) : Void; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/errors/DefinitionError.hx0000664000175000017500000000015712607337712023175 0ustar andyandy00000000000000package flash.errors; @:native("DefinitionError") extern class DefinitionError extends flash.errors.Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/EOFError.hx0000664000175000017500000000017012607337712021511 0ustar andyandy00000000000000package flash.errors; extern class EOFError extends IOError { function new(?message : String, id : Int = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/errors/Error.hx0000664000175000017500000000076012607337712021164 0ustar andyandy00000000000000package flash.errors; extern class Error #if !flash_strict implements Dynamic #end { var errorID(default,null) : Int; var message : Dynamic; var name : Dynamic; function new(?message : Dynamic, id : Dynamic = 0) : Void; function getStackTrace() : String; static var length : Int; static function getErrorMessage(index : Int) : String; static function throwError(type : Class, index : UInt, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Dynamic; } haxe_3.2.1+dfsg.orig/std/flash/errors/EvalError.hx0000664000175000017500000000014312607337712021767 0ustar andyandy00000000000000package flash.errors; @:native("EvalError") extern class EvalError extends flash.errors.Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/IOError.hx0000664000175000017500000000016512607337712021413 0ustar andyandy00000000000000package flash.errors; extern class IOError extends Error { function new(?message : String, id : Int = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/errors/IllegalOperationError.hx0000664000175000017500000000020312607337712024327 0ustar andyandy00000000000000package flash.errors; extern class IllegalOperationError extends Error { function new(?message : String, id : Int = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/errors/InvalidSWFError.hx0000664000175000017500000000017512607337712023053 0ustar andyandy00000000000000package flash.errors; extern class InvalidSWFError extends Error { function new(?message : String, id : Int = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/errors/MemoryError.hx0000664000175000017500000000017112607337712022351 0ustar andyandy00000000000000package flash.errors; extern class MemoryError extends Error { function new(?message : String, id : Int = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/errors/RangeError.hx0000664000175000017500000000014512607337712022136 0ustar andyandy00000000000000package flash.errors; @:native("RangeError") extern class RangeError extends flash.errors.Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/ReferenceError.hx0000664000175000017500000000015512607337712023001 0ustar andyandy00000000000000package flash.errors; @:native("ReferenceError") extern class ReferenceError extends flash.errors.Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/ScriptTimeoutError.hx0000664000175000017500000000020012607337712023705 0ustar andyandy00000000000000package flash.errors; extern class ScriptTimeoutError extends Error { function new(?message : String, id : Int = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/errors/SecurityError.hx0000664000175000017500000000013612607337712022711 0ustar andyandy00000000000000package flash.errors; @:native("SecurityError") extern class SecurityError extends Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/StackOverflowError.hx0000664000175000017500000000020012607337712023663 0ustar andyandy00000000000000package flash.errors; extern class StackOverflowError extends Error { function new(?message : String, id : Int = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/errors/SyntaxError.hx0000664000175000017500000000014712607337712022372 0ustar andyandy00000000000000package flash.errors; @:native("SyntaxError") extern class SyntaxError extends flash.errors.Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/TypeError.hx0000664000175000017500000000012612607337712022022 0ustar andyandy00000000000000package flash.errors; @:native("TypeError") extern class TypeError extends Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/URIError.hx0000664000175000017500000000014112607337712021535 0ustar andyandy00000000000000package flash.errors; @:native("URIError") extern class URIError extends flash.errors.Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/UninitializedError.hx0000664000175000017500000000016512607337712023714 0ustar andyandy00000000000000package flash.errors; @:native("UninitializedError") extern class UninitializedError extends flash.errors.Error { } haxe_3.2.1+dfsg.orig/std/flash/errors/VerifyError.hx0000664000175000017500000000013212607337712022342 0ustar andyandy00000000000000package flash.errors; @:native("VerifyError") extern class VerifyError extends Error { } haxe_3.2.1+dfsg.orig/std/flash/events/AVDictionaryDataEvent.hx0000664000175000017500000000055512607337712024215 0ustar andyandy00000000000000package flash.events; extern class AVDictionaryDataEvent extends Event { var dictionary(default,null) : flash.utils.Dictionary; var time(default,null) : Float; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, ?init_dictionary : flash.utils.Dictionary, init_dataTime : Float = 0) : Void; static var AV_DICTIONARY_DATA : String; } haxe_3.2.1+dfsg.orig/std/flash/events/AVHTTPStatusEvent.hx0000664000175000017500000000057512607337712023303 0ustar andyandy00000000000000package flash.events; extern class AVHTTPStatusEvent extends Event { var responseHeaders : Array; var responseURL : String; var status(default,null) : Int; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, status : Int = 0, ?responseUrl : String, ?responseHeaders : Array) : Void; static var AV_HTTP_RESPONSE_STATUS : String; } haxe_3.2.1+dfsg.orig/std/flash/events/AVLoadInfoEvent.hx0000664000175000017500000000043712607337712023010 0ustar andyandy00000000000000package flash.events; extern class AVLoadInfoEvent extends Event { var loadInfo(default,null) : flash.utils.Dictionary; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, ?inLoadInfo : flash.utils.Dictionary) : Void; static var AV_LOAD_INFO : Dynamic; } haxe_3.2.1+dfsg.orig/std/flash/events/AVManifestLoadEvent.hx0000664000175000017500000000067312607337712023665 0ustar andyandy00000000000000package flash.events; extern class AVManifestLoadEvent extends Event { var duration(default,null) : Float; var handle(default,null) : Int; var result(default,null) : flash.media.AVResult; var userData(default,null) : Int; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, inResult : Int = 0, inUserData : Int = 0, inHandle : Int = 0, inDuration : Float = 0) : Void; static var AV_MANIFEST_LOAD : String; } haxe_3.2.1+dfsg.orig/std/flash/events/AVPauseAtPeriodEndEvent.hx0000664000175000017500000000041312607337712024443 0ustar andyandy00000000000000package flash.events; extern class AVPauseAtPeriodEndEvent extends Event { var userData(default,null) : Int; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, userData : Int = 0) : Void; static var AV_PAUSE_AT_PERIOD_END : String; } haxe_3.2.1+dfsg.orig/std/flash/events/AVPlayStateEvent.hx0000664000175000017500000000041712607337712023221 0ustar andyandy00000000000000package flash.events; extern class AVPlayStateEvent extends Event { var playState(default,null) : flash.media.AVPlayState; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, inState : Int = 0) : Void; static var AV_PLAY_STATE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/AVStatusEvent.hx0000664000175000017500000000174212607337712022600 0ustar andyandy00000000000000package flash.events; extern class AVStatusEvent extends Event { var description(default,null) : String; var notificationType(default,null) : String; var result(default,null) : flash.media.AVResult; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, ?inNotificationType : String, inResult : Int = 0, ?inDescription : String) : Void; static var AV_STATUS : String; static var BACKGROUND_MANIFEST_ERROR : String; static var BACKGROUND_MANIFEST_WARNING : String; static var BUFFER_STATE : String; static var DECODER_TYPE : String; static var DIMENSION_CHANGE : String; static var ERROR : String; static var INSERTION_COMPLETE : String; static var LOAD_COMPLETE : String; static var MANIFEST_UPDATE : String; static var PLAY_STATE : String; static var RENDER_TYPE : String; static var SEEK_COMPLETE : String; static var STEP_COMPLETE : String; static var STREAM_SWITCH : String; static var TRICKPLAY_ENDED : String; static var WARNING : String; } haxe_3.2.1+dfsg.orig/std/flash/events/AVStreamSwitchEvent.hx0000664000175000017500000000104312607337712023724 0ustar andyandy00000000000000package flash.events; extern class AVStreamSwitchEvent extends Event { var bitrate(default,null) : Int; var description(default,null) : String; var switchType(default,null) : Int; var time(default,null) : Float; var userData(default,null) : Int; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, time : Float = 0, switchType : Int = 0, bitrate : Int = 0, ?description : String, userData : Int = 0) : Void; static var ABR_SWITCH : Int; static var AV_STREAM_SWITCH : String; static var PERIOD_SWITCH : Int; } haxe_3.2.1+dfsg.orig/std/flash/events/AccelerometerEvent.hx0000664000175000017500000000064712607337712023643 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class AccelerometerEvent extends Event { var accelerationX : Float; var accelerationY : Float; var accelerationZ : Float; var timestamp : Float; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, timestamp : Float = 0, accelerationX : Float = 0, accelerationY : Float = 0, accelerationZ : Float = 0) : Void; static var UPDATE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/ActivityEvent.hx0000664000175000017500000000035612607337712022662 0ustar andyandy00000000000000package flash.events; extern class ActivityEvent extends Event { var activating : Bool; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, activating : Bool = false) : Void; static var ACTIVITY : String; } haxe_3.2.1+dfsg.orig/std/flash/events/AsyncErrorEvent.hx0000664000175000017500000000042312607337712023150 0ustar andyandy00000000000000package flash.events; extern class AsyncErrorEvent extends ErrorEvent { var error : flash.errors.Error; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?text : String, ?error : flash.errors.Error) : Void; static var ASYNC_ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/ContextMenuEvent.hx0000664000175000017500000000076412607337712023342 0ustar andyandy00000000000000package flash.events; extern class ContextMenuEvent extends Event { var contextMenuOwner : flash.display.InteractiveObject; @:require(flash10) var isMouseTargetInaccessible : Bool; var mouseTarget : flash.display.InteractiveObject; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?mouseTarget : flash.display.InteractiveObject, ?contextMenuOwner : flash.display.InteractiveObject) : Void; static var MENU_ITEM_SELECT : String; static var MENU_SELECT : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMAuthenticateEvent.hx0000664000175000017500000000132712607337712024046 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class DRMAuthenticateEvent extends Event { var authenticationType(default,null) : String; var header(default,null) : String; var netstream(default,null) : flash.net.NetStream; var passwordPrompt(default,null) : String; var urlPrompt(default,null) : String; var usernamePrompt(default,null) : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?header : String, ?userPrompt : String, ?passPrompt : String, ?urlPrompt : String, ?authenticationType : String, ?netstream : flash.net.NetStream) : Void; static var AUTHENTICATION_TYPE_DRM : String; static var AUTHENTICATION_TYPE_PROXY : String; static var DRM_AUTHENTICATE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMAuthenticationCompleteEvent.hx0000664000175000017500000000062012607337712026073 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class DRMAuthenticationCompleteEvent extends Event { var domain : String; var serverURL : String; var token : flash.utils.ByteArray; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?inServerURL : String, ?inDomain : String, ?inToken : flash.utils.ByteArray) : Void; static var AUTHENTICATION_COMPLETE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMAuthenticationErrorEvent.hx0000664000175000017500000000064112607337712025417 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class DRMAuthenticationErrorEvent extends ErrorEvent { var domain : String; var serverURL : String; var subErrorID : Int; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?inDetail : String, inErrorID : Int = 0, inSubErrorID : Int = 0, ?inServerURL : String, ?inDomain : String) : Void; static var AUTHENTICATION_ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMCustomProperties.hx0000664000175000017500000000015112607337712023747 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class DRMCustomProperties { function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMDeviceGroupErrorEvent.hx0000664000175000017500000000114412607337712024653 0ustar andyandy00000000000000package flash.events; extern class DRMDeviceGroupErrorEvent extends ErrorEvent { var deviceGroup : flash.net.drm.DRMDeviceGroup; var drmUpdateNeeded(default,null) : Bool; var subErrorID : Int; var systemUpdateNeeded(default,null) : Bool; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?errorDetail : String, errorCode : Int = 0, subErrorID : Int = 0, ?deviceGroup : flash.net.drm.DRMDeviceGroup, systemUpdateNeeded : Bool = false, drmUpdateNeeded : Bool = false) : Void; static var ADD_TO_DEVICE_GROUP_ERROR : String; static var REMOVE_FROM_DEVICE_GROUP_ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMDeviceGroupEvent.hx0000664000175000017500000000055312607337712023644 0ustar andyandy00000000000000package flash.events; extern class DRMDeviceGroupEvent extends Event { var deviceGroup : flash.net.drm.DRMDeviceGroup; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?deviceGroup : flash.net.drm.DRMDeviceGroup) : Void; static var ADD_TO_DEVICE_GROUP_COMPLETE : String; static var REMOVE_FROM_DEVICE_GROUP_COMPLETE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMErrorEvent.hx0000664000175000017500000000115712607337712022522 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class DRMErrorEvent extends ErrorEvent { var contentData : flash.net.drm.DRMContentData; var drmUpdateNeeded(default,null) : Bool; var subErrorID(default,null) : Int; var systemUpdateNeeded(default,null) : Bool; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, ?inErrorDetail : String, inErrorCode : Int = 0, insubErrorID : Int = 0, ?inMetadata : flash.net.drm.DRMContentData, inSystemUpdateNeeded : Bool = false, inDrmUpdateNeeded : Bool = false) : Void; static var DRM_ERROR : String; static var DRM_LOAD_DEVICEID_ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMLicenseRequestEvent.hx0000664000175000017500000000037312607337712024363 0ustar andyandy00000000000000package flash.events; extern class DRMLicenseRequestEvent extends Event { var serverURL : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?inServerURL : String) : Void; static var LICENSE_REQUEST : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMMetadataEvent.hx0000664000175000017500000000054612607337712023152 0ustar andyandy00000000000000package flash.events; extern class DRMMetadataEvent extends Event { var drmMetadata(default,null) : flash.net.drm.DRMContentData; var timestamp(default,null) : Float; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, ?inMetadata : flash.utils.ByteArray, inTimestamp : Float = 0) : Void; static var DRM_METADATA : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMReturnVoucherCompleteEvent.hx0000664000175000017500000000066312607337712025736 0ustar andyandy00000000000000package flash.events; extern class DRMReturnVoucherCompleteEvent extends Event { var licenseID : String; var numberOfVouchersReturned : Int; var policyID : String; var serverURL : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?inServerURL : String, ?inLicenseID : String, ?inPolicyID : String, inNumberOfVouchersReturned : Int = 0) : Void; static var RETURN_VOUCHER_COMPLETE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMReturnVoucherErrorEvent.hx0000664000175000017500000000067712607337712025264 0ustar andyandy00000000000000package flash.events; extern class DRMReturnVoucherErrorEvent extends ErrorEvent { var licenseID : String; var policyID : String; var serverURL : String; var subErrorID : Int; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?inDetail : String, inErrorID : Int = 0, inSubErrorID : Int = 0, ?inServerURL : String, ?inLicenseID : String, ?inPolicyID : String) : Void; static var RETURN_VOUCHER_ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DRMStatusEvent.hx0000664000175000017500000000065612607337712022717 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class DRMStatusEvent extends Event { var contentData : flash.net.drm.DRMContentData; var isLocal : Bool; var voucher : flash.net.drm.DRMVoucher; function new(?type : String, bubbles : Bool = false, cancelable : Bool = false, ?inMetadata : flash.net.drm.DRMContentData, ?inVoucher : flash.net.drm.DRMVoucher, inLocal : Bool = false) : Void; static var DRM_STATUS : String; } haxe_3.2.1+dfsg.orig/std/flash/events/DataEvent.hx0000664000175000017500000000040612607337712021733 0ustar andyandy00000000000000package flash.events; extern class DataEvent extends TextEvent { var data : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?data : String) : Void; static var DATA : String; static var UPLOAD_COMPLETE_DATA : String; } haxe_3.2.1+dfsg.orig/std/flash/events/ErrorEvent.hx0000664000175000017500000000041612607337712022154 0ustar andyandy00000000000000package flash.events; extern class ErrorEvent extends TextEvent { @:require(flash10_1) var errorID(default,null) : Int; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?text : String, id : Int = 0) : Void; static var ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/Event.hx0000664000175000017500000000452012607337712021142 0ustar andyandy00000000000000package flash.events; extern class Event { var bubbles(default,null) : Bool; var cancelable(default,null) : Bool; var currentTarget(default,null) : Dynamic; var eventPhase(default,null) : EventPhase; var target(default,null) : Dynamic; var type(default,null) : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false) : Void; function clone() : Event; function formatToString(className : String, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : String; function isDefaultPrevented() : Bool; function preventDefault() : Void; function stopImmediatePropagation() : Void; function stopPropagation() : Void; function toString() : String; static var ACTIVATE : String; static var ADDED : String; static var ADDED_TO_STAGE : String; @:require(flash15) static var BROWSER_ZOOM_CHANGE : String; static var CANCEL : String; static var CHANGE : String; static var CHANNEL_MESSAGE : String; static var CHANNEL_STATE : String; @:require(flash10) static var CLEAR : String; static var CLOSE : String; static var COMPLETE : String; static var CONNECT : String; @:require(flash11) static var CONTEXT3D_CREATE : String; @:require(flash10) static var COPY : String; @:require(flash10) static var CUT : String; static var DEACTIVATE : String; static var ENTER_FRAME : String; @:require(flash10) static var EXIT_FRAME : String; @:require(flash10) static var FRAME_CONSTRUCTED : String; @:require(flash11_3) static var FRAME_LABEL : String; static var FULLSCREEN : String; static var ID3 : String; static var INIT : String; static var MOUSE_LEAVE : String; static var OPEN : String; @:require(flash10) static var PASTE : String; static var REMOVED : String; static var REMOVED_FROM_STAGE : String; static var RENDER : String; static var RESIZE : String; static var SCROLL : String; static var SELECT : String; @:require(flash10) static var SELECT_ALL : String; static var SOUND_COMPLETE : String; @:require(flash11_3) static var SUSPEND : String; static var TAB_CHILDREN_CHANGE : String; static var TAB_ENABLED_CHANGE : String; static var TAB_INDEX_CHANGE : String; @:require(flash11_3) static var TEXTURE_READY : String; @:require(flash11) static var TEXT_INTERACTION_MODE_CHANGE : String; static var UNLOAD : String; static var VIDEO_FRAME : String; static var WORKER_STATE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/EventDispatcher.hx0000664000175000017500000000107512607337712023153 0ustar andyandy00000000000000package flash.events; extern class EventDispatcher implements IEventDispatcher { function new(?target : IEventDispatcher) : Void; function addEventListener(type : String, listener : Dynamic -> Void, useCapture : Bool = false, priority : Int = 0, useWeakReference : Bool = false) : Void; function dispatchEvent(event : Event) : Bool; function hasEventListener(type : String) : Bool; function removeEventListener(type : String, listener : Dynamic -> Void, useCapture : Bool = false) : Void; function toString() : String; function willTrigger(type : String) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/events/EventPhase.hx0000664000175000017500000000016212607337712022121 0ustar andyandy00000000000000package flash.events; @:fakeEnum(UInt) extern enum EventPhase { AT_TARGET; BUBBLING_PHASE; CAPTURING_PHASE; } haxe_3.2.1+dfsg.orig/std/flash/events/FocusEvent.hx0000664000175000017500000000104312607337712022137 0ustar andyandy00000000000000package flash.events; extern class FocusEvent extends Event { @:require(flash10) var isRelatedObjectInaccessible : Bool; var keyCode : UInt; var relatedObject : flash.display.InteractiveObject; var shiftKey : Bool; function new(type : String, bubbles : Bool = true, cancelable : Bool = false, ?relatedObject : flash.display.InteractiveObject, shiftKey : Bool = false, keyCode : UInt = 0) : Void; static var FOCUS_IN : String; static var FOCUS_OUT : String; static var KEY_FOCUS_CHANGE : String; static var MOUSE_FOCUS_CHANGE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/FullScreenEvent.hx0000664000175000017500000000065512607337712023132 0ustar andyandy00000000000000package flash.events; extern class FullScreenEvent extends ActivityEvent { var fullScreen(default,null) : Bool; @:require(flash11_3) var interactive(default,null) : Bool; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, fullScreen : Bool = false, interactive : Bool = false) : Void; static var FULL_SCREEN : String; @:require(flash11_3) static var FULL_SCREEN_INTERACTIVE_ACCEPTED : String; } haxe_3.2.1+dfsg.orig/std/flash/events/GameInputEvent.hx0000664000175000017500000000060212607337712022751 0ustar andyandy00000000000000package flash.events; @:final @:require(flash11_8) extern class GameInputEvent extends Event { var device(default,null) : flash.ui.GameInputDevice; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?device : flash.ui.GameInputDevice) : Void; static var DEVICE_ADDED : String; static var DEVICE_REMOVED : String; static var DEVICE_UNUSABLE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/GeolocationEvent.hx0000664000175000017500000000111112607337712023317 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class GeolocationEvent extends Event { var altitude : Float; var heading : Float; var horizontalAccuracy : Float; var latitude : Float; var longitude : Float; var speed : Float; var timestamp : Float; var verticalAccuracy : Float; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, latitude : Float = 0, longitude : Float = 0, altitude : Float = 0, hAccuracy : Float = 0, vAccuracy : Float = 0, speed : Float = 0, heading : Float = 0, timestamp : Float = 0) : Void; static var UPDATE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/GestureEvent.hx0000664000175000017500000000110612607337712022476 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class GestureEvent extends Event { var altKey : Bool; var ctrlKey : Bool; var localX : Float; var localY : Float; var phase : String; var shiftKey : Bool; var stageX(default,null) : Float; var stageY(default,null) : Float; function new(type : String, bubbles : Bool = true, cancelable : Bool = false, ?phase : String, localX : Float = 0, localY : Float = 0, ctrlKey : Bool = false, altKey : Bool = false, shiftKey : Bool = false) : Void; function updateAfterEvent() : Void; static var GESTURE_TWO_FINGER_TAP : String; } haxe_3.2.1+dfsg.orig/std/flash/events/GesturePhase.hx0000664000175000017500000000017112607337712022456 0ustar andyandy00000000000000package flash.events; @:fakeEnum(String) @:require(flash10_1) extern enum GesturePhase { ALL; BEGIN; END; UPDATE; } haxe_3.2.1+dfsg.orig/std/flash/events/HTTPStatusEvent.hx0000664000175000017500000000072212607337712023046 0ustar andyandy00000000000000package flash.events; extern class HTTPStatusEvent extends Event { var redirected : Bool; @:require(flash10_1) var responseHeaders : Array; @:require(flash10_1) var responseURL : String; var status(default,null) : Int; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, status : Int = 0, redirected : Bool = false) : Void; @:require(flash10_1) static var HTTP_RESPONSE_STATUS : String; static var HTTP_STATUS : String; } haxe_3.2.1+dfsg.orig/std/flash/events/IEventDispatcher.hx0000664000175000017500000000072512607337712023265 0ustar andyandy00000000000000package flash.events; extern interface IEventDispatcher { function addEventListener(type : String, listener : Dynamic -> Void, useCapture : Bool = false, priority : Int = 0, useWeakReference : Bool = false) : Void; function dispatchEvent(event : Event) : Bool; function hasEventListener(type : String) : Bool; function removeEventListener(type : String, listener : Dynamic -> Void, useCapture : Bool = false) : Void; function willTrigger(type : String) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/events/IMEEvent.hx0000664000175000017500000000057312607337712021501 0ustar andyandy00000000000000package flash.events; extern class IMEEvent extends TextEvent { @:require(flash10_1) var imeClient : flash.text.ime.IIMEClient; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?text : String, ?imeClient : flash.text.ime.IIMEClient) : Void; static var IME_COMPOSITION : String; @:require(flash10_1) static var IME_START_COMPOSITION : String; } haxe_3.2.1+dfsg.orig/std/flash/events/IOErrorEvent.hx0000664000175000017500000000050512607337712022403 0ustar andyandy00000000000000package flash.events; extern class IOErrorEvent extends ErrorEvent { function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?text : String, id : Int = 0) : Void; static var DISK_ERROR : String; static var IO_ERROR : String; static var NETWORK_ERROR : String; static var VERIFY_ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/KeyboardEvent.hx0000664000175000017500000000110612607337712022620 0ustar andyandy00000000000000package flash.events; extern class KeyboardEvent extends Event { var altKey : Bool; var charCode : UInt; var ctrlKey : Bool; var keyCode : UInt; var keyLocation : flash.ui.KeyLocation; var shiftKey : Bool; function new(type : String, bubbles : Bool = true, cancelable : Bool = false, charCodeValue : UInt = 0, keyCodeValue : UInt = 0, keyLocationValue : flash.ui.KeyLocation = 0, ctrlKeyValue : Bool = false, altKeyValue : Bool = false, shiftKeyValue : Bool = false) : Void; function updateAfterEvent() : Void; static var KEY_DOWN : String; static var KEY_UP : String; } haxe_3.2.1+dfsg.orig/std/flash/events/MouseEvent.hx0000664000175000017500000000307412607337712022156 0ustar andyandy00000000000000package flash.events; extern class MouseEvent extends Event { var altKey : Bool; var buttonDown : Bool; var ctrlKey : Bool; var delta : Int; @:require(flash10) var isRelatedObjectInaccessible : Bool; var localX : Float; var localY : Float; @:require(flash11_2) var movementX : Float; @:require(flash11_2) var movementY : Float; var relatedObject : flash.display.InteractiveObject; var shiftKey : Bool; var stageX(default,null) : Float; var stageY(default,null) : Float; function new(type : String, bubbles : Bool = true, cancelable : Bool = false, ?localX : Float, ?localY : Float, ?relatedObject : flash.display.InteractiveObject, ctrlKey : Bool = false, altKey : Bool = false, shiftKey : Bool = false, buttonDown : Bool = false, delta : Int = 0) : Void; function updateAfterEvent() : Void; static var CLICK : String; @:require(flash11_2) static var CONTEXT_MENU : String; static var DOUBLE_CLICK : String; @:require(flash11_2) static var MIDDLE_CLICK : String; @:require(flash11_2) static var MIDDLE_MOUSE_DOWN : String; @:require(flash11_2) static var MIDDLE_MOUSE_UP : String; static var MOUSE_DOWN : String; static var MOUSE_MOVE : String; static var MOUSE_OUT : String; static var MOUSE_OVER : String; static var MOUSE_UP : String; static var MOUSE_WHEEL : String; @:require(flash11_3) static var RELEASE_OUTSIDE : String; @:require(flash11_2) static var RIGHT_CLICK : String; @:require(flash11_2) static var RIGHT_MOUSE_DOWN : String; @:require(flash11_2) static var RIGHT_MOUSE_UP : String; static var ROLL_OUT : String; static var ROLL_OVER : String; } haxe_3.2.1+dfsg.orig/std/flash/events/NetDataEvent.hx0000664000175000017500000000046212607337712022404 0ustar andyandy00000000000000package flash.events; extern class NetDataEvent extends Event { var info(default,null) : Dynamic; var timestamp(default,null) : Float; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, timestamp : Float = 0, ?info : Dynamic) : Void; static var MEDIA_TYPE_DATA : String; } haxe_3.2.1+dfsg.orig/std/flash/events/NetFilterEvent.hx0000664000175000017500000000044512607337712022761 0ustar andyandy00000000000000package flash.events; extern class NetFilterEvent extends Event { var data : flash.utils.ByteArray; var header : flash.utils.ByteArray; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?header : flash.utils.ByteArray, ?data : flash.utils.ByteArray) : Void; } haxe_3.2.1+dfsg.orig/std/flash/events/NetMonitorEvent.hx0000664000175000017500000000043412607337712023161 0ustar andyandy00000000000000package flash.events; extern class NetMonitorEvent extends Event { var netStream(default,null) : flash.net.NetStream; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?netStream : flash.net.NetStream) : Void; static var NET_STREAM_CREATE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/NetStatusEvent.hx0000664000175000017500000000034412607337712023015 0ustar andyandy00000000000000package flash.events; extern class NetStatusEvent extends Event { var info : Dynamic; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?info : Dynamic) : Void; static var NET_STATUS : String; } haxe_3.2.1+dfsg.orig/std/flash/events/OutputProgressEvent.hx0000664000175000017500000000045612607337712024114 0ustar andyandy00000000000000package flash.events; extern class OutputProgressEvent extends Event { var bytesPending : Float; var bytesTotal : Float; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, bytesPending : Float = 0, bytesTotal : Float = 0) : Void; static var OUTPUT_PROGRESS : String; } haxe_3.2.1+dfsg.orig/std/flash/events/PressAndTapGestureEvent.hx0000664000175000017500000000103012607337712024577 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class PressAndTapGestureEvent extends GestureEvent { var tapLocalX : Float; var tapLocalY : Float; var tapStageX(default,null) : Float; var tapStageY(default,null) : Float; function new(type : String, bubbles : Bool = true, cancelable : Bool = false, ?phase : String, localX : Float = 0, localY : Float = 0, tapLocalX : Float = 0, tapLocalY : Float = 0, ctrlKey : Bool = false, altKey : Bool = false, shiftKey : Bool = false) : Void; static var GESTURE_PRESS_AND_TAP : String; } haxe_3.2.1+dfsg.orig/std/flash/events/ProgressEvent.hx0000664000175000017500000000050112607337712022662 0ustar andyandy00000000000000package flash.events; extern class ProgressEvent extends Event { var bytesLoaded : Float; var bytesTotal : Float; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, bytesLoaded : Float = 0, bytesTotal : Float = 0) : Void; static var PROGRESS : String; static var SOCKET_DATA : String; } haxe_3.2.1+dfsg.orig/std/flash/events/SampleDataEvent.hx0000664000175000017500000000046512607337712023102 0ustar andyandy00000000000000package flash.events; extern class SampleDataEvent extends Event { var data : flash.utils.ByteArray; var position : Float; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, theposition : Float = 0, ?thedata : flash.utils.ByteArray) : Void; static var SAMPLE_DATA : String; } haxe_3.2.1+dfsg.orig/std/flash/events/SecurityErrorEvent.hx0000664000175000017500000000035112607337712023702 0ustar andyandy00000000000000package flash.events; extern class SecurityErrorEvent extends ErrorEvent { function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?text : String, id : Int = 0) : Void; static var SECURITY_ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/ShaderEvent.hx0000664000175000017500000000062312607337712022271 0ustar andyandy00000000000000package flash.events; extern class ShaderEvent extends Event { var bitmapData : flash.display.BitmapData; var byteArray : flash.utils.ByteArray; var vector : flash.Vector; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?bitmap : flash.display.BitmapData, ?array : flash.utils.ByteArray, ?vector : flash.Vector) : Void; static var COMPLETE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/SoftKeyboardEvent.hx0000664000175000017500000000070712607337712023462 0ustar andyandy00000000000000package flash.events; extern class SoftKeyboardEvent extends Event { var relatedObject : flash.display.InteractiveObject; var triggerType(default,null) : String; function new(type : String, bubbles : Bool, cancelable : Bool, relatedObjectVal : flash.display.InteractiveObject, triggerTypeVal : String) : Void; static var SOFT_KEYBOARD_ACTIVATE : String; static var SOFT_KEYBOARD_ACTIVATING : String; static var SOFT_KEYBOARD_DEACTIVATE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/SoftKeyboardTrigger.hx0000664000175000017500000000024112607337712023775 0ustar andyandy00000000000000package flash.events; extern class SoftKeyboardTrigger { function new() : Void; static var CONTENT_TRIGGERED : String; static var USER_TRIGGERED : String; } haxe_3.2.1+dfsg.orig/std/flash/events/StageVideoAvailabilityEvent.hx0000664000175000017500000000050712607337712025451 0ustar andyandy00000000000000package flash.events; extern class StageVideoAvailabilityEvent extends Event { var availability(default,null) : String; var driver : String; var reason : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?availability : String) : Void; static var STAGE_VIDEO_AVAILABILITY : String; } haxe_3.2.1+dfsg.orig/std/flash/events/StageVideoEvent.hx0000664000175000017500000000076012607337712023117 0ustar andyandy00000000000000package flash.events; @:require(flash10_2) extern class StageVideoEvent extends Event { var codecInfo : String; var colorSpace(default,null) : String; var status(default,null) : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?status : String, ?colorSpace : String) : Void; static var RENDER_STATE : String; static var RENDER_STATUS_ACCELERATED : String; static var RENDER_STATUS_SOFTWARE : String; static var RENDER_STATUS_UNAVAILABLE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/StatusEvent.hx0000664000175000017500000000040112607337712022340 0ustar andyandy00000000000000package flash.events; extern class StatusEvent extends Event { var code : String; var level : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?code : String, ?level : String) : Void; static var STATUS : String; } haxe_3.2.1+dfsg.orig/std/flash/events/SyncEvent.hx0000664000175000017500000000036312607337712022000 0ustar andyandy00000000000000package flash.events; extern class SyncEvent extends Event { var changeList : Array; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?changeList : Array) : Void; static var SYNC : String; } haxe_3.2.1+dfsg.orig/std/flash/events/TextEvent.hx0000664000175000017500000000037012607337712022006 0ustar andyandy00000000000000package flash.events; extern class TextEvent extends Event { var text : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?text : String) : Void; static var LINK : String; static var TEXT_INPUT : String; } haxe_3.2.1+dfsg.orig/std/flash/events/ThrottleEvent.hx0000664000175000017500000000052312607337712022667 0ustar andyandy00000000000000package flash.events; @:require(flash11_2) extern class ThrottleEvent extends Event { var state(default,null) : String; var targetFrameRate(default,null) : Float; function new(type : ThrottleType, bubbles : Bool = false, cancelable : Bool = false, ?state : String, targetFrameRate : Float = 0) : Void; static var THROTTLE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/ThrottleType.hx0000664000175000017500000000014312607337712022525 0ustar andyandy00000000000000package flash.events; @:fakeEnum(String) extern enum ThrottleType { PAUSE; RESUME; THROTTLE; } haxe_3.2.1+dfsg.orig/std/flash/events/TimerEvent.hx0000664000175000017500000000037712607337712022151 0ustar andyandy00000000000000package flash.events; extern class TimerEvent extends Event { function new(type : String, bubbles : Bool = false, cancelable : Bool = false) : Void; function updateAfterEvent() : Void; static var TIMER : String; static var TIMER_COMPLETE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/TouchEvent.hx0000664000175000017500000000266512607337712022155 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class TouchEvent extends Event { var altKey : Bool; var ctrlKey : Bool; var isPrimaryTouchPoint : Bool; var isRelatedObjectInaccessible : Bool; var localX : Float; var localY : Float; var pressure : Float; var relatedObject : flash.display.InteractiveObject; var shiftKey : Bool; var sizeX : Float; var sizeY : Float; var stageX(default,null) : Float; var stageY(default,null) : Float; var touchPointID : Int; function new(type : String, bubbles : Bool = true, cancelable : Bool = false, touchPointID : Int = 0, isPrimaryTouchPoint : Bool = false, localX : Float = 0./*NaN*/, localY : Float = 0./*NaN*/, sizeX : Float = 0./*NaN*/, sizeY : Float = 0./*NaN*/, pressure : Float = 0./*NaN*/, ?relatedObject : flash.display.InteractiveObject, ctrlKey : Bool = false, altKey : Bool = false, shiftKey : Bool = false) : Void; function updateAfterEvent() : Void; static var PROXIMITY_BEGIN : String; static var PROXIMITY_END : String; static var PROXIMITY_MOVE : String; static var PROXIMITY_OUT : String; static var PROXIMITY_OVER : String; static var PROXIMITY_ROLL_OUT : String; static var PROXIMITY_ROLL_OVER : String; static var TOUCH_BEGIN : String; static var TOUCH_END : String; static var TOUCH_MOVE : String; static var TOUCH_OUT : String; static var TOUCH_OVER : String; static var TOUCH_ROLL_OUT : String; static var TOUCH_ROLL_OVER : String; static var TOUCH_TAP : String; } haxe_3.2.1+dfsg.orig/std/flash/events/TransformGestureEvent.hx0000664000175000017500000000124312607337712024374 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class TransformGestureEvent extends GestureEvent { var offsetX : Float; var offsetY : Float; var rotation : Float; var scaleX : Float; var scaleY : Float; function new(type : String, bubbles : Bool = true, cancelable : Bool = false, ?phase : String, localX : Float = 0, localY : Float = 0, scaleX : Float = 1, scaleY : Float = 1, rotation : Float = 0, offsetX : Float = 0, offsetY : Float = 0, ctrlKey : Bool = false, altKey : Bool = false, shiftKey : Bool = false) : Void; static var GESTURE_PAN : String; static var GESTURE_ROTATE : String; static var GESTURE_SWIPE : String; static var GESTURE_ZOOM : String; } haxe_3.2.1+dfsg.orig/std/flash/events/UncaughtErrorEvent.hx0000664000175000017500000000043012607337712023647 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class UncaughtErrorEvent extends ErrorEvent { var error(default,null) : Dynamic; function new(?type : String, bubbles : Bool = true, cancelable : Bool = true, ?error_in : Dynamic) : Void; static var UNCAUGHT_ERROR : String; } haxe_3.2.1+dfsg.orig/std/flash/events/UncaughtErrorEvents.hx0000664000175000017500000000020112607337712024026 0ustar andyandy00000000000000package flash.events; @:require(flash10_1) extern class UncaughtErrorEvents extends EventDispatcher { function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/events/VideoEvent.hx0000664000175000017500000000065512607337712022136 0ustar andyandy00000000000000package flash.events; @:require(flash10_2) extern class VideoEvent extends Event { var codecInfo : String; var status(default,null) : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?status : String) : Void; static var RENDER_STATE : String; static var RENDER_STATUS_ACCELERATED : String; static var RENDER_STATUS_SOFTWARE : String; static var RENDER_STATUS_UNAVAILABLE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/VideoTextureEvent.hx0000664000175000017500000000052012607337712023506 0ustar andyandy00000000000000package flash.events; extern class VideoTextureEvent extends Event { var codecInfo : String; var colorSpace(default,null) : String; var status(default,null) : String; function new(type : String, bubbles : Bool = false, cancelable : Bool = false, ?status : String, ?colorSpace : String) : Void; static var RENDER_STATE : String; } haxe_3.2.1+dfsg.orig/std/flash/events/WeakFunctionClosure.hx0000664000175000017500000000007412607337712024013 0ustar andyandy00000000000000package flash.events; extern class WeakFunctionClosure { } haxe_3.2.1+dfsg.orig/std/flash/events/WeakMethodClosure.hx0000664000175000017500000000012212607337712023440 0ustar andyandy00000000000000package flash.events; extern class WeakMethodClosure { function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/external/ExternalInterface.hx0000664000175000017500000000061612607337712024004 0ustar andyandy00000000000000package flash.external; extern class ExternalInterface { static var available(default,null) : Bool; static var marshallExceptions : Bool; static var objectID(default,null) : String; static function addCallback(functionName : String, closure : Dynamic) : Void; static function call(functionName : String, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Dynamic; } haxe_3.2.1+dfsg.orig/std/flash/filters/BevelFilter.hx0000664000175000017500000000124112607337712022425 0ustar andyandy00000000000000package flash.filters; @:final extern class BevelFilter extends BitmapFilter { var angle : Float; var blurX : Float; var blurY : Float; var distance : Float; var highlightAlpha : Float; var highlightColor : UInt; var knockout : Bool; var quality : Int; var shadowAlpha : Float; var shadowColor : UInt; var strength : Float; var type : BitmapFilterType; function new(distance : Float = 4, angle : Float = 45, highlightColor : UInt = 0xFFFFFF, highlightAlpha : Float = 1, shadowColor : UInt = 0, shadowAlpha : Float = 1, blurX : Float = 4, blurY : Float = 4, strength : Float = 1, quality : Int = 1, ?type : BitmapFilterType, knockout : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/BitmapFilter.hx0000664000175000017500000000016012607337712022603 0ustar andyandy00000000000000package flash.filters; extern class BitmapFilter { function new() : Void; function clone() : BitmapFilter; } haxe_3.2.1+dfsg.orig/std/flash/filters/BitmapFilterQuality.hx0000664000175000017500000000024712607337712024162 0ustar andyandy00000000000000package flash.filters; extern class BitmapFilterQuality { static inline var HIGH : Int = 3; static inline var LOW : Int = 1; static inline var MEDIUM : Int = 2; } haxe_3.2.1+dfsg.orig/std/flash/filters/BitmapFilterType.hx0000664000175000017500000000014312607337712023446 0ustar andyandy00000000000000package flash.filters; @:fakeEnum(String) extern enum BitmapFilterType { FULL; INNER; OUTER; } haxe_3.2.1+dfsg.orig/std/flash/filters/BlurFilter.hx0000664000175000017500000000033412607337712022276 0ustar andyandy00000000000000package flash.filters; @:final extern class BlurFilter extends BitmapFilter { var blurX : Float; var blurY : Float; var quality : Int; function new(blurX : Float = 4, blurY : Float = 4, quality : Int = 1) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/ColorMatrixFilter.hx0000664000175000017500000000024612607337712023637 0ustar andyandy00000000000000package flash.filters; @:final extern class ColorMatrixFilter extends BitmapFilter { var matrix : Array; function new(?matrix : Array) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/ConvolutionFilter.hx0000664000175000017500000000076012607337712023714 0ustar andyandy00000000000000package flash.filters; extern class ConvolutionFilter extends BitmapFilter { var alpha : Float; var bias : Float; var clamp : Bool; var color : UInt; var divisor : Float; var matrix : Array; var matrixX : Float; var matrixY : Float; var preserveAlpha : Bool; function new(matrixX : Float = 0, matrixY : Float = 0, ?matrix : Array, divisor : Float = 1, bias : Float = 0, preserveAlpha : Bool = true, clamp : Bool = true, color : UInt = 0, alpha : Float = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/DisplacementMapFilter.hx0000664000175000017500000000111212607337712024433 0ustar andyandy00000000000000package flash.filters; @:final extern class DisplacementMapFilter extends BitmapFilter { var alpha : Float; var color : UInt; var componentX : UInt; var componentY : UInt; var mapBitmap : flash.display.BitmapData; var mapPoint : flash.geom.Point; var mode : DisplacementMapFilterMode; var scaleX : Float; var scaleY : Float; function new(?mapBitmap : flash.display.BitmapData, ?mapPoint : flash.geom.Point, componentX : UInt = 0, componentY : UInt = 0, scaleX : Float = 0, scaleY : Float = 0, ?mode : DisplacementMapFilterMode, color : UInt = 0, alpha : Float = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/DisplacementMapFilterMode.hx0000664000175000017500000000016512607337712025247 0ustar andyandy00000000000000package flash.filters; @:fakeEnum(String) extern enum DisplacementMapFilterMode { CLAMP; COLOR; IGNORE; WRAP; } haxe_3.2.1+dfsg.orig/std/flash/filters/DropShadowFilter.hx0000664000175000017500000000107312607337712023445 0ustar andyandy00000000000000package flash.filters; @:final extern class DropShadowFilter extends BitmapFilter { var alpha : Float; var angle : Float; var blurX : Float; var blurY : Float; var color : UInt; var distance : Float; var hideObject : Bool; var inner : Bool; var knockout : Bool; var quality : Int; var strength : Float; function new(distance : Float = 4, angle : Float = 45, color : UInt = 0, alpha : Float = 1, blurX : Float = 4, blurY : Float = 4, strength : Float = 1, quality : Int = 1, inner : Bool = false, knockout : Bool = false, hideObject : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/GlowFilter.hx0000664000175000017500000000066412607337712022310 0ustar andyandy00000000000000package flash.filters; @:final extern class GlowFilter extends BitmapFilter { var alpha : Float; var blurX : Float; var blurY : Float; var color : UInt; var inner : Bool; var knockout : Bool; var quality : Int; var strength : Float; function new(color : UInt = 16711680, alpha : Float = 1, blurX : Float = 6, blurY : Float = 6, strength : Float = 2, quality : Int = 1, inner : Bool = false, knockout : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/GradientBevelFilter.hx0000664000175000017500000000114212607337712024103 0ustar andyandy00000000000000package flash.filters; @:final extern class GradientBevelFilter extends BitmapFilter { var alphas : Array; var angle : Float; var blurX : Float; var blurY : Float; var colors : Array; var distance : Float; var knockout : Bool; var quality : Int; var ratios : Array; var strength : Float; var type : String; function new(distance : Float = 4, angle : Float = 45, ?colors : Array, ?alphas : Array, ?ratios : Array, blurX : Float = 4, blurY : Float = 4, strength : Float = 1, quality : Int = 1, ?type : String, knockout : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/GradientGlowFilter.hx0000664000175000017500000000116512607337712023763 0ustar andyandy00000000000000package flash.filters; @:final extern class GradientGlowFilter extends BitmapFilter { var alphas : Array; var angle : Float; var blurX : Float; var blurY : Float; var colors : Array; var distance : Float; var knockout : Bool; var quality : Int; var ratios : Array; var strength : Float; var type : BitmapFilterType; function new(distance : Float = 4, angle : Float = 45, ?colors : Array, ?alphas : Array, ?ratios : Array, blurX : Float = 4, blurY : Float = 4, strength : Float = 1, quality : Int = 1, ?type : BitmapFilterType, knockout : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/filters/ShaderFilter.hx0000664000175000017500000000041712607337712022602 0ustar andyandy00000000000000package flash.filters; extern class ShaderFilter extends BitmapFilter { var bottomExtension : Int; var leftExtension : Int; var rightExtension : Int; var shader : flash.display.Shader; var topExtension : Int; function new(?shader : flash.display.Shader) : Void; } haxe_3.2.1+dfsg.orig/std/flash/geom/ColorTransform.hx0000664000175000017500000000113312607337712022453 0ustar andyandy00000000000000package flash.geom; extern class ColorTransform { var alphaMultiplier : Float; var alphaOffset : Float; var blueMultiplier : Float; var blueOffset : Float; var color : UInt; var greenMultiplier : Float; var greenOffset : Float; var redMultiplier : Float; var redOffset : Float; function new(redMultiplier : Float = 1, greenMultiplier : Float = 1, blueMultiplier : Float = 1, alphaMultiplier : Float = 1, redOffset : Float = 0, greenOffset : Float = 0, blueOffset : Float = 0, alphaOffset : Float = 0) : Void; function concat(second : ColorTransform) : Void; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/geom/Matrix.hx0000664000175000017500000000260112607337712020746 0ustar andyandy00000000000000package flash.geom; extern class Matrix { var a : Float; var b : Float; var c : Float; var d : Float; var tx : Float; var ty : Float; function new(a : Float = 1, b : Float = 0, c : Float = 0, d : Float = 1, tx : Float = 0, ty : Float = 0) : Void; function clone() : Matrix; function concat(m : Matrix) : Void; @:require(flash11) function copyColumnFrom(column : UInt, vector3D : Vector3D) : Void; @:require(flash11) function copyColumnTo(column : UInt, vector3D : Vector3D) : Void; @:require(flash11) function copyFrom(sourceMatrix : Matrix) : Void; @:require(flash11) function copyRowFrom(row : UInt, vector3D : Vector3D) : Void; @:require(flash11) function copyRowTo(row : UInt, vector3D : Vector3D) : Void; function createBox(scaleX : Float, scaleY : Float, rotation : Float = 0, tx : Float = 0, ty : Float = 0) : Void; function createGradientBox(width : Float, height : Float, rotation : Float = 0, tx : Float = 0, ty : Float = 0) : Void; function deltaTransformPoint(point : Point) : Point; function identity() : Void; function invert() : Void; function rotate(angle : Float) : Void; function scale(sx : Float, sy : Float) : Void; @:require(flash11) function setTo(aa : Float, ba : Float, ca : Float, da : Float, txa : Float, tya : Float) : Void; function toString() : String; function transformPoint(point : Point) : Point; function translate(dx : Float, dy : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/geom/Matrix3D.hx0000664000175000017500000000430112607337712021134 0ustar andyandy00000000000000package flash.geom; @:require(flash10) extern class Matrix3D { var determinant(default,null) : Float; var position : Vector3D; var rawData : flash.Vector; function new(?v : flash.Vector) : Void; function append(lhs : Matrix3D) : Void; function appendRotation(degrees : Float, axis : Vector3D, ?pivotPoint : Vector3D) : Void; function appendScale(xScale : Float, yScale : Float, zScale : Float) : Void; function appendTranslation(x : Float, y : Float, z : Float) : Void; function clone() : Matrix3D; @:require(flash11) function copyColumnFrom(column : UInt, vector3D : Vector3D) : Void; @:require(flash11) function copyColumnTo(column : UInt, vector3D : Vector3D) : Void; @:require(flash11) function copyFrom(sourceMatrix3D : Matrix3D) : Void; @:require(flash11) function copyRawDataFrom(vector : flash.Vector, index : UInt = 0, transpose : Bool = false) : Void; @:require(flash11) function copyRawDataTo(vector : flash.Vector, index : UInt = 0, transpose : Bool = false) : Void; @:require(flash11) function copyRowFrom(row : UInt, vector3D : Vector3D) : Void; @:require(flash11) function copyRowTo(row : UInt, vector3D : Vector3D) : Void; @:require(flash11) function copyToMatrix3D(dest : Matrix3D) : Void; function decompose(?orientationStyle : Orientation3D) : flash.Vector; function deltaTransformVector(v : Vector3D) : Vector3D; function identity() : Void; function interpolateTo(toMat : Matrix3D, percent : Float) : Void; function invert() : Bool; function pointAt(pos : Vector3D, ?at : Vector3D, ?up : Vector3D) : Void; function prepend(rhs : Matrix3D) : Void; function prependRotation(degrees : Float, axis : Vector3D, ?pivotPoint : Vector3D) : Void; function prependScale(xScale : Float, yScale : Float, zScale : Float) : Void; function prependTranslation(x : Float, y : Float, z : Float) : Void; function recompose(components : flash.Vector, ?orientationStyle : Orientation3D) : Bool; function transformVector(v : Vector3D) : Vector3D; function transformVectors(vin : flash.Vector, vout : flash.Vector) : Void; function transpose() : Void; static function interpolate(thisMat : Matrix3D, toMat : Matrix3D, percent : Float) : Matrix3D; } haxe_3.2.1+dfsg.orig/std/flash/geom/Orientation3D.hx0000664000175000017500000000015712607337712022170 0ustar andyandy00000000000000package flash.geom; @:fakeEnum(String) extern enum Orientation3D { AXIS_ANGLE; EULER_ANGLES; QUATERNION; } haxe_3.2.1+dfsg.orig/std/flash/geom/PerspectiveProjection.hx0000664000175000017500000000033512607337712024032 0ustar andyandy00000000000000package flash.geom; @:require(flash10) extern class PerspectiveProjection { var fieldOfView : Float; var focalLength : Float; var projectionCenter : Point; function new() : Void; function toMatrix3D() : Matrix3D; } haxe_3.2.1+dfsg.orig/std/flash/geom/Point.hx0000664000175000017500000000137412607337712020601 0ustar andyandy00000000000000package flash.geom; extern class Point { var length(default,null) : Float; var x : Float; var y : Float; function new(x : Float = 0, y : Float = 0) : Void; function add(v : Point) : Point; function clone() : Point; @:require(flash11) function copyFrom(sourcePoint : Point) : Void; function equals(toCompare : Point) : Bool; function normalize(thickness : Float) : Void; function offset(dx : Float, dy : Float) : Void; @:require(flash11) function setTo(xa : Float, ya : Float) : Void; function subtract(v : Point) : Point; function toString() : String; static function distance(pt1 : Point, pt2 : Point) : Float; static function interpolate(pt1 : Point, pt2 : Point, f : Float) : Point; static function polar(len : Float, angle : Float) : Point; } haxe_3.2.1+dfsg.orig/std/flash/geom/Rectangle.hx0000664000175000017500000000225212607337712021410 0ustar andyandy00000000000000package flash.geom; extern class Rectangle { var bottom : Float; var bottomRight : Point; var height : Float; var left : Float; var right : Float; var size : Point; var top : Float; var topLeft : Point; var width : Float; var x : Float; var y : Float; function new(x : Float = 0, y : Float = 0, width : Float = 0, height : Float = 0) : Void; function clone() : Rectangle; function contains(x : Float, y : Float) : Bool; function containsPoint(point : Point) : Bool; function containsRect(rect : Rectangle) : Bool; @:require(flash11) function copyFrom(sourceRect : Rectangle) : Void; function equals(toCompare : Rectangle) : Bool; function inflate(dx : Float, dy : Float) : Void; function inflatePoint(point : Point) : Void; function intersection(toIntersect : Rectangle) : Rectangle; function intersects(toIntersect : Rectangle) : Bool; function isEmpty() : Bool; function offset(dx : Float, dy : Float) : Void; function offsetPoint(point : Point) : Void; function setEmpty() : Void; @:require(flash11) function setTo(xa : Float, ya : Float, widtha : Float, heighta : Float) : Void; function toString() : String; function union(toUnion : Rectangle) : Rectangle; } haxe_3.2.1+dfsg.orig/std/flash/geom/Transform.hx0000664000175000017500000000104612607337712021457 0ustar andyandy00000000000000package flash.geom; extern class Transform { var colorTransform : ColorTransform; var concatenatedColorTransform(default,null) : ColorTransform; var concatenatedMatrix(default,null) : Matrix; var matrix : Matrix; @:require(flash10) var matrix3D : Matrix3D; @:require(flash10) var perspectiveProjection : PerspectiveProjection; var pixelBounds(default,null) : Rectangle; function new(displayObject : flash.display.DisplayObject) : Void; @:require(flash10) function getRelativeMatrix3D(relativeTo : flash.display.DisplayObject) : Matrix3D; } haxe_3.2.1+dfsg.orig/std/flash/geom/Utils3D.hx0000664000175000017500000000063012607337712020771 0ustar andyandy00000000000000package flash.geom; @:require(flash10) extern class Utils3D { static function pointTowards(percent : Float, mat : Matrix3D, pos : Vector3D, ?at : Vector3D, ?up : Vector3D) : Matrix3D; static function projectVector(m : Matrix3D, v : Vector3D) : Vector3D; static function projectVectors(m : Matrix3D, verts : flash.Vector, projectedVerts : flash.Vector, uvts : flash.Vector) : Void; } haxe_3.2.1+dfsg.orig/std/flash/geom/Vector3D.hx0000664000175000017500000000240312607337712021133 0ustar andyandy00000000000000package flash.geom; @:require(flash10) extern class Vector3D { var length(default,null) : Float; var lengthSquared(default,null) : Float; var w : Float; var x : Float; var y : Float; var z : Float; function new(x : Float = 0, y : Float = 0, z : Float = 0, w : Float = 0) : Void; function add(a : Vector3D) : Vector3D; function clone() : Vector3D; @:require(flash11) function copyFrom(sourceVector3D : Vector3D) : Void; function crossProduct(a : Vector3D) : Vector3D; function decrementBy(a : Vector3D) : Void; function dotProduct(a : Vector3D) : Float; function equals(toCompare : Vector3D, allFour : Bool = false) : Bool; function incrementBy(a : Vector3D) : Void; function nearEquals(toCompare : Vector3D, tolerance : Float, allFour : Bool = false) : Bool; function negate() : Void; function normalize() : Float; function project() : Void; function scaleBy(s : Float) : Void; @:require(flash11) function setTo(xa : Float, ya : Float, za : Float) : Void; function subtract(a : Vector3D) : Vector3D; function toString() : String; static var X_AXIS : Vector3D; static var Y_AXIS : Vector3D; static var Z_AXIS : Vector3D; static function angleBetween(a : Vector3D, b : Vector3D) : Float; static function distance(pt1 : Vector3D, pt2 : Vector3D) : Float; } haxe_3.2.1+dfsg.orig/std/flash/globalization/Collator.hx0000664000175000017500000000126612607337712023176 0ustar andyandy00000000000000package flash.globalization; @:final @:require(flash10_1) extern class Collator { var actualLocaleIDName(default,null) : String; var ignoreCase : Bool; var ignoreCharacterWidth : Bool; var ignoreDiacritics : Bool; var ignoreKanaType : Bool; var ignoreSymbols : Bool; var lastOperationStatus(default,null) : LastOperationStatus; var numericComparison : Bool; var requestedLocaleIDName(default,null) : String; function new(requestedLocaleIDName : String, ?initialMode : CollatorMode) : Void; function compare(string1 : String, string2 : String) : Int; function equals(string1 : String, string2 : String) : Bool; static function getAvailableLocaleIDNames() : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/globalization/CollatorMode.hx0000664000175000017500000000014312607337712023774 0ustar andyandy00000000000000package flash.globalization; @:fakeEnum(String) extern enum CollatorMode { MATCHING; SORTING; } haxe_3.2.1+dfsg.orig/std/flash/globalization/CurrencyFormatter.hx0000664000175000017500000000210612607337712025067 0ustar andyandy00000000000000package flash.globalization; @:final @:require(flash10_1) extern class CurrencyFormatter { var actualLocaleIDName(default,null) : String; var currencyISOCode(default,null) : String; var currencySymbol(default,null) : String; var decimalSeparator : String; var digitsType : UInt; var fractionalDigits : Int; var groupingPattern : String; var groupingSeparator : String; var lastOperationStatus(default,null) : LastOperationStatus; var leadingZero : Bool; var negativeCurrencyFormat : UInt; var negativeSymbol : String; var positiveCurrencyFormat : UInt; var requestedLocaleIDName(default,null) : String; var trailingZeros : Bool; var useGrouping : Bool; function new(requestedLocaleIDName : String) : Void; function format(value : Float, withCurrencySymbol : Bool = false) : String; function formattingWithCurrencySymbolIsSafe(requestedISOCode : String) : Bool; function parse(inputString : String) : CurrencyParseResult; function setCurrency(currencyISOCode : String, currencySymbol : String) : Void; static function getAvailableLocaleIDNames() : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/globalization/CurrencyParseResult.hx0000664000175000017500000000033412607337712025376 0ustar andyandy00000000000000package flash.globalization; @:final extern class CurrencyParseResult { var currencyString(default,null) : String; var value(default,null) : Float; function new(value : Float = 0./*NaN*/, ?symbol : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/globalization/DateTimeFormatter.hx0000664000175000017500000000204712607337712024775 0ustar andyandy00000000000000package flash.globalization; @:final @:require(flash10_1) extern class DateTimeFormatter { var actualLocaleIDName(default,null) : String; var lastOperationStatus(default,null) : LastOperationStatus; var requestedLocaleIDName(default,null) : String; function new(requestedLocaleIDName : String, ?dateStyle : DateTimeStyle, ?timeStyle : DateTimeStyle) : Void; function format(dateTime : Date) : String; function formatUTC(dateTime : Date) : String; function getDateStyle() : DateTimeStyle; function getDateTimePattern() : DateTimeStyle; function getFirstWeekday() : Int; function getMonthNames(?nameStyle : DateTimeNameStyle, ?context : DateTimeNameContext) : flash.Vector; function getTimeStyle() : DateTimeStyle; function getWeekdayNames(?nameStyle : DateTimeNameStyle, ?context : DateTimeNameContext) : flash.Vector; function setDateTimePattern(pattern : String) : Void; function setDateTimeStyles(dateStyle : DateTimeStyle, timeStyle : DateTimeStyle) : Void; static function getAvailableLocaleIDNames() : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/globalization/DateTimeNameContext.hx0000664000175000017500000000015312607337712025253 0ustar andyandy00000000000000package flash.globalization; @:fakeEnum(String) extern enum DateTimeNameContext { FORMAT; STANDALONE; } haxe_3.2.1+dfsg.orig/std/flash/globalization/DateTimeNameStyle.hx0000664000175000017500000000020312607337712024723 0ustar andyandy00000000000000package flash.globalization; @:fakeEnum(String) extern enum DateTimeNameStyle { FULL; LONG_ABBREVIATION; SHORT_ABBREVIATION; } haxe_3.2.1+dfsg.orig/std/flash/globalization/DateTimeStyle.hx0000664000175000017500000000016712607337712024133 0ustar andyandy00000000000000package flash.globalization; @:fakeEnum(String) extern enum DateTimeStyle { CUSTOM; LONG; MEDIUM; NONE; SHORT; } haxe_3.2.1+dfsg.orig/std/flash/globalization/LastOperationStatus.hx0000664000175000017500000000071012607337712025400 0ustar andyandy00000000000000package flash.globalization; @:fakeEnum(String) extern enum LastOperationStatus { BUFFER_OVERFLOW_ERROR; ERROR_CODE_UNKNOWN; ILLEGAL_ARGUMENT_ERROR; INDEX_OUT_OF_BOUNDS_ERROR; INVALID_ATTR_VALUE; INVALID_CHAR_FOUND; MEMORY_ALLOCATION_ERROR; NO_ERROR; NUMBER_OVERFLOW_ERROR; PARSE_ERROR; PATTERN_SYNTAX_ERROR; PLATFORM_API_FAILED; TRUNCATED_CHAR_FOUND; UNEXPECTED_TOKEN; UNSUPPORTED_ERROR; USING_DEFAULT_WARNING; USING_FALLBACK_WARNING; } haxe_3.2.1+dfsg.orig/std/flash/globalization/LocaleID.hx0000664000175000017500000000114012607337712023022 0ustar andyandy00000000000000package flash.globalization; @:final @:require(flash10_1) extern class LocaleID { var lastOperationStatus(default,null) : LastOperationStatus; var name(default,null) : String; function new(name : String) : Void; function getKeysAndValues() : flash.utils.Object; function getLanguage() : String; function getRegion() : String; function getScript() : String; function getVariant() : String; function isRightToLeft() : Bool; static var DEFAULT : String; static function determinePreferredLocales(want : flash.Vector, have : flash.Vector, ?keyword : String) : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/globalization/NationalDigitsType.hx0000664000175000017500000000064712607337712025174 0ustar andyandy00000000000000package flash.globalization; @:fakeEnum(UInt) extern enum NationalDigitsType { ARABIC_INDIC; BALINESE; BENGALI; CHAM; DEVANAGARI; EUROPEAN; EXTENDED_ARABIC_INDIC; FULL_WIDTH; GUJARATI; GURMUKHI; KANNADA; KAYAH_LI; KHMER; LAO; LEPCHA; LIMBU; MALAYALAM; MONGOLIAN; MYANMAR; MYANMAR_SHAN; NEW_TAI_LUE; NKO; OL_CHIKI; ORIYA; OSMANYA; SAURASHTRA; SUNDANESE; TAMIL; TELUGU; THAI; TIBETAN; VAI; } haxe_3.2.1+dfsg.orig/std/flash/globalization/NumberFormatter.hx0000664000175000017500000000164012607337712024527 0ustar andyandy00000000000000package flash.globalization; @:final @:require(flash10_1) extern class NumberFormatter { var actualLocaleIDName(default,null) : String; var decimalSeparator : String; var digitsType : NationalDigitsType; var fractionalDigits : Int; var groupingPattern : String; var groupingSeparator : String; var lastOperationStatus(default,null) : LastOperationStatus; var leadingZero : Bool; var negativeNumberFormat : UInt; var negativeSymbol : String; var requestedLocaleIDName(default,null) : String; var trailingZeros : Bool; var useGrouping : Bool; function new(requestedLocaleIDName : String) : Void; function formatInt(value : Int) : String; function formatNumber(value : Float) : String; function formatUint(value : UInt) : String; function parse(parseString : String) : NumberParseResult; function parseNumber(parseString : String) : Float; static function getAvailableLocaleIDNames() : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/globalization/NumberParseResult.hx0000664000175000017500000000046512607337712025041 0ustar andyandy00000000000000package flash.globalization; @:final @:require(flash10_1) extern class NumberParseResult { var endIndex(default,null) : Int; var startIndex(default,null) : Int; var value(default,null) : Float; function new(value : Float = 0./*NaN*/, startIndex : Int = 2147483647, endIndex : Int = 2147483647) : Void; } haxe_3.2.1+dfsg.orig/std/flash/globalization/StringTools.hx0000664000175000017500000000071412607337712023703 0ustar andyandy00000000000000package flash.globalization; @:final @:require(flash10_1) extern class StringTools { var actualLocaleIDName(default,null) : String; var lastOperationStatus(default,null) : LastOperationStatus; var requestedLocaleIDName(default,null) : String; function new(requestedLocaleIDName : String) : Void; function toLowerCase(s : String) : String; function toUpperCase(s : String) : String; static function getAvailableLocaleIDNames() : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/media/AVABRParameters.hx0000664000175000017500000000062112607337712022511 0ustar andyandy00000000000000package flash.media; extern class AVABRParameters { var maxBitsPerSecond : Int; var minBitsPerSecond : Int; var policy : String; var startBitsPerSecond : Int; function new(init_policy : String, init_startBitsPerSecond : UInt, init_minBitsPerSecond : UInt, init_maxBitsPerSecond : UInt) : Void; static var AGGRESSIVE : String; static var CONSERVATIVE : String; static var MODERATE : String; } haxe_3.2.1+dfsg.orig/std/flash/media/AVABRProfileInfo.hx0000664000175000017500000000036612607337712022630 0ustar andyandy00000000000000package flash.media; extern class AVABRProfileInfo { var bitsPerSecond(default,null) : Int; var height(default,null) : Int; var width(default,null) : Int; function new(init_bitsPerSecond : Int, init_width : Int, init_height : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVCaptionStyle.hx0000664000175000017500000000316212607337712022502 0ustar andyandy00000000000000package flash.media; extern class AVCaptionStyle { var backgroundColor : String; var backgroundOpacity : String; var bottomInset : String; var edgeColor : String; var fillColor : String; var fillOpacity : String; var font : String; var fontColor : String; var fontEdge : String; var fontOpacity : String; var size : String; function new() : Void; static var BLACK : String; static var BLUE : String; static var BRIGHT_BLUE : String; static var BRIGHT_CYAN : String; static var BRIGHT_GREEN : String; static var BRIGHT_MAGENTA : String; static var BRIGHT_RED : String; static var BRIGHT_WHITE : String; static var BRIGHT_YELLOW : String; static var CASUAL : String; static var CURSIVE : String; static var CYAN : String; static var DARK_BLUE : String; static var DARK_CYAN : String; static var DARK_GREEN : String; static var DARK_MAGENTA : String; static var DARK_RED : String; static var DARK_YELLOW : String; static var DEFAULT : String; static var DEPRESSED : String; static var GRAY : String; static var GREEN : String; static var LARGE : String; static var LEFT_DROP_SHADOW : String; static var MAGENTA : String; static var MEDIUM : String; static var MONOSPACED_WITHOUT_SERIFS : String; static var MONOSPACE_WITH_SERIFS : String; static var NONE : String; static var PROPORTIONAL_WITHOUT_SERIFS : String; static var PROPORTIONAL_WITH_SERIFS : String; static var RAISED : String; static var RED : String; static var RIGHT_DROP_SHADOW : String; static var SMALL : String; static var SMALL_CAPITALS : String; static var UNIFORM : String; static var WHITE : String; static var YELLOW : String; } haxe_3.2.1+dfsg.orig/std/flash/media/AVCuePoint.hx0000664000175000017500000000035012607337712021606 0ustar andyandy00000000000000package flash.media; extern class AVCuePoint { var dictionary(default,null) : flash.utils.Dictionary; var localTime(default,null) : Float; function new(init_dictionary : flash.utils.Dictionary, init_localTime : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVInsertionResult.hx0000664000175000017500000000037012607337712023233 0ustar andyandy00000000000000package flash.media; extern class AVInsertionResult extends AVResult { var insertedBeforeReadHead(default,null) : Bool; var periodIndex(default,null) : Int; function new(result : Int, periodIndex : Int, insertedBeforeReadHead : Bool) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVNetworkingParams.hx0000664000175000017500000000050512607337712023355 0ustar andyandy00000000000000package flash.media; extern class AVNetworkingParams { var forceNativeNetworking : Bool; var readSetCookieHeader : Bool; var useCookieHeaderForAllRequests : Bool; function new(init_forceNativeNetworking : Bool = false, init_readSetCookieHeader : Bool = true, init_useCookieHeaderForAllRequests : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVPeriodInfo.hx0000664000175000017500000000144612607337712022125 0ustar andyandy00000000000000package flash.media; extern class AVPeriodInfo { var duration(default,null) : Float; var firstCuePointIndex(default,null) : Int; var firstSubscribedTagIndex(default,null) : Int; var lastCuePointIndex(default,null) : Int; var lastSubscribedTagIndex(default,null) : Int; var localStartTime(default,null) : Float; var supportsTrickPlay(default,null) : Bool; var targetDuration(default,null) : Float; var userData(default,null) : Int; var virtualStartTime(default,null) : Float; function new(init_localStartTime : Float, init_virtualStartTime : Float, init_duration : Float, init_firstCuePointIndex : Int, init_lastCuePointIndex : Int, init_firstSubscribedTagIndex : Int, init_lastSubscribedTagIndex : Int, init_userData : Int, init_supportsTrickPlay : Bool, init_targetDuration : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVPlayState.hx0000664000175000017500000000057412607337712021776 0ustar andyandy00000000000000package flash.media; extern class AVPlayState { var state(default,null) : Int; function new(state : UInt) : Void; static var BUFFERING : Int; static var EOF : Int; static var PAUSED : Int; static var PLAYING : Int; static var READY : Int; static var SUSPENDED : Int; static var TRICK_PLAY : Int; static var UNINITIALIZED : Int; static var UNRECOVERABLE_ERROR : Int; } haxe_3.2.1+dfsg.orig/std/flash/media/AVResult.hx0000664000175000017500000000765512607337712021355 0ustar andyandy00000000000000package flash.media; extern class AVResult { var result(default,null) : Int; function new(inResult : Int) : Void; static var ASYNC_OPERATION_IN_PROGRESS : Int; static var AUDIO_ONLY_STREAM_END : Int; static var AUDIO_ONLY_STREAM_START : Int; static var AUDIO_START_ERROR : Int; static var BAD_MANIFEST_SIGNATURE : Int; static var BAD_MEDIASAMPLE_FOUND : Int; static var BAD_MEDIA_INTERLEAVING : Int; static var CALLED_FROM_WRONG_THREAD : Int; static var CANNOT_ERASE_TIMELINE : Int; static var CANNOT_FAIL_OVER : Int; static var CANNOT_HANDLE_MAIN_MANIFEST_UPDATE : Int; static var CANNOT_LOAD_PLAY_LIST : Int; static var CANNOT_SPLIT_TIMELINE : Int; static var CODEC_NOT_SUPPORTED : Int; static var COMPONENT_CREATION_FAILURE : Int; static var CONTAINER_NOT_SUPPORTED : Int; static var CONTENT_LENGTH_MISMATCH : Int; static var CRYPTO_ALGORITHM_NOT_SUPPORTED : Int; static var CRYPTO_ERROR_BAD_CERTIFICATE : Int; static var CRYPTO_ERROR_BAD_PARAMETER : Int; static var CRYPTO_ERROR_BUFFER_TOO_SMALL : Int; static var CRYPTO_ERROR_CORRUPTED_DATA : Int; static var CRYPTO_ERROR_DIGEST_FINISH : Int; static var CRYPTO_ERROR_DIGEST_UPDATE : Int; static var CRYPTO_ERROR_UNKNOWN : Int; static var CURRENT_PERIOD_EXPIRED : Int; static var DECODER_FAILED : Int; static var DEVICE_OPEN_ERROR : Int; static var DID_NOT_GET_NEXT_FRAGMENT : Int; static var DRM_INIT_ERROR : Int; static var DRM_NOT_AVAILABLE : Int; static var END_OF_PERIOD : Int; static var EOF : Int; static var FILE_NOT_FOUND : Int; static var FILE_OPEN_ERROR : Int; static var FILE_READ_ERROR : Int; static var FILE_STRUCTURE_INVALID : Int; static var FILE_WRITE_ERROR : Int; static var FRAGMENT_READ_ERROR : Int; static var GENERIC_ERROR : Int; static var HTTP_TIME_OUT : Int; static var ID3_PARSE_ERROR : Int; static var INCOMPATIBLE_RENDER_MODE : Int; static var INCOMPATIBLE_VERSION : Int; static var INTERNAL_ERROR : Int; static var INVALID_KEY : Int; static var INVALID_OPERATION : Int; static var INVALID_PARAMETER : Int; static var INVALID_REPLACE_DURATION : Int; static var INVALID_SEEK_TIME : Int; static var INVALID_WITH_AUDIO_ONLY_FILE : Int; static var IRRECOVERABLE_ERROR : Int; static var KEY_NOT_FOUND : Int; static var KEY_SERVER_NOT_FOUND : Int; static var LISTENER_NOT_FOUND : Int; static var LIVE_HOLD : Int; static var LIVE_WINDOW_MOVED_BACKWARD : Int; static var LOST_CONNECTION_RECOVERABLE : Int; static var MANIFEST_FILE_UNEXPECTEDLY_CHANGED : Int; static var NETWORK_DOWN : Int; static var NETWORK_ERROR : Int; static var NETWORK_UNAVAILABLE : Int; static var NOT_IMPLEMENTED : Int; static var NO_AUDIO_SINK : Int; static var NO_FIXED_SIZE : Int; static var NO_TIMELINE : Int; static var NO_USEABLE_BITRATE_PROFILE : Int; static var NULL_OPERATION : Int; static var ONLY_ALLOWED_IN_PAUSED_STATE : Int; static var OPERATION_ABORTED : Int; static var OUT_OF_MEMORY : Int; static var OVERFLOW : Int; static var PARSE_ERROR : Int; static var PARTIAL_REPLACEMENT : Int; static var PERIOD_HOLD : Int; static var PERIOD_NOT_LOADED : Int; static var PLAYBACK_NOT_ENABLED : Int; static var POSTROLL_WITH_LIVE_NOT_ALLOWED : Int; static var PREVIOUS_STEP_SEEK_IN_PROGRESS : Int; static var PROTOCOL_NOT_SUPPORTED : Int; static var RANGE_ERROR : Int; static var RANGE_SPANS_READHEAD : Int; static var RENDITION_M3U8_ERROR : Int; static var REPLACEMENT_FAILED : Int; static var RESOURCE_NOT_SPECIFIED : Int; static var SECURITY_ERROR : Int; static var SEEK_FAILED : Int; static var SEGMENT_SKIPPED_ON_FAILURE : Int; static var SIZE_UNKNOWN : Int; static var SPS_PPS_FOUND_OUTSIDE_AVCC : Int; static var SUCCESS : Int; static var SWITCH_TO_ASYMMETRIC_PROFILE : Int; static var TIMELINE_TOO_SHORT : Int; static var UNDERFLOW : Int; static var UNSUPPORTED_CONFIGURATION : Int; static var UNSUPPORTED_HLS_VERSION : Int; static var UNSUPPORTED_OPERATION : Int; static var VIDEO_PROFILE_NOT_SUPPORTED : Int; static var WAITING_FOR_INIT : Int; } haxe_3.2.1+dfsg.orig/std/flash/media/AVSegmentedSource.hx0000664000175000017500000000572512607337712023167 0ustar andyandy00000000000000package flash.media; extern class AVSegmentedSource extends AVSource { var cookieHeader(null,default) : String; var masterUpdateInterval(null,default) : Int; var networkingParams : AVNetworkingParams; var useRedirectedUrl(null,default) : Bool; function new() : Void; function clearPauseAtPeriodEnd(periodIndex : Int) : AVResult; function getABRProfileCount(periodIndex : Int) : Int; function getABRProfileInfoAtIndex(periodIndex : Int, abrProfileIndex : Int) : AVABRProfileInfo; function getBackgroundPeriodInfo(periodIndex : Int) : AVPeriodInfo; function getBackgroundTimeline() : AVTimeline; function getCuePoint(periodIndex : Int, cuePointIndex : Int) : AVCuePoint; function getPerceivedBandwidth() : UInt; function getPeriodInfo(periodIndex : Int) : AVPeriodInfo; function getSubscribedTag(periodIndex : Int, tagDataIndex : Int) : AVTagData; function getSubscribedTagForBackgroundManifest(periodIndex : Int, tagDataIndex : Int) : AVTagData; function getTimeline() : AVTimeline; function getTrackCount(periodIndex : Int, payloadType : String) : Int; function getTrackInfo(periodIndex : Int, payloadType : String, trackIndex : Int) : AVTrackInfo; function insertByLocalTime(periodIndex : Int, insertionTime : Float, handle : Int, userData : Int = 0, replaceDuration : Float = 0) : AVInsertionResult; function insertByVirtualTime(insertionTime : Float, handle : Int, userData : Int = 0, replaceDuration : Float = 0) : AVInsertionResult; function load(url : String, ?containerType : String, userData : Int = 0) : AVResult; function loadManifest(uri : String, userData : Int = 0, ?containerType : String) : AVResult; function loadWithBackgroundManifest(url : String, containerType : String, userData : Int, backgroundManifest : String) : AVResult; function releaseManifest(handle : Int) : AVResult; function removeByLocalTime(periodIndex : Int, timeStart : Float, timeEnd : Float, replaceWithMainMedia : Bool) : AVResult; function removeByVirtualTime(virtualTimeStart : Float, virtualTimeEnd : Float) : AVResult; function selectTrack(periodIndex : Int, payloadType : String, trackIndex : Int) : AVResult; function selectTrackString(periodIndex : Int, payloadType : String, trackString : String) : AVResult; function setABRParameters(params : AVABRParameters) : AVResult; function setBandwidth(bitsPerSecond : Int) : AVResult; function setCuePointTags(tagArray : Array) : AVResult; function setHoldAt(time : Float) : AVResult; function setPauseAtPeriodEnd(periodIndex : Int, userData : Int = 0) : AVResult; function setSubscribedTags(tagArray : Array) : AVResult; function setSubscribedTagsForBackgroundManifest(tagArray : Array) : AVResult; static var AUDIO : String; static var AUDIO_DESCRIPTION : String; static var AUDIO_LANGUAGE : String; static var AUDIO_PID : String; static var DASH : String; static var DATA : String; static var DATA_DESCRIPTION : String; static var HLS : String; static var VIDEO : String; static var VIDEO_DESCRIPTION : String; } haxe_3.2.1+dfsg.orig/std/flash/media/AVSource.hx0000664000175000017500000000021112607337712021314 0ustar andyandy00000000000000package flash.media; extern class AVSource extends flash.events.EventDispatcher { function new() : Void; function dispose() : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVStream.hx0000664000175000017500000000266212607337712021323 0ustar andyandy00000000000000package flash.media; extern class AVStream extends flash.events.EventDispatcher { var backBufferLength(default,null) : Float; var backBufferTime(null,default) : Float; var bufferLength(default,null) : Float; var bufferTime(null,default) : Float; var captionStyle(null,default) : AVCaptionStyle; var captionsEnabled : Bool; var clientLivePoint(default,null) : Float; var currentFPS(default,null) : Float; var decoderType(default,null) : String; var droppedFrames(default,null) : Int; var frameTime(default,null) : Float; var initialBufferTime(null,default) : Float; var playState(default,null) : AVPlayState; var renderType(default,null) : String; var time(default,null) : Float; var useHardwareDecoder : Bool; var volume : Float; function new(source : AVSource) : Void; function dispose() : Void; function fastForward(rate : Float) : AVResult; function pause() : AVResult; function play() : AVResult; function resume() : Bool; function rewind(rate : Float) : AVResult; function seek(offset : Float, inBufferSeek : Bool = true) : AVResult; function seekToKeyFrame(offset : Float, inBufferSeek : Bool = true) : AVResult; function seekToLivePoint() : AVResult; function seekToLocalTime(periodIndex : Int, time : Float) : AVResult; function setPlaySpeed(speed : Float, reserved : Float) : Void; function step(frames : Int) : AVResult; static var HARDWARE : String; static var SOFTWARE : String; static var UNDEFINED : String; } haxe_3.2.1+dfsg.orig/std/flash/media/AVTagData.hx0000664000175000017500000000027312607337712021371 0ustar andyandy00000000000000package flash.media; extern class AVTagData { var data(default,null) : String; var localTime(default,null) : Float; function new(init_data : String, init_localTime : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVTimeline.hx0000664000175000017500000000073412607337712021634 0ustar andyandy00000000000000package flash.media; extern class AVTimeline { var complete(default,null) : Bool; var firstPeriodIndex(default,null) : Int; var lastPeriodIndex(default,null) : Int; var type(default,null) : String; var virtualDuration(default,null) : Float; var virtualStartTime(default,null) : Float; function new(init_type : String, init_virtualStartTime : Float, init_virtualDuration : Float, init_firstPeriodIndex : Int, init_lastPeriodIndex : Int, init_complete : Bool) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVTrackInfo.hx0000664000175000017500000000127712607337712021751 0ustar andyandy00000000000000package flash.media; extern class AVTrackInfo { var activity(default,null) : Bool; var autoSelect(default,null) : Bool; var dataTrackInfoServiceType(default,null) : String; var defaultTrack(default,null) : Bool; var description(default,null) : String; var forced(default,null) : Bool; var language(default,null) : String; var pid(default,null) : Int; function new(init_description : String, init_language : String, init_defaultTrack : Bool, init_autoSelect : Bool, init_forced : Bool, init_activity : Bool, init_dataTrackInfoServiceType : String, init_pid : Int) : Void; static var DTI_608_CAPTIONS : String; static var DTI_708_CAPTIONS : String; static var DTI_WEBVTT_CAPTIONS : String; } haxe_3.2.1+dfsg.orig/std/flash/media/AVURLLoader.hx0000664000175000017500000000031312607337712021650 0ustar andyandy00000000000000package flash.media; extern class AVURLLoader extends flash.net.URLLoader { var cookieHeader(null,default) : String; var stream : AVURLStream; function new(?request : flash.net.URLRequest) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AVURLStream.hx0000664000175000017500000000022112607337712021673 0ustar andyandy00000000000000package flash.media; extern class AVURLStream extends flash.net.URLStream { var cookieHeader(null,default) : String; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/AudioDecoder.hx0000664000175000017500000000046212607337712022164 0ustar andyandy00000000000000package flash.media; extern class AudioDecoder { function new() : Void; static var DOLBY_DIGITAL : String; static var DOLBY_DIGITAL_PLUS : String; static var DTS : String; static var DTS_EXPRESS : String; static var DTS_HD_HIGH_RESOLUTION_AUDIO : String; static var DTS_HD_MASTER_AUDIO : String; } haxe_3.2.1+dfsg.orig/std/flash/media/Camera.hx0000664000175000017500000000313312607337712021023 0ustar andyandy00000000000000package flash.media; @:final extern class Camera extends flash.events.EventDispatcher { var activityLevel(default,null) : Float; var bandwidth(default,null) : Int; var currentFPS(default,null) : Float; var fps(default,null) : Float; var height(default,null) : Int; var index(default,null) : Int; var keyFrameInterval(default,null) : Int; var loopback(default,null) : Bool; var motionLevel(default,null) : Int; var motionTimeout(default,null) : Int; var muted(default,null) : Bool; var name(default,null) : String; @:require(flash11_2) var position(default,null) : String; var quality(default,null) : Int; var width(default,null) : Int; function new() : Void; @:require(flash11_4) function copyToByteArray(rect : flash.geom.Rectangle, destination : flash.utils.ByteArray) : Void; @:require(flash11_4) function copyToVector(rect : flash.geom.Rectangle, destination : flash.Vector) : Void; @:require(flash11_4) function drawToBitmapData(destination : flash.display.BitmapData) : Void; function setCursor(value : Bool) : Void; function setKeyFrameInterval(keyFrameInterval : Int) : Void; function setLoopback(compress : Bool = false) : Void; function setMode(width : Int, height : Int, fps : Float, favorArea : Bool = true) : Void; function setMotionLevel(motionLevel : Int, timeout : Int = 2000) : Void; function setQuality(bandwidth : Int, quality : Int) : Void; @:require(flash10_1) static var isSupported(default,null) : Bool; static var names(default,null) : Array; @:require(flash10_1) static function _scanHardware() : Void; static function getCamera(?name : String) : Camera; } haxe_3.2.1+dfsg.orig/std/flash/media/H264Level.hx0000664000175000017500000000107612607337712021252 0ustar andyandy00000000000000package flash.media; extern class H264Level { function new() : Void; static var LEVEL_1 : String; static var LEVEL_1B : String; static var LEVEL_1_1 : String; static var LEVEL_1_2 : String; static var LEVEL_1_3 : String; static var LEVEL_2 : String; static var LEVEL_2_1 : String; static var LEVEL_2_2 : String; static var LEVEL_3 : String; static var LEVEL_3_1 : String; static var LEVEL_3_2 : String; static var LEVEL_4 : String; static var LEVEL_4_1 : String; static var LEVEL_4_2 : String; static var LEVEL_5 : String; static var LEVEL_5_1 : String; } haxe_3.2.1+dfsg.orig/std/flash/media/H264Profile.hx0000664000175000017500000000020512607337712021574 0ustar andyandy00000000000000package flash.media; extern class H264Profile { function new() : Void; static var BASELINE : String; static var MAIN : String; } haxe_3.2.1+dfsg.orig/std/flash/media/H264VideoStreamSettings.hx0000664000175000017500000000037712607337712024151 0ustar andyandy00000000000000package flash.media; extern class H264VideoStreamSettings extends VideoStreamSettings { var level(default,null) : String; var profile(default,null) : String; function new() : Void; function setProfileLevel(profile : String, level : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/ID3Info.hx0000664000175000017500000000037212607337712021030 0ustar andyandy00000000000000package flash.media; @:final extern class ID3Info implements Dynamic { var album : String; var artist : String; var comment : String; var genre : String; var songName : String; var track : String; var year : String; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/Microphone.hx0000664000175000017500000000232212607337712021735 0ustar andyandy00000000000000package flash.media; @:final extern class Microphone extends flash.events.EventDispatcher { var activityLevel(default,null) : Float; @:require(flash10) var codec : SoundCodec; @:require(flash10_1) var enableVAD : Bool; @:require(flash10) var encodeQuality : Int; @:require(flash10_2) var enhancedOptions : MicrophoneEnhancedOptions; @:require(flash10) var framesPerPacket : Int; var gain : Float; var index(default,null) : Int; var muted(default,null) : Bool; var name(default,null) : String; @:require(flash10_1) var noiseSuppressionLevel : Int; var rate : Int; var silenceLevel(default,null) : Float; var silenceTimeout(default,null) : Int; var soundTransform : SoundTransform; var useEchoSuppression(default,null) : Bool; function new() : Void; function setLoopBack(state : Bool = true) : Void; function setSilenceLevel(silenceLevel : Float, timeout : Int = -1) : Void; function setUseEchoSuppression(useEchoSuppression : Bool) : Void; @:require(flash10_1) static var isSupported(default,null) : Bool; static var names(default,null) : Array; @:require(flash10_2) static function getEnhancedMicrophone(index : Int = -1) : Microphone; static function getMicrophone(index : Int = -1) : Microphone; } haxe_3.2.1+dfsg.orig/std/flash/media/MicrophoneEnhancedMode.hx0000664000175000017500000000024012607337712024165 0ustar andyandy00000000000000package flash.media; @:fakeEnum(String) @:require(flash10_2) extern enum MicrophoneEnhancedMode { FULL_DUPLEX; HALF_DUPLEX; HEADSET; OFF; SPEAKER_MUTE; } haxe_3.2.1+dfsg.orig/std/flash/media/MicrophoneEnhancedOptions.hx0000664000175000017500000000040212607337712024734 0ustar andyandy00000000000000package flash.media; @:final @:require(flash10_2) extern class MicrophoneEnhancedOptions { var autoGain : Bool; var echoPath : Int; var isVoiceDetected : Int; var mode : MicrophoneEnhancedMode; var nonLinearProcessing : Bool; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/Sound.hx0000664000175000017500000000206712607337712020730 0ustar andyandy00000000000000package flash.media; extern class Sound extends flash.events.EventDispatcher { var bytesLoaded(default,null) : UInt; var bytesTotal(default,null) : Int; var id3(default,null) : ID3Info; var isBuffering(default,null) : Bool; @:require(flash10_1) var isURLInaccessible(default,null) : Bool; var length(default,null) : Float; var url(default,null) : String; function new(?stream : flash.net.URLRequest, ?context : SoundLoaderContext) : Void; function close() : Void; @:require(flash10) function extract(target : flash.utils.ByteArray, length : Float, startPosition : Float = -1) : Float; function load(stream : flash.net.URLRequest, ?context : SoundLoaderContext) : Void; @:require(flash11) function loadCompressedDataFromByteArray(bytes : flash.utils.ByteArray, bytesLength : UInt) : Void; @:require(flash11) function loadPCMFromByteArray(bytes : flash.utils.ByteArray, samples : UInt, ?format : String, stereo : Bool = true, sampleRate : Float = 44100) : Void; function play(startTime : Float = 0, loops : Int = 0, ?sndTransform : SoundTransform) : SoundChannel; } haxe_3.2.1+dfsg.orig/std/flash/media/SoundChannel.hx0000664000175000017500000000045012607337712022213 0ustar andyandy00000000000000package flash.media; @:final extern class SoundChannel extends flash.events.EventDispatcher { var leftPeak(default,null) : Float; var position(default,null) : Float; var rightPeak(default,null) : Float; var soundTransform : SoundTransform; function new() : Void; function stop() : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/SoundCodec.hx0000664000175000017500000000014712607337712021663 0ustar andyandy00000000000000package flash.media; @:fakeEnum(String) extern enum SoundCodec { NELLYMOSER; PCMA; PCMU; SPEEX; } haxe_3.2.1+dfsg.orig/std/flash/media/SoundLoaderContext.hx0000664000175000017500000000030112607337712023411 0ustar andyandy00000000000000package flash.media; extern class SoundLoaderContext { var bufferTime : Float; var checkPolicyFile : Bool; function new(bufferTime : Float = 1000, checkPolicyFile : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/SoundMixer.hx0000664000175000017500000000064412607337712021734 0ustar andyandy00000000000000package flash.media; extern class SoundMixer { static var audioPlaybackMode : String; static var bufferTime : Int; static var soundTransform : SoundTransform; static var useSpeakerphoneForVoice : Bool; static function areSoundsInaccessible() : Bool; static function computeSpectrum(outputArray : flash.utils.ByteArray, FFTMode : Bool = false, stretchFactor : Int = 0) : Void; static function stopAll() : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/SoundTransform.hx0000664000175000017500000000041112607337712022613 0ustar andyandy00000000000000package flash.media; @:final extern class SoundTransform { var leftToLeft : Float; var leftToRight : Float; var pan : Float; var rightToLeft : Float; var rightToRight : Float; var volume : Float; function new(vol : Float = 1, panning : Float = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/StageVideo.hx0000664000175000017500000000111712607337712021665 0ustar andyandy00000000000000package flash.media; @:require(flash10_2) extern class StageVideo extends flash.events.EventDispatcher { var colorSpaces(default,null) : flash.Vector; var depth : Int; var pan : flash.geom.Point; var videoHeight(default,null) : Int; var videoWidth(default,null) : Int; var viewPort : flash.geom.Rectangle; var zoom : flash.geom.Point; function new() : Void; @:require(flash11_7) function attachAVStream(avStream : AVStream) : Void; @:require(flash11_4) function attachCamera(theCamera : Camera) : Void; function attachNetStream(netStream : flash.net.NetStream) : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/StageVideoAvailability.hx0000664000175000017500000000023012607337712024213 0ustar andyandy00000000000000package flash.media; extern class StageVideoAvailability { function new() : Void; static var AVAILABLE : String; static var UNAVAILABLE : String; } haxe_3.2.1+dfsg.orig/std/flash/media/StageVideoAvailabilityReason.hx0000664000175000017500000000041712607337712025372 0ustar andyandy00000000000000package flash.media; extern class StageVideoAvailabilityReason { function new() : Void; static var DRIVER_TOO_OLD : String; static var NO_ERROR : String; static var UNAVAILABLE : String; static var USER_DISABLED : String; static var WMODE_INCOMPATIBLE : String; } haxe_3.2.1+dfsg.orig/std/flash/media/Video.hx0000664000175000017500000000062412607337712020703 0ustar andyandy00000000000000package flash.media; extern class Video extends flash.display.DisplayObject { var deblocking : Int; var smoothing : Bool; var videoHeight(default,null) : Int; var videoWidth(default,null) : Int; function new(width : Int = 320, height : Int = 240) : Void; function attachCamera(camera : Camera) : Void; function attachNetStream(netStream : flash.net.NetStream) : Void; function clear() : Void; } haxe_3.2.1+dfsg.orig/std/flash/media/VideoCodec.hx0000664000175000017500000000024112607337712021634 0ustar andyandy00000000000000package flash.media; extern class VideoCodec { function new() : Void; static var H264AVC : String; static var SORENSON : String; static var VP6 : String; } haxe_3.2.1+dfsg.orig/std/flash/media/VideoStatus.hx0000664000175000017500000000025612607337712022110 0ustar andyandy00000000000000package flash.media; extern class VideoStatus { function new() : Void; static var ACCELERATED : String; static var SOFTWARE : String; static var UNAVAILABLE : String; } haxe_3.2.1+dfsg.orig/std/flash/media/VideoStreamSettings.hx0000664000175000017500000000100512607337712023572 0ustar andyandy00000000000000package flash.media; extern class VideoStreamSettings { var bandwidth(default,null) : Int; var codec(default,null) : String; var fps(default,null) : Float; var height(default,null) : Int; var keyFrameInterval(default,null) : Int; var quality(default,null) : Int; var width(default,null) : Int; function new() : Void; function setKeyFrameInterval(keyFrameInterval : Int) : Void; function setMode(width : Int, height : Int, fps : Float) : Void; function setQuality(bandwidth : Int, quality : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/DynamicPropertyOutput.hx0000664000175000017500000000027412607337712023717 0ustar andyandy00000000000000package flash.net; extern class DynamicPropertyOutput implements IDynamicPropertyOutput { function new() : Void; function writeDynamicProperty(name : String, value : Dynamic) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/FileFilter.hx0000664000175000017500000000032612607337712021370 0ustar andyandy00000000000000package flash.net; @:final extern class FileFilter { var description : String; var extension : String; var macType : String; function new(description : String, extension : String, ?macType : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/FileReference.hx0000664000175000017500000000143512607337712022043 0ustar andyandy00000000000000package flash.net; extern class FileReference extends flash.events.EventDispatcher { var creationDate(default,null) : Date; var creator(default,null) : String; @:require(flash10) var data(default,null) : flash.utils.ByteArray; var modificationDate(default,null) : Date; var name(default,null) : String; var size(default,null) : Float; var type(default,null) : String; function new() : Void; function browse(?typeFilter : Array) : Bool; function cancel() : Void; function download(request : URLRequest, ?defaultFileName : String) : Void; @:require(flash10) function load() : Void; @:require(flash10) function save(data : Dynamic, ?defaultFileName : String) : Void; function upload(request : URLRequest, ?uploadDataFieldName : String, testUpload : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/FileReferenceList.hx0000664000175000017500000000034212607337712022673 0ustar andyandy00000000000000package flash.net; extern class FileReferenceList extends flash.events.EventDispatcher { var fileList(default,null) : Array; function new() : Void; function browse(?typeFilter : Array) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/net/GroupSpecifier.hx0000664000175000017500000000235112607337712022271 0ustar andyandy00000000000000package flash.net; @:require(flash10_1) extern class GroupSpecifier { var ipMulticastMemberUpdatesEnabled : Bool; var minGroupspecVersion : Int; var multicastEnabled : Bool; var objectReplicationEnabled : Bool; var peerToPeerDisabled : Bool; var postingEnabled : Bool; var routingEnabled : Bool; var serverChannelEnabled : Bool; function new(name : String) : Void; function addBootstrapPeer(peerID : String) : Void; function addIPMulticastAddress(address : String, ?port : Dynamic, ?source : String) : Void; function authorizations() : String; function groupspecWithAuthorizations() : String; function groupspecWithoutAuthorizations() : String; function makeUnique() : Void; function setPostingPassword(?password : String, ?salt : String) : Void; function setPublishPassword(?password : String, ?salt : String) : Void; function toString() : String; static var maxSupportedGroupspecVersion(default,null) : Int; static function encodeBootstrapPeerIDSpec(peerID : String) : String; static function encodeIPMulticastAddressSpec(address : String, ?port : Dynamic, ?source : String) : String; static function encodePostingAuthorization(password : String) : String; static function encodePublishAuthorization(password : String) : String; } haxe_3.2.1+dfsg.orig/std/flash/net/IDynamicPropertyOutput.hx0000664000175000017500000000020712607337712024024 0ustar andyandy00000000000000package flash.net; extern interface IDynamicPropertyOutput { function writeDynamicProperty(name : String, value : Dynamic) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/IDynamicPropertyWriter.hx0000664000175000017500000000024412607337712024001 0ustar andyandy00000000000000package flash.net; extern interface IDynamicPropertyWriter { function writeDynamicProperties(obj : flash.utils.Object, output : IDynamicPropertyOutput) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/LocalConnection.hx0000664000175000017500000000132312607337712022413 0ustar andyandy00000000000000package flash.net; extern class LocalConnection extends flash.events.EventDispatcher { var client : Dynamic; var domain(default,null) : String; @:require(flash10_1) var isPerUser : Bool; function new() : Void; function allowDomain(?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; function allowInsecureDomain(?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; function close() : Void; function connect(connectionName : String) : Void; function send(connectionName : String, methodName : String, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; @:require(flash10_1) static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/net/NetConnection.hx0000664000175000017500000000224312607337712022111 0ustar andyandy00000000000000package flash.net; extern class NetConnection extends flash.events.EventDispatcher { var client : Dynamic; var connected(default,null) : Bool; var connectedProxyType(default,null) : String; @:require(flash10) var farID(default,null) : String; @:require(flash10) var farNonce(default,null) : String; @:require(flash10) var maxPeerConnections : UInt; @:require(flash10) var nearID(default,null) : String; @:require(flash10) var nearNonce(default,null) : String; var objectEncoding : UInt; @:require(flash10) var protocol(default,null) : String; var proxyType : String; @:require(flash10) var unconnectedPeerStreams(default,null) : Array; var uri(default,null) : String; var usingTLS(default,null) : Bool; function new() : Void; function addHeader(operation : String, mustUnderstand : Bool = false, ?param : flash.utils.Object) : Void; function call(command : String, responder : Responder, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; function close() : Void; function connect(command : String, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; static var defaultObjectEncoding : UInt; } haxe_3.2.1+dfsg.orig/std/flash/net/NetGroup.hx0000664000175000017500000000253312607337712021110 0ustar andyandy00000000000000package flash.net; @:require(flash10_1) extern class NetGroup extends flash.events.EventDispatcher { var estimatedMemberCount(default,null) : Float; var info(default,null) : NetGroupInfo; var localCoverageFrom(default,null) : String; var localCoverageTo(default,null) : String; var neighborCount(default,null) : Float; var receiveMode : String; var replicationStrategy : String; function new(connection : NetConnection, groupspec : String) : Void; function addHaveObjects(startIndex : Float, endIndex : Float) : Void; function addMemberHint(peerID : String) : Bool; function addNeighbor(peerID : String) : Bool; function addWantObjects(startIndex : Float, endIndex : Float) : Void; function close() : Void; function convertPeerIDToGroupAddress(peerID : String) : String; function denyRequestedObject(requestID : Int) : Void; function post(message : flash.utils.Object) : String; function removeHaveObjects(startIndex : Float, endIndex : Float) : Void; function removeWantObjects(startIndex : Float, endIndex : Float) : Void; function sendToAllNeighbors(message : flash.utils.Object) : String; function sendToNearest(message : flash.utils.Object, groupAddress : String) : String; function sendToNeighbor(message : flash.utils.Object, sendMode : String) : String; function writeRequestedObject(requestID : Int, object : flash.utils.Object) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/NetGroupInfo.hx0000664000175000017500000000167012607337712021725 0ustar andyandy00000000000000package flash.net; @:final @:require(flash10_1) extern class NetGroupInfo { var objectReplicationReceiveBytesPerSecond(default,null) : Float; var objectReplicationSendBytesPerSecond(default,null) : Float; var postingReceiveControlBytesPerSecond(default,null) : Float; var postingReceiveDataBytesPerSecond(default,null) : Float; var postingSendControlBytesPerSecond(default,null) : Float; var postingSendDataBytesPerSecond(default,null) : Float; var routingReceiveBytesPerSecond(default,null) : Float; var routingSendBytesPerSecond(default,null) : Float; function new(postingSendDataBytesPerSecond : Float, postingSendControlBytesPerSecond : Float, postingReceiveDataBytesPerSecond : Float, postingReceiveControlBytesPerSecond : Float, routingSendBytesPerSecond : Float, routingReceiveBytesPerSecond : Float, objectReplicationSendBytesPerSecond : Float, objectReplicationReceiveBytesPerSecond : Float) : Void; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/net/NetGroupReceiveMode.hx0000664000175000017500000000021312607337712023211 0ustar andyandy00000000000000package flash.net; extern class NetGroupReceiveMode { function new() : Void; static var EXACT : String; static var NEAREST : String; } haxe_3.2.1+dfsg.orig/std/flash/net/NetGroupReplicationStrategy.hx0000664000175000017500000000023712607337712025024 0ustar andyandy00000000000000package flash.net; extern class NetGroupReplicationStrategy { function new() : Void; static var LOWEST_FIRST : String; static var RAREST_FIRST : String; } haxe_3.2.1+dfsg.orig/std/flash/net/NetGroupSendMode.hx0000664000175000017500000000023212607337712022521 0ustar andyandy00000000000000package flash.net; extern class NetGroupSendMode { function new() : Void; static var NEXT_DECREASING : String; static var NEXT_INCREASING : String; } haxe_3.2.1+dfsg.orig/std/flash/net/NetGroupSendResult.hx0000664000175000017500000000024612607337712023120 0ustar andyandy00000000000000package flash.net; extern class NetGroupSendResult { function new() : Void; static var ERROR : String; static var NO_ROUTE : String; static var SENT : String; } haxe_3.2.1+dfsg.orig/std/flash/net/NetMonitor.hx0000664000175000017500000000026312607337712021441 0ustar andyandy00000000000000package flash.net; @:require(flash11) extern class NetMonitor extends flash.events.EventDispatcher { function new() : Void; function listStreams() : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/net/NetStream.hx0000664000175000017500000000665212607337712021255 0ustar andyandy00000000000000package flash.net; extern class NetStream extends flash.events.EventDispatcher { var audioCodec(default,null) : UInt; @:require(flash10_1) var audioReliable : Bool; @:require(flash10_1) var audioSampleAccess : Bool; @:require(flash10_1) var backBufferLength(default,null) : Float; @:require(flash10_1) var backBufferTime : Float; var bufferLength(default,null) : Float; var bufferTime : Float; @:require(flash10_1) var bufferTimeMax : Float; var bytesLoaded(default,null) : UInt; var bytesTotal(default,null) : UInt; var checkPolicyFile : Bool; var client : Dynamic; var currentFPS(default,null) : Float; @:require(flash10_1) var dataReliable : Bool; var decodedFrames(default,null) : UInt; @:require(flash10) var farID(default,null) : String; @:require(flash10) var farNonce(default,null) : String; @:require(flash10_1) var inBufferSeek : Bool; @:require(flash10) var info(default,null) : NetStreamInfo; var liveDelay(default,null) : Float; @:require(flash10) var maxPauseBufferTime : Float; @:require(flash10_1) var multicastAvailabilitySendToAll : Bool; @:require(flash10_1) var multicastAvailabilityUpdatePeriod : Float; @:require(flash10_1) var multicastFetchPeriod : Float; @:require(flash10_1) var multicastInfo(default,null) : NetStreamMulticastInfo; @:require(flash10_1) var multicastPushNeighborLimit : Float; @:require(flash10_1) var multicastRelayMarginDuration : Float; @:require(flash10_1) var multicastWindowDuration : Float; @:require(flash10) var nearNonce(default,null) : String; var objectEncoding(default,null) : UInt; @:require(flash10) var peerStreams(default,null) : Array; var soundTransform : flash.media.SoundTransform; var time(default,null) : Float; @:require(flash11) var useHardwareDecoder : Bool; @:require(flash11_3) var useJitterBuffer : Bool; var videoCodec(default,null) : UInt; @:require(flash10_1) var videoReliable : Bool; @:require(flash10_1) var videoSampleAccess : Bool; @:require(flash11) var videoStreamSettings : flash.media.VideoStreamSettings; function new(connection : NetConnection, ?peerID : String) : Void; @:require(flash10_1) function appendBytes(bytes : flash.utils.ByteArray) : Void; @:require(flash10_1) function appendBytesAction(netStreamAppendBytesAction : String) : Void; @:require(flash10_1) function attach(connection : NetConnection) : Void; function attachAudio(microphone : flash.media.Microphone) : Void; function attachCamera(theCamera : flash.media.Camera, snapshotMilliseconds : Int = -1) : Void; function close() : Void; @:require(flash11_2) function dispose() : Void; @:require(flash10) function onPeerConnect(subscriber : NetStream) : Bool; function pause() : Void; function play(?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; @:require(flash10) function play2(param : NetStreamPlayOptions) : Void; function publish(?name : String, ?type : String) : Void; function receiveAudio(flag : Bool) : Void; function receiveVideo(flag : Bool) : Void; function receiveVideoFPS(FPS : Float) : Void; function resume() : Void; function seek(offset : Float) : Void; function send(handlerName : String, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; @:require(flash10_1) function step(frames : Int) : Void; function togglePause() : Void; @:require(flash10) static var CONNECT_TO_FMS : String; @:require(flash10) static var DIRECT_CONNECTIONS : String; static function resetDRMVouchers() : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/NetStreamAppendBytesAction.hx0000664000175000017500000000027612607337712024546 0ustar andyandy00000000000000package flash.net; extern class NetStreamAppendBytesAction { function new() : Void; static var END_SEQUENCE : String; static var RESET_BEGIN : String; static var RESET_SEEK : String; } haxe_3.2.1+dfsg.orig/std/flash/net/NetStreamInfo.hx0000664000175000017500000000335512607337712022066 0ustar andyandy00000000000000package flash.net; @:final extern class NetStreamInfo { var SRTT(default,null) : Float; var audioBufferByteLength(default,null) : Float; var audioBufferLength(default,null) : Float; var audioByteCount(default,null) : Float; var audioBytesPerSecond(default,null) : Float; var audioLossRate(default,null) : Float; var byteCount(default,null) : Float; var currentBytesPerSecond(default,null) : Float; var dataBufferByteLength(default,null) : Float; var dataBufferLength(default,null) : Float; var dataByteCount(default,null) : Float; var dataBytesPerSecond(default,null) : Float; var droppedFrames(default,null) : Float; var isLive(default,null) : Bool; var maxBytesPerSecond(default,null) : Float; var metaData(default,null) : Dynamic; var playbackBytesPerSecond(default,null) : Float; var resourceName(default,null) : String; var uri(default,null) : String; var videoBufferByteLength(default,null) : Float; var videoBufferLength(default,null) : Float; var videoByteCount(default,null) : Float; var videoBytesPerSecond(default,null) : Float; @:require(flash10_1) var videoLossRate(default,null) : Float; var xmpData(default,null) : Dynamic; function new(curBPS : Float, byteCount : Float, maxBPS : Float, audioBPS : Float, audioByteCount : Float, videoBPS : Float, videoByteCount : Float, dataBPS : Float, dataByteCount : Float, playbackBPS : Float, droppedFrames : Float, audioBufferByteLength : Float, videoBufferByteLength : Float, dataBufferByteLength : Float, audioBufferLength : Float, videoBufferLength : Float, dataBufferLength : Float, srtt : Float, audioLossRate : Float, videoLossRate : Float, ?metaData : Dynamic, ?xmpData : Dynamic, ?uri : String, ?resourceName : String, isLive : Bool = true) : Void; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/net/NetStreamMulticastInfo.hx0000664000175000017500000000352712607337712023755 0ustar andyandy00000000000000package flash.net; @:final @:require(flash10_1) extern class NetStreamMulticastInfo { var bytesPushedFromPeers(default,null) : Float; var bytesPushedToPeers(default,null) : Float; var bytesReceivedFromIPMulticast(default,null) : Float; var bytesReceivedFromServer(default,null) : Float; var bytesRequestedByPeers(default,null) : Float; var bytesRequestedFromPeers(default,null) : Float; var fragmentsPushedFromPeers(default,null) : Float; var fragmentsPushedToPeers(default,null) : Float; var fragmentsReceivedFromIPMulticast(default,null) : Float; var fragmentsReceivedFromServer(default,null) : Float; var fragmentsRequestedByPeers(default,null) : Float; var fragmentsRequestedFromPeers(default,null) : Float; var receiveControlBytesPerSecond(default,null) : Float; var receiveDataBytesPerSecond(default,null) : Float; var receiveDataBytesPerSecondFromIPMulticast(default,null) : Float; var receiveDataBytesPerSecondFromServer(default,null) : Float; var sendControlBytesPerSecond(default,null) : Float; var sendControlBytesPerSecondToServer(default,null) : Float; var sendDataBytesPerSecond(default,null) : Float; function new(sendDataBytesPerSecond : Float, sendControlBytesPerSecond : Float, receiveDataBytesPerSecond : Float, receiveControlBytesPerSecond : Float, bytesPushedToPeers : Float, fragmentsPushedToPeers : Float, bytesRequestedByPeers : Float, fragmentsRequestedByPeers : Float, bytesPushedFromPeers : Float, fragmentsPushedFromPeers : Float, bytesRequestedFromPeers : Float, fragmentsRequestedFromPeers : Float, sendControlBytesPerSecondToServer : Float, receiveDataBytesPerSecondFromServer : Float, bytesReceivedFromServer : Float, fragmentsReceivedFromServer : Float, receiveDataBytesPerSecondFromIPMulticast : Float, bytesReceivedFromIPMulticast : Float, fragmentsReceivedFromIPMulticast : Float) : Void; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/net/NetStreamPlayOptions.hx0000664000175000017500000000045312607337712023450 0ustar andyandy00000000000000package flash.net; extern class NetStreamPlayOptions extends flash.events.EventDispatcher implements Dynamic { var len : Float; @:require(flash10_1) var offset : Float; var oldStreamName : String; var start : Float; var streamName : String; var transition : String; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/NetStreamPlayTransitions.hx0000664000175000017500000000014512607337712024330 0ustar andyandy00000000000000package flash.net; extern enum NetStreamPlayTransitions { SWAP; SWITCH; STOP; APPEND; RESET; } haxe_3.2.1+dfsg.orig/std/flash/net/ObjectEncoding.hx0000664000175000017500000000027612607337712022224 0ustar andyandy00000000000000package flash.net; extern class ObjectEncoding { static var AMF0 : UInt; static var AMF3 : UInt; static var DEFAULT : UInt; static var dynamicPropertyWriter : IDynamicPropertyWriter; } haxe_3.2.1+dfsg.orig/std/flash/net/Responder.hx0000664000175000017500000000015212607337712021301 0ustar andyandy00000000000000package flash.net; extern class Responder { function new(result : Dynamic, ?status : Dynamic) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/SecureSocket.hx0000664000175000017500000000057712607337712021752 0ustar andyandy00000000000000package flash.net; @:require(flash11) extern class SecureSocket extends Socket { var serverCertificate(default,null) : flash.security.X509Certificate; var serverCertificateStatus(default,null) : String; function new() : Void; function addBinaryChainBuildingCertificate(certificate : flash.utils.ByteArray, trusted : Bool) : Void; static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/net/SharedObject.hx0000664000175000017500000000211212607337712021673 0ustar andyandy00000000000000package flash.net; extern class SharedObject extends flash.events.EventDispatcher { var client : Dynamic; var data(default,null) : Dynamic; var fps(null,default) : Float; var objectEncoding : UInt; var size(default,null) : UInt; function new() : Void; function clear() : Void; function close() : Void; function connect(myConnection : NetConnection, ?params : String) : Void; function flush(minDiskSpace : Int = 0) : String; function send(?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; function setDirty(propertyName : String) : Void; function setProperty(propertyName : String, ?value : flash.utils.Object) : Void; static var defaultObjectEncoding : UInt; @:require(flash11_7) static var preventBackup : Bool; static function deleteAll(url : String) : Int; static function getDiskUsage(url : String) : Int; static function getLocal(name : String, ?localPath : String, secure : Bool = false) : SharedObject; static function getRemote(name : String, ?remotePath : String, persistence : Dynamic = false, secure : Bool = false) : SharedObject; } haxe_3.2.1+dfsg.orig/std/flash/net/SharedObjectFlushStatus.hx0000664000175000017500000000022112607337712024100 0ustar andyandy00000000000000package flash.net; extern class SharedObjectFlushStatus { function new() : Void; static var FLUSHED : String; static var PENDING : String; } haxe_3.2.1+dfsg.orig/std/flash/net/Socket.hx0000664000175000017500000000327512607337712020601 0ustar andyandy00000000000000package flash.net; extern class Socket extends flash.events.EventDispatcher implements flash.utils.IDataOutput implements flash.utils.IDataInput { var bytesAvailable(default,null) : UInt; @:require(flash11) var bytesPending(default,null) : UInt; var connected(default,null) : Bool; var endian : flash.utils.Endian; var objectEncoding : UInt; @:require(flash10) var timeout : UInt; function new(?host : String, port : Int = 0) : Void; function close() : Void; function connect(host : String, port : Int) : Void; function flush() : Void; function readBoolean() : Bool; function readByte() : Int; function readBytes(bytes : flash.utils.ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function readDouble() : Float; function readFloat() : Float; function readInt() : Int; function readMultiByte(length : UInt, charSet : String) : String; function readObject() : Dynamic; function readShort() : Int; function readUTF() : String; function readUTFBytes(length : UInt) : String; function readUnsignedByte() : UInt; function readUnsignedInt() : UInt; function readUnsignedShort() : UInt; function writeBoolean(value : Bool) : Void; function writeByte(value : Int) : Void; function writeBytes(bytes : flash.utils.ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function writeDouble(value : Float) : Void; function writeFloat(value : Float) : Void; function writeInt(value : Int) : Void; function writeMultiByte(value : String, charSet : String) : Void; function writeObject(object : Dynamic) : Void; function writeShort(value : Int) : Void; function writeUTF(value : String) : Void; function writeUTFBytes(value : String) : Void; function writeUnsignedInt(value : UInt) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/URLLoader.hx0000664000175000017500000000046512607337712021140 0ustar andyandy00000000000000package flash.net; extern class URLLoader extends flash.events.EventDispatcher { var bytesLoaded : UInt; var bytesTotal : UInt; var data : Dynamic; var dataFormat : URLLoaderDataFormat; function new(?request : URLRequest) : Void; function close() : Void; function load(request : URLRequest) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/URLLoaderDataFormat.hx0000664000175000017500000000014712607337712023100 0ustar andyandy00000000000000package flash.net; @:fakeEnum(String) extern enum URLLoaderDataFormat { BINARY; TEXT; VARIABLES; } haxe_3.2.1+dfsg.orig/std/flash/net/URLRequest.hx0000664000175000017500000000057212607337712021361 0ustar andyandy00000000000000package flash.net; @:final extern class URLRequest { var contentType : String; var data : Dynamic; var digest : String; var method : String; var requestHeaders : Array; var url : String; function new(?url : String) : Void; function useRedirectedURL(sourceRequest : URLRequest, wholeURL : Bool = false, ?pattern : Dynamic, ?replace : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/URLRequestHeader.hx0000664000175000017500000000023612607337712022467 0ustar andyandy00000000000000package flash.net; @:final extern class URLRequestHeader { var name : String; var value : String; function new(?name : String, ?value : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/URLRequestMethod.hx0000664000175000017500000000045712607337712022524 0ustar andyandy00000000000000package flash.net; extern class URLRequestMethod { @:require(flash10_1) static var DELETE : String; static var GET : String; @:require(flash10_1) static var HEAD : String; @:require(flash10_1) static var OPTIONS : String; static var POST : String; @:require(flash10_1) static var PUT : String; } haxe_3.2.1+dfsg.orig/std/flash/net/URLStream.hx0000664000175000017500000000215312607337712021161 0ustar andyandy00000000000000package flash.net; extern class URLStream extends flash.events.EventDispatcher implements flash.utils.IDataInput { var bytesAvailable(default,null) : UInt; var connected(default,null) : Bool; @:require(flash11_4) var diskCacheEnabled(default,null) : Bool; var endian : flash.utils.Endian; @:require(flash11_4) var length(default,null) : Float; var objectEncoding : UInt; @:require(flash11_4) var position : Float; function new() : Void; function close() : Void; function load(request : URLRequest) : Void; function readBoolean() : Bool; function readByte() : Int; function readBytes(bytes : flash.utils.ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function readDouble() : Float; function readFloat() : Float; function readInt() : Int; function readMultiByte(length : UInt, charSet : String) : String; function readObject() : Dynamic; function readShort() : Int; function readUTF() : String; function readUTFBytes(length : UInt) : String; function readUnsignedByte() : UInt; function readUnsignedInt() : UInt; function readUnsignedShort() : UInt; @:require(flash11_4) function stop() : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/URLVariables.hx0000664000175000017500000000026612607337712021641 0ustar andyandy00000000000000package flash.net; extern class URLVariables implements Dynamic { function new(?source : String) : Void; function decode(source : String) : Void; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/net/XMLSocket.hx0000664000175000017500000000051612607337712021155 0ustar andyandy00000000000000package flash.net; extern class XMLSocket extends flash.events.EventDispatcher { var connected(default,null) : Bool; @:require(flash10) var timeout : Int; function new(?host : String, port : Int = 0) : Void; function close() : Void; function connect(host : String, port : Int) : Void; function send(object : Dynamic) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/AddToDeviceGroupSetting.hx0000664000175000017500000000030112607337712024604 0ustar andyandy00000000000000package flash.net.drm; extern class AddToDeviceGroupSetting { function new() : Void; static var ALLOW_SERVER : String; static var FORCE_REFRESH : String; static var LOCAL_ONLY : String; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/AuthenticationMethod.hx0000664000175000017500000000024212607337712024242 0ustar andyandy00000000000000package flash.net.drm; extern class AuthenticationMethod { function new() : Void; static var ANONYMOUS : String; static var USERNAME_AND_PASSWORD : String; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMAddToDeviceGroupContext.hx0000664000175000017500000000031412607337712025162 0ustar andyandy00000000000000package flash.net.drm; extern class DRMAddToDeviceGroupContext extends DRMManagerSession { function new() : Void; function addToDeviceGroup(deviceGroup : DRMDeviceGroup, forceRefresh : Bool) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMAuthenticationContext.hx0000664000175000017500000000043012607337712025010 0ustar andyandy00000000000000package flash.net.drm; extern class DRMAuthenticationContext extends DRMManagerSession { var authenticationToken(default,null) : flash.utils.ByteArray; function new() : Void; function authenticate(url : String, domain : String, username : String, password : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMContentData.hx0000664000175000017500000000053012607337712022671 0ustar andyandy00000000000000package flash.net.drm; extern class DRMContentData { var authenticationMethod(default,null) : String; var domain(default,null) : String; var licenseID(default,null) : String; var serverURL(default,null) : String; function new(?rawData : flash.utils.ByteArray) : Void; function getVoucherAccessInfo() : flash.Vector; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMDeviceGroup.hx0000664000175000017500000000035112607337712022702 0ustar andyandy00000000000000package flash.net.drm; @:final extern class DRMDeviceGroup { var authenticationMethod(default,null) : String; var domain(default,null) : String; var name : String; var serverURL(default,null) : String; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMManager.hx0000664000175000017500000000212212607337712022036 0ustar andyandy00000000000000package flash.net.drm; extern class DRMManager extends flash.events.EventDispatcher { function new() : Void; function addToDeviceGroup(deviceGroup : DRMDeviceGroup, forceRefresh : Bool = false) : Void; function authenticate(serverURL : String, domain : String, username : String, password : String) : Void; function loadPreviewVoucher(contentData : DRMContentData) : Void; function loadVoucher(contentData : DRMContentData, setting : String) : Void; function removeFromDeviceGroup(deviceGroup : DRMDeviceGroup) : Void; function resetDRMVouchers() : Void; function resetDRMVouchersInternal(isAutoReset : Bool) : Void; function returnVoucher(inServerURL : String, immediateCommit : Bool, licenseID : String, policyID : String) : Void; function setAuthenticationToken(serverUrl : String, domain : String, token : flash.utils.ByteArray) : Void; function storeVoucher(voucher : flash.utils.ByteArray) : Void; static var isSupported(default,null) : Bool; static var networkIdleTimeout : Float; static function getDRMManager() : DRMManager; static function getDRMManagerInternal() : DRMManager; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMManagerSession.hx0000664000175000017500000000151112607337712023403 0ustar andyandy00000000000000package flash.net.drm; extern class DRMManagerSession extends flash.events.EventDispatcher { var m_isInSession : Bool; var metadata : DRMContentData; function new() : Void; function checkStatus() : UInt; function errorCodeToThrow(errorCode : UInt) : Void; function getLastError() : UInt; function getLastServerErrorString() : String; function getLastSubErrorID() : UInt; function issueDRMErrorEvent(metadata : DRMContentData, errorID : Int, subErrorID : Int, serverErrorString : String) : Void; function issueDRMStatusEvent(inMetadata : DRMContentData, voucher : DRMVoucher) : Dynamic; function onSessionComplete() : Void; function onSessionError() : Void; function setTimerUp() : Void; static var STATUS_FAILED : UInt; static var STATUS_NOTREADY : UInt; static var STATUS_READY : UInt; static var STATUS_UNKNOWN : UInt; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMModuleCycleProvider.hx0000664000175000017500000000013012607337712024401 0ustar andyandy00000000000000package flash.net.drm; extern class DRMModuleCycleProvider { function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMPlaybackTimeWindow.hx0000664000175000017500000000030112607337712024216 0ustar andyandy00000000000000package flash.net.drm; extern class DRMPlaybackTimeWindow { var endDate(default,null) : Date; var period(default,null) : UInt; var startDate(default,null) : Date; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMRemoveFromDeviceGroupContext.hx0000664000175000017500000000030112607337712026244 0ustar andyandy00000000000000package flash.net.drm; extern class DRMRemoveFromDeviceGroupContext extends DRMManagerSession { function new() : Void; function removeFromDeviceGroup(deviceGroup : DRMDeviceGroup) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMResetContext.hx0000664000175000017500000000026412607337712023120 0ustar andyandy00000000000000package flash.net.drm; extern class DRMResetContext extends DRMManagerSession { var m_isAutoReset : Bool; function new(isAutoReset : Bool) : Void; function doReset() : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMReturnVoucherContext.hx0000664000175000017500000000035012607337712024645 0ustar andyandy00000000000000package flash.net.drm; extern class DRMReturnVoucherContext extends DRMManagerSession { function new() : Void; function returnVoucher(inServerURL : String, immediateCommit : Bool, licenseID : String, policyID : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMURLDownloadContext.hx0000664000175000017500000000047512607337712024174 0ustar andyandy00000000000000package flash.net.drm; extern class DRMURLDownloadContext extends flash.events.EventDispatcher { function new() : Void; function httpGetASync(url : String) : Void; function httpPostAndReceiveASync(url : String, headerName : String, headerValue : String, data : flash.utils.ByteArray, serverType : UInt) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMVoucher.hx0000664000175000017500000000101512607337712022077 0ustar andyandy00000000000000package flash.net.drm; extern class DRMVoucher { var licenseID(default,null) : String; var offlineLeaseEndDate(default,null) : Date; var offlineLeaseStartDate(default,null) : Date; var playbackTimeWindow(default,null) : DRMPlaybackTimeWindow; var policies(default,null) : Dynamic; var policyID(default,null) : String; var serverURL(default,null) : String; var voucherEndDate(default,null) : Date; var voucherStartDate(default,null) : Date; function new() : Void; function toByteArray() : flash.utils.ByteArray; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMVoucherDownloadContext.hx0000664000175000017500000000036512607337712025143 0ustar andyandy00000000000000package flash.net.drm; extern class DRMVoucherDownloadContext extends DRMManagerSession { var voucher(default,null) : DRMVoucher; function new() : Void; function download(inMetadata : DRMContentData, previewVoucher : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/DRMVoucherStoreContext.hx0000664000175000017500000000033612607337712024466 0ustar andyandy00000000000000package flash.net.drm; extern class DRMVoucherStoreContext extends DRMManagerSession { var voucher(default,null) : DRMVoucher; function new() : Void; function getVoucherFromStore(inMetadata : DRMContentData) : Void; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/LoadVoucherSetting.hx0000664000175000017500000000027412607337712023700 0ustar andyandy00000000000000package flash.net.drm; extern class LoadVoucherSetting { function new() : Void; static var ALLOW_SERVER : String; static var FORCE_REFRESH : String; static var LOCAL_ONLY : String; } haxe_3.2.1+dfsg.orig/std/flash/net/drm/VoucherAccessInfo.hx0000664000175000017500000000046112607337712023476 0ustar andyandy00000000000000package flash.net.drm; @:final extern class VoucherAccessInfo { var authenticationMethod(default,null) : String; var deviceGroup(default,null) : DRMDeviceGroup; var displayName(default,null) : String; var domain(default,null) : String; var policyID(default,null) : String; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/printing/PrintJob.hx0000664000175000017500000000107412607337712022137 0ustar andyandy00000000000000package flash.printing; extern class PrintJob extends flash.events.EventDispatcher { var orientation(default,null) : PrintJobOrientation; var pageHeight(default,null) : Int; var pageWidth(default,null) : Int; var paperHeight(default,null) : Int; var paperWidth(default,null) : Int; function new() : Void; function addPage(sprite : flash.display.Sprite, ?printArea : flash.geom.Rectangle, ?options : PrintJobOptions, frameNum : Int = 0) : Void; function send() : Void; function start() : Bool; @:require(flash10_1) static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/printing/PrintJobOptions.hx0000664000175000017500000000021112607337712023503 0ustar andyandy00000000000000package flash.printing; extern class PrintJobOptions { var printAsBitmap : Bool; function new(printAsBitmap : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/printing/PrintJobOrientation.hx0000664000175000017500000000014712607337712024353 0ustar andyandy00000000000000package flash.printing; @:fakeEnum(String) extern enum PrintJobOrientation { LANDSCAPE; PORTRAIT; } haxe_3.2.1+dfsg.orig/std/flash/sampler/Api.hx0000664000175000017500000000503712607337712020735 0ustar andyandy00000000000000package flash.sampler; extern class Api { public inline static function clearSamples() : Void { untyped __global__["flash.sampler.clearSamples"](); } public inline static function getGetterInvocationCount( obj : Dynamic, qname : flash.utils.QName ) : Float { return untyped __global__["flash.sampler.getGetterInvocationCount"](obj,qname); } public inline static function getSetterInvocationCount( obj : Dynamic, qname : flash.utils.QName ) : Float { return untyped __global__["flash.sampler.getSetterInvocationCount"](obj,qname); } public inline static function getInvocationCount( obj : Dynamic, qname : flash.utils.QName ) : Float { return untyped __global__["flash.sampler.getInvocationCount"](obj,qname); } public inline static function getMemberNames( obj : Dynamic, instanceNames : Bool = false ) : Dynamic { return untyped __global__["flash.sampler.getMemberNames"](obj,instanceNames); } public inline static function getSampleCount() : Float { return untyped __global__["flash.sampler.getSampleCount"](); } public inline static function getSamples() : Array { return untyped __foreach__(__global__["flash.sampler.getSamples"]()); } public inline static function getSize( obj : Dynamic ) : Float { return untyped __global__["flash.sampler.getSize"](obj); } public inline static function isGetterSetter( obj : Dynamic, qname : flash.utils.QName ) : Bool { return untyped __global__["flash.sampler.isGetterSetter"](obj,qname); } public inline static function pauseSampling() : Void { untyped __global__["flash.sampler.pauseSampling"](); } public inline static function startSampling() : Void { untyped __global__["flash.sampler.startSampling"](); } public inline static function stopSampling() : Void { untyped __global__["flash.sampler.stopSampling"](); } public inline static function getLexicalScopes( fun : Dynamic ) : Array { return untyped __global__["flash.sampler.getLexicalScopes"](fun); } public inline static function getMasterString( s : String ) : String { return untyped __global__["flash.sampler.getMasterString"](s); } public inline static function getSavedThis( fun : Dynamic ) : Dynamic { return untyped __global__["flash.sampler.getSavedThis"](fun); } public inline static function sampleInternalAllocs( b : Bool ) : Void { untyped __global__["flash.sampler.sampleInternalAllocs"](b); } public inline static function setSamplerCallback( callb : Dynamic ) : Void { untyped __global__["flash.sampler.setSamplerCallback"](callb); } }haxe_3.2.1+dfsg.orig/std/flash/sampler/ClassFactory.hx0000664000175000017500000000041712607337712022616 0ustar andyandy00000000000000package flash.sampler; extern class ClassFactory { function new() : Void; static var DeleteObjectSampleClass : Class; static var NewObjectSampleClass : Class; static var SampleClass : Class; static var StackFrameClass : Class; } haxe_3.2.1+dfsg.orig/std/flash/sampler/DeleteObjectSample.hx0000664000175000017500000000016712607337712023716 0ustar andyandy00000000000000package flash.sampler; @:final extern class DeleteObjectSample extends Sample { var id : Float; var size : Float; } haxe_3.2.1+dfsg.orig/std/flash/sampler/NewObjectSample.hx0000664000175000017500000000033012607337712023235 0ustar andyandy00000000000000package flash.sampler; @:final extern class NewObjectSample extends Sample { var id : Float; var object(default,null) : Dynamic; @:require(flash10_1) var size(default,null) : Float; var type : Class; } haxe_3.2.1+dfsg.orig/std/flash/sampler/Sample.hx0000664000175000017500000000014312607337712021436 0ustar andyandy00000000000000package flash.sampler; extern class Sample { var stack : Array; var time : Float; } haxe_3.2.1+dfsg.orig/std/flash/sampler/StackFrame.hx0000664000175000017500000000030112607337712022231 0ustar andyandy00000000000000package flash.sampler; @:final extern class StackFrame { var file : String; var line : UInt; var name : String; @:require(flash10_1) var scriptID : Float; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/security/CertificateStatus.hx0000664000175000017500000000060312607337712024050 0ustar andyandy00000000000000package flash.security; extern class CertificateStatus { function new() : Void; static var EXPIRED : String; static var INVALID : String; static var INVALID_CHAIN : String; static var NOT_YET_VALID : String; static var PRINCIPAL_MISMATCH : String; static var REVOKED : String; static var TRUSTED : String; static var UNKNOWN : String; static var UNTRUSTED_SIGNERS : String; } haxe_3.2.1+dfsg.orig/std/flash/security/X500DistinguishedName.hx0000664000175000017500000000060512607337712024405 0ustar andyandy00000000000000package flash.security; extern class X500DistinguishedName { var commonName(default,null) : String; var countryName(default,null) : String; var localityName(default,null) : String; var organizationName(default,null) : String; var organizationalUnitName(default,null) : String; var stateOrProvinceName(default,null) : String; function new() : Void; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/security/X509Certificate.hx0000664000175000017500000000130612607337712023233 0ustar andyandy00000000000000package flash.security; extern class X509Certificate { var encoded(default,null) : flash.utils.ByteArray; var issuer(default,null) : X500DistinguishedName; var issuerUniqueID(default,null) : String; var serialNumber(default,null) : String; var signatureAlgorithmOID(default,null) : String; var signatureAlgorithmParams(default,null) : flash.utils.ByteArray; var subject(default,null) : X500DistinguishedName; var subjectPublicKey(default,null) : String; var subjectPublicKeyAlgorithmOID(default,null) : String; var subjectUniqueID(default,null) : String; var validNotAfter(default,null) : Date; var validNotBefore(default,null) : Date; var version(default,null) : UInt; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/sensors/Accelerometer.hx0000664000175000017500000000042712607337712023025 0ustar andyandy00000000000000package flash.sensors; @:require(flash10_1) extern class Accelerometer extends flash.events.EventDispatcher { var muted(default,null) : Bool; function new() : Void; function setRequestedUpdateInterval(interval : Float) : Void; static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/sensors/Geolocation.hx0000664000175000017500000000042512607337712022514 0ustar andyandy00000000000000package flash.sensors; @:require(flash10_1) extern class Geolocation extends flash.events.EventDispatcher { var muted(default,null) : Bool; function new() : Void; function setRequestedUpdateInterval(interval : Float) : Void; static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/system/ApplicationDomain.hx0000664000175000017500000000107212607337712023473 0ustar andyandy00000000000000package flash.system; @:final extern class ApplicationDomain { @:require(flash10) var domainMemory : flash.utils.ByteArray; var parentDomain(default,null) : ApplicationDomain; function new(?parentDomain : ApplicationDomain) : Void; function getDefinition(name : String) : flash.utils.Object; @:require(flash11_3) function getQualifiedDefinitionNames() : flash.Vector; function hasDefinition(name : String) : Bool; @:require(flash10) static var MIN_DOMAIN_MEMORY_LENGTH(default,null) : UInt; static var currentDomain(default,null) : ApplicationDomain; } haxe_3.2.1+dfsg.orig/std/flash/system/ApplicationInstaller.hx0000664000175000017500000000055612607337712024227 0ustar andyandy00000000000000package flash.system; @:final @:require(flash11_3) extern class ApplicationInstaller extends flash.events.EventDispatcher { var isInstalled(default,null) : Bool; function new() : Void; function install(?mode : String) : Void; static function iconDigest(icon : flash.utils.ByteArray) : String; static function stringsDigest(strings : flash.xml.XML) : String; } haxe_3.2.1+dfsg.orig/std/flash/system/ApplicationInstallerMode.hx0000664000175000017500000000021412607337712025023 0ustar andyandy00000000000000package flash.system; @:fakeEnum(String) extern enum ApplicationInstallerMode { INSTALL_ONLY; INSTALL_WITH_SHORTCUTS; SHORTCUTS_ONLY; } haxe_3.2.1+dfsg.orig/std/flash/system/AuthorizedFeatures.hx0000664000175000017500000000126012607337712023714 0ustar andyandy00000000000000package flash.system; @:final @:require(flash11_3) extern class AuthorizedFeatures { function new() : Void; function createApplicationInstaller(strings : flash.xml.XML, icon : flash.utils.ByteArray) : ApplicationInstaller; function enableAVURLLoader(loader : flash.media.AVURLLoader) : Bool; function enableAVURLStream(stream : flash.media.AVURLStream) : Bool; @:require(flash11_4) function enableDiskCache(stream : flash.net.URLStream) : Bool; @:require(flash11_7) function enableHLSPlayback(stream : flash.media.AVStream) : Bool; @:require(flash11_4) function isFeatureEnabled(feature : String, ?data : String) : Bool; @:require(flash11_4) function isNegativeToken() : Bool; } haxe_3.2.1+dfsg.orig/std/flash/system/AuthorizedFeaturesLoader.hx0000664000175000017500000000063212607337712025045 0ustar andyandy00000000000000package flash.system; @:final @:require(flash11_3) extern class AuthorizedFeaturesLoader extends flash.events.EventDispatcher { var authorizedFeatures(default,null) : AuthorizedFeatures; function new() : Void; function loadAuthorizedFeatures() : Void; @:require(flash11_7) function loadAuthorizedFeaturesFromData(data : flash.utils.ByteArray) : Void; @:require(flash11_4) function makeGlobal() : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/Capabilities.hx0000664000175000017500000000360712607337712022477 0ustar andyandy00000000000000package flash.system; extern class Capabilities { static var _internal(default,null) : UInt; static var avHardwareDisable(default,null) : Bool; @:require(flash10_1) static var cpuArchitecture(default,null) : String; static var hasAccessibility(default,null) : Bool; static var hasAudio(default,null) : Bool; static var hasAudioEncoder(default,null) : Bool; static var hasEmbeddedVideo(default,null) : Bool; static var hasIME(default,null) : Bool; static var hasMP3(default,null) : Bool; static var hasPrinting(default,null) : Bool; static var hasScreenBroadcast(default,null) : Bool; static var hasScreenPlayback(default,null) : Bool; static var hasStreamingAudio(default,null) : Bool; static var hasStreamingVideo(default,null) : Bool; static var hasTLS(default,null) : Bool; static var hasVideoEncoder(default,null) : Bool; static var isDebugger(default,null) : Bool; @:require(flash10) static var isEmbeddedInAcrobat(default,null) : Bool; static var language(default,null) : String; static var localFileReadDisable(default,null) : Bool; static var manufacturer(default,null) : String; @:require(flash10) static var maxLevelIDC(default,null) : String; static var os(default,null) : String; static var pixelAspectRatio(default,null) : Float; static var playerType(default,null) : String; static var screenColor(default,null) : String; static var screenDPI(default,null) : Float; static var screenResolutionX(default,null) : Float; static var screenResolutionY(default,null) : Float; static var serverString(default,null) : String; @:require(flash10_1) static var supports32BitProcesses(default,null) : Bool; @:require(flash10_1) static var supports64BitProcesses(default,null) : Bool; @:require(flash10_1) static var touchscreenType(default,null) : TouchscreenType; static var version(default,null) : String; @:require(flash11) static function hasMultiChannelAudio(type : String) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/system/ConnexionsClient.hx0000664000175000017500000000054512607337712023366 0ustar andyandy00000000000000package flash.system; @:final extern class ConnexionsClient { function new() : Void; function Connexions() : Dynamic; function _init(topLocation : String, documentReferrer : String, windowLocation : String, movie : String, userAgent : String, timeout : UInt) : Void; function autoAdd(port : Int) : Dynamic; function manualAdd(port : Int) : Dynamic; } haxe_3.2.1+dfsg.orig/std/flash/system/DomainMemoryWithStage3D.hx0000664000175000017500000000013012607337712024501 0ustar andyandy00000000000000package flash.system; extern class DomainMemoryWithStage3D { function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/FSCommand.hx0000664000175000017500000000016712607337712021713 0ustar andyandy00000000000000package flash.system; extern class FSCommand { static function _fscommand(command : String, args : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/IME.hx0000664000175000017500000000076312607337712020520 0ustar andyandy00000000000000package flash.system; extern class IME extends flash.events.EventDispatcher { static var conversionMode : IMEConversionMode; static var enabled : Bool; @:require(flash10_1) static var isSupported(default,null) : Bool; @:require(flash10_1) static function compositionAbandoned() : Void; @:require(flash10_1) static function compositionSelectionChanged(start : Int, end : Int) : Void; static function doConversion() : Void; static function setCompositionString(composition : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/IMEConversionMode.hx0000664000175000017500000000032712607337712023367 0ustar andyandy00000000000000package flash.system; @:fakeEnum(String) extern enum IMEConversionMode { ALPHANUMERIC_FULL; ALPHANUMERIC_HALF; CHINESE; JAPANESE_HIRAGANA; JAPANESE_KATAKANA_FULL; JAPANESE_KATAKANA_HALF; KOREAN; UNKNOWN; } haxe_3.2.1+dfsg.orig/std/flash/system/ImageDecodingPolicy.hx0000664000175000017500000000014412607337712023736 0ustar andyandy00000000000000package flash.system; @:fakeEnum(String) extern enum ImageDecodingPolicy { ON_DEMAND; ON_LOAD; } haxe_3.2.1+dfsg.orig/std/flash/system/JPEGLoaderContext.hx0000664000175000017500000000044012607337712023317 0ustar andyandy00000000000000package flash.system; @:require(flash10) extern class JPEGLoaderContext extends LoaderContext { var deblockingFilter : Float; function new(deblockingFilter : Float = 0, checkPolicyFile : Bool = false, ?applicationDomain : ApplicationDomain, ?securityDomain : SecurityDomain) : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/LoaderContext.hx0000664000175000017500000000113512607337712022653 0ustar andyandy00000000000000package flash.system; extern class LoaderContext { @:require(flash10_1) var allowCodeImport : Bool; @:require(flash10_1) var allowLoadBytesCodeExecution : Bool; var applicationDomain : ApplicationDomain; var checkPolicyFile : Bool; @:require(flash11) var imageDecodingPolicy : ImageDecodingPolicy; @:require(flash11) var parameters : Dynamic; @:require(flash11) var requestedContentParent : flash.display.DisplayObjectContainer; var securityDomain : SecurityDomain; function new(checkPolicyFile : Bool = false, ?applicationDomain : ApplicationDomain, ?securityDomain : SecurityDomain) : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/MessageChannel.hx0000664000175000017500000000055412607337712022761 0ustar andyandy00000000000000package flash.system; @:final @:require(flash11_4) extern class MessageChannel extends flash.events.EventDispatcher { var messageAvailable(default,null) : Bool; var state(default,null) : MessageChannelState; function close() : Void; function receive(blockUntilReceived : Bool = false) : Dynamic; function send(arg : Dynamic, queueLimit : Int = -1) : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/MessageChannelState.hx0000664000175000017500000000025212607337712023755 0ustar andyandy00000000000000package flash.system; extern class MessageChannelState { function new() : Void; static var CLOSED : String; static var CLOSING : String; static var OPEN : String; } haxe_3.2.1+dfsg.orig/std/flash/system/Security.hx0000664000175000017500000000202012607337712021701 0ustar andyandy00000000000000package flash.system; extern class Security { @:require(flash10_1) static var APPLICATION : String; static var LOCAL_TRUSTED : String; static var LOCAL_WITH_FILE : String; static var LOCAL_WITH_NETWORK : String; static var REMOTE : String; static var disableAVM1Loading : Bool; static var exactSettings : Bool; @:require(flash11) static var pageDomain(default,null) : String; static var sandboxType(default,null) : String; static function allowDomain(?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; static function allowInsecureDomain(?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Void; @:require(flash10_1) static function duplicateSandboxBridgeInputArguments(toplevel : Dynamic, args : Array) : Array; @:require(flash10_1) static function duplicateSandboxBridgeOutputArgument(toplevel : Dynamic, arg : Dynamic) : Dynamic; static function loadPolicyFile(url : String) : Void; static function showSettings(?panel : SecurityPanel) : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/SecurityDomain.hx0000664000175000017500000000025412607337712023040 0ustar andyandy00000000000000package flash.system; extern class SecurityDomain { @:require(flash11_3) var domainID(default,null) : String; static var currentDomain(default,null) : SecurityDomain; } haxe_3.2.1+dfsg.orig/std/flash/system/SecurityPanel.hx0000664000175000017500000000023712607337712022671 0ustar andyandy00000000000000package flash.system; @:fakeEnum(String) extern enum SecurityPanel { CAMERA; DEFAULT; DISPLAY; LOCAL_STORAGE; MICROPHONE; PRIVACY; SETTINGS_MANAGER; } haxe_3.2.1+dfsg.orig/std/flash/system/System.hx0000664000175000017500000000154012607337712021364 0ustar andyandy00000000000000package flash.system; extern class System { @:require(flash10_1) static var freeMemory(default,null) : Float; static var ime(default,null) : IME; @:require(flash10_1) static var privateMemory(default,null) : Float; @:require(flash11) static var processCPUUsage(default,null) : Float; static var totalMemory(default,null) : UInt; @:require(flash10_1) static var totalMemoryNumber(default,null) : Float; static var useCodePage : Bool; static var vmVersion(default,null) : String; @:require(flash10_1) static function disposeXML(node : flash.xml.XML) : Void; static function exit(code : UInt) : Void; static function gc() : Void; static function pause() : Void; @:require(flash11) static function pauseForGCIfCollectionImminent(imminence : Float = 0.75) : Void; static function resume() : Void; static function setClipboard(string : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/SystemUpdater.hx0000664000175000017500000000032612607337712022712 0ustar andyandy00000000000000package flash.system; @:require(flash10_1) extern class SystemUpdater extends flash.events.EventDispatcher { function new() : Void; function cancel() : Void; function update(type : SystemUpdaterType) : Void; } haxe_3.2.1+dfsg.orig/std/flash/system/SystemUpdaterType.hx0000664000175000017500000000013312607337712023550 0ustar andyandy00000000000000package flash.system; @:fakeEnum(String) extern enum SystemUpdaterType { DRM; SYSTEM; } haxe_3.2.1+dfsg.orig/std/flash/system/TouchscreenType.hx0000664000175000017500000000014312607337712023222 0ustar andyandy00000000000000package flash.system; @:fakeEnum(String) extern enum TouchscreenType { FINGER; NONE; STYLUS; } haxe_3.2.1+dfsg.orig/std/flash/system/Worker.hx0000664000175000017500000000101712607337712021350 0ustar andyandy00000000000000package flash.system; @:final @:require(flash11_4) extern class Worker extends flash.events.EventDispatcher { var isPrimordial(default,null) : Bool; var state(default,null) : WorkerState; function createMessageChannel(receiver : Worker) : MessageChannel; function getSharedProperty(key : String) : Dynamic; function setSharedProperty(key : String, value : Dynamic) : Void; function start() : Void; function terminate() : Bool; static var current(default,null) : Worker; static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/system/WorkerDomain.hx0000664000175000017500000000053212607337712022501 0ustar andyandy00000000000000package flash.system; @:final @:require(flash11_4) extern class WorkerDomain { function new() : Void; function createWorker(swf : flash.utils.ByteArray, giveAppPrivileges : Bool = false) : Worker; function listWorkers() : flash.Vector; static var current(default,null) : WorkerDomain; static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/system/WorkerState.hx0000664000175000017500000000014312607337712022350 0ustar andyandy00000000000000package flash.system; @:fakeEnum(String) extern enum WorkerState { NEW; RUNNING; TERMINATED; } haxe_3.2.1+dfsg.orig/std/flash/text/AntiAliasType.hx0000664000175000017500000000013212607337712022243 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum AntiAliasType { ADVANCED; NORMAL; } haxe_3.2.1+dfsg.orig/std/flash/text/CSMSettings.hx0000664000175000017500000000033512607337712021704 0ustar andyandy00000000000000package flash.text; @:final extern class CSMSettings { var fontSize : Float; var insideCutoff : Float; var outsideCutoff : Float; function new(fontSize : Float, insideCutoff : Float, outsideCutoff : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/Font.hx0000664000175000017500000000056612607337712020455 0ustar andyandy00000000000000package flash.text; extern class Font { var fontName(default,null) : String; var fontStyle(default,null) : FontStyle; var fontType(default,null) : FontType; function new() : Void; function hasGlyphs(str : String) : Bool; static function enumerateFonts(enumerateDeviceFonts : Bool = false) : Array; static function registerFont(font : Class) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/FontStyle.hx0000664000175000017500000000015212607337712021465 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum FontStyle { BOLD; BOLD_ITALIC; ITALIC; REGULAR; } haxe_3.2.1+dfsg.orig/std/flash/text/FontType.hx0000664000175000017500000000014412607337712021307 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum FontType { DEVICE; EMBEDDED; EMBEDDED_CFF; } haxe_3.2.1+dfsg.orig/std/flash/text/GridFitType.hx0000664000175000017500000000013612607337712021732 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum GridFitType { NONE; PIXEL; SUBPIXEL; } haxe_3.2.1+dfsg.orig/std/flash/text/StaticText.hx0000664000175000017500000000022712607337712021635 0ustar andyandy00000000000000package flash.text; @:final extern class StaticText extends flash.display.DisplayObject { var text(default,null) : String; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/StyleSheet.hx0000664000175000017500000000071312607337712021632 0ustar andyandy00000000000000package flash.text; extern class StyleSheet extends flash.events.EventDispatcher implements Dynamic { var styleNames(default,null) : Array; function new() : Void; function clear() : Void; function getStyle(styleName : String) : flash.utils.Object; function parseCSS(CSSText : String) : Void; function setStyle(styleName : String, styleObject : flash.utils.Object) : Void; function transform(formatObject : flash.utils.Object) : TextFormat; } haxe_3.2.1+dfsg.orig/std/flash/text/TextColorType.hx0000664000175000017500000000014112607337712022321 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum TextColorType { DARK_COLOR; LIGHT_COLOR; } haxe_3.2.1+dfsg.orig/std/flash/text/TextDisplayMode.hx0000664000175000017500000000013612607337712022617 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum TextDisplayMode { CRT; DEFAULT; LCD; } haxe_3.2.1+dfsg.orig/std/flash/text/TextExtent.hx0000664000175000017500000000050712607337712021656 0ustar andyandy00000000000000package flash.text; extern class TextExtent { var ascent : Float; var descent : Float; var height : Float; var textFieldHeight : Float; var textFieldWidth : Float; var width : Float; function new(width : Float, height : Float, textFieldWidth : Float, textFieldHeight : Float, ascent : Float, descent : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/TextField.hx0000664000175000017500000000555212607337712021437 0ustar andyandy00000000000000package flash.text; extern class TextField extends flash.display.InteractiveObject { var alwaysShowSelection : Bool; var antiAliasType : AntiAliasType; var autoSize : TextFieldAutoSize; var background : Bool; var backgroundColor : UInt; var border : Bool; var borderColor : UInt; var bottomScrollV(default,null) : Int; var caretIndex(default,null) : Int; var condenseWhite : Bool; var defaultTextFormat : TextFormat; var displayAsPassword : Bool; var embedFonts : Bool; var gridFitType : GridFitType; var htmlText : String; var length(default,null) : Int; var maxChars : Int; var maxScrollH(default,null) : Int; var maxScrollV(default,null) : Int; var mouseWheelEnabled : Bool; var multiline : Bool; var numLines(default,null) : Int; var restrict : String; var scrollH : Int; var scrollV : Int; var selectable : Bool; var selectedText(default,null) : String; var selectionBeginIndex(default,null) : Int; var selectionEndIndex(default,null) : Int; var sharpness : Float; var styleSheet : StyleSheet; var text : String; var textColor : UInt; var textHeight(default,null) : Float; @:require(flash11) var textInteractionMode(default,null) : TextInteractionMode; var textWidth(default,null) : Float; var thickness : Float; var type : TextFieldType; var useRichTextClipboard : Bool; var wordWrap : Bool; function new() : Void; function appendText(newText : String) : Void; function copyRichText() : String; function getCharBoundaries(charIndex : Int) : flash.geom.Rectangle; function getCharIndexAtPoint(x : Float, y : Float) : Int; function getFirstCharInParagraph(charIndex : Int) : Int; function getImageReference(id : String) : flash.display.DisplayObject; function getLineIndexAtPoint(x : Float, y : Float) : Int; function getLineIndexOfChar(charIndex : Int) : Int; function getLineLength(lineIndex : Int) : Int; function getLineMetrics(lineIndex : Int) : TextLineMetrics; function getLineOffset(lineIndex : Int) : Int; function getLineText(lineIndex : Int) : String; function getParagraphLength(charIndex : Int) : Int; function getRawText() : String; function getTextFormat(beginIndex : Int = -1, endIndex : Int = -1) : TextFormat; function getTextRuns(beginIndex : Int = 0, endIndex : Int = 2147483647) : Array; function getXMLText(beginIndex : Int = 0, endIndex : Int = 2147483647) : String; function insertXMLText(beginIndex : Int, endIndex : Int, richText : String, pasting : Bool = false) : Void; function pasteRichText(richText : String) : Bool; function replaceSelectedText(value : String) : Void; function replaceText(beginIndex : Int, endIndex : Int, newText : String) : Void; function setSelection(beginIndex : Int, endIndex : Int) : Void; function setTextFormat(format : TextFormat, beginIndex : Int = -1, endIndex : Int = -1) : Void; @:require(flash10) static function isFontCompatible(fontName : String, fontStyle : String) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/text/TextFieldAutoSize.hx0000664000175000017500000000015112607337712023111 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum TextFieldAutoSize { CENTER; LEFT; NONE; RIGHT; } haxe_3.2.1+dfsg.orig/std/flash/text/TextFieldType.hx0000664000175000017500000000013012607337712022264 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum TextFieldType { DYNAMIC; INPUT; } haxe_3.2.1+dfsg.orig/std/flash/text/TextFormat.hx0000664000175000017500000000146712607337712021645 0ustar andyandy00000000000000package flash.text; extern class TextFormat { var align : TextFormatAlign; var blockIndent : Null; var bold : Null; var bullet : Null; var color : Null; var display : TextFormatDisplay; var font : String; var indent : Null; var italic : Null; var kerning : Null; var leading : Null; var leftMargin : Null; var letterSpacing : Null; var rightMargin : Null; var size : Null; var tabStops : Array; var target : String; var underline : Null; var url : String; function new(?font : String, ?size : Float, ?color : UInt, ?bold : Bool, ?italic : Bool, ?underline : Bool, ?url : String, ?target : String, ?align : TextFormatAlign, ?leftMargin : Float, ?rightMargin : Float, ?indent : Float, ?leading : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/TextFormatAlign.hx0000664000175000017500000000017012607337712022606 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum TextFormatAlign { CENTER; END; JUSTIFY; LEFT; RIGHT; START; } haxe_3.2.1+dfsg.orig/std/flash/text/TextFormatDisplay.hx0000664000175000017500000000013312607337712023160 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum TextFormatDisplay { BLOCK; INLINE; } haxe_3.2.1+dfsg.orig/std/flash/text/TextInteractionMode.hx0000664000175000017500000000014112607337712023465 0ustar andyandy00000000000000package flash.text; @:fakeEnum(String) extern enum TextInteractionMode { NORMAL; SELECTION; } haxe_3.2.1+dfsg.orig/std/flash/text/TextLineMetrics.hx0000664000175000017500000000044212607337712022623 0ustar andyandy00000000000000package flash.text; extern class TextLineMetrics { var ascent : Float; var descent : Float; var height : Float; var leading : Float; var width : Float; var x : Float; function new(x : Float, width : Float, height : Float, ascent : Float, descent : Float, leading : Float) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/TextRenderer.hx0000664000175000017500000000051412607337712022153 0ustar andyandy00000000000000package flash.text; extern class TextRenderer { static var antiAliasType : AntiAliasType; static var displayMode : TextDisplayMode; static var maxLevel : Int; static function setAdvancedAntiAliasingTable(fontName : String, fontStyle : FontStyle, colorType : TextColorType, advancedAntiAliasingTable : Array) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/TextRun.hx0000664000175000017500000000031112607337712021144 0ustar andyandy00000000000000package flash.text; extern class TextRun { var beginIndex : Int; var endIndex : Int; var textFormat : TextFormat; function new(beginIndex : Int, endIndex : Int, textFormat : TextFormat) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/TextSnapshot.hx0000664000175000017500000000133412607337712022205 0ustar andyandy00000000000000package flash.text; extern class TextSnapshot { var charCount(default,null) : Int; function new() : Void; function findText(beginIndex : Int, textToFind : String, caseSensitive : Bool) : Int; function getSelected(beginIndex : Int, endIndex : Int) : Bool; function getSelectedText(includeLineEndings : Bool = false) : String; function getText(beginIndex : Int, endIndex : Int, includeLineEndings : Bool = false) : String; function getTextRunInfo(beginIndex : Int, endIndex : Int) : Array; function hitTestTextNearPos(x : Float, y : Float, maxDistance : Float = 0) : Float; function setSelectColor(hexColor : UInt = 16776960) : Void; function setSelected(beginIndex : Int, endIndex : Int, select : Bool) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/BreakOpportunity.hx0000664000175000017500000000015212607337712024324 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum BreakOpportunity { ALL; ANY; AUTO; NONE; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/CFFHinting.hx0000664000175000017500000000014312607337712022722 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum CFFHinting { HORIZONTAL_STEM; NONE; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/ContentElement.hx0000664000175000017500000000110012607337712023721 0ustar andyandy00000000000000package flash.text.engine; extern class ContentElement { var elementFormat : ElementFormat; var eventMirror : flash.events.EventDispatcher; var groupElement(default,null) : GroupElement; var rawText(default,null) : String; var text(default,null) : String; var textBlock(default,null) : TextBlock; var textBlockBeginIndex(default,null) : Int; var textRotation : TextRotation; var userData : Dynamic; function new(?elementFormat : ElementFormat, ?eventMirror : flash.events.EventDispatcher, ?textRotation : TextRotation) : Void; static var GRAPHIC_ELEMENT : UInt; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/DigitCase.hx0000664000175000017500000000015012607337712022635 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum DigitCase { DEFAULT; LINING; OLD_STYLE; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/DigitWidth.hx0000664000175000017500000000015512607337712023046 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum DigitWidth { DEFAULT; PROPORTIONAL; TABULAR; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/EastAsianJustifier.hx0000664000175000017500000000046412607337712024546 0ustar andyandy00000000000000package flash.text.engine; @:final extern class EastAsianJustifier extends TextJustifier { var composeTrailingIdeographicSpaces : Bool; var justificationStyle : JustificationStyle; function new(?locale : String, ?lineJustification : LineJustification, ?justificationStyle : JustificationStyle) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/ElementFormat.hx0000664000175000017500000000222512607337712023550 0ustar andyandy00000000000000package flash.text.engine; @:final extern class ElementFormat { var alignmentBaseline : TextBaseline; var alpha : Float; var baselineShift : Float; var breakOpportunity : BreakOpportunity; var color : UInt; var digitCase : DigitCase; var digitWidth : DigitWidth; var dominantBaseline : TextBaseline; var fontDescription : FontDescription; var fontSize : Float; var kerning : Kerning; var ligatureLevel : LigatureLevel; var locale : String; var locked : Bool; var textRotation : TextRotation; var trackingLeft : Float; var trackingRight : Float; var typographicCase : TypographicCase; function new(?fontDescription : FontDescription, fontSize : Float = 12, color : UInt = 0, alpha : Float = 1, ?textRotation : TextRotation, ?dominantBaseline : TextBaseline, ?alignmentBaseline : TextBaseline, baselineShift : Float = 0, ?kerning : Kerning, trackingRight : Float = 0, trackingLeft : Float = 0, ?locale : String, ?breakOpportunity : BreakOpportunity, ?digitCase : DigitCase, ?digitWidth : DigitWidth, ?ligatureLevel : LigatureLevel, ?typographicCase : TypographicCase) : Void; function clone() : ElementFormat; function getFontMetrics() : FontMetrics; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/FontDescription.hx0000664000175000017500000000134512607337712024122 0ustar andyandy00000000000000package flash.text.engine; @:final extern class FontDescription { var cffHinting : CFFHinting; var fontLookup : FontLookup; var fontName : String; var fontPosture : FontPosture; var fontWeight : FontWeight; var locked : Bool; var renderingMode : RenderingMode; function new(?fontName : String, ?fontWeight : FontWeight, ?fontPosture : FontPosture, ?fontLookup : FontLookup, ?renderingMode : RenderingMode, ?cffHinting : CFFHinting) : Void; function clone() : FontDescription; @:require(flash10_1) static function isDeviceFontCompatible(fontName : String, fontWeight : FontWeight, fontPosture : FontPosture) : Bool; static function isFontCompatible(fontName : String, fontWeight : FontWeight, fontPosture : FontPosture) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/FontLookup.hx0000664000175000017500000000014212607337712023102 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum FontLookup { DEVICE; EMBEDDED_CFF; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/FontMetrics.hx0000664000175000017500000000123312607337712023241 0ustar andyandy00000000000000package flash.text.engine; @:final extern class FontMetrics { var emBox : flash.geom.Rectangle; var lineGap : Float; var strikethroughOffset : Float; var strikethroughThickness : Float; var subscriptOffset : Float; var subscriptScale : Float; var superscriptOffset : Float; var superscriptScale : Float; var underlineOffset : Float; var underlineThickness : Float; function new(emBox : flash.geom.Rectangle, strikethroughOffset : Float, strikethroughThickness : Float, underlineOffset : Float, underlineThickness : Float, subscriptOffset : Float, subscriptScale : Float, superscriptOffset : Float, superscriptScale : Float, lineGap : Float = 0) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/FontPosture.hx0000664000175000017500000000013512607337712023274 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum FontPosture { ITALIC; NORMAL; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/FontWeight.hx0000664000175000017500000000013212607337712023057 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum FontWeight { BOLD; NORMAL; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/GraphicElement.hx0000664000175000017500000000063612607337712023701 0ustar andyandy00000000000000package flash.text.engine; @:final extern class GraphicElement extends ContentElement { var elementHeight : Float; var elementWidth : Float; var graphic : flash.display.DisplayObject; function new(?graphic : flash.display.DisplayObject, elementWidth : Float = 15, elementHeight : Float = 15, ?elementFormat : ElementFormat, ?eventMirror : flash.events.EventDispatcher, ?textRotation : TextRotation) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/GroupElement.hx0000664000175000017500000000170612607337712023417 0ustar andyandy00000000000000package flash.text.engine; @:final extern class GroupElement extends ContentElement { var elementCount(default,null) : Int; function new(?elements : flash.Vector, ?elementFormat : ElementFormat, ?eventMirror : flash.events.EventDispatcher, ?textRotation : TextRotation) : Void; function getElementAt(index : Int) : ContentElement; function getElementAtCharIndex(charIndex : Int) : ContentElement; function getElementIndex(element : ContentElement) : Int; function groupElements(beginIndex : Int, endIndex : Int) : GroupElement; function mergeTextElements(beginIndex : Int, endIndex : Int) : TextElement; function replaceElements(beginIndex : Int, endIndex : Int, newElements : flash.Vector) : flash.Vector; function setElements(value : flash.Vector) : Void; function splitTextElement(elementIndex : Int, splitIndex : Int) : TextElement; function ungroupElements(groupIndex : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/JustificationStyle.hx0000664000175000017500000000022212607337712024635 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum JustificationStyle { PRIORITIZE_LEAST_ADJUSTMENT; PUSH_IN_KINSOKU; PUSH_OUT_ONLY; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/Kerning.hx0000664000175000017500000000013112607337712022375 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum Kerning { AUTO; OFF; ON; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/LigatureLevel.hx0000664000175000017500000000017312607337712023552 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum LigatureLevel { COMMON; EXOTIC; MINIMUM; NONE; UNCOMMON; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/LineJustification.hx0000664000175000017500000000023512607337712024430 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum LineJustification { ALL_BUT_LAST; ALL_BUT_MANDATORY_BREAK; ALL_INCLUDING_LAST; UNJUSTIFIED; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/RenderingMode.hx0000664000175000017500000000013412607337712023525 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum RenderingMode { CFF; NORMAL; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/SpaceJustifier.hx0000664000175000017500000000057112607337712023730 0ustar andyandy00000000000000package flash.text.engine; @:final extern class SpaceJustifier extends TextJustifier { var letterSpacing : Bool; @:require(flash10_1) var maximumSpacing : Float; @:require(flash10_1) var minimumSpacing : Float; @:require(flash10_1) var optimumSpacing : Float; function new(?locale : String, ?lineJustification : LineJustification, letterSpacing : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TabAlignment.hx0000664000175000017500000000015512607337712023353 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum TabAlignment { CENTER; DECIMAL; END; START; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TabStop.hx0000664000175000017500000000040012607337712022353 0ustar andyandy00000000000000package flash.text.engine; @:final extern class TabStop { var alignment : TabAlignment; var decimalAlignmentToken : String; var position : Float; function new(?alignment : TabAlignment, position : Float = 0, ?decimalAlignmentToken : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextBaseline.hx0000664000175000017500000000027312607337712023376 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum TextBaseline { ASCENT; DESCENT; IDEOGRAPHIC_BOTTOM; IDEOGRAPHIC_CENTER; IDEOGRAPHIC_TOP; ROMAN; USE_DOMINANT_BASELINE; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextBlock.hx0000664000175000017500000000326412607337712022711 0ustar andyandy00000000000000package flash.text.engine; @:final extern class TextBlock { var applyNonLinearFontScaling : Bool; var baselineFontDescription : FontDescription; var baselineFontSize : Float; var baselineZero : TextBaseline; var bidiLevel : Int; var content : ContentElement; var firstInvalidLine(default,null) : TextLine; var firstLine(default,null) : TextLine; var lastLine(default,null) : TextLine; var lineRotation : TextRotation; var tabStops : flash.Vector; var textJustifier : TextJustifier; var textLineCreationResult(default,null) : TextLineCreationResult; var userData : Dynamic; function new(?content : ContentElement, ?tabStops : flash.Vector, ?textJustifier : TextJustifier, ?lineRotation : TextRotation, ?baselineZero : TextBaseline, bidiLevel : Int = 0, applyNonLinearFontScaling : Bool = true, ?baselineFontDescription : FontDescription, baselineFontSize : Float = 12) : Void; function createTextLine(?previousLine : TextLine, width : Float = 1000000, lineOffset : Float = 0, fitSomething : Bool = false) : TextLine; function dump() : String; function findNextAtomBoundary(afterCharIndex : Int) : Int; function findNextWordBoundary(afterCharIndex : Int) : Int; function findPreviousAtomBoundary(beforeCharIndex : Int) : Int; function findPreviousWordBoundary(beforeCharIndex : Int) : Int; function getTextLineAtCharIndex(charIndex : Int) : TextLine; @:require(flash10_1) function recreateTextLine(textLine : TextLine, ?previousLine : TextLine, width : Float = 1000000, lineOffset : Float = 0, fitSomething : Bool = false) : TextLine; @:require(flash10_1) function releaseLineCreationData() : Void; function releaseLines(firstLine : TextLine, lastLine : TextLine) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextElement.hx0000664000175000017500000000047312607337712023247 0ustar andyandy00000000000000package flash.text.engine; @:final extern class TextElement extends ContentElement { function new(?text : String, ?elementFormat : ElementFormat, ?eventMirror : flash.events.EventDispatcher, ?textRotation : TextRotation) : Void; function replaceText(beginIndex : Int, endIndex : Int, newText : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextJustifier.hx0000664000175000017500000000050512607337712023616 0ustar andyandy00000000000000package flash.text.engine; extern class TextJustifier { var lineJustification : LineJustification; var locale(default,null) : String; function new(locale : String, lineJustification : LineJustification) : Void; function clone() : TextJustifier; static function getJustifierForLocale(locale : String) : TextJustifier; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextLine.hx0000664000175000017500000000341712607337712022546 0ustar andyandy00000000000000package flash.text.engine; @:final extern class TextLine extends flash.display.DisplayObjectContainer { var ascent(default,null) : Float; var atomCount(default,null) : Int; var descent(default,null) : Float; var hasGraphicElement(default,null) : Bool; @:require(flash10_1) var hasTabs(default,null) : Bool; var mirrorRegions(default,null) : flash.Vector; var nextLine(default,null) : TextLine; var previousLine(default,null) : TextLine; var rawTextLength(default,null) : Int; var specifiedWidth(default,null) : Float; var textBlock(default,null) : TextBlock; var textBlockBeginIndex(default,null) : Int; var textHeight(default,null) : Float; var textWidth(default,null) : Float; var totalAscent(default,null) : Float; var totalDescent(default,null) : Float; var totalHeight(default,null) : Float; var unjustifiedTextWidth(default,null) : Float; var userData : Dynamic; var validity : String; function new() : Void; function dump() : String; function flushAtomData() : Void; function getAtomBidiLevel(atomIndex : Int) : Int; function getAtomBounds(atomIndex : Int) : flash.geom.Rectangle; function getAtomCenter(atomIndex : Int) : Float; function getAtomGraphic(atomIndex : Int) : flash.display.DisplayObject; function getAtomIndexAtCharIndex(charIndex : Int) : Int; function getAtomIndexAtPoint(stageX : Float, stageY : Float) : Int; function getAtomTextBlockBeginIndex(atomIndex : Int) : Int; function getAtomTextBlockEndIndex(atomIndex : Int) : Int; function getAtomTextRotation(atomIndex : Int) : String; function getAtomWordBoundaryOnLeft(atomIndex : Int) : Bool; function getBaselinePosition(baseline : String) : Float; function getMirrorRegion(mirror : flash.events.EventDispatcher) : TextLineMirrorRegion; static var MAX_LINE_WIDTH : Int; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextLineCreationResult.hx0000664000175000017500000000021412607337712025422 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum TextLineCreationResult { COMPLETE; EMERGENCY; INSUFFICIENT_WIDTH; SUCCESS; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextLineMirrorRegion.hx0000664000175000017500000000062312607337712025101 0ustar andyandy00000000000000package flash.text.engine; @:final extern class TextLineMirrorRegion { var bounds(default,null) : flash.geom.Rectangle; var element(default,null) : ContentElement; var mirror(default,null) : flash.events.EventDispatcher; var nextRegion(default,null) : TextLineMirrorRegion; var previousRegion(default,null) : TextLineMirrorRegion; var textLine(default,null) : TextLine; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextLineValidity.hx0000664000175000017500000000017612607337712024253 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum TextLineValidity { INVALID; POSSIBLY_INVALID; STATIC; VALID; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TextRotation.hx0000664000175000017500000000020412607337712023445 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum TextRotation { AUTO; ROTATE_0; ROTATE_180; ROTATE_270; ROTATE_90; } haxe_3.2.1+dfsg.orig/std/flash/text/engine/TypographicCase.hx0000664000175000017500000000024312607337712024071 0ustar andyandy00000000000000package flash.text.engine; @:fakeEnum(String) extern enum TypographicCase { CAPS; CAPS_AND_SMALL_CAPS; DEFAULT; LOWERCASE; SMALL_CAPS; TITLE; UPPERCASE; } haxe_3.2.1+dfsg.orig/std/flash/text/ime/CompositionAttributeRange.hx0000664000175000017500000000041412607337712025455 0ustar andyandy00000000000000package flash.text.ime; @:final extern class CompositionAttributeRange { var converted : Bool; var relativeEnd : Int; var relativeStart : Int; var selected : Bool; function new(relativeStart : Int, relativeEnd : Int, selected : Bool, converted : Bool) : Void; } haxe_3.2.1+dfsg.orig/std/flash/text/ime/IIMEClient.hx0000664000175000017500000000136612607337712022202 0ustar andyandy00000000000000package flash.text.ime; extern interface IIMEClient { var compositionEndIndex(default,null) : Int; var compositionStartIndex(default,null) : Int; var selectionActiveIndex(default,null) : Int; var selectionAnchorIndex(default,null) : Int; var verticalTextLayout(default,null) : Bool; function confirmComposition(?text : String, preserveSelection : Bool = false) : Void; function getTextBounds(startIndex : Int, endIndex : Int) : flash.geom.Rectangle; function getTextInRange(startIndex : Int, endIndex : Int) : String; function selectRange(anchorIndex : Int, activeIndex : Int) : Void; function updateComposition(text : String, attributes : flash.Vector, compositionStartIndex : Int, compositionEndIndex : Int) : Void; } haxe_3.2.1+dfsg.orig/std/flash/trace/Trace.hx0000664000175000017500000000074612607337712020717 0ustar andyandy00000000000000package flash.trace; extern class Trace { static var FILE : Dynamic; static var LISTENER : Dynamic; static var METHODS : Int; static var METHODS_AND_LINES : Int; static var METHODS_AND_LINES_WITH_ARGS : Int; static var METHODS_WITH_ARGS : Int; static var OFF : Int; static function getLevel(target : Int = 2) : Int; static function getListener() : Dynamic; static function setLevel(l : Int, target : Int = 2) : Dynamic; static function setListener(f : Dynamic) : Dynamic; } haxe_3.2.1+dfsg.orig/std/flash/ui/ContextMenu.hx0000664000175000017500000000076112607337712021446 0ustar andyandy00000000000000package flash.ui; @:final extern class ContextMenu extends flash.display.NativeMenu { var builtInItems : ContextMenuBuiltInItems; @:require(flash10) var clipboardItems : ContextMenuClipboardItems; @:require(flash10) var clipboardMenu : Bool; var customItems : Array; @:require(flash10) var link : flash.net.URLRequest; function new() : Void; function clone() : ContextMenu; function hideBuiltInItems() : Void; @:require(flash10_1) static var isSupported(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/ui/ContextMenuBuiltInItems.hx0000664000175000017500000000045112607337712023733 0ustar andyandy00000000000000package flash.ui; @:final extern class ContextMenuBuiltInItems { var forwardAndBack : Bool; var loop : Bool; var play : Bool; var print : Bool; var quality : Bool; var rewind : Bool; var save : Bool; var zoom : Bool; function new() : Void; function clone() : ContextMenuBuiltInItems; } haxe_3.2.1+dfsg.orig/std/flash/ui/ContextMenuClipboardItems.hx0000664000175000017500000000035512607337712024267 0ustar andyandy00000000000000package flash.ui; @:final extern class ContextMenuClipboardItems { var clear : Bool; var copy : Bool; var cut : Bool; var paste : Bool; var selectAll : Bool; function new() : Void; function clone() : ContextMenuClipboardItems; } haxe_3.2.1+dfsg.orig/std/flash/ui/ContextMenuItem.hx0000664000175000017500000000050512607337712022261 0ustar andyandy00000000000000package flash.ui; @:final extern class ContextMenuItem extends flash.display.NativeMenuItem { var caption : String; var separatorBefore : Bool; var visible : Bool; function new(caption : String, separatorBefore : Bool = false, enabled : Bool = true, visible : Bool = true) : Void; function clone() : ContextMenuItem; } haxe_3.2.1+dfsg.orig/std/flash/ui/GameInput.hx0000664000175000017500000000037712607337712021071 0ustar andyandy00000000000000package flash.ui; @:require(flash11_8) extern class GameInput extends flash.events.EventDispatcher { static var isSupported(default,null) : Bool; static var numDevices(default,null) : Int; static function getDeviceAt(index : Int) : GameInputDevice; } haxe_3.2.1+dfsg.orig/std/flash/ui/GameInputControl.hx0000664000175000017500000000047612607337712022432 0ustar andyandy00000000000000package flash.ui; extern class GameInputControl extends flash.events.EventDispatcher implements Dynamic { var device(default,null) : GameInputDevice; var id(default,null) : String; var maxValue(default,null) : Float; var minValue(default,null) : Float; var value(default,null) : Float; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/ui/GameInputControlType.hx0000664000175000017500000000021712607337712023265 0ustar andyandy00000000000000package flash.ui; @:fakeEnum(String) extern enum GameInputControlType { ACCELERATION; BUTTON; DIRECTION; MOVEMENT; ROTATION; TRIGGER; } haxe_3.2.1+dfsg.orig/std/flash/ui/GameInputDevice.hx0000664000175000017500000000105712607337712022205 0ustar andyandy00000000000000package flash.ui; @:final @:require(flash11_8) extern class GameInputDevice { var enabled : Bool; var id(default,null) : String; var name(default,null) : String; var numControls(default,null) : Int; var sampleInterval : Int; function new() : Void; function getCachedSamples(data : flash.utils.ByteArray, append : Bool = false) : Int; function getControlAt(i : Int) : GameInputControl; function startCachingSamples(numSamples : Int, controls : flash.Vector) : Void; function stopCachingSamples() : Void; static var MAX_BUFFER_SIZE : Int; } haxe_3.2.1+dfsg.orig/std/flash/ui/GameInputFinger.hx0000664000175000017500000000015112607337712022212 0ustar andyandy00000000000000package flash.ui; @:fakeEnum(String) extern enum GameInputFinger { INDEX; MIDDLE; THUMB; UNKNOWN; } haxe_3.2.1+dfsg.orig/std/flash/ui/GameInputHand.hx0000664000175000017500000000013512607337712021654 0ustar andyandy00000000000000package flash.ui; @:fakeEnum(String) extern enum GameInputHand { LEFT; RIGHT; UNKNOWN; } haxe_3.2.1+dfsg.orig/std/flash/ui/KeyLocation.hx0000664000175000017500000000015412607337712021412 0ustar andyandy00000000000000package flash.ui; @:fakeEnum(UInt) extern enum KeyLocation { D_PAD; LEFT; NUM_PAD; RIGHT; STANDARD; } haxe_3.2.1+dfsg.orig/std/flash/ui/Keyboard.hx0000664000175000017500000003254112607337712020736 0ustar andyandy00000000000000package flash.ui; extern class Keyboard { @:require(flash10_1) static var A : UInt; @:require(flash10_1) static var ALTERNATE : UInt; @:require(flash10_2) static var AUDIO : UInt; @:require(flash10_1) static var B : UInt; @:require(flash10_2) static var BACK : UInt; @:require(flash10_1) static var BACKQUOTE : UInt; @:require(flash10_1) static var BACKSLASH : UInt; static var BACKSPACE : UInt; @:require(flash10_2) static var BLUE : UInt; @:require(flash10_1) static var C : UInt; static var CAPS_LOCK : UInt; @:require(flash10_2) static var CHANNEL_DOWN : UInt; @:require(flash10_2) static var CHANNEL_UP : UInt; @:require(flash10_1) static var COMMA : UInt; @:require(flash10_1) static var COMMAND : UInt; static var CONTROL : UInt; @:require(flash10_1) static var CharCodeStrings : Array; @:require(flash10_1) static var D : UInt; static var DELETE : UInt; static var DOWN : UInt; @:require(flash10_2) static var DVR : UInt; @:require(flash10_1) static var E : UInt; static var END : UInt; static var ENTER : UInt; @:require(flash10_1) static var EQUAL : UInt; static var ESCAPE : UInt; @:require(flash10_2) static var EXIT : UInt; @:require(flash10_1) static var F : UInt; static var F1 : UInt; static var F10 : UInt; static var F11 : UInt; static var F12 : UInt; static var F13 : UInt; static var F14 : UInt; static var F15 : UInt; static var F2 : UInt; static var F3 : UInt; static var F4 : UInt; static var F5 : UInt; static var F6 : UInt; static var F7 : UInt; static var F8 : UInt; static var F9 : UInt; @:require(flash10_2) static var FAST_FORWARD : UInt; @:require(flash10_1) static var G : UInt; @:require(flash10_2) static var GREEN : UInt; @:require(flash10_2) static var GUIDE : UInt; @:require(flash10_1) static var H : UInt; @:require(flash10_2) static var HELP : UInt; static var HOME : UInt; @:require(flash10_1) static var I : UInt; @:require(flash10_2) static var INFO : UInt; @:require(flash10_2) static var INPUT : UInt; static var INSERT : UInt; @:require(flash10_1) static var J : UInt; @:require(flash10_1) static var K : UInt; @:require(flash10_1) static var KEYNAME_BEGIN : String; @:require(flash10_1) static var KEYNAME_BREAK : String; @:require(flash10_1) static var KEYNAME_CLEARDISPLAY : String; @:require(flash10_1) static var KEYNAME_CLEARLINE : String; @:require(flash10_1) static var KEYNAME_DELETE : String; @:require(flash10_1) static var KEYNAME_DELETECHAR : String; @:require(flash10_1) static var KEYNAME_DELETELINE : String; @:require(flash10_1) static var KEYNAME_DOWNARROW : String; @:require(flash10_1) static var KEYNAME_END : String; @:require(flash10_1) static var KEYNAME_EXECUTE : String; @:require(flash10_1) static var KEYNAME_F1 : String; @:require(flash10_1) static var KEYNAME_F10 : String; @:require(flash10_1) static var KEYNAME_F11 : String; @:require(flash10_1) static var KEYNAME_F12 : String; @:require(flash10_1) static var KEYNAME_F13 : String; @:require(flash10_1) static var KEYNAME_F14 : String; @:require(flash10_1) static var KEYNAME_F15 : String; @:require(flash10_1) static var KEYNAME_F16 : String; @:require(flash10_1) static var KEYNAME_F17 : String; @:require(flash10_1) static var KEYNAME_F18 : String; @:require(flash10_1) static var KEYNAME_F19 : String; @:require(flash10_1) static var KEYNAME_F2 : String; @:require(flash10_1) static var KEYNAME_F20 : String; @:require(flash10_1) static var KEYNAME_F21 : String; @:require(flash10_1) static var KEYNAME_F22 : String; @:require(flash10_1) static var KEYNAME_F23 : String; @:require(flash10_1) static var KEYNAME_F24 : String; @:require(flash10_1) static var KEYNAME_F25 : String; @:require(flash10_1) static var KEYNAME_F26 : String; @:require(flash10_1) static var KEYNAME_F27 : String; @:require(flash10_1) static var KEYNAME_F28 : String; @:require(flash10_1) static var KEYNAME_F29 : String; @:require(flash10_1) static var KEYNAME_F3 : String; @:require(flash10_1) static var KEYNAME_F30 : String; @:require(flash10_1) static var KEYNAME_F31 : String; @:require(flash10_1) static var KEYNAME_F32 : String; @:require(flash10_1) static var KEYNAME_F33 : String; @:require(flash10_1) static var KEYNAME_F34 : String; @:require(flash10_1) static var KEYNAME_F35 : String; @:require(flash10_1) static var KEYNAME_F4 : String; @:require(flash10_1) static var KEYNAME_F5 : String; @:require(flash10_1) static var KEYNAME_F6 : String; @:require(flash10_1) static var KEYNAME_F7 : String; @:require(flash10_1) static var KEYNAME_F8 : String; @:require(flash10_1) static var KEYNAME_F9 : String; @:require(flash10_1) static var KEYNAME_FIND : String; @:require(flash10_1) static var KEYNAME_HELP : String; @:require(flash10_1) static var KEYNAME_HOME : String; @:require(flash10_1) static var KEYNAME_INSERT : String; @:require(flash10_1) static var KEYNAME_INSERTCHAR : String; @:require(flash10_1) static var KEYNAME_INSERTLINE : String; @:require(flash10_1) static var KEYNAME_LEFTARROW : String; @:require(flash10_1) static var KEYNAME_MENU : String; @:require(flash10_1) static var KEYNAME_MODESWITCH : String; @:require(flash10_1) static var KEYNAME_NEXT : String; @:require(flash10_1) static var KEYNAME_PAGEDOWN : String; @:require(flash10_1) static var KEYNAME_PAGEUP : String; @:require(flash10_1) static var KEYNAME_PAUSE : String; @:require(flash10_1) static var KEYNAME_PREV : String; @:require(flash10_1) static var KEYNAME_PRINT : String; @:require(flash10_1) static var KEYNAME_PRINTSCREEN : String; @:require(flash10_1) static var KEYNAME_REDO : String; @:require(flash10_1) static var KEYNAME_RESET : String; @:require(flash10_1) static var KEYNAME_RIGHTARROW : String; @:require(flash10_1) static var KEYNAME_SCROLLLOCK : String; @:require(flash10_1) static var KEYNAME_SELECT : String; @:require(flash10_1) static var KEYNAME_STOP : String; @:require(flash10_1) static var KEYNAME_SYSREQ : String; @:require(flash10_1) static var KEYNAME_SYSTEM : String; @:require(flash10_1) static var KEYNAME_UNDO : String; @:require(flash10_1) static var KEYNAME_UPARROW : String; @:require(flash10_1) static var KEYNAME_USER : String; @:require(flash10_1) static var L : UInt; @:require(flash10_2) static var LAST : UInt; static var LEFT : UInt; @:require(flash10_1) static var LEFTBRACKET : UInt; @:require(flash10_2) static var LIVE : UInt; @:require(flash10_1) static var M : UInt; @:require(flash10_2) static var MASTER_SHELL : UInt; @:require(flash10_2) static var MENU : UInt; @:require(flash10_1) static var MINUS : UInt; @:require(flash10_1) static var N : UInt; @:require(flash10_2) static var NEXT : UInt; @:require(flash10_1) static var NUMBER_0 : UInt; @:require(flash10_1) static var NUMBER_1 : UInt; @:require(flash10_1) static var NUMBER_2 : UInt; @:require(flash10_1) static var NUMBER_3 : UInt; @:require(flash10_1) static var NUMBER_4 : UInt; @:require(flash10_1) static var NUMBER_5 : UInt; @:require(flash10_1) static var NUMBER_6 : UInt; @:require(flash10_1) static var NUMBER_7 : UInt; @:require(flash10_1) static var NUMBER_8 : UInt; @:require(flash10_1) static var NUMBER_9 : UInt; @:require(flash10_1) static var NUMPAD : UInt; static var NUMPAD_0 : UInt; static var NUMPAD_1 : UInt; static var NUMPAD_2 : UInt; static var NUMPAD_3 : UInt; static var NUMPAD_4 : UInt; static var NUMPAD_5 : UInt; static var NUMPAD_6 : UInt; static var NUMPAD_7 : UInt; static var NUMPAD_8 : UInt; static var NUMPAD_9 : UInt; static var NUMPAD_ADD : UInt; static var NUMPAD_DECIMAL : UInt; static var NUMPAD_DIVIDE : UInt; static var NUMPAD_ENTER : UInt; static var NUMPAD_MULTIPLY : UInt; static var NUMPAD_SUBTRACT : UInt; @:require(flash10_1) static var O : UInt; @:require(flash10_1) static var P : UInt; static var PAGE_DOWN : UInt; static var PAGE_UP : UInt; @:require(flash10_2) static var PAUSE : UInt; @:require(flash10_1) static var PERIOD : UInt; @:require(flash10_2) static var PLAY : UInt; @:require(flash10_2) static var PREVIOUS : UInt; @:require(flash10_1) static var Q : UInt; @:require(flash10_1) static var QUOTE : UInt; @:require(flash10_1) static var R : UInt; @:require(flash10_2) static var RECORD : UInt; @:require(flash10_2) static var RED : UInt; @:require(flash10_2) static var REWIND : UInt; static var RIGHT : UInt; @:require(flash10_1) static var RIGHTBRACKET : UInt; @:require(flash10_1) static var S : UInt; @:require(flash10_2) static var SEARCH : UInt; @:require(flash10_1) static var SEMICOLON : UInt; @:require(flash10_2) static var SETUP : UInt; static var SHIFT : UInt; @:require(flash10_2) static var SKIP_BACKWARD : UInt; @:require(flash10_2) static var SKIP_FORWARD : UInt; @:require(flash10_1) static var SLASH : UInt; static var SPACE : UInt; @:require(flash10_2) static var STOP : UInt; @:require(flash10_1) static var STRING_BEGIN : String; @:require(flash10_1) static var STRING_BREAK : String; @:require(flash10_1) static var STRING_CLEARDISPLAY : String; @:require(flash10_1) static var STRING_CLEARLINE : String; @:require(flash10_1) static var STRING_DELETE : String; @:require(flash10_1) static var STRING_DELETECHAR : String; @:require(flash10_1) static var STRING_DELETELINE : String; @:require(flash10_1) static var STRING_DOWNARROW : String; @:require(flash10_1) static var STRING_END : String; @:require(flash10_1) static var STRING_EXECUTE : String; @:require(flash10_1) static var STRING_F1 : String; @:require(flash10_1) static var STRING_F10 : String; @:require(flash10_1) static var STRING_F11 : String; @:require(flash10_1) static var STRING_F12 : String; @:require(flash10_1) static var STRING_F13 : String; @:require(flash10_1) static var STRING_F14 : String; @:require(flash10_1) static var STRING_F15 : String; @:require(flash10_1) static var STRING_F16 : String; @:require(flash10_1) static var STRING_F17 : String; @:require(flash10_1) static var STRING_F18 : String; @:require(flash10_1) static var STRING_F19 : String; @:require(flash10_1) static var STRING_F2 : String; @:require(flash10_1) static var STRING_F20 : String; @:require(flash10_1) static var STRING_F21 : String; @:require(flash10_1) static var STRING_F22 : String; @:require(flash10_1) static var STRING_F23 : String; @:require(flash10_1) static var STRING_F24 : String; @:require(flash10_1) static var STRING_F25 : String; @:require(flash10_1) static var STRING_F26 : String; @:require(flash10_1) static var STRING_F27 : String; @:require(flash10_1) static var STRING_F28 : String; @:require(flash10_1) static var STRING_F29 : String; @:require(flash10_1) static var STRING_F3 : String; @:require(flash10_1) static var STRING_F30 : String; @:require(flash10_1) static var STRING_F31 : String; @:require(flash10_1) static var STRING_F32 : String; @:require(flash10_1) static var STRING_F33 : String; @:require(flash10_1) static var STRING_F34 : String; @:require(flash10_1) static var STRING_F35 : String; @:require(flash10_1) static var STRING_F4 : String; @:require(flash10_1) static var STRING_F5 : String; @:require(flash10_1) static var STRING_F6 : String; @:require(flash10_1) static var STRING_F7 : String; @:require(flash10_1) static var STRING_F8 : String; @:require(flash10_1) static var STRING_F9 : String; @:require(flash10_1) static var STRING_FIND : String; @:require(flash10_1) static var STRING_HELP : String; @:require(flash10_1) static var STRING_HOME : String; @:require(flash10_1) static var STRING_INSERT : String; @:require(flash10_1) static var STRING_INSERTCHAR : String; @:require(flash10_1) static var STRING_INSERTLINE : String; @:require(flash10_1) static var STRING_LEFTARROW : String; @:require(flash10_1) static var STRING_MENU : String; @:require(flash10_1) static var STRING_MODESWITCH : String; @:require(flash10_1) static var STRING_NEXT : String; @:require(flash10_1) static var STRING_PAGEDOWN : String; @:require(flash10_1) static var STRING_PAGEUP : String; @:require(flash10_1) static var STRING_PAUSE : String; @:require(flash10_1) static var STRING_PREV : String; @:require(flash10_1) static var STRING_PRINT : String; @:require(flash10_1) static var STRING_PRINTSCREEN : String; @:require(flash10_1) static var STRING_REDO : String; @:require(flash10_1) static var STRING_RESET : String; @:require(flash10_1) static var STRING_RIGHTARROW : String; @:require(flash10_1) static var STRING_SCROLLLOCK : String; @:require(flash10_1) static var STRING_SELECT : String; @:require(flash10_1) static var STRING_STOP : String; @:require(flash10_1) static var STRING_SYSREQ : String; @:require(flash10_1) static var STRING_SYSTEM : String; @:require(flash10_1) static var STRING_UNDO : String; @:require(flash10_1) static var STRING_UPARROW : String; @:require(flash10_1) static var STRING_USER : String; @:require(flash10_2) static var SUBTITLE : UInt; @:require(flash10_1) static var T : UInt; static var TAB : UInt; @:require(flash10_1) static var U : UInt; static var UP : UInt; @:require(flash10_1) static var V : UInt; @:require(flash10_2) static var VOD : UInt; @:require(flash10_1) static var W : UInt; @:require(flash10_1) static var X : UInt; @:require(flash10_1) static var Y : UInt; @:require(flash10_2) static var YELLOW : UInt; @:require(flash10_1) static var Z : UInt; static var capsLock(default,null) : Bool; @:require(flash10_1) static var hasVirtualKeyboard(default,null) : Bool; static var numLock(default,null) : Bool; @:require(flash10_1) static var physicalKeyboardType(default,null) : KeyboardType; static function isAccessible() : Bool; } haxe_3.2.1+dfsg.orig/std/flash/ui/KeyboardType.hx0000664000175000017500000000014212607337712021570 0ustar andyandy00000000000000package flash.ui; @:fakeEnum(String) extern enum KeyboardType { ALPHANUMERIC; KEYPAD; NONE; } haxe_3.2.1+dfsg.orig/std/flash/ui/Mouse.hx0000664000175000017500000000073512607337712020266 0ustar andyandy00000000000000package flash.ui; extern class Mouse { @:require(flash10) static var cursor : Dynamic; @:require(flash10_1) static var supportsCursor(default,null) : Bool; @:require(flash11) static var supportsNativeCursor(default,null) : Bool; static function hide() : Void; @:require(flash10_2) static function registerCursor(name : String, cursor : MouseCursorData) : Void; static function show() : Void; @:require(flash11) static function unregisterCursor(name : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/ui/MouseCursor.hx0000664000175000017500000000027312607337712021461 0ustar andyandy00000000000000package flash.ui; extern class MouseCursor { static var ARROW : String; static var AUTO : String; static var BUTTON : String; static var HAND : String; static var IBEAM : String; } haxe_3.2.1+dfsg.orig/std/flash/ui/MouseCursorData.hx0000664000175000017500000000032612607337712022252 0ustar andyandy00000000000000package flash.ui; @:final @:require(flash10_2) extern class MouseCursorData { var data : flash.Vector; var frameRate : Float; var hotSpot : flash.geom.Point; function new() : Void; } haxe_3.2.1+dfsg.orig/std/flash/ui/Multitouch.hx0000664000175000017500000000056712607337712021336 0ustar andyandy00000000000000package flash.ui; @:require(flash10_1) extern class Multitouch { static var inputMode : MultitouchInputMode; static var mapTouchToMouse : Bool; static var maxTouchPoints(default,null) : Int; static var supportedGestures(default,null) : flash.Vector; static var supportsGestureEvents(default,null) : Bool; static var supportsTouchEvents(default,null) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/ui/MultitouchInputMode.hx0000664000175000017500000000017612607337712023157 0ustar andyandy00000000000000package flash.ui; @:fakeEnum(String) @:require(flash10_1) extern enum MultitouchInputMode { GESTURE; NONE; TOUCH_POINT; } haxe_3.2.1+dfsg.orig/std/flash/utils/ByteArray.hx0000664000175000017500000000376612607337712021632 0ustar andyandy00000000000000package flash.utils; extern class ByteArray implements IDataOutput2 implements IDataInput2 implements ArrayAccess { var bytesAvailable(default,null) : UInt; var endian : Endian; var length : UInt; var objectEncoding : UInt; var position : UInt; @:require(flash11_4) var shareable : Bool; function new() : Void; @:require(flash11_4) function atomicCompareAndSwapIntAt(byteIndex : Int, expectedValue : Int, newValue : Int) : Int; @:require(flash11_4) function atomicCompareAndSwapLength(expectedLength : Int, newLength : Int) : Int; @:require(flash10) function clear() : Void; function compress(?algorithm : CompressionAlgorithm) : Void; @:require(flash10) function deflate() : Void; @:require(flash10) function inflate() : Void; function readBoolean() : Bool; function readByte() : Int; function readBytes(bytes : ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function readDouble() : Float; function readFloat() : Float; function readInt() : Int; function readMultiByte(length : UInt, charSet : String) : String; function readObject() : Dynamic; function readShort() : Int; function readUTF() : String; function readUTFBytes(length : UInt) : String; function readUnsignedByte() : UInt; function readUnsignedInt() : UInt; function readUnsignedShort() : UInt; function toString() : String; function uncompress(?algorithm : CompressionAlgorithm) : Void; function writeBoolean(value : Bool) : Void; function writeByte(value : Int) : Void; function writeBytes(bytes : ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function writeDouble(value : Float) : Void; function writeFloat(value : Float) : Void; function writeInt(value : Int) : Void; function writeMultiByte(value : String, charSet : String) : Void; function writeObject(object : Dynamic) : Void; function writeShort(value : Int) : Void; function writeUTF(value : String) : Void; function writeUTFBytes(value : String) : Void; function writeUnsignedInt(value : UInt) : Void; static var defaultObjectEncoding : UInt; } haxe_3.2.1+dfsg.orig/std/flash/utils/CompressionAlgorithm.hx0000664000175000017500000000017112607337712024063 0ustar andyandy00000000000000package flash.utils; @:fakeEnum(String) @:require(flash11) extern enum CompressionAlgorithm { DEFLATE; LZMA; ZLIB; } haxe_3.2.1+dfsg.orig/std/flash/utils/Dictionary.hx0000664000175000017500000000016412607337712022022 0ustar andyandy00000000000000package flash.utils; extern class Dictionary implements Dynamic { function new(weakKeys : Bool = false) : Void; } haxe_3.2.1+dfsg.orig/std/flash/utils/Endian.hx0000664000175000017500000000013512607337712021111 0ustar andyandy00000000000000package flash.utils; @:fakeEnum(String) extern enum Endian { BIG_ENDIAN; LITTLE_ENDIAN; } haxe_3.2.1+dfsg.orig/std/flash/utils/Function.hx0000664000175000017500000000006112607337712021476 0ustar andyandy00000000000000package flash.utils; typedef Function = Dynamic haxe_3.2.1+dfsg.orig/std/flash/utils/IDataInput.hx0000664000175000017500000000127412607337712021722 0ustar andyandy00000000000000package flash.utils; extern interface IDataInput { var bytesAvailable(default,null) : UInt; var endian : Endian; var objectEncoding : UInt; function readBoolean() : Bool; function readByte() : Int; function readBytes(bytes : ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function readDouble() : Float; function readFloat() : Float; function readInt() : Int; function readMultiByte(length : UInt, charSet : String) : String; function readObject() : Dynamic; function readShort() : Int; function readUTF() : String; function readUTFBytes(length : UInt) : String; function readUnsignedByte() : UInt; function readUnsignedInt() : UInt; function readUnsignedShort() : UInt; } haxe_3.2.1+dfsg.orig/std/flash/utils/IDataInput2.hx0000664000175000017500000000011212607337712021772 0ustar andyandy00000000000000package flash.utils; extern interface IDataInput2 extends IDataInput { } haxe_3.2.1+dfsg.orig/std/flash/utils/IDataOutput.hx0000664000175000017500000000127712607337712022126 0ustar andyandy00000000000000package flash.utils; extern interface IDataOutput { var endian : Endian; var objectEncoding : UInt; function writeBoolean(value : Bool) : Void; function writeByte(value : Int) : Void; function writeBytes(bytes : ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function writeDouble(value : Float) : Void; function writeFloat(value : Float) : Void; function writeInt(value : Int) : Void; function writeMultiByte(value : String, charSet : String) : Void; function writeObject(object : Dynamic) : Void; function writeShort(value : Int) : Void; function writeUTF(value : String) : Void; function writeUTFBytes(value : String) : Void; function writeUnsignedInt(value : UInt) : Void; } haxe_3.2.1+dfsg.orig/std/flash/utils/IDataOutput2.hx0000664000175000017500000000011412607337712022175 0ustar andyandy00000000000000package flash.utils; extern interface IDataOutput2 extends IDataOutput { } haxe_3.2.1+dfsg.orig/std/flash/utils/IExternalizable.hx0000664000175000017500000000024412607337712022776 0ustar andyandy00000000000000package flash.utils; extern interface IExternalizable { function readExternal(input : IDataInput) : Void; function writeExternal(output : IDataOutput) : Void; } haxe_3.2.1+dfsg.orig/std/flash/utils/JSON.hx0000664000175000017500000000036212607337712020466 0ustar andyandy00000000000000package flash.utils; @:native("JSON") @:require(flash11) extern class JSON { static function parse(text : String, ?reviver : Dynamic) : Dynamic; static function stringify(value : Dynamic, ?replacer : Dynamic, ?space : Dynamic) : String; } haxe_3.2.1+dfsg.orig/std/flash/utils/Namespace.hx0000664000175000017500000000027012607337712021607 0ustar andyandy00000000000000package flash.utils; @:final extern class Namespace { var prefix(default,null) : Dynamic; var uri(default,null) : String; function new(?prefix : Dynamic, ?uri : Dynamic) : Void; } haxe_3.2.1+dfsg.orig/std/flash/utils/Object.hx0000664000175000017500000000005712607337712021124 0ustar andyandy00000000000000package flash.utils; typedef Object = Dynamic haxe_3.2.1+dfsg.orig/std/flash/utils/ObjectInput.hx0000664000175000017500000000134712607337712022147 0ustar andyandy00000000000000package flash.utils; extern class ObjectInput implements IDataInput { var bytesAvailable(default,null) : UInt; var endian : Endian; var objectEncoding : UInt; function new() : Void; function readBoolean() : Bool; function readByte() : Int; function readBytes(bytes : ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function readDouble() : Float; function readFloat() : Float; function readInt() : Int; function readMultiByte(length : UInt, charSet : String) : String; function readObject() : Dynamic; function readShort() : Int; function readUTF() : String; function readUTFBytes(length : UInt) : String; function readUnsignedByte() : UInt; function readUnsignedInt() : UInt; function readUnsignedShort() : UInt; } haxe_3.2.1+dfsg.orig/std/flash/utils/ObjectOutput.hx0000664000175000017500000000135312607337712022345 0ustar andyandy00000000000000package flash.utils; extern class ObjectOutput implements IDataOutput { var endian : Endian; var objectEncoding : UInt; function new() : Void; function writeBoolean(value : Bool) : Void; function writeByte(value : Int) : Void; function writeBytes(bytes : ByteArray, offset : UInt = 0, length : UInt = 0) : Void; function writeDouble(value : Float) : Void; function writeFloat(value : Float) : Void; function writeInt(value : Int) : Void; function writeMultiByte(value : String, charSet : String) : Void; function writeObject(object : Dynamic) : Void; function writeShort(value : Int) : Void; function writeUTF(value : String) : Void; function writeUTFBytes(value : String) : Void; function writeUnsignedInt(value : UInt) : Void; } haxe_3.2.1+dfsg.orig/std/flash/utils/Proxy.hx0000664000175000017500000000230312607337712021033 0ustar andyandy00000000000000package flash.utils; extern class Proxy { function new() : Void; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function callProperty(name : Dynamic, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic) : Dynamic; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function deleteProperty(name : Dynamic) : Bool; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function getDescendants(name : Dynamic) : Dynamic; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function getProperty(name : Dynamic) : Dynamic; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function hasProperty(name : Dynamic) : Bool; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function isAttribute(name : Dynamic) : Bool; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function nextName(index : Int) : String; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function nextNameIndex(index : Int) : Int; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function nextValue(index : Int) : Dynamic; @:ns("http://www.adobe.com/2006/actionscript/flash/proxy") function setProperty(name : Dynamic, value : Dynamic) : Void; } haxe_3.2.1+dfsg.orig/std/flash/utils/QName.hx0000664000175000017500000000027312607337712020717 0ustar andyandy00000000000000package flash.utils; @:final extern class QName { var localName(default,null) : String; var uri(default,null) : Dynamic; function new(?namespace : Dynamic, ?name : Dynamic) : Void; } haxe_3.2.1+dfsg.orig/std/flash/utils/RegExp.hx0000664000175000017500000000103612607337712021106 0ustar andyandy00000000000000package flash.utils; @:native("RegExp") extern class RegExp implements Dynamic { var dotall(default,null) : Bool; var extended(default,null) : Bool; var global(default,null) : Bool; var ignoreCase(default,null) : Bool; var lastIndex : Int; var multiline(default,null) : Bool; var source(default,null) : String; function new(?pattern : Dynamic, ?options : Dynamic) : Void; @:ns("http://adobe.com/AS3/2006/builtin") function exec(?s : String) : Dynamic; @:ns("http://adobe.com/AS3/2006/builtin") function test(?s : String) : Bool; } haxe_3.2.1+dfsg.orig/std/flash/utils/SetIntervalTimer.hx0000664000175000017500000000037012607337712023155 0ustar andyandy00000000000000package flash.utils; @:final extern class SetIntervalTimer extends Timer { var id : UInt; function new(closure : Dynamic, delay : Float, repeats : Bool, rest : Array) : Void; static function clearInterval(id_to_clear : UInt) : Void; } haxe_3.2.1+dfsg.orig/std/flash/utils/Telemetry.hx0000664000175000017500000000103612607337712021666 0ustar andyandy00000000000000package flash.utils; @:require(flash11_4) @:native("flash.profiler.Telemetry") extern class Telemetry extends flash.events.EventDispatcher { static var connected(default,null) : Bool; static var spanMarker(default,null) : Float; static function registerCommandHandler(commandName : String, handler : Dynamic) : Bool; static function unregisterCommandHandler(commandName : String) : Bool; static function sendMetric(metric : String, value : Dynamic) : Void; static function sendSpanMetric(metric : String, startMarker : Float) : Void; }haxe_3.2.1+dfsg.orig/std/flash/utils/Timer.hx0000664000175000017500000000052112607337712020772 0ustar andyandy00000000000000package flash.utils; extern class Timer extends flash.events.EventDispatcher { var currentCount(default,null) : Int; var delay : Float; var repeatCount : Int; var running(default,null) : Bool; function new(delay : Float, repeatCount : Int = 0) : Void; function reset() : Void; function start() : Void; function stop() : Void; } haxe_3.2.1+dfsg.orig/std/flash/xml/XML.hx0000664000175000017500000000422412607337712020016 0ustar andyandy00000000000000package flash.xml; @:final extern class XML implements Dynamic { function new(?value : Dynamic) : Void; function addNamespace(ns : Dynamic) : XML; function appendChild(child : Dynamic) : XML; function attribute(arg : Dynamic) : XMLList; function attributes() : XMLList; function child(propertyName : Dynamic) : XMLList; function childIndex() : Int; function children() : XMLList; function comments() : XMLList; function contains(value : Dynamic) : Bool; function copy() : XML; function descendants(?name : Dynamic) : XMLList; function elements(?name : Dynamic) : XMLList; function hasComplexContent() : Bool; function hasSimpleContent() : Bool; function inScopeNamespaces() : Array; function insertChildAfter(child1 : Dynamic, child2 : Dynamic) : Dynamic; function insertChildBefore(child1 : Dynamic, child2 : Dynamic) : Dynamic; function length() : Int; function localName() : flash.utils.Object; function name() : flash.utils.Object; function namespace(?prefix : Dynamic) : flash.utils.Namespace; function namespaceDeclarations() : Array; function nodeKind() : String; function normalize() : XML; function notification() : flash.utils.Function; function parent() : XML; function prependChild(value : Dynamic) : XML; function processingInstructions(?name : Dynamic) : XMLList; function removeNamespace(ns : Dynamic) : XML; function replace(propertyName : Dynamic, value : Dynamic) : XML; function setChildren(value : Dynamic) : XML; function setLocalName(name : Dynamic) : Void; function setName(name : Dynamic) : Void; function setNamespace(ns : Dynamic) : Void; function setNotification(f : flash.utils.Function) : Dynamic; function text() : XMLList; @:require(flash11) function toJSON(k : String) : Dynamic; function toString() : String; function toXMLString() : String; function valueOf() : XML; static var ignoreComments : Bool; static var ignoreProcessingInstructions : Bool; static var ignoreWhitespace : Bool; static var prettyIndent : Int; static var prettyPrinting : Bool; static function defaultSettings() : Dynamic; static function setSettings(?o : Dynamic) : Void; static function settings() : Dynamic; } haxe_3.2.1+dfsg.orig/std/flash/xml/XMLDocument.hx0000664000175000017500000000053512607337712021516 0ustar andyandy00000000000000package flash.xml; extern class XMLDocument extends XMLNode { var docTypeDecl : Dynamic; var idMap : Dynamic; var ignoreWhite : Bool; var xmlDecl : Dynamic; function new(?source : String) : Void; function createElement(name : String) : XMLNode; function createTextNode(text : String) : XMLNode; function parseXML(source : String) : Void; } haxe_3.2.1+dfsg.orig/std/flash/xml/XMLList.hx0000664000175000017500000000336012607337712020652 0ustar andyandy00000000000000package flash.xml; @:final extern class XMLList implements ArrayAccess { function new(?value : Dynamic) : Void; function addNamespace(ns : Dynamic) : XML; function appendChild(child : Dynamic) : XML; function attribute(arg : Dynamic) : XMLList; function attributes() : XMLList; function child(propertyName : Dynamic) : XMLList; function childIndex() : Int; function children() : XMLList; function comments() : XMLList; function contains(value : Dynamic) : Bool; function copy() : XMLList; function descendants(?name : Dynamic) : XMLList; function elements(?name : Dynamic) : XMLList; function hasComplexContent() : Bool; function hasSimpleContent() : Bool; function inScopeNamespaces() : Array; function insertChildAfter(child1 : Dynamic, child2 : Dynamic) : Dynamic; function insertChildBefore(child1 : Dynamic, child2 : Dynamic) : Dynamic; function length() : Int; function localName() : flash.utils.Object; function name() : flash.utils.Object; function namespace(?prefix : Dynamic) : flash.utils.Namespace; function namespaceDeclarations() : Array; function nodeKind() : String; function normalize() : XMLList; function parent() : XML; function prependChild(value : Dynamic) : XML; function processingInstructions(?name : Dynamic) : XMLList; function removeNamespace(ns : Dynamic) : XML; function replace(propertyName : Dynamic, value : Dynamic) : XML; function setChildren(value : Dynamic) : XML; function setLocalName(name : Dynamic) : Void; function setName(name : Dynamic) : Void; function setNamespace(ns : Dynamic) : Void; function text() : XMLList; @:require(flash11) function toJSON(k : String) : Dynamic; function toString() : String; function toXMLString() : String; function valueOf() : XMLList; } haxe_3.2.1+dfsg.orig/std/flash/xml/XMLNode.hx0000664000175000017500000000155612607337712020631 0ustar andyandy00000000000000package flash.xml; extern class XMLNode { var attributes : Dynamic; var childNodes(default,null) : Array; var firstChild : XMLNode; var lastChild : XMLNode; var localName(default,null) : String; var namespaceURI(default,null) : String; var nextSibling : XMLNode; var nodeName : String; var nodeType : XMLNodeType; var nodeValue : String; var parentNode : XMLNode; var prefix(default,null) : String; var previousSibling : XMLNode; function new(type : XMLNodeType, value : String) : Void; function appendChild(node : XMLNode) : Void; function cloneNode(deep : Bool) : XMLNode; function getNamespaceForPrefix(prefix : String) : String; function getPrefixForNamespace(ns : String) : String; function hasChildNodes() : Bool; function insertBefore(node : XMLNode, before : XMLNode) : Void; function removeNode() : Void; function toString() : String; } haxe_3.2.1+dfsg.orig/std/flash/xml/XMLNodeType.hx0000664000175000017500000000027512607337712021470 0ustar andyandy00000000000000package flash.xml; @:fakeEnum(UInt) extern enum XMLNodeType { CDATA_NODE; COMMENT_NODE; DOCUMENT_TYPE_NODE; ELEMENT_NODE; PROCESSING_INSTRUCTION_NODE; TEXT_NODE; XML_DECLARATION; } haxe_3.2.1+dfsg.orig/std/flash/xml/XMLParser.hx0000664000175000017500000000027012607337712021170 0ustar andyandy00000000000000package flash.xml; @:final extern class XMLParser { function new() : Void; function getNext(tag : XMLTag) : Int; function startParse(source : String, ignoreWhite : Bool) : Void; } haxe_3.2.1+dfsg.orig/std/flash/xml/XMLTag.hx0000664000175000017500000000024312607337712020447 0ustar andyandy00000000000000package flash.xml; @:final extern class XMLTag { var attrs : Dynamic; var empty : Bool; var type : XMLNodeType; var value : String; function new() : Void; } haxe_3.2.1+dfsg.orig/std/haxe/CallStack.hx0000664000175000017500000002360312607337712020251 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** Elements return by `CallStack` methods. **/ enum StackItem { CFunction; Module( m : String ); FilePos( s : Null, file : String, line : Int ); Method( classname : String, method : String ); LocalFunction( ?v : Int ); } /** Get informations about the call stack. **/ class CallStack { #if js static var lastException:js.Error; static function getStack(e:js.Error):Array { if (e == null) return []; // https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi var oldValue = (untyped Error).prepareStackTrace; (untyped Error).prepareStackTrace = function (error, callsites :Array) { var stack = []; for (site in callsites) { if (wrapCallSite != null) site = wrapCallSite(site); var method = null; var fullName :String = site.getFunctionName(); if (fullName != null) { var idx = fullName.lastIndexOf("."); if (idx >= 0) { var className = fullName.substr(0, idx); var methodName = fullName.substr(idx+1); method = Method(className, methodName); } } stack.push(FilePos(method, site.getFileName(), site.getLineNumber())); } return stack; } var a = makeStack(e.stack); (untyped Error).prepareStackTrace = oldValue; return a; } // support for source-map-support module @:noCompletion public static var wrapCallSite:Dynamic->Dynamic; #end /** Return the call stack elements, or an empty array if not available. **/ public static function callStack() : Array { #if neko var a = makeStack(untyped __dollar__callstack()); a.shift(); // remove Stack.callStack() return a; #elseif flash var a = makeStack( new flash.errors.Error().getStackTrace() ); a.shift(); // remove Stack.callStack() return a; #elseif php return makeStack("%s"); #elseif cpp var s:Array = untyped __global__.__hxcpp_get_call_stack(true); return makeStack(s); #elseif js try { throw new js.Error(); } catch( e : Dynamic ) { var a = getStack(e); a.shift(); // remove Stack.callStack() return a; } #elseif java var stack = []; for ( el in java.lang.Thread.currentThread().getStackTrace() ) { var className = el.getClassName(); var methodName = el.getMethodName(); var fileName = el.getFileName(); var lineNumber = el.getLineNumber(); var method = Method( className, methodName ); if ( fileName != null || lineNumber >= 0 ) { stack.push( FilePos( method, fileName, lineNumber ) ); } else { stack.push( method ); } } stack.shift(); stack.shift(); stack.pop(); return stack; #elseif cs return makeStack(new cs.system.diagnostics.StackTrace(1, true)); #elseif python var stack = []; var infos = python.lib.Traceback.extract_stack(); infos.pop(); infos.reverse(); for (elem in infos) stack.push(FilePos(null, elem._1, elem._2)); return stack; #else return []; // Unsupported #end } /** Return the exception stack : this is the stack elements between the place the last exception was thrown and the place it was caught, or an empty array if not available. **/ #if cpp @:noStack #end /* Do not mess up the exception stack */ public static function exceptionStack() : Array { #if neko return makeStack(untyped __dollar__excstack()); #elseif as3 return new Array(); #elseif flash var err : flash.errors.Error = untyped flash.Boot.lastError; if( err == null ) return new Array(); var a = makeStack( err.getStackTrace() ); var c = callStack(); var i = c.length - 1; while( i > 0 ) { if( Std.string(a[a.length-1]) == Std.string(c[i]) ) a.pop(); else break; i--; } return a; #elseif php return makeStack("%e"); #elseif cpp var s:Array = untyped __global__.__hxcpp_get_exception_stack(); return makeStack(s); #elseif java var stack = []; for ( el in java.internal.Exceptions.currentException().getStackTrace() ) { var className = el.getClassName(); var methodName = el.getMethodName(); var fileName = el.getFileName(); var lineNumber = el.getLineNumber(); var method = Method( className, methodName ); if ( fileName != null || lineNumber >= 0 ) { stack.push( FilePos( method, fileName, lineNumber ) ); } else { stack.push( method ); } } // stack.shift(); stack.shift(); stack.pop(); return stack; #elseif cs return makeStack(new cs.system.diagnostics.StackTrace(cs.internal.Exceptions.exception, true)); #elseif python var stack = []; var exc = python.lib.Sys.exc_info(); if (exc._3 != null) { var infos = python.lib.Traceback.extract_tb(exc._3); infos.reverse(); for (elem in infos) stack.push(FilePos(null, elem._1, elem._2)); } return stack; #elseif js return untyped __define_feature__("haxe.CallStack.exceptionStack", getStack(lastException)); #else return []; // Unsupported #end } /** Returns a representation of the stack as a printable string. **/ public static function toString( stack : Array ) { var b = new StringBuf(); for( s in stack ) { b.add("\nCalled from "); itemToString(b,s); } return b.toString(); } private static function itemToString( b : StringBuf, s ) { switch( s ) { case CFunction: b.add("a C function"); case Module(m): b.add("module "); b.add(m); case FilePos(s,file,line): if( s != null ) { itemToString(b,s); b.add(" ("); } b.add(file); b.add(" line "); b.add(line); if( s != null ) b.add(")"); case Method(cname,meth): b.add(cname); b.add("."); b.add(meth); case LocalFunction(n): b.add("local function #"); b.add(n); } } #if cpp @:noStack #end /* Do not mess up the exception stack */ private static function makeStack(s #if cs : cs.system.diagnostics.StackTrace #end) { #if neko var a = new Array(); var l = untyped __dollar__asize(s); var i = 0; while( i < l ) { var x = s[i++]; if( x == null ) a.unshift(CFunction); else if( untyped __dollar__typeof(x) == __dollar__tstring ) a.unshift(Module(new String(x))); else a.unshift(FilePos(null,new String(untyped x[0]),untyped x[1])); } return a; #elseif flash var a = new Array(); var r = ~/at ([^\/]+?)\$?(\/[^\(]+)?\(\)(\[(.*?):([0-9]+)\])?/; var rlambda = ~/^MethodInfo-([0-9]+)$/g; while( r.match(s) ) { var cl = r.matched(1).split("::").join("."); var meth = r.matched(2); var item; if( meth == null ) { if( rlambda.match(cl) ) item = LocalFunction(Std.parseInt(rlambda.matched(1))); else item = Method(cl,"new"); } else item = Method(cl,meth.substr(1)); if( r.matched(3) != null ) item = FilePos( item, r.matched(4), Std.parseInt(r.matched(5)) ); a.push(item); s = r.matchedRight(); } return a; #elseif php if (!untyped __call__("isset", __var__("GLOBALS", s))) return []; var a : Array = untyped __var__("GLOBALS", s); var m = []; for( i in 0...a.length - ((s == "%s") ? 2 : 0)) { var d = a[i].split("::"); m.unshift(Method(d[0],d[1])); } return m; #elseif cpp var stack : Array = s; var m = new Array(); for(func in stack) { var words = func.split("::"); if (words.length==0) m.push(CFunction) else if (words.length==2) m.push(Method(words[0],words[1])); else if (words.length==4) m.push(FilePos( Method(words[0],words[1]),words[2],Std.parseInt(words[3]))); } return m; #elseif js if (s == null) { return []; } else if ((untyped __js__("typeof"))(s) == "string") { // Return the raw lines in browsers that don't support prepareStackTrace var stack : Array = s.split("\n"); if( stack[0] == "Error" ) stack.shift(); var m = []; var rie10 = ~/^ at ([A-Za-z0-9_. ]+) \(([^)]+):([0-9]+):([0-9]+)\)$/; for( line in stack ) { if( rie10.match(line) ) { var path = rie10.matched(1).split("."); var meth = path.pop(); var file = rie10.matched(2); var line = Std.parseInt(rie10.matched(3)); m.push(FilePos( meth == "Anonymous function" ? LocalFunction() : meth == "Global code" ? null : Method(path.join("."),meth), file, line )); } else m.push(Module(StringTools.trim(line))); // A little weird, but better than nothing } return m; } else { return cast s; } #elseif cs var stack = []; for (i in 0...s.FrameCount) { var frame = s.GetFrame(i); var m = frame.GetMethod(); var method = StackItem.Method(m.ReflectedType.ToString(), m.Name); var fileName = frame.GetFileName(); var lineNumber = frame.GetFileLineNumber(); if (fileName != null || lineNumber >= 0) stack.push(FilePos(method, fileName, lineNumber)); else stack.push(method); } return stack; #else return null; #end } } haxe_3.2.1+dfsg.orig/std/haxe/Constraints.hx0000664000175000017500000000355112607337712020717 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** This type unifies with any function type. It is intended to be used as a type parameter constraint. If used as a real type, the underlying type will be `Dynamic`. **/ @:callable abstract Function(Dynamic) { } /** This type unifies with an enum instance if all constructors of the enum require no arguments. It is intended to be used as a type parameter constraint. If used as a real type, the underlying type will be `Dynamic`. **/ abstract FlatEnum(Dynamic) { } interface IMap { public function get(k:K):Null; public function set(k:K, v:V):Void; public function exists(k:K):Bool; public function remove(k:K):Bool; public function keys():Iterator; public function iterator():Iterator; public function toString():String; }haxe_3.2.1+dfsg.orig/std/haxe/DynamicAccess.hx0000664000175000017500000000556012607337712021120 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** DynamicAccess is an abstract type for working with anonymous structures that are intended to hold collections of objects by the string key. For example, these types of structures are often created from JSON. Basically, it wraps `Reflect` calls in a `Map`-like interface. **/ abstract DynamicAccess(Dynamic) from Dynamic to Dynamic { /** Creates a new structure. **/ public inline function new() this = {}; /** Returns a value by specified `key`. If the structure does not contain the given key, null is returned. If `key` is null, the result is unspecified. **/ @:arrayAccess public inline function get(key:String):Null { #if js return untyped this[key]; // we know it's an object, so we don't need a check #else return Reflect.field(this, key); #end } /** Sets a `value` for a specified `key`. If the structure contains the given key, its value will be overwritten. Returns the given value. If `key` is null, the result is unspecified. **/ @:arrayAccess public inline function set(key:String, value:T):T { #if js return untyped this[key] = value; #else Reflect.setField(this, key, value); return value; #end } /** Tells if the structure contains a specified `key`. If `key` is null, the result is unspecified. **/ public inline function exists(key:String):Bool return Reflect.hasField(this, key); /** Removes a specified `key` from the structure. Returns true, if `key` was present in structure, or false otherwise. If `key` is null, the result is unspecified. **/ public inline function remove(key:String):Bool return Reflect.deleteField(this, key); /** Returns an array of `keys` in a structure. **/ public inline function keys():Array return Reflect.fields(this); } haxe_3.2.1+dfsg.orig/std/haxe/EnumFlags.hx0000664000175000017500000000572612607337712020277 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** A typed interface for bit flags. This is not a real object, only a typed interface for an actual Int. Each flag can be tested/set with the corresponding enum instance. Up to 32 flags can be stored that way. Enum constructor indices are preserved from haxe syntax, so the first declared is index 0, the next index 1 etc. The methods are optimized if the enum instance is passed directly, e.g. as has(EnumCtor). Otherwise Type.enumIndex() reflection is used. **/ abstract EnumFlags(Int) { /** Initializes the bitflags to `i`. **/ public inline function new(i = 0) { this = i; } /** Checks if the index of enum instance `v` is set. This method is optimized if `v` is an enum instance expression such as SomeEnum.SomeCtor. If `v` is null, the result is unspecified. **/ public inline function has( v : T ) : Bool { return this & (1 << Type.enumIndex(v)) != 0; } /** Sets the index of enum instance `v`. This method is optimized if `v` is an enum instance expression such as SomeEnum.SomeCtor. If `v` is null, the result is unspecified. **/ public inline function set( v : T ) : Void { this |= 1 << Type.enumIndex(v); } /** Unsets the index of enum instance `v`. This method is optimized if `v` is an enum instance expression such as SomeEnum.SomeCtor. If `v` is null, the result is unspecified. **/ public inline function unset( v : T ) : Void { this &= 0xFFFFFFF - (1 << Type.enumIndex(v)); } /** Convert a integer bitflag into a typed one (this is a no-op, it does not have any impact on speed). **/ public inline static function ofInt( i : Int ) : EnumFlags { return new EnumFlags(i); } /** Convert the typed bitflag into the corresponding int value (this is a no-op, it doesn't have any impact on speed). **/ public inline function toInt() : Int { return this; } } haxe_3.2.1+dfsg.orig/std/haxe/EnumTools.hx0000664000175000017500000001300012607337712020323 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; extern class EnumTools { /** Returns the name of enum `e`, including its path. If `e` is inside a package, the package structure is returned dot- separated, with another dot separating the enum name: pack1.pack2.(...).packN.EnumName If `e` is a sub-type of a haxe module, that module is not part of the package structure. If `e` has no package, the enum name is returned. If `e` is null, the result is unspecified. The enum name does not include any type parameters. **/ static public inline function getName(e:Enum):String { return Type.getEnumName(e); } /** Creates an instance of enum `e` by calling its constructor `constr` with arguments `params`. If `e` or `constr` is null, or if enum `e` has no constructor named `constr`, or if the number of elements in `params` does not match the expected number of constructor arguments, or if any argument has an invalid type, the result is unspecified. **/ static public inline function createByName(e:Enum, constr:String, ?params:Array):T { return Type.createEnum(e, constr, params); } /** Creates an instance of enum `e` by calling its constructor number `index` with arguments `params`. The constructor indices are preserved from haxe syntax, so the first declared is index 0, the next index 1 etc. If `e` or `index` is null, or if enum `e` has no constructor corresponding to index `index`, or if the number of elements in `params` does not match the expected number of constructor arguments, or if any argument has an invalid type, the result is unspecified. **/ static public inline function createByIndex(e:Enum, index:Int, ?params:Array):T { return Type.createEnumIndex(e, index, params); } /** Returns a list of all constructors of enum `e` that require no arguments. This may return the empty Array [] if all constructors of `e` require arguments. Otherwise an instance of `e` constructed through each of its non- argument constructors is returned, in the order of the constructor declaration. If `e` is null, the result is unspecified. **/ static public inline function createAll(e:Enum):Array { return Type.allEnums(e); } /** Returns a list of the names of all constructors of enum `e`. The order of the constructor names in the returned Array is preserved from the original syntax. If `c` is null, the result is unspecified. **/ static public inline function getConstructors(e:Enum):Array { return Type.getEnumConstructs(e); } } extern class EnumValueTools { /** Recursively compares two enum instances `a` and `b` by value. Unlike `a == b`, this function performs a deep equality check on the arguments of the constructors, if exists. If `a` or `b` are null, the result is unspecified. **/ static public inline function equals(a:T, b:T):Bool { return Type.enumEq(a, b); } /** Returns the constructor name of enum instance `e`. The result String does not contain any constructor arguments. If `e` is null, the result is unspecified. **/ static public inline function getName(e:EnumValue):String { return Type.enumConstructor(e); } /** Returns a list of the constructor arguments of enum instance `e`. If `e` has no arguments, the result is []. Otherwise the result are the values that were used as arguments to `e`, in the order of their declaration. If `e` is null, the result is unspecified. **/ static public inline function getParameters(e:EnumValue):Array { return Type.enumParameters(e); } /** Returns the index of enum instance `e`. This corresponds to the original syntactic position of `e`. The index of the first declared constructor is 0, the next one is 1 etc. If `e` is null, the result is unspecified. **/ static public inline function getIndex(e:EnumValue):Int { return Type.enumIndex(e); } /** Matches enum instance `e` against pattern `pattern`, returning true if matching succeeded and false otherwise. Example usage: ``` if (e.match(pattern)) { // codeIfTrue } else { // codeIfFalse } ``` This is equivalent to the following code: ``` switch (e) { case pattern: // codeIfTrue case _: // codeIfFalse } ``` This method is implemented in the compiler. This definition exists only for documentation. **/ static public function match(e:EnumValue, pattern:Dynamic):Bool { return false; } }haxe_3.2.1+dfsg.orig/std/haxe/Http.hx0000664000175000017500000005037012607337712017330 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; #if sys import sys.net.Host; import sys.net.Socket; private typedef AbstractSocket = { var input(default,null) : haxe.io.Input; var output(default,null) : haxe.io.Output; function connect( host : Host, port : Int ) : Void; function setTimeout( t : Float ) : Void; function write( str : String ) : Void; function close() : Void; function shutdown( read : Bool, write : Bool ) : Void; } #end /** This class can be used to handle Http requests consistently across platforms. There are two intended usages: - call haxe.Http.requestUrl(url) and receive the result as a String (not available on flash) - create a new haxe.Http(url), register your callbacks for onData, onError and onStatus, then call request(). **/ class Http { /** The url of `this` request. It is used only by the request() method and can be changed in order to send the same request to different target Urls. **/ public var url : String; public var responseData(default, null) : Null; #if sys public var noShutdown : Bool; public var cnxTimeout : Float; public var responseHeaders : Map; var chunk_size : Null; var chunk_buf : haxe.io.Bytes; var file : { param : String, filename : String, io : haxe.io.Input, size : Int, mimeType : String }; #elseif js public var async : Bool; #end var postData : String; var headers : List<{ header:String, value:String }>; var params : List<{ param:String, value:String }>; #if sys public static var PROXY : { host : String, port : Int, auth : { user : String, pass : String } } = null; #end /** Creates a new Http instance with `url` as parameter. This does not do a request until request() is called. If `url` is null, the field url must be set to a value before making the call to request(), or the result is unspecified. (Php) Https (SSL) connections are allowed only if the OpenSSL extension is enabled. **/ public function new( url : String ) { this.url = url; headers = new List<{ header:String, value:String }>(); params = new List<{ param:String, value:String }>(); #if js async = true; #elseif sys cnxTimeout = 10; #end #if php noShutdown = ! untyped __call__('function_exists', 'stream_socket_shutdown'); #end } /** Sets the header identified as `header` to value `value`. If `header` or `value` are null, the result is unspecified. This method provides a fluent interface. **/ public function setHeader( header : String, value : String ):Http { headers = Lambda.filter(headers, function(h) return h.header != header); headers.push({ header:header, value:value }); return this; } public function addHeader( header : String, value : String ):Http { headers.push({ header:header, value:value }); return this; } /** Sets the parameter identified as `param` to value `value`. If `header` or `value` are null, the result is unspecified. This method provides a fluent interface. **/ public function setParameter( param : String, value : String ):Http { params = Lambda.filter(params, function(p) return p.param != param); params.push({ param:param, value:value }); return this; } public function addParameter( param : String, value : String ):Http { params.push({ param:param, value:value }); return this; } /** Sets the post data of `this` Http request to `data`. There can only be one post data per request. Subsequent calls overwrite the previously set value. If `data` is null, the post data is considered to be absent. This method provides a fluent interface. **/ public function setPostData( data : String ):Http { postData = data; return this; } #if (js || flash) #if js var req:js.html.XMLHttpRequest; #elseif flash var req:flash.net.URLLoader; #end /** Cancels `this` Http request if `request` has been called and a response has not yet been received. **/ public function cancel() { if (req == null) return; #if js req.abort(); #elseif flash req.close(); #end req = null; } #end /** Sends `this` Http request to the Url specified by `this.url`. If `post` is true, the request is sent as POST request, otherwise it is sent as GET request. Depending on the outcome of the request, this method calls the onStatus(), onError() or onData() callback functions. If `this.url` is null, the result is unspecified. If `this.url` is an invalid or inaccessible Url, the onError() callback function is called. (Js) If `this.async` is false, the callback functions are called before this method returns. **/ public function request( ?post : Bool ) : Void { var me = this; #if js me.responseData = null; var r = req = js.Browser.createXMLHttpRequest(); var onreadystatechange = function(_) { if( r.readyState != 4 ) return; var s = try r.status catch( e : Dynamic ) null; if ( s != null ) { // If the request is local and we have data: assume a success (jQuery approach): var protocol = js.Browser.location.protocol.toLowerCase(); var rlocalProtocol = ~/^(?:about|app|app-storage|.+-extension|file|res|widget):$/; var isLocal = rlocalProtocol.match( protocol ); if ( isLocal ) { s = r.responseText != null ? 200 : 404; } } if( s == untyped __js__("undefined") ) s = null; if( s != null ) me.onStatus(s); if( s != null && s >= 200 && s < 400 ) { me.req = null; me.onData(me.responseData = r.responseText); } else if ( s == null ) { me.req = null; me.onError("Failed to connect or resolve host"); } else switch( s ) { case 12029: me.req = null; me.onError("Failed to connect to host"); case 12007: me.req = null; me.onError("Unknown host"); default: me.req = null; me.responseData = r.responseText; me.onError("Http Error #"+r.status); } }; if( async ) r.onreadystatechange = onreadystatechange; var uri = postData; if( uri != null ) post = true; else for( p in params ) { if( uri == null ) uri = ""; else uri += "&"; uri += StringTools.urlEncode(p.param)+"="+StringTools.urlEncode(p.value); } try { if( post ) r.open("POST",url,async); else if( uri != null ) { var question = url.split("?").length <= 1; r.open("GET",url+(if( question ) "?" else "&")+uri,async); uri = null; } else r.open("GET",url,async); } catch( e : Dynamic ) { me.req = null; onError(e.toString()); return; } if( !Lambda.exists(headers, function(h) return h.header == "Content-Type") && post && postData == null ) r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); for( h in headers ) r.setRequestHeader(h.header,h.value); r.send(uri); if( !async ) onreadystatechange(null); #elseif flash me.responseData = null; var loader = req = new flash.net.URLLoader(); loader.addEventListener( "complete", function(e) { me.req = null; me.responseData = loader.data; me.onData( loader.data ); }); loader.addEventListener( "httpStatus", function(e:flash.events.HTTPStatusEvent){ // on Firefox 1.5, Flash calls onHTTPStatus with 0 (!??) if( e.status != 0 ) me.onStatus( e.status ); }); loader.addEventListener( "ioError", function(e:flash.events.IOErrorEvent){ me.req = null; me.responseData = loader.data; me.onError(e.text); }); loader.addEventListener( "securityError", function(e:flash.events.SecurityErrorEvent){ me.req = null; me.onError(e.text); }); // headers var param = false; var vars = new flash.net.URLVariables(); for( p in params ){ param = true; Reflect.setField(vars,p.param,p.value); } var small_url = url; if( param && !post ){ var k = url.split("?"); if( k.length > 1 ) { small_url = k.shift(); vars.decode(k.join("?")); } } // Bug in flash player 9 ??? var bug = small_url.split("xxx"); var request = new flash.net.URLRequest( small_url ); for( h in headers ) request.requestHeaders.push( new flash.net.URLRequestHeader(h.header,h.value) ); if( postData != null ) { request.data = postData; request.method = "POST"; } else { request.data = vars; request.method = if( post ) "POST" else "GET"; } try { loader.load( request ); }catch( e : Dynamic ){ me.req = null; onError("Exception: "+Std.string(e)); } #elseif sys var me = this; var output = new haxe.io.BytesOutput(); var old = onError; var err = false; onError = function(e) { #if neko me.responseData = neko.Lib.stringReference(output.getBytes()); #else me.responseData = output.getBytes().toString(); #end err = true; // Resetting back onError before calling it allows for a second "retry" request to be sent without onError being wrapped twice onError = old; onError(e); } customRequest(post,output); if( !err ) #if neko me.onData(me.responseData = neko.Lib.stringReference(output.getBytes())); #else me.onData(me.responseData = output.getBytes().toString()); #end #end } #if sys /** Note: Deprecated in 4.0 **/ @:noCompletion inline public function fileTransfert( argname : String, filename : String, file : haxe.io.Input, size : Int, mimeType = "application/octet-stream" ) { fileTransfer(argname, filename, file, size, mimeType); } public function fileTransfer( argname : String, filename : String, file : haxe.io.Input, size : Int, mimeType = "application/octet-stream" ) { this.file = { param : argname, filename : filename, io : file, size : size, mimeType : mimeType }; } public function customRequest( post : Bool, api : haxe.io.Output, ?sock : AbstractSocket, ?method : String ) { this.responseData = null; var url_regexp = ~/^(https?:\/\/)?([a-zA-Z\.0-9_-]+)(:[0-9]+)?(.*)$/; if( !url_regexp.match(url) ) { onError("Invalid URL"); return; } var secure = (url_regexp.matched(1) == "https://"); if( sock == null ) { if( secure ) { #if php sock = new php.net.SslSocket(); #elseif java sock = new java.net.SslSocket(); #elseif hxssl #if neko sock = new neko.tls.Socket(); #else sock = new sys.ssl.Socket(); #end #else throw "Https is only supported with -lib hxssl"; #end } else sock = new Socket(); } var host = url_regexp.matched(2); var portString = url_regexp.matched(3); var request = url_regexp.matched(4); if( request == "" ) request = "/"; var port = if ( portString == null || portString == "" ) secure ? 443 : 80 else Std.parseInt(portString.substr(1, portString.length - 1)); var data; var multipart = (file != null); var boundary = null; var uri = null; if( multipart ) { post = true; boundary = Std.string(Std.random(1000))+Std.string(Std.random(1000))+Std.string(Std.random(1000))+Std.string(Std.random(1000)); while( boundary.length < 38 ) boundary = "-" + boundary; var b = new StringBuf(); for( p in params ) { b.add("--"); b.add(boundary); b.add("\r\n"); b.add('Content-Disposition: form-data; name="'); b.add(p.param); b.add('"'); b.add("\r\n"); b.add("\r\n"); b.add(p.value); b.add("\r\n"); } b.add("--"); b.add(boundary); b.add("\r\n"); b.add('Content-Disposition: form-data; name="'); b.add(file.param); b.add('"; filename="'); b.add(file.filename); b.add('"'); b.add("\r\n"); b.add("Content-Type: "+file.mimeType+"\r\n"+"\r\n"); uri = b.toString(); } else { for( p in params ) { if( uri == null ) uri = ""; else uri += "&"; uri += StringTools.urlEncode(p.param)+"="+StringTools.urlEncode(p.value); } } var b = new StringBuf(); if( method != null ) { b.add(method); b.add(" "); } else if( post ) b.add("POST "); else b.add("GET "); if( Http.PROXY != null ) { b.add("http://"); b.add(host); if( port != 80 ) { b.add(":"); b.add(port); } } b.add(request); if( !post && uri != null ) { if( request.indexOf("?",0) >= 0 ) b.add("&"); else b.add("?"); b.add(uri); } b.add(" HTTP/1.1\r\nHost: "+host+"\r\n"); if( postData != null ) b.add("Content-Length: "+postData.length+"\r\n"); else if( post && uri != null ) { if( multipart || !Lambda.exists(headers, function(h) return h.header == "Content-Type") ) { b.add("Content-Type: "); if( multipart ) { b.add("multipart/form-data"); b.add("; boundary="); b.add(boundary); } else b.add("application/x-www-form-urlencoded"); b.add("\r\n"); } if( multipart ) b.add("Content-Length: "+(uri.length+file.size+boundary.length+6)+"\r\n"); else b.add("Content-Length: "+uri.length+"\r\n"); } for( h in headers ) { b.add(h.header); b.add(": "); b.add(h.value); b.add("\r\n"); } b.add("\r\n"); if( postData != null) b.add(postData); else if( post && uri != null ) b.add(uri); try { if( Http.PROXY != null ) sock.connect(new Host(Http.PROXY.host),Http.PROXY.port); else sock.connect(new Host(host),port); sock.write(b.toString()); if( multipart ) { var bufsize = 4096; var buf = haxe.io.Bytes.alloc(bufsize); while( file.size > 0 ) { var size = if( file.size > bufsize ) bufsize else file.size; var len = 0; try { len = file.io.readBytes(buf,0,size); } catch( e : haxe.io.Eof ) break; sock.output.writeFullBytes(buf,0,len); file.size -= len; } sock.write("\r\n"); sock.write("--"); sock.write(boundary); sock.write("--"); } readHttpResponse(api,sock); sock.close(); } catch( e : Dynamic ) { try sock.close() catch( e : Dynamic ) { }; onError(Std.string(e)); } } function readHttpResponse( api : haxe.io.Output, sock : AbstractSocket ) { // READ the HTTP header (until \r\n\r\n) var b = new haxe.io.BytesBuffer(); var k = 4; var s = haxe.io.Bytes.alloc(4); sock.setTimeout(cnxTimeout); while( true ) { var p = sock.input.readBytes(s,0,k); while( p != k ) p += sock.input.readBytes(s,p,k - p); b.addBytes(s,0,k); switch( k ) { case 1: var c = s.get(0); if( c == 10 ) break; if( c == 13 ) k = 3; else k = 4; case 2: var c = s.get(1); if( c == 10 ) { if( s.get(0) == 13 ) break; k = 4; } else if( c == 13 ) k = 3; else k = 4; case 3: var c = s.get(2); if( c == 10 ) { if( s.get(1) != 13 ) k = 4; else if( s.get(0) != 10 ) k = 2; else break; } else if( c == 13 ) { if( s.get(1) != 10 || s.get(0) != 13 ) k = 1; else k = 3; } else k = 4; case 4: var c = s.get(3); if( c == 10 ) { if( s.get(2) != 13 ) continue; else if( s.get(1) != 10 || s.get(0) != 13 ) k = 2; else break; } else if( c == 13 ) { if( s.get(2) != 10 || s.get(1) != 13 ) k = 3; else k = 1; } } } #if neko var headers = neko.Lib.stringReference(b.getBytes()).split("\r\n"); #else var headers = b.getBytes().toString().split("\r\n"); #end var response = headers.shift(); var rp = response.split(" "); var status = Std.parseInt(rp[1]); if( status == 0 || status == null ) throw "Response status error"; // remove the two lasts \r\n\r\n headers.pop(); headers.pop(); responseHeaders = new haxe.ds.StringMap(); var size = null; var chunked = false; for( hline in headers ) { var a = hline.split(": "); var hname = a.shift(); var hval = if( a.length == 1 ) a[0] else a.join(": "); hval = StringTools.ltrim( StringTools.rtrim( hval ) ); responseHeaders.set(hname, hval); switch(hname.toLowerCase()) { case "content-length": size = Std.parseInt(hval); case "transfer-encoding": chunked = (hval.toLowerCase() == "chunked"); } } onStatus(status); var chunk_re = ~/^([0-9A-Fa-f]+)[ ]*\r\n/m; chunk_size = null; chunk_buf = null; var bufsize = 1024; var buf = haxe.io.Bytes.alloc(bufsize); if( size == null ) { if( !noShutdown ) sock.shutdown(false,true); try { while( true ) { var len = sock.input.readBytes(buf,0,bufsize); if( chunked ) { if( !readChunk(chunk_re,api,buf,len) ) break; } else api.writeBytes(buf,0,len); } } catch( e : haxe.io.Eof ) { } } else { api.prepare(size); try { while( size > 0 ) { var len = sock.input.readBytes(buf,0,if( size > bufsize ) bufsize else size); if( chunked ) { if( !readChunk(chunk_re,api,buf,len) ) break; } else api.writeBytes(buf,0,len); size -= len; } } catch( e : haxe.io.Eof ) { throw "Transfer aborted"; } } if( chunked && (chunk_size != null || chunk_buf != null) ) throw "Invalid chunk"; if( status < 200 || status >= 400 ) throw "Http Error #"+status; api.close(); } function readChunk(chunk_re : EReg, api : haxe.io.Output, buf : haxe.io.Bytes, len ) { if( chunk_size == null ) { if( chunk_buf != null ) { var b = new haxe.io.BytesBuffer(); b.add(chunk_buf); b.addBytes(buf,0,len); buf = b.getBytes(); len += chunk_buf.length; chunk_buf = null; } #if neko if( chunk_re.match(neko.Lib.stringReference(buf)) ) { #else if( chunk_re.match(buf.toString()) ) { #end var p = chunk_re.matchedPos(); if( p.len <= len ) { var cstr = chunk_re.matched(1); chunk_size = Std.parseInt("0x"+cstr); if( cstr == "0" ) { chunk_size = null; chunk_buf = null; return false; } len -= p.len; return readChunk(chunk_re,api,buf.sub(p.len,len),len); } } // prevent buffer accumulation if( len > 10 ) { onError("Invalid chunk"); return false; } chunk_buf = buf.sub(0,len); return true; } if( chunk_size > len ) { chunk_size -= len; api.writeBytes(buf,0,len); return true; } var end = chunk_size + 2; if( len >= end ) { if( chunk_size > 0 ) api.writeBytes(buf,0,chunk_size); len -= end; chunk_size = null; if( len == 0 ) return true; return readChunk(chunk_re,api,buf.sub(end,len),len); } if( chunk_size > 0 ) api.writeBytes(buf,0,chunk_size); chunk_size -= len; return true; } #end /** This method is called upon a successful request, with `data` containing the result String. The intended usage is to bind it to a custom function: `httpInstance.onData = function(data) { // handle result }` **/ public dynamic function onData( data : String ) { } /** This method is called upon a request error, with `msg` containing the error description. The intended usage is to bind it to a custom function: `httpInstance.onError = function(msg) { // handle error }` **/ public dynamic function onError( msg : String ) { } /** This method is called upon a Http status change, with `status` being the new status. The intended usage is to bind it to a custom function: `httpInstance.onStatus = function(status) { // handle status }` **/ public dynamic function onStatus( status : Int ) { } #if !flash /** Makes a synchronous request to `url`. This creates a new Http instance and makes a GET request by calling its request(false) method. If `url` is null, the result is unspecified. **/ public static function requestUrl( url : String ) : String { var h = new Http(url); #if js h.async = false; #end var r = null; h.onData = function(d){ r = d; } h.onError = function(e){ throw e; } h.request(false); return r; } #end } haxe_3.2.1+dfsg.orig/std/haxe/Int32.hx0000664000175000017500000001737312607337712017316 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** Int32 provides a 32-bit integer with consistent overflow behavior across all platforms. **/ abstract Int32(Int) from Int to Int { @:op(-A) private function negate():Int32; @:op(++A) private inline function preIncrement():Int32 return this = clamp(++this); @:op(A++) private inline function postIncrement():Int32 { var ret = this++; this = clamp(this); return ret; } @:op(--A) private inline function preDecrement():Int32 return this = clamp(--this); @:op(A--) private inline function postDecrement():Int32 { var ret = this--; this = clamp(this); return ret; } @:op(A + B) private static inline function add(a:Int32, b:Int32):Int32 return clamp( (a : Int) + (b : Int) ); @:op(A + B) @:commutative private static inline function addInt(a:Int32, b:Int):Int32 return clamp( (a : Int) + (b : Int) ); @:op(A + B) @:commutative private static function addFloat(a:Int32, b:Float):Float; @:op(A - B) private static inline function sub(a:Int32, b:Int32):Int32 return clamp( (a : Int) - (b : Int) ); @:op(A - B) private static inline function subInt(a:Int32, b:Int):Int32 return clamp( (a : Int) - (b : Int) ); @:op(A - B) private static inline function intSub(a:Int, b:Int32):Int32 return clamp( (a : Int) - (b : Int) ); @:op(A - B) private static function subFloat(a:Int32, b:Float):Float; @:op(A - B) public static function floatSub(a:Float, b:Int32):Float; #if (as3 || js || php || python) @:op(A * B) private static function mul(a:Int32, b:Int32):Int32 return clamp( (a : Int) * ((b : Int) & 0xFFFF) + clamp( (a : Int) * ((b : Int) >>> 16) << 16 ) ); @:op(A * B) @:commutative private static inline function mulInt(a:Int32, b:Int):Int32 return mul(a, b); #else @:op(A * B) private static function mul(a:Int32, b:Int32):Int32; @:op(A * B) @:commutative private static function mulInt(a:Int32, b:Int):Int32; #end @:op(A * B) @:commutative private static function mulFloat(a:Int32, b:Float):Float; @:op(A / B) private static function div(a:Int32, b:Int32):Float; @:op(A / B) private static function divInt(a:Int32, b:Int):Float; @:op(A / B) private static function intDiv(a:Int, b:Int32):Float; @:op(A / B) private static function divFloat(a:Int32, b:Float):Float; @:op(A / B) private static function floatDiv(a:Float, b:Int32):Float; @:op(A % B) private static function mod(a:Int32, b:Int32):Int32; @:op(A % B) private static function modInt(a:Int32, b:Int):Int; @:op(A % B) private static function intMod(a:Int, b:Int32):Int; @:op(A % B) private static function modFloat(a:Int32, b:Float):Float; @:op(A % B) private static function floatMod(a:Float, b:Int32):Float; @:op(A == B) private static function eq(a:Int32, b:Int32):Bool; @:op(A == B) @:commutative private static function eqInt(a:Int32, b:Int):Bool; @:op(A == B) @:commutative private static function eqFloat(a:Int32, b:Float):Bool; @:op(A != B) private static function neq(a:Int32, b:Int32):Bool; @:op(A != B) @:commutative private static function neqInt(a:Int32, b:Int):Bool; @:op(A != B) @:commutative private static function neqFloat(a:Int32, b:Float):Bool; @:op(A < B) private static function lt(a:Int32, b:Int32):Bool; @:op(A < B) private static function ltInt(a:Int32, b:Int):Bool; @:op(A < B) private static function intLt(a:Int, b:Int32):Bool; @:op(A < B) private static function ltFloat(a:Int32, b:Float):Bool; @:op(A < B) private static function floatLt(a:Float, b:Int32):Bool; @:op(A <= B) private static function lte(a:Int32, b:Int32):Bool; @:op(A <= B) private static function lteInt(a:Int32, b:Int):Bool; @:op(A <= B) private static function intLte(a:Int, b:Int32):Bool; @:op(A <= B) private static function lteFloat(a:Int32, b:Float):Bool; @:op(A <= B) private static function floatLte(a:Float, b:Int32):Bool; @:op(A > B) private static function gt(a:Int32, b:Int32):Bool; @:op(A > B) private static function gtInt(a:Int32, b:Int):Bool; @:op(A > B) private static function intGt(a:Int, b:Int32):Bool; @:op(A > B) private static function gtFloat(a:Int32, b:Float):Bool; @:op(A > B) private static function floatGt(a:Float, b:Int32):Bool; @:op(A >= B) private static function gte(a:Int32, b:Int32):Bool; @:op(A >= B) private static function gteInt(a:Int32, b:Int):Bool; @:op(A >= B) private static function intGte(a:Int, b:Int32):Bool; @:op(A >= B) private static function gteFloat(a:Int32, b:Float):Bool; @:op(A >= B) private static function floatGte(a:Float, b:Int32):Bool; @:op(~A) private function complement():Int32; @:op(A & B) private static function and(a:Int32, b:Int32):Int32; @:op(A & B) @:commutative private static function andInt(a:Int32, b:Int):Int32; @:op(A | B) private static function or(a:Int32, b:Int32):Int32; @:op(A | B) @:commutative private static function orInt(a:Int32, b:Int):Int32; @:op(A ^ B) private static function xor(a:Int32, b:Int32):Int32; @:op(A ^ B) @:commutative private static function xorInt(a:Int32, b:Int):Int32; @:op(A >> B) private static function shr(a:Int32, b:Int32):Int32; @:op(A >> B) private static function shrInt(a:Int32, b:Int):Int32; @:op(A >> B) private static function intShr(a:Int, b:Int32):Int32; @:op(A >>> B) private static function ushr(a:Int32, b:Int32):Int32; @:op(A >>> B) private static function ushrInt(a:Int32, b:Int):Int32; @:op(A >>> B) private static function intUshr(a:Int, b:Int32):Int32; #if (php || python) // PHP may be 64-bit, so shifts must be clamped @:op(A << B) private static inline function shl(a:Int32, b:Int32):Int32 return clamp( (a : Int) << (b : Int) ); @:op(A << B) private static inline function shlInt(a:Int32, b:Int):Int32 return clamp( (a : Int) << b ); @:op(A << B) private static inline function intShl(a:Int, b:Int32):Int32 return clamp( a << (b : Int) ); #else @:op(A << B) private static function shl(a:Int32, b:Int32):Int32; @:op(A << B) private static function shlInt(a:Int32, b:Int):Int32; @:op(A << B) private static function intShl(a:Int, b:Int32):Int32; #end @:to private inline function toFloat():Float return this; /** Compare `a` and `b` in unsigned mode. **/ public static function ucompare( a : Int32, b : Int32 ) : Int { if( a < 0 ) return b < 0 ? ( ~b - ~a ) : 1; return b < 0 ? -1 : (a - b); } #if php static var extraBits : Int = untyped __php__("PHP_INT_SIZE") * 8 - 32; #end static inline function clamp( x : Int ) : Int { // force to-int conversion on platforms that require it #if (as3 || js) return x | 0; #elseif php // we might be on 64-bit php, so sign extend from 32-bit return (x << extraBits) >> extraBits; #elseif python return python.Syntax.pythonCode("{0} % {1}", (x + python.Syntax.opPow(2, 31)), python.Syntax.opPow(2, 32)) - python.Syntax.opPow(2, 31); #else return (x); #end } } haxe_3.2.1+dfsg.orig/std/haxe/Int64.hx0000664000175000017500000003060012607337712017307 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; using haxe.Int64; /** A cross-platform signed 64-bit integer. Int64 instances can be created from two 32-bit words using `Int64.make()`. **/ #if flash @:notNull #end abstract Int64(__Int64) from __Int64 to __Int64 { private inline function new( x : __Int64 ) this = x; /** Makes a copy of `this` Int64. **/ public inline function copy():Int64 return make( high, low ); /** Construct an Int64 from two 32-bit words `high` and `low`. **/ public static inline function make( high:Int32, low:Int32 ) : Int64 return new Int64( new __Int64(high, low) ); /** Returns an Int64 with the value of the Int `x`. `x` is sign-extended to fill 64 bits. **/ @:from public static inline function ofInt( x : Int ) : Int64 return make( x >> 31, x ); /** Returns an Int with the value of the Int64 `x`. Throws an exception if `x` cannot be represented in 32 bits. **/ public static inline function toInt( x : Int64 ) : Int { if( x.high != x.low >> 31 ) throw "Overflow"; return x.low; } /** Returns whether the value `val` is of type `haxe.Int64` **/ inline public static function is( val : Dynamic ) : Bool return Std.is(val,__Int64); /** Returns the high 32-bit word of `x`. **/ @:deprecated("Use high instead") public static inline function getHigh( x : Int64 ) : Int32 return x.high; /** Returns the low 32-bit word of `x`. **/ @:deprecated("Use low instead") public static inline function getLow( x : Int64 ) : Int32 return x.low; /** Returns `true` if `x` is less than zero. **/ public static inline function isNeg( x : Int64) : Bool return x.high < 0; /** Returns `true` if `x` is exactly zero. **/ public static inline function isZero( x : Int64 ) : Bool return x == 0; /** Compares `a` and `b` in signed mode. Returns a negative value if `a < b`, positive if `a > b`, or 0 if `a == b`. **/ public static inline function compare( a : Int64, b : Int64 ) : Int { var v = a.high - b.high; v = if( v != 0 ) v else Int32.ucompare(a.low, b.low); return a.high < 0 ? (b.high < 0 ? v : -1) : (b.high >= 0 ? v : 1); } /** Compares `a` and `b` in unsigned mode. Returns a negative value if `a < b`, positive if `a > b`, or 0 if `a == b`. **/ public static inline function ucompare( a : Int64, b : Int64 ) : Int { var v = Int32.ucompare(a.high, b.high); return if( v != 0 ) v else Int32.ucompare(a.low, b.low); } /** Returns a signed decimal `String` representation of `x`. **/ public static inline function toStr(x:Int64) : String return x.toString(); #if as3 public #else private #end function toString() : String { var i : Int64 = cast this; if ( i == 0 ) return "0"; var str = ""; var neg = false; if( i.isNeg() ) { neg = true; i = -i; } var ten : Int64 = 10; while( i != 0 ) { var r = i.divMod( ten ); str = r.modulus.low + str; i = r.quotient; } if( neg ) str = "-" + str; return str; } /** Performs signed integer divison of `dividend` by `divisor`. Returns `{ quotient : Int64, modulus : Int64 }`. **/ public static function divMod( dividend : Int64, divisor : Int64 ) : { quotient : Int64, modulus : Int64 } { // Handle special cases of 0 and 1 if( divisor.high == 0 ) { switch( divisor.low ) { case 0: throw "divide by zero"; case 1: return { quotient : dividend.copy(), modulus : 0 }; } } var divSign = dividend.isNeg() != divisor.isNeg(); var modulus = dividend.isNeg() ? -dividend : dividend.copy(); divisor = divisor.isNeg() ? -divisor : divisor; var quotient : Int64 = 0; var mask : Int64 = 1; while( !divisor.isNeg() ) { var cmp = ucompare( divisor, modulus ); divisor <<= 1; mask <<= 1; if( cmp >= 0 ) break; } while( mask != 0 ) { if( ucompare(modulus, divisor) >= 0 ) { quotient |= mask; modulus -= divisor; } mask >>>= 1; divisor >>>= 1; } if( divSign ) quotient = -quotient; if( dividend.isNeg() ) modulus = -modulus; return { quotient : quotient, modulus : modulus }; } /** Returns the negative of `x`. **/ @:op(-A) public static inline function neg( x : Int64 ) : Int64 { var high = ~x.high; var low = -x.low; if( low == 0 ) high++; return make( high, low ); } @:op(++A) private inline function preIncrement() : Int64 { this.low++; if( this.low == 0 ) this.high++; return cast this; } @:op(A++) private inline function postIncrement() : Int64 { var ret = copy(); preIncrement(); return ret; } @:op(--A) private inline function preDecrement() : Int64 { if( this.low == 0 ) this.high--; this.low--; return cast this; } @:op(A--) private inline function postDecrement() : Int64 { var ret = copy(); preDecrement(); return ret; } /** Returns the sum of `a` and `b`. **/ @:op(A + B) public static inline function add( a : Int64, b : Int64 ) : Int64 { var high = a.high + b.high; var low = a.low + b.low; if( Int32.ucompare( low, a.low ) < 0 ) high++; return make( high, low ); } @:op(A + B) @:commutative private static inline function addInt( a : Int64, b : Int ) : Int64 return add( a, b ); /** Returns `a` minus `b`. **/ @:op(A - B) public static inline function sub( a : Int64, b : Int64 ) : Int64 { var high = a.high - b.high; var low = a.low - b.low; if( Int32.ucompare( a.low, b.low ) < 0 ) high--; return make( high, low ); } @:op(A - B) private static inline function subInt( a : Int64, b : Int ) : Int64 return sub( a, b ); @:op(A - B) private static inline function intSub( a : Int, b : Int64 ) : Int64 return sub( a, b ); /** Returns the product of `a` and `b`. **/ @:op(A * B) public static inline function mul( a : Int64, b : Int64 ) : Int64 { var mask = 0xFFFF; var al = a.low & mask, ah = a.low >>> 16; var bl = b.low & mask, bh = b.low >>> 16; var p00 = al * bl; var p10 = ah * bl; var p01 = al * bh; var p11 = ah * bh; var low = p00; var high = p11 + (p01 >>> 16) + (p10 >>> 16); p01 <<= 16; low += p01; if( Int32.ucompare(low, p01) < 0 ) high++; p10 <<= 16; low += p10; if( Int32.ucompare(low, p10) < 0 ) high++; high += a.low * b.high + a.high * b.low; return make( high, low ); } @:op(A * B) @:commutative private static inline function mulInt( a : Int64, b : Int ) : Int64 return mul( a, b ); /** Returns the quotient of `a` divided by `b`. **/ @:op(A / B) public static inline function div( a : Int64, b : Int64 ) : Int64 return divMod(a, b).quotient; @:op(A / B) private static inline function divInt( a : Int64, b : Int ) : Int64 return div( a, b ); @:op(A / B) private static inline function intDiv( a : Int, b : Int64 ) : Int64 return div( a, b ).toInt(); /** Returns the modulus of `a` divided by `b`. **/ @:op(A % B) public static inline function mod( a : Int64, b : Int64 ) : Int64 return divMod(a, b).modulus; @:op(A % B) private static inline function modInt( a : Int64, b : Int ) : Int64 return mod( a, b ).toInt(); @:op(A % B) private static inline function intMod( a : Int, b : Int64 ) : Int64 return mod( a, b ).toInt(); /** Returns `true` if `a` is equal to `b`. **/ @:op(A == B) public static inline function eq( a : Int64, b : Int64 ) : Bool return a.high == b.high && a.low == b.low; @:op(A == B) @:commutative private static inline function eqInt( a : Int64, b : Int ) : Bool return eq( a, b ); /** Returns `true` if `a` is not equal to `b`. **/ @:op(A != B) public static inline function neq( a : Int64, b : Int64 ) : Bool return a.high != b.high || a.low != b.low; @:op(A != B) @:commutative private static inline function neqInt( a : Int64, b : Int ) : Bool return neq(a, b); @:op(A < B) private static inline function lt( a : Int64, b : Int64 ) : Bool return compare(a, b) < 0; @:op(A < B) private static inline function ltInt( a : Int64, b : Int ) : Bool return lt(a, b); @:op(A < B) private static inline function intLt( a : Int, b : Int64 ) : Bool return lt(a, b); @:op(A <= B) private static inline function lte( a : Int64, b : Int64 ) : Bool return compare(a, b) <= 0; @:op(A <= B) private static inline function lteInt( a : Int64, b : Int ) : Bool return lte(a, b); @:op(A <= B) private static inline function intLte( a : Int, b : Int64 ) : Bool return lte(a, b); @:op(A > B) private static inline function gt( a : Int64, b : Int64 ) : Bool return compare(a, b) > 0; @:op(A > B) private static inline function gtInt( a : Int64, b : Int ) : Bool return gt(a, b); @:op(A > B) private static inline function intGt( a : Int, b : Int64 ) : Bool return gt( a, b ); @:op(A >= B) private static inline function gte( a : Int64, b : Int64 ) : Bool return compare(a, b) >= 0; @:op(A >= B) private static inline function gteInt( a : Int64, b : Int ) : Bool return gte(a, b); @:op(A >= B) private static inline function intGte( a : Int, b : Int64 ) : Bool return gte(a, b); /** Returns the bitwise NOT of `a`. **/ @:op(~A) private static inline function complement( a : Int64 ) : Int64 return make( ~a.high, ~a.low ); /** Returns the bitwise AND of `a` and `b`. **/ @:op(A & B) public static inline function and( a : Int64, b : Int64 ) : Int64 return make( a.high & b.high, a.low & b.low ); /** Returns the bitwise OR of `a` and `b`. **/ @:op(A | B) public static inline function or( a : Int64, b : Int64 ) : Int64 return make( a.high | b.high, a.low | b.low ); /** Returns the bitwise XOR of `a` and `b`. **/ @:op(A ^ B) public static inline function xor( a : Int64, b : Int64 ) : Int64 return make( a.high ^ b.high, a.low ^ b.low ); /** Returns `a` left-shifted by `b` bits. **/ @:op(A << B) public static inline function shl( a : Int64, b : Int ) : Int64 { b &= 63; return if( b == 0 ) a.copy() else if( b < 32 ) make( (a.high << b) | (a.low >>> (32-b)), a.low << b) else make( a.low << (b-32), 0 ); } /** Returns `a` right-shifted by `b` bits in signed mode. `a` is sign-extended. **/ @:op(A >> B) public static inline function shr( a : Int64, b : Int) : Int64 { b &= 63; return if( b == 0 ) a.copy() else if( b < 32 ) make( a.high >> b, (a.high << (32-b)) | (a.low >>> b) ) else make( a.high >> 31, a.high >> (b - 32) ); } /** Returns `a` right-shifted by `b` bits in unsigned mode. `a` is padded with zeroes. **/ @:op(A >>> B) public static inline function ushr( a : Int64, b : Int ) : Int64 { b &= 63; return if( b == 0 ) a.copy() else if( b < 32 ) make( a.high >>> b, (a.high << (32-b)) | (a.low >>> b) ) else make( 0, a.high >>> (b - 32) ); } public var high(get, never) : Int32; private inline function get_high() return this.high; private inline function set_high(x) return this.high = x; public var low(get, never) : Int32; private inline function get_low() return this.low; private inline function set_low(x) return this.low = x; } /** * This typedef will fool @:coreApi into thinking that we are using * the same underlying type, even though it might be different on * specific platforms. */ private typedef __Int64 = ___Int64; private class ___Int64 { public var high : Int32; public var low : Int32; public inline function new( high, low ) { this.high = high; this.low = low; } /** We also define toString here to ensure we always get a pretty string when tracing or calling Std.string. This tends not to happen when toString is only in the abstract. **/ public function toString() : String return Int64.toStr( cast this ); } haxe_3.2.1+dfsg.orig/std/haxe/Json.hx0000664000175000017500000000456612607337712017330 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** Crossplatform JSON API : it will automatically use the optimized native API if available. Use -D haxeJSON to force usage of the Haxe implementation even if a native API is found : this will provide extra encoding features such as enums (replaced by their index) and StringMaps. **/ class Json { /** Parses given JSON-encoded `text` and returns the resulting object. JSON objects are parsed into anonymous structures and JSON arrays are parsed into Array. If given `text` is not valid JSON, an exception will be thrown. **/ public static inline function parse( text : String ) : Dynamic { return haxe.format.JsonParser.parse(text); } /** Encodes given `value` and returns the resulting JSON string. If `replacer` is given and is not null, it is used to retrieve actual object to be encoded. The `replacer` function two parameters, the key and the value being encoded. Initial key value is an empty string. If `space` is given and is not null, the result will be pretty-printed. Successive levels will be indented by this string. **/ public static inline function stringify( value : Dynamic, ?replacer:Dynamic -> Dynamic -> Dynamic, ?space : String ) : String { return haxe.format.JsonPrinter.print(value, replacer, space); } } haxe_3.2.1+dfsg.orig/std/haxe/Log.hx0000664000175000017500000000773012607337712017134 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** Log primarily provides the trace() method, which is invoked upon a call to trace() in haxe code. **/ class Log { /** Outputs `v` in a platform-dependent way. The second parameter `infos` is injected by the compiler and contains information about the position where the trace() call was made. This method can be rebound to a custom function: var oldTrace = haxe.Log.trace; // store old function haxe.Log.trace = function(v,infos) { // handle trace } ... haxe.Log.trace = oldTrace; If it is bound to null, subsequent calls to trace() will cause an exception. **/ public static dynamic function trace( v : Dynamic, ?infos : PosInfos ) : Void { #if flash #if (fdb || native_trace) var pstr = infos == null ? "(null)" : infos.fileName + ":" + infos.lineNumber; var str = flash.Boot.__string_rec(v, ""); if( infos != null && infos.customParams != null ) for( v in infos.customParams ) str += "," + flash.Boot.__string_rec(v, ""); untyped __global__["trace"](pstr+": "+str); #else untyped flash.Boot.__trace(v,infos); #end #elseif neko untyped { $print(infos.fileName + ":" + infos.lineNumber + ": ", v); if( infos.customParams != null ) for( v in infos.customParams ) $print(",", v); $print("\n"); } #elseif js untyped js.Boot.__trace(v,infos); #elseif php if (infos!=null && infos.customParams!=null) { var extra:String = ""; for( v in infos.customParams ) extra += "," + v; untyped __call__('_hx_trace', v + extra, infos); } else untyped __call__('_hx_trace', v, infos); #elseif cpp if (infos!=null && infos.customParams!=null) { var extra:String = ""; for( v in infos.customParams ) extra += "," + v; untyped __trace(v + extra,infos); } else untyped __trace(v,infos); #elseif (cs || java) var str:String = null; if (infos != null) { str = infos.fileName + ":" + infos.lineNumber + ": " + v; if (infos.customParams != null) { str += "," + infos.customParams.join(","); } } else { str = v; } #if cs cs.system.Console.WriteLine(str); #elseif java untyped __java__("java.lang.System.out.println(str)"); #end #elseif (python) var str:String = null; if (infos != null) { str = infos.fileName + ":" + Std.string(infos.lineNumber) + ": " + v; if (infos.customParams != null) { str += "," + infos.customParams.join(","); } } else { str = v; } python.Lib.println(str); #end } #if (flash || js) /** Clears the trace output. **/ public static dynamic function clear() : Void { #if flash untyped flash.Boot.__clear_trace(); #elseif js untyped js.Boot.__clear_trace(); #end } #end #if flash /** Sets the color of the trace output to `rgb`. **/ public static dynamic function setColor( rgb : Int ) { untyped flash.Boot.__set_trace_color(rgb); } #end } haxe_3.2.1+dfsg.orig/std/haxe/PosInfos.hx0000664000175000017500000000326612607337712020153 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** PosInfos is a magic type which can be used to generate position information into the output for debugging use. If a function has a final optional argument of this type, i.e. (..., ?pos:haxe.PosInfos), each call to that function which does not assign a value to that argument has its position added as call argument. This can be used to track positions of calls in e.g. a unit testing framework. **/ typedef PosInfos = { var fileName : String; var lineNumber : Int; var className : String; var methodName : String; @:optional var customParams : Array; }haxe_3.2.1+dfsg.orig/std/haxe/Resource.hx0000664000175000017500000000564112607337712020201 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** Resource can be used to access resources that were added through the -resource file@name command line parameter. Depending on their type they can be obtained as String through getString(name), or as binary data through getBytes(name). A list of all available resource names can be obtained from listNames(). **/ class Resource { static var content : Array<{ name : String, data : String, str : String }>; /** Lists all available resource names. The resource name is the name part of the -resource file@name command line parameter. **/ public static function listNames() : Array { return [for (x in content) x.name]; } /** Retrieves the resource identified by `name` as a String. If `name` does not match any resource name, null is returned. **/ public static function getString( name : String ) : String { for( x in content ) if( x.name == name ) { #if neko return new String(x.data); #else if( x.str != null ) return x.str; var b : haxe.io.Bytes = haxe.crypto.Base64.decode(x.data); return b.toString(); #end } return null; } /** Retrieves the resource identified by `name` as an instance of haxe.io.Bytes. If `name` does not match any resource name, null is returned. **/ public static function getBytes( name : String ) : haxe.io.Bytes { for( x in content ) if( x.name == name ) { #if neko return haxe.io.Bytes.ofData(cast x.data); #else if( x.str != null ) return haxe.io.Bytes.ofString(x.str); return haxe.crypto.Base64.decode(x.data); #end } return null; } static function __init__() { #if neko var tmp = untyped __resources__(); content = untyped Array.new1(tmp,__dollar__asize(tmp)); #elseif php content = null; #elseif as3 null; #else content = untyped __resources__(); #end } } haxe_3.2.1+dfsg.orig/std/haxe/Serializer.hx0000664000175000017500000003332312607337712020521 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** The Serializer class can be used to encode values and objects into a String, from which the Unserializer class can recreate the original representation. This class can be used in two ways: - create a new Serializer() instance, call its serialize() method with any argument and finally retrieve the String representation from toString() - call Serializer.run() to obtain the serialized representation of a single argument Serialization is guaranteed to work for all haxe-defined classes, but may or may not work for instances of external/native classes. The specification of the serialization format can be found here: `http://haxe.org/manual/serialization/format` **/ class Serializer { /** If the values you are serializing can contain circular references or objects repetitions, you should set USE_CACHE to true to prevent infinite loops. This may also reduce the size of serialization Strings at the expense of performance. This value can be changed for individual instances of Serializer by setting their useCache field. **/ public static var USE_CACHE = false; /** Use constructor indexes for enums instead of names. This may reduce the size of serialization Strings, but makes them less suited for long-term storage: If constructors are removed or added from the enum, the indices may no longer match. This value can be changed for individual instances of Serializer by setting their useEnumIndex field. **/ public static var USE_ENUM_INDEX = false; static var BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:"; var buf : StringBuf; var cache : Array; var shash : haxe.ds.StringMap; var scount : Int; /** The individual cache setting for `this` Serializer instance. See USE_CACHE for a complete description. **/ public var useCache : Bool; /** The individual enum index setting for `this` Serializer instance. See USE_ENUM_INDEX for a complete description. **/ public var useEnumIndex : Bool; /** Creates a new Serializer instance. Subsequent calls to `this.serialize` will append values to the internal buffer of this String. Once complete, the contents can be retrieved through a call to `this.toString`. Each Serializer instance maintains its own cache if this.useCache` is true. **/ public function new() { buf = new StringBuf(); cache = new Array(); useCache = USE_CACHE; useEnumIndex = USE_ENUM_INDEX; shash = new haxe.ds.StringMap(); scount = 0; } /** Return the String representation of `this` Serializer. The exact format specification can be found here: http://haxe.org/manual/serialization/format **/ public function toString() { return buf.toString(); } /* prefixes : a : array b : hash c : class d : Float e : reserved (float exp) f : false g : object end h : array/list/hash end i : Int j : enum (by index) k : NaN l : list m : -Inf n : null o : object p : +Inf q : haxe.ds.IntMap r : reference s : bytes (base64) t : true u : array nulls v : date w : enum x : exception y : urlencoded string z : zero A : Class B : Enum M : haxe.ds.ObjectMap C : custom */ function serializeString( s : String ) { var x = shash.get(s); if( x != null ) { buf.add("R"); buf.add(x); return; } shash.set(s,scount++); #if old_serialize // no more support for -D old_serialize due to 'j' reuse #if error #end #end buf.add("y"); s = StringTools.urlEncode(s); buf.add(s.length); buf.add(":"); buf.add(s); } function serializeRef(v) { #if js var vt = untyped __js__("typeof")(v); #end for( i in 0...cache.length ) { #if js var ci = cache[i]; if( untyped __js__("typeof")(ci) == vt && ci == v ) { #else if( cache[i] == v ) { #end buf.add("r"); buf.add(i); return true; } } cache.push(v); return false; } #if flash // only the instance variables function serializeClassFields(v,c) { var xml : flash.xml.XML = untyped __global__["flash.utils.describeType"](c); var vars = xml.factory[0].child("variable"); for( i in 0...vars.length() ) { var f = vars[i].attribute("name").toString(); if( !v.hasOwnProperty(f) ) continue; serializeString(f); serialize(Reflect.field(v,f)); } buf.add("g"); } #end function serializeFields(v) { for( f in Reflect.fields(v) ) { serializeString(f); serialize(Reflect.field(v,f)); } buf.add("g"); } /** Serializes `v`. All haxe-defined values and objects with the exception of functions can be serialized. Serialization of external/native objects is not guaranteed to work. The values of `this.useCache` and `this.useEnumIndex` may affect serialization output. **/ public function serialize( v : Dynamic ) { switch( Type.typeof(v) ) { case TNull: buf.add("n"); case TInt: var v : Int = v; if( v == 0 ) { buf.add("z"); return; } buf.add("i"); buf.add(v); case TFloat: var v : Float = v; if( Math.isNaN(v) ) buf.add("k"); else if( !Math.isFinite(v) ) buf.add(if( v < 0 ) "m" else "p"); else { buf.add("d"); buf.add(v); } case TBool: buf.add(if( v ) "t" else "f"); case TClass(c): if( #if neko untyped c.__is_String #else c == String #end ) { serializeString(v); return; } if( useCache && serializeRef(v) ) return; switch( #if (neko || cs || python) Type.getClassName(c) #else c #end ) { case #if (neko || cs || python) "Array" #else cast Array #end: var ucount = 0; buf.add("a"); #if (flash || python) var v : Array = v; #end var l = #if (neko || flash || php || cs || java || python) v.length #elseif cpp v.__length() #else __getField(v, "length") #end; for( i in 0...l ) { if( v[i] == null ) ucount++; else { if( ucount > 0 ) { if( ucount == 1 ) buf.add("n"); else { buf.add("u"); buf.add(ucount); } ucount = 0; } serialize(v[i]); } } if( ucount > 0 ) { if( ucount == 1 ) buf.add("n"); else { buf.add("u"); buf.add(ucount); } } buf.add("h"); case #if (neko || cs || python) "List" #else cast List #end: buf.add("l"); var v : List = v; for( i in v ) serialize(i); buf.add("h"); case #if (neko || cs || python) "Date" #else cast Date #end: var d : Date = v; buf.add("v"); buf.add(d.getTime()); case #if (neko || cs || python) "haxe.ds.StringMap" #else cast haxe.ds.StringMap #end: buf.add("b"); var v : haxe.ds.StringMap = v; for( k in v.keys() ) { serializeString(k); serialize(v.get(k)); } buf.add("h"); case #if (neko || cs || python) "haxe.ds.IntMap" #else cast haxe.ds.IntMap #end: buf.add("q"); var v : haxe.ds.IntMap = v; for( k in v.keys() ) { buf.add(":"); buf.add(k); serialize(v.get(k)); } buf.add("h"); case #if (neko || cs || python) "haxe.ds.ObjectMap" #else cast haxe.ds.ObjectMap #end: buf.add("M"); var v : haxe.ds.ObjectMap = v; for ( k in v.keys() ) { #if (js || neko) var id = Reflect.field(k, "__id__"); Reflect.deleteField(k, "__id__"); serialize(k); Reflect.setField(k, "__id__", id); #else serialize(k); #end serialize(v.get(k)); } buf.add("h"); case #if (neko || cs || python) "haxe.io.Bytes" #else cast haxe.io.Bytes #end: var v : haxe.io.Bytes = v; #if neko var chars = new String(base_encode(v.getData(),untyped BASE64.__s)); #else var i = 0; var max = v.length - 2; var charsBuf = new StringBuf(); var b64 = BASE64; while( i < max ) { var b1 = v.get(i++); var b2 = v.get(i++); var b3 = v.get(i++); charsBuf.add(b64.charAt(b1 >> 2)); charsBuf.add(b64.charAt(((b1 << 4) | (b2 >> 4)) & 63)); charsBuf.add(b64.charAt(((b2 << 2) | (b3 >> 6)) & 63)); charsBuf.add(b64.charAt(b3 & 63)); } if( i == max ) { var b1 = v.get(i++); var b2 = v.get(i++); charsBuf.add(b64.charAt(b1 >> 2)); charsBuf.add(b64.charAt(((b1 << 4) | (b2 >> 4)) & 63)); charsBuf.add(b64.charAt((b2 << 2) & 63)); } else if( i == max + 1 ) { var b1 = v.get(i++); charsBuf.add(b64.charAt(b1 >> 2)); charsBuf.add(b64.charAt((b1 << 4) & 63)); } var chars = charsBuf.toString(); #end buf.add("s"); buf.add(chars.length); buf.add(":"); buf.add(chars); default: if( useCache ) cache.pop(); if( #if flash try v.hxSerialize != null catch( e : Dynamic ) false #elseif (cs || java || python) Reflect.hasField(v, "hxSerialize") #else v.hxSerialize != null #end ) { buf.add("C"); serializeString(Type.getClassName(c)); if( useCache ) cache.push(v); v.hxSerialize(this); buf.add("g"); } else { buf.add("c"); serializeString(Type.getClassName(c)); if( useCache ) cache.push(v); #if flash serializeClassFields(v,c); #else serializeFields(v); #end } } case TObject: if (Std.is(v,Class)) { var className = Type.getClassName(v); #if (flash || cpp) // Currently, Enum and Class are the same for flash and cpp. // use resolveEnum to test if it is actually an enum if (Type.resolveEnum(className)!=null) buf.add("B") else #end buf.add("A"); serializeString(className); } else if (Std.is(v,Enum)) { buf.add("B"); serializeString(Type.getEnumName(v)); } else { if( useCache && serializeRef(v) ) return; buf.add("o"); serializeFields(v); } case TEnum(e): if( useCache ) { if( serializeRef(v) ) return; cache.pop(); } buf.add(useEnumIndex?"j":"w"); serializeString(Type.getEnumName(e)); #if neko if( useEnumIndex ) { buf.add(":"); buf.add(v.index); } else serializeString(new String(v.tag)); buf.add(":"); if( v.args == null ) buf.add(0); else { var l : Int = untyped __dollar__asize(v.args); buf.add(l); for( i in 0...l ) serialize(v.args[i]); } #elseif flash if( useEnumIndex ) { buf.add(":"); var i : Int = v.index; buf.add(i); } else serializeString(v.tag); buf.add(":"); var pl : Array = v.params; if( pl == null ) buf.add(0); else { buf.add(pl.length); for( p in pl ) serialize(p); } #elseif cpp if( useEnumIndex ) { buf.add(":"); buf.add(v.__Index()); } else serializeString(v.__Tag()); buf.add(":"); var pl : Array = v.__EnumParams(); if( pl == null ) buf.add(0); else { buf.add(pl.length); for( p in pl ) serialize(p); } #elseif php if( useEnumIndex ) { buf.add(":"); buf.add(v.index); } else serializeString(v.tag); buf.add(":"); var l : Int = untyped __call__("count", v.params); if( l == 0 || v.params == null) buf.add(0); else { buf.add(l); for( i in 0...l ) serialize(untyped __field__(v, __php__("params"), i)); } #elseif (java || cs || python) if( useEnumIndex ) { buf.add(":"); buf.add(Type.enumIndex(v)); } else serializeString(Type.enumConstructor(v)); buf.add(":"); var arr:Array = Type.enumParameters(v); if (arr != null) { buf.add(arr.length); for (v in arr) serialize(v); } else { buf.add("0"); } #else if( useEnumIndex ) { buf.add(":"); buf.add(v[1]); } else serializeString(v[0]); buf.add(":"); var l = __getField(v, "length"); buf.add(l - 2); for( i in 2...l ) serialize(v[i]); #end if( useCache ) cache.push(v); case TFunction: throw "Cannot serialize function"; default: #if neko if( untyped (__i32__kind != null && __dollar__iskind(v,__i32__kind)) ) { buf.add("i"); buf.add(v); return; } #end throw "Cannot serialize "+Std.string(v); } } @:extern inline function __getField(o:Dynamic, f:String):Dynamic return untyped o[f]; public function serializeException( e : Dynamic ) { buf.add("x"); #if flash if( untyped __is__(e,__global__["Error"]) ) { var e : flash.errors.Error = e; var s = e.getStackTrace(); if( s == null ) serialize(e.message); else serialize(s); return; } #end serialize(e); } /** Serializes `v` and returns the String representation. This is a convenience function for creating a new instance of Serializer, serialize `v` into it and obtain the result through a call to toString(). **/ public static function run( v : Dynamic ) { var s = new Serializer(); s.serialize(v); return s.toString(); } #if neko static var base_encode = neko.Lib.load("std","base_encode",2); #end } haxe_3.2.1+dfsg.orig/std/haxe/Template.hx0000664000175000017500000002640212607337712020163 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; private enum TemplateExpr { OpVar( v : String ); OpExpr( expr : Void -> Dynamic ); OpIf( expr : Void -> Dynamic, eif : TemplateExpr, eelse : TemplateExpr ); OpStr( str : String ); OpBlock( l : List ); OpForeach( expr : Void -> Dynamic, loop : TemplateExpr ); OpMacro( name : String, params : List ); } private typedef Token = { var s : Bool; var p : String; var l : Array; } private typedef ExprToken = { var s : Bool; var p : String; } /** Template provides a basic templating mechanism to replace values in a source String, and to have some basic logic. A complete documentation of the supported syntax is available at: http://haxe.org/manual/std-template.html **/ class Template { static var splitter = ~/(::[A-Za-z0-9_ ()&|!+=\/><*."-]+::|\$\$([A-Za-z0-9_-]+)\()/; static var expr_splitter = ~/(\(|\)|[ \r\n\t]*"[^"]*"[ \r\n\t]*|[!+=\/><*.&|-]+)/; static var expr_trim = ~/^[ ]*([^ ]+)[ ]*$/; static var expr_int = ~/^[0-9]+$/; static var expr_float = ~/^([+-]?)(?=\d|,\d)\d*(,\d*)?([Ee]([+-]?\d+))?$/; /** Global replacements which are used across all Template instances. This has lower priority than the context argument of execute(). **/ public static var globals : Dynamic = {}; var expr : TemplateExpr; var context : Dynamic; var macros : Dynamic; var stack : List; var buf : StringBuf; /** Creates a new Template instance from `str`. `str` is parsed into tokens, which are stored for internal use. This means that multiple execute() operations on a single Template instance are more efficient than one execute() operations on multiple Template instances. If `str` is null, the result is unspecified. **/ public function new( str : String ) { var tokens = parseTokens(str); expr = parseBlock(tokens); if( !tokens.isEmpty() ) throw "Unexpected '"+tokens.first().s+"'"; } /** Executes `this` Template, taking into account `context` for replacements and `macros` for callback functions. If `context` has a field 'name', its value replaces all occurrences of ::name:: in the Template. Otherwise Template.globals is checked instead, If 'name' is not a field of that either, ::name:: is replaced with null. If `macros` has a field 'name', all occurrences of $$name(args) are replaced with the result of calling that field. The first argument is always the resolve() method, followed by the given arguments. If `macros` has no such field, the result is unspecified. If `context` is null, the result is unspecified. If `macros` is null, no macros are used. **/ public function execute( context : Dynamic, ?macros : Dynamic ):String { this.macros = if( macros == null ) {} else macros; this.context = context; stack = new List(); buf = new StringBuf(); run(expr); return buf.toString(); } function resolve( v : String ) : Dynamic { if( Reflect.hasField(context,v) ) return Reflect.field(context,v); for( ctx in stack ) if( Reflect.hasField(ctx,v) ) return Reflect.field(ctx,v); if( v == "__current__" ) return context; return Reflect.field(globals,v); } function parseTokens( data : String ) { var tokens = new List(); while( splitter.match(data) ) { var p = splitter.matchedPos(); if( p.pos > 0 ) tokens.add({ p : data.substr(0,p.pos), s : true, l : null }); // : ? if( data.charCodeAt(p.pos) == 58 ) { tokens.add({ p : data.substr(p.pos + 2,p.len - 4), s : false, l : null }); data = splitter.matchedRight(); continue; } // macro parse var parp = p.pos + p.len; var npar = 1; var params = []; var part = ""; while( true ) { var c = data.charCodeAt(parp); parp++; if( c == 40 ) { npar++; } else if( c == 41 ) { npar--; if (npar <= 0) break; } else if( c == null ){ throw "Unclosed macro parenthesis"; } if ( c == 44 && npar == 1) { params.push(part); part = ""; } else { part += String.fromCharCode(c); } } params.push(part); tokens.add({ p : splitter.matched(2), s : false, l : params }); data = data.substr(parp,data.length - parp); } if( data.length > 0 ) tokens.add({ p : data, s : true, l : null }); return tokens; } function parseBlock( tokens : List ) { var l = new List(); while( true ) { var t = tokens.first(); if( t == null ) break; if( !t.s && (t.p == "end" || t.p == "else" || t.p.substr(0,7) == "elseif ") ) break; l.add(parse(tokens)); } if( l.length == 1 ) return l.first(); return OpBlock(l); } function parse( tokens : List ) { var t = tokens.pop(); var p = t.p; if( t.s ) return OpStr(p); // macro if( t.l != null ) { var pe = new List(); for( p in t.l ) pe.add(parseBlock(parseTokens(p))); return OpMacro(p,pe); } // 'end' , 'else', 'elseif' can't be found here if( p.substr(0,3) == "if " ) { p = p.substr(3,p.length - 3); var e = parseExpr(p); var eif = parseBlock(tokens); var t = tokens.first(); var eelse; if( t == null ) throw "Unclosed 'if'"; if( t.p == "end" ) { tokens.pop(); eelse = null; } else if( t.p == "else" ) { tokens.pop(); eelse = parseBlock(tokens); t = tokens.pop(); if( t == null || t.p != "end" ) throw "Unclosed 'else'"; } else { // elseif t.p = t.p.substr(4,t.p.length - 4); eelse = parse(tokens); } return OpIf(e,eif,eelse); } if( p.substr(0,8) == "foreach " ) { p = p.substr(8,p.length - 8); var e = parseExpr(p); var efor = parseBlock(tokens); var t = tokens.pop(); if( t == null || t.p != "end" ) throw "Unclosed 'foreach'"; return OpForeach(e,efor); } if( expr_splitter.match(p) ) return OpExpr(parseExpr(p)); return OpVar(p); } function parseExpr( data : String ) { var l = new List(); var expr = data; while( expr_splitter.match(data) ) { var p = expr_splitter.matchedPos(); var k = p.pos + p.len; if( p.pos != 0 ) l.add({ p : data.substr(0,p.pos), s : true }); var p = expr_splitter.matched(0); l.add({ p : p, s : p.indexOf('"') >= 0 }); data = expr_splitter.matchedRight(); } if( data.length != 0 ) l.add({ p : data, s : true }); var e:Void->Dynamic; try { e = makeExpr(l); if( !l.isEmpty() ) throw l.first().p; } catch( s : String ) { throw "Unexpected '"+s+"' in "+expr; } return function() { try { return e(); } catch( exc : Dynamic ) { throw "Error : "+Std.string(exc)+" in "+expr; } } } function makeConst( v : String ) : Void -> Dynamic { expr_trim.match(v); v = expr_trim.matched(1); if( v.charCodeAt(0) == 34 ) { var str = v.substr(1,v.length-2); return function() return str; } if( expr_int.match(v) ) { var i = Std.parseInt(v); return function() { return i; }; } if( expr_float.match(v) ) { var f = Std.parseFloat(v); return function() { return f; }; } var me = this; return function() { return me.resolve(v); }; } function makePath( e : Void -> Dynamic, l : List ) { var p = l.first(); if( p == null || p.p != "." ) return e; l.pop(); var field = l.pop(); if( field == null || !field.s ) throw field.p; var f = field.p; expr_trim.match(f); f = expr_trim.matched(1); return makePath(function() { return Reflect.field(e(),f); },l); } function makeExpr( l ) { return makePath(makeExpr2(l),l); } function makeExpr2( l : List ) : Void -> Dynamic { var p = l.pop(); if( p == null ) throw ""; if( p.s ) return makeConst(p.p); switch( p.p ) { case "(": var e1:Dynamic = makeExpr(l); var p = l.pop(); if( p == null || p.s ) throw p.p; if( p.p == ")" ) return e1; var e2:Dynamic = makeExpr(l); var p2 = l.pop(); if( p2 == null || p2.p != ")" ) throw p2.p; return switch( p.p ) { case "+": function() { return cast e1() + e2(); }; case "-": function() { return cast e1() - e2(); }; case "*": function() { return cast e1() * e2(); }; case "/": function() { return cast e1() / e2(); }; case ">": function() { return cast e1() > e2(); }; case "<": function() { return cast e1() < e2(); }; case ">=": function() { return cast e1() >= e2(); }; case "<=": function() { return cast e1() <= e2(); }; case "==": function() { return cast e1() == e2(); }; case "!=": function() { return cast e1() != e2(); }; case "&&": function() { return cast e1() && e2(); }; case "||": function() { return cast e1() || e2(); }; default: throw "Unknown operation "+p.p; } case "!": var e : Void->Dynamic = makeExpr(l); return function() { var v : Dynamic = e(); return (v == null || v == false); }; case "-": var e = makeExpr(l); return function() { return -e(); }; } throw p.p; } function run( e : TemplateExpr ) { switch( e ) { case OpVar(v): buf.add(Std.string(resolve(v))); case OpExpr(e): buf.add(Std.string(e())); case OpIf(e,eif,eelse): var v : Dynamic = e(); if( v == null || v == false ) { if( eelse != null ) run(eelse); } else run(eif); case OpStr(str): buf.add(str); case OpBlock(l): for( e in l ) run(e); case OpForeach(e,loop): var v : Dynamic = e(); try { var x : Dynamic = v.iterator(); if( x.hasNext == null ) throw null; v = x; } catch( e : Dynamic ) try { if( v.hasNext == null ) throw null; } catch( e : Dynamic ) { throw "Cannot iter on " + v; } stack.push(context); var v : Iterator = v; for( ctx in v ) { context = ctx; run(loop); } context = stack.pop(); case OpMacro(m,params): var v : Dynamic = Reflect.field(macros,m); var pl = new Array(); var old = buf; pl.push(resolve); for( p in params ) { switch( p ) { case OpVar(v): pl.push(resolve(v)); default: buf = new StringBuf(); run(p); pl.push(buf.toString()); } } buf = old; try { buf.add(Std.string(Reflect.callMethod(macros,v,pl))); } catch( e : Dynamic ) { var plstr = try pl.join(",") catch( e : Dynamic ) "???"; var msg = "Macro call "+m+"("+plstr+") failed ("+Std.string(e)+")"; #if neko neko.Lib.rethrow(msg); #else throw msg; #end } } } } haxe_3.2.1+dfsg.orig/std/haxe/Timer.hx0000664000175000017500000001216012607337712017464 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** The Timer class allows you to create asynchronous timers on platforms that support events. The intended usage is to create an instance of the Timer class with a given interval, set its run() method to a custom function to be invoked and eventually call stop() to stop the Timer. Note that a running Timer may or may not prevent the program to exit automatically when main() returns. It is also possible to extend this class and override its run() method in the child class. **/ class Timer { #if (flash || js || java || python) #if (flash || js) private var id : Null; #elseif java private var timer : java.util.Timer; private var task : java.util.TimerTask; #end /** Creates a new timer that will run every `time_ms` milliseconds. After creating the Timer instance, it calls `this].run` repeatedly, with delays of `time_ms` milliseconds, until `this.stop` is called. The first invocation occurs after `time_ms` milliseconds, not immediately. The accuracy of this may be platform-dependent. **/ public function new( time_ms : Int ){ #if flash var me = this; id = untyped __global__["flash.utils.setInterval"](function() { me.run(); },time_ms); #elseif js var me = this; id = untyped setInterval(function() me.run(),time_ms); #elseif java timer = new java.util.Timer(); timer.scheduleAtFixedRate(task = new TimerTask(this), haxe.Int64.ofInt(time_ms), haxe.Int64.ofInt(time_ms)); #end } /** Stops `this` Timer. After calling this method, no additional invocations of `this.run` will occur. It is not possible to restart `this` Timer once stopped. **/ public function stop() { #if (flash || js) if( id == null ) return; #if flash untyped __global__["flash.utils.clearInterval"](id); #elseif js untyped clearInterval(id); #end id = null; #elseif java timer.cancel(); timer = null; task = null; #end } /** This method is invoked repeatedly on `this` Timer. It can be overridden in a subclass, or rebound directly to a custom function: var timer = new haxe.Timer(1000); // 1000ms delay timer.run = function() { ... } Once bound, it can still be rebound to different functions until `this` Timer is stopped through a call to `this.stop`. **/ public dynamic function run() { } /** Invokes `f` after `time_ms` milliseconds. This is a convenience function for creating a new Timer instance with `time_ms` as argument, binding its run() method to `f` and then stopping `this` Timer upon the first invocation. If `f` is null, the result is unspecified. **/ public static function delay( f : Void -> Void, time_ms : Int ) { var t = new haxe.Timer(time_ms); t.run = function() { t.stop(); f(); }; return t; } #end /** Measures the time it takes to execute `f`, in seconds with fractions. This is a convenience function for calculating the difference between Timer.stamp() before and after the invocation of `f`. The difference is passed as argument to Log.trace(), with "s" appended to denote the unit. The optional `pos` argument is passed through. If `f` is null, the result is unspecified. **/ public static function measure( f : Void -> T, ?pos : PosInfos ) : T { var t0 = stamp(); var r = f(); Log.trace((stamp() - t0) + "s", pos); return r; } /** Returns a timestamp, in seconds with fractions. The value itself might differ depending on platforms, only differences between two values make sense. **/ public static function stamp() : Float { #if flash return flash.Lib.getTimer() / 1000; #elseif (neko || php) return Sys.time(); #elseif js return Date.now().getTime() / 1000; #elseif cpp return untyped __global__.__time_stamp(); #elseif sys return Sys.time(); #else return 0; #end } } #if java @:nativeGen private class TimerTask extends java.util.TimerTask { var timer:Timer; public function new(timer:Timer):Void { super(); this.timer = timer; } @:overload override public function run():Void { timer.run(); } } #end haxe_3.2.1+dfsg.orig/std/haxe/Ucs2.hx0000664000175000017500000001452212607337712017224 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** Cross platform UCS2 string API. **/ abstract Ucs2(String) { @:extern public var length(get,never) : Int; @:extern inline function new(str:String) : Void { // this implementation only allows platforms which have native UCS2 String. // other platforms should create a shadow class in their _std directory #if !(flash || js) throw "Ucs2 String not supported on this platform"; #end this = str; } @:extern inline function get_length() { return this.length; } /** Returns a Ucs2 where all characters of `this` Ucs2 are upper case. Affects the characters `a-z`. Other characters remain unchanged. **/ @:extern public inline function toUpperCase() : Ucs2 { return new Ucs2(this.toUpperCase()); } /** Returns a Ucs2 where all characters of `this` Ucs2 are lower case. Affects the characters `A-Z`. Other characters remain unchanged. **/ @:extern public inline function toLowerCase() : Ucs2 { return new Ucs2(this.toLowerCase()); } /** Returns the character at position `index` of `this` Ucs2. If `index` is negative or exceeds `this.length`, the empty Ucs2 "" is returned. **/ @:extern public inline function charAt(index : Int) : Ucs2 { return new Ucs2(this.charAt(index)); } /** Returns the character code at position `index` of `this` Ucs2. If `index` is negative or exceeds `this.length`, null is returned. To obtain the character code of a single character, "x".code can be used instead to @:extern public inline the character code at compile time. Note that this only works on Ucs2 literals of length 1. **/ @:extern public inline function charCodeAt( index : Int) : Null { return this.charCodeAt(index); } /** Returns the position of the leftmost occurence of `str` within `this` Ucs2. If `startIndex` is given, the search is performed within the substring of `this` Ucs2 starting from `startIndex`. Otherwise the search is performed within `this` Ucs2. In either case, the returned position is relative to the beginning of `this` Ucs2. If `str` cannot be found, -1 is returned. **/ @:extern public inline function indexOf( str : Ucs2, ?startIndex : Int ) : Int { return this.indexOf(str.toNativeString(),startIndex); } /** Returns the position of the rightmost occurence of `str` within `this` Ucs2. If `startIndex` is given, the search is performed within the substring of `this` Ucs2 from 0 to `startIndex`. Otherwise the search is performed within `this` Ucs2. In either case, the returned position is relative to the beginning of `this` Ucs2. If `str` cannot be found, -1 is returned. **/ @:extern public inline function lastIndexOf( str : Ucs2, ?startIndex : Int ) : Int { return this.lastIndexOf(str.toNativeString(),startIndex); } /** Splits `this` Ucs2 at each occurence of `delimiter`. If `this` Ucs2 is the empty Ucs2 "", the result is not consistent across targets and may either be `[]` (on Js, Cpp) or `[""]`. If `delimiter` is the empty Ucs2 "", `this` Ucs2 is split into an Array of `this.length` elements, where the elements correspond to the characters of `this` Ucs2. If `delimiter` is not found within `this` Ucs2, the result is an Array with one element, which equals `this` Ucs2. If `delimiter` is null, the result is unspecified. Otherwise, `this` Ucs2 is split into parts at each occurence of `delimiter`. If `this` Ucs2 starts (or ends) with [delimiter}, the result Array contains a leading (or trailing) empty Ucs2 "" element. Two subsequent delimiters also result in an empty Ucs2 "" element. **/ @:extern public inline function split( delimiter : Ucs2 ) : Array { return cast this.split(delimiter.toNativeString()); } /** Returns `len` characters of `this` Ucs2, starting at position `pos`. If `len` is omitted, all characters from position `pos` to the end of `this` Ucs2 are included. If `pos` is negative, its value is calculated from the end of `this` Ucs2 by `this.length + pos`. If this yields a negative value, 0 is used instead. If the calculated position + `len` exceeds `this.length`, the characters from that position to the end of `this` Ucs2 are returned. If `len` is negative, the result is unspecified. **/ @:extern public inline function substr( pos : Int, ?len : Int ) : Ucs2 { return new Ucs2(this.substr(pos,len)); } /** Returns the part of `this` Ucs2 from `startIndex` to `endIndex`. If `startIndex` or `endIndex` are negative, 0 is used instead. If `startIndex` exceeds `endIndex`, they are swapped. If the (possibly swapped) `endIndex` is omitted or exceeds `this.length`, `this.length` is used instead. If the (possibly swapped) `startIndex` exceeds `this.length`, the empty Ucs2 "" is returned. **/ @:extern public inline function substring( startIndex : Int, ?endIndex : Int ) : Ucs2 { return new Ucs2(this.substring(startIndex,endIndex)); } /** Returns the native underlying String. **/ @:extern public inline function toNativeString() : String { return this; } /** Returns the Ucs2 corresponding to the character code `code`. If `code` is negative or has another invalid value, the result is unspecified. **/ @:extern public static inline function fromCharCode( code : Int ) : Ucs2 { return new Ucs2(String.fromCharCode(code)); } }haxe_3.2.1+dfsg.orig/std/haxe/Unserializer.hx0000664000175000017500000002773512607337712021076 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; @:noDoc typedef TypeResolver = { function resolveClass( name : String ) : Class; function resolveEnum( name : String ) : Enum; } /** The Unserializer class is the complement to the Serializer class. It parses a serialization String and creates objects from the contained data. This class can be used in two ways: - create a new Unserializer() instance with a given serialization String, then call its unserialize() method until all values are extracted - call Unserializer.run() to unserialize a single value from a given String **/ class Unserializer { /** This value can be set to use custom type resolvers. A type resolver finds a Class or Enum instance from a given String. By default, the haxe Type Api is used. A type resolver must provide two methods: 1. resolveClass(name:String):Class is called to determine a Class from a class name 2. resolveEnum(name:String):Enum is called to determine an Enum from an enum name This value is applied when a new Unserializer instance is created. Changing it afterwards has no effect on previously created instances. **/ public static var DEFAULT_RESOLVER : TypeResolver = Type; static var BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%:"; #if !neko static var CODES = null; static function initCodes() { var codes = #if flash new flash.utils.ByteArray(); #else new Array(); #end for( i in 0...BASE64.length ) codes[StringTools.fastCodeAt(BASE64,i)] = i; return codes; } #end var buf : String; var pos : Int; var length : Int; var cache : Array; var scache : Array; var resolver : TypeResolver; #if neko var upos : Int; #end /** Creates a new Unserializer instance, with its internal buffer initialized to `buf`. This does not parse `buf` immediately. It is parsed only when calls to `this.unserialize` are made. Each Unserializer instance maintains its own cache. **/ public function new( buf : String ) { this.buf = buf; length = buf.length; pos = 0; #if neko upos = 0; #end scache = new Array(); cache = new Array(); var r = DEFAULT_RESOLVER; if( r == null ) { r = Type; DEFAULT_RESOLVER = r; } setResolver(r); } /** Sets the type resolver of `this` Unserializer instance to `r`. If `r` is null, a special resolver is used which returns null for all input values. See DEFAULT_RESOLVER for more information on type resolvers. **/ public function setResolver( r ) { if( r == null ) resolver = { resolveClass : function(_) { return null; }, resolveEnum : function(_) { return null; } }; else resolver = r; } /** Gets the type resolver of `this` Unserializer instance. See DEFAULT_RESOLVER for more information on type resolvers. **/ public function getResolver() { return resolver; } inline function get(p) : Int { return StringTools.fastCodeAt(buf, p); } function readDigits() { var k = 0; var s = false; var fpos = pos; while( true ) { var c = get(pos); if( StringTools.isEof(c) ) break; if( c == "-".code ) { if( pos != fpos ) break; s = true; pos++; continue; } if( c < "0".code || c > "9".code ) break; k = k * 10 + (c - "0".code); pos++; } if( s ) k *= -1; return k; } function readFloat() { var p1 = pos; while( true ) { var c = get(pos); // + - . , 0-9 if( (c >= 43 && c < 58) || c == "e".code || c == "E".code ) pos++; else break; } return Std.parseFloat(buf.substr(p1,pos-p1)); } function unserializeObject(o) { while( true ) { if( pos >= length ) throw "Invalid object"; if( get(pos) == "g".code ) break; var k = unserialize(); if( !Std.is(k,String) ) throw "Invalid object key"; var v = unserialize(); Reflect.setField(o,k,v); } pos++; } function unserializeEnum( edecl, tag ) { if( get(pos++) != ":".code ) throw "Invalid enum format"; var nargs = readDigits(); if( nargs == 0 ) return Type.createEnum(edecl,tag); var args = new Array(); while( nargs-- > 0 ) args.push(unserialize()); return Type.createEnum(edecl,tag,args); } /** Unserializes the next part of `this` Unserializer instance and returns the according value. This function may call `this.resolver.resolveClass` to determine a Class from a String, and `this.resolver.resolveEnum` to determine an Enum from a String. If `this` Unserializer instance contains no more or invalid data, an exception is thrown. This operation may fail on structurally valid data if a type cannot be resolved or if a field cannot be set. This can happen when unserializing Strings that were serialized on a different haxe target, in which the serialization side has to make sure not to include platform-specific data. Classes are created from Type.createEmptyInstance, which means their constructors are not called. **/ public function unserialize() : Dynamic { switch( get(pos++) ) { case "n".code: return null; case "t".code: return true; case "f".code: return false; case "z".code: return 0; case "i".code: return readDigits(); case "d".code: return readFloat(); case "y".code: var len = readDigits(); if( get(pos++) != ":".code || length - pos < len ) throw "Invalid string length"; var s = buf.substr(pos,len); pos += len; s = StringTools.urlDecode(s); scache.push(s); return s; case "k".code: return Math.NaN; case "m".code: return Math.NEGATIVE_INFINITY; case "p".code: return Math.POSITIVE_INFINITY; case "a".code: var buf = buf; var a = new Array(); cache.push(a); while( true ) { var c = get(pos); if( c == "h".code ) { pos++; break; } if( c == "u".code ) { pos++; var n = readDigits(); a[a.length+n-1] = null; } else a.push(unserialize()); } return a; case "o".code: var o = {}; cache.push(o); unserializeObject(o); return o; case "r".code: var n = readDigits(); if( n < 0 || n >= cache.length ) throw "Invalid reference"; return cache[n]; case "R".code: var n = readDigits(); if( n < 0 || n >= scache.length ) throw "Invalid string reference"; return scache[n]; case "x".code: throw unserialize(); case "c".code: var name = unserialize(); var cl = resolver.resolveClass(name); if( cl == null ) throw "Class not found " + name; var o = Type.createEmptyInstance(cl); cache.push(o); unserializeObject(o); return o; case "w".code: var name = unserialize(); var edecl = resolver.resolveEnum(name); if( edecl == null ) throw "Enum not found " + name; var e = unserializeEnum(edecl, unserialize()); cache.push(e); return e; case "j".code: var name = unserialize(); var edecl = resolver.resolveEnum(name); if( edecl == null ) throw "Enum not found " + name; pos++; /* skip ':' */ var index = readDigits(); var tag = Type.getEnumConstructs(edecl)[index]; if( tag == null ) throw "Unknown enum index "+name+"@"+index; var e = unserializeEnum(edecl, tag); cache.push(e); return e; case "l".code: var l = new List(); cache.push(l); var buf = buf; while( get(pos) != "h".code ) l.add(unserialize()); pos++; return l; case "b".code: var h = new haxe.ds.StringMap(); cache.push(h); var buf = buf; while( get(pos) != "h".code ) { var s = unserialize(); h.set(s,unserialize()); } pos++; return h; case "q".code: var h = new haxe.ds.IntMap(); cache.push(h); var buf = buf; var c = get(pos++); while( c == ":".code ) { var i = readDigits(); h.set(i,unserialize()); c = get(pos++); } if( c != "h".code ) throw "Invalid IntMap format"; return h; case "M".code: var h = new haxe.ds.ObjectMap(); cache.push(h); var buf = buf; while( get(pos) != "h".code ) { var s = unserialize(); h.set(s,unserialize()); } pos++; return h; case "v".code: var d; if( get(pos) >= '0'.code && get(pos) <= '9'.code && get(pos + 1) >= '0'.code && get(pos + 1) <= '9'.code && get(pos + 2) >= '0'.code && get(pos + 2) <= '9'.code && get(pos + 3) >= '0'.code && get(pos + 3) <= '9'.code && get(pos + 4) == '-'.code ) { // Included for backwards compatibility d = Date.fromString(buf.substr(pos,19)); pos += 19; } else d = Date.fromTime(readFloat()); cache.push(d); return d; case "s".code: var len = readDigits(); var buf = buf; if( get(pos++) != ":".code || length - pos < len ) throw "Invalid bytes length"; #if neko var bytes = haxe.io.Bytes.ofData( base_decode(untyped buf.substr(pos,len).__s,untyped BASE64.__s) ); #else var codes = CODES; if( codes == null ) { codes = initCodes(); CODES = codes; } var i = pos; var rest = len & 3; var size = (len >> 2) * 3 + ((rest >= 2) ? rest - 1 : 0); var max = i + (len - rest); var bytes = haxe.io.Bytes.alloc(size); var bpos = 0; while( i < max ) { var c1 = codes[StringTools.fastCodeAt(buf,i++)]; var c2 = codes[StringTools.fastCodeAt(buf,i++)]; bytes.set(bpos++,(c1 << 2) | (c2 >> 4)); var c3 = codes[StringTools.fastCodeAt(buf,i++)]; bytes.set(bpos++,(c2 << 4) | (c3 >> 2)); var c4 = codes[StringTools.fastCodeAt(buf,i++)]; bytes.set(bpos++,(c3 << 6) | c4); } if( rest >= 2 ) { var c1 = codes[StringTools.fastCodeAt(buf,i++)]; var c2 = codes[StringTools.fastCodeAt(buf,i++)]; bytes.set(bpos++,(c1 << 2) | (c2 >> 4)); if( rest == 3 ) { var c3 = codes[StringTools.fastCodeAt(buf,i++)]; bytes.set(bpos++,(c2 << 4) | (c3 >> 2)); } } #end pos += len; cache.push(bytes); return bytes; case "C".code: var name = unserialize(); var cl = resolver.resolveClass(name); if( cl == null ) throw "Class not found " + name; var o : Dynamic = Type.createEmptyInstance(cl); cache.push(o); o.hxUnserialize(this); if( get(pos++) != "g".code ) throw "Invalid custom data"; return o; case "A".code: var name = unserialize(); var cl = resolver.resolveClass(name); if( cl == null ) throw "Class not found " + name; return cl; case "B".code: var name = unserialize(); var e = resolver.resolveEnum(name); if( e == null ) throw "Enum not found " + name; return e; default: } pos--; throw ("Invalid char "+buf.charAt(pos)+" at position "+pos); } /** Unserializes `v` and returns the according value. This is a convenience function for creating a new instance of Unserializer with `v` as buffer and calling its unserialize() method once. **/ public static function run( v : String ) : Dynamic { return new Unserializer(v).unserialize(); } #if neko static var base_decode = neko.Lib.load("std","base_decode",2); #end } haxe_3.2.1+dfsg.orig/std/haxe/Utf8.hx0000664000175000017500000000620512607337712017235 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; /** Since all platforms does not guarantee that String always uses UTF-8 encoding, you can use this crossplatform API to perform operations on such strings. **/ class Utf8 { var __b : String; /** Allocate a new Utf8 buffer using an optional bytes size. **/ public function new( ?size : Int ) { __b = ""; } /** Add the given UTF8 character code to the buffer. **/ public inline function addChar( c : Int ) : Void { __b += String.fromCharCode(c); } /** Returns the buffer converted to a String; **/ public inline function toString() : String { return __b; } /** Call the `chars` function for each UTF8 char of the string. **/ public static function iter( s : String, chars : Int -> Void ) { for( i in 0...s.length ) chars(s.charCodeAt(i)); } /** Encode the input ISO string into the corresponding UTF8 one. **/ public static function encode( s : String ) : String { throw "Not implemented"; } /** Decode an UTF8 string back to an ISO string. Throw an exception if a given UTF8 character is not supported by the decoder. **/ public static function decode( s : String ) : String { throw "Not implemented"; } /** Similar to `String.charCodeAt` but uses the UTF8 character position. **/ public static inline function charCodeAt( s : String, index : Int ) : Int { return s.charCodeAt(index); } /** Tells if the String is correctly encoded as UTF8. **/ public static inline function validate( s : String ) : Bool { return true; } /** Returns the number of UTF8 chars of the String. **/ #if js @:extern #end public static inline function length( s : String ) : Int { return s.length; } /** Compare two UTF8 strings, character by character. **/ public static function compare( a : String, b : String ) : Int { return a > b ? 1 : (a == b ? 0 : -1); } /** This is similar to `String.substr` but the `pos` and `len` parts are considering UTF8 characters. **/ public static inline function sub( s : String, pos : Int, len : Int ) : String { return s.substr(pos,len); } }haxe_3.2.1+dfsg.orig/std/haxe/crypto/Adler32.hx0000664000175000017500000000412012607337712021115 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Calculates the Adler32 of the given Bytes. */ class Adler32 { var a1 : Int; var a2 : Int; public function new() { a1 = 1; a2 = 0; } public function get() { return (a2 << 16) | a1; } public function update( b : haxe.io.Bytes, pos, len ) { var a1 = a1, a2 = a2; for( p in pos...pos + len ) { var c = b.get(p); a1 = (a1 + c) % 65521; a2 = (a2 + a1) % 65521; } this.a1 = a1; this.a2 = a2; } public function equals( a : Adler32 ) { return a.a1 == a1 && a.a2 == a2; } public function toString() { return StringTools.hex(a2,8) + StringTools.hex(a1,8); } public static function read( i : haxe.io.Input ) { var a = new Adler32(); var a2a = i.readByte(); var a2b = i.readByte(); var a1a = i.readByte(); var a1b = i.readByte(); a.a1 = (a1a << 8) | a1b; a.a2 = (a2a << 8) | a2b; return a; } public static function make( b : haxe.io.Bytes ) { var a = new Adler32(); a.update(b,0,b.length); return a.get(); } } haxe_3.2.1+dfsg.orig/std/haxe/crypto/Base64.hx0000664000175000017500000000365712607337712020763 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Allows to encode/decode String and bytes using Base64 encoding. **/ class Base64 { public static var CHARS(default,null) = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; public static var BYTES(default,null) = haxe.io.Bytes.ofString(CHARS); public static function encode( bytes : haxe.io.Bytes, complement = true ) : String { var str = new BaseCode(BYTES).encodeBytes(bytes).toString(); if( complement ) switch (bytes.length % 3) { case 1: str += "=="; case 2: str += "="; default: } return str; } public static function decode( str : String, complement = true ) : haxe.io.Bytes { if( complement ) while( str.charCodeAt(str.length-1) == "=".code ) str = str.substr(0,-1); return new BaseCode(BYTES).decodeBytes(haxe.io.Bytes.ofString(str)); } } haxe_3.2.1+dfsg.orig/std/haxe/crypto/BaseCode.hx0000664000175000017500000001013112607337712021365 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Allows to encode/decode String and bytes using a power of two base dictionnary. **/ class BaseCode { var base : haxe.io.Bytes; var nbits : Int; var tbl : Array; public function new( base : haxe.io.Bytes ) { var len = base.length; var nbits = 1; while( len > 1 << nbits ) nbits++; if( nbits > 8 || len != 1 << nbits ) throw "BaseCode : base length must be a power of two."; this.base = base; this.nbits = nbits; } public function encodeBytes( b : haxe.io.Bytes ) : haxe.io.Bytes { #if (neko && !interp) return haxe.io.Bytes.ofData( base_encode(b.getData(),base.getData()) ); #else var nbits = this.nbits; var base = this.base; var size = Std.int(b.length * 8 / nbits); var out = haxe.io.Bytes.alloc(size + (((b.length * 8) % nbits == 0) ? 0 : 1) ); var buf = 0; var curbits = 0; var mask = (1 << nbits) - 1; var pin = 0; var pout = 0; while( pout < size ) { while( curbits < nbits ) { curbits += 8; buf <<= 8; buf |= b.get(pin++); } curbits -= nbits; out.set(pout++,base.get((buf >> curbits) & mask)); } if( curbits > 0 ) out.set(pout++,base.get((buf << (nbits - curbits)) & mask)); return out; #end } function initTable() { var tbl = new Array(); for( i in 0...256 ) tbl[i] = -1; for( i in 0...base.length ) tbl[base.get(i)] = i; this.tbl = tbl; } public function decodeBytes( b : haxe.io.Bytes ) : haxe.io.Bytes { #if (neko && !interp) return haxe.io.Bytes.ofData( base_decode(b.getData(),base.getData()) ); #else var nbits = this.nbits; var base = this.base; if( this.tbl == null ) initTable(); var tbl = this.tbl; var size = (b.length * nbits) >> 3; var out = haxe.io.Bytes.alloc(size); var buf = 0; var curbits = 0; var pin = 0; var pout = 0; while( pout < size ) { while( curbits < 8 ) { curbits += nbits; buf <<= nbits; var i = tbl[b.get(pin++)]; if( i == -1 ) throw "BaseCode : invalid encoded char"; buf |= i; } curbits -= 8; out.set(pout++,(buf >> curbits) & 0xFF); } return out; #end } public function encodeString( s : String ) { #if (neko && !interp) return neko.NativeString.toString( base_encode(neko.NativeString.ofString(s),base.getData()) ); #else return encodeBytes(haxe.io.Bytes.ofString(s)).toString(); #end } public function decodeString( s : String ) { #if (neko && !interp) return neko.NativeString.toString( base_decode(neko.NativeString.ofString(s),base.getData()) ); #else return decodeBytes(haxe.io.Bytes.ofString(s)).toString(); #end } public static function encode( s : String, base : String ) { var b = new BaseCode(haxe.io.Bytes.ofString(base)); return b.encodeString(s); } public static function decode( s : String, base : String ) { var b = new BaseCode(haxe.io.Bytes.ofString(base)); return b.decodeString(s); } #if neko private static var base_encode = neko.Lib.load("std","base_encode",2); private static var base_decode = neko.Lib.load("std","base_decode",2); #end } haxe_3.2.1+dfsg.orig/std/haxe/crypto/Crc32.hx0000664000175000017500000000437712607337712020613 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Calculates the Crc32 of the given Bytes. */ class Crc32 { var crc : Int; public function new() { crc = 0xFFFFFFFF; } public function byte( b : Int ) { var tmp = (crc ^ b) & 0xFF; for( j in 0...8 ) { if( tmp & 1 == 1 ) tmp = (tmp >>> 1) ^ 0xEDB88320; else tmp >>>= 1; } crc = (crc >>> 8) ^ tmp; } public function update( b : haxe.io.Bytes, pos, len ) { var b = b.getData(); for( i in pos...pos+len ) { var tmp = (crc ^ haxe.io.Bytes.fastGet(b,i)) & 0xFF; for( j in 0...8 ) { if( tmp & 1 == 1 ) tmp = (tmp >>> 1) ^ 0xEDB88320; else tmp >>>= 1; } crc = (crc >>> 8) ^ tmp; } } public function get() { return crc ^ 0xFFFFFFFF; } /** Calculates the CRC32 of the given data bytes **/ public static function make( data : haxe.io.Bytes ) : Int { var init = 0xFFFFFFFF; var crc = init; var b = data.getData(); for( i in 0...data.length ) { var tmp = (crc ^ haxe.io.Bytes.fastGet(b,i)) & 0xFF; for( j in 0...8 ) { if( tmp & 1 == 1 ) tmp = (tmp >>> 1) ^ 0xEDB88320; else tmp >>>= 1; } crc = (crc >>> 8) ^ tmp; } return crc ^ init; } } haxe_3.2.1+dfsg.orig/std/haxe/crypto/Hmac.hx0000664000175000017500000000502112607337712020572 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Hash methods for Hmac calculation. */ enum HashMethod { MD5; SHA1; SHA256; } /** Calculates a Hmac of the given Bytes using a HashMethod. */ class Hmac { var method : HashMethod; var blockSize : Int; var length : Int; public function new( hashMethod : HashMethod ) { method = hashMethod; blockSize = switch ( hashMethod ) { case MD5, SHA1, SHA256: 64; } length = switch ( hashMethod ) { case MD5: 16; case SHA1: 20; case SHA256: 32; } } inline function doHash( b : haxe.io.Bytes ) : haxe.io.Bytes { return switch ( method ) { case MD5: Md5.make(b); case SHA1: Sha1.make(b); case SHA256: Sha256.make(b); } } function nullPad( s : haxe.io.Bytes, chunkLen : Int ) : haxe.io.Bytes { var r = chunkLen - (s.length % chunkLen); if(r == chunkLen && s.length != 0) return s; var sb = new haxe.io.BytesBuffer(); sb.add(s); for(x in 0...r) sb.addByte(0); return sb.getBytes(); } public function make( key : haxe.io.Bytes, msg : haxe.io.Bytes ) : haxe.io.Bytes { if(key.length > blockSize) { key = doHash(key); } key = nullPad(key, blockSize); var Ki = new haxe.io.BytesBuffer(); var Ko = new haxe.io.BytesBuffer(); for (i in 0...key.length) { Ko.addByte(key.get(i) ^ 0x5c); Ki.addByte(key.get(i) ^ 0x36); } // hash(Ko + hash(Ki + message)) Ki.add(msg); Ko.add(doHash(Ki.getBytes())); return doHash(Ko.getBytes()); } } haxe_3.2.1+dfsg.orig/std/haxe/crypto/Md5.hx0000664000175000017500000002113212607337712020350 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Creates a MD5 of a String. **/ class Md5 { public static function encode( s : String ) : String { #if neko return untyped new String(base_encode(make_md5(s.__s),"0123456789abcdef".__s)); #elseif php return untyped __call__("md5", s); #else var m = new Md5(); var h = m.doEncode(str2blks(s)); return m.hex(h); #end } public static function make( b : haxe.io.Bytes ) : haxe.io.Bytes { #if neko return haxe.io.Bytes.ofData(make_md5(b.getData())); #elseif php return haxe.io.Bytes.ofData(untyped __call__("md5", b.getData(), true)); #else var h = new Md5().doEncode(bytes2blks(b)); var out = haxe.io.Bytes.alloc(16); var p = 0; for( i in 0...4 ) { out.set(p++,h[i]&0xFF); out.set(p++,(h[i]>>8)&0xFF); out.set(p++,(h[i]>>16)&0xFF); out.set(p++,h[i]>>>24); } return out; #end } #if neko static var base_encode = neko.Lib.load("std","base_encode",2); static var make_md5 = neko.Lib.load("std","make_md5",1); #elseif !php /* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Copyright (C) Paul Johnston 1999 - 2000. * Updated by Greg Holt 2000 - 2001. * See http://pajhome.org.uk/site/legal.html for details. */ function new() { } function bitOR(a, b){ var lsb = (a & 0x1) | (b & 0x1); var msb31 = (a >>> 1) | (b >>> 1); return (msb31 << 1) | lsb; } function bitXOR(a, b){ var lsb = (a & 0x1) ^ (b & 0x1); var msb31 = (a >>> 1) ^ (b >>> 1); return (msb31 << 1) | lsb; } function bitAND(a, b){ var lsb = (a & 0x1) & (b & 0x1); var msb31 = (a >>> 1) & (b >>> 1); return (msb31 << 1) | lsb; } function addme(x, y) { var lsw = (x & 0xFFFF)+(y & 0xFFFF); var msw = (x >> 16)+(y >> 16)+(lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function hex( a : Array ){ var str = ""; var hex_chr = "0123456789abcdef"; for( num in a ) for( j in 0...4 ) str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) + hex_chr.charAt((num >> (j * 8)) & 0x0F); return str; } static function bytes2blks( b : haxe.io.Bytes ){ var nblk = ((b.length + 8) >> 6) + 1; var blks = new Array(); //preallocate size var blksSize = nblk * 16; #if (neko || cs || cpp || java) blks[blksSize - 1] = 0; #end #if !(cpp || cs) //C++ and C# will already initialize them with zeroes. for( i in 0...blksSize ) blks[i] = 0; #end var i = 0; while( i < b.length ) { blks[i >> 2] |= b.get(i) << ((((b.length << 3) + i) & 3) << 3); i++; } blks[i >> 2] |= 0x80 << (((b.length * 8 + i) % 4) * 8); var l = b.length * 8; var k = nblk * 16 - 2; blks[k] = (l & 0xFF); blks[k] |= ((l >>> 8) & 0xFF) << 8; blks[k] |= ((l >>> 16) & 0xFF) << 16; blks[k] |= ((l >>> 24) & 0xFF) << 24; return blks; } static function str2blks( str : String ){ var nblk = ((str.length + 8) >> 6) + 1; var blks = new Array(); //preallocate size var blksSize = nblk * 16; #if (neko || cs || cpp || java) blks[blksSize - 1] = 0; #end #if !(cpp || cs) //C++ and C# will already initialize them with zeroes. for( i in 0...blksSize ) blks[i] = 0; #end var i = 0; while( i < str.length ) { blks[i >> 2] |= str.charCodeAt(i) << (((str.length * 8 + i) % 4) * 8); i++; } blks[i >> 2] |= 0x80 << (((str.length * 8 + i) % 4) * 8); var l = str.length * 8; var k = nblk * 16 - 2; blks[k] = (l & 0xFF); blks[k] |= ((l >>> 8) & 0xFF) << 8; blks[k] |= ((l >>> 16) & 0xFF) << 16; blks[k] |= ((l >>> 24) & 0xFF) << 24; return blks; } function rol(num, cnt){ return (num << cnt) | (num >>> (32 - cnt)); } function cmn(q, a, b, x, s, t){ return addme(rol((addme(addme(a, q), addme(x, t))), s), b); } function ff(a, b, c, d, x, s, t){ return cmn(bitOR(bitAND(b, c), bitAND((~b), d)), a, b, x, s, t); } function gg(a, b, c, d, x, s, t){ return cmn(bitOR(bitAND(b, d), bitAND(c, (~d))), a, b, x, s, t); } function hh(a, b, c, d, x, s, t){ return cmn(bitXOR(bitXOR(b, c), d), a, b, x, s, t); } function ii(a, b, c, d, x, s, t){ return cmn(bitXOR(c, bitOR(b, (~d))), a, b, x, s, t); } function doEncode( x : Array ) : Array { var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; var step; var i = 0; while( i < x.length ) { var olda = a; var oldb = b; var oldc = c; var oldd = d; step = 0; a = ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = ff(d, a, b, c, x[i+ 1], 12, -389564586); c = ff(c, d, a, b, x[i+ 2], 17, 606105819); b = ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = ff(b, c, d, a, x[i+ 7], 22, -45705983); a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = ff(c, d, a, b, x[i+10], 17, -42063); b = ff(b, c, d, a, x[i+11], 22, -1990404162); a = ff(a, b, c, d, x[i+12], 7 , 1804603682); d = ff(d, a, b, c, x[i+13], 12, -40341101); c = ff(c, d, a, b, x[i+14], 17, -1502002290); b = ff(b, c, d, a, x[i+15], 22, 1236535329); a = gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = gg(c, d, a, b, x[i+11], 14, 643717713); b = gg(b, c, d, a, x[i+ 0], 20, -373897302); a = gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = gg(d, a, b, c, x[i+10], 9 , 38016083); c = gg(c, d, a, b, x[i+15], 14, -660478335); b = gg(b, c, d, a, x[i+ 4], 20, -405537848); a = gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = gg(d, a, b, c, x[i+14], 9 , -1019803690); c = gg(c, d, a, b, x[i+ 3], 14, -187363961); b = gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = gg(a, b, c, d, x[i+13], 5 , -1444681467); d = gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = gg(b, c, d, a, x[i+12], 20, -1926607734); a = hh(a, b, c, d, x[i+ 5], 4 , -378558); d = hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = hh(c, d, a, b, x[i+11], 16, 1839030562); b = hh(b, c, d, a, x[i+14], 23, -35309556); a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = hh(c, d, a, b, x[i+ 7], 16, -155497632); b = hh(b, c, d, a, x[i+10], 23, -1094730640); a = hh(a, b, c, d, x[i+13], 4 , 681279174); d = hh(d, a, b, c, x[i+ 0], 11, -358537222); c = hh(c, d, a, b, x[i+ 3], 16, -722521979); b = hh(b, c, d, a, x[i+ 6], 23, 76029189); a = hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = hh(d, a, b, c, x[i+12], 11, -421815835); c = hh(c, d, a, b, x[i+15], 16, 530742520); b = hh(b, c, d, a, x[i+ 2], 23, -995338651); a = ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = ii(c, d, a, b, x[i+14], 15, -1416354905); b = ii(b, c, d, a, x[i+ 5], 21, -57434055); a = ii(a, b, c, d, x[i+12], 6 , 1700485571); d = ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = ii(c, d, a, b, x[i+10], 15, -1051523); b = ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = ii(d, a, b, c, x[i+15], 10, -30611744); c = ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = ii(b, c, d, a, x[i+13], 21, 1309151649); a = ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = ii(d, a, b, c, x[i+11], 10, -1120210379); c = ii(c, d, a, b, x[i+ 2], 15, 718787259); b = ii(b, c, d, a, x[i+ 9], 21, -343485551); a = addme(a, olda); b = addme(b, oldb); c = addme(c, oldc); d = addme(d, oldd); i += 16; } return [a,b,c,d]; } #end } haxe_3.2.1+dfsg.orig/std/haxe/crypto/Sha1.hx0000664000175000017500000001046412607337712020525 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Creates a Sha1 of a String. */ class Sha1 { public static function encode( s:String ) : String { #if php return untyped __call__("sha1", s); #else var sh = new Sha1(); var h = sh.doEncode(str2blks(s)); return sh.hex(h); #end } public static function make( b : haxe.io.Bytes ) : haxe.io.Bytes { #if php return haxe.io.Bytes.ofData(untyped __call__("sha1", b.getData(), true)); #else var h = new Sha1().doEncode(bytes2blks(b)); var out = haxe.io.Bytes.alloc(20); var p = 0; for( i in 0...5 ) { out.set(p++,h[i]>>>24); out.set(p++,(h[i]>>16)&0xFF); out.set(p++,(h[i]>>8)&0xFF); out.set(p++,h[i]&0xFF); } return out; #end } #if !php function new() { } function doEncode( x : Array ) : Array { var w = new Array(); var a = 0x67452301; var b = 0xEFCDAB89; var c = 0x98BADCFE; var d = 0x10325476; var e = 0xC3D2E1F0; var i = 0; while( i < x.length ) { var olda = a; var oldb = b; var oldc = c; var oldd = d; var olde = e; var j = 0; while( j < 80 ) { if(j < 16) w[j] = x[i + j]; else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1); var t = rol(a, 5) + ft(j, b, c, d) + e + w[j] + kt(j); e = d; d = c; c = rol(b, 30); b = a; a = t; j++; } a += olda; b += oldb; c += oldc; d += oldd; e += olde; i += 16; } return [a,b,c,d,e]; } /* Convert a string to a sequence of 16-word blocks, stored as an array. Append padding bits and the length, as described in the SHA1 standard. */ static function str2blks( s :String ) : Array { var nblk = ((s.length + 8) >> 6) + 1; var blks = new Array(); for (i in 0...nblk*16) blks[i] = 0; for (i in 0...s.length){ var p = i >> 2; blks[p] |= s.charCodeAt(i) << (24 - ((i & 3) << 3)); } var i = s.length; var p = i >> 2; blks[p] |= 0x80 << (24 - ((i & 3) << 3)); blks[nblk * 16 - 1] = s.length * 8; return blks; } static function bytes2blks( b : haxe.io.Bytes ) : Array { var nblk = ((b.length + 8) >> 6) + 1; var blks = new Array(); for (i in 0...nblk*16) blks[i] = 0; for (i in 0...b.length){ var p = i >> 2; blks[p] |= b.get(i) << (24 - ((i & 3) << 3)); } var i = b.length; var p = i >> 2; blks[p] |= 0x80 << (24 - ((i & 3) << 3)); blks[nblk * 16 - 1] = b.length * 8; return blks; } /** Bitwise rotate a 32-bit number to the left */ inline function rol( num : Int, cnt : Int ) : Int { return (num << cnt) | (num >>> (32 - cnt)); } /** Perform the appropriate triplet combination function for the current iteration */ function ft( t : Int, b : Int, c : Int, d : Int ) : Int { if ( t < 20 ) return (b & c) | ((~b) & d); if ( t < 40 ) return b ^ c ^ d; if ( t < 60 ) return (b & c) | (b & d) | (c & d); return b ^ c ^ d; } /** Determine the appropriate additive constant for the current iteration */ function kt( t : Int ) : Int { if( t < 20) return 0x5A827999; if ( t < 40) return 0x6ED9EBA1; if (t < 60) return 0x8F1BBCDC; return 0xCA62C1D6; } function hex( a : Array ){ var str = ""; for( num in a ) { str += StringTools.hex(num, 8); } return str.toLowerCase(); } #end } haxe_3.2.1+dfsg.orig/std/haxe/crypto/Sha224.hx0000664000175000017500000001461612607337712020677 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of Charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERChANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Creates a Sha224 of a String. */ class Sha224 { public static function encode( s:String ) : String { #if php return untyped __call__("hash", "sha224", s); #else var sh = new Sha224(); var h = sh.doEncode(s, s.length*8); return sh.hex(h); #end } public static function make( b : haxe.io.Bytes ) : haxe.io.Bytes { #if php return haxe.io.Bytes.ofData(untyped __call__("hash", "sha224", b.getData(), true)); #else var h = new Sha224().doEncode(b.toString(), b.length*8); var out = haxe.io.Bytes.alloc(28); var p = 0; for( i in 0...8 ) { out.set(p++,h[i]>>>24); out.set(p++,(h[i]>>16)&0xFF); out.set(p++,(h[i]>>8)&0xFF); out.set(p++,h[i]&0xFF); } return out; #end } public function new() { } function doEncode( str : String, strlen : Int ) : Array { var K : Array = [ 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6 , 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351 , 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2 ]; var HASH : Array = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ]; var W = new Array(); W[64] = 0; var a:Int,b:Int,c:Int,d:Int,e:Int,f:Int,g:Int,h:Int,i:Int,j:Int; var T1, T2; var i : Int = 0; var blocks : Array = str2blks(str); blocks[strlen >> 5] |= 0x80 << (24 - strlen % 32); blocks[((strlen + 64 >> 9) << 4) + 15] = strlen; while ( i < blocks.length ) { a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7]; for ( j in 0...64 ) { if (j < 16) { W[j] = blocks[j + i]; } else { W[j] = safeAdd(safeAdd(safeAdd(Gamma1(W[j - 2]), W[j - 7]), Gamma0(W[j - 15])), W[j - 16]); } T1 = safeAdd(safeAdd(safeAdd(safeAdd(h, Sigma1(e)), Ch(e, f, g)), K[j]), W[j]); T2 = safeAdd(Sigma0(a), Maj(a, b, c)); h = g; g = f; f = e; e = safeAdd(d, T1); d = c; c = b; b = a; a = safeAdd(T1, T2); } HASH[0] = safeAdd(a, HASH[0]); HASH[1] = safeAdd(b, HASH[1]); HASH[2] = safeAdd(c, HASH[2]); HASH[3] = safeAdd(d, HASH[3]); HASH[4] = safeAdd(e, HASH[4]); HASH[5] = safeAdd(f, HASH[5]); HASH[6] = safeAdd(g, HASH[6]); HASH[7] = safeAdd(h, HASH[7]); i += 16; } return HASH; } static function str2blks( s :String ) : Array { var nblk = ((s.length + 8) >> 6) + 1; var blks = new Array(); for (i in 0...nblk*16) blks[i] = 0; for (i in 0...s.length){ var p = i >> 2; blks[p] |= s.charCodeAt(i) << (24 - ((i & 3) << 3)); } var i = s.length; var p = i >> 2; blks[p] |= 0x80 << (24 - ((i & 3) << 3)); blks[nblk * 16 - 1] = s.length * 8; return blks; } static function safeAdd(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >>> 16) + (y >>> 16) + (lsw >>> 16); return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF); } // ++ function ROTR(X, n) { return ( X >>> n ) | (X << (32 - n)); } // ++ function SHR(X, n) { return ( X >>> n ); } // ++ function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); } // ++ function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); } function Sigma0(x) { return ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22); } function Sigma1(x) { return ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25); } function Gamma0(x) { return ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3); } function Gamma1(x) { return ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10); } function hex( a : Array ){ var str = ""; for( num in a ) { str += StringTools.hex(num, 8); } return str.substring(0, 56).toLowerCase(); } } haxe_3.2.1+dfsg.orig/std/haxe/crypto/Sha256.hx0000664000175000017500000001316012607337712020675 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.crypto; /** Creates a Sha256 of a String. */ class Sha256 { public static function encode( s:String ) : String { #if php return untyped __call__("hash", "sha256", s); #else var sh = new Sha256(); var h = sh.doEncode(str2blks(s), s.length*8); return sh.hex(h); #end } public static function make( b : haxe.io.Bytes ) : haxe.io.Bytes { #if php return haxe.io.Bytes.ofData(untyped __call__("hash", "sha256", b.getData(), true)); #else var h = new Sha256().doEncode(bytes2blks(b), b.length*8); var out = haxe.io.Bytes.alloc(32); var p = 0; for( i in 0...8 ) { out.set(p++,h[i]>>>24); out.set(p++,(h[i]>>16)&0xFF); out.set(p++,(h[i]>>8)&0xFF); out.set(p++,h[i]&0xFF); } return out; #end } public function new() { } function doEncode( m : Array, l : Int ) : Array { var K : Array = [ 0x428A2F98,0x71374491,0xB5C0FBCF,0xE9B5DBA5,0x3956C25B, 0x59F111F1,0x923F82A4,0xAB1C5ED5,0xD807AA98,0x12835B01, 0x243185BE,0x550C7DC3,0x72BE5D74,0x80DEB1FE,0x9BDC06A7, 0xC19BF174,0xE49B69C1,0xEFBE4786,0xFC19DC6,0x240CA1CC, 0x2DE92C6F,0x4A7484AA,0x5CB0A9DC,0x76F988DA,0x983E5152, 0xA831C66D,0xB00327C8,0xBF597FC7,0xC6E00BF3,0xD5A79147, 0x6CA6351,0x14292967,0x27B70A85,0x2E1B2138,0x4D2C6DFC, 0x53380D13,0x650A7354,0x766A0ABB,0x81C2C92E,0x92722C85, 0xA2BFE8A1,0xA81A664B,0xC24B8B70,0xC76C51A3,0xD192E819, 0xD6990624,0xF40E3585,0x106AA070,0x19A4C116,0x1E376C08, 0x2748774C,0x34B0BCB5,0x391C0CB3,0x4ED8AA4A,0x5B9CCA4F, 0x682E6FF3,0x748F82EE,0x78A5636F,0x84C87814,0x8CC70208, 0x90BEFFFA,0xA4506CEB,0xBEF9A3F7,0xC67178F2 ]; var HASH : Array = [ 0x6A09E667,0xBB67AE85,0x3C6EF372,0xA54FF53A, 0x510E527F,0x9B05688C,0x1F83D9AB,0x5BE0CD19 ]; var W = new Array(); W[64] = 0; var a:Int,b:Int,c:Int,d:Int,e:Int,f:Int,g:Int,h:Int; var T1, T2; m[l >> 5] |= 0x80 << (24 - l % 32); m[((l + 64 >> 9) << 4) + 15] = l; var i : Int = 0; while ( i < m.length ) { a = HASH[0]; b = HASH[1]; c = HASH[2]; d = HASH[3]; e = HASH[4]; f = HASH[5]; g = HASH[6]; h = HASH[7]; for ( j in 0...64 ) { if (j < 16) W[j] = m[j + i]; else W[j] = safeAdd(safeAdd(safeAdd(Gamma1256(W[j - 2]), W[j - 7]), Gamma0256(W[j - 15])), W[j - 16]); T1 = safeAdd(safeAdd(safeAdd(safeAdd(h, Sigma1256(e)), Ch(e, f, g)), K[j]), W[j]); T2 = safeAdd(Sigma0256(a), Maj(a, b, c)); h = g; g = f; f = e; e = safeAdd(d, T1); d = c; c = b; b = a; a = safeAdd(T1, T2); } HASH[0] = safeAdd(a, HASH[0]); HASH[1] = safeAdd(b, HASH[1]); HASH[2] = safeAdd(c, HASH[2]); HASH[3] = safeAdd(d, HASH[3]); HASH[4] = safeAdd(e, HASH[4]); HASH[5] = safeAdd(f, HASH[5]); HASH[6] = safeAdd(g, HASH[6]); HASH[7] = safeAdd(h, HASH[7]); i += 16; } return HASH; } /* Convert a string to a sequence of 16-word blocks, stored as an array. Append padding bits and the length, as described in the SHA1 standard. */ static function str2blks( s :String ) : Array { var nblk = ((s.length + 8) >> 6) + 1; var blks = new Array(); for (i in 0...nblk*16) blks[i] = 0; for (i in 0...s.length){ var p = i >> 2; blks[p] |= s.charCodeAt(i) << (24 - ((i & 3) << 3)); } var i = s.length; var p = i >> 2; blks[p] |= 0x80 << (24 - ((i & 3) << 3)); blks[nblk * 16 - 1] = s.length * 8; return blks; } static function bytes2blks( b : haxe.io.Bytes ) : Array { var nblk = ((b.length + 8) >> 6) + 1; var blks = new Array(); for (i in 0...nblk*16) blks[i] = 0; for (i in 0...b.length){ var p = i >> 2; blks[p] |= b.get(i) << (24 - ((i & 3) << 3)); } var i = b.length; var p = i >> 2; blks[p] |= 0x80 << (24 - ((i & 3) << 3)); blks[nblk * 16 - 1] = b.length * 8; return blks; } function S(X, n) { return ( X >>> n ) | (X << (32 - n)); } function R(X, n) { return ( X >>> n ); } function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); } function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); } function Sigma0256(x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); } function Sigma1256(x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); } function Gamma0256(x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); } function Gamma1256(x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); } function safeAdd(x, y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function hex( a : Array ){ var str = ""; for( num in a ) { str += StringTools.hex(num, 8); } return str.toLowerCase(); } } haxe_3.2.1+dfsg.orig/std/haxe/ds/ArraySort.hx0000664000175000017500000001044112607337712020740 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** ArraySort provides a stable implementation of merge sort through its `sort` method. It should be used instead of `Array.sort` in cases where the order of equal elements has to be retained on all targets. **/ class ArraySort { /** Sorts Array `a` according to the comparison function `cmp`, where `cmp(x,y)` returns 0 if `x == y`, a positive Int if `x > y` and a negative Int if `x < y`. This operation modifies Array `a` in place. This operation is stable: The order of equal elements is preserved. If `a` or `cmp` are null, the result is unspecified. **/ static public function sort(a:Array, cmp:T -> T -> Int) { rec(a, cmp, 0, a.length); } static function rec(a:Array, cmp, from, to) { var middle = (from + to) >> 1; if (to - from < 12) { if (to <= from) return; for (i in (from + 1)...to) { var j = i; while (j > from) { if (compare(a, cmp, j, j - 1) < 0) swap(a, j - 1, j); else break; j--; } } return; } rec(a, cmp, from, middle); rec(a, cmp, middle, to); doMerge(a, cmp, from, middle, to, middle - from, to - middle); } static function doMerge(a:Array, cmp, from, pivot, to, len1, len2) { var first_cut, second_cut, len11, len22, new_mid; if (len1 == 0 || len2 == 0) return; if (len1 + len2 == 2) { if (compare(a, cmp, pivot, from) < 0) swap(a, pivot, from); return; } if (len1 > len2) { len11 = len1 >> 1; first_cut = from + len11; second_cut = lower(a, cmp, pivot, to, first_cut); len22 = second_cut - pivot; } else { len22 = len2 >> 1; second_cut = pivot + len22; first_cut = upper(a, cmp, from, pivot, second_cut); len11 = first_cut - from; } rotate(a, cmp, first_cut, pivot, second_cut); new_mid = first_cut + len22; doMerge(a, cmp, from, first_cut, new_mid, len11, len22); doMerge(a, cmp, new_mid, second_cut, to, len1 - len11, len2 - len22); } static function rotate(a:Array, cmp, from, mid, to) { var n; if (from == mid || mid == to) return; n = gcd(to - from, mid - from); while (n-- != 0) { var val = a[from + n]; var shift = mid - from; var p1 = from + n, p2 = from + n + shift; while (p2 != from + n) { a[p1] = a[p2]; p1 = p2; if (to - p2 > shift) p2 += shift; else p2 = from + (shift - (to - p2)); } a[p1] = val; } } static function gcd(m, n) { while (n != 0) { var t = m % n; m = n; n = t; } return m; } static function upper(a:Array, cmp, from, to, val) { var len = to - from, half, mid; while (len > 0) { half = len >> 1; mid = from + half; if (compare(a, cmp, val, mid) < 0) len = half; else { from = mid + 1; len = len - half - 1; } } return from; } static function lower(a:Array, cmp, from, to, val) { var len = to - from, half, mid; while (len > 0) { half = len >> 1; mid = from + half; if (compare(a, cmp, mid, val) < 0) { from = mid + 1; len = len - half - 1; } else len = half; } return from; } static function swap(a:Array, i, j) { var tmp = a[i]; a[i] = a[j]; a[j] = tmp; } static inline function compare(a:Array, cmp, i, j) { return cmp(a[i], a[j]); } }haxe_3.2.1+dfsg.orig/std/haxe/ds/BalancedTree.hx0000664000175000017500000001507512607337712021333 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** BalancedTree allows key-value mapping with arbitrary keys, as long as they can be ordered. By default, `Reflect.compare` is used in the `compare` method, which can be overridden in subclasses. Operations have a logarithmic average and worst-case cost. Iteration over keys and values, using `keys` and `iterator` respectively, are in-order. **/ class BalancedTree { var root:TreeNode; /** Creates a new BalancedTree, which is initially empty. **/ public function new() { } /** Binds `key` to `value`. If `key` is already bound to a value, that binding disappears. If `key` is null, the result is unspecified. **/ public function set(key:K, value:V) { root = setLoop(key, value, root); } /** Returns the value `key` is bound to. If `key` is not bound to any value, `null` is returned. If `key` is null, the result is unspecified. **/ public function get(key:K):Null { var node = root; while (node != null) { var c = compare(key, node.key); if (c == 0) return node.value; if (c < 0) node = node.left; else node = node.right; } return null; } /** Removes the current binding of `key`. If `key` has no binding, `this` BalancedTree is unchanged and false is returned. Otherwise the binding of `key` is removed and true is returned. If `key` is null, the result is unspecified. **/ public function remove(key:K) { try { root = removeLoop(key, root); return true; } catch (e:String) { return false; } } /** Tells if `key` is bound to a value. This method returns true even if `key` is bound to null. If `key` is null, the result is unspecified. **/ public function exists(key:K) { var node = root; while (node != null) { var c = compare(key, node.key); if (c == 0) return true; else if (c < 0) node = node.left; else node = node.right; } return false; } /** Iterates over the bound values of `this` BalancedTree. This operation is performed in-order. **/ public function iterator():Iterator { var ret = []; iteratorLoop(root, ret); return ret.iterator(); } /** Iterates over the keys of `this` BalancedTree. This operation is performed in-order. **/ public function keys():Iterator { var ret = []; keysLoop(root, ret); return ret.iterator(); } function setLoop(k:K, v:V, node:TreeNode) { if (node == null) return new TreeNode(null, k, v, null); var c = compare(k, node.key); return if (c == 0) new TreeNode(node.left, k, v, node.right, node.get_height()); else if (c < 0) { var nl = setLoop(k, v, node.left); balance(nl, node.key, node.value, node.right); } else { var nr = setLoop(k, v, node.right); balance(node.left, node.key, node.value, nr); } } function removeLoop(k:K, node:TreeNode) { if (node == null) throw "Not_found"; var c = compare(k, node.key); return if (c == 0) merge(node.left, node.right); else if (c < 0) balance(removeLoop(k, node.left), node.key, node.value, node.right); else balance(node.left, node.key, node.value, removeLoop(k, node.right)); } function iteratorLoop(node:TreeNode, acc:Array) { if (node != null) { iteratorLoop(node.left, acc); acc.push(node.value); iteratorLoop(node.right, acc); } } function keysLoop(node:TreeNode, acc:Array) { if (node != null) { keysLoop(node.left, acc); acc.push(node.key); keysLoop(node.right, acc); } } function merge(t1, t2) { if (t1 == null) return t2; if (t2 == null) return t1; var t = minBinding(t2); return balance(t1, t.key, t.value, removeMinBinding(t2)); } function minBinding(t:TreeNode) { return if (t == null) throw "Not_found"; else if (t.left == null) t; else minBinding(t.left); } function removeMinBinding(t:TreeNode) { return if (t.left == null) t.right; else balance(removeMinBinding(t.left), t.key, t.value, t.right); } function balance(l:TreeNode, k:K, v:V, r:TreeNode):TreeNode { var hl = l.get_height(); var hr = r.get_height(); return if (hl > hr + 2) { if (l.left.get_height() >= l.right.get_height()) new TreeNode(l.left, l.key, l.value, new TreeNode(l.right, k, v, r)); else new TreeNode(new TreeNode(l.left,l.key, l.value, l.right.left), l.right.key, l.right.value, new TreeNode(l.right.right, k, v, r)); } else if (hr > hl + 2) { if (r.right.get_height() > r.left.get_height()) new TreeNode(new TreeNode(l, k, v, r.left), r.key, r.value, r.right); else new TreeNode(new TreeNode(l, k, v, r.left.left), r.left.key, r.left.value, new TreeNode(r.left.right, r.key, r.value, r.right)); } else { new TreeNode(l, k, v, r, (hl > hr ? hl : hr) + 1); } } function compare(k1:K, k2:K) { return Reflect.compare(k1, k2); } public function toString() { return root == null ? '{}' : '{${root.toString()}}'; } } class TreeNode { public var left : TreeNode; public var right : TreeNode; public var key : K; public var value : V; #if as3 public #end var _height : Int; public function new(l, k, v, r, h = -1) { left = l; key = k; value = v; right = r; if (h == -1) _height = (left.get_height() > right.get_height() ? left.get_height() : right.get_height()) + 1; else _height = h; } @:extern public inline function get_height() return this == null ? 0 : _height; public function toString() { return (left == null ? "" : left.toString() + ", ") + '$key=$value' + (right == null ? "" : ", " +right.toString()); } }haxe_3.2.1+dfsg.orig/std/haxe/ds/Either.hx0000664000175000017500000000240112607337712020227 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** Either represents values which are either of type `L` (Left) or type `R` (Right). **/ enum Either { Left(v:L); Right(v:R); }haxe_3.2.1+dfsg.orig/std/haxe/ds/EnumValueMap.hx0000664000175000017500000000431712607337712021356 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** EnumValueMap allows mapping of enum value keys to arbitrary values. Keys are compared by value and recursively over their parameters. If any parameter is not an enum value, `Reflect.compare` is used to compare them. **/ class EnumValueMap extends haxe.ds.BalancedTree implements haxe.Constraints.IMap { override function compare(k1:EnumValue, k2:EnumValue):Int { var d = k1.getIndex() - k2.getIndex(); if (d != 0) return d; var p1 = k1.getParameters(); var p2 = k2.getParameters(); if (p1.length == 0 && p2.length == 0) return 0; return compareArgs(p1, p2); } function compareArgs(a1:Array, a2:Array):Int { var ld = a1.length - a2.length; if (ld != 0) return ld; for (i in 0...a1.length) { var d = compareArg(a1[i], a2[i]); if (d != 0) return d; } return 0; } function compareArg(v1:Dynamic, v2:Dynamic):Int { return if (Reflect.isEnumValue(v1) && Reflect.isEnumValue(v2)) { compare(v1, v2); } else if (Std.is(v1, Array) && Std.is(v2, Array)) { compareArgs(v1, v2); } else { Reflect.compare(v1, v2); } } }haxe_3.2.1+dfsg.orig/std/haxe/ds/GenericStack.hx0000664000175000017500000001007412607337712021356 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; #if (flash || cpp) @:generic #end class GenericCell { public var elt : T; public var next : GenericCell; public function new(elt,next) { this.elt = elt; this.next = next; } } #if cpp @:generic private class GenericStackIterator extends cpp.FastIterator { public var current : GenericCell; override public function hasNext():Bool { return current!=null; } override public function next():T { var result = current.elt; current = current.next; return result; } public function new(head) { current = head; } } #end /** A stack of elements. This class is generic, which means one type is generated for each type parameter T on static targets. For example: - `new GenericStack()` generates `GenericStack_Int` - `new GenericStack()` generates `GenericStack_String` The generated name is an implementation detail and should not be relied upon. **/ #if (flash || cpp) @:generic #end class GenericStack { public var head : GenericCell; /** Creates a new empty GenericStack. **/ public function new() { } /** Pushes element `item` onto the stack. **/ public inline function add( item : T ) { head = new GenericCell(item,head); } /** Returns the topmost stack element without removing it. If the stack is empty, null is returned. **/ public inline function first() : Null { return if( head == null ) null else head.elt; } /** Returns the topmost stack element and removes it. If the stack is empty, null is returned. **/ public inline function pop() : Null { var k = head; if( k== null ) return null; else { head = k.next; return k.elt; } } /** Tells if the stack is empty. **/ public inline function isEmpty() : Bool { return (head == null); } /** Removes the first element which is equal to `v` according to the `==` operator. This method traverses the stack until it finds a matching element and unlinks it, returning true. If no matching element is found, false is returned. **/ public function remove( v : T ) : Bool { var prev:GenericCell = null; var l = head; while( l != null ) { if( l.elt == v ) { if( prev == null ) head = l.next; else prev.next = l.next; break; } prev = l; l = l.next; } return (l != null); } #if cpp /** Returns an iterator over the elements of `this` GenericStack. **/ public function iterator() : Iterator { return new GenericStackIterator(head); } #else /** Returns an iterator over the elements of `this` GenericStack. **/ public function iterator() : Iterator { var l = head; return { hasNext : function() { return l != null; }, next : function() { var k = l; l = k.next; return k.elt; } }; } #end /** Returns a String representation of `this` GenericStack. **/ public function toString() { var a = new Array(); var l = head; while( l != null ) { a.push(l.elt); l = l.next; } return "{"+a.join(",")+"}"; } } haxe_3.2.1+dfsg.orig/std/haxe/ds/HashMap.hx0000664000175000017500000000374212607337712020341 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; abstract HashMap(HashMapData) { public inline function new() { this = new HashMapData(); } public inline function set(k:K, v:V) { this.keys.set(k.hashCode(), k); this.values.set(k.hashCode(), v); } public inline function get(k:K) { return this.values.get(k.hashCode()); } public inline function exists(k:K) { return this.values.exists(k.hashCode()); } public inline function remove(k:K) { this.values.remove(k.hashCode()); return this.keys.remove(k.hashCode()); } public inline function keys() { return this.keys.iterator(); } public inline function iterator() { return this.values.iterator(); } } private class HashMapData { public var keys:IntMap; public var values:IntMap; public inline function new() { keys = new IntMap(); values = new IntMap(); } }haxe_3.2.1+dfsg.orig/std/haxe/ds/IntMap.hx0000664000175000017500000000354712607337712020213 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** IntMap allows mapping of Int keys to arbitrary values. See `Map` for documentation details. **/ extern class IntMap implements haxe.Constraints.IMap { /** Creates a new IntMap. **/ public function new() : Void; /** See `Map.set` **/ public function set( key : Int, value : T ) : Void; /** See `Map.get` **/ public function get( key : Int ) : Null; /** See `Map.exists` **/ public function exists( key : Int ) : Bool; /** See `Map.remove` **/ public function remove( key : Int ) : Bool; /** See `Map.keys` **/ public function keys() : Iterator; /** See `Map.iterator` **/ public function iterator() : Iterator; /** See `Map.toString` **/ public function toString() : String; } haxe_3.2.1+dfsg.orig/std/haxe/ds/ListSort.hx0000664000175000017500000000753312607337712020605 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** ListSort provides a stable implementation of merge sort through its `sort` method. It has a O(N.log(N)) complexity and does not require additional memory allocation **/ class ListSort { // Note : we prefer [inline] over [@:generic] here since we want to inline the comparison function as well /** Sorts List `lst` according to the comparison function `cmp`, where `cmp(x,y)` returns 0 if `x == y`, a positive Int if `x > y` and a negative Int if `x < y`. This operation modifies List `a` in place and returns its head once modified. The `prev` of the head is set to the tail of the sorted list. If `list` or `cmp` are null, the result is unspecified. **/ public static inline function sort(list:T, cmp : T -> T -> Int) : T { // ported from http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html if( list == null ) return null; var insize = 1, nmerges, psize = 0, qsize = 0; var p, q, e, tail : T = null; while( true ) { p = list; list = null; tail = null; nmerges = 0; while( p != null ) { nmerges++; q = p; psize = 0; for( i in 0...insize ) { psize++; q = q.next; if( q == null ) break; } qsize = insize; while( psize > 0 || (qsize > 0 && q != null) ) { if( psize == 0 ) { e = q; q = q.next; qsize--; } else if( qsize == 0 || q == null || cmp(p,q) <= 0 ) { e = p; p = p.next; psize--; } else { e = q; q = q.next; qsize--; } if( tail != null ) tail.next = e; else list = e; e.prev = tail; tail = e; } p = q; } tail.next = null; if( nmerges <= 1 ) break; insize *= 2; } list.prev = tail; return list; } /** Same as [sort] but on single linked list. **/ public static inline function sortSingleLinked(list:T, cmp : T -> T -> Int) : T { if( list == null ) return null; var insize = 1, nmerges, psize = 0, qsize = 0; var p, q, e, tail : T; while( true ) { p = list; list = null; tail = null; nmerges = 0; while( p != null ) { nmerges++; q = p; psize = 0; for( i in 0...insize ) { psize++; q = q.next; if( q == null ) break; } qsize = insize; while( psize > 0 || (qsize > 0 && q != null) ) { if( psize == 0 ) { e = q; q = q.next; qsize--; } else if( qsize == 0 || q == null || cmp(p,q) <= 0 ) { e = p; p = p.next; psize--; } else { e = q; q = q.next; qsize--; } if( tail != null ) tail.next = e; else list = e; tail = e; } p = q; } tail.next = null; if( nmerges <= 1 ) break; insize *= 2; } return list; } }haxe_3.2.1+dfsg.orig/std/haxe/ds/ObjectMap.hx0000664000175000017500000000371712607337712020666 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** ObjectMap allows mapping of object keys to arbitrary values. On static targets, the keys are considered to be strong references. Refer to `haxe.ds.WeakMap` for a weak reference version. See `Map` for documentation details. **/ extern class ObjectMap < K: { }, V > implements haxe.Constraints.IMap { /** Creates a new ObjectMap. **/ public function new():Void; /** See `Map.set` **/ public function set(key:K, value:V):Void; /** See `Map.get` **/ public function get(key:K):Null; /** See `Map.exists` **/ public function exists(key:K):Bool; /** See `Map.remove` **/ public function remove(key:K):Bool; /** See `Map.keys` **/ public function keys():Iterator; /** See `Map.iterator` **/ public function iterator():Iterator; /** See `Map.toString` **/ public function toString():String; }haxe_3.2.1+dfsg.orig/std/haxe/ds/Option.hx0000664000175000017500000000237612607337712020272 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** An Option is a wrapper type which can either have a value (Some) or not a value (None). **/ enum Option { Some(v:T); None; }haxe_3.2.1+dfsg.orig/std/haxe/ds/StringMap.hx0000664000175000017500000000360612607337712020723 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** StringMap allows mapping of String keys to arbitrary values. See `Map` for documentation details. **/ extern class StringMap implements haxe.Constraints.IMap { /** Creates a new StringMap. **/ public function new() : Void; /** See `Map.set` **/ public function set( key : String, value : T ) : Void; /** See `Map.get` **/ public function get( key : String ) : Null; /** See `Map.exists` **/ public function exists( key : String ) : Bool; /** See `Map.remove` **/ public function remove( key : String ) : Bool; /** See `Map.keys` **/ public function keys() : Iterator; /** See `Map.iterator` **/ public function iterator() : Iterator; /** See `Map.toString` **/ public function toString() : String; } haxe_3.2.1+dfsg.orig/std/haxe/ds/Vector.hx0000664000175000017500000001352012607337712020255 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; #if cpp using cpp.NativeArray; #end private typedef VectorData = #if flash10 flash.Vector #elseif neko neko.NativeArray #elseif cs cs.NativeArray #elseif java java.NativeArray #else Array #end /** A Vector is a storage of fixed size. It can be faster than Array on some targets, and is never slower. **/ abstract Vector(VectorData) { /** Creates a new Vector of length `length`. Initially `this` Vector contains `length` neutral elements: - always null on dynamic targets - 0, 0.0 or false for Int, Float and Bool respectively on static targets - null for other types on static targets If `length` is less than or equal to 0, the result is unspecified. **/ public inline function new(length:Int) { #if flash10 this = new flash.Vector(length, true); #elseif neko this = untyped __dollar__amake(length); #elseif js this = untyped __new__(Array, length); #elseif cs this = new cs.NativeArray(length); #elseif java this = new java.NativeArray(length); #elseif cpp this = new Array(); untyped this.__SetSizeExact(length); #elseif python this = python.Syntax.pythonCode("[{0}]*{1}", null, length); #else this = []; untyped this.length = length; #end } /** Returns the value at index `index`. If `index` is negative or exceeds `this.length`, the result is unspecified. **/ @:arrayAccess public inline function get(index:Int):T { #if cpp return this.unsafeGet(index); #elseif python return python.internal.ArrayImpl.unsafeGet(this, index); #else return this[index]; #end } /** Sets the value at index `index` to `val`. If `index` is negative or exceeds `this.length`, the result is unspecified. **/ @:arrayAccess public inline function set(index:Int, val:T):T { #if cpp return this.unsafeSet(index,val); #elseif python return python.internal.ArrayImpl.unsafeSet(this, index, val); #else return this[index] = val; #end } /** Returns the length of `this` Vector. **/ public var length(get, never):Int; inline function get_length():Int { #if neko return untyped __dollar__asize(this); #elseif cs return this.Length; #elseif java return this.length; #elseif python return this.length; #else return untyped this.length; #end } /** Copies `length` of elements from `src` Vector, beginning at `srcPos` to `dest` Vector, beginning at `destPos` The results are unspecified if `length` results in out-of-bounds access, or if `src` or `dest` are null **/ public static #if (cs || java || neko || cpp) inline #end function blit(src:Vector, srcPos:Int, dest:Vector, destPos:Int, len:Int):Void { #if neko untyped __dollar__ablit(dest,destPos,src,srcPos,len); #elseif java java.lang.System.arraycopy(src, srcPos, dest, destPos, len); #elseif cs cs.system.Array.Copy(cast src, srcPos,cast dest, destPos, len); #elseif cpp dest.toData().blit(destPos,src.toData(), srcPos,len); #else for (i in 0...len) { dest[destPos + i] = src[srcPos + i]; } #end } /** Creates a new Array, copy the content from the Vector to it, and returns it. **/ public #if (flash || cpp) inline #end function toArray():Array { #if cpp return this.copy(); #elseif python return this.copy(); #else var a = new Array(); var len = length; #if (neko) // prealloc good size if( len > 0 ) a[len - 1] = get(0); #end for( i in 0...len ) a[i] = get(i); return a; #end } /** Extracts the data of `this` Vector. This returns the internal representation type. **/ public inline function toData():VectorData return cast this; /** Initializes a new Vector from `data`. Since `data` is the internal representation of Vector, this is a no-op. If `data` is null, the corresponding Vector is also `null`. **/ static public inline function fromData(data:VectorData):Vector return cast data; /** Creates a new Vector by copying the elements of `array`. This always creates a copy, even on platforms where the internal representation is Array. The elements are not copied and retain their identity, so `a[i] == Vector.fromArrayCopy(a).get(i)` is true for any valid i. If `array` is null, the result is unspecified. **/ #if as3 @:extern #end static public inline function fromArrayCopy(array:Array):Vector { #if python return cast array.copy(); #elseif flash10 return fromData(flash.Vector.ofArray(array)); #elseif java return fromData(java.Lib.nativeArray(array,false)); #elseif cs return fromData(cs.Lib.nativeArray(array,false)); #else // TODO: Optimize this for flash (and others?) var vec = new Vector(array.length); for (i in 0...array.length) vec.set(i, array[i]); return vec; #end } } haxe_3.2.1+dfsg.orig/std/haxe/ds/WeakMap.hx0000664000175000017500000000405212607337712020340 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; /** WeakMap allows mapping of object keys to arbitrary values. The keys are considered to be weak references on static targets. See `Map` for documentation details. **/ class WeakMap implements haxe.Constraints.IMap { /** Creates a new WeakMap. **/ public function new():Void { throw "Not implemented for this platform"; } /** See `Map.set` **/ public function set(key:K, value:V):Void { } /** See `Map.get` **/ public function get(key:K):Null { return null; } /** See `Map.exists` **/ public function exists(key:K):Bool { return false; } /** See `Map.remove` **/ public function remove(key:K):Bool { return false; } /** See `Map.keys` **/ public function keys():Iterator { return null; } /** See `Map.iterator` **/ public function iterator():Iterator { return null; } /** See `Map.toString` **/ public function toString():String { return null; } }haxe_3.2.1+dfsg.orig/std/haxe/extern/EitherType.hx0000664000175000017500000000273412607337712022001 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.extern; /** An abstract type allowing values to be either of `T1` or `T2` type. Supports implicit casts from/to either types. It is useful for interfacing with external code on dynamic platforms such as JavaScript or Python. Otherwise, use of this type is discouraged. **/ abstract EitherType(Dynamic) from T1 to T1 from T2 to T2 {} haxe_3.2.1+dfsg.orig/std/haxe/extern/Rest.hx0000664000175000017500000000262412607337712020632 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.extern; /** A special abstract type that represents "rest" function argument. Should be used as a type for the last argument of an extern method, representing that arbitrary number of arguments of given type can be passed to that method. **/ abstract Rest(Array) {} haxe_3.2.1+dfsg.orig/std/haxe/format/JsonParser.hx0000664000175000017500000001603512607337712021767 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.format; /** An implementation of JSON parser in Haxe. This class is used by `haxe.Json` when native JSON implementation is not available. **/ class JsonParser { /** Parses given JSON-encoded `str` and returns the resulting object. JSON objects are parsed into anonymous structures and JSON arrays are parsed into Array. If given `str` is not valid JSON, an exception will be thrown. If `str` is null, the result is unspecified. **/ static public inline function parse(str : String) : Dynamic { return new JsonParser(str).parseRec(); } var str : String; var pos : Int; function new( str : String ) { this.str = str; this.pos = 0; } function parseRec() : Dynamic { while( true ) { var c = nextChar(); switch( c ) { case ' '.code, '\r'.code, '\n'.code, '\t'.code: // loop case '{'.code: var obj = {}, field = null, comma : Null = null; while( true ) { var c = nextChar(); switch( c ) { case ' '.code, '\r'.code, '\n'.code, '\t'.code: // loop case '}'.code: if( field != null || comma == false ) invalidChar(); return obj; case ':'.code: if( field == null ) invalidChar(); Reflect.setField(obj,field,parseRec()); field = null; comma = true; case ','.code: if( comma ) comma = false else invalidChar(); case '"'.code: if( comma ) invalidChar(); field = parseString(); default: invalidChar(); } } case '['.code: var arr = [], comma : Null = null; while( true ) { var c = nextChar(); switch( c ) { case ' '.code, '\r'.code, '\n'.code, '\t'.code: // loop case ']'.code: if( comma == false ) invalidChar(); return arr; case ','.code: if( comma ) comma = false else invalidChar(); default: if( comma ) invalidChar(); pos--; arr.push(parseRec()); comma = true; } } case 't'.code: var save = pos; if( nextChar() != 'r'.code || nextChar() != 'u'.code || nextChar() != 'e'.code ) { pos = save; invalidChar(); } return true; case 'f'.code: var save = pos; if( nextChar() != 'a'.code || nextChar() != 'l'.code || nextChar() != 's'.code || nextChar() != 'e'.code ) { pos = save; invalidChar(); } return false; case 'n'.code: var save = pos; if( nextChar() != 'u'.code || nextChar() != 'l'.code || nextChar() != 'l'.code ) { pos = save; invalidChar(); } return null; case '"'.code: return parseString(); case '0'.code, '1'.code,'2'.code,'3'.code,'4'.code,'5'.code,'6'.code,'7'.code,'8'.code,'9'.code,'-'.code: return parseNumber(c); default: invalidChar(); } } } function parseString() { var start = pos; var buf = null; while( true ) { var c = nextChar(); if( c == '"'.code ) break; if( c == '\\'.code ) { if (buf == null) { buf = new StringBuf(); } buf.addSub(str,start, pos - start - 1); c = nextChar(); switch( c ) { case "r".code: buf.addChar("\r".code); case "n".code: buf.addChar("\n".code); case "t".code: buf.addChar("\t".code); case "b".code: buf.addChar(8); case "f".code: buf.addChar(12); case "/".code, '\\'.code, '"'.code: buf.addChar(c); case 'u'.code: var uc = Std.parseInt("0x" + str.substr(pos, 4)); pos += 4; #if (neko || php || cpp) if( uc <= 0x7F ) buf.addChar(uc); else if( uc <= 0x7FF ) { buf.addChar(0xC0 | (uc >> 6)); buf.addChar(0x80 | (uc & 63)); } else if( uc <= 0xFFFF ) { buf.addChar(0xE0 | (uc >> 12)); buf.addChar(0x80 | ((uc >> 6) & 63)); buf.addChar(0x80 | (uc & 63)); } else { buf.addChar(0xF0 | (uc >> 18)); buf.addChar(0x80 | ((uc >> 12) & 63)); buf.addChar(0x80 | ((uc >> 6) & 63)); buf.addChar(0x80 | (uc & 63)); } #else buf.addChar(uc); #end default: throw "Invalid escape sequence \\" + String.fromCharCode(c) + " at position " + (pos - 1); } start = pos; } #if (neko || php || cpp) // ensure utf8 chars are not cut else if( c >= 0x80 ) { pos++; if( c >= 0xFC ) pos += 4; else if( c >= 0xF8 ) pos += 3; else if( c >= 0xF0 ) pos += 2; else if( c >= 0xE0 ) pos++; } #end else if( StringTools.isEof(c) ) throw "Unclosed string"; } if (buf == null) { return str.substr(start, pos - start - 1); } else { buf.addSub(str,start, pos - start - 1); return buf.toString(); } } inline function parseNumber( c : Int ) : Dynamic { var start = pos - 1; var minus = c == '-'.code, digit = !minus, zero = c == '0'.code; var point = false, e = false, pm = false, end = false; while( true ) { c = nextChar(); switch( c ) { case '0'.code : if (zero && !point) invalidNumber(start); if (minus) { minus = false; zero = true; } digit = true; case '1'.code,'2'.code,'3'.code,'4'.code,'5'.code,'6'.code,'7'.code,'8'.code,'9'.code : if (zero && !point) invalidNumber(start); if (minus) minus = false; digit = true; zero = false; case '.'.code : if (minus || point) invalidNumber(start); digit = false; point = true; case 'e'.code, 'E'.code : if (minus || zero || e) invalidNumber(start); digit = false; e = true; case '+'.code, '-'.code : if (!e || pm) invalidNumber(start); digit = false; pm = true; default : if (!digit) invalidNumber(start); pos--; end = true; } if (end) break; } var f = Std.parseFloat(str.substr(start, pos - start)); var i = Std.int(f); return if( i == f ) i else f; } inline function nextChar() { return StringTools.fastCodeAt(str,pos++); } function invalidChar() { pos--; // rewind throw "Invalid char "+StringTools.fastCodeAt(str,pos)+" at position "+pos; } function invalidNumber( start : Int ) { throw "Invalid number at position "+start+": " + str.substr(start, pos - start); } } haxe_3.2.1+dfsg.orig/std/haxe/format/JsonPrinter.hx0000664000175000017500000001376012607337712022160 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.format; /** An implementation of JSON printer in Haxe. This class is used by `haxe.Json` when native JSON implementation is not available. **/ class JsonPrinter { /** Encodes `o` value and returns the resulting JSON string. If `replacer` is given and is not null, it is used to retrieve actual object to be encoded. The `replacer` function two parameters, the key and the value being encoded. Initial key value is an empty string. If `space` is given and is not null, the result will be pretty-printed. Successive levels will be indented by this string. **/ static public function print(o:Dynamic, ?replacer:Dynamic -> Dynamic -> Dynamic, ?space:String) : String { var printer = new JsonPrinter(replacer, space); printer.write("", o); return printer.buf.toString(); } var buf : #if flash flash.utils.ByteArray #else StringBuf #end; var replacer : Dynamic -> Dynamic -> Dynamic; var indent:String; var pretty:Bool; var nind:Int; function new(replacer:Dynamic -> Dynamic -> Dynamic, space:String) { this.replacer = replacer; this.indent = space; this.pretty = space != null; this.nind = 0; #if flash buf = new flash.utils.ByteArray(); buf.endian = flash.utils.Endian.BIG_ENDIAN; buf.position = 0; #else buf = new StringBuf(); #end } inline function ipad ():Void { if (pretty) add(StringTools.lpad('', indent, nind * indent.length)); } inline function newl ():Void { if (pretty) addChar('\n'.code); } function write(k:Dynamic, v:Dynamic) { if (replacer != null) v = replacer(k, v); switch( Type.typeof(v) ) { case TUnknown: add('"???"'); case TObject: objString(v); case TInt: add(v); case TFloat: add(Math.isFinite(v) ? v : 'null'); case TFunction: add('""'); case TClass(c): if( c == String ) quote(v); else if( c == Array ) { var v : Array = v; addChar('['.code); var len = v.length; var last = len - 1; for (i in 0...len) { if (i > 0) addChar(','.code) else nind++; newl(); ipad(); write(i, v[i]); if (i == last) { nind--; newl(); ipad(); } } addChar(']'.code); } else if( c == haxe.ds.StringMap ) { var v : haxe.ds.StringMap = v; var o = {}; for( k in v.keys() ) Reflect.setField(o,k,v.get(k)); objString(o); } else if( c == Date ) { var v : Date = v; quote(v.toString()); } else #if flash classString(v); #else objString(v); #end case TEnum(_): var i : Dynamic = Type.enumIndex(v); add(i); case TBool: add(#if php (v ? 'true' : 'false') #else v #end); case TNull: add('null'); } } @:extern inline function addChar(c:Int) { #if flash buf.writeByte(c); #else buf.addChar(c); #end } @:extern inline function add(v:String) { #if flash // argument is not always a string but will be automatically casted buf.writeUTFBytes(v); #else buf.add(v); #end } #if flash function classString ( v : Dynamic ) { fieldsString(v,Type.getInstanceFields(Type.getClass(v))); } #end inline function objString( v : Dynamic ) { fieldsString(v,Reflect.fields(v)); } function fieldsString( v : Dynamic, fields : Array ) { addChar('{'.code); var len = fields.length; var last = len - 1; var first = true; for( i in 0...len ) { var f = fields[i]; var value = Reflect.field(v,f); if( Reflect.isFunction(value) ) continue; if( first ) { nind++; first = false; } else addChar(','.code); newl(); ipad(); quote(f); addChar(':'.code); if (pretty) addChar(' '.code); write(f, value); if (i == last) { nind--; newl(); ipad(); } } addChar('}'.code); } function quote( s : String ) { #if (neko || php || cpp) if( s.length != haxe.Utf8.length(s) ) { quoteUtf8(s); return; } #end addChar('"'.code); var i = 0; while( true ) { var c = StringTools.fastCodeAt(s, i++); if( StringTools.isEof(c) ) break; switch( c ) { case '"'.code: add('\\"'); case '\\'.code: add('\\\\'); case '\n'.code: add('\\n'); case '\r'.code: add('\\r'); case '\t'.code: add('\\t'); case 8: add('\\b'); case 12: add('\\f'); default: #if flash if( c >= 128 ) add(String.fromCharCode(c)) else addChar(c); #else addChar(c); #end } } addChar('"'.code); } #if (neko || php || cpp) function quoteUtf8( s : String ) { var u = new haxe.Utf8(); haxe.Utf8.iter(s,function(c) { switch( c ) { case '\\'.code, '"'.code: u.addChar('\\'.code); u.addChar(c); case '\n'.code: u.addChar('\\'.code); u.addChar('n'.code); case '\r'.code: u.addChar('\\'.code); u.addChar('r'.code); case '\t'.code: u.addChar('\\'.code); u.addChar('t'.code); case 8: u.addChar('\\'.code); u.addChar('b'.code); case 12: u.addChar('\\'.code); u.addChar('f'.code); default: u.addChar(c); } }); buf.add('"'); buf.add(u.toString()); buf.add('"'); } #end } haxe_3.2.1+dfsg.orig/std/haxe/io/ArrayBufferView.hx0000664000175000017500000000467112607337712022066 0ustar andyandy00000000000000package haxe.io; typedef ArrayBufferViewData = ArrayBufferViewImpl; class ArrayBufferViewImpl { public var bytes : haxe.io.Bytes; public var byteOffset : Int; public var byteLength : Int; public function new(bytes, pos, length) { this.bytes = bytes; this.byteOffset = pos; this.byteLength = length; } public function sub( begin : Int, ?length : Int ) { if( length == null ) length = byteLength - begin; if( begin < 0 || length < 0 || begin + length > byteLength ) throw Error.OutsideBounds; return new ArrayBufferViewImpl(bytes, byteOffset + begin, length); } public function subarray( ?begin : Int, ?end : Int ) { if( begin == null ) begin = 0; if( end == null ) end = byteLength - begin; return sub(begin, end - begin); } } abstract ArrayBufferView(ArrayBufferViewData) { /** On some platforms configurations (for instance JS with no TypedArray support as in IE8-), Haxe will try to emulate the array buffers API. However in that case memory sharing will not be supported : each typed array or will copy its own data set. This flag allows users to detect if we are doing such emulation. At the moment only JavaScript is concerned. **/ public static var EMULATED(get,never) : Bool; static inline function get_EMULATED() : Bool { return false; } public var buffer(get,never) : haxe.io.Bytes; public var byteOffset(get, never) : Int; public var byteLength(get, never) : Int; public inline function new( size : Int ) { this = new ArrayBufferViewData(haxe.io.Bytes.alloc(size), 0, size); } inline function get_byteOffset() : Int return this.byteOffset; inline function get_byteLength() : Int return this.byteLength; inline function get_buffer() : haxe.io.Bytes return this.bytes; public inline function sub( begin : Int, ?length : Int ) : ArrayBufferView { return fromData(this.sub(begin,length)); } public inline function subarray( ?begin : Int, ?end : Int ) : ArrayBufferView { return fromData(this.subarray(begin,end)); } public inline function getData() : ArrayBufferViewData { return this; } public static inline function fromData( a : ArrayBufferViewData ) : ArrayBufferView { return cast a; } public static function fromBytes( bytes : haxe.io.Bytes, pos = 0, ?length : Int ) : ArrayBufferView { if( length == null ) length = bytes.length - pos; if( pos < 0 || length < 0 || pos + length > bytes.length ) throw Error.OutsideBounds; return fromData(new ArrayBufferViewData(bytes, pos, length)); } }haxe_3.2.1+dfsg.orig/std/haxe/io/BufferInput.hx0000664000175000017500000000374012607337712021250 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; class BufferInput extends haxe.io.Input { public var i : haxe.io.Input; public var buf : haxe.io.Bytes; public var available : Int; public var pos : Int; public function new(i, buf, ?pos = 0, ?available = 0) { this.i = i; this.buf = buf; this.pos = pos; this.available = available; } public function refill() { if( pos > 0 ) { buf.blit(0, buf, pos, available); pos = 0; } available += i.readBytes(buf, available, buf.length - available); } override function readByte() { if( available == 0 ) refill(); var c = buf.get(pos); pos++; available--; return c; } override function readBytes( buf : haxe.io.Bytes, pos : Int, len : Int ) { if( available == 0 ) refill(); var size = if( len > available ) available else len; buf.blit(pos, this.buf, this.pos, size); this.pos += size; this.available -= size; return size; } }haxe_3.2.1+dfsg.orig/std/haxe/io/Bytes.hx0000664000175000017500000003715212607337712020111 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; #if cpp using cpp.NativeArray; #end class Bytes { public var length(default,null) : Int; var b : BytesData; function new(length,b) { this.length = length; this.b = b; #if flash b.endian = flash.utils.Endian.LITTLE_ENDIAN; #end } public inline function get( pos : Int ) : Int { #if neko return untyped $sget(b,pos); #elseif flash return b[pos]; #elseif php return untyped __call__("ord", b[pos]); #elseif cpp return untyped b[pos]; #elseif java return untyped b[pos] & 0xFF; #elseif python return python.Syntax.arrayAccess(b, pos); #else return b[pos]; #end } public inline function set( pos : Int, v : Int ) : Void { #if neko untyped $sset(b,pos,v); #elseif flash b[pos] = v; #elseif php b[pos] = untyped __call__("chr", v); #elseif cpp untyped b[pos] = v; #elseif java b[pos] = cast v; #elseif cs b[pos] = cast v; #elseif python python.Syntax.arraySet(b, pos, v & 0xFF); #else b[pos] = v & 0xFF; #end } public function blit( pos : Int, src : Bytes, srcpos : Int, len : Int ) : Void { #if !neko if( pos < 0 || srcpos < 0 || len < 0 || pos + len > length || srcpos + len > src.length ) throw Error.OutsideBounds; #end #if neko try untyped $sblit(b,pos,src.b,srcpos,len) catch( e : Dynamic ) throw Error.OutsideBounds; #elseif php b = untyped __php__("substr($this->b, 0, $pos) . substr($src->b, $srcpos, $len) . substr($this->b, $pos+$len)"); //__call__("substr", b, 0, pos)+__call__("substr", src.b, srcpos, len)+__call__("substr", b, pos+len); #elseif flash b.position = pos; if( len > 0 ) b.writeBytes(src.b,srcpos,len); #elseif java java.lang.System.arraycopy(src.b, srcpos, b, pos, len); #elseif cs cs.system.Array.Copy(src.b, srcpos, b, pos, len); #elseif python python.Syntax.pythonCode("self.b[{0}:{0}+{1}] = src.b[srcpos:srcpos+{1}]", pos, len); #elseif cpp b.blit(pos, src.b, srcpos, len); #else var b1 = b; var b2 = src.b; if( b1 == b2 && pos > srcpos ) { var i = len; while( i > 0 ) { i--; b1[i + pos] = b2[i + srcpos]; } return; } for( i in 0...len ) b1[i+pos] = b2[i+srcpos]; #end } public function fill( pos : Int, len : Int, value : Int ) { #if flash var v4 = value&0xFF; v4 |= v4<<8; v4 |= v4<<16; b.position = pos; for( i in 0...len>>2 ) b.writeUnsignedInt(v4); pos += len&~3; for( i in 0...len&3 ) set(pos++,value); #elseif cpp untyped __global__.__hxcpp_memory_memset(b,pos,len,value); #else for( i in 0...len ) set(pos++, value); #end } public function sub( pos : Int, len : Int ) : Bytes { #if !neko if( pos < 0 || len < 0 || pos + len > length ) throw Error.OutsideBounds; #end #if neko return try new Bytes(len,untyped __dollar__ssub(b,pos,len)) catch( e : Dynamic ) throw Error.OutsideBounds; #elseif flash b.position = pos; var b2 = new flash.utils.ByteArray(); b.readBytes(b2,0,len); return new Bytes(len,b2); #elseif php return new Bytes(len, untyped __call__("substr", b, pos, len)); #elseif java var newarr = new java.NativeArray(len); java.lang.System.arraycopy(b, pos, newarr, 0, len); return new Bytes(len, newarr); #elseif cs var newarr = new cs.NativeArray(len); cs.system.Array.Copy(b, pos, newarr, 0, len); return new Bytes(len, newarr); #elseif python return new Bytes(len, python.Syntax.arrayAccess(b, pos, pos+len) ); #else return new Bytes(len,b.slice(pos,pos+len)); #end } public function compare( other : Bytes ) : Int { #if neko return untyped __dollar__compare(b,other.b); #elseif flash var len = (length < other.length) ? length : other.length; var b1 = b; var b2 = other.b; b1.position = 0; b2.position = 0; b1.endian = flash.utils.Endian.BIG_ENDIAN; b2.endian = flash.utils.Endian.BIG_ENDIAN; for( i in 0...len>>2 ) if( b1.readUnsignedInt() != b2.readUnsignedInt() ) { b1.position -= 4; b2.position -= 4; var d = b1.readUnsignedInt() - b2.readUnsignedInt(); b1.endian = flash.utils.Endian.LITTLE_ENDIAN; b2.endian = flash.utils.Endian.LITTLE_ENDIAN; return d; } for( i in 0...len & 3 ) if( b1.readUnsignedByte() != b2.readUnsignedByte() ) { b1.endian = flash.utils.Endian.LITTLE_ENDIAN; b2.endian = flash.utils.Endian.LITTLE_ENDIAN; return b1[b1.position-1] - b2[b2.position-1]; } b1.endian = flash.utils.Endian.LITTLE_ENDIAN; b2.endian = flash.utils.Endian.LITTLE_ENDIAN; return length - other.length; #elseif php return untyped __php__("$this->b < $other->b ? -1 : ($this->b == $other->b ? 0 : 1)"); //#elseif cs //TODO: memcmp if unsafe flag is on #elseif cpp return b.memcmp(other.b); #else var b1 = b; var b2 = other.b; var len = (length < other.length) ? length : other.length; for( i in 0...len ) if( b1[i] != b2[i] ) return untyped b1[i] - untyped b2[i]; return length - other.length; #end } /** Returns the IEEE double precision value at given position (in low endian encoding). Result is unspecified if reading outside of the bounds **/ #if (neko_v21 || (cpp && !cppia)) inline #end public function getDouble( pos : Int ) : Float { #if neko_v21 return untyped $sgetd(b, pos, false); #elseif flash b.position = pos; return b.readDouble(); #elseif cpp if( pos < 0 || pos + 8 > length ) throw Error.OutsideBounds; return untyped __global__.__hxcpp_memory_get_double(b,pos); #else return FPHelper.i64ToDouble(getInt32(pos),getInt32(pos+4)); #end } /** Returns the IEEE single precision value at given position (in low endian encoding). Result is unspecified if reading outside of the bounds **/ #if (neko_v21 || (cpp && !cppia)) inline #end public function getFloat( pos : Int ) : Float { #if neko_v21 return untyped $sgetf(b, pos, false); #elseif flash b.position = pos; return b.readFloat(); #elseif cpp if( pos < 0 || pos + 4 > length ) throw Error.OutsideBounds; return untyped __global__.__hxcpp_memory_get_float(b,pos); #else var b = new haxe.io.BytesInput(this,pos,4); return b.readFloat(); #end } /** Store the IEEE double precision value at given position in low endian encoding. Result is unspecified if writing outside of the bounds. **/ #if neko_v21 inline #end public function setDouble( pos : Int, v : Float ) : Void { #if neko_v21 untyped $ssetd(b, pos, v, false); #elseif neko untyped $sblit(b, pos, FPHelper._double_bytes(v,false), 0, 8); #elseif flash b.position = pos; b.writeDouble(v); #elseif cpp if( pos < 0 || pos + 8 > length ) throw Error.OutsideBounds; untyped __global__.__hxcpp_memory_set_double(b,pos,v); #else var i = FPHelper.doubleToI64(v); setInt32(pos, i.low); setInt32(pos + 4, i.high); #end } /** Store the IEEE single precision value at given position in low endian encoding. Result is unspecified if writing outside of the bounds. **/ #if neko_v21 inline #end public function setFloat( pos : Int, v : Float ) : Void { #if neko_v21 untyped $ssetf(b, pos, v, false); #elseif neko untyped $sblit(b, pos, FPHelper._float_bytes(v,false), 0, 4); #elseif flash b.position = pos; b.writeFloat(v); #elseif cpp if( pos < 0 || pos + 4 > length ) throw Error.OutsideBounds; untyped __global__.__hxcpp_memory_set_float(b,pos,v); #else setInt32(pos, FPHelper.floatToI32(v)); #end } /** Returns the 16 bit unsignged integer at given position (in low endian encoding). **/ public inline function getUInt16( pos : Int ) : Int { #if neko_v21 return untyped $sget16(b, pos, false); #else return get(pos) | (get(pos + 1) << 8); #end } /** Returns the 16 bit unsignged integer at given position (in low endian encoding). **/ public inline function setUInt16( pos : Int, v : Int ) : Void { #if neko_v21 untyped $sset16(b, pos, v, false); #else set(pos, v); set(pos + 1, v >> 8); #end } /** Returns the 32 bit integer at given position (in low endian encoding). **/ public inline function getInt32( pos : Int ) : Int { #if neko_v21 return untyped $sget32(b, pos, false); #elseif (php || python) var v = get(pos) | (get(pos + 1) << 8) | (get(pos + 2) << 16) | (get(pos+3) << 24); return if( v & 0x80000000 != 0 ) v | 0x80000000 else v; #else return get(pos) | (get(pos + 1) << 8) | (get(pos + 2) << 16) | (get(pos+3) << 24); #end } /** Returns the 64 bit integer at given position (in low endian encoding). **/ public inline function getInt64( pos : Int ) : haxe.Int64 { return haxe.Int64.make(getInt32(pos+4),getInt32(pos)); } /** Store the 32 bit integer at given position (in low endian encoding). **/ public inline function setInt32( pos : Int, v : Int ) : Void { #if neko_v21 untyped $sset32(b, pos, v, false); #else set(pos, v); set(pos + 1, v >> 8); set(pos + 2, v >> 16); set(pos + 3, v >>> 24); #end } /** Store the 64 bit integer at given position (in low endian encoding). **/ public inline function setInt64( pos : Int, v : haxe.Int64 ) : Void { setInt32(pos, v.low); setInt32(pos + 4, v.high); } public function getString( pos : Int, len : Int ) : String { #if !neko if( pos < 0 || len < 0 || pos + len > length ) throw Error.OutsideBounds; #end #if neko return try new String(untyped __dollar__ssub(b,pos,len)) catch( e : Dynamic ) throw Error.OutsideBounds; #elseif flash b.position = pos; return b.readUTFBytes(len); #elseif php return untyped __call__("substr", b, pos, len); #elseif cpp var result:String=""; untyped __global__.__hxcpp_string_of_bytes(b,result,pos,len); return result; #elseif cs return cs.system.text.Encoding.UTF8.GetString(b, pos, len); #elseif java try return new String(b, pos, len, "UTF-8") catch (e:Dynamic) throw e; #elseif python return python.Syntax.pythonCode("self.b[{0}:{0}+{1}].decode('UTF-8','replace')", pos, len); #else var s = ""; var b = b; var fcc = String.fromCharCode; var i = pos; var max = pos+len; // utf8-decode and utf16-encode while( i < max ) { var c = b[i++]; if( c < 0x80 ) { if( c == 0 ) break; s += fcc(c); } else if( c < 0xE0 ) s += fcc( ((c & 0x3F) << 6) | (b[i++] & 0x7F) ); else if( c < 0xF0 ) { var c2 = b[i++]; s += fcc( ((c & 0x1F) << 12) | ((c2 & 0x7F) << 6) | (b[i++] & 0x7F) ); } else { var c2 = b[i++]; var c3 = b[i++]; var u = ((c & 0x0F) << 18) | ((c2 & 0x7F) << 12) | ((c3 & 0x7F) << 6) | (b[i++] & 0x7F); // surrogate pair s += fcc( (u >> 10) + 0xD7C0 ); s += fcc( (u & 0x3FF) | 0xDC00 ); } } return s; #end } @:deprecated("readString is deprecated, use getString instead") @:noCompletion public inline function readString(pos:Int, len:Int):String { return getString(pos, len); } public function toString() : String { #if neko return new String(untyped __dollar__ssub(b,0,length)); #elseif flash b.position = 0; return b.readUTFBytes(length); #elseif php return cast b; #elseif cs return cs.system.text.Encoding.UTF8.GetString(b, 0, length); #elseif java try { return new String(b, 0, length, "UTF-8"); } catch (e:Dynamic) throw e; #else return getString(0,length); #end } public function toHex() : String { var s = new StringBuf(); var chars = []; var str = "0123456789abcdef"; for( i in 0...str.length ) chars.push(str.charCodeAt(i)); for( i in 0...length ) { var c = get(i); s.addChar(chars[c >> 4]); s.addChar(chars[c & 15]); } return s.toString(); } public inline function getData() : BytesData { return b; } public static function alloc( length : Int ) : Bytes { #if neko return new Bytes(length,untyped __dollar__smake(length)); #elseif flash var b = new flash.utils.ByteArray(); b.length = length; return new Bytes(length,b); #elseif php return new Bytes(length, untyped __call__("str_repeat", __call__("chr", 0), length)); #elseif cpp var a = new BytesData(); if (length>0) a[length-1] = untyped 0; return new Bytes(length, a); #elseif cs return new Bytes(length, new cs.NativeArray(length)); #elseif java return new Bytes(length, new java.NativeArray(length)); #elseif python return new Bytes(length, new python.Bytearray(length)); #else var a = new Array(); for( i in 0...length ) a.push(0); return new Bytes(length,a); #end } public static function ofString( s : String ) : Bytes { #if neko return new Bytes(s.length,untyped __dollar__ssub(s.__s,0,s.length)); #elseif flash var b = new flash.utils.ByteArray(); b.writeUTFBytes(s); return new Bytes(b.length,b); #elseif php return new Bytes(untyped __call__("strlen", s), cast s); // return ofData(untyped __call__("new _hx_array", __call__("array_values", __call__("unpack", "C*", s)))); #elseif cpp var a = new BytesData(); untyped __global__.__hxcpp_bytes_of_string(a,s); return new Bytes(a.length, a); #elseif cs var b = cs.system.text.Encoding.UTF8.GetBytes(s); return new Bytes(b.Length, b); #elseif java try { var b:BytesData = untyped s.getBytes("UTF-8"); return new Bytes(b.length, b); } catch (e:Dynamic) throw e; #elseif python var b:BytesData = new python.Bytearray(s, "UTF-8"); return new Bytes(b.length, b); #else var a = new Array(); // utf16-decode and utf8-encode var i = 0; while( i < s.length ) { var c : Int = StringTools.fastCodeAt(s,i++); // surrogate pair if( 0xD800 <= c && c <= 0xDBFF ) c = (c - 0xD7C0 << 10) | (StringTools.fastCodeAt(s,i++) & 0x3FF); if( c <= 0x7F ) a.push(c); else if( c <= 0x7FF ) { a.push( 0xC0 | (c >> 6) ); a.push( 0x80 | (c & 63) ); } else if( c <= 0xFFFF ) { a.push( 0xE0 | (c >> 12) ); a.push( 0x80 | ((c >> 6) & 63) ); a.push( 0x80 | (c & 63) ); } else { a.push( 0xF0 | (c >> 18) ); a.push( 0x80 | ((c >> 12) & 63) ); a.push( 0x80 | ((c >> 6) & 63) ); a.push( 0x80 | (c & 63) ); } } return new Bytes(a.length,a); #end } public static function ofData( b : BytesData ) { #if flash return new Bytes(b.length,b); #elseif neko return new Bytes(untyped __dollar__ssize(b),b); #elseif php return new Bytes(untyped __call__("strlen", b), b); #elseif cs return new Bytes(b.Length,b); #else return new Bytes(b.length,b); #end } /** Read the most efficiently possible the n-th byte of the data. Behavior when reading outside of the available data is unspecified. **/ public inline static function fastGet( b : BytesData, pos : Int ) : Int { #if neko return untyped __dollar__sget(b,pos); #elseif flash return b[pos]; #elseif php return untyped __call__("ord", b[pos]); #elseif cpp return untyped b.unsafeGet(pos); #elseif java return untyped b[pos] & 0xFF; #else return b[pos]; #end } } haxe_3.2.1+dfsg.orig/std/haxe/io/BytesBuffer.hx0000664000175000017500000001231012607337712021230 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; class BytesBuffer { #if neko var b : Dynamic; // neko string buffer #elseif flash var b : flash.utils.ByteArray; #elseif php var b : String; #elseif cpp var b : BytesData; #elseif cs var b : cs.system.io.MemoryStream; #elseif java var b : java.io.ByteArrayOutputStream; #else var b : Array; #end /** The length of the buffer in bytes. **/ public var length(get,never) : Int; public function new() { #if neko b = untyped StringBuf.__make(); #elseif flash b = new flash.utils.ByteArray(); b.endian = flash.utils.Endian.LITTLE_ENDIAN; #elseif php b = ""; #elseif cpp b = new BytesData(); #elseif cs b = new cs.system.io.MemoryStream(); #elseif java b = new java.io.ByteArrayOutputStream(); #else b = new Array(); #end } inline function get_length() : Int { #if neko return untyped __dollar__ssize( StringBuf.__to_string(b) ); #elseif cs return haxe.Int64.toInt( b.Length ); #elseif java return b.size(); #else return b.length; #end } public inline function addByte( byte : Int ) { #if neko untyped StringBuf.__add_char(b,byte); #elseif flash b.writeByte(byte); #elseif php b += untyped __call__("chr", byte); #elseif cpp b.push(untyped byte); #elseif cs b.WriteByte(cast byte); #elseif java b.write(byte); #else b.push(byte); #end } public inline function add( src : Bytes ) { #if neko untyped StringBuf.__add(b,src.getData()); #elseif flash b.writeBytes(src.getData()); #elseif php b += cast src.getData(); #elseif cs b.Write(src.getData(), 0, src.length); #elseif java b.write(src.getData(), 0, src.length); #elseif js var b1 = b; var b2 = @:privateAccess src.b; for( i in 0...src.length ) b.push(b2[i]); #else var b1 = b; var b2 = src.getData(); for( i in 0...src.length ) b.push(b2[i]); #end } public inline function addString( v : String ) { #if neko untyped StringBuf.__add(b, v.__s); #elseif flash b.writeUTFBytes(v); #else add(Bytes.ofString(v)); #end } public #if flash inline #end function addInt32( v : Int ) { #if flash b.writeUnsignedInt(v); #else addByte(v&0xFF); addByte((v>>8)&0xFF); addByte((v>>16)&0xFF); addByte(v>>>24); #end } public #if flash inline #end function addInt64( v : haxe.Int64 ) { addInt32(v.low); addInt32(v.high); } public inline function addFloat( v : Float ) { #if flash b.writeFloat(v); #else addInt32(FPHelper.floatToI32(v)); #end } public inline function addDouble( v : Float ) { #if flash b.writeDouble(v); #else addInt64(FPHelper.doubleToI64(v)); #end } public inline function addBytes( src : Bytes, pos : Int, len : Int ) { #if !neko if( pos < 0 || len < 0 || pos + len > src.length ) throw Error.OutsideBounds; #end #if neko try untyped StringBuf.__add_sub(b,src.getData(),pos,len) catch( e : Dynamic ) throw Error.OutsideBounds; #elseif flash if( len > 0 ) b.writeBytes(src.getData(),pos,len); #elseif php b += untyped __call__("substr", src.b, pos, len); #elseif cs b.Write(src.getData(), pos, len); #elseif java b.write(src.getData(), pos, len); #elseif js var b1 = b; var b2 = @:privateAccess src.b; for( i in pos...pos+len ) b.push(b2[i]); #else var b1 = b; var b2 = src.getData(); for( i in pos...pos+len ) b.push(b2[i]); #end } /** Returns either a copy or a reference of the current bytes. Once called, the buffer can no longer be used. **/ public function getBytes() : Bytes untyped { #if neko var str = StringBuf.__to_string(b); var bytes = new Bytes(__dollar__ssize(str),str); #elseif flash var bytes = new Bytes(b.length,b); b.position = 0; #elseif php var bytes = new Bytes(b.length, cast b); #elseif cs var buf = b.GetBuffer(); var bytes = new Bytes(cast b.Length, buf); #elseif java var buf = b.toByteArray(); var bytes = new Bytes(buf.length, buf); #elseif python var buf = new python.Bytearray(b); var bytes = new Bytes(buf.length, buf); #elseif js var bytes = new Bytes(new js.html.Uint8Array(b).buffer); #else var bytes = new Bytes(b.length,b); #end b = null; return bytes; } } haxe_3.2.1+dfsg.orig/std/haxe/io/BytesData.hx0000664000175000017500000000322112607337712020671 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; #if neko typedef BytesData = neko.NativeString; #elseif flash typedef BytesData = flash.utils.ByteArray; #elseif php typedef BytesData = php.NativeString; #elseif cpp extern class Unsigned_char__ { } typedef BytesData = Array; #elseif java typedef BytesData = java.NativeArray; #elseif cs typedef BytesData = cs.NativeArray; #elseif python typedef BytesData = python.Bytearray; #elseif js typedef BytesData = js.html.ArrayBuffer; #else typedef BytesData = Array; #end haxe_3.2.1+dfsg.orig/std/haxe/io/BytesInput.hx0000664000175000017500000001242612607337712021126 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; class BytesInput extends Input { var b : #if js js.html.Uint8Array #else BytesData #end; #if !flash var pos : Int; var len : Int; var totlen : Int; #end /** The current position in the stream in bytes. */ public var position(get,set) : Int; /** The length of the stream in bytes. */ public var length(get,never) : Int; public function new( b : Bytes, ?pos : Int, ?len : Int ) { if( pos == null ) pos = 0; if( len == null ) len = b.length - pos; if( pos < 0 || len < 0 || pos + len > b.length ) throw Error.OutsideBounds; #if flash var ba = b.getData(); ba.position = pos; if( len != ba.bytesAvailable ) { // truncate this.b = new flash.utils.ByteArray(); ba.readBytes(this.b,0,len); } else this.b = ba; this.b.endian = flash.utils.Endian.LITTLE_ENDIAN; #else this.b = #if js @:privateAccess b.b #else b.getData() #end; this.pos = pos; this.len = len; this.totlen = len; #end #if python bigEndian = false; #end } inline function get_position() : Int { #if flash return b.position; #else return pos; #end } inline function get_length() : Int { #if flash return b.length; #else return totlen; #end } function set_position( p : Int ) : Int { if( p < 0 ) p = 0; else if( p > length ) p = length; #if flash return b.position = p; #else len = totlen - p; return pos = p; #end } public override function readByte() : Int { #if flash return try b.readUnsignedByte() catch( e : Dynamic ) throw new Eof(); #else if( this.len == 0 ) throw new Eof(); len--; #if neko return untyped __dollar__sget(b,pos++); #elseif php return untyped __call__("ord", b[pos++]); #elseif cpp return untyped b[pos++]; #elseif java return untyped b[pos++] & 0xFF; #else return b[pos++]; #end #end } public override function readBytes( buf : Bytes, pos, len ) : Int { #if !neko if( pos < 0 || len < 0 || pos + len > buf.length ) throw Error.OutsideBounds; #end #if flash var avail : Int = b.bytesAvailable; if( len > avail && avail > 0 ) len = avail; try b.readBytes(buf.getData(),pos,len) catch( e : Dynamic ) throw new Eof(); #elseif java var avail : Int = this.len; if ( len > avail ) len = avail; if (len == 0) throw new Eof(); java.lang.System.arraycopy(this.b, this.pos, buf.getData(), pos, len); this.pos += len; this.len -= len; #elseif cs var avail : Int = this.len; if ( len > avail ) len = avail; if (len == 0) throw new Eof(); cs.system.Array.Copy(this.b,this.pos, buf.getData(), pos, len); this.pos += len; this.len -= len; #else if( this.len == 0 && len > 0 ) throw new Eof(); if( this.len < len ) len = this.len; #if neko try untyped __dollar__sblit(buf.getData(),pos,b,this.pos,len) catch( e : Dynamic ) throw Error.OutsideBounds; #elseif php untyped __php__("$buf->b = substr($buf->b, 0, $pos) . substr($this->b, $this->pos, $len) . substr($buf->b, $pos+$len)"); #else var b1 = b; var b2 = #if js @:privateAccess buf.b #else buf.getData() #end; for( i in 0...len ) b2[pos+i] = b1[this.pos+i]; #end this.pos += len; this.len -= len; #end return len; } #if flash @:dox(hide) override function set_bigEndian(e) { bigEndian = e; b.endian = e ? flash.utils.Endian.BIG_ENDIAN : flash.utils.Endian.LITTLE_ENDIAN; return e; } @:dox(hide) override function readFloat() { return try b.readFloat() catch( e : Dynamic ) throw new Eof(); } @:dox(hide) override function readDouble() { return try b.readDouble() catch( e : Dynamic ) throw new Eof(); } @:dox(hide) override function readInt8() { return try b.readByte() catch( e : Dynamic ) throw new Eof(); } @:dox(hide) override function readInt16() { return try b.readShort() catch( e : Dynamic ) throw new Eof(); } @:dox(hide) override function readUInt16() : Int { return try b.readUnsignedShort() catch( e : Dynamic ) throw new Eof(); } @:dox(hide) override function readInt32() : Int { return try b.readInt() catch( e : Dynamic ) throw new Eof(); } @:dox(hide) override function readString( len : Int ) { return try b.readUTFBytes(len) catch( e : Dynamic ) throw new Eof(); } #end } haxe_3.2.1+dfsg.orig/std/haxe/io/BytesOutput.hx0000664000175000017500000000613712607337712021331 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; class BytesOutput extends Output { #if flash var b : flash.utils.ByteArray; #else var b : BytesBuffer; #end /** The length of the stream in bytes. **/ public var length(get,never) : Int; public function new() { #if flash b = new flash.utils.ByteArray(); b.endian = flash.utils.Endian.LITTLE_ENDIAN; #else b = new BytesBuffer(); #end #if python bigEndian = false; #end } inline function get_length() : Int { return b.length; } override function writeByte(c) { #if flash b.writeByte(c); #else b.addByte(c); #end } override function writeBytes( buf : Bytes, pos, len ) : Int { #if flash if( pos < 0 || len < 0 || pos + len > buf.length ) throw Error.OutsideBounds; b.writeBytes(buf.getData(),pos,len); #else b.addBytes(buf,pos,len); #end return len; } #if flash // optimized operations @:dox(hide) override function set_bigEndian(e) { bigEndian = e; b.endian = e ? flash.utils.Endian.BIG_ENDIAN : flash.utils.Endian.LITTLE_ENDIAN; return e; } @:dox(hide) override function writeFloat( f : Float ) { b.writeFloat(f); } @:dox(hide) override function writeDouble( f : Float ) { b.writeDouble(f); } @:dox(hide) override function writeInt8( x : Int ) { if( x < -0x80 || x >= 0x80 ) throw Error.Overflow; b.writeByte(x); } @:dox(hide) override function writeInt16( x : Int ) { if( x < -0x8000 || x >= 0x8000 ) throw Error.Overflow; b.writeShort(x); } @:dox(hide) override function writeUInt16( x : Int ) { if( x < 0 || x >= 0x10000 ) throw Error.Overflow; b.writeShort(x); } @:dox(hide) override function writeInt32( x : Int ) { b.writeInt(x); } @:dox(hide) override function prepare( size : Int ) { if( size > 0 ) b[size-1] = b[size-1]; } @:dox(hide) override function writeString( s : String ) { b.writeUTFBytes(s); } #end public function getBytes() : Bytes { #if flash var bytes = b; b = null; return untyped new Bytes(bytes.length,bytes); #else return b.getBytes(); #end } } haxe_3.2.1+dfsg.orig/std/haxe/io/Eof.hx0000664000175000017500000000246212607337712017530 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; /** This exception is raised when reading while data is no longer available in the [Input]. **/ class Eof { public function new() { } @:keep function toString() { return "Eof"; } } haxe_3.2.1+dfsg.orig/std/haxe/io/Error.hx0000664000175000017500000000272012607337712020105 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; /** The possible IO errors that can occur **/ enum Error { /** The IO is set into nonblocking mode and some data cannot be read or written **/ Blocked; /** An integer value is outside its allowed range **/ Overflow; /** An operation on Bytes is outside of its valid range **/ OutsideBounds; /** Other errors **/ Custom( e : Dynamic ); } haxe_3.2.1+dfsg.orig/std/haxe/io/FPHelper.hx0000664000175000017500000002456312607337712020472 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; /** Helper that converts between floating point and binary representation. Always works in low-endian encoding. **/ class FPHelper { #if neko_v21 // stored in helper #elseif neko static var i64tmp = new neko.vm.Tls(); #elseif !(java || cs) static var i64tmp = Int64.ofInt(0); #end #if neko #if neko_v21 static var helpers = new neko.vm.Tls>(); #else static var helperf = new neko.vm.Tls(); static var helperd = new neko.vm.Tls(); static var _float_of_bytes = neko.Lib.load("std","float_of_bytes",2); static var _double_of_bytes = neko.Lib.load("std","double_of_bytes",2); static var _float_bytes = neko.Lib.load("std","float_bytes",2); static var _double_bytes = neko.Lib.load("std","double_bytes",2); #end #elseif flash static var helper = { var b = new flash.utils.ByteArray(); b.endian = flash.utils.Endian.LITTLE_ENDIAN; b; } #elseif php static var isLittleEndian : Bool = untyped __call__('unpack','S','\x01\x00')[1] == 1; #else static inline var LN2 = 0.6931471805599453; // Math.log(2) #end #if neko_v21 inline #end public static function i32ToFloat( i : Int ) : Float { #if neko #if neko_v21 return untyped $itof(i,false); #else var helper = helperf.value; if( helper == null ) helperf.value = helper = neko.NativeString.alloc(4); untyped $sset(helper,0,i&0xFF); untyped $sset(helper,1,(i>>8)&0xFF); untyped $sset(helper,2,(i>>16)&0xFF); untyped $sset(helper,3,i>>>24); return _float_of_bytes(helper,false); #end #elseif cpp return untyped __global__.__hxcpp_reinterpret_le_int32_as_float32(i); #elseif cs var helper = new SingleHelper(0); if( cs.system.BitConverter.IsLittleEndian ) { helper.i = i; } else { helper.i = ((i >>> 24) & 0xFF) | (((i >> 16) & 0xFF) << 8) | (((i >> 8) & 0xFF) << 16) | ((i & 0xFF) << 24); } return helper.f; #elseif java return java.lang.Float.FloatClass.intBitsToFloat(i); #elseif php return untyped __call__('unpack', 'f', __call__('pack', 'l', i))[1]; #elseif flash var helper = helper; helper.position = 0; helper.writeUnsignedInt(i); helper.position = 0; return helper.readFloat(); #else var sign = 1 - ((i >>> 31) << 1); var exp = (i >>> 23) & 0xFF; var sig = i & 0x7FFFFF; if( sig == 0 && exp == 0 ) return 0.0; return sign*(1 + Math.pow(2, -23)*sig) * Math.pow(2, exp-127); #end } #if neko_v21 inline #end public static function floatToI32( f : Float ) : Int { #if neko #if neko_v21 return untyped $ftoi(f,false); #else var r = _float_bytes(f,false); return untyped $sget(r,0) | ($sget(r,1)<<8) | ($sget(r,2)<<16) | ($sget(r,3)<<24); #end #elseif cpp return untyped __global__.__hxcpp_reinterpret_float32_as_le_int32(f); #elseif cs var helper = new SingleHelper(f); if( cs.system.BitConverter.IsLittleEndian ) { return helper.i; } else { var i = helper.i; return ((i >>> 24) & 0xFF) | (((i >> 16) & 0xFF) << 8) | (((i >> 8) & 0xFF) << 16) | ((i & 0xFF) << 24); } #elseif java return java.lang.Float.FloatClass.floatToRawIntBits(f); #elseif flash var helper = helper; helper.position = 0; helper.writeFloat(f); helper.position = 0; return helper.readUnsignedInt(); #elseif php return untyped __call__('unpack','l',__call__('pack', 'f', f))[1]; #else if( f == 0 ) return 0; var af = f < 0 ? -f : f; var exp = Math.floor(Math.log(af) / LN2); if( exp < -127 ) exp = -127 else if( exp > 128 ) exp = 128; var sig = Math.round((af / Math.pow(2, exp) - 1) * 0x800000) & 0x7FFFFF; return (f < 0 ? 0x80000000 : 0) | ((exp + 127) << 23) | sig; #end } #if neko_v21 inline #end public static function i64ToDouble( low : Int, high : Int ) : Float { #if neko #if neko_v21 return untyped $itod(low,high,false); #else var helper = helperd.value; if( helper == null ) helperd.value = helper = neko.NativeString.alloc(8); untyped $sset(helper,0,low&0xFF); untyped $sset(helper,1,(low>>8)&0xFF); untyped $sset(helper,2,(low>>16)&0xFF); untyped $sset(helper,3,low>>>24); untyped $sset(helper,4,high&0xFF); untyped $sset(helper,5,(high>>8)&0xFF); untyped $sset(helper,6,(high>>16)&0xFF); untyped $sset(helper,7,high>>>24); return _double_of_bytes(helper,false); #end #elseif cpp return untyped __global__.__hxcpp_reinterpret_le_int32s_as_float64(low,high); #elseif cs var helper = new FloatHelper(0); if( cs.system.BitConverter.IsLittleEndian ) { helper.i = haxe.Int64.make(high,low); } else { var i1 = high, i2 = low; var j2 = ((i1 >>> 24) & 0xFF) | (((i1 >> 16) & 0xFF) << 8) | (((i1 >> 8) & 0xFF) << 16) | ((i1 & 0xFF) << 24); var j1 = ((i2 >>> 24) & 0xFF) | (((i2 >> 16) & 0xFF) << 8) | (((i2 >> 8) & 0xFF) << 16) | ((i2 & 0xFF) << 24); helper.i = haxe.Int64.make(j1,j2); } return helper.f; #elseif java return java.lang.Double.DoubleClass.longBitsToDouble( Int64.make(high,low) ); #elseif flash var helper = helper; helper.position = 0; helper.writeUnsignedInt(low); helper.writeUnsignedInt(high); helper.position = 0; return helper.readDouble(); #elseif php return untyped __call__('unpack', 'd', __call__('pack', 'ii', isLittleEndian ? low : high, isLittleEndian ? high : low))[1]; #else var sign = 1 - ((high >>> 31) << 1); var exp = ((high >> 20) & 0x7FF) - 1023; var sig = (high&0xFFFFF) * 4294967296. + (low>>>31) * 2147483648. + (low&0x7FFFFFFF); if( sig == 0 && exp == -1023 ) return 0.0; return sign*(1.0 + Math.pow(2, -52)*sig) * Math.pow(2, exp); #end } /** Returns an Int64 representing the bytes representation of the double precision IEEE float value. WARNING : for performance reason, the same Int64 value might be reused every time. Copy its low/high values before calling again. We still ensure that this is safe to use in a multithread environment **/ public static function doubleToI64( v : Float ) : Int64 { #if neko #if neko_v21 var helper = helpers.value; if( helper == null ) { helpers.value = helper = neko.NativeArray.alloc(2); helper[0] = neko.NativeArray.alloc(2); helper[1] = haxe.Int64.ofInt(0); } var i64 : haxe.Int64 = helper[1], int2 = helper[0]; untyped $dtoi(v,int2,false); @:privateAccess { i64.set_low(int2[0]); i64.set_high(int2[1]); } return i64; #else var r = _double_bytes(v,false), i64 = i64tmp.value; if( i64 == null ) i64 = i64tmp.value = haxe.Int64.ofInt(0); @:privateAccess { i64.set_low(untyped $sget(r,0) | ($sget(r,1)<<8) | ($sget(r,2)<<16) | ($sget(r,3)<<24)); i64.set_high(untyped $sget(r,4) | ($sget(r,5)<<8) | ($sget(r,6)<<16) | ($sget(r,7)<<24)); } return i64; #end #elseif cpp return Int64.make(untyped __global__.__hxcpp_reinterpret_float64_as_le_int32_high(v), untyped __global__.__hxcpp_reinterpret_float64_as_le_int32_low(v) ); #elseif java return java.lang.Double.DoubleClass.doubleToRawLongBits(v); #elseif cs var helper = new FloatHelper(v); if( cs.system.BitConverter.IsLittleEndian ) { return helper.i; } else { var i = helper.i; var i1 = haxe.Int64.getHigh(i), i2 = haxe.Int64.getLow(i); var j2 = ((i1 >>> 24) & 0xFF) | (((i1 >> 16) & 0xFF) << 8) | (((i1 >> 8) & 0xFF) << 16) | ((i1 & 0xFF) << 24); var j1 = ((i2 >>> 24) & 0xFF) | (((i2 >> 16) & 0xFF) << 8) | (((i2 >> 8) & 0xFF) << 16) | ((i2 & 0xFF) << 24); return haxe.Int64.make(j1,j2); } #elseif flash var helper = helper; helper.position = 0; helper.writeDouble(v); helper.position = 0; var i64 = i64tmp; @:privateAccess { i64.set_low(cast helper.readUnsignedInt()); i64.set_high(cast helper.readUnsignedInt()); } return i64; #elseif php var a = untyped __call__('unpack',isLittleEndian ? 'V2' : 'N2',__call__('pack', 'd', v)); var i64 = i64tmp; @:privateAccess { i64.set_low(a[isLittleEndian ? 1 : 2]); i64.set_high(a[isLittleEndian ? 2 : 1]); } return i64; #else var i64 = i64tmp; if( v == 0 ) { @:privateAccess { i64.set_low(0); i64.set_high(0); } } else { var av = v < 0 ? -v : v; var exp = Math.floor(Math.log(av) / LN2); var sig = Math.fround(((av / Math.pow(2, exp)) - 1) * 4503599627370496.); // 2^52 var sig_l = Std.int(sig); var sig_h = Std.int(sig / 4294967296.0); @:privateAccess { i64.set_low(sig_l); i64.set_high((v < 0 ? 0x80000000 : 0) | ((exp + 1023) << 20) | sig_h); } } return i64; #end } } #if cs @:meta(System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)) @:nativeGen @:struct private class SingleHelper { @:meta(System.Runtime.InteropServices.FieldOffset(0)) public var i:Int; @:meta(System.Runtime.InteropServices.FieldOffset(0)) public var f:Single; public function new(f:Single) { this.i = 0; this.f = f; } } @:meta(System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)) @:nativeGen @:struct private class FloatHelper { @:meta(System.Runtime.InteropServices.FieldOffset(0)) public var i:haxe.Int64; @:meta(System.Runtime.InteropServices.FieldOffset(0)) public var f:Float; public function new(f:Float) { this.i = haxe.Int64.ofInt(0); this.f = f; } } #end haxe_3.2.1+dfsg.orig/std/haxe/io/Float32Array.hx0000664000175000017500000000601312607337712021224 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef Float32ArrayData = ArrayBufferView.ArrayBufferViewData; abstract Float32Array(Float32ArrayData) { public static inline var BYTES_PER_ELEMENT = 4; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new ArrayBufferView(elements * BYTES_PER_ELEMENT).getData(); } inline function get_length() { return this.byteLength >> 2; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Float { return this.bytes.getFloat((index<<2) + this.byteOffset); } @:arrayAccess public inline function set( index : Int, value : Float ) : Float { if( index >= 0 && index < length ) { this.bytes.setFloat((index<<2) + this.byteOffset, value); return value; } return 0; } public inline function sub( begin : Int, ?length : Int ) : Float32Array { return fromData(this.sub(begin<<2,length == null ? null : length<<2)); } public inline function subarray( ?begin : Int, ?end : Int ) : Float32Array { return fromData(this.subarray(begin==null?null:begin<<2,end==null?null:end<<2)); } public inline function getData() : Float32ArrayData { return this; } public static function fromData( d : Float32ArrayData ) : Float32Array { return cast d; } public static function fromArray( a : Array, pos = 0, ?length : Int ) : Float32Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; var i = new Float32Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos = 0, ?length : Int ) : Float32Array { return fromData(ArrayBufferView.fromBytes(bytes,bytePos,(length == null ? (bytes.length - bytePos)>>2 : length)<<2).getData()); } } haxe_3.2.1+dfsg.orig/std/haxe/io/Float64Array.hx0000664000175000017500000000601312607337712021231 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef Float64ArrayData = ArrayBufferView.ArrayBufferViewData; abstract Float64Array(Float64ArrayData) { public static inline var BYTES_PER_ELEMENT = 8; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new ArrayBufferView(elements * BYTES_PER_ELEMENT).getData(); } inline function get_length() { return this.byteLength >> 3; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Float { return this.bytes.getFloat((index<<3) + this.byteOffset); } @:arrayAccess public inline function set( index : Int, value : Float ) : Float { if( index >= 0 && index < length ) { this.bytes.setFloat((index<<3) + this.byteOffset, value); return value; } return 0; } public inline function sub( begin : Int, ?length : Int ) : Float64Array { return fromData(this.sub(begin<<3,length == null ? null : length<<3)); } public inline function subarray( ?begin : Int, ?end : Int ) : Float64Array { return fromData(this.subarray(begin==null?null:begin<<3,end==null?null:end<<3)); } public inline function getData() : Float64ArrayData { return this; } public static function fromData( d : Float64ArrayData ) : Float64Array { return cast d; } public static function fromArray( a : Array, pos = 0, ?length : Int ) : Float64Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; var i = new Float64Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos = 0, ?length : Int ) : Float64Array { return fromData(ArrayBufferView.fromBytes(bytes,bytePos,(length == null ? (bytes.length - bytePos)>>3 : length)<<3).getData()); } } haxe_3.2.1+dfsg.orig/std/haxe/io/Input.hx0000664000175000017500000002027312607337712020116 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; /** An Input is an abstract reader. See other classes in the `haxe.io` package for several possible implementations. **/ class Input { /** Endianness (word byte order) used when reading numbers. If `true`, big-endian is used, otherwise `little-endian` is used. **/ public var bigEndian(default,set) : Bool; #if cs private var helper:BytesData; #elseif java private var helper:java.nio.ByteBuffer; #end /** Read and return one byte. **/ public function readByte() : Int { #if cpp throw "Not implemented"; #else return throw "Not implemented"; #end } /** Read `len` bytes and write them into `s` to the position specified by `pos`. Returns the actual length of read data that can be smaller than `len`. See `readFullBytes` that tries to read the exact amount of specified bytes. **/ public function readBytes( s : Bytes, pos : Int, len : Int ) : Int { var k = len; var b = #if js @:privateAccess s.b #else s.getData() #end; if( pos < 0 || len < 0 || pos + len > s.length ) throw Error.OutsideBounds; while( k > 0 ) { #if neko untyped __dollar__sset(b,pos,readByte()); #elseif php b[pos] = untyped __call__("chr", readByte()); #elseif cpp b[pos] = untyped readByte(); #else b[pos] = cast readByte(); #end pos++; k--; } return len; } /** Close the input source. Behaviour while reading after calling this method is unspecified. **/ public function close() : Void { } function set_bigEndian( b : Bool ) : Bool { bigEndian = b; return b; } /* ------------------ API ------------------ */ /** Read and return all available data. The `bufsize` optional argument specifies the size of chunks by which data is read. Its default value is target-specific. **/ public function readAll( ?bufsize : Int ) : Bytes { if( bufsize == null ) #if php bufsize = 8192; // default value for PHP and max under certain circumstances #else bufsize = (1 << 14); // 16 Ko #end var buf = Bytes.alloc(bufsize); var total = new haxe.io.BytesBuffer(); try { while( true ) { var len = readBytes(buf,0,bufsize); if( len == 0 ) throw Error.Blocked; total.addBytes(buf,0,len); } } catch( e : Eof ) { } return total.getBytes(); } /** Read `len` bytes and write them into `s` to the position specified by `pos`. Unlike `readBytes`, this method tries to read the exact `len` amount of bytes. **/ public function readFullBytes( s : Bytes, pos : Int, len : Int ) : Void { while( len > 0 ) { var k = readBytes(s,pos,len); pos += k; len -= k; } } /** Read and return `nbytes` bytes. **/ public function read( nbytes : Int ) : Bytes { var s = Bytes.alloc(nbytes); var p = 0; while( nbytes > 0 ) { var k = readBytes(s,p,nbytes); if( k == 0 ) throw Error.Blocked; p += k; nbytes -= k; } return s; } /** Read a string until a character code specified by `end` is occurred. The final character is not included in the resulting string. **/ public function readUntil( end : Int ) : String { var buf = new StringBuf(); var last : Int; while( (last = readByte()) != end ) buf.addChar( last ); return buf.toString(); } /** Read a line of text separated by CR and/or LF bytes. The CR/LF characters are not included in the resulting string. **/ public function readLine() : String { var buf = new StringBuf(); var last : Int; var s; try { while( (last = readByte()) != 10 ) buf.addChar( last ); s = buf.toString(); if( s.charCodeAt(s.length-1) == 13 ) s = s.substr(0,-1); } catch( e : Eof ) { s = buf.toString(); if( s.length == 0 ) #if neko neko.Lib.rethrow #else throw #end (e); } return s; } /** Read a 32-bit floating point number. Endianness is specified by the `bigEndian` property. **/ public #if !(flash || python) inline #end function readFloat() : Float { return FPHelper.i32ToFloat(readInt32()); } /** Read a 64-bit double-precision floating point number. Endianness is specified by the `bigEndian` property. **/ public function readDouble() : Float { var i1 = readInt32(); var i2 = readInt32(); return bigEndian ? FPHelper.i64ToDouble(i2,i1) : FPHelper.i64ToDouble(i1,i2); } /** Read a 8-bit signed integer. **/ public function readInt8() : Int { var n = readByte(); if( n >= 128 ) return n - 256; return n; } /** Read a 16-bit signed integer. Endianness is specified by the `bigEndian` property. **/ public function readInt16() : Int { var ch1 = readByte(); var ch2 = readByte(); var n = bigEndian ? ch2 | (ch1 << 8) : ch1 | (ch2 << 8); if( n & 0x8000 != 0 ) return n - 0x10000; return n; } /** Read a 16-bit unsigned integer. Endianness is specified by the `bigEndian` property. **/ public function readUInt16() : Int { var ch1 = readByte(); var ch2 = readByte(); return bigEndian ? ch2 | (ch1 << 8) : ch1 | (ch2 << 8); } /** Read a 24-bit signed integer. Endianness is specified by the `bigEndian` property. **/ public function readInt24() : Int { var ch1 = readByte(); var ch2 = readByte(); var ch3 = readByte(); var n = bigEndian ? ch3 | (ch2 << 8) | (ch1 << 16) : ch1 | (ch2 << 8) | (ch3 << 16); if( n & 0x800000 != 0 ) return n - 0x1000000; return n; } /** Read a 24-bit unsigned integer. Endianness is specified by the `bigEndian` property. **/ public function readUInt24() : Int { var ch1 = readByte(); var ch2 = readByte(); var ch3 = readByte(); return bigEndian ? ch3 | (ch2 << 8) | (ch1 << 16) : ch1 | (ch2 << 8) | (ch3 << 16); } /** Read a 32-bit signed integer. Endianness is specified by the `bigEndian` property. **/ public function readInt32() : Int { var ch1 = readByte(); var ch2 = readByte(); var ch3 = readByte(); var ch4 = readByte(); #if (php || python) // php will overflow integers. Convert them back to signed 32-bit ints. var n = bigEndian ? ch4 | (ch3 << 8) | (ch2 << 16) | (ch1 << 24) : ch1 | (ch2 << 8) | (ch3 << 16) | (ch4 << 24); if (n & 0x80000000 != 0) return ( n | 0x80000000); else return n; #else return bigEndian ? ch4 | (ch3 << 8) | (ch2 << 16) | (ch1 << 24) : ch1 | (ch2 << 8) | (ch3 << 16) | (ch4 << 24); #end } /** Read and `len` bytes as a string. **/ public function readString( len : Int ) : String { var b = Bytes.alloc(len); readFullBytes(b,0,len); #if neko return neko.Lib.stringReference(b); #else return b.toString(); #end } #if neko static var _float_of_bytes = neko.Lib.load("std","float_of_bytes",2); static var _double_of_bytes = neko.Lib.load("std","double_of_bytes",2); static function __init__() untyped { Input.prototype.bigEndian = false; } #elseif cpp static var _float_of_bytes = cpp.Lib.load("std","float_of_bytes",2); static var _double_of_bytes = cpp.Lib.load("std","double_of_bytes",2); #end #if (flash || js || python) function getDoubleSig(bytes:Array) { return (((bytes[1]&0xF) << 16) | (bytes[2] << 8) | bytes[3] ) * 4294967296. + (bytes[4] >> 7) * 2147483648 + (((bytes[4]&0x7F) << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7]); } #end } haxe_3.2.1+dfsg.orig/std/haxe/io/Int32Array.hx0000664000175000017500000000575512607337712020725 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef Int32ArrayData = ArrayBufferView.ArrayBufferViewData; abstract Int32Array(Int32ArrayData) { public static inline var BYTES_PER_ELEMENT = 4; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new ArrayBufferView(elements * BYTES_PER_ELEMENT).getData(); } inline function get_length() { return this.byteLength >> 2; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Int { return this.bytes.getInt32((index<<2) + this.byteOffset); } @:arrayAccess public inline function set( index : Int, value : Int ) : Int { if( index >= 0 && index < length ) { this.bytes.setInt32((index<<2) + this.byteOffset, value); return value; } return 0; } public inline function sub( begin : Int, ?length : Int ) : Int32Array { return fromData(this.sub(begin<<2,length == null ? null : length<<2)); } public inline function subarray( ?begin : Int, ?end : Int ) : Int32Array { return fromData(this.subarray(begin==null?null:begin<<2,end==null?null:end<<2)); } public inline function getData() : Int32ArrayData { return this; } public static function fromData( d : Int32ArrayData ) : Int32Array { return cast d; } public static function fromArray( a : Array, pos = 0, ?length : Int ) : Int32Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; var i = new Int32Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos = 0, ?length : Int ) : Int32Array { return fromData(ArrayBufferView.fromBytes(bytes,bytePos,(length == null ? (bytes.length - bytePos)>>2 : length)<<2).getData()); } } haxe_3.2.1+dfsg.orig/std/haxe/io/Output.hx0000664000175000017500000001545712607337712020327 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; /** An Output is an abstract write. A specific output implementation will only have to override the [writeByte] and maybe the [write], [flush] and [close] methods. See [File.write] and [String.write] for two ways of creating an Output. **/ class Output { /** Endianness (word byte order) used when writing numbers. If `true`, big-endian is used, otherwise `little-endian` is used. **/ public var bigEndian(default, set) : Bool; #if java private var helper:java.nio.ByteBuffer; #end /** Write one byte. **/ public function writeByte( c : Int ) : Void { throw "Not implemented"; } /** Write `len` bytes from `s` starting by position specified by `pos`. Returns the actual length of written data that can differ from `len`. See `writeFullBytes` that tries to write the exact amount of specified bytes. **/ public function writeBytes( s : Bytes, pos : Int, len : Int ) : Int { var k = len; var b = s.getData(); #if !neko if( pos < 0 || len < 0 || pos + len > s.length ) throw Error.OutsideBounds; #end while( k > 0 ) { #if neko writeByte(untyped __dollar__sget(b,pos)); #elseif php writeByte(untyped __call__("ord", b[pos])); #elseif cpp writeByte(untyped b[pos]); #else writeByte(untyped b[pos]); #end pos++; k--; } return len; } /** Flush any buffered data. **/ public function flush() { } /** Close the output. Behaviour while writing after calling this method is unspecified. **/ public function close() { } function set_bigEndian( b ) { bigEndian = b; return b; } /* ------------------ API ------------------ */ /** Write all bytes stored in `s`. **/ public function write( s : Bytes ) : Void { var l = s.length; var p = 0; while( l > 0 ) { var k = writeBytes(s,p,l); if( k == 0 ) throw Error.Blocked; p += k; l -= k; } } /** Write `len` bytes from `s` starting by position specified by `pos`. Unlike `writeBytes`, this method tries to write the exact `len` amount of bytes. **/ public function writeFullBytes( s : Bytes, pos : Int, len : Int ) { while( len > 0 ) { var k = writeBytes(s,pos,len); pos += k; len -= k; } } /** Write `x` as 32-bit floating point number. Endianness is specified by the `bigEndian` property. **/ public #if !(flash || python) inline #end function writeFloat( x : Float ) { writeInt32(FPHelper.floatToI32(x)); } /** Write `x` as 64-bit double-precision floating point number. Endianness is specified by the `bigEndian` property. **/ public function writeDouble( x : Float ) { var i64 = FPHelper.doubleToI64(x); if( bigEndian ) { writeInt32(i64.high); writeInt32(i64.low); } else { writeInt32(i64.low); writeInt32(i64.high); } } /** Write `x` as 8-bit signed integer. **/ public function writeInt8( x : Int ) { if( x < -0x80 || x >= 0x80 ) throw Error.Overflow; writeByte(x & 0xFF); } /** Write `x` as 16-bit signed integer. Endianness is specified by the `bigEndian` property. **/ public function writeInt16( x : Int ) { if( x < -0x8000 || x >= 0x8000 ) throw Error.Overflow; writeUInt16(x & 0xFFFF); } /** Write `x` as 16-bit unsigned integer. Endianness is specified by the `bigEndian` property. **/ public function writeUInt16( x : Int ) { if( x < 0 || x >= 0x10000 ) throw Error.Overflow; if( bigEndian ) { writeByte(x >> 8); writeByte(x & 0xFF); } else { writeByte(x & 0xFF); writeByte(x >> 8); } } /** Write `x` as 24-bit signed integer. Endianness is specified by the `bigEndian` property. **/ public function writeInt24( x : Int ) { if( x < -0x800000 || x >= 0x800000 ) throw Error.Overflow; writeUInt24(x & 0xFFFFFF); } /** Write `x` as 24-bit unsigned integer. Endianness is specified by the `bigEndian` property. **/ public function writeUInt24( x : Int ) { if( x < 0 || x >= 0x1000000 ) throw Error.Overflow; if( bigEndian ) { writeByte(x >> 16); writeByte((x >> 8) & 0xFF); writeByte(x & 0xFF); } else { writeByte(x & 0xFF); writeByte((x >> 8) & 0xFF); writeByte(x >> 16); } } /** Write `x` as 32-bit signed integer. Endianness is specified by the `bigEndian` property. **/ public function writeInt32( x : Int ) { if( bigEndian ) { writeByte( x >>> 24 ); writeByte( (x >> 16) & 0xFF ); writeByte( (x >> 8) & 0xFF ); writeByte( x & 0xFF ); } else { writeByte( x & 0xFF ); writeByte( (x >> 8) & 0xFF ); writeByte( (x >> 16) & 0xFF ); writeByte( x >>> 24 ); } } /** Inform that we are about to write at least `nbytes` bytes. The underlying implementation can allocate proper working space depending on this information, or simply ignore it. This is not a mandatory call but a tip and is only used in some specific cases. **/ public function prepare( nbytes : Int ) { } /** Read all available data from `i` and write it. The `bufsize` optional argument specifies the size of chunks by which data is read and written. Its default value is 4096. **/ public function writeInput( i : Input, ?bufsize : Int ) { if( bufsize == null ) bufsize = 4096; var buf = Bytes.alloc(bufsize); try { while( true ) { var len = i.readBytes(buf,0,bufsize); if( len == 0 ) throw Error.Blocked; var p = 0; while( len > 0 ) { var k = writeBytes(buf,p,len); if( k == 0 ) throw Error.Blocked; p += k; len -= k; } } } catch( e : Eof ) { } } /** Write `s` string. **/ public function writeString( s : String ) { #if neko var b = untyped new Bytes(s.length,s.__s); #else var b = Bytes.ofString(s); #end writeFullBytes(b,0,b.length); } #if neko static function __init__() untyped { Output.prototype.bigEndian = false; } #end } haxe_3.2.1+dfsg.orig/std/haxe/io/Path.hx0000664000175000017500000002036312607337712017713 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; /** This class provides a convenient way of working with paths. It supports the common path formats: - directory1/directory2/filename.extension - directory1\directory2\filename.excention **/ class Path { /** The directory. This is the leading part of the path that is not part of the file name and the extension. Does not end with a `/` or `\` separator. If the path has no directory, the value is null. **/ public var dir : String; /** The file name. This is the part of the part between the directory and the extension. If there is no file name, e.g. for ".htaccess" or "/dir/", the value is the empty String "". **/ public var file : String; /** The file extension. It is separated from the file name by a dot. This dot is not part of the extension. If the path has no extension, the value is null. **/ public var ext : String; /** True if the last directory separator is a backslash, false otherwise. **/ public var backslash : Bool; /** Creates a new Path instance by parsing `path`. Path information can be retrieved by accessing the dir, file and ext properties. **/ public function new( path : String ) { switch (path) { case "." | "..": dir = path; file = ""; return; } var c1 = path.lastIndexOf("/"); var c2 = path.lastIndexOf("\\"); if( c1 < c2 ) { dir = path.substr(0,c2); path = path.substr(c2+1); backslash = true; } else if( c2 < c1 ) { dir = path.substr(0,c1); path = path.substr(c1+1); } else dir = null; var cp = path.lastIndexOf("."); if( cp != -1 ) { ext = path.substr(cp+1); file = path.substr(0,cp); } else { ext = null; file = path; } } /** Returns a String representation of `this` path. If `this.backslash` is true, backslash is used as directory separator, otherwise slash is used. This only affects the separator between `this.dir` and `this.file`. If `this.directory` or `this.extension` is null, their representation is the empty String "". **/ public function toString() { return (if( dir == null ) "" else dir + if( backslash ) "\\" else "/") + file + (if( ext == null ) "" else "." + ext); } /** Returns the String representation of `path` without the file extension. If `path` is null, the result is unspecified. **/ public static function withoutExtension( path : String ) { var s = new Path(path); s.ext = null; return s.toString(); } /** Returns the String representation of `path` without the directory. If `path` is null, the result is unspecified. **/ public static function withoutDirectory( path ) { var s = new Path(path); s.dir = null; return s.toString(); } /** Returns the directory of `path`. If the directory is null, the empty String "" is returned. If `path` is null, the result is unspecified. **/ public static function directory( path ) { var s = new Path(path); if( s.dir == null ) return ""; return s.dir; } /** Returns the extension of `path`. If the extension is null, the empty String "" is returned. If `path` is null, the result is unspecified. **/ public static function extension( path ) { var s = new Path(path); if( s.ext == null ) return ""; return s.ext; } /** Returns a String representation of `path` where the extension is `ext`. If `path` has no extension, `ext` is added as extension. If `path` or `ext` are null, the result is unspecified. **/ public static function withExtension( path, ext ) { var s = new Path(path); s.ext = ext; return s.toString(); } /** Joins all paths in `paths` together. If `paths` is empty, the empty String `""` is returned. Otherwise the paths are joined with a slash between them. If `paths` is null, the result is unspecified. **/ public static function join(paths:Array) : String { var paths = paths.filter(function(s) return s != null && s != ""); if (paths.length == 0) { return ""; } var path = paths[0]; for (i in 1...paths.length) { path = addTrailingSlash(path); path += paths[i]; } return normalize(path); } /** Normalize a given `path` (e.g. make '/usr/local/../lib' to '/usr/lib'). Also replaces backslashes \ with slashes / and afterwards turns multiple slashes into a single one. If `path` is null, the result is unspecified. **/ public static function normalize(path : String) : String { var slash = '/'; path = path.split("\\").join("/"); if( path == null || path == slash ) { return slash; } var target = []; for( token in path.split(slash) ) { if(token == '..' && target.length > 0 && target[target.length-1] != "..") { target.pop(); } else if(token != '.') { target.push(token); } } var tmp = target.join(slash); var regex = ~/([^:])\/+/g; var result = regex.replace(tmp, "$1" +slash); var acc = new StringBuf(); var colon = false; var slashes = false; for (i in 0...tmp.length) { switch (tmp.charCodeAt(i)) { case ":".code: acc.add(":"); colon = true; case "/".code if (colon == false): slashes = true; case i: colon = false; if (slashes) { acc.add("/"); slashes = false; } acc.add(String.fromCharCode(i)); } } var result = acc.toString(); return result; } /** Adds a trailing slash to `path`, if it does not have one already. If the last slash in `path` is a backslash, a backslash is appended to `path`. If the last slash in `path` is a slash, or if no slash is found, a slash is appended to `path`. In particular, this applies to the empty String "". If `path` is null, the result is unspecified. **/ public static function addTrailingSlash( path : String ) : String { if (path.length == 0) return "/"; var c1 = path.lastIndexOf("/"); var c2 = path.lastIndexOf("\\"); return if ( c1 < c2 ) { if (c2 != path.length - 1) path + "\\"; else path; } else { if (c1 != path.length - 1) path + "/"; else path; } } /** Removes trailing slashes from `path`. If `path` does not end with a `/` or `\`, `path` is returned unchanged. Otherwise the substring of `path` excluding the trailing slashes or backslashes is returned. If `path` is null, the result is unspecified. **/ @:require(haxe_ver >= 3.1) public static function removeTrailingSlashes ( path : String ) : String { while (true) { switch(path.charCodeAt(path.length - 1)) { case '/'.code | '\\'.code: path = path.substr(0, -1); case _: break; } } return path; } /** Returns true if the path is an absolute path, and false otherwise. **/ @:require(haxe_ver >= 3.2) public static function isAbsolute ( path : String ) : Bool { if (StringTools.startsWith(path, '/')) return true; if (path.charAt(1) == ':') return true; return false; } private static function unescape( path : String ) : String { var regex = ~/-x([0-9][0-9])/g; return regex.map(path, function(regex) return String.fromCharCode(Std.parseInt(regex.matched(1)))); } private static function escape( path : String, allowSlashes : Bool = false ) : String { var regex = allowSlashes ? ~/[^A-Za-z0-9_\/\\\.]/g : ~/[^A-Za-z0-9_\.]/g; return regex.map(path, function(v) return '-x' + v.matched(0).charCodeAt(0)); } } haxe_3.2.1+dfsg.orig/std/haxe/io/StringInput.hx0000664000175000017500000000251212607337712021301 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; class StringInput extends BytesInput { public function new( s : String ) { #if neko // don't copy the string super( neko.Lib.bytesReference(s) ); #else super( haxe.io.Bytes.ofString(s) ); #end } }haxe_3.2.1+dfsg.orig/std/haxe/io/UInt16Array.hx0000664000175000017500000000577212607337712021053 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef UInt16ArrayData = ArrayBufferView.ArrayBufferViewData; abstract UInt16Array(UInt16ArrayData) { public static inline var BYTES_PER_ELEMENT = 2; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new ArrayBufferView(elements * BYTES_PER_ELEMENT).getData(); } inline function get_length() { return this.byteLength >> 1; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Int { return this.bytes.getUInt16((index<<1) + this.byteOffset); } @:arrayAccess public inline function set( index : Int, value : Int ) : Int { if( index >= 0 && index < length ) { this.bytes.setUInt16((index<<1) + this.byteOffset, value); return value; } return 0; } public inline function sub( begin : Int, ?length : Int ) : UInt16Array { return fromData(this.sub(begin<<1,length == null ? null : length<<1)); } public inline function subarray( ?begin : Int, ?end : Int ) : UInt16Array { return fromData(this.subarray(begin==null?null:begin<<1,end==null?null:end<<1)); } public inline function getData() : UInt16ArrayData { return this; } public static function fromData( d : UInt16ArrayData ) : UInt16Array { return cast d; } public static function fromArray( a : Array, pos = 0, ?length : Int ) : UInt16Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; var i = new UInt16Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos = 0, ?length : Int ) : UInt16Array { return fromData(ArrayBufferView.fromBytes(bytes,bytePos,(length == null ? (bytes.length - bytePos)>>1 : length)<<1).getData()); } } haxe_3.2.1+dfsg.orig/std/haxe/io/UInt32Array.hx0000664000175000017500000000577412607337712021053 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef UInt32ArrayData = ArrayBufferView.ArrayBufferViewData; abstract UInt32Array(UInt32ArrayData) { public static inline var BYTES_PER_ELEMENT = 4; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new ArrayBufferView(elements * BYTES_PER_ELEMENT).getData(); } inline function get_length() { return this.byteLength >> 2; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : UInt { return this.bytes.getInt32((index<<2) + this.byteOffset); } @:arrayAccess public inline function set( index : Int, value : UInt ) : UInt { if( index >= 0 && index < length ) { this.bytes.setInt32((index<<2) + this.byteOffset, value); return value; } return 0; } public inline function sub( begin : Int, ?length : Int ) : UInt32Array { return fromData(this.sub(begin<<2,length == null ? null : length<<2)); } public inline function subarray( ?begin : Int, ?end : Int ) : UInt32Array { return fromData(this.subarray(begin==null?null:begin<<2,end==null?null:end<<2)); } public inline function getData() : UInt32ArrayData { return this; } public static function fromData( d : UInt32ArrayData ) : UInt32Array { return cast d; } public static function fromArray( a : Array, pos = 0, ?length : Int ) : UInt32Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; var i = new UInt32Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos = 0, ?length : Int ) : UInt32Array { return fromData(ArrayBufferView.fromBytes(bytes,bytePos,(length == null ? (bytes.length - bytePos)>>2 : length)<<2).getData()); } } haxe_3.2.1+dfsg.orig/std/haxe/io/UInt8Array.hx0000664000175000017500000000553512607337712020771 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef UInt8ArrayData = ArrayBufferView.ArrayBufferViewData; abstract UInt8Array(UInt8ArrayData) { public static inline var BYTES_PER_ELEMENT = 1; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new ArrayBufferView(elements * BYTES_PER_ELEMENT).getData(); } inline function get_length() { return this.byteLength; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) { return this.bytes.get(index + this.byteOffset); } @:arrayAccess public inline function set( index : Int, value : Int ) : Int { if( index >= 0 && index < length ) { this.bytes.set(index + this.byteOffset, value); return value; } return 0; } public inline function sub( begin : Int, ?length : Int ) : UInt8Array { return fromData(this.sub(begin,length)); } public inline function subarray( ?begin : Int, ?end : Int ) : UInt8Array { return fromData(this.subarray(begin,end)); } public inline function getData() : UInt8ArrayData { return this; } public static function fromData( d : UInt8ArrayData ) : UInt8Array { return cast d; } public static function fromArray( a : Array, pos = 0, ?length : Int ) : UInt8Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; var i = new UInt8Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : UInt8Array { return fromData(ArrayBufferView.fromBytes(bytes,bytePos,length).getData()); } } haxe_3.2.1+dfsg.orig/std/haxe/macro/Compiler.hx0000664000175000017500000002700112607337712021257 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Expr; /** All these methods can be called for compiler configuration macros. **/ class Compiler { macro static public function getDefine( key : String ) { return macro $v{haxe.macro.Context.definedValue(key)}; } #if neko static var ident = ~/^[A-Za-z_][A-Za-z0-9_]*$/; static var path = ~/^[A-Za-z_][A-Za-z0-9_.]*$/; public static function allowPackage( v : String ) { untyped load("allow_package", 1)(v.__s); } public static function define( flag : String, ?value : String ) untyped { var v = flag + (value == null ? "" : "=" + value); load("define", 1)(v.__s); } public static function removeField( className : String, field : String, ?isStatic : Bool ) { if( !path.match(className) ) throw "Invalid "+className; if( !ident.match(field) ) throw "Invalid "+field; untyped load("type_patch",4)(className.__s,field.__s,isStatic == true,null); } public static function setFieldType( className : String, field : String, type : String, ?isStatic : Bool ) { if( !path.match(className) ) throw "Invalid "+className; if( !ident.match((field.charAt(0) == "$") ? field.substr(1) : field) ) throw "Invalid "+field; untyped load("type_patch",4)(className.__s,field.__s,isStatic == true,type.__s); } public static function addMetadata( meta : String, className : String, ?field : String, ?isStatic : Bool ) { if( !path.match(className) ) throw "Invalid "+className; if( field != null && !ident.match(field) ) throw "Invalid "+field; untyped load("meta_patch",4)(meta.__s,className.__s,(field == null)?null:field.__s,isStatic == true); } public static function addClassPath( path : String ) { untyped load("add_class_path",1)(path.__s); } public static function getOutput() : String { return new String(untyped load("get_output",0)()); } public static function setOutput( fileOrDir : String ) { untyped load("set_output",1)(untyped fileOrDir.__s); } public static function getDisplayPos() : Null<{ file : String, pos : Int }> { var o = untyped load("get_display_pos",0)(); if( o != null ) o.file = new String(o.file); return o; } /** Adds a native library depending on the platform (eg : -swf-lib for Flash) **/ public static function addNativeLib( name : String ) { untyped load("add_native_lib",1)(name.__s); } /** Adds an argument to be passed to the native compiler (eg : -javac-arg for Java) **/ public static function addNativeArg( argument : String ) { untyped load("add_native_arg",1)(argument.__s); } /** Includes all modules in package `pack` in the compilation. In order to include single modules, their paths can be listed directly on command line: `haxe ... ModuleName pack.ModuleName`. By default `Compiler.include` will search for modules in the directories defined with `-cp`. If you want to specify a different set of paths to search for modules, you can use the optional argument `classPath`. @param rec If true, recursively adds all sub-packages. @param ignore Array of module names to ignore for inclusion. @param classPaths An alternative array of paths (directory names) to use to search for modules to include. Note that if you pass this argument, only the specified paths will be used for inclusion. **/ public static function include( pack : String, ?rec = true, ?ignore : Array, ?classPaths : Array ) { var skip = if( ignore == null ) { function(c) return false; } else { function(c) return Lambda.has(ignore, c); } var displayValue = Context.definedValue("display"); if( classPaths == null ) { classPaths = Context.getClassPath(); // do not force inclusion when using completion switch (displayValue) { case null: case "usage": case _: return; } // normalize class path for( i in 0...classPaths.length ) { var cp = StringTools.replace(classPaths[i], "\\", "/"); if(StringTools.endsWith(cp, "/")) cp = cp.substr(0, -1); if( cp == "" ) cp = "."; classPaths[i] = cp; } } var prefix = pack == '' ? '' : pack + '.'; for( cp in classPaths ) { var path = pack == '' ? cp : cp + "/" + pack.split(".").join("/"); if( !sys.FileSystem.exists(path) || !sys.FileSystem.isDirectory(path) ) continue; for( file in sys.FileSystem.readDirectory(path) ) { if( StringTools.endsWith(file, ".hx") ) { var cl = prefix + file.substr(0, file.length - 3); if( skip(cl) ) continue; Context.getModule(cl); } else if( rec && sys.FileSystem.isDirectory(path + "/" + file) && !skip(prefix + file) ) include(prefix + file, true, ignore, classPaths); } } } /** Exclude a class or a enum without changing it to @:nativeGen. **/ static function excludeBaseType( baseType : Type.BaseType ) : Void { if (!baseType.isExtern) { var meta = baseType.meta; if (!meta.has(":nativeGen")) { meta.add(":hxGen", [], baseType.pos); } baseType.exclude(); } } /** Exclude a given class or a complete package from being generated. **/ public static function exclude( pack : String, ?rec = true ) { Context.onGenerate(function(types) { for( t in types ) { var b : Type.BaseType, name; switch( t ) { case TInst(c, _): name = c.toString(); b = c.get(); case TEnum(e, _): name = e.toString(); b = e.get(); default: continue; } var p = b.pack.join("."); if( (p == pack || name == pack) || (rec && StringTools.startsWith(p, pack + ".")) ) excludeBaseType(b); } }); } /** Exclude classes listed in an extern file (one per line) from being generated. **/ public static function excludeFile( fileName : String ) { fileName = Context.resolvePath(fileName); var f = sys.io.File.read(fileName,true); var classes = new haxe.ds.StringMap(); try { while( true ) { var l = StringTools.trim(f.readLine()); if( l == "" || !~/[A-Za-z0-9._]/.match(l) ) continue; classes.set(l,true); } } catch( e : haxe.io.Eof ) { } Context.onGenerate(function(types) { for( t in types ) { switch( t ) { case TInst(c, _): if( classes.exists(c.toString()) ) excludeBaseType(c.get()); case TEnum(e, _): if( classes.exists(e.toString()) ) excludeBaseType(e.get()); default: } } }); } /** Load a type patch file that can modify declared classes fields types **/ public static function patchTypes( file : String ) : Void { var file = Context.resolvePath(file); var f = sys.io.File.read(file, true); try { while( true ) { var r = StringTools.trim(f.readLine()); if( r == "" || r.substr(0,2) == "//" ) continue; if( StringTools.endsWith(r,";") ) r = r.substr(0,-1); if( r.charAt(0) == "-" ) { r = r.substr(1); var isStatic = StringTools.startsWith(r,"static "); if( isStatic ) r = r.substr(7); var p = r.split("."); var field = p.pop(); removeField(p.join("."),field,isStatic); continue; } if( r.charAt(0) == "@" ) { var rp = r.split(" "); var type = rp.pop(); var isStatic = rp[rp.length - 1] == "static"; if( isStatic ) rp.pop(); var meta = rp.join(" "); var p = type.split("."); var field = if( p.length > 1 && p[p.length-2].charAt(0) >= "a" ) null else p.pop(); addMetadata(meta,p.join("."),field,isStatic); continue; } if( StringTools.startsWith(r, "enum ") ) { define("fakeEnum:" + r.substr(5)); continue; } var rp = r.split(" : "); if( rp.length > 1 ) { r = rp.shift(); var isStatic = StringTools.startsWith(r,"static "); if( isStatic ) r = r.substr(7); var p = r.split("."); var field = p.pop(); setFieldType(p.join("."),field,rp.join(" : "),isStatic); continue; } throw "Invalid type patch "+r; } } catch( e : haxe.io.Eof ) { } } /** Marks types or packages to be kept by DCE. This also extends to the sub-types of resolved modules. In order to include module sub-types directly, their full dot path including the containing module has to be used (e.g. msignal.Signal.Signal0). This operation has no effect if the type has already been loaded, e.g. through `Context.getType`. @param path A package, module or sub-type dot path to keep. @param paths An Array of package, module or sub-type dot paths to keep. @param recursive If true, recurses into sub-packages for package paths. **/ public static function keep(?path : String, ?paths : Array, ?recursive:Bool = true) { if (null == paths) paths = []; if (null != path) paths.push(path); for (path in paths) { addGlobalMetadata(path, "@:keep", recursive, true, true); } } /** Adds metadata `meta` to all types (if `toTypes = true`) or fields (if `toFields = true`) whose dot-path matches `pathFilter`. If `recursive` is true a dot-path is considered matched if it starts with `pathFilter`. This automatically applies to path filters of packages. Otherwise an exact match is required. If `pathFilter` is the empty String `""` it matches everything (if `recursive = true`) or only top-level types (if `recursive = false`). This operation has no effect if the type has already been loaded, e.g. through `Context.getType`. **/ public static function addGlobalMetadata(pathFilter:String, meta:String, ?recursive:Bool = true, ?toTypes:Bool = true, ?toFields:Bool = false) { untyped load("add_global_metadata",5)(untyped pathFilter.__s, meta.__s, recursive, toTypes, toFields); } /** Change the default JS output by using a custom generator callback **/ public static function setCustomJSGenerator( callb : JSGenApi -> Void ) { load("custom_js",1)(callb); } static function load( f, nargs ) : Dynamic { #if macro return neko.Lib.load("macro", f, nargs); #else return Reflect.makeVarArgs(function(_) return throw "Can't be called outside of macro"); #end } #end #if (js || macro) /** Embed an on-disk javascript file (can be called into an __init__ method) **/ public static macro function includeFile( fileName : Expr ) { var str = switch( fileName.expr ) { case EConst(c): switch( c ) { case CString(str): str; default: null; } default: null; } if( str == null ) Context.error("Should be a constant string", fileName.pos); var f = try sys.io.File.getContent(Context.resolvePath(str)) catch( e : Dynamic ) Context.error(Std.string(e), fileName.pos); var p = Context.currentPos(); return { expr : EUntyped( { expr : ECall( { expr : EConst(CIdent("__js__")), pos : p }, [ { expr : EConst(CString(f)), pos : p } ]), pos : p } ), pos : p }; } #end } haxe_3.2.1+dfsg.orig/std/haxe/macro/ComplexTypeTools.hx0000664000175000017500000000373412607337712023006 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Expr; /** This class provides some utility methods to work with AST-level types. It is best used through 'using haxe.macro.ComplexTypeTools' syntax and then provides additional methods on haxe.macro.Expr.ComplexType instances. **/ class ComplexTypeTools { /** Converts type [c] to a human-readable String representation. The result is guaranteed to be valid haxe code, but there may be differences from the original lexical syntax. **/ static public function toString( c : ComplexType ) : String return new Printer().printComplexType(c); #if macro /** Returns a type corresponding to [c]. If [c] is null, the result is null. **/ static public function toType( c : ComplexType ) : Null return c == null ? null : haxe.macro.Context.typeof( { expr: ECheckType(macro null, c), pos: Context.currentPos() } ); #end }haxe_3.2.1+dfsg.orig/std/haxe/macro/Context.hx0000664000175000017500000003725012607337712021140 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Expr; import haxe.macro.Type.TypedExpr; /** Context provides an API for macro programming. It contains common functions that interact with the macro interpreter to query or set information. Other API functions are available in the tools classes: - `haxe.macro.ComplexTypeTools` - `haxe.macro.ExprTools` - `haxe.macro.TypeTools` **/ #if !neko @:noDoc #end class Context { #if neko /** Displays a compilation error `msg` at the given `Position` `pos` and aborts the current macro call. **/ public static function error( msg : String, pos : Position ) : Dynamic { return load("error",2)(untyped msg.__s, pos); } /** Displays a compilation error `msg` at the given `Position` `pos` and aborts the compilation. **/ public static function fatalError( msg : String, pos : Position ) : Dynamic { return load("fatal_error",2)(untyped msg.__s, pos); } /** Displays a compilation warning `msg` at the given `Position` `pos`. **/ public static function warning( msg : String, pos : Position ) { load("warning",2)(untyped msg.__s, pos); } /** Resolves a file name `file` based on the current class paths. The resolution follows the usual class path rules where the last declared class path has priority. If a class path was declared relative, this method returns the relative file path. Otherwise it returns the absolute file path. **/ public static function resolvePath( file : String ) { return new String(load("resolve",1)(untyped file.__s)); } /** Returns an `Array` of current class paths in the order of their declaration. Modifying the returned array has no effect on the compiler. Class paths can be added using `haxe.macro.Compiler.addClassPath`. **/ public static function getClassPath() : Array { var c : neko.NativeArray = load("class_path",0)(); var a = new Array(); for( i in 0...neko.NativeArray.length(c) ) a.push(Std.string(c[i])); return a; } /** Returns the position at which the macro was called. **/ public static function currentPos() : Position { return load("curpos", 0)(); } /** Returns the type which is expected at the place the macro is called. This affects usages such as `var x:Int = macroCall()`, where the expected type will be reported as Int. Might return null if no specific type is expected or if the calling macro is not an expression-macro. **/ @:require(haxe_ver >= 3.1) public static function getExpectedType():Null { var l : Type = load("expected_type", 0)(); if( l == null ) return null; return l; } /** Returns the call arguments that lead to the invocation of the current `@:genericBuild` macro, if available. Returns `null` if the current macro is not a `@:genericBuild` macro. **/ @:require(haxe_ver >= 3.2) public static function getCallArguments():Null> { return load("call_arguments", 0)(); } /** Returns the current class in which the macro was called. If no such class exists, null is returned. **/ public static function getLocalClass() : Null> { var l : Type = load("local_type", 0)(); if( l == null ) return null; return switch( l ) { case TInst(c,_): c; default: null; } } /** Returns the current module path in/on which the macro was called. **/ public static function getLocalModule() : String { return new String(load("local_module", 0)()); } /** Returns the current type in/on which the macro was called. If no such type exists, null is returned. **/ public static function getLocalType() : Null { var l : Type = load("local_type", 0)(); if( l == null ) return null; return l; } /** Returns the name of the method from which the macro was called. If no such method exists, null is returned. **/ public static function getLocalMethod() : Null { var l : String = load("local_method", 0)(); if (l == "") return null; return new String(l); } /** Returns an `Array` of classes which are available for `using` usage in the context the macro was called. Modifying the returned array has no effect on the compiler. **/ public static function getLocalUsing() : Array> { return load("local_using", 0)(); } /** Returns a map of local variables accessible in the context the macro was called. The keys of the returned map are the variable names, the values are their types. Modifying the returned map has no effect on the compiler. **/ @:deprecated("Use Context.getLocalTVars() instead") public static function getLocalVars() : Map { return load("local_vars", 1)(false); } /** Similar to `getLocalVars`, but returns elements of type `TVar` instead of `Type`. **/ @:require(haxe_ver >= 3.102) public static function getLocalTVars() : Map { return load("local_vars", 1)(true); } /** Tells if compiler directive `s` has been set. Compiler directives are set using the `-D` command line parameter, or by calling `haxe.macro.Compiler.define`. **/ public static function defined( s : String ) : Bool { return load("defined", 1)(untyped s.__s); } /** Returns the value defined for compiler directive `key`. If no value is defined for `key`, null is returned. Compiler directive values are set using the `-D key=value` command line parameter, or by calling `haxe.macro.Compiler.define`. The default value is `"1"`. **/ public static function definedValue( key : String ) : String { var d = load("defined_value", 1)(untyped key.__s); return d == null ? null : new String(d); } /** Returns a map of all compiler directives that have been set. Compiler directives are set using the `-D` command line parameter, or by calling `haxe.macro.Compiler.define`. Modifying the returned map has no effect on the compiler. */ public static function getDefines() : Map { return load("get_defines", 0)(); } /** Resolves a type identified by `name`. The resolution follows the usual class path rules where the last declared class path has priority. If no type can be found, an exception of type `String` is thrown. **/ public static function getType( name : String ) : Type { return load("get_type", 1)(untyped name.__s); } /** Resolves a module identified by `name` and returns an `Array` of all its contained types. The resolution follows the usual class path rules where the last declared class path has priority. If no module can be found, null is returned. **/ public static function getModule( name : String ) : Array { return load("get_module", 1)(untyped name.__s); } /** Parses `expr` as haxe code, returning the corresponding AST. String interpolation of single quote strings within `expr` is not supported. The provided `Position` `pos` is used for all generated inner AST nodes. **/ public static function parse( expr : String, pos : Position ) : Expr { return load("parse", 3)(untyped expr.__s, pos, false); } /** Similar to `parse`, but error positions are reported within the provided String `expr`. **/ public static function parseInlineString( expr : String, pos : Position ) : Expr { return load("parse", 3)(untyped expr.__s, pos, true); } /** Builds an expression from `v`. This method generates AST nodes depending on the macro-runtime value of `v`. As such, only basic types and enums are supported and the behavior for other types is undefined. The provided `Position` `pos` is used for all generated inner AST nodes. **/ public static function makeExpr( v : Dynamic, pos : Position ) : Expr { return load("make_expr", 2)(v, pos); } /** Returns a hashed MD5 signature of value `v`. **/ public static function signature( v : Dynamic ) : String { return new String(load("signature", 1)(v)); } /** Adds a callback function `callback` which is invoked after the compiler's typing phase, just before its generation phase. The callback receives an `Array` containing all types which are about to be generated. Modifications are limited to metadata, it is mainly intended to obtain information. **/ public static function onGenerate( callback : Array -> Void ) { load("on_generate",1)(callback); } /** Adds a callback function `callback` which is invoked after the compiler generation phase. Compilation has completed at this point and cannot be influenced anymore. However, contextual information is still available. **/ @:require(haxe_ver >= 3.1) public static function onAfterGenerate( callback : Void -> Void ) { load("after_generate",1)(callback); } /** Adds a callback function `callback` which is invoked when a type name cannot be resolved. The callback may return a type definition, which is then used for the expected type. If it returns null, the type is considered to still not exist. **/ public static function onTypeNotFound ( callback : String -> TypeDefinition ) { load("on_type_not_found",1)(callback); } /** Types expression `e` and returns its type. Typing the expression may result in an compiler error which can be caught using `try ... catch`. **/ public static function typeof( e : Expr ) : Type { return load("typeof", 1)(e); } /** Types expression `e` and returns the corresponding `TypedExpr`. Typing the expression may result in an compiler error which can be caught using `try ... catch`. **/ @:require(haxe_ver >= 3.1) public static function typeExpr( e : Expr ) : TypedExpr { return load("type_expr", 1)(e); } /** Returns the `ComplexType` corresponding to the given `Type` `t`. See `haxe.macro.TypeTools.toComplexType` for details. **/ public static function toComplexType( t : Type ) : Null { return load("to_complex", 1)(t); } /** Returns true if `t1` and `t2` unify, false otherwise. **/ public static function unify( t1 : Type, t2 : Type) : Bool { return load("unify", 2)(t1, t2); } /** Follows a type. See `haxe.macro.TypeTools.follow` for details. **/ public static function follow( t : Type, ?once : Bool ) : Type { return load("follow", 2)(t,once); } /** Returns the information stored in `Position` `p`. **/ public static function getPosInfos( p : Position ) : { min : Int, max : Int, file : String } { var i = load("get_pos_infos",1)(p); i.file = new String(i.file); return i; } /** Builds a `Position` from `inf`. **/ public static function makePosition( inf : { min : Int, max : Int, file : String } ) : Position { return load("make_pos",3)(inf.min,inf.max,untyped inf.file.__s); } /** Returns a map of all registered resources for this compilation unit. Modifying the returned map has no effect on the compilation, use `haxe.macro.Context.addResource` to add new resources to the compilation unit. **/ public static function getResources():Map { var x:haxe.ds.StringMap = load("get_resources",0)(); var r = new haxe.ds.StringMap(); for (k in x.keys()) { r.set(k, haxe.io.Bytes.ofData(x.get(k))); } return r; } /** Makes resource `data` available as `name`. The resource is then available using the `haxe.macro.Resource` API. If a previous resource was bound to `name`, it is overwritten. **/ public static function addResource( name : String, data : haxe.io.Bytes ) { load("add_resource",2)(untyped name.__s,data.getData()); } /** Returns an `Array` of fields of the class which is to be built. This is only defined for `@:build/@:autoBuild` macros. **/ public static function getBuildFields() : Array { return load("build_fields", 0)(); } /** Defines a new type from `TypeDefinition` `t`. **/ public static function defineType( t : TypeDefinition ) : Void { load("define_type", 1)(t); } /** Defines a new module as `modulePath` with several `TypeDefinition` `types`. This is analogous to defining a .hx file. The individial `types` can reference each other and any identifier respects the `imports` and `usings` as usual, expect that imports are not allowed to have `.*` wildcards or `in s` shorthands. **/ public static function defineModule( modulePath : String, types : Array, ?imports: Array, ?usings : Array ) : Void { if (imports == null) imports = []; if (usings == null) usings = []; load("define_module", 4)(untyped modulePath.__s, untyped types.__neko(), untyped imports.__neko(), untyped usings.__neko()); } /** Returns a syntax-level expression corresponding to typed expression `t`. This process may lose some information. **/ public static function getTypedExpr( t : Type.TypedExpr ) : Expr { return load("get_typed_expr",1)(t); } /** Store typed expression `t` internally and give a syntax-level expression that can be returned from a macro and will be replaced by the stored typed expression. If `t` is null or invalid, an exception is thrown. NOTE: the returned value references an internally stored typed expression that is reset between compilations, so care should be taken when storing the expression returned by this method in a static variable and using the compilation server. **/ @:require(haxe_ver >= 3.2) public static function storeTypedExpr( t : Type.TypedExpr ) : Expr { return load("store_typed_expr",1)(t); } /** Manually adds a dependency between module `modulePath` and an external file `externFile`. This affects the compilation cache, causing the module to be typed if `externFile` has changed. Has no effect if the compilation cache is not used. **/ public static function registerModuleDependency( modulePath : String, externFile : String ) { load("module_dependency", 2)(untyped modulePath.__s,untyped externFile.__s); } /** Add a macro call to perform in case the module is reused by the compilation cache. **/ public static function registerModuleReuseCall( modulePath : String, macroCall : String ) { load("module_reuse_call", 2)(untyped modulePath.__s,untyped macroCall.__s); } /** Register a callback function that will be called everytime the macro context cached is reused with a new compilation. This enable to reset some static vars since the code might have been changed. If the callback returns false, the macro context is discarded and another one is created. **/ public static function onMacroContextReused( callb : Void -> Bool ) { load("macro_context_reused", 1)(callb); } @:allow(haxe.macro.TypeTools) @:allow(haxe.macro.MacroStringTools) @:allow(haxe.macro.TypedExprTools) static function load( f, nargs ) : Dynamic { #if macro return neko.Lib.load("macro", f, nargs); #else return Reflect.makeVarArgs(function(_) return throw "Can't be called outside of macro"); #end } #end } haxe_3.2.1+dfsg.orig/std/haxe/macro/ExampleJSGenerator.hx0000664000175000017500000001516012607337712023207 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Type; import haxe.macro.Expr; using Lambda; class ExampleJSGenerator { var api : JSGenApi; var buf : StringBuf; var inits : List; var statics : List<{ c : ClassType, f : ClassField }>; var packages : haxe.ds.StringMap; var forbidden : haxe.ds.StringMap; public function new(api) { this.api = api; buf = new StringBuf(); inits = new List(); statics = new List(); packages = new haxe.ds.StringMap(); forbidden = new haxe.ds.StringMap(); for( x in ["prototype", "__proto__", "constructor"] ) forbidden.set(x, true); api.setTypeAccessor(getType); } function getType( t : Type ) { return switch(t) { case TInst(c, _): getPath(c.get()); case TEnum(e, _): getPath(e.get()); case TAbstract(a, _): getPath(a.get()); default: throw "assert"; }; } inline function print(str) { buf.add(str); } inline function newline() { buf.add(";\n"); } inline function genExpr(e) { print(api.generateValue(e)); } function field(p) { return api.isKeyword(p) ? '["' + p + '"]' : "." + p; } function genPackage( p : Array ) { var full = null; for( x in p ) { var prev = full; if( full == null ) full = x else full += "." + x; if( packages.exists(full) ) continue; packages.set(full, true); if( prev == null ) print('if(typeof $x==\'undefined\') $x = {}'); else { var p = prev + field(x); print('if(!$p) $p = {}'); } newline(); } } function getPath( t : BaseType ) { return (t.pack.length == 0) ? t.name : t.pack.join(".") + "." + t.name; } function checkFieldName( c : ClassType, f : ClassField ) { if( forbidden.exists(f.name) ) Context.error("The field " + f.name + " is not allowed in JS", c.pos); } function genClassField( c : ClassType, p : String, f : ClassField ) { checkFieldName(c, f); var field = field(f.name); print('$p.prototype$field = '); var e = f.expr(); if( e == null ) print("null"); else { genExpr(e); } newline(); } function genStaticField( c : ClassType, p : String, f : ClassField ) { checkFieldName(c, f); var field = field(f.name); var e = f.expr(); if( e == null ) { print('$p$field = null'); newline(); } else switch( f.kind ) { case FMethod(_): print('$p$field = '); genExpr(e); newline(); default: statics.add( { c : c, f : f } ); } } function genClass( c : ClassType ) { genPackage(c.pack); api.setCurrentClass(c); var p = getPath(c); print('$p = $$hxClasses[\'$p\'] = '); if( c.constructor != null ) genExpr(c.constructor.get().expr()); else print("function() { }"); newline(); var name = p.split(".").map(api.quoteString).join(","); print('$p.__name__ = [$name]'); newline(); if( c.superClass != null ) { var psup = getPath(c.superClass.t.get()); print('$p.__super__ = $psup'); newline(); print('for(var k in $psup.prototype ) $p.prototype[k] = $psup.prototype[k]'); newline(); } for( f in c.statics.get() ) genStaticField(c, p, f); for( f in c.fields.get() ) { switch( f.kind ) { case FVar(r, _): if( r == AccResolve ) continue; default: } genClassField(c, p, f); } print('$p.prototype.__class__ = $p'); newline(); if( c.interfaces.length > 0 ) { var me = this; var inter = c.interfaces.map(function(i) return me.getPath(i.t.get())).join(","); print('$p.__interfaces__ = [$inter]'); newline(); } } function genEnum( e : EnumType ) { genPackage(e.pack); var p = getPath(e); var names = p.split(".").map(api.quoteString).join(","); var constructs = e.names.map(api.quoteString).join(","); print('$p = $$hxClasses[\'$p\'] = { __ename__ : [$names], __constructs__ : [$constructs] }'); newline(); for( c in e.constructs.keys() ) { var c = e.constructs.get(c); var f = field(c.name); print('$p$f = '); switch( c.type ) { case TFun(args, _): var sargs = args.map(function(a) return a.name).join(","); print('function($sargs) { var $$x = ["${c.name}",${c.index},$sargs]; $$x.__enum__ = $p; $$x.toString = $$estr; return $$x; }'); default: print("[" + api.quoteString(c.name) + "," + c.index + "]"); newline(); print('$p$f.toString = $$estr'); newline(); print('$p$f.__enum__ = $p'); } newline(); } var meta = api.buildMetaData(e); if( meta != null ) { print('$p.__meta__ = '); genExpr(meta); newline(); } } function genStaticValue( c : ClassType, cf : ClassField ) { var p = getPath(c); var f = field(cf.name); print('$p$f = '); genExpr(cf.expr()); newline(); } function genType( t : Type ) { switch( t ) { case TInst(c, _): var c = c.get(); if( c.init != null ) inits.add(c.init); if( !c.isExtern ) genClass(c); case TEnum(r, _): var e = r.get(); if( !e.isExtern ) genEnum(e); default: } } public function generate() { print("var $_, $hxClasses = $hxClasses || {}, $estr = function() { return js.Boot.__string_rec(this,''); }"); newline(); print("function $bind(o,m) { var f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; return f; };"); newline(); for( t in api.types ) genType(t); for( e in inits ) { print(api.generateStatement(e)); newline(); } for( s in statics ) { genStaticValue(s.c,s.f); newline(); } if( api.main != null ) { genExpr(api.main); newline(); } sys.io.File.saveContent(api.outputFile, buf.toString()); } #if macro public static function use() { Compiler.setCustomJSGenerator(function(api) new ExampleJSGenerator(api).generate()); } #end } haxe_3.2.1+dfsg.orig/std/haxe/macro/Expr.hx0000664000175000017500000001417712607337712020435 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; #if (macro && !doc_gen) extern enum Position { } #else typedef Position = { var file : String; var min : Int; var max : Int; } #end enum Constant { CInt( v : String ); CFloat( f : String ); CString( s : String ); CIdent( s : String ); CRegexp( r : String, opt : String ); } enum Binop { /** `+` **/ OpAdd; /** `*` **/ OpMult; /** `/` **/ OpDiv; /** `-` **/ OpSub; /** `=` **/ OpAssign; /** `==` **/ OpEq; /** `!=` **/ OpNotEq; /** `>` **/ OpGt; /** `>=` **/ OpGte; /** `<` **/ OpLt; /** `<=` **/ OpLte; /** `&` **/ OpAnd; /** `|` **/ OpOr; /** `^` **/ OpXor; /** `&&` **/ OpBoolAnd; /** `||` **/ OpBoolOr; /** `<<` **/ OpShl; /** `>>` **/ OpShr; /** `>>>` **/ OpUShr; /** `%` **/ OpMod; /** `+=` `-=` `/=` `*=` `<<=` `>>=` `>>>=` `|=` `&=` `^=` `%=` **/ OpAssignOp( op : Binop ); /** `...` **/ OpInterval; /** `=>` **/ OpArrow; } enum Unop { /** `++` **/ OpIncrement; /** `--` **/ OpDecrement; /** `!` **/ OpNot; /** `-` **/ OpNeg; /** `~` **/ OpNegBits; } typedef Expr = { var expr : ExprDef; var pos : Position; } typedef ExprOf = Expr; typedef Case = { var values : Array; @:optional var guard : Null; var expr: Null; } typedef Var = { name : String, type : Null, expr : Null } typedef Catch = { name : String, type : ComplexType, expr : Expr } enum ExprDef { EConst( c : Constant ); EArray( e1 : Expr, e2 : Expr ); EBinop( op : Binop, e1 : Expr, e2 : Expr ); EField( e : Expr, field : String ); EParenthesis( e : Expr ); EObjectDecl( fields : Array<{ field : String, expr : Expr }> ); EArrayDecl( values : Array ); ECall( e : Expr, params : Array ); ENew( t : TypePath, params : Array ); EUnop( op : Unop, postFix : Bool, e : Expr ); EVars( vars : Array ); EFunction( name : Null, f : Function ); EBlock( exprs : Array ); EFor( it : Expr, expr : Expr ); EIn( e1 : Expr, e2 : Expr ); EIf( econd : Expr, eif : Expr, eelse : Null ); EWhile( econd : Expr, e : Expr, normalWhile : Bool ); ESwitch( e : Expr, cases : Array, edef : Null> ); ETry( e : Expr, catches : Array ); EReturn( ?e : Null ); EBreak; EContinue; EUntyped( e : Expr ); EThrow( e : Expr ); ECast( e : Expr, t : Null ); EDisplay( e : Expr, isCall : Bool ); EDisplayNew( t : TypePath ); ETernary( econd : Expr, eif : Expr, eelse : Expr ); ECheckType( e : Expr, t : ComplexType ); EMeta( s : MetadataEntry, e : Expr ); } enum ComplexType { TPath( p : TypePath ); TFunction( args : Array, ret : ComplexType ); TAnonymous( fields : Array ); TParent( t : ComplexType ); TExtend( p : Array, fields : Array ); TOptional( t : ComplexType ); } typedef TypePath = { var pack : Array; var name : String; @:optional var params : Array; @:optional var sub : Null; } enum TypeParam { TPType( t : ComplexType ); TPExpr( e : Expr ); } typedef TypeParamDecl = { var name : String; @:optional var constraints : Array; @:optional var params : Array; } typedef Function = { var args : Array; var ret : Null; var expr : Null; @:optional var params : Array; } typedef FunctionArg = { var name : String; @:optional var opt : Bool; var type : Null; @:optional var value : Null; } typedef MetadataEntry = { name : String, ?params : Array, pos : Position } typedef Metadata = Array; typedef Field = { var name : String; @:optional var doc : Null; @:optional var access : Array; var kind : FieldType; var pos : Position; @:optional var meta : Metadata; } enum Access { APublic; APrivate; AStatic; AOverride; ADynamic; AInline; AMacro; } enum FieldType { FVar( t : Null, ?e : Null ); FFun( f : Function ); FProp( get : String, set : String, ?t : Null, ?e : Null ); } typedef TypeDefinition = { var pack : Array; var name : String; var pos : Position; @:optional var meta : Metadata; @:optional var params : Array; @:optional var isExtern : Bool; var kind : TypeDefKind; var fields : Array; } enum TypeDefKind { TDEnum; TDStructure; TDClass( ?superClass : TypePath, ?interfaces : Array, ?isInterface : Bool ); TDAlias( t : ComplexType ); // ignore TypeDefinition.fields TDAbstract( tthis : Null, ?from : Array, ?to: Array ); } /** This error can be used to handle or produce compilation errors in macros. **/ class Error { public var message : String; public var pos : Expr.Position; public function new(m,p) { this.message = m; this.pos = p; } function toString() { return message; } } enum ImportMode { INormal; IAsName(alias:String); IAll; } typedef ImportExpr = { var path: Array< { pos: Position, name: String } >; var mode: ImportMode; } haxe_3.2.1+dfsg.orig/std/haxe/macro/ExprTools.hx0000664000175000017500000002264012607337712021450 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Expr; using Lambda; /** This class provides some utility methods to work with expressions. It is best used through 'using haxe.macro.ExprTools' syntax and then provides additional methods on haxe.macro.Expr instances. While mainly intended to be used in macros, it works in non-macro code as well. **/ class ExprTools { /** Converts expression [e] to a human-readable String representation. The result is guaranteed to be valid haxe code, but there may be differences from the original lexical syntax. **/ static public function toString( e : Expr ) : String return new Printer().printExpr(e); /** Calls function [f] on each sub-expression of [e]. If [e] has no sub-expressions, this operation has no effect. Otherwise [f] is called once per sub-expression of [e], with the sub-expression as argument. These calls are done in order of the sub-expression declarations. This method does not call itself recursively. It should instead be used in a recursive function which handles the expression nodes of interest. Usage example: function findStrings(e:Expr) { switch(e.expr) { case EConst(CString(s)): // handle s case _: ExprTools.iter(e, findStrings); } } **/ static public function iter( e : Expr, f : Expr -> Void ) : Void { switch(e.expr) { case EConst(_), EContinue, EBreak, EDisplayNew(_): case EField(e, _), EParenthesis(e), EUntyped(e), EThrow(e), EDisplay(e, _), ECheckType(e, _), EUnop(_, _, e), ECast(e, _), EMeta(_, e): f(e); case EArray(e1, e2), EWhile(e1, e2, _), EBinop(_, e1, e2), EFor(e1, e2), EIn(e1, e2): f(e1); f(e2); case EVars(vl): for (v in vl) opt2(v.expr, f); case ETry(e, cl): f(e); for (c in cl) f(c.expr); case ETernary(e1, e2, e3) | EIf(e1, e2, e3): f(e1); f(e2); opt2(e3, f); case EArrayDecl(el), ENew(_, el), EBlock(el): ExprArrayTools.iter(el, f); case EObjectDecl(fl): for (fd in fl) f(fd.expr); case ECall(e, el): f(e); ExprArrayTools.iter(el, f); case EReturn(e): opt2(e, f); case EFunction(_, func): for (arg in func.args) opt2(arg.value, f); opt2(func.expr, f); case ESwitch(e, cl, edef): f(e); for (c in cl) { ExprArrayTools.iter(c.values, f); opt2(c.guard, f); opt2(c.expr, f); } if (edef != null && edef.expr != null) f(edef); } } /** Transforms the sub-expressions of [e] by calling [f] on each of them. If [e] has no sub-expressions, this operation returns [e] unchanged. Otherwise [f] is called once per sub-expression of [e], with the sub-expression as argument. These calls are done in order of the sub-expression declarations. This method does not call itself recursively. It should instead be used in a recursive function which handles the expression nodes of interest. Usage example: function capitalizeStrings(e:Expr) { return switch(e.expr) { case EConst(CString(s)): { expr: EConst(CString(s.toUpperCase())), pos: e.pos }; case _: ExprTools.map(e, capitalizeStrings); } } **/ static public function map( e : Expr, f : Expr -> Expr ) : Expr { return {pos: e.pos, expr: switch(e.expr) { case EConst(_): e.expr; case EArray(e1, e2): EArray(f(e1), f(e2)); case EBinop(op, e1, e2): EBinop(op, f(e1), f(e2)); case EField(e, field): EField(f(e), field); case EParenthesis(e): EParenthesis(f(e)); case EObjectDecl(fields): var ret = []; for (field in fields) ret.push( { field: field.field, expr: f(field.expr) } ); EObjectDecl(ret); case EArrayDecl(el): EArrayDecl(ExprArrayTools.map(el, f)); case ECall(e, params): ECall(f(e), ExprArrayTools.map(params, f)); case ENew(tp, params): ENew(tp, ExprArrayTools.map(params, f)); case EUnop(op, postFix, e): EUnop(op, postFix, f(e)); case EVars(vars): var ret = []; for (v in vars) ret.push( { name: v.name, type:v.type, expr: opt(v.expr, f) } ); EVars(ret); case EBlock(el): EBlock(ExprArrayTools.map(el, f)); case EFor(it, expr): EFor(f(it), f(expr)); case EIn(e1, e2): EIn(f(e1), f(e2)); case EIf(econd, eif, eelse): EIf(f(econd), f(eif), opt(eelse, f)); case EWhile(econd, e, normalWhile): EWhile(f(econd), f(e), normalWhile); case EReturn(e): EReturn(opt(e,f)); case EUntyped(e): EUntyped(f(e)); case EThrow(e): EThrow(f(e)); case ECast(e, t): ECast(f(e), t); case EDisplay(e, isCall): EDisplay(f(e), isCall); case ETernary(econd, eif, eelse): ETernary(f(econd), f(eif), f(eelse)); case ECheckType(e, t): ECheckType(f(e), t); case EDisplayNew(_), EContinue, EBreak: e.expr; case ETry(e, catches): var ret = []; for (c in catches) ret.push( { name:c.name, type:c.type, expr:f(c.expr) } ); ETry(f(e), ret); case ESwitch(e, cases, edef): var ret = []; for (c in cases) ret.push( { expr: opt (c.expr, f), guard: opt(c.guard, f), values: ExprArrayTools.map(c.values, f) } ); ESwitch(f(e), ret, edef == null || edef.expr == null ? edef : f(edef)); case EFunction(name, func): var ret = []; for (arg in func.args) ret.push( { name: arg.name, opt: arg.opt, type: arg.type, value: opt(arg.value, f) } ); EFunction(name, { args: ret, ret: func.ret, params: func.params, expr: f(func.expr) } ); case EMeta(m, e): EMeta(m, f(e)); }}; } /** Returns the value `e` represents. Supported expressions are: - `Int`, `Float` and `String` literals - identifiers `true`, `false` and `null` - structure declarations if all their fields are values - array declarations if all their elements are values - unary operators `-`, `!` and `~` if the operand is a value - binary operators except `=>`, `...` and assignments Parentheses, metadata and the `untyped` keyword are ignored. If any non-value is encountered, an exception of type `String` is thrown. If `e` is null, the result is unspecified. **/ static public function getValue(e:Expr):Dynamic { return switch (e.expr) { case EConst(CInt(v)): Std.parseInt(v); case EConst(CFloat(v)): Std.parseFloat(v); case EConst(CString(s)): s; case EConst(CIdent("true")): true; case EConst(CIdent("false")): false; case EConst(CIdent("null")): null; case EParenthesis(e1) | EUntyped(e1) | EMeta(_, e1): getValue(e1); case EObjectDecl(fields): var obj = {}; for (field in fields) { Reflect.setField(obj, field.field, getValue(field.expr)); } obj; case EArrayDecl(el): el.map(getValue); case EIf(econd, eif, eelse) | ETernary(econd, eif, eelse): if (eelse == null) { throw "If statements only have a value if the else clause is defined"; } else { var econd:Dynamic = getValue(econd); econd ? getValue(eif) : getValue(eelse); } case EUnop(op, false, e1): var e1:Dynamic = getValue(e1); switch (op) { case OpNot: !e1; case OpNeg: -e1; case OpNegBits: ~e1; case _: throw 'Unsupported expression: $e'; } case EBinop(op, e1, e2): var e1:Dynamic = getValue(e1); var e2:Dynamic = getValue(e2); switch (op) { case OpAdd: e1 + e2; case OpSub: e1 - e2; case OpMult: e1 * e2; case OpDiv: e1 / e2; case OpMod: e1 % e2; case OpEq: e1 == e2; case OpNotEq: e1 != e2; case OpLt: e1 < e2; case OpLte: e1 <= e2; case OpGt: e1 > e2; case OpGte: e1 >= e2; case OpOr: e1 | e2; case OpAnd: e1 & e2; case OpXor: e1 ^ e2; case OpBoolAnd: e1 && e2; case OpBoolOr: e1 || e2; case OpShl: e1 << e2; case OpShr: e1 >> e2; case OpUShr: e1 >>> e2; case _: throw 'Unsupported expression: $e'; } case _: throw 'Unsupported expression: $e'; } } static inline function opt(e:Null, f : Expr -> Expr):Expr return e == null ? null : f(e); static inline function opt2(e:Null, f : Expr -> Void):Void if (e != null) f(e); } /** This class provides functions on expression arrays for convenience. For a detailed reference on each method, see the documentation of ExprTools. */ class ExprArrayTools { static public function map( el : Array, f : Expr -> Expr):Array { var ret = []; for (e in el) ret.push(f(e)); return ret; } static public function iter( el : Array, f : Expr -> Void):Void { for (e in el) f(e); } } haxe_3.2.1+dfsg.orig/std/haxe/macro/Format.hx0000664000175000017500000000714612607337712020745 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Expr; import haxe.macro.Context; /** The actual macro implemented for Std.format **/ class Format { #if macro public static function format( estr : Expr ) { var str = switch( estr.expr ) { case EConst(c): switch(c) { case CString(s): s; default: null; } default: null; }; if( str == null ) Context.error("Constant string required", estr.pos); var pos = Context.getPosInfos(estr.pos); var min = pos.min; pos.min++; var expr = null; function make(size) { pos.max = pos.min + size; var p = Context.makePosition(pos); pos.min += size; return p; } function add(e) { if( expr == null ) expr = e; else expr = { expr : EBinop(OpAdd,expr,e), pos : Context.makePosition({ min : min, max : pos.min, file : pos.file }) }; } var i = 0, start = 0; var max = str.length; while( i < max ) { if( StringTools.fastCodeAt(str,i++) != '$'.code ) continue; var len = i - start - 1; if( len > 0 || expr == null ) add({ expr : EConst(CString(str.substr(start,len))), pos : make(len) }); pos.min++; start = i; var c = StringTools.fastCodeAt(str, i); if( c == '{'.code ) { var count = 1; i++; while( i < max ) { var c = StringTools.fastCodeAt(str,i++); if( c == "}".code ) { if( --count == 0 ) break; } else if( c == "{".code ) count++; } if( count > 0 ) Context.error("Closing brace not found",make(1)); pos.min++; start++; var len = i - start - 1; var expr = str.substr(start, len); add(Context.parseInlineString(expr, make(len))); pos.min++; start++; } else if( (c >= 'a'.code && c <= 'z'.code) || (c >= 'A'.code && c <= 'Z'.code) || c == '_'.code ) { i++; while( true ) { var c = StringTools.fastCodeAt(str, i); if( (c >= 'a'.code && c <= 'z'.code) || (c >= 'A'.code && c <= 'Z'.code) || (c >= '0'.code && c <= '9'.code) || c == '_'.code ) i++; else break; } var len = i - start; var ident = str.substr(start, len); add( { expr : EConst(CIdent(ident)), pos : make(len) } ); } else if( c == '$'.code ) { start = i++; continue; } else { start = i - 1; continue; } start = i; } var len = i - start; if( len > 0 ) add({ expr : EConst(CString(str.substr(start,len))), pos : make(len) }); if( expr == null ) expr = { expr : EConst(CString("")), pos : make(0) }; return { expr : ECheckType(expr,TPath({ pack : [], name : "String", params : [] })), pos : expr.pos }; } #end } haxe_3.2.1+dfsg.orig/std/haxe/macro/JSGenApi.hx0000664000175000017500000000462512607337712021114 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Type; /** This is the api that is passed to the custom JS generator. **/ typedef JSGenApi = { /** the file in which the JS code can be generated **/ var outputFile : String; /** all the types that were compiled by Haxe **/ var types : Array; /** the main call expression, if a -main class is defined **/ var main : Null; /** generate the JS code for any given typed expression **/ function generateStatement( e : TypedExpr ) : String; /** generate the JS code for a given typed expression-value **/ function generateValue( e : TypedExpr ) : String; /** define the JS code that gets generated when a class or enum is accessed in a typed expression **/ function setTypeAccessor( callb : Type -> String ) : Void; /** tells if the given identifier is a JS keyword **/ function isKeyword( ident : String ) : Bool; /** add a feature **/ function addFeature( f : String ) : Bool; /** check if a feature is used **/ function hasFeature( f : String ) : Bool; /** quote and escape the given string constant **/ function quoteString( s : String ) : String; /** create the metadata expression for the given type **/ function buildMetaData( t : BaseType ) : Null; /** select the current classe **/ function setCurrentClass( c : ClassType ) : Void; } haxe_3.2.1+dfsg.orig/std/haxe/macro/MacroStringTools.hx0000664000175000017500000000612612607337712022763 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Expr; /** This class provides some utility methods to work with strings in macro context. **/ class MacroStringTools { #if macro /** Formats `String` `s` using the usual interpolation rules. The returned expression is a concatenation of string parts and escaped elements. **/ static public function formatString(s:String, pos:Position) { return Context.load("format_string", 2)(untyped s.__s, pos); } /** Tells if `e` is a format string, i.e. uses single quotes `'` as delimiters. This only works if `e` has a position which the compiler can find. While this is true for any expressions appearing in real Haxe code (i.e. some .hx file), it might not work for expressions generated by macros. This operation depends on the position of `e`. **/ static public function isFormatExpr(e:ExprOf) { return Context.load("is_fmt_string", 1)(e.pos); } #end /** Converts an array of Strings `sl` to a field expression. If `sl` has no elements, the result is null. If `sl` has one element, the result is `EConst(CIdent(sl[0])`. Otherwise the result is a chain of `EField` nodes. If `sl` is null, the result is unspecified. **/ static public function toFieldExpr(sl:Array):Expr { return Lambda.fold(sl, function(s, e) return e == null ? (macro $i{s}) : (macro $e.$s), null); } /** Converts a path given by package `pack` and name `name` to a `String` separated by dots. If `pack` has no elements, the result is `name`. If `pack` is null, the result is unspecified. Otherwise the elements of `pack` are joined with a separating dot, with an appended dot separating the result from `name`. **/ static public function toDotPath(pack:Array, name:String):String { return if (pack.length == 0) name else pack.join(".") + "." +name; } static public function toComplex( path : String ) : ComplexType { var pack = path.split("."); return TPath( { pack : pack, name : pack.pop(), params : [] } ); } } haxe_3.2.1+dfsg.orig/std/haxe/macro/MacroType.hx0000664000175000017500000000244212607337712021412 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; /** This type is meant to be used to generate custom types using a macro. For instance by doing MacroType<[my.Class.myMacro(55)]> **/ extern class MacroType { }haxe_3.2.1+dfsg.orig/std/haxe/macro/PositionTools.hx0000664000175000017500000000166512607337712022342 0ustar andyandy00000000000000package haxe.macro; import haxe.macro.Expr; class PositionTools { /** Returns the `Position` where the caller of `here` is. **/ macro public static function here():ExprOf { var positionExpr = Context.makeExpr(Context.getPosInfos(Context.currentPos()), Context.currentPos()); if (Context.defined("macro")) { return macro Context.makePosition($positionExpr); } else { return positionExpr; } } /** Like `Context.getPosInfos`, except this method is available on all platforms. **/ public static function getInfos( p : Position ) : { min : Int, max : Int, file : String } { #if macro return Context.getPosInfos(p); #else return p; #end } /** Like `Context.makePosition`, except this method is available on all platforms. **/ public static function make( inf : { min : Int, max : Int, file : String } ) : Position { #if macro return Context.makePosition(inf); #else return inf; #end } } haxe_3.2.1+dfsg.orig/std/haxe/macro/Printer.hx0000664000175000017500000003057012607337712021135 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Expr; using Lambda; using StringTools; class Printer { var tabs:String; var tabString:String; public function new(?tabString = "\t") { tabs = ""; this.tabString = tabString; } public function printUnop(op:Unop) return switch(op) { case OpIncrement: "++"; case OpDecrement: "--"; case OpNot: "!"; case OpNeg: "-"; case OpNegBits: "~"; } public function printBinop(op:Binop) return switch(op) { case OpAdd: "+"; case OpMult: "*"; case OpDiv: "/"; case OpSub: "-"; case OpAssign: "="; case OpEq: "=="; case OpNotEq: "!="; case OpGt: ">"; case OpGte: ">="; case OpLt: "<"; case OpLte: "<="; case OpAnd: "&"; case OpOr: "|"; case OpXor: "^"; case OpBoolAnd: "&&"; case OpBoolOr: "||"; case OpShl: "<<"; case OpShr: ">>"; case OpUShr: ">>>"; case OpMod: "%"; case OpInterval: "..."; case OpArrow: "=>"; case OpAssignOp(op): printBinop(op) + "="; } function escapeString(s:String,delim:String) { return delim + s.replace("\n","\\n").replace("\t","\\t").replace("'","\\'").replace('"',"\\\"") #if sys .replace("\x00","\\x00") #end + delim; } public function printFormatString(s:String) { return escapeString(s,"'"); } public function printString(s:String) { return escapeString(s,'"'); } public function printConstant(c:Constant) return switch(c) { case CString(s): printString(s); case CIdent(s), CInt(s), CFloat(s): s; case CRegexp(s,opt): '~/$s/$opt'; } public function printTypeParam(param:TypeParam) return switch(param) { case TPType(ct): printComplexType(ct); case TPExpr(e): printExpr(e); } public function printTypePath(tp:TypePath) return (tp.pack.length > 0 ? tp.pack.join(".") + "." : "") + tp.name + (tp.sub != null ? '.${tp.sub}' : "") + (tp.params == null ? "" : tp.params.length > 0 ? "<" + tp.params.map(printTypeParam).join(", ") + ">" : ""); // TODO: check if this can cause loops public function printComplexType(ct:ComplexType) return switch(ct) { case TPath(tp): printTypePath(tp); case TFunction(args, ret): (args.length>0 ? args.map(printComplexType).join(" -> ") : "Void") + " -> " + printComplexType(ret); case TAnonymous(fields): "{ " + [for (f in fields) printField(f) + "; "].join("") + "}"; case TParent(ct): "(" + printComplexType(ct) + ")"; case TOptional(ct): "?" + printComplexType(ct); case TExtend(tpl, fields): '{> ${tpl.map(printTypePath).join(" >, ")}, ${fields.map(printField).join(", ")} }'; } public function printMetadata(meta:MetadataEntry) return '@${meta.name}' + ((meta.params != null && meta.params.length > 0) ? '(${printExprs(meta.params,", ")})' : ""); public function printAccess(access:Access) return switch(access) { case AStatic: "static"; case APublic: "public"; case APrivate: "private"; case AOverride: "override"; case AInline: "inline"; case ADynamic: "dynamic"; case AMacro: "macro"; } public function printField(field:Field) return (field.doc != null && field.doc != "" ? "/**\n" + tabs + tabString + StringTools.replace(field.doc, "\n", "\n" + tabs + tabString) + "\n" + tabs + "**/\n" + tabs : "") + (field.meta != null && field.meta.length > 0 ? field.meta.map(printMetadata).join('\n$tabs') + '\n$tabs' : "") + (field.access != null && field.access.length > 0 ? field.access.map(printAccess).join(" ") + " " : "") + switch(field.kind) { case FVar(t, eo): 'var ${field.name}' + opt(t, printComplexType, " : ") + opt(eo, printExpr, " = "); case FProp(get, set, t, eo): 'var ${field.name}($get, $set)' + opt(t, printComplexType, " : ") + opt(eo, printExpr, " = "); case FFun(func): 'function ${field.name}' + printFunction(func); } public function printTypeParamDecl(tpd:TypeParamDecl) return tpd.name + (tpd.params != null && tpd.params.length > 0 ? "<" + tpd.params.map(printTypeParamDecl).join(", ") + ">" : "") + (tpd.constraints != null && tpd.constraints.length > 0 ? ":(" + tpd.constraints.map(printComplexType).join(", ") + ")" : ""); public function printFunctionArg(arg:FunctionArg) return (arg.opt ? "?" : "") + arg.name + opt(arg.type, printComplexType, ":") + opt(arg.value, printExpr, " = "); public function printFunction(func:Function) return (func.params == null ? "" : func.params.length > 0 ? "<" + func.params.map(printTypeParamDecl).join(", ") + ">" : "") + "(" + func.args.map(printFunctionArg).join(", ") + ")" + opt(func.ret, printComplexType, ":") + opt(func.expr, printExpr, " "); public function printVar(v:Var) return v.name + opt(v.type, printComplexType, ":") + opt(v.expr, printExpr, " = "); public function printExpr(e:Expr) return e == null ? "#NULL" : switch(e.expr) { #if macro case EConst(CString(s)): haxe.macro.MacroStringTools.isFormatExpr(e) ? printFormatString(s) : printString(s); #end case EConst(c): printConstant(c); case EArray(e1, e2): '${printExpr(e1)}[${printExpr(e2)}]'; case EBinop(op, e1, e2): '${printExpr(e1)} ${printBinop(op)} ${printExpr(e2)}'; case EField(e1, n): '${printExpr(e1)}.$n'; case EParenthesis(e1): '(${printExpr(e1)})'; case EObjectDecl(fl): "{ " + fl.map(function(fld) return '${fld.field} : ${printExpr(fld.expr)}').join(", ") + " }"; case EArrayDecl(el): '[${printExprs(el, ", ")}]'; case ECall(e1, el): '${printExpr(e1)}(${printExprs(el,", ")})'; case ENew(tp, el): 'new ${printTypePath(tp)}(${printExprs(el,", ")})'; case EUnop(op, true, e1): printExpr(e1) + printUnop(op); case EUnop(op, false, e1): printUnop(op) + printExpr(e1); case EFunction(no, func) if (no != null): 'function $no' + printFunction(func); case EFunction(_, func): "function" +printFunction(func); case EVars(vl): "var " +vl.map(printVar).join(", "); case EBlock([]): '{ }'; case EBlock(el): var old = tabs; tabs += tabString; var s = '{\n$tabs' + printExprs(el, ';\n$tabs'); tabs = old; s + ';\n$tabs}'; case EFor(e1, e2): 'for (${printExpr(e1)}) ${printExpr(e2)}'; case EIn(e1, e2): '${printExpr(e1)} in ${printExpr(e2)}'; case EIf(econd, eif, null): 'if (${printExpr(econd)}) ${printExpr(eif)}'; case EIf(econd, eif, eelse): 'if (${printExpr(econd)}) ${printExpr(eif)} else ${printExpr(eelse)}'; case EWhile(econd, e1, true): 'while (${printExpr(econd)}) ${printExpr(e1)}'; case EWhile(econd, e1, false): 'do ${printExpr(e1)} while (${printExpr(econd)})'; case ESwitch(e1, cl, edef): var old = tabs; tabs += tabString; var s = 'switch ${printExpr(e1)} {\n$tabs' + cl.map(function(c) return 'case ${printExprs(c.values, ", ")}' + (c.guard != null ? ' if (${printExpr(c.guard)}):' : ":") + (c.expr != null ? (opt(c.expr, printExpr)) + ";" : "")) .join('\n$tabs'); if (edef != null) s += '\n${tabs}default:' + (edef.expr == null ? "" : printExpr(edef) + ";"); tabs = old; s + '\n$tabs}'; case ETry(e1, cl): 'try ${printExpr(e1)}' + cl.map(function(c) return ' catch(${c.name}:${printComplexType(c.type)}) ${printExpr(c.expr)}').join(""); case EReturn(eo): "return" + opt(eo, printExpr, " "); case EBreak: "break"; case EContinue: "continue"; case EUntyped(e1): "untyped " +printExpr(e1); case EThrow(e1): "throw " +printExpr(e1); case ECast(e1, cto) if (cto != null): 'cast(${printExpr(e1)}, ${printComplexType(cto)})'; case ECast(e1, _): "cast " +printExpr(e1); case EDisplay(e1, _): '#DISPLAY(${printExpr(e1)})'; case EDisplayNew(tp): '#DISPLAY(${printTypePath(tp)})'; case ETernary(econd, eif, eelse): '${printExpr(econd)} ? ${printExpr(eif)} : ${printExpr(eelse)}'; case ECheckType(e1, ct): '(${printExpr(e1)} : ${printComplexType(ct)})'; case EMeta(meta, e1): printMetadata(meta) + " " +printExpr(e1); } public function printExprs(el:Array, sep:String) { return el.map(printExpr).join(sep); } function printExtension(tpl:Array, fields: Array) { return '{\n$tabs>' + tpl.map(printTypePath).join(',\n$tabs>') + "," + (fields.length > 0 ? ('\n$tabs' + fields.map(printField).join(';\n$tabs') + ";\n}") : ("\n}")); } function printStructure(fields:Array) { return fields.length == 0 ? "{ }" : '{\n$tabs' + fields.map(printField).join(';\n$tabs') + ";\n}"; } public function printTypeDefinition(t:TypeDefinition, printPackage = true):String { var old = tabs; tabs = tabString; var str = t == null ? "#NULL" : (printPackage && t.pack.length > 0 && t.pack[0] != "" ? "package " + t.pack.join(".") + ";\n" : "") + (t.meta != null && t.meta.length > 0 ? t.meta.map(printMetadata).join(" ") + " " : "") + (t.isExtern ? "extern " : "") + switch (t.kind) { case TDEnum: "enum " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + " {\n" + [for (field in t.fields) tabs + (field.doc != null && field.doc != "" ? "/**\n" + tabs + tabString + StringTools.replace(field.doc, "\n", "\n" + tabs + tabString) + "\n" + tabs + "**/\n" + tabs : "") + (field.meta != null && field.meta.length > 0 ? field.meta.map(printMetadata).join(" ") + " " : "") + (switch(field.kind) { case FVar(t, _): field.name + opt(t, printComplexType, ":"); case FProp(_, _, _, _): throw "FProp is invalid for TDEnum."; case FFun(func): field.name + printFunction(func); }) + ";" ].join("\n") + "\n}"; case TDStructure: "typedef " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + " = {\n" + [for (f in t.fields) { tabs + printField(f) + ";"; }].join("\n") + "\n}"; case TDClass(superClass, interfaces, isInterface): (isInterface ? "interface " : "class ") + t.name + (t.params != null && t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + (superClass != null ? " extends " + printTypePath(superClass) : "") + (interfaces != null ? (isInterface ? [for (tp in interfaces) " extends " + printTypePath(tp)] : [for (tp in interfaces) " implements " + printTypePath(tp)]).join("") : "") + " {\n" + [for (f in t.fields) { var fstr = printField(f); tabs + fstr + switch(f.kind) { case FVar(_, _), FProp(_, _, _, _): ";"; case FFun({expr:null}): ";"; case FFun({expr:{expr:EBlock(_)}}): ""; case FFun(_): ";"; case _: ""; }; }].join("\n") + "\n}"; case TDAlias(ct): "typedef " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + " = " + (switch(ct) { case TExtend(tpl, fields): printExtension(tpl, fields); case TAnonymous(fields): printStructure(fields); case _: printComplexType(ct); }) + ";"; case TDAbstract(tthis, from, to): "abstract " + t.name + (t.params.length > 0 ? "<" + t.params.map(printTypeParamDecl).join(", ") + ">" : "") + (tthis == null ? "" : "(" + printComplexType(tthis) + ")") + (from == null ? "" : [for (f in from) " from " + printComplexType(f)].join("")) + (to == null ? "" : [for (t in to) " to " + printComplexType(t)].join("")) + " {\n" + [for (f in t.fields) { var fstr = printField(f); tabs + fstr + switch(f.kind) { case FVar(_, _), FProp(_, _, _, _): ";"; case FFun(func) if (func.expr == null): ";"; case _: ""; }; }].join("\n") + "\n}"; } tabs = old; return str; } function opt(v:T, f:T->String, prefix = "") return v == null ? "" : (prefix + f(v)); } haxe_3.2.1+dfsg.orig/std/haxe/macro/Tools.hx0000664000175000017500000000276712607337712020621 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; /** This class can be added via 'using haxe.macro.Tools' in order to enable 'using' functionality on all macro tool classes listed below. **/ typedef TExprTools = ExprTools; typedef TComplexTypeTools = ComplexTypeTools; typedef TTypeTools = TypeTools; typedef TMacroStringTools = MacroStringTools; typedef TTypedExprTools = TypedExprTools; typedef TPositionTools = PositionTools; haxe_3.2.1+dfsg.orig/std/haxe/macro/Type.hx0000664000175000017500000002153112607337712020430 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; /* Warning: Some of these types correspond to compiler-internal data structures and might change in minor Haxe releases in order to adapt to internal changes. */ typedef Ref = { public function get() : T; public function toString() : String; } enum Type { /** Represents a monomorph. @see http://haxe.org/manual/types-monomorph.html **/ TMono( t : Ref> ); /** Represents an enum instance. @see http://haxe.org/manual/types-enum-instance.html **/ TEnum( t : Ref, params : Array ); /** Represents a class instance. @see http://haxe.org/manual/types-class-instance.html **/ TInst( t : Ref, params : Array ); /** Represents a typedef. @see http://haxe.org/manual/type-system-typedef.html **/ TType( t : Ref, params : Array ); /** Represents a function type. @see http://haxe.org/manual/types-function.html **/ TFun( args : Array<{ name : String, opt : Bool, t : Type }>, ret : Type ); /** Represents an anonymous structure type. @see http://haxe.org/manual/types-anonymous-structure.html **/ TAnonymous( a : Ref ); /** Represents Dynamic. @see http://haxe.org/manual/types-dynamic.html **/ TDynamic( t : Null ); /** Used internally by the compiler to delay some typing. **/ TLazy( f : Void -> Type ); /** Represents an abstract type. @see http://haxe.org/manual/types-abstract.html **/ TAbstract( t : Ref, params : Array ); } typedef AnonType = { var fields : Array; var status : AnonStatus; } enum AnonStatus { AClosed; AOpened; AConst; AExtend( tl:Ref> ); AClassStatics( t : Ref ); AEnumStatics( t : Ref ); AAbstractStatics( t : Ref ); } typedef TypeParameter = { var name: String; var t: Type; } typedef BaseType = { var pack : Array; var name : String; var module : String; var pos : Expr.Position; var isPrivate : Bool; var isExtern : Bool; var params : Array; var meta : MetaAccess; var doc : Null; function exclude() : Void; } typedef ClassField = { var name : String; var type : Type; var isPublic : Bool; var params : Array; var meta : MetaAccess; var kind : FieldKind; function expr() : Null; var pos : Expr.Position; var doc : Null; } enum ClassKind { KNormal; KTypeParameter(constraints:Array); KExtension(cl:Ref, params:Array); KExpr(expr:Expr); KGeneric; KGenericInstance(cl:Ref, params:Array); KMacroType; KAbstractImpl(a:Ref); KGenericBuild; } typedef ClassType = {> BaseType, var kind : ClassKind; var isInterface : Bool; var superClass : Null<{ t : Ref, params : Array }>; var interfaces : Array<{ t : Ref, params : Array }>; var fields : Ref>; var statics : Ref>; //var dynamic : Null; //var arrayAccess : Null; var constructor : Null>; var init : Null; var overrides : Array>; } typedef EnumField = { var name : String; var type : Type; var pos : Expr.Position; var meta : MetaAccess; var index : Int; var doc : Null; var params : Array; } typedef EnumType = {> BaseType, var constructs : Map; var names : Array; } typedef DefType = {> BaseType, var type : Type; } typedef AbstractType = {>BaseType, var type : Type; var impl : Null>; var binops : Array<{op:Expr.Binop, field:ClassField}>; var unops : Array<{op:Expr.Unop, postFix:Bool, field:ClassField}>; var from : Array<{t:Type, field:Null}>; var to : Array<{t:Type, field:Null}>; var array : Array; } /** MetaAccess is a wrapper for the `Metadata` array. It can be used to add metadata to and remove metadata from its origin. **/ typedef MetaAccess = { /** Return the wrapped `Metadata` array. Modifying this array has no effect on the origin of `this` MetaAccess. The `add` and `remove` methods can be used for that. **/ function get() : Expr.Metadata; /** Extract metadata entries by given `name`. If there's no metadata with such name, empty array is returned. If `name` is null, compilation fails with an error. **/ function extract( name : String ) : Array; /** Adds the metadata specified by `name`, `params` and `pos` to the origin of `this` MetaAccess. Metadata names are not unique during compilation, so this method never overwrites a previous metadata. If a `Metadata` array is obtained through a call to `get`, a subsequent call to `add` has no effect on that array. If any argument is null, compilation fails with an error. **/ function add( name : String, params : Array, pos : Expr.Position ) : Void; /** Removes all `name` metadata entries from the origin of `this` MetaAccess. This method might clear several metadata entries of the same name. If a `Metadata` array is obtained through a call to `get`, a subsequent call to `remove` has no effect on that array. If `name` is null, compilation fails with an error. **/ function remove( name : String ) : Void; /** Tells if the origin of `this` MetaAccess has a `name` metadata entry. If `name` is null, compilation fails with an error. **/ function has( name : String ) : Bool; } enum FieldKind { FVar( read : VarAccess, write : VarAccess ); FMethod( k : MethodKind ); } enum VarAccess { AccNormal; AccNo; AccNever; AccResolve; AccCall; AccInline; AccRequire( r : String, ?msg : String ); } enum MethodKind { MethNormal; MethInline; MethDynamic; MethMacro; } enum TConstant { TInt(i:Int); TFloat(s:String); TString(s:String); TBool(b:Bool); TNull; TThis; TSuper; } typedef TVar = { public var id(default, never):Int; public var name(default, never):String; public var t(default, never):Type; public var capture(default, never):Bool; public var extra(default,never):Null<{params: Array, expr: Null}>; } enum ModuleType { TClassDecl(c:Ref); TEnumDecl(e:Ref); TTypeDecl(t:Ref); TAbstract(a:Ref); } typedef TFunc = { args: Array<{v:TVar, value:Null}>, t: Type, expr: TypedExpr } enum FieldAccess { FInstance(c:Ref, params:Array, cf:Ref); FStatic(c:Ref, cf:Ref); FAnon(cf:Ref); FDynamic(s:String); FClosure(c:Null<{c:Ref, params:Array}>, cf:Ref); FEnum(e:Ref, ef:EnumField); } enum TypedExprDef { TConst(c:TConstant); TLocal(v:TVar); TArray(e1:TypedExpr, e2:TypedExpr); TBinop(op:Expr.Binop, e1:TypedExpr, e2:TypedExpr); TField(e:TypedExpr, fa:FieldAccess); TTypeExpr(m:ModuleType); TParenthesis(e:TypedExpr); TObjectDecl(fields:Array<{name:String, expr:TypedExpr}>); TArrayDecl(el:Array); TCall(e:TypedExpr, el:Array); TNew(c:Ref, params: Array, el:Array); TUnop(op:Expr.Unop, postFix:Bool, e:TypedExpr); TFunction(tfunc:TFunc); TVar(v:TVar, expr:Null); TBlock(el:Array); TFor(v:TVar, e1:TypedExpr, e2:TypedExpr); TIf(econd:TypedExpr, eif:TypedExpr, eelse:Null); TWhile(econd:TypedExpr, e:TypedExpr, normalWhile:Bool); TSwitch(e:TypedExpr, cases:Array<{values:Array, expr:TypedExpr}>, edef:Null); TTry(e:TypedExpr, catches:Array<{v:TVar, expr:TypedExpr}>); TReturn(e:Null); TBreak; TContinue; TThrow(e:TypedExpr); TCast(e:TypedExpr, m:Null); TMeta(m:Expr.MetadataEntry, e1:TypedExpr); TEnumParameter(e1:TypedExpr, ef:EnumField, index:Int); } typedef TypedExpr = { expr: TypedExprDef, pos: Expr.Position, t: Type } haxe_3.2.1+dfsg.orig/std/haxe/macro/TypeTools.hx0000664000175000017500000002353012607337712021452 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Context; import haxe.macro.Expr; import haxe.macro.Type; using Lambda; /** This class provides some utility methods to work with types. It is best used through 'using haxe.macro.TypeTools' syntax and then provides additional methods on haxe.macro.Type instances. **/ class TypeTools { static function nullable(complexType : ComplexType) : ComplexType return macro : Null<$complexType>; static function toField(cf : ClassField) : Field return { function varAccessToString(va : VarAccess, getOrSet : String) : String return { switch (va) { case AccNormal: "default"; case AccNo: "null"; case AccNever: "never"; case AccResolve: throw "Invalid TAnonymous"; case AccCall: getOrSet; case AccInline: "default"; case AccRequire(_, _): "default"; } } if (cf.params.length == 0) { name: cf.name, doc: cf.doc, access: cf.isPublic ? [ APublic ] : [ APrivate ], kind: switch([ cf.kind, cf.type ]) { case [ FVar(read, write), ret ]: FProp( varAccessToString(read, "get"), varAccessToString(write, "set"), toComplexType(ret), null); case [ FMethod(_), TFun(args, ret) ]: FFun({ args: [ for (a in args) { name: a.name, opt: a.opt, type: toComplexType(a.t), } ], ret: toComplexType(ret), expr: null, }); default: throw "Invalid TAnonymous"; }, pos: cf.pos, meta: cf.meta.get(), } else { throw "Invalid TAnonymous"; } } /** Returns a syntax-level type corresponding to Type `t`. This function is mostly inverse to `ComplexTypeTools.toType`, but may lose some information on types that do not have a corresponding syntax version, such as monomorphs. In these cases, the result is null. If `t` is null, an internal exception is thrown. **/ public static function toComplexType(type : Null) : Null return { #if macro Context.toComplexType(type); #else switch (type) { case null: null; case TMono(_.get() => t): t == null ? null : toComplexType(t); case TEnum(_.get() => baseType, params): TPath(toTypePath(baseType, params)); case TInst(_.get() => classType, params): switch (classType.kind) { case KTypeParameter(_): TPath({ name: classType.name, pack: [], }); default: TPath(toTypePath(classType, params)); } case TType(_.get() => baseType, params): TPath(toTypePath(baseType, params)); case TFun(args, ret): TFunction( [ for (a in args) a.opt ? nullable(toComplexType(a.t)) : toComplexType(a.t) ], toComplexType(ret)); case TAnonymous(_.get() => { fields: fields }): TAnonymous([ for (cf in fields) toField(cf) ]); case TDynamic(t): if (t == null) { macro : Dynamic; } else { var ct = toComplexType(t); macro : Dynamic<$ct>; } case TLazy(f): toComplexType(f()); case TAbstract(_.get() => baseType, params): TPath(toTypePath(baseType, params)); default: throw "Invalid type"; } #end } static function toTypePath(baseType : BaseType, params : Array) : TypePath return { var module = baseType.module; { pack: baseType.pack, name: module.substring(module.lastIndexOf(".") + 1), sub: baseType.name, params: [ for (t in params) TPType(toComplexType(t)) ], } } #if macro /** Follows all typedefs of `t` to reach the actual type. If `once` is true, this function does not call itself recursively, otherwise it does. This can be useful in cases where intermediate typedefs might be of interest. Affected types are monomorphs `TMono` and typedefs `TType(t,pl)`. If `t` is null, an internal exception is thrown. Usage example: var t = Context.typeof(macro null); // TMono() var ts = Context.typeof(macro "foo"); //TInst(String,[]) Context.unify(t, ts); trace(t); // TMono() trace(t.follow()); //TInst(String,[]) **/ static public inline function follow( t : Type, ?once : Bool ) : Type return Context.follow(t, once); /** Returns true if `t1` and `t2` unify, false otherwise. **/ static public inline function unify( t1 : Type, t2:Type ) : Bool return Context.unify(t1, t2); /** Tries to extract the class instance stored inside `t`. If `t` is a class instance `TInst(c,pl)`, c is returned. If `t` is of a different type, an exception of type String is thrown. If `t` is null, the result is null. **/ static public function getClass( t : Type ) return t == null ? null : switch(follow(t)) { case TInst(c, _): c.get(); case _: throw "Class instance expected"; } /** Tries to extract the enum instance stored inside `t`. If `t` is an enum instance `TEnum(e,pl)`, e is returned. If `t` is of a different type, an exception of type String is thrown. If `t` is null, the result is null. **/ static public function getEnum( t : Type ) return t == null ? null : switch(follow(t)) { case TEnum(e, _): e.get(); case _: throw "Enum instance expected"; } /** Applies the type parameters `typeParameters` to type `t` with the given types `concreteTypes`. This function replaces occurences of type parameters in `t` if they are part of `typeParameters`. The array index of such a type parameter is then used to lookup the concrete type in `concreteTypes`. If `typeParameters.length` is not equal to `concreteTypes.length`, an exception of type `String` is thrown. If `typeParameters.length` is 0, `t` is returned unchanged. If either argument is `null`, the result is unspecified. **/ static public function applyTypeParameters(t:Type, typeParameters:Array, concreteTypes:Array):Type { if (typeParameters.length != concreteTypes.length) throw 'Incompatible arguments: ${typeParameters.length} type parameters and ${concreteTypes.length} concrete types'; else if (typeParameters.length == 0) return t; return Context.load("apply_params", 3)(typeParameters.map(function(tp) return {name:untyped tp.name.__s, t:tp.t}), concreteTypes, t); } /** Transforms `t` by calling `f` on each of its subtypes. If `t` is a compound type, `f` is called on each of its components. Otherwise `t` is returned unchanged. The following types are considered compound: - TInst, TEnum, TType and TAbstract with type parameters - TFun - TAnonymous If `t` or `f` are null, the result is unspecified. **/ static public function map(t:Type, f:Type -> Type):Type { return switch(t) { case TMono(tm): switch(tm.get()) { case null: t; case t: f(t); } case TEnum(_, []) | TInst(_, []) | TType(_, []): t; case TEnum(en, tl): TEnum(en, tl.map(f)); case TInst(cl, tl): TInst(cl, tl.map(f)); case TType(t2, tl): TType(t2, tl.map(f)); case TAbstract(a, tl): TAbstract(a, tl.map(f)); case TFun(args, ret): TFun(args.map(function(arg) return { name: arg.name, opt: arg.opt, t: f(arg.t) }), f(ret)); case TAnonymous(an): t; // TODO: Ref? case TDynamic(t2): t == t2 ? t : TDynamic(f(t2)); case TLazy(ft): var ft = ft(); var ft2 = f(ft); ft == ft2 ? t : ft2; } } /** Calls function `f` on each component of type `t`. If `t` is not a compound type, this operation has no effect. The following types are considered compound: - TInst, TEnum, TType and TAbstract with type parameters - TFun - TAnonymous If `t` or `f` are null, the result is unspecified. **/ static public function iter(t:Type, f:Type -> Void):Void { switch (t) { case TMono(tm): var t = tm.get(); if (t != null) f(t); case TEnum(_, tl) | TInst(_, tl) | TType(_, tl) | TAbstract(_, tl): for (t in tl) f(t); case TDynamic(t2): if (t != t2) f(t2); case TLazy(ft): f(ft()); case TAnonymous(an): for (field in an.get().fields) f(field.type); case TFun(args, ret): for (arg in args) f(arg.t); f(ret); } } /** Converts type `t` to a human-readable String representation. **/ static public function toString( t : Type ) : String return new String(Context.load("s_type", 1)(t)); #end /** Resolves the field named `name` on class `c`. If `isStatic` is true, the classes' static fields are checked. Otherwise the classes' member fields are checked. If the field is found, it is returned. Otherwise if `c` has a super class, `findField` recursively checks that super class. Otherwise null is returned. If any argument is null, the result is unspecified. **/ static public function findField(c:ClassType, name:String, isStatic:Bool = false):Null { var field = (isStatic ? c.statics : c.fields).get().find(function(field) return field.name == name); return if(field != null) field; else if (c.superClass != null) findField(c.superClass.t.get(), name, isStatic); else null; } } haxe_3.2.1+dfsg.orig/std/haxe/macro/TypedExprTools.hx0000664000175000017500000001570012607337712022455 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.macro; import haxe.macro.Type; class TypedExprTools { static function with(e:TypedExpr, ?edef:TypedExprDef, ?t:Type) { return { expr: edef == null ? e.expr : edef, pos: e.pos, t: t == null ? e.t : t } } /** Transforms the sub-expressions of [e] by calling [f] on each of them. See `haxe.macro.ExprTools.map` for details on expression mapping in general. This function works the same way, but with a different data structure. **/ static public function map(e:TypedExpr, f:TypedExpr -> TypedExpr):TypedExpr { return switch(e.expr) { case TConst(_) | TLocal(_) | TBreak | TContinue | TTypeExpr(_): e; case TArray(e1, e2): with(e, TArray(f(e1), f(e2))); case TBinop(op, e1, e2): with(e, TBinop(op, f(e1), f(e2))); case TFor(v, e1, e2): with(e, TFor(v, f(e1), f(e2))); case TWhile(e1, e2, flag): with(e, TWhile(f(e1), f(e2), flag)); case TThrow(e1): with(e, TThrow(f(e1))); case TEnumParameter(e1, ef, i): with(e, TEnumParameter(f(e1), ef, i)); case TField(e1, fa): with(e, TField(f(e1), fa)); case TParenthesis(e1): with(e, TParenthesis(f(e1))); case TUnop(op, pre, e1): with(e, TUnop(op, pre, f(e1))); case TArrayDecl(el): with(e, TArrayDecl(el.map(f))); case TNew(t, pl, el): with(e, TNew(t, pl, el.map(f))); case TBlock(el): with(e, TBlock(el.map(f))); case TObjectDecl(fl): with(e, TObjectDecl(fl.map(function(field) return { name: field.name, expr: f(field.expr) }))); case TCall(e1, el): with(e, TCall(f(e1), el.map(f))); case TVar(v,eo): with(e, TVar(v, eo == null ? null : f(eo))); case TFunction(fu): with(e, TFunction({ t: fu.t, args: fu.args, expr: f(fu.expr)})); case TIf(e1, e2, e3): with(e, TIf(f(e1), f(e2), e3 == null ? null : f(e3))); case TSwitch(e1, cases, e2): with(e, TSwitch(f(e1), cases.map(function(c) return { values: c.values.map(f), expr: f(c.expr) }), e2 == null ? null : f(e2))); case TTry(e1, catches): with(e, TTry(f(e1), catches.map(function(c) return { v:c.v, expr: f(c.expr) }))); case TReturn(e1): with(e, TReturn(e1 == null ? null : f(e1))); case TCast(e1, mt): with(e, TCast(f(e1), mt)); case TMeta(m, e1): with(e, TMeta(m, f(e1))); } } /** Calls function [f] on each sub-expression of [e]. See `haxe.macro.ExprTools.iter` for details on iterating expressions in general. This function works the same way, but with a different data structure. **/ static public function iter(e:TypedExpr, f:TypedExpr -> Void):Void { switch(e.expr) { case TConst(_) | TLocal(_) | TBreak | TContinue | TTypeExpr(_): case TArray(e1, e2) | TBinop(_, e1, e2) | TFor(_, e1, e2) | TWhile(e1, e2, _): f(e1); f(e2); case TThrow(e1) | TEnumParameter(e1, _, _) | TField(e1, _) | TParenthesis(e1) | TUnop(_, _, e1) | TCast(e1, _) | TMeta(_, e1): f(e1); case TArrayDecl(el) | TNew(_, _, el) | TBlock(el): for (e in el) f(e); case TObjectDecl(fl): for (field in fl) f(field.expr); case TCall(e1, el): f(e1); for (e in el) f(e); case TVar(_, e1) | TReturn(e1): if (e1 != null) f(e1); case TFunction(fu): f(fu.expr); case TIf(e1, e2, e3): f(e1); f(e2); if (e3 != null) f(e3); case TSwitch(e1, cases, e2): f(e1); for (c in cases) { for (v in c.values) f(v); f(c.expr); } if (e2 != null) f(e2); case TTry(e1, catches): f(e1); for (c in catches) f(c.expr); } } /** Transforms the sub-expressions of [e] by calling [f] on each of them. Additionally, types are mapped using `ft` and variables are mapped using `fv`. See `haxe.macro.ExprTools.map` for details on expression mapping in general. This function works the same way, but with a different data structure. **/ static public function mapWithType(e:TypedExpr, f:TypedExpr -> TypedExpr, ft:Type -> Type, fv:TVar -> TVar):TypedExpr { return switch(e.expr) { case TConst(_) | TBreak | TContinue | TTypeExpr(_): with(e, ft(e.t)); case TLocal(v): with(e, TLocal(fv(v)), ft(e.t)); case TArray(e1, e2): with(e, TArray(f(e1), f(e2)), ft(e.t)); case TBinop(op, e1, e2): with(e, TBinop(op, f(e1), f(e2)), ft(e.t)); case TFor(v, e1, e2): with(e, TFor(fv(v), f(e1), f(e2)), ft(e.t)); case TWhile(e1, e2, flag): with(e, TWhile(f(e1), f(e2), flag), ft(e.t)); case TThrow(e1): with(e, TThrow(f(e1)), ft(e.t)); case TEnumParameter(e1, ef, i): with(e, TEnumParameter(f(e1), ef, i), ft(e.t)); case TField(e1, fa): with(e, TField(f(e1), fa), ft(e.t)); case TParenthesis(e1): with(e, TParenthesis(e1), ft(e.t)); case TUnop(op, pre, e1): with(e, TUnop(op, pre, f(e1)), ft(e.t)); case TArrayDecl(el): with(e, TArrayDecl(el.map(f)), ft(e.t)); case TNew(t, pl, el): with(e, TNew(t, pl, el.map(f)), ft(e.t)); case TBlock(el): with(e, TBlock(el.map(f)), ft(e.t)); case TObjectDecl(fl): with(e, TObjectDecl(fl.map(function(field) return { name: field.name, expr: f(field.expr) })), ft(e.t)); case TCall(e1, el): with(e, TCall(f(e1), el.map(f)), ft(e.t)); case TVar(v,eo): with(e, TVar(fv(v), eo == null ? null : f(eo)), ft(e.t)); case TFunction(fu): with(e, TFunction({ t: ft(fu.t), args: fu.args.map(function(arg) return { v: fv(arg.v), value: arg.value }), expr: f(fu.expr)}), ft(e.t)); case TIf(e1, e2, e3): with(e, TIf(f(e1), f(e2), e3 == null ? null : f(e3)), ft(e.t)); case TSwitch(e1, cases, e2): with(e, TSwitch(f(e1), cases.map(function(c) return { values: c.values.map(f), expr: f(c.expr) }), e2 == null ? null : f(e2)), ft(e.t)); case TTry(e1, catches): with(e, TTry(f(e1), catches.map(function(c) return { v:fv(c.v), expr: f(c.expr) })), ft(e.t)); case TReturn(e1): with(e, TReturn(e1 == null ? null : f(e1)), ft(e.t)); case TCast(e1, mt): with(e, TCast(f(e1), mt), ft(e.t)); case TMeta(m, e1): with(e, TMeta(m, f(e1)), ft(e.t)); } } #if macro static public function toString(t:TypedExpr, ?pretty = false):String { return new String(haxe.macro.Context.load("s_expr", 2)(t, pretty)); } #end } haxe_3.2.1+dfsg.orig/std/haxe/remoting/AMFConnection.hx0000664000175000017500000000527112607337712022660 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class AMFConnection implements AsyncConnection implements Dynamic { var __data : { error : Dynamic -> Void, #if flash cnx : flash.net.NetConnection, #else cnx : Dynamic, #end }; var __path : Array; function new( data, path ) { __data = data; __path = path; } public function resolve( name ) : AsyncConnection { var s = new AMFConnection(__data,__path.copy()); s.__path.push(name); return s; } public function setErrorHandler(h) { __data.error = h; } public function close() { __data.cnx.close(); } public function call( params : Array, ?onResult : Dynamic -> Void ) : Void { if( onResult == null ) onResult = function(e) {}; var p = params.copy(); #if flash p.unshift(new flash.net.Responder(onResult,__data.error)); #else p.unshift({ onStatus : __data.error, onResult : onResult }); #end p.unshift(__path.join(".")); untyped __data.cnx.call.apply(__data,p); } #if flash public static function urlConnect( gatewayUrl : String ) { var c = new flash.net.NetConnection(); var cnx = new AMFConnection({ cnx : c, error : function(e) throw e },[]); c.addEventListener(flash.events.NetStatusEvent.NET_STATUS,function(e:flash.events.NetStatusEvent) { cnx.__data.error(e); }); c.connect(gatewayUrl); return cnx; } public static function connect( nc ) { return new AMFConnection({ cnx : nc, error : function(e) throw e },[]); } public static function registerClassAlias( s : String, cl : Class ) { untyped __global__[ "flash.net.registerClassAlias" ]( s, cl ); } #end } haxe_3.2.1+dfsg.orig/std/haxe/remoting/AsyncAdapter.hx0000664000175000017500000000362612607337712022615 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; /** Build an AsyncConnection from a synchronized Connection. **/ class AsyncAdapter implements AsyncConnection { var __cnx : Connection; var __error : { ref : Dynamic -> Void }; function new(cnx,error) { __cnx = cnx; __error = error; } public function resolve( name ) : AsyncConnection { return new AsyncAdapter(__cnx.resolve(name),__error); } public function setErrorHandler(h) { __error.ref = h; } public function call( params : Array, ?onResult : Dynamic -> Void ) { var ret; try { ret = __cnx.call(params); } catch( e : Dynamic ) { __error.ref(e); return; } if( onResult != null ) onResult(ret); } public static function create( cnx : Connection ) : AsyncConnection { return new AsyncAdapter(cnx,{ ref : function(e) throw e }); } } haxe_3.2.1+dfsg.orig/std/haxe/remoting/AsyncConnection.hx0000664000175000017500000000260012607337712023323 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; interface AsyncConnection implements Dynamic { function resolve( name : String ) : AsyncConnection; function call( params : Array, ?result : Dynamic -> Void ) : Void; function setErrorHandler( error : Dynamic -> Void ) : Void; } haxe_3.2.1+dfsg.orig/std/haxe/remoting/AsyncDebugConnection.hx0000664000175000017500000000547012607337712024302 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class AsyncDebugConnection implements AsyncConnection implements Dynamic { var __path : Array; var __cnx : AsyncConnection; var __data : { error : Dynamic -> Void, oncall : Array -> Array -> Void, onerror : Array -> Array -> Dynamic -> Void, onresult : Array -> Array -> Dynamic -> Void, }; function new(path,cnx,data) { __path = path; __cnx = cnx; __data = data; } public function resolve( name ) : AsyncConnection { var cnx = new AsyncDebugConnection(__path.copy(),__cnx.resolve(name),__data); cnx.__path.push(name); return cnx; } public function setErrorHandler(h) { __data.error = h; } public function setErrorDebug(h) { __data.onerror = h; } public function setResultDebug(h) { __data.onresult = h; } public function setCallDebug(h) { __data.oncall = h; } public function call( params : Array, ?onResult : Dynamic -> Void ) { var me = this; __data.oncall(__path,params); __cnx.setErrorHandler(function(e) { me.__data.onerror(me.__path,params,e); me.__data.error(e); }); __cnx.call(params,function(r) { me.__data.onresult(me.__path,params,r); if( onResult != null ) onResult(r); }); } public static function create( cnx : AsyncConnection ) { var cnx = new AsyncDebugConnection([],cnx,{ error : function(e) throw e, oncall : function(path,params) {}, onerror : null, onresult : null, }); cnx.setErrorDebug(function(path,params,e) trace(path.join(".")+"("+params.join(",")+") = ERROR "+Std.string(e))); cnx.setResultDebug(function(path,params,e) trace(path.join(".")+"("+params.join(",")+") = "+Std.string(e))); return cnx; } } haxe_3.2.1+dfsg.orig/std/haxe/remoting/AsyncProxy.hx0000664000175000017500000000261712607337712022355 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; /** This class is magic. When you extend it with a class C, it will automaticaly create a stub class with all public methods forwarding remoting messages over the connection. **/ class AsyncProxy { var __cnx : AsyncConnection; function new( c ) { __cnx = c; } }haxe_3.2.1+dfsg.orig/std/haxe/remoting/Connection.hx0000664000175000017500000000243412607337712022332 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; interface Connection implements Dynamic { function resolve( name : String ) : Connection; function call( params : Array ) : Dynamic; } haxe_3.2.1+dfsg.orig/std/haxe/remoting/Context.hx0000664000175000017500000000414212607337712021655 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class Context { var objects : haxe.ds.StringMap<{ obj : Dynamic, rec : Bool }>; public function new() { objects = new haxe.ds.StringMap(); } public function addObject( name : String, obj : {}, ?recursive ) { objects.set(name,{ obj : obj, rec : recursive }); } public function call( path : Array, params : Array ) : Dynamic { if( path.length < 2 ) throw "Invalid path '"+path.join(".")+"'"; var inf = objects.get(path[0]); if( inf == null ) throw "No such object "+path[0]; var o = inf.obj; var m = Reflect.field(o,path[1]); if( path.length > 2 ) { if( !inf.rec ) throw "Can't access "+path.join("."); for( i in 2...path.length ) { o = m; m = Reflect.field(o,path[i]); } } if( !Reflect.isFunction(m) ) throw "No such method "+path.join("."); return Reflect.callMethod(o,m,params); } public static function share( name : String, obj : {} ) : Context { var ctx = new Context(); ctx.addObject(name,obj); return ctx; } }haxe_3.2.1+dfsg.orig/std/haxe/remoting/ContextAll.hx0000664000175000017500000000376212607337712022315 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class ContextAll extends Context { public override function call( path : Array, params : Array ) : Dynamic { #if neko var o : Dynamic = null; var m : Dynamic = neko.Lib.getClasses(); for( p in path ) { o = m; m = Reflect.field(o,p); } #elseif js var path2 = path.copy(); var f = path2.pop(); var o; try { o = js.Lib.eval(path2.join(".")); } catch( e : Dynamic ) { o = null; } var m = Reflect.field(o,f); #elseif flash var path2 = path.copy(); var f = path2.pop(); var o = flash.Lib.eval(path2.join(".")); var m = Reflect.field(o,f); #elseif php var path2 = path.copy(); var f = path2.pop(); var o = Type.resolveClass(path2.join(".")); var m = Reflect.field(o,f); #else var o = null; var m = null; #end if( m == null ) return super.call(path,params); return Reflect.callMethod(o,m,params); } }haxe_3.2.1+dfsg.orig/std/haxe/remoting/DelayedConnection.hx0000664000175000017500000000504412607337712023622 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class DelayedConnection implements AsyncConnection implements Dynamic { public var connection(get,set) : AsyncConnection; var __path : Array; var __data : { cnx : AsyncConnection, error : Dynamic -> Void, cache : Array<{ path : Array, params : Array, onResult : Dynamic -> Void, onError : Dynamic -> Void }>, }; function new(data,path) { __data = data; __path = path; } public function setErrorHandler(h) { __data.error = h; } public function resolve( name ) : AsyncConnection { var d = new DelayedConnection(__data,__path.copy()); d.__path.push(name); return d; } function get_connection() { return __data.cnx; } function set_connection(cnx) { __data.cnx = cnx; process(this); return cnx; } public function call( params : Array, ?onResult ) { __data.cache.push({ path : __path, params : params, onResult : onResult, onError : __data.error }); process(this); } static function process( d : DelayedConnection ) { var cnx = d.__data.cnx; if( cnx == null ) return; while( true ) { var m = d.__data.cache.shift(); if( m == null ) break; var c = cnx; for( p in m.path ) c = c.resolve(p); c.setErrorHandler(m.onError); c.call(m.params,m.onResult); } } public static function create() { return new DelayedConnection({ cnx : null, error : function(e) throw e, cache : new Array() },[]); } } haxe_3.2.1+dfsg.orig/std/haxe/remoting/ExternalConnection.hx0000664000175000017500000001072012607337712024032 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; /** Synchronous communications between Flash and Javascript. **/ @:expose class ExternalConnection implements Connection implements Dynamic { var __data : { name : String, ctx : Context, #if js flash : String #end }; var __path : Array; function new( data, path ) { __data = data; __path = path; } public function resolve(field) : Connection { var e = new ExternalConnection(__data,__path.copy()); e.__path.push(field); return e; } public function close() { connections.remove(__data.name); } #if flash static function escapeString( s : String ) { return s.split("\\").join("\\\\"); } #else static inline function escapeString(s) { return s; } #end public function call( params : Array ) : Dynamic { var s = new haxe.Serializer(); s.serialize(params); var params = escapeString(s.toString()); var data = null; #if flash data = flash.external.ExternalInterface.call("haxe.remoting.ExternalConnection.doCall",__data.name,__path.join("."),params); #elseif js var fobj : Dynamic = (untyped js.Browser.document)[cast __data.flash]; // FIXME(bruno): Why is this necessary? if( fobj == null ) fobj = js.Browser.document.getElementById(__data.flash); if( fobj == null ) throw "Could not find flash object '"+__data.flash+"'"; try data = fobj.externalRemotingCall(__data.name,__path.join("."),params) catch( e : Dynamic ) {}; #end if( data == null ) { #if js var domain, pageDomain; try { // check that swf in on the same domain domain = fobj.src.split("/")[2]; pageDomain = js.Browser.location.host; } catch( e : Dynamic ) { domain = null; pageDomain = null; } if( domain != pageDomain ) throw "ExternalConnection call failure : SWF need allowDomain('"+pageDomain+"')"; #end throw "Call failure : ExternalConnection is not " + #if flash "compiled in JS" #else "initialized in Flash" #end; } return new haxe.Unserializer(data).unserialize(); } static var connections = new haxe.ds.StringMap(); @:keep static function doCall( name : String, path : String, params : String ) : String { try { var cnx = connections.get(name); if( cnx == null ) throw "Unknown connection : "+name; if( cnx.__data.ctx == null ) throw "No context shared for the connection "+name; var params = new haxe.Unserializer(params).unserialize(); var ret = cnx.__data.ctx.call(path.split("."),params); var s = new haxe.Serializer(); s.serialize(ret); #if flash return escapeString(s.toString()); #else return s.toString()+"#"; #end } catch( e : Dynamic ) { var s = new haxe.Serializer(); s.serializeException(e); return s.toString(); } #if as3 return ""; #end } #if flash public static function jsConnect( name : String, ?ctx : Context ) { if( !flash.external.ExternalInterface.available ) throw "External Interface not available"; try flash.external.ExternalInterface.addCallback("externalRemotingCall",doCall) catch( e : Dynamic ) {}; var cnx = new ExternalConnection({ name : name, ctx : ctx },[]); connections.set(name,cnx); return cnx; } #elseif js public static function flashConnect( name : String, flashObjectID : String, ?ctx : Context ) { var cnx = new ExternalConnection({ ctx : ctx, name : name, flash : flashObjectID },[]); connections.set(name,cnx); return cnx; } #end } haxe_3.2.1+dfsg.orig/std/haxe/remoting/FlashJsConnection.hx0000664000175000017500000001130712607337712023604 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class FlashJsConnection #if flash implements AsyncConnection implements Dynamic #end { #if flash var __path : Array; var __data : { id : String, name : String, ctx : Context, error : Dynamic -> Void, timer : haxe.Timer, queue : Array Void>, }; function new( data, path ) { __data = data; __path = path; } public function close() { connections.remove(__data.name); } public function resolve( name ) : AsyncConnection { var c = new FlashJsConnection(__data,__path.copy()); c.__path.push(name); return c; } public function setErrorHandler(h) { __data.error = h; } public function call( params : Array, ?onResult : Dynamic -> Void ) { var s = new haxe.Serializer(); s.serialize(params); var params = escapeString(s.toString()); var error = __data.error; __data.queue.push(function() { var data = flash.external.ExternalInterface.call("haxe.remoting.FlashJsConnection.flashCall",__data.id,__data.name,__path.join("."),params); var v : Dynamic; try { if( data == null ) throw "Call failure : FlashJsConnection is not compiled in JS"; v = new haxe.Unserializer(data).unserialize(); } catch( e : Dynamic ) { error(e); return; } if( onResult != null ) onResult(v); }); if( __data.timer == null ) { __data.timer = new haxe.Timer(1); __data.timer.run = function() { var q = __data.queue.shift(); if( q == null ) { __data.timer.stop(); __data.timer = null; return; } q(); }; } } static var connections = new haxe.ds.StringMap(); static function escapeString( s : String ) { #if flash return s.split("\\").join("\\\\"); #else return s.split("\\").join("\\\\").split("&").join("&"); #end } static function doCall( name : String, path : String, params : String ) : String { try { var cnx = connections.get(name); if( cnx == null ) throw "Unknown connection : "+name; if( cnx.__data.ctx == null ) throw "No context shared for the connection "+name; var params = new haxe.Unserializer(params).unserialize(); var ret = cnx.__data.ctx.call(path.split("."),params); var s = new haxe.Serializer(); s.serialize(ret); return escapeString(s.toString()); } catch( e : Dynamic ) { var s = new haxe.Serializer(); s.serializeException(e); return s.toString(); } #if as3 return ""; #end } public static function connect( name : String, objId : String, ?ctx : Context ) { if( !flash.external.ExternalInterface.available ) throw "External Interface not available"; try flash.external.ExternalInterface.addCallback("flashJsRemotingCall",doCall) catch( e : Dynamic ) {}; var cnx = new FlashJsConnection({ id : objId, name : name, ctx : ctx, error : function(e) throw e, queue : [], timer : null, },[]); connections.set(name,cnx); return cnx; } #elseif js static function flashCall( flashObj : String, name : String, path : String, params : String ) : String { try { var fobj : Dynamic = untyped (untyped js.Browser.document)[__data.flash]; // FIXME(bruno): Why is this necessary? if( fobj == null ) fobj = js.Browser.document.getElementById(flashObj); if( fobj == null ) throw "Could not find flash object '"+flashObj+"'"; var data = null; try data = fobj.flashJsRemotingCall(name,path,params) catch( e : Dynamic ) {}; if( data == null ) throw "Flash object "+flashObj+" does not have an active FlashJsConnection"; return data; } catch( e : Dynamic ) { var s = new haxe.Serializer(); s.serializeException(e); return s.toString(); } } #end } haxe_3.2.1+dfsg.orig/std/haxe/remoting/HttpAsyncConnection.hx0000664000175000017500000000475312607337712024176 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class HttpAsyncConnection implements AsyncConnection implements Dynamic { var __data : { url : String, error : Dynamic -> Void }; var __path : Array; function new(data,path) { __data = data; __path = path; } public function resolve( name ) : AsyncConnection { var c = new HttpAsyncConnection(__data,__path.copy()); c.__path.push(name); return c; } public function setErrorHandler(h) { __data.error = h; } public function call( params : Array, ?onResult : Dynamic -> Void ) { var h = new haxe.Http(__data.url); #if (neko && no_remoting_shutdown) h.noShutdown = true; #end var s = new haxe.Serializer(); s.serialize(__path); s.serialize(params); h.setHeader("X-Haxe-Remoting","1"); h.setParameter("__x",s.toString()); var error = __data.error; h.onData = function( response : String ) { var ok = true; var ret; try { if( response.substr(0,3) != "hxr" ) throw "Invalid response : '"+response+"'"; var s = new haxe.Unserializer(response.substr(3)); ret = s.unserialize(); } catch( err : Dynamic ) { ret = null; ok = false; error(err); } if( ok && onResult != null ) onResult(ret); }; h.onError = error; h.request(true); } public static function urlConnect( url : String ) { return new HttpAsyncConnection({ url : url, error : function(e) throw e },[]); } } haxe_3.2.1+dfsg.orig/std/haxe/remoting/HttpConnection.hx0000664000175000017500000000635712607337712023202 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class HttpConnection implements Connection implements Dynamic { public static var TIMEOUT = 10.; var __url : String; var __path : Array; function new(url,path) { __url = url; __path = path; } public function resolve( name ) : Connection { var c = new HttpConnection(__url,__path.copy()); c.__path.push(name); return c; } public function call( params : Array ) : Dynamic { var data = null; var h = new haxe.Http(__url); #if js h.async = false; #end #if (neko && no_remoting_shutdown) h.noShutdown = true; #end #if (neko || php || cpp) h.cnxTimeout = TIMEOUT; #end var s = new haxe.Serializer(); s.serialize(__path); s.serialize(params); h.setHeader("X-Haxe-Remoting","1"); h.setParameter("__x",s.toString()); h.onData = function(d) { data = d; }; h.onError = function(e) { throw e; }; h.request(true); if( data.substr(0,3) != "hxr" ) throw "Invalid response : '"+data+"'"; data = data.substr(3); return new haxe.Unserializer(data).unserialize(); } #if (js || neko || php) public static function urlConnect( url : String ) { return new HttpConnection(url,[]); } #end #if neko public static function handleRequest( ctx : Context ) { var v = neko.Web.getParams().get("__x"); if( neko.Web.getClientHeader("X-Haxe-Remoting") == null || v == null ) return false; neko.Lib.print(processRequest(v,ctx)); return true; } #elseif php public static function handleRequest( ctx : Context ) { var v = php.Web.getParams().get("__x"); if( php.Web.getClientHeader("X-Haxe-Remoting") == null || v == null ) return false; php.Lib.print(processRequest(v,ctx)); return true; } #end public static function processRequest( requestData : String, ctx : Context ) : String { try { var u = new haxe.Unserializer(requestData); var path = u.unserialize(); var args = u.unserialize(); var data = ctx.call(path,args); var s = new haxe.Serializer(); s.serialize(data); return "hxr" + s.toString(); } catch( e : Dynamic ) { var s = new haxe.Serializer(); s.serializeException(e); return "hxr" + s.toString(); } } } haxe_3.2.1+dfsg.orig/std/haxe/remoting/LocalConnection.hx0000664000175000017500000001010312607337712023275 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; class LocalConnection implements AsyncConnection implements Dynamic { static var ID = 0; var __path : Array; var __data : { ctx : Context, results : haxe.ds.IntMap<{ error : Dynamic -> Void, result : Dynamic -> Void }>, error : Dynamic -> Void, target : String, #if flash cnx : flash.net.LocalConnection, #else cnx : Dynamic, #end }; function new(data,path) { this.__path = path; this.__data = data; } public function resolve( name ) : AsyncConnection { var s = new LocalConnection(__data,__path.copy()); s.__path.push(name); return s; } public function setErrorHandler(h) { __data.error = h; } public function call( params : Array, ?onResult : Dynamic -> Void ) : Void { try { var id = ID++; #if flash __data.cnx.send(__data.target,"remotingCall",id,__path.join("."),haxe.Serializer.run(params)); #else if( !__data.cnx.send(__data.target,"remotingCall",id,__path.join("."),haxe.Serializer.run(params)) ) throw "Remoting call failure"; #end __data.results.set(id,{ error : __data.error, result : onResult }); } catch( e : Dynamic ) { __data.error(e); } } public function close() { __data.cnx.close(); } static function remotingCall( c : LocalConnection, id : Int, path : String, args : String ) { var r; try { if( c.__data.ctx == null ) throw "No context shared for this connection"; var ret = c.__data.ctx.call(path.split("."),haxe.Unserializer.run(args)); r = haxe.Serializer.run(ret); } catch( e : Dynamic ) { var s = new haxe.Serializer(); s.serializeException(e); r = s.toString(); } // don't forward 'send' errors on connection since it's only the receiving side c.__data.cnx.send(c.__data.target,"remotingResult",id,r); } static function remotingResult( c : LocalConnection, id : Int, result : String ) { var f = c.__data.results.get(id); if( f == null ) c.__data.error("Invalid result ID "+id); c.__data.results.remove(id); var val : Dynamic; try { val = new haxe.Unserializer(result).unserialize(); } catch( e : Dynamic ) { f.error(e); return; } if( f.result != null ) f.result(val); } #if flash public static function connect( name : String, ?ctx : Context, ?allowDomains : Array ) { var l = new flash.net.LocalConnection(); var recv = name + "_recv"; var c = new LocalConnection({ ctx : ctx, error : function(e) throw e, results : new haxe.ds.IntMap(), cnx : l, target : recv, },[]); l.client = { remotingCall : remotingCall.bind(c), remotingResult : remotingResult.bind(c), }; l.addEventListener(flash.events.StatusEvent.STATUS, function(s:flash.events.StatusEvent) { if( s.level != "status" ) c.__data.error("Failed to send data on LocalConnection"); }); try l.connect(name) catch( e : Dynamic ) { l.connect(recv); c.__data.target = name; } if( allowDomains != null ) for( d in allowDomains ) l.allowDomain(d); return c; } #end } haxe_3.2.1+dfsg.orig/std/haxe/remoting/Proxy.hx0000664000175000017500000000260512607337712021354 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; /** This class is magic. When you extend it with a class C, it will automaticaly create a stub class with all public methods forwarding remoting messages over the connection. **/ class Proxy { var __cnx : Connection; function new( c ) { __cnx = c; } }haxe_3.2.1+dfsg.orig/std/haxe/remoting/SocketConnection.hx0000664000175000017500000001203512607337712023501 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; import haxe.remoting.SocketProtocol.Socket; class SocketConnection implements AsyncConnection implements Dynamic { var __path : Array; var __data : { protocol : SocketProtocol, results : List<{ onResult : Dynamic -> Void, onError : Dynamic -> Void }>, log : Array -> Array -> Dynamic -> Void, error : Dynamic -> Void, #if js queue : Array Void>, timer : haxe.Timer, #end }; function new(data,path) { __data = data; __path = path; } public function resolve(name) : AsyncConnection { var s = new SocketConnection(__data,__path.copy()); s.__path.push(name); return s; } public function call( params : Array, ?onResult : Dynamic -> Void ) { try { __data.protocol.sendRequest(__path,params); __data.results.add({ onResult : onResult, onError : __data.error }); } catch( e : Dynamic ) { __data.error(e); } } public function setErrorHandler(h) { __data.error = h; } public function setErrorLogger(h) { __data.log = h; } public function setProtocol( p : SocketProtocol ) { __data.protocol = p; } public function getProtocol() : SocketProtocol { return __data.protocol; } public function close() { try __data.protocol.socket.close() catch( e : Dynamic ) { }; } public function processMessage( data : String ) { var request; var proto = __data.protocol; data = proto.decodeData(data); try { request = proto.isRequest(data); } catch( e : Dynamic ) { var msg = Std.string(e) + " (in "+StringTools.urlEncode(data)+")"; __data.error(msg); // protocol error return; } // request if( request ) { try proto.processRequest(data,__data.log) catch( e : Dynamic ) __data.error(e); return; } // answer var f = __data.results.pop(); if( f == null ) { __data.error("No response excepted ("+data+")"); return; } var ret; try { ret = proto.processAnswer(data); } catch( e : Dynamic ) { f.onError(e); return; } if( f.onResult != null ) f.onResult(ret); } function defaultLog(path,args,e) { // exception inside the called method var astr, estr; try astr = args.join(",") catch( e : Dynamic ) astr = "???"; try estr = Std.string(e) catch( e : Dynamic ) estr = "???"; var header = "Error in call to "+path.join(".")+"("+astr+") : "; __data.error(header + estr); } public static function create( s : Socket, ?ctx : Context ) { var data = { protocol : new SocketProtocol(s,ctx), results : new List(), error : function(e) throw e, log : null, #if js queue : [], timer : null, #end }; var sc = new SocketConnection(data,[]); data.log = sc.defaultLog; #if flash s.addEventListener(flash.events.DataEvent.DATA, function(e : flash.events.DataEvent) { var data = e.data; var msgLen = sc.__data.protocol.messageLength(data.charCodeAt(0),data.charCodeAt(1)); if( msgLen == null || data.length != msgLen - 1 ) { sc.__data.error("Invalid message header"); return; } sc.processMessage(e.data.substr(2,e.data.length-2)); }); #elseif js // we can't deliver directly the message // since it might trigger a blocking action on JS side // and in that case this will trigger a Flash bug // where a new onData is called is a parallel thread // ...with the buffer of the previous onData (!) s.onData = function( data : String ) { sc.__data.queue.push(function() { var msgLen = sc.__data.protocol.messageLength(data.charCodeAt(0),data.charCodeAt(1)); if( msgLen == null || data.length != msgLen - 1 ) { sc.__data.error("Invalid message header"); return; } sc.processMessage(data.substr(2,data.length-2)); }); if( sc.__data.timer == null ) { sc.__data.timer = new haxe.Timer(1); sc.__data.timer.run = function() { var q = sc.__data.queue.shift(); if( q == null ) { sc.__data.timer.stop(); sc.__data.timer = null; return; } q(); }; } }; #end return sc; } } haxe_3.2.1+dfsg.orig/std/haxe/remoting/SocketProtocol.hx0000664000175000017500000001236712607337712023213 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; typedef Socket = #if flash flash.net.XMLSocket #elseif js js.XMLSocket #elseif sys sys.net.Socket #else Dynamic #end /** The Haxe Remoting Socket Protocol is composed of serialized string exchanges. Each string is prefixed with a 2-chars header encoding the string size (up to 4KB) and postfixed with the \0 message delimiting char. A request string is composed of the following serialized values : - the boolean true for a request - an array of strings representing the object+method path - an array of parameters A response string is composed of the following serialized values : - the boolean false for a response - a serialized value representing the result Exceptions are serialized with [serializeException] so they will be thrown immediatly when they are unserialized. **/ class SocketProtocol { public var socket : Socket; public var context : Context; public function new( sock, ctx ) { this.socket = sock; this.context = ctx; } function decodeChar(c) : Null { // A...Z if( c >= 65 && c <= 90 ) return c - 65; // a...z if( c >= 97 && c <= 122 ) return c - 97 + 26; // 0...9 if( c >= 48 && c <= 57 ) return c - 48 + 52; // + if( c == 43 ) return 62; // / if( c == 47 ) return 63; return null; } function encodeChar(c) : Null { if( c < 0 ) return null; // A...Z if( c < 26 ) return c + 65; // a...z if( c < 52 ) return (c - 26) + 97; // 0...9 if( c < 62 ) return (c - 52) + 48; // + if( c == 62 ) return 43; // / if( c == 63 ) return 47; return null; } public function messageLength( c1 : Int, c2 : Int ) : Null { var e1 = decodeChar(c1); var e2 = decodeChar(c2); if( e1 == null || e2 == null ) return null; return (e1 << 6) | e2; } public function encodeMessageLength( len : Int ) { var c1 = encodeChar(len>>6); if( c1 == null ) throw "Message is too big"; var c2 = encodeChar(len&63); return { c1 : c1, c2 : c2 }; } public function sendRequest( path : Array, params : Array ) { var s = new haxe.Serializer(); s.serialize(true); s.serialize(path); s.serialize(params); sendMessage(s.toString()); } public function sendAnswer( answer : Dynamic, ?isException : Bool ) { var s = new haxe.Serializer(); s.serialize(false); if( isException ) s.serializeException(answer); else s.serialize(answer); sendMessage(s.toString()); } public function sendMessage( msg : String ) { var e = encodeMessageLength(msg.length + 3); #if sys var o = socket.output; o.writeByte(e.c1); o.writeByte(e.c2); o.writeString(msg); o.writeByte(0); #else socket.send(String.fromCharCode(e.c1)+String.fromCharCode(e.c2)+msg); #end } public dynamic function decodeData( data : String ) { return data; } public function isRequest( data : String ) { return switch( haxe.Unserializer.run(data) ) { case true: true; case false: false; default: throw "Invalid data"; } } public function processRequest( data : String, ?onError : Array -> Array -> Dynamic -> Void ) { var s = new haxe.Unserializer(data); var result : Dynamic; var isException = false; if( s.unserialize() != true ) throw "Not a request"; var path : Array = s.unserialize(); var args : Array = s.unserialize(); try { if( context == null ) throw "No context is shared"; result = context.call(path,args); } catch( e : Dynamic ) { result = e; isException = true; } // send back result/exception over network sendAnswer(result,isException); // send the error event if( isException && onError != null ) onError(path,args,result); } public function processAnswer( data : String ) : Dynamic { var s = new haxe.Unserializer(data); if( s.unserialize() != false ) throw "Not an answer"; return s.unserialize(); } #if sys public function readMessage() { var i = socket.input; var c1 = i.readByte(); var c2 = i.readByte(); var len = messageLength(c1,c2); if( len == null ) throw "Invalid header"; var data = i.readString(len - 3); if( i.readByte() != 0 ) throw "Invalid message"; return decodeData(data); } #end } haxe_3.2.1+dfsg.orig/std/haxe/remoting/SocketWrapper.hx0000664000175000017500000000466412607337712023033 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; import haxe.remoting.SocketProtocol.Socket; /** See [js.XMLSocket] **/ class SocketWrapper { static var ID = 0; static function create( prefix : String ) : String { var id = prefix + "WrappedSocket"+(ID++); var s = new Socket(); var ctx = new Context(); var cnx = haxe.remoting.ExternalConnection.jsConnect(id,ctx); ctx.addObject("sock",s); var o = {}; Reflect.setField(o,"close",cnx.close); ctx.addObject("api",o); #if flash var connected = false; s.addEventListener(flash.events.Event.CONNECT,function(_) { connected = true; cnx.api.onConnect.call([true]); }); s.addEventListener(flash.events.SecurityErrorEvent.SECURITY_ERROR,function(_) { if( connected ) cnx.api.onClose.call([]); else cnx.api.onConnect.call([false]); }); s.addEventListener(flash.events.Event.CLOSE,function(_) { cnx.api.onClose.call([]); }); s.addEventListener(flash.events.DataEvent.DATA,function(e:flash.events.DataEvent) { cnx.api.onData.call([e.data]); }); #end return id; } static function init() { if( !flash.external.ExternalInterface.available ) return null; var ctx = new Context(); var o = {}; Reflect.setField(o,"create",create); ctx.addObject("api",o); haxe.remoting.ExternalConnection.jsConnect("SocketWrapper", ctx); return null; } static var _ = init(); } haxe_3.2.1+dfsg.orig/std/haxe/remoting/SyncSocketConnection.hx0000664000175000017500000000506712607337712024345 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.remoting; import haxe.remoting.SocketProtocol.Socket; class SyncSocketConnection implements Connection implements Dynamic { var __path : Array; var __proto : SocketProtocol; function new(proto,path) { __proto = proto; __path = path; } public function resolve( name ) : Connection { var s = new SyncSocketConnection(__proto,__path.copy()); s.__path.push(name); return s; } public function call( params : Array ) : Dynamic { var proto = __proto; proto.sendRequest(__path,params); while( true ) { var data = proto.readMessage(); if( proto.isRequest(data) ) { if( proto.context == null ) throw "Request received"; proto.processRequest(data,onRequestError); continue; } return proto.processAnswer(data); } return null; // never reached } public function processRequest() { if( __proto.context == null ) throw "Can't process request"; var data = __proto.readMessage(); __proto.processRequest(data,onRequestError); } public function onRequestError( path : Array, args : Array, exc : Dynamic ) { } public function setProtocol( p : SocketProtocol ) { __proto = p; } public function getProtocol() : SocketProtocol { return __proto; } public function close() { try __proto.socket.close() catch( e : Dynamic ) { }; } public static function create( s : Socket, ?ctx : Context ) { return new SyncSocketConnection(new SocketProtocol(s,ctx),[]); } } haxe_3.2.1+dfsg.orig/std/haxe/rtti/CType.hx0000664000175000017500000001716712607337712020426 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.rtti; typedef Path = String typedef Platforms = List typedef FunctionArgument = { name : String, opt : Bool, t : CType, ?value:String } enum CType { CUnknown; CEnum( name : Path, params : List ); CClass( name : Path, params : List ); CTypedef( name : Path, params : List ); CFunction( args : List, ret : CType ); CAnonymous( fields : List ); CDynamic( ?t : CType ); CAbstract( name : Path, params : List ); } typedef PathParams = { var path : Path; var params : List; } typedef TypeParams = Array // no contraints enum Rights { RNormal; RNo; RCall( m : String ); RMethod; RDynamic; RInline; } typedef MetaData = Array<{ name : String, params : Array }>; typedef ClassField = { var name : String; var type : CType; var isPublic : Bool; var isOverride : Bool; var doc : Null; var get : Rights; var set : Rights; var params : TypeParams; var platforms : Platforms; var meta : MetaData; var line : Null; var overloads : Null>; var expr : Null; } typedef TypeInfos = { var path : Path; var module : Path; var file : Null; var params : TypeParams; var doc : Null; var isPrivate : Bool; var platforms : Platforms; var meta : MetaData; } typedef Classdef = {> TypeInfos, var isExtern : Bool; var isInterface : Bool; var superClass : Null; var interfaces : List; var fields : List; var statics : List; var tdynamic : Null; } typedef EnumField = { var name : String; var args : Null>; var doc : String; var platforms : Platforms; var meta : MetaData; } typedef Enumdef = {> TypeInfos, var isExtern : Bool; var constructors : List; } typedef Typedef = {> TypeInfos, var type : CType; var types : Map; // by platform } typedef Abstractdef = {> TypeInfos, var to : Array<{t:CType, field:Null}>; var from : Array<{t:CType, field:Null}>; var impl : Classdef; var athis : CType; } enum TypeTree { TPackage( name : String, full : String, subs : Array ); TClassdecl( c : Classdef ); TEnumdecl( e : Enumdef ); TTypedecl( t : Typedef ); TAbstractdecl( a : Abstractdef ); } typedef TypeRoot = Array class TypeApi { public static function typeInfos( t : TypeTree ) : TypeInfos { var inf : TypeInfos; switch( t ) { case TClassdecl(c): inf = c; case TEnumdecl(e): inf = e; case TTypedecl(t): inf = t; case TAbstractdecl(a): inf = a; case TPackage(_,_,_): throw "Unexpected Package"; } return inf; } public static function isVar( t : CType ) { return switch( t ) { case CFunction(_,_): false; default: true; } } static function leq( f : T -> T -> Bool, l1 : List, l2 : List ) { var it = l2.iterator(); for( e1 in l1 ) { if( !it.hasNext() ) return false; var e2 = it.next(); if( !f(e1,e2) ) return false; } if( it.hasNext() ) return false; return true; } public static function rightsEq( r1 : Rights, r2 : Rights ) { if( r1 == r2 ) return true; switch( r1 ) { case RCall(m1): switch( r2 ) { case RCall(m2): return m1 == m2; default: } default: } return false; } public static function typeEq( t1 : CType, t2 : CType ) { switch( t1 ) { case CUnknown: return t2 == CUnknown; case CEnum(name,params): switch( t2 ) { case CEnum(name2,params2): return name == name2 && leq(typeEq,params,params2); default: } case CClass(name,params): switch( t2 ) { case CClass(name2,params2): return name == name2 && leq(typeEq,params,params2); default: } case CAbstract(name,params): switch( t2 ) { case CAbstract(name2,params2): return name == name2 && leq(typeEq,params,params2); default: } case CTypedef(name,params): switch( t2 ) { case CTypedef(name2,params2): return name == name2 && leq(typeEq,params,params2); default: } case CFunction(args,ret): switch( t2 ) { case CFunction(args2,ret2): return leq(function(a:FunctionArgument,b:FunctionArgument) { return a.name == b.name && a.opt == b.opt && typeEq(a.t,b.t); },args,args2) && typeEq(ret,ret2); default: } case CAnonymous(fields): switch( t2 ) { case CAnonymous(fields2): return leq(function(a,b) return fieldEq(a,b),fields,fields2); default: } case CDynamic(t): switch( t2 ) { case CDynamic(t2): if( (t == null) != (t2 == null) ) return false; return t == null || typeEq(t,t2); default: } } return false; } public static function fieldEq( f1 : ClassField, f2 : ClassField ) { if( f1.name != f2.name ) return false; if( !typeEq(f1.type,f2.type) ) return false; if( f1.isPublic != f2.isPublic ) return false; if( f1.doc != f2.doc ) return false; if( !rightsEq(f1.get,f2.get) ) return false; if( !rightsEq(f1.set,f2.set) ) return false; if( (f1.params == null) != (f2.params == null) ) return false; if( f1.params != null && f1.params.join(":") != f2.params.join(":") ) return false; return true; } public static function constructorEq( c1 : EnumField, c2: EnumField ) { if( c1.name != c2.name ) return false; if( c1.doc != c2.doc ) return false; if( (c1.args == null) != (c2.args == null) ) return false; if( c1.args != null && !leq(function(a,b) { return a.name == b.name && a.opt == b.opt && typeEq(a.t,b.t); },c1.args,c2.args) ) return false; return true; } } class CTypeTools { static public function toString(t:CType):String { return switch (t) { case CUnknown: "unknown"; case CClass(name, params), CEnum(name, params), CTypedef(name, params), CAbstract(name, params): nameWithParams(name, params); case CFunction(args, ret): if (args.length == 0) { "Void -> " +toString(ret); } else { args.map(functionArgumentName).join(" -> "); } case CDynamic(d): if (d == null) { "Dynamic"; } else { "Dynamic<" + toString(d) + ">"; } case CAnonymous(fields): "{ " + fields.map(classField).join(", "); } } static function nameWithParams(name:String, params:List) { if (params.length == 0) { return name; } return name + "<" + params.map(toString).join(", ") + ">"; } static function functionArgumentName(arg:FunctionArgument) { return (arg.opt ? "?" : "") + arg.name + ":" + toString(arg.t) + (arg.value == null ? "" : " = " +arg.value); } static function classField(cf:ClassField) { return cf.name + ":" +toString(cf.type); } }haxe_3.2.1+dfsg.orig/std/haxe/rtti/Meta.hx0000664000175000017500000000477712607337712020273 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.rtti; /** An api to access classes and enums metadata at runtime. **/ class Meta { /** Returns the metadata that were declared for the given type (class or enum) **/ public static function getType( t : Dynamic ) : Dynamic> { var meta = getMeta(t); return (meta == null || meta.obj == null) ? {} : meta.obj; } private static function getMeta(t:Dynamic):Dynamic { #if (java || cs) var ret = Reflect.field(t, "__meta__"); if (ret == null && Std.is(t,Class)) { #if java var interf = java.Lib.toNativeType(t).isInterface(); #elseif cs var interf = cs.Lib.toNativeType(t).IsInterface; #end if (interf) { var name = Type.getClassName(t), cls = Type.resolveClass(name + '_HxMeta'); if (cls != null) return Reflect.field(cls, "__meta__"); } } return ret; #else return untyped t.__meta__; #end } /** Returns the metadata that were declared for the given class static fields **/ public static function getStatics( t : Dynamic ) : Dynamic>> { var meta = getMeta(t); return (meta == null || meta.statics == null) ? {} : meta.statics; } /** Returns the metadata that were declared for the given class fields or enum constructors **/ public static function getFields( t : Dynamic ) : Dynamic>> { var meta = getMeta(t); return (meta == null || meta.fields == null) ? {} : meta.fields; } } haxe_3.2.1+dfsg.orig/std/haxe/rtti/Rtti.hx0000664000175000017500000000413512607337712020313 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.rtti; import haxe.rtti.CType; /** Rtti is a helper class which supplements the `@:rtti` metadata. **/ class Rtti { /** Returns the `haxe.rtti.CType.Classdef` corresponding to class `c`. If `c` has no runtime type information, e.g. because no `@:rtti@` was added, `null` is returned. If `c` is null, the result is unspecified. **/ static public function getRtti(c:Class):Classdef { var rtti = Reflect.field(c, "__rtti"); if (rtti == null) { throw 'Class ${Type.getClassName(c)} has no RTTI information, consider adding @:rtti'; } var x = Xml.parse(rtti).firstElement(); var infos = new haxe.rtti.XmlParser().processElement(x); switch (infos) { case TClassdecl(c): return c; case t: throw 'Enum mismatch: expected TClassDecl but found $t'; } } /** Tells if `c` has runtime type information. If `c` is null, the result is unspecified. **/ static public function hasRtti(c:Class):Bool { return Lambda.has(Type.getClassFields(c), "__rtti"); } }haxe_3.2.1+dfsg.orig/std/haxe/rtti/XmlParser.hx0000664000175000017500000003616612607337712021317 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.rtti; import haxe.rtti.CType; import haxe.xml.Fast; class XmlParser { public var root : TypeRoot; var curplatform : String; public function new() { root = new Array(); } public function sort( ?l ) { if( l == null ) l = root; l.sort(function(e1,e2) { var n1 = switch e1 { case TPackage(p,_,_) : " "+p; default: TypeApi.typeInfos(e1).path; }; var n2 = switch e2 { case TPackage(p,_,_) : " "+p; default: TypeApi.typeInfos(e2).path; }; if( n1 > n2 ) return 1; return -1; }); for( x in l ) switch( x ) { case TPackage(_,_,l): sort(l); case TClassdecl(c): c.fields = sortFields(c.fields); c.statics = sortFields(c.statics); case TEnumdecl(_): case TAbstractdecl(_): case TTypedecl(_): } } function sortFields(fl) { var a = Lambda.array(fl); a.sort(function(f1 : ClassField,f2 : ClassField) { var v1 = TypeApi.isVar(f1.type); var v2 = TypeApi.isVar(f2.type); if( v1 && !v2 ) return -1; if( v2 && !v1 ) return 1; if( f1.name == "new" ) return -1; if( f2.name == "new" ) return 1; if( f1.name > f2.name ) return 1; return -1; }); return Lambda.list(a); } public function process( x : Xml, platform ) { curplatform = platform; xroot(new Fast(x)); } // merge inline and not inline function mergeRights( f1 : ClassField, f2 : ClassField ) { if( f1.get == RInline && f1.set == RNo && f2.get == RNormal && f2.set == RMethod ) { f1.get = RNormal; f1.set = RMethod; return true; } return Type.enumEq(f1.get, f2.get) && Type.enumEq(f1.set, f2.set); } function mergeDoc( f1 : ClassField, f2 : ClassField ) { if( f1.doc == null ) f1.doc = f2.doc; else if( f2.doc == null ) f2.doc = f1.doc; return true; } function mergeFields( f : ClassField, f2 : ClassField ) { return TypeApi.fieldEq(f,f2) || (f.name == f2.name && (mergeRights(f,f2) || mergeRights(f2,f)) && mergeDoc(f,f2) && TypeApi.fieldEq(f,f2)); } public dynamic function newField( c : Classdef, f : ClassField ) { } function mergeClasses( c : Classdef, c2 : Classdef ) { // todo : compare supers & interfaces if( c.isInterface != c2.isInterface ) return false; if( curplatform != null ) c.platforms.add(curplatform); if( c.isExtern != c2.isExtern ) c.isExtern = false; for( f2 in c2.fields ) { var found = null; for( f in c.fields ) if( mergeFields(f,f2) ) { found = f; break; } if( found == null ) { newField(c,f2); c.fields.add(f2); } else if( curplatform != null ) found.platforms.add(curplatform); } for( f2 in c2.statics ) { var found = null; for( f in c.statics ) if( mergeFields(f,f2) ) { found = f; break; } if( found == null ) { newField(c,f2); c.statics.add(f2); } else if( curplatform != null ) found.platforms.add(curplatform); } return true; } function mergeEnums( e : Enumdef, e2 : Enumdef ) { if( e.isExtern != e2.isExtern ) return false; if( curplatform != null ) e.platforms.add(curplatform); for( c2 in e2.constructors ) { var found = null; for( c in e.constructors ) if( TypeApi.constructorEq(c,c2) ) { found = c; break; } if( found == null ) return false; // don't allow by-platform constructor ? if( curplatform != null ) found.platforms.add(curplatform); } return true; } function mergeTypedefs( t : Typedef, t2 : Typedef ) { if( curplatform == null ) return false; t.platforms.add(curplatform); t.types.set(curplatform,t2.type); return true; } function mergeAbstracts( a : Abstractdef, a2 : Abstractdef ) { if( curplatform == null ) return false; if( a.to.length != a2.to.length || a.from.length != a2.from.length ) return false; for( i in 0...a.to.length ) if( !TypeApi.typeEq(a.to[i].t,a2.to[i].t) ) return false; for( i in 0...a.from.length ) if( !TypeApi.typeEq(a.from[i].t,a2.from[i].t) ) return false; if (a2.impl != null) mergeClasses(a.impl, a2.impl); a.platforms.add(curplatform); return true; } function merge( t : TypeTree ) { var inf = TypeApi.typeInfos(t); var pack = inf.path.split("."); var cur = root; var curpack = new Array(); pack.pop(); for( p in pack ) { var found = false; for( pk in cur ) switch( pk ) { case TPackage(pname,_,subs): if( pname == p ) { found = true; cur = subs; break; } default: } curpack.push(p); if( !found ) { var pk = new Array(); cur.push(TPackage(p,curpack.join("."),pk)); cur = pk; } } var prev = null; for( ct in cur ) { var tinf; try tinf = TypeApi.typeInfos(ct) catch( e : Dynamic ) continue; // compare params ? if( tinf.path == inf.path ) { var sameType = true; if( (tinf.doc == null) != (inf.doc == null) ) { if( inf.doc == null ) inf.doc = tinf.doc; else tinf.doc = inf.doc; } if (tinf.path == "haxe._Int64.NativeInt64") continue; if( tinf.module == inf.module && tinf.doc == inf.doc && tinf.isPrivate == inf.isPrivate ) switch( ct ) { case TClassdecl(c): switch( t ) { case TClassdecl(c2): if( mergeClasses(c,c2) ) return; default: sameType = false; } case TEnumdecl(e): switch( t ) { case TEnumdecl(e2): if( mergeEnums(e,e2) ) return; default: sameType = false; } case TTypedecl(td): switch( t ) { case TTypedecl(td2): if( mergeTypedefs(td,td2) ) return; default: } case TAbstractdecl(a): switch( t ) { case TAbstractdecl(a2): if( mergeAbstracts(a,a2) ) return; default: sameType = false; } case TPackage(_,_,_): sameType = false; } // we already have a mapping, but which is incompatible var msg = if( tinf.module != inf.module ) "module "+inf.module+" should be "+tinf.module; else if( tinf.doc != inf.doc ) "documentation is different"; else if( tinf.isPrivate != inf.isPrivate ) "private flag is different"; else if( !sameType ) "type kind is different"; else "could not merge definition"; throw "Incompatibilities between "+tinf.path+" in "+tinf.platforms.join(",")+" and "+curplatform+" ("+msg+")"; } } cur.push(t); } function mkPath( p : String ) : Path { return p; } function mkTypeParams( p : String ) : TypeParams { var pl = p.split(":"); if( pl[0] == "" ) return new Array(); return pl; } function mkRights( r : String ) : Rights { return switch( r ) { case "null": RNo; case "method": RMethod; case "dynamic": RDynamic; case "inline": RInline; default: RCall(r); } } function xerror( c : Fast ) : Dynamic { return throw "Invalid "+c.name; } function xroot( x : Fast ) { for( c in x.x.elements() ) merge(processElement(c)); } public function processElement( x : Xml ) { var c = new haxe.xml.Fast(x); return switch( c.name ) { case "class": TClassdecl(xclass(c)); case "enum": TEnumdecl(xenum(c)); case "typedef": TTypedecl(xtypedef(c)); case "abstract": TAbstractdecl(xabstract(c)); default: xerror(c); } } function xmeta( x : Fast ) : MetaData { var ml = []; for( m in x.nodes.m ) { var pl = []; for( p in m.nodes.e ) pl.push(p.innerHTML); ml.push({ name : m.att.n, params : pl }); } return ml; } function xoverloads( x : Fast ) : List { var l = new List(); for ( m in x.elements ) { l.add(xclassfield(m)); } return l; } function xpath( x : Fast ) : PathParams { var path = mkPath(x.att.path); var params = new List(); for( c in x.elements ) params.add(xtype(c)); return { path : path, params : params, }; } function xclass( x : Fast ) : Classdef { var csuper = null; var doc = null; var tdynamic = null; var interfaces = new List(); var fields = new List(); var statics = new List(); var meta = []; for( c in x.elements ) switch( c.name ) { case "haxe_doc": doc = c.innerData; case "extends": csuper = xpath(c); case "implements": interfaces.add(xpath(c)); case "haxe_dynamic": tdynamic = xtype(new Fast(c.x.firstElement())); case "meta": meta = xmeta(c); default: if( c.x.exists("static") ) statics.add(xclassfield(c)); else fields.add(xclassfield(c)); } return { file : if(x.has.file) x.att.file else null, path : mkPath(x.att.path), module : if( x.has.module ) mkPath(x.att.module) else null, doc : doc, isPrivate : x.x.exists("private"), isExtern : x.x.exists("extern"), isInterface : x.x.exists("interface"), params : mkTypeParams(x.att.params), superClass : csuper, interfaces : interfaces, fields : fields, statics : statics, tdynamic : tdynamic, platforms : defplat(), meta : meta, }; } function xclassfield( x : Fast, ?defPublic = false ) : ClassField { var e = x.elements; var t = xtype(e.next()); var doc = null; var meta = []; var overloads = null; for( c in e ) switch( c.name ) { case "haxe_doc": doc = c.innerData; case "meta": meta = xmeta(c); case "overloads": overloads = xoverloads(c); default: xerror(c); } return { name : x.name, type : t, isPublic : x.x.exists("public") || defPublic, isOverride : x.x.exists("override"), line : if( x.has.line ) Std.parseInt(x.att.line) else null, doc : doc, get : if( x.has.get ) mkRights(x.att.get) else RNormal, set : if( x.has.set ) mkRights(x.att.set) else RNormal, params : if( x.has.params ) mkTypeParams(x.att.params) else [], platforms : defplat(), meta : meta, overloads: overloads, expr : if( x.has.expr ) x.att.expr else null }; } function xenum( x : Fast ) : Enumdef { var cl = new List(); var doc = null; var meta = []; for( c in x.elements ) if( c.name == "haxe_doc" ) doc = c.innerData; else if ( c.name == "meta" ) meta = xmeta(c); else cl.add(xenumfield(c)); return { file : if(x.has.file) x.att.file else null, path : mkPath(x.att.path), module : if( x.has.module ) mkPath(x.att.module) else null, doc : doc, isPrivate : x.x.exists("private"), isExtern : x.x.exists("extern"), params : mkTypeParams(x.att.params), constructors : cl, platforms : defplat(), meta : meta, }; } function xenumfield( x : Fast ) : EnumField { var args = null; var xdoc = x.x.elementsNamed("haxe_doc").next(); var meta = if( x.hasNode.meta ) xmeta(x.node.meta) else []; if( x.has.a ) { var names = x.att.a.split(":"); var elts = x.elements; args = new List(); for( c in names ) { var opt = false; if( c.charAt(0) == "?" ) { opt = true; c = c.substr(1); } args.add({ name : c, opt : opt, t : xtype(elts.next()), }); } } return { name : x.name, args : args, doc : if( xdoc == null ) null else new Fast(xdoc).innerData, meta : meta, platforms : defplat(), }; } function xabstract( x : Fast ) : Abstractdef { var doc = null, impl = null, athis = null; var meta = [], to = [], from = []; for( c in x.elements ) switch( c.name ) { case "haxe_doc": doc = c.innerData; case "meta": meta = xmeta(c); case "to": for( t in c.elements ) to.push({t: xtype(new Fast(t.x.firstElement())), field: t.has.field ? t.att.field : null}); case "from": for( t in c.elements ) from.push({t: xtype(new Fast(t.x.firstElement())), field: t.has.field ? t.att.field : null}); case "impl": impl = xclass(c.node.resolve("class")); case "this": athis = xtype(new Fast(c.x.firstElement())); default: xerror(c); } return { file : if(x.has.file) x.att.file else null, path : mkPath(x.att.path), module : if( x.has.module ) mkPath(x.att.module) else null, doc : doc, isPrivate : x.x.exists("private"), params : mkTypeParams(x.att.params), platforms : defplat(), meta : meta, athis : athis, to : to, from : from, impl: impl }; } function xtypedef( x : Fast ) : Typedef { var doc = null; var t = null; var meta = []; for( c in x.elements ) if( c.name == "haxe_doc" ) doc = c.innerData; else if ( c.name == "meta" ) meta = xmeta(c); else t = xtype(c); var types = new haxe.ds.StringMap(); if( curplatform != null ) types.set(curplatform,t); return { file : if(x.has.file) x.att.file else null, path : mkPath(x.att.path), module : if( x.has.module ) mkPath(x.att.module) else null, doc : doc, isPrivate : x.x.exists("private"), params : mkTypeParams(x.att.params), type : t, types : types, platforms : defplat(), meta : meta, }; } function xtype( x : Fast ) : CType { return switch( x.name ) { case "unknown": CUnknown; case "e": CEnum(mkPath(x.att.path),xtypeparams(x)); case "c": CClass(mkPath(x.att.path),xtypeparams(x)); case "t": CTypedef(mkPath(x.att.path),xtypeparams(x)); case "x": CAbstract(mkPath(x.att.path),xtypeparams(x)); case "f": var args = new List(); var aname = x.att.a.split(":"); var eargs = aname.iterator(); var evalues = x.has.v ? x.att.v.split(":").iterator() : null; for( e in x.elements ) { var opt = false; var a = eargs.next(); if( a == null ) a = ""; if( a.charAt(0) == "?" ) { opt = true; a = a.substr(1); } var v = evalues == null ? null : evalues.next(); args.add({ name : a, opt : opt, t : xtype(e), value : v == "" ? null : v }); } var ret = args.last(); args.remove(ret); CFunction(args,ret.t); case "a": var fields = new List(); for( f in x.elements ) { var f = xclassfield(f,true); f.platforms = new List(); // platforms selection are on the type itself, not on fields fields.add(f); } CAnonymous(fields); case "d": var t = null; var tx = x.x.firstElement(); if( tx != null ) t = xtype(new Fast(tx)); CDynamic(t); default: xerror(x); } } function xtypeparams( x : Fast ) : List { var p = new List(); for( c in x.elements ) p.add(xtype(c)); return p; } function defplat() { var l = new List(); if( curplatform != null ) l.add(curplatform); return l; } } haxe_3.2.1+dfsg.orig/std/haxe/unit/TestCase.hx0000664000175000017500000000426412607337712021104 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.unit; import haxe.PosInfos; @:keepSub @:publicFields class TestCase { public var currentTest : TestStatus; public function new( ) { } public function setup() : Void { } public function tearDown() : Void { } function print( v : Dynamic ) { haxe.unit.TestRunner.print(v); } function assertTrue( b:Bool, ?c : PosInfos ) : Void { currentTest.done = true; if (b != true){ currentTest.success = false; currentTest.error = "expected true but was false"; currentTest.posInfos = c; throw currentTest; } } function assertFalse( b:Bool, ?c : PosInfos ) : Void { currentTest.done = true; if (b == true){ currentTest.success = false; currentTest.error = "expected false but was true"; currentTest.posInfos = c; throw currentTest; } } function assertEquals( expected: T , actual: T, ?c : PosInfos ) : Void { currentTest.done = true; if (actual != expected){ currentTest.success = false; currentTest.error = "expected '" + expected + "' but was '" + actual + "'"; currentTest.posInfos = c; throw currentTest; } } } haxe_3.2.1+dfsg.orig/std/haxe/unit/TestResult.hx0000664000175000017500000000464712607337712021514 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.unit; class TestResult { var m_tests : List; public var success(default,null) : Bool; public function new() { m_tests = new List(); success = true; } public function add( t:TestStatus ) : Void { m_tests.add(t); if( !t.success ) success = false; } public function toString() : String { var buf = new StringBuf(); var failures = 0; for ( test in m_tests ){ if (test.success == false){ buf.add("* "); buf.add(test.classname); buf.add("::"); buf.add(test.method); buf.add("()"); buf.add("\n"); buf.add("ERR: "); if( test.posInfos != null ){ buf.add(test.posInfos.fileName); buf.add(":"); buf.add(test.posInfos.lineNumber); buf.add("("); buf.add(test.posInfos.className); buf.add("."); buf.add(test.posInfos.methodName); buf.add(") - "); } buf.add(test.error); buf.add("\n"); if (test.backtrace != null) { buf.add(test.backtrace); buf.add("\n"); } buf.add("\n"); failures++; } } buf.add("\n"); if (failures == 0) buf.add("OK "); else buf.add("FAILED "); buf.add(m_tests.length); buf.add(" tests, "); buf.add(failures); buf.add(" failed, "); buf.add( (m_tests.length - failures) ); buf.add(" success"); buf.add("\n"); return buf.toString(); } } haxe_3.2.1+dfsg.orig/std/haxe/unit/TestRunner.hx0000664000175000017500000001063712607337712021503 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.unit; import Reflect; class TestRunner { public var result(default, null) : TestResult; var cases : List; #if flash static var tf : flash.text.TextField = null; #end public static dynamic function print( v : Dynamic ) untyped { #if flash if( tf == null ) { tf = new flash.text.TextField(); tf.selectable = false; tf.width = flash.Lib.current.stage.stageWidth; tf.autoSize = flash.text.TextFieldAutoSize.LEFT; flash.Lib.current.addChild(tf); } tf.appendText(v); #elseif neko __dollar__print(v); #elseif php php.Lib.print(v); #elseif cpp cpp.Lib.print(v); #elseif js var msg = js.Boot.__string_rec(v,""); var d; if( __js__("typeof")(document) != "undefined" && (d = document.getElementById("haxe:trace")) != null ) { msg = StringTools.htmlEscape(msg).split("\n").join("
"); d.innerHTML += msg+"
"; } else if ( __js__("typeof process") != "undefined" && __js__("process").stdout != null && __js__("process").stdout.write != null) __js__("process").stdout.write(msg); // node else if ( __js__("typeof console") != "undefined" && __js__("console").log != null ) __js__("console").log(msg); // document-less js (which may include a line break) #elseif cs cs.system.Console.Write(v); #elseif java var str:String = v; untyped __java__("java.lang.System.out.print(str)"); #elseif python python.Lib.print(v); #end } private static function customTrace( v, ?p : haxe.PosInfos ) { print(p.fileName+":"+p.lineNumber+": "+Std.string(v)+"\n"); } public function new() { result = new TestResult(); cases = new List(); } public function add( c:TestCase ) : Void{ cases.add(c); } public function run() : Bool { result = new TestResult(); for ( c in cases ){ runCase(c); } print(result.toString()); return result.success; } function runCase( t:TestCase ) : Void { var old = haxe.Log.trace; haxe.Log.trace = customTrace; var cl = Type.getClass(t); var fields = Type.getInstanceFields(cl); print( "Class: "+Type.getClassName(cl)+" "); for ( f in fields ){ var fname = f; var field = Reflect.field(t, f); if ( StringTools.startsWith(fname,"test") && Reflect.isFunction(field) ){ t.currentTest = new TestStatus(); t.currentTest.classname = Type.getClassName(cl); t.currentTest.method = fname; t.setup(); try { Reflect.callMethod(t, field, new Array()); if( t.currentTest.done ){ t.currentTest.success = true; print("."); }else{ t.currentTest.success = false; t.currentTest.error = "(warning) no assert"; print("W"); } }catch ( e : TestStatus ){ print("F"); t.currentTest.backtrace = haxe.CallStack.toString(haxe.CallStack.exceptionStack()); }catch ( e : Dynamic ){ print("E"); #if js if( e.message != null ){ t.currentTest.error = "exception thrown : "+e+" ["+e.message+"]"; }else{ t.currentTest.error = "exception thrown : "+e; } #else t.currentTest.error = "exception thrown : "+e; #end t.currentTest.backtrace = haxe.CallStack.toString(haxe.CallStack.exceptionStack()); } result.add(t.currentTest); t.tearDown(); } } print("\n"); haxe.Log.trace = old; } } haxe_3.2.1+dfsg.orig/std/haxe/unit/TestStatus.hx0000664000175000017500000000271412607337712021512 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.unit; import haxe.CallStack; import haxe.PosInfos; class TestStatus { public var done : Bool; public var success : Bool; public var error : String; public var method : String; public var classname : String; public var posInfos : PosInfos; public var backtrace : String; public function new() { done = false; success = false; } } haxe_3.2.1+dfsg.orig/std/haxe/web/Dispatch.hx0000664000175000017500000003265112607337712020727 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.web; #if macro import haxe.macro.Expr; import haxe.macro.Type.ClassField; import haxe.macro.Context; #end typedef DispatchConfig = { var obj : Dynamic; var rules : Dynamic; } typedef Lock = T; enum MatchRule { MRInt; MRBool; MRFloat; MRString; MRDate; MREnum( e : String ); MRDispatch; MRSpod( c : String, lock : Bool ); MROpt( r : MatchRule ); } enum DispatchRule { DRMatch( r : MatchRule ); DRMult( r : Array ); DRArgs( r : DispatchRule, args : Array<{ name : String, rule : MatchRule, opt : Bool }>, opt : Bool ); DRMeta( r : DispatchRule ); } enum DispatchError { DENotFound( part : String ); DEInvalidValue; DEMissing; DEMissingParam( p : String ); DETooManyValues; } class Redirect { public function new() { } } class Dispatch { public var parts : Array; public var params : Map; public var name : String; public var cfg : DispatchConfig; var subDispatch : Bool; public function new(url:String, params) { parts = url.split("/"); if( parts[0] == "" ) parts.shift(); this.params = params; } public macro function dispatch( ethis : Expr, obj : ExprOf<{}> ) : ExprOf { var p = Context.currentPos(); var cfg = makeConfig(obj); return { expr : ECall({ expr : EField(ethis, "runtimeDispatch"), pos : p }, [cfg]), pos : p }; } public macro function getParams( ethis : Expr ) : Expr { var p = Context.currentPos(); if( PARAMS == null ) { PARAMS = new Array(); Context.onGenerate(buildParams); } var index = PARAMS.length; var t = Context.typeof({ expr : EConst(CIdent("null")), pos : p }); PARAMS.push( { p : p, t : t } ); var call = { expr : ECall( { expr : EField(ethis, "runtimeGetParams"), pos : p }, [ { expr : EConst(CInt(Std.string(index))), pos : p } ]), pos : p }; var rt = TPath( { pack : ["haxe", "macro"], name : "MacroType", params : [TPExpr(Context.parse("haxe.web.Dispatch.getRunParam("+index+")",p))], sub : null } ); return { expr : EBlock([ { expr : EVars([ { name : "tmp", type : rt, expr : call } ]), pos : p }, { expr : EConst(CIdent("tmp")), pos : p } ]), pos : p }; } public dynamic function onMeta( v : String, args : Null> ) { } function resolveName( name : String ) { return name; } public function runtimeDispatch( cfg : DispatchConfig ) { name = parts.shift(); if( name == null ) name = "default"; name = resolveName(name); this.cfg = cfg; var r : DispatchRule = Reflect.field(cfg.rules, name); if( r == null ) { r = Reflect.field(cfg.rules, "default"); if( r == null ) throw DENotFound(name); parts.unshift(name); name = "default"; } name = "do" + name.charAt(0).toUpperCase() + name.substr(1); var args = []; subDispatch = false; loop(args, r); if( parts.length > 0 && !subDispatch ) { if( parts.length == 1 && parts[parts.length - 1] == "" ) parts.pop() else throw DETooManyValues; } try { Reflect.callMethod(cfg.obj, Reflect.field(cfg.obj, name), args); } catch( e : Redirect ) { runtimeDispatch(cfg); } } public function redirect( url : String, ?params : Map ) { parts = url.split("/"); if( parts[0] == "" ) parts.shift(); if( params != null ) this.params = params; throw new Redirect(); } static var GET_RULES; public function runtimeGetParams( cfgIndex : Int ) : Dynamic { if( GET_RULES == null ) GET_RULES = haxe.Unserializer.run(haxe.rtti.Meta.getType(Dispatch).getParams[0]); return checkParams(GET_RULES[cfgIndex], true); } function match( v : String, r : MatchRule, opt : Bool ) : Dynamic { switch( r ) { case MRInt: if( v == null ) throw DEMissing; if( opt && v == "" ) return null; var v = Std.parseInt(v); if( v == null ) throw DEInvalidValue; return v; case MRFloat: if( v == null ) throw DEMissing; if( opt && v == "" ) return null; var v = Std.parseFloat(v); if( Math.isNaN(v) ) throw DEInvalidValue; return v; case MRString: if( v == null ) throw DEMissing; return v; case MRBool: return v != null && v != "0" && v != "false" && v != "null"; case MRDate: if( v == null ) throw DEMissing; try{ return Date.fromString(v); } catch (e:Dynamic) { throw DEInvalidValue; } case MREnum(e): if( v == null ) throw DEMissing; if( opt && v == "" ) return null; if( v == "" ) throw DEMissing; var en : Dynamic = Type.resolveEnum(e); if( en == null ) throw "assert"; var ev:Dynamic; if (v.charCodeAt(0) >= '0'.code && v.charCodeAt(0) <= '9'.code) { ev = Type.createEnumIndex(en, Std.parseInt(v)); } else { ev = Type.createEnum(en, v); } return ev; case MRDispatch: if( v != null ) parts.unshift(v); subDispatch = true; return this; case MRSpod(c, lock): if( v == null ) throw DEMissing; var v = Std.parseInt(v); if( v == null ) throw DEInvalidValue; var cl : Dynamic = Type.resolveClass(c); if( cl == null ) throw "assert"; var o : Dynamic; #if !old_spod o = cl.manager.unsafeGet(v, lock); #else o = cl.manager.get(v, lock); #end if( o == null ) throw DEInvalidValue; return o; case MROpt(r) : if( v == null ) return null; return match(v, r, true); } } function checkParams( params : Array<{ name : String, opt : Bool, rule : MatchRule }>, opt ) { var po = { }; for( p in params ) { var v = this.params.get(p.name); if( v == null ) { if( p.opt ) continue; if( opt ) return null; throw DEMissingParam(p.name); } Reflect.setField(po, p.name, match(v, p.rule,p.opt)); } return po; } function loop( args : Array, r ) { switch( r ) { case DRArgs(r, params, opt): loop(args, r); args.push( checkParams(params, opt) ); case DRMatch(r): args.push(match(parts.shift(), r, false)); case DRMult(rl): for( r in rl ) args.push(match(parts.shift(), r, false)); case DRMeta(r): loop(args, r); var c = Type.getClass(cfg.obj); var m; do { if( c == null ) throw "assert"; m = Reflect.field(haxe.rtti.Meta.getFields(c), name); c = Type.getSuperClass(c); } while( m == null ); for( mv in Reflect.fields(m) ) onMeta(mv, Reflect.field(m, mv)); } } #if macro static inline var PREFIX = "haxe.web.Dispatch.DispatchRule."; static function getType(t,p) { switch( Context.follow(t) ) { case TInst(i,_): switch( i.toString() ) { case "Int": return MRInt; case "Float": return MRFloat; case "String": return MRString; case "Date": return MRDate; case "haxe.web.Dispatch": return MRDispatch; default: var c = i.get(); var csup = c.superClass; while( csup != null ) { var name = csup.t.toString(); if( name == "neko.db.Object" || name == "sys.db.Object" ) { var lock = switch( t ) { case TType(t, _): t.get().name == "Lock"; default: false; } return MRSpod(i.toString(), lock); } else if ( name == "haxe.web.Dispatch" ) { return MRDispatch; } csup = csup.t.get().superClass; } Context.error("Unsupported dispatch type '"+i.toString()+"'",p); } case TEnum(e, _): switch( e.toString() ) { case "Bool": return MRBool; default: return MREnum(e.toString()); } case TAbstract(a,_): switch( a.toString() ) { case "Int": return MRInt; case "Float": return MRFloat; case "Bool": return MRBool; default: Context.error("Unsupported dispatch type "+a.toString(),p); } default: Context.error("Unsupported dispatch type "+Std.string(t),p); } return null; } static function makeArgs( t : haxe.macro.Type, p ) { var args = []; switch( Context.follow(t) ) { case TAnonymous(a): for( f in a.get().fields ) { var r = getType(f.type, f.pos); var opt = f.meta.has(":optional"); switch( f.type ) { case TType(t, _): if( t.get().name == "Null" ) opt = true; default: } if( r == MRBool ) opt = true; args.push( { name : f.name, rule : r, opt : opt } ); } default: Context.error("Arguments should be an anonymous object", p); } return args; } static function makeRule( f : ClassField ) : DispatchRule { switch( Context.follow(f.type) ) { case TFun(pl, _): var params = []; var rules = []; var args = null, argsOpt = false; for( p in pl ) { if( p.name == "args" ) { if( args != null ) Context.error("Duplicate arguments", f.pos); argsOpt = p.opt; args = makeArgs(p.t,f.pos); continue; } if( args != null ) Context.error("Arguments should be last parameter", f.pos); var r = getType(p.t, f.pos); if( p.opt ) r = MROpt(r); rules.push(r); } var rule = if( rules.length == 1 ) DRMatch(rules[0]); else DRMult(rules); if( args != null ) rule = DRArgs(rule, args, argsOpt); return rule; default: Context.error("Configuration entry should be a function", f.pos); } return null; } static function makeConfig( obj : Expr ) { var p = obj.pos; if( Context.defined("display") ) return { expr : EObjectDecl([ { field : "obj", expr : obj }, { field : "rules", expr : { expr : EObjectDecl([]), pos : p } } ]), pos : p }; var t = Context.typeof(obj); switch( Context.follow(t) ) { case TAnonymous(fl): var fields = []; for( f in fl.get().fields ) { if( f.name.substr(0, 2) != "do" ) continue; if (!f.meta.has(':keep')) f.meta.add(':keep', [], f.pos); var r = makeRule(f); fields.push( { field : f.name.charAt(2).toLowerCase() + f.name.substr(3), expr : Context.makeExpr(r,p) } ); } if( fields.length == 0 ) Context.error("No dispatch method found", p); var rules = { expr : EObjectDecl(fields), pos : p }; return { expr : EObjectDecl([ { field : "obj", expr : obj }, { field : "rules", expr : rules } ]), pos : p }; case TInst(i, _): var i = i.get(); // store the config inside the class metadata (only once) if( !i.meta.has("dispatchConfig") ) { var fields = {}; var tmp = i; while( true ) { for( f in tmp.fields.get() ) { if( f.name.substr(0, 2) != "do" ) continue; if (!f.meta.has(':keep')) f.meta.add(':keep', [], f.pos); var r = makeRule(f); for( m in f.meta.get() ) if( m.name.charAt(0) != ":" ) { checkMeta(f); r = DRMeta(r); break; } Reflect.setField(fields, f.name.charAt(2).toLowerCase() + f.name.substr(3), r); } if( tmp.superClass == null ) break; tmp = tmp.superClass.t.get(); } if( Reflect.fields(fields).length == 0 ) Context.error("No dispatch method found", p); var str = serialize(fields); i.meta.add("dispatchConfig", [ { expr : EConst(CString(str)), pos : p } ], p); } return { expr : EUntyped ({ expr : ECall({ expr : EField(Context.makeExpr(Dispatch,p),"extractConfig"), pos : p },[obj]), pos : p }), pos : p }; default: Context.error("Configuration should be an anonymous object",p); } return null; } static var PARAMS:Array = null; static function buildParams(_) { var rules = []; for( p in PARAMS ) rules.push(makeArgs(p.t, p.p)); var str = serialize(rules); switch( Context.getType("haxe.web.Dispatch") ) { case TInst(c, _): var c = c.get(); c.meta.remove("getParams"); c.meta.add("getParams",[{ expr : EConst(CString(str)), pos : c.pos }],c.pos); default: } } static function serialize( v : Dynamic ) { var s = new haxe.Serializer(); s.useEnumIndex = true; s.serialize(v); return s.toString(); } public static function getRunParam(i:Int) { return PARAMS[i].t; } public dynamic static function checkMeta( f : ClassField ) { } #end public static macro function make( obj : ExprOf<{}> ) : ExprOf { return makeConfig(obj); } public static macro function run( url : ExprOf, params : ExprOf>, obj : ExprOf<{}> ) : ExprOf { var p = Context.currentPos(); var cfg = makeConfig(obj); return { expr : ECall({ expr : EField({ expr : ENew({ name : "Dispatch", pack : ["haxe","web"], params : [], sub : null },[url,params]), pos : p },"runtimeDispatch"), pos : p },[cfg]), pos : p }; } static function extractConfig( obj : Dynamic ) : DispatchConfig { // extract the config from the class metadata (cache result) var c = Type.getClass(obj); var dc = haxe.rtti.Meta.getType(c); var m : Dynamic = dc.dispatchConfig[0]; if( Std.is(m,String) ) { m = haxe.Unserializer.run(m); dc.dispatchConfig[0] = m; } return { obj : obj, rules : m }; } } haxe_3.2.1+dfsg.orig/std/haxe/web/Request.hx0000664000175000017500000000435712607337712020622 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.web; class Request { /** Returns the current page GET and POST parameters (only GET parameters for Javascript) **/ public static function getParams() : Map { #if neko return neko.Web.getParams(); #elseif php return php.Web.getParams(); #elseif js var get : String = js.Browser.location.search.substr(1); var params = new haxe.ds.StringMap(); for( p in ~/[&;]/g.split(get) ) { var pl = p.split("="); if( pl.length < 2 ) continue; var name = pl.shift(); params.set(StringTools.urlDecode(name), StringTools.urlDecode(pl.join("="))); } return params; #end } /** Returns the local server host name **/ public static function getHostName() : String { #if neko return neko.Web.getHostName(); #elseif php return php.Web.getHostName(); #elseif js return js.Browser.location.host; // includes port #end } /** Returns the original request URL (before any server internal redirections) **/ public static function getURI() : String { #if neko return neko.Web.getURI(); #elseif php return php.Web.getURI(); #elseif js return js.Browser.location.pathname; #end } } haxe_3.2.1+dfsg.orig/std/haxe/xml/Check.hx0000664000175000017500000002020012607337712020213 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.xml; enum Filter { FInt; FBool; FEnum( values : Array ); FReg( matcher : EReg ); } enum Attrib { Att( name : String, ?filter : Filter, ?defvalue : String ); } enum Rule { RNode( name : String, ?attribs : Array, ?childs : Rule ); RData( ?filter : Filter ); RMulti( rule : Rule, ?atLeastOne : Bool ); RList( rules : Array, ?ordered : Bool ); RChoice( choices : Array ); ROptional( rule : Rule ); } private enum CheckResult { CMatch; CMissing( r : Rule ); CExtra( x : Xml ); CElementExpected( name : String, x : Xml ); CDataExpected( x : Xml ); CExtraAttrib( att : String, x : Xml ); CMissingAttrib( att : String, x : Xml ); CInvalidAttrib( att : String, x : Xml, f : Filter ); CInvalidData( x : Xml, f : Filter ); CInElement( x : Xml, r : CheckResult ); } class Check { static var blanks = ~/^[ \r\n\t]*$/; static function isBlank( x : Xml ) { return( x.nodeType == Xml.PCData && blanks.match(x.nodeValue) ) || x.nodeType == Xml.Comment; } static function filterMatch( s : String, f : Filter ) { switch( f ) { case FInt: return filterMatch(s,FReg(~/[0-9]+/)); case FBool: return filterMatch(s,FEnum(["true","false","0","1"])); case FEnum(values): for( v in values ) if( s == v ) return true; return false; case FReg(r): return r.match(s); } } static function isNullable( r : Rule ) { switch( r ) { case RMulti(r,one): return( one != true || isNullable(r) ); case RList(rl,_): for( r in rl ) if( !isNullable(r) ) return false; return true; case RChoice(rl): for( r in rl ) if( isNullable(r) ) return true; return false; case RData(_): return false; case RNode(_,_,_): return false; case ROptional(_): return true; } } static function check( x : Xml, r : Rule ) { switch( r ) { // check the node validity case RNode(name,attribs,childs): if( x.nodeType != Xml.Element || x.nodeName != name ) return CElementExpected(name,x); var attribs = if( attribs == null ) new Array() else attribs.copy(); // check defined attributes for( xatt in x.attributes() ) { var found = false; for( att in attribs ) switch( att ) { case Att(name,filter,_): if( xatt != name ) continue; if( filter != null && !filterMatch(x.get(xatt),filter) ) return CInvalidAttrib(name,x,filter); attribs.remove(att); found = true; } if( !found ) return CExtraAttrib(xatt,x); } // check remaining unchecked attributes for( att in attribs ) switch( att ) { case Att(name,_,defvalue): if( defvalue == null ) return CMissingAttrib(name,x); } // check childs if( childs == null ) childs = RList([]); var m = checkList(x.iterator(),childs); if( m != CMatch ) return CInElement(x,m); // set default attribs values for( att in attribs ) switch( att ) { case Att(name,_,defvalue): x.set(name,defvalue); } return CMatch; // check the data validity case RData(filter): if( x.nodeType != Xml.PCData && x.nodeType != Xml.CData ) return CDataExpected(x); if( filter != null && !filterMatch(x.nodeValue,filter) ) return CInvalidData(x,filter); return CMatch; // several choices case RChoice(choices): if( choices.length == 0 ) throw "No choice possible"; for( c in choices ) if( check(x,c) == CMatch ) return CMatch; return check(x,choices[0]); case ROptional(r): return check(x,r); default: throw "Unexpected "+Std.string(r); } } static function checkList( it : Iterator, r : Rule ) { switch( r ) { case RList(rules,ordered): var rules = rules.copy(); for( x in it ) { if( isBlank(x) ) continue; var found = false; for( r in rules ) { var m = checkList([x].iterator(),r); if( m == CMatch ) { found = true; switch(r) { case RMulti(rsub,one): if( one ) { var i; for( i in 0...rules.length ) if( rules[i] == r ) rules[i] = RMulti(rsub); } default: rules.remove(r); } break; } else if( ordered && !isNullable(r) ) return m; } if( !found ) return CExtra(x); } for( r in rules ) if( !isNullable(r) ) return CMissing(r); return CMatch; case RMulti(r,one): var found = false; for( x in it ) { if( isBlank(x) ) continue; var m = checkList([x].iterator(),r); if( m != CMatch ) return m; found = true; } if( one && !found ) return CMissing(r); return CMatch; default: var found = false; for( x in it ) { if( isBlank(x) ) continue; var m = check(x,r); if( m != CMatch ) return m; found = true; break; } if( !found ) { switch(r) { case ROptional(_): default: return CMissing(r); } } for( x in it ) { if( isBlank(x) ) continue; return CExtra(x); } return CMatch; } } static function makeWhere( path : Array ) { if( path.length == 0 ) return ""; var s = "In "; var first = true; for( x in path ) { if( first ) first = false; else s += "."; s += x.nodeName; } return s+": "; } static function makeString( x : Xml ) { if( x.nodeType == Xml.Element ) return "element "+x.nodeName; var s = x.nodeValue.split("\r").join("\\r").split("\n").join("\\n").split("\t").join("\\t"); if( s.length > 20 ) return s.substr(0,17)+"..."; return s; } static function makeRule( r : Rule ) { switch( r ) { case RNode(name,_,_): return "element "+name; case RData(_): return "data"; case RMulti(r,_): return makeRule(r); case RList(rules,_): return makeRule(rules[0]); case RChoice(choices): return makeRule(choices[0]); case ROptional(r): return makeRule(r); } } static function makeError(m,?path) { if( path == null ) path = new Array(); switch( m ) { case CMatch: throw "assert"; case CMissing(r): return makeWhere(path)+"Missing "+makeRule(r); case CExtra(x): return makeWhere(path)+"Unexpected "+makeString(x); case CElementExpected(name,x): return makeWhere(path)+makeString(x)+" while expected element "+name; case CDataExpected(x): return makeWhere(path)+makeString(x)+" while data expected"; case CExtraAttrib(att,x): path.push(x); return makeWhere(path)+"unexpected attribute "+att; case CMissingAttrib(att,x): path.push(x); return makeWhere(path)+"missing required attribute "+att; case CInvalidAttrib(att,x,_): path.push(x); return makeWhere(path)+"invalid attribute value for "+att; case CInvalidData(x,_): return makeWhere(path)+"invalid data format for "+makeString(x); case CInElement(x,m): path.push(x); return makeError(m,path); } } public static function checkNode( x : Xml, r : Rule ) { var m = checkList([x].iterator(),r); if( m == CMatch ) return; throw makeError(m); } public static function checkDocument( x : Xml, r : Rule ) { if( x.nodeType != Xml.Document ) throw "Document expected"; var m = checkList(x.iterator(),r); if( m == CMatch ) return; throw makeError(m); } } haxe_3.2.1+dfsg.orig/std/haxe/xml/Fast.hx0000664000175000017500000001073312607337712020105 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.xml; private class NodeAccess implements Dynamic { var __x : Xml; public function new( x : Xml ) { __x = x; } public function resolve( name : String ) : Fast { var x = __x.elementsNamed(name).next(); if( x == null ) { var xname = if( __x.nodeType == Xml.Document ) "Document" else __x.nodeName; throw xname+" is missing element "+name; } return new Fast(x); } } private class AttribAccess implements Dynamic { var __x : Xml; public function new( x : Xml ) { __x = x; } public function resolve( name : String ) : String { if( __x.nodeType == Xml.Document ) throw "Cannot access document attribute "+name; var v = __x.get(name); if( v == null ) throw __x.nodeName+" is missing attribute "+name; return v; } } private class HasAttribAccess implements Dynamic { var __x : Xml; public function new( x : Xml ) { __x = x; } public function resolve( name : String ) : Bool { if( __x.nodeType == Xml.Document ) throw "Cannot access document attribute "+name; return __x.exists(name); } } private class HasNodeAccess implements Dynamic { var __x : Xml; public function new( x : Xml ) { __x = x; } public function resolve( name : String ) : Bool { return __x.elementsNamed(name).hasNext(); } } private class NodeListAccess implements Dynamic> { var __x : Xml; public function new( x : Xml ) { __x = x; } public function resolve( name : String ) : List { var l = new List(); for( x in __x.elementsNamed(name) ) l.add(new Fast(x)); return l; } } class Fast { public var x(default,null) : Xml; public var name(get,null) : String; public var innerData(get,null) : String; public var innerHTML(get,null) : String; public var node(default,null) : NodeAccess; public var nodes(default,null) : NodeListAccess; public var att(default,null) : AttribAccess; public var has(default,null) : HasAttribAccess; public var hasNode(default,null) : HasNodeAccess; public var elements(get,null) : Iterator; public function new( x : Xml ) { if( x.nodeType != Xml.Document && x.nodeType != Xml.Element ) throw "Invalid nodeType "+x.nodeType; this.x = x; node = new NodeAccess(x); nodes = new NodeListAccess(x); att = new AttribAccess(x); has = new HasAttribAccess(x); hasNode = new HasNodeAccess(x); } function get_name() { return if( x.nodeType == Xml.Document ) "Document" else x.nodeName; } function get_innerData() { var it = x.iterator(); if( !it.hasNext() ) throw name+" does not have data"; var v = it.next(); var n = it.next(); if( n != null ) { // handle CDATA if( v.nodeType == Xml.PCData && n.nodeType == Xml.CData && StringTools.trim(v.nodeValue) == "" ) { var n2 = it.next(); if( n2 == null || (n2.nodeType == Xml.PCData && StringTools.trim(n2.nodeValue) == "" && it.next() == null) ) return n.nodeValue; } throw name+" does not only have data"; } if( v.nodeType != Xml.PCData && v.nodeType != Xml.CData ) throw name+" does not have data"; return v.nodeValue; } function get_innerHTML() { var s = new StringBuf(); for( x in x ) s.add(x.toString()); return s.toString(); } function get_elements() { var it = x.elements(); return { hasNext : it.hasNext, next : function() { var x = it.next(); if( x == null ) return null; return new Fast(x); } }; } } haxe_3.2.1+dfsg.orig/std/haxe/xml/Parser.hx0000664000175000017500000002471712607337712020453 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.xml; using StringTools; /* poor'man enum : reduce code size + a bit faster since inlined */ extern private class S { public static inline var IGNORE_SPACES = 0; public static inline var BEGIN = 1; public static inline var BEGIN_NODE = 2; public static inline var TAG_NAME = 3; public static inline var BODY = 4; public static inline var ATTRIB_NAME = 5; public static inline var EQUALS = 6; public static inline var ATTVAL_BEGIN = 7; public static inline var ATTRIB_VAL = 8; public static inline var CHILDS = 9; public static inline var CLOSE = 10; public static inline var WAIT_END = 11; public static inline var WAIT_END_RET = 12; public static inline var PCDATA = 13; public static inline var HEADER = 14; public static inline var COMMENT = 15; public static inline var DOCTYPE = 16; public static inline var CDATA = 17; public static inline var ESCAPE = 18; } class Parser { static var escapes = { var h = new haxe.ds.StringMap(); h.set("lt", "<"); h.set("gt", ">"); h.set("amp", "&"); h.set("quot", '"'); h.set("apos", "'"); h; } /** Parses the String into an XML Document. Set strict parsing to true in order to enable a strict check of XML attributes and entities. **/ static public function parse(str:String, strict = false) { var doc = Xml.createDocument(); doParse(str, strict, 0, doc); return doc; } static function doParse(str:String, strict:Bool, p:Int = 0, ?parent:Xml):Int { var xml:Xml = null; var state = S.BEGIN; var next = S.BEGIN; var aname = null; var start = 0; var nsubs = 0; var nbrackets = 0; var c = str.fastCodeAt(p); var buf = new StringBuf(); // need extra state because next is in use var escapeNext = S.BEGIN; var attrValQuote = -1; inline function addChild(xml:Xml) { parent.addChild(xml); nsubs++; } while (!StringTools.isEof(c)) { switch(state) { case S.IGNORE_SPACES: switch(c) { case '\n'.code, '\r'.code, '\t'.code, ' '.code: default: state = next; continue; } case S.BEGIN: switch(c) { case '<'.code: state = S.IGNORE_SPACES; next = S.BEGIN_NODE; default: start = p; state = S.PCDATA; continue; } case S.PCDATA: if (c == '<'.code) { buf.addSub(str, start, p - start); var child = Xml.createPCData(buf.toString()); buf = new StringBuf(); addChild(child); state = S.IGNORE_SPACES; next = S.BEGIN_NODE; } else if (c == '&'.code) { buf.addSub(str, start, p - start); state = S.ESCAPE; escapeNext = S.PCDATA; start = p + 1; } case S.CDATA: if (c == ']'.code && str.fastCodeAt(p + 1) == ']'.code && str.fastCodeAt(p + 2) == '>'.code) { var child = Xml.createCData(str.substr(start, p - start)); addChild(child); p += 2; state = S.BEGIN; } case S.BEGIN_NODE: switch(c) { case '!'.code: if (str.fastCodeAt(p + 1) == '['.code) { p += 2; if (str.substr(p, 6).toUpperCase() != "CDATA[") throw("Expected '.code: state = S.CHILDS; default: state = S.ATTRIB_NAME; start = p; continue; } case S.ATTRIB_NAME: if (!isValidChar(c)) { var tmp; if( start == p ) throw("Expected attribute name"); tmp = str.substr(start,p-start); aname = tmp; if( xml.exists(aname) ) throw("Duplicate attribute"); state = S.IGNORE_SPACES; next = S.EQUALS; continue; } case S.EQUALS: switch(c) { case '='.code: state = S.IGNORE_SPACES; next = S.ATTVAL_BEGIN; default: throw("Expected ="); } case S.ATTVAL_BEGIN: switch(c) { case '"'.code | '\''.code: buf = new StringBuf(); state = S.ATTRIB_VAL; start = p + 1; attrValQuote = c; default: throw("Expected \""); } case S.ATTRIB_VAL: switch (c) { case '&'.code: buf.addSub(str, start, p - start); state = S.ESCAPE; escapeNext = S.ATTRIB_VAL; start = p + 1; case '>'.code | '<'.code if( strict ): // HTML allows these in attributes values throw "Invalid unescaped " + String.fromCharCode(c) + " in attribute value"; case _ if (c == attrValQuote): buf.addSub(str, start, p - start); var val = buf.toString(); buf = new StringBuf(); xml.set(aname, val); state = S.IGNORE_SPACES; next = S.BODY; } case S.CHILDS: p = doParse(str, strict, p, xml); start = p; state = S.BEGIN; case S.WAIT_END: switch(c) { case '>'.code: state = S.BEGIN; default : throw("Expected >"); } case S.WAIT_END_RET: switch(c) { case '>'.code: if( nsubs == 0 ) parent.addChild(Xml.createPCData("")); return p; default : throw("Expected >"); } case S.CLOSE: if (!isValidChar(c)) { if( start == p ) throw("Expected node name"); var v = str.substr(start,p - start); if (v != parent.nodeName) throw "Expected "; state = S.IGNORE_SPACES; next = S.WAIT_END_RET; continue; } case S.COMMENT: if (c == '-'.code && str.fastCodeAt(p +1) == '-'.code && str.fastCodeAt(p + 2) == '>'.code) { addChild(Xml.createComment(str.substr(start, p - start))); p += 2; state = S.BEGIN; } case S.DOCTYPE: if(c == '['.code) nbrackets++; else if(c == ']'.code) nbrackets--; else if (c == '>'.code && nbrackets == 0) { addChild(Xml.createDocType(str.substr(start, p - start))); state = S.BEGIN; } case S.HEADER: if (c == '?'.code && str.fastCodeAt(p + 1) == '>'.code) { p++; var str = str.substr(start + 1, p - start - 2); addChild(Xml.createProcessingInstruction(str)); state = S.BEGIN; } case S.ESCAPE: if (c == ';'.code) { var s = str.substr(start, p - start); if (s.fastCodeAt(0) == '#'.code) { var c = s.fastCodeAt(1) == 'x'.code ? Std.parseInt("0" +s.substr(1, s.length - 1)) : Std.parseInt(s.substr(1, s.length - 1)); #if (neko || cpp || php) if( c >= 128 ) { // UTF8-encode it if( c <= 0x7FF ) { buf.addChar(0xC0 | (c >> 6)); buf.addChar(0x80 | (c & 63)); } else if( c <= 0xFFFF ) { buf.addChar(0xE0 | (c >> 12)); buf.addChar(0x80 | ((c >> 6) & 63)); buf.addChar(0x80 | (c & 63)); } else if( c <= 0x10FFFF ) { buf.addChar(0xF0 | (c >> 18)); buf.addChar(0x80 | ((c >> 12) & 63)); buf.addChar(0x80 | ((c >> 6) & 63)); buf.addChar(0x80 | (c & 63)); } else throw "Cannot encode UTF8-char " + c; } else #end buf.addChar(c); } else if (!escapes.exists(s)) { if( strict ) throw 'Undefined entity: $s'; buf.add('&$s;'); } else { buf.add(escapes.get(s)); } start = p + 1; state = escapeNext; } else if (!isValidChar(c) && c != "#".code) { if( strict ) throw 'Invalid character in entity: ' + String.fromCharCode(c); buf.addChar("&".code); buf.addSub(str, start, p - start); p--; start = p + 1; state = escapeNext; } } c = str.fastCodeAt(++p); } if (state == S.BEGIN) { start = p; state = S.PCDATA; } if (state == S.PCDATA) { if (p != start || nsubs == 0) { buf.addSub(str, start, p-start); addChild(Xml.createPCData(buf.toString())); } return p; } if( !strict && state == S.ESCAPE && escapeNext == S.PCDATA ) { buf.addChar("&".code); buf.addSub(str, start, p - start); addChild(Xml.createPCData(buf.toString())); return p; } throw "Unexpected end"; } static inline function isValidChar(c) { return (c >= 'a'.code && c <= 'z'.code) || (c >= 'A'.code && c <= 'Z'.code) || (c >= '0'.code && c <= '9'.code) || c == ':'.code || c == '.'.code || c == '_'.code || c == '-'.code; } }haxe_3.2.1+dfsg.orig/std/haxe/xml/Printer.hx0000664000175000017500000000714312607337712020634 0ustar andyandy00000000000000/* * Copyright (c)2005-2013, Haxe Foundation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * Neither the name of the Haxe Foundation nor the names of its contributors * may be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ package haxe.xml; class Printer { static public function print(xml:Xml, ?pretty = false) { var printer = new Printer(pretty); printer.writeNode(xml, ""); return printer.output.toString(); } var output:StringBuf; var pretty:Bool; function new(pretty) { output = new StringBuf(); this.pretty = pretty; } function writeNode(value:Xml, tabs:String) { switch (value.nodeType) { case CData: write(tabs + ""); newline(); case Comment: var commentContent:String = value.nodeValue; commentContent = ~/[\n\r\t]+/g.replace(commentContent, ""); commentContent = ""; write(tabs); write(StringTools.trim(commentContent)); newline(); case Document: for (child in value) { writeNode(child, tabs); } case Element: write(tabs + "<"); write(value.nodeName); for (attribute in value.attributes()) { write(" " + attribute + "=\""); write(StringTools.htmlEscape(value.get(attribute), true)); write("\""); } if (hasChildren(value)) { write(">"); newline(); for (child in value) { writeNode(child, pretty ? tabs + "\t" : tabs); } write(tabs + ""); newline(); } else { write("/>"); newline(); } case PCData: var nodeValue:String = value.nodeValue; if (nodeValue.length != 0) { write(tabs + StringTools.htmlEscape(nodeValue)); newline(); } case ProcessingInstruction: write(""); case DocType: write(""); } } inline function write(input:String) { output.add(input); } inline function newline() { if (pretty) { output.add(""); } } function hasChildren(value:Xml):Bool { for (child in value) { switch (child.nodeType) { case Xml.Element, Xml.PCData: return true; case Xml.CData, Xml.Comment: if (StringTools.ltrim(child.nodeValue).length != 0) { return true; } case _: } } return false; } }haxe_3.2.1+dfsg.orig/std/haxe/xml/Proxy.hx0000664000175000017500000000341512607337712020330 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.xml; /** This proxy can be inherited with an XML file name parameter. It will only allow access to fields which corresponds to an "id" attribute value in the XML file : [ class MyXml extends haxe.xml.Proxy<"my.xml",MyStructure> { } ... var h = new haxe.ds.StringMap(); // ... fill h with "my.xml" content var m = new MyXml(h.get); trace(m.myNode.structField); // access to "myNode" is only possible // if you have an id="myNode" attribute // in your XML, and completion works as well ] **/ class Proxy { var __f : String -> T; public function new(f) { this.__f = f; } public function resolve(k) { return __f(k); } } haxe_3.2.1+dfsg.orig/std/haxe/zip/Compress.hx0000664000175000017500000000314712607337712021006 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; class Compress { public function new( level : Int ) { throw "Not implemented for this platform"; } public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } { return null; } public function setFlushMode( f : FlushMode ) { } public function close() { } public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes { throw "Not implemented for this platform"; return null; } } haxe_3.2.1+dfsg.orig/std/haxe/zip/Entry.hx0000664000175000017500000000275212607337712020315 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; enum ExtraField { FUnknown( tag : Int, bytes : haxe.io.Bytes ); FInfoZipUnicodePath( name : String, crc : Int ); FUtf8; } typedef Entry = { var fileName : String; var fileSize : Int; var fileTime : Date; var compressed : Bool; var dataSize : Int; var data : Null; var crc32 : Null; @:optional var extraFields : Null>; } haxe_3.2.1+dfsg.orig/std/haxe/zip/FlushMode.hx0000664000175000017500000000225612607337712021101 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; enum FlushMode { NO; SYNC; FULL; FINISH; BLOCK; } haxe_3.2.1+dfsg.orig/std/haxe/zip/Huffman.hx0000664000175000017500000000622512607337712020577 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; enum Huffman { Found( i : Int ); NeedBit( left : Huffman, right : Huffman ); NeedBits( n : Int, table : Array ); } class HuffTools { public function new() { } function treeDepth(t) { return switch(t) { case Found(_): 0; case NeedBits(_,_): throw "assert"; case NeedBit(a,b): var da = treeDepth(a); var db = treeDepth(b); 1 + ((da < db) ? da : db); } } function treeCompress(t) { var d = treeDepth(t); if( d == 0 ) return t; if( d == 1 ) return switch( t ) { case NeedBit(a,b): NeedBit(treeCompress(a),treeCompress(b)); default: throw "assert"; } var size = 1 << d; var table = new Array(); for( i in 0...size ) table.push(Found(-1)); treeWalk(table,0,0,d,t); return NeedBits(d,table); } function treeWalk(table,p,cd,d,t) { switch( t ) { case NeedBit(a,b): if( d > 0 ) { treeWalk(table,p,cd+1,d-1,a); treeWalk(table,p|(1<, maxbits : Int, v : Int, len : Int ) { if( len > maxbits ) throw "Invalid huffman"; var idx = (v << 5) | len; if( bits.exists(idx) ) return Found(bits.get(idx)); v <<= 1; len += 1; return NeedBit(treeMake(bits,maxbits,v,len),treeMake(bits,maxbits,v|1,len)); } public function make(lengths,pos,nlengths,maxbits) { var counts = new Array(); var tmp = new Array(); if( maxbits > 32 ) throw "Invalid huffman"; for( i in 0...maxbits ) { counts.push(0); tmp.push(0); } for( i in 0...nlengths ) { var p = lengths[i+pos]; if( p >= maxbits ) throw "Invalid huffman"; counts[p]++; } var code = 0; for( i in 1...maxbits-1 ) { code = (code + counts[i]) << 1; tmp[i] = code; } var bits = new haxe.ds.IntMap(); for( i in 0...nlengths ) { var l = lengths[i + pos]; if( l != 0 ) { var n = tmp[l-1]; tmp[l-1] = n + 1; bits.set((n << 5) | l,i); } } return treeCompress(NeedBit(treeMake(bits,maxbits,0,1),treeMake(bits,maxbits,1,1))); } } haxe_3.2.1+dfsg.orig/std/haxe/zip/InflateImpl.hx0000664000175000017500000002177412607337712021425 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; import haxe.zip.Huffman; import haxe.crypto.Adler32; private class Window { public static inline var SIZE = 1 << 15; public static inline var BUFSIZE = 1 << 16; public var buffer : haxe.io.Bytes; public var pos : Int; var crc : Adler32; public function new(hasCrc) { buffer = haxe.io.Bytes.alloc(BUFSIZE); pos = 0; if( hasCrc ) crc = new Adler32(); } public function slide() { if( crc != null ) crc.update(buffer,0,SIZE); var b = haxe.io.Bytes.alloc(BUFSIZE); pos -= SIZE; b.blit(0,buffer,SIZE,pos); buffer = b; } public function addBytes(b,p,len) { if( pos + len > BUFSIZE ) slide(); buffer.blit(pos,b,p,len); pos += len; } public function addByte(c) { if( pos == BUFSIZE ) slide(); buffer.set(pos,c); pos++; } public function getLastChar() { return buffer.get(pos - 1); } public function available() { return pos; } public function checksum() { if( crc != null ) crc.update(buffer,0,pos); return crc; } } private enum State { Head; Block; CData; Flat; Crc; Dist; DistOne; Done; } /** A pure Haxe implementation of the ZLIB Inflate algorithm which allows reading compressed data without any platform-specific support. **/ class InflateImpl { static var LEN_EXTRA_BITS_TBL = [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,-1,-1]; static var LEN_BASE_VAL_TBL = [3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258]; static var DIST_EXTRA_BITS_TBL = [0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,-1,-1]; static var DIST_BASE_VAL_TBL = [1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]; static var CODE_LENGTHS_POS = [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]; var nbits : Int; var bits : Int; var state : State; var final : Bool; var huffman : Huffman; var huffdist : Null; var htools : HuffTools; var len : Int; var dist : Int; var needed : Int; var output : haxe.io.Bytes; var outpos : Int; var input : haxe.io.Input; var lengths : Array; var window : Window; static var FIXED_HUFFMAN = null; public function new( i, ?header = true, ?crc = true ) { final = false; htools = new HuffTools(); huffman = buildFixedHuffman(); huffdist = null; len = 0; dist = 0; state = header ? Head : Block; input = i; bits = 0; nbits = 0; needed = 0; output = null; outpos = 0; lengths = new Array(); for( i in 0...19 ) lengths.push(-1); window = new Window(crc); } function buildFixedHuffman() { if( FIXED_HUFFMAN != null ) return FIXED_HUFFMAN; var a = new Array(); for( n in 0...288 ) a.push(if( n <= 143 ) 8 else if( n <= 255 ) 9 else if( n <= 279 ) 7 else 8); FIXED_HUFFMAN = htools.make(a,0,288,10); return FIXED_HUFFMAN; } public function readBytes(b,pos,len) { needed = len; outpos = pos; output = b; if( len > 0 ) while( inflateLoop() ) { } return len - needed; } function getBits(n) { while( nbits < n ) { bits |= input.readByte() << nbits; nbits += 8; } var b = bits & ((1 << n) - 1); nbits -= n; bits >>= n; return b; } function getBit() { if( nbits == 0 ) { nbits = 8; bits = input.readByte(); } var b = bits & 1 == 1; nbits--; bits >>= 1; return b; } function getRevBits(n) { return if( n == 0 ) 0 else if( getBit() ) (1 << (n - 1)) | getRevBits(n-1) else getRevBits(n-1); } function resetBits() { bits = 0; nbits = 0; } function addBytes(b,p,len) { window.addBytes(b,p,len); output.blit(outpos,b,p,len); needed -= len; outpos += len; } function addByte(b) { window.addByte(b); output.set(outpos,b); needed--; outpos++; } function addDistOne(n) { var c = window.getLastChar(); for( i in 0...n ) addByte(c); } function addDist(d,len) { addBytes(window.buffer,window.pos - d,len); } function applyHuffman(h) { return switch(h) { case Found(n): n; case NeedBit(a,b): applyHuffman(getBit()?b:a); case NeedBits(n,tbl): applyHuffman(tbl[getBits(n)]); } } function inflateLengths(a,max) { var i = 0; var prev = 0; while( i < max ) { var n = applyHuffman(huffman); switch( n ) { case 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15: prev = n; a[i] = n; i++; case 16: var end = i + 3 + getBits(2); if( end > max ) throw "Invalid data"; while( i < end ) { a[i] = prev; i++; } case 17: i += 3 + getBits(3); if( i > max ) throw "Invalid data"; case 18: i += 11 + getBits(7); if( i > max ) throw "Invalid data"; default: throw "Invalid data"; } } } function inflateLoop() { switch( state ) { case Head: var cmf = input.readByte(); var cm = cmf & 15; var cinfo = cmf >> 4; if( cm != 8 ) throw "Invalid data"; var flg = input.readByte(); //var fcheck = flg & 31; var fdict = flg & 32 != 0; //var flevel = flg >> 6; if( ((cmf << 8) + flg) % 31 != 0 ) throw "Invalid data"; if( fdict ) throw "Unsupported dictionary"; state = Block; return true; case Crc: var calc = window.checksum(); if( calc == null ) { state = Done; return true; } var crc = Adler32.read(input); if( !calc.equals(crc) ) throw "Invalid CRC"; state = Done; return true; case Done: // nothing return false; case Block: final = getBit(); switch( getBits(2) ) { case 0: // no compression len = input.readUInt16(); var nlen = input.readUInt16(); if( nlen != 0xFFFF - len ) throw "Invalid data"; state = Flat; var r = inflateLoop(); resetBits(); return r; case 1: // fixed Huffman huffman = buildFixedHuffman(); huffdist = null; state = CData; return true; case 2: // dynamic Huffman var hlit = getBits(5) + 257; var hdist = getBits(5) + 1; var hclen = getBits(4) + 4; for( i in 0...hclen ) lengths[CODE_LENGTHS_POS[i]] = getBits(3); for( i in hclen...19 ) lengths[CODE_LENGTHS_POS[i]] = 0; huffman = htools.make(lengths,0,19,8); var lengths = new Array(); for( i in 0...hlit + hdist ) lengths.push(0); inflateLengths(lengths,hlit + hdist); huffdist = htools.make(lengths,hlit,hdist,16); huffman = htools.make(lengths,0,hlit,16); state = CData; return true; default: throw "Invalid data"; } case Flat: var rlen = (len < needed) ? len : needed; var bytes = input.read(rlen); len -= rlen; addBytes(bytes,0,rlen); if( len == 0 ) state = final ? Crc : Block; return needed > 0; case DistOne: var rlen = (len < needed) ? len : needed; addDistOne(rlen); len -= rlen; if( len == 0 ) state = CData; return needed > 0; case Dist: while( len > 0 && needed > 0 ) { var rdist = (len < dist) ? len : dist; var rlen = (needed < rdist) ? needed : rdist; addDist(dist,rlen); len -= rlen; } if( len == 0 ) state = CData; return needed > 0; case CData: var n = applyHuffman(huffman); if( n < 256 ) { addByte(n); return needed > 0; } else if( n == 256 ) { state = final ? Crc : Block; return true; } else { n -= 257; var extra_bits = LEN_EXTRA_BITS_TBL[n]; if( extra_bits == -1 ) throw "Invalid data"; len = LEN_BASE_VAL_TBL[n] + getBits(extra_bits); var dist_code = if( huffdist == null ) getRevBits(5) else applyHuffman(huffdist); extra_bits = DIST_EXTRA_BITS_TBL[dist_code]; if( extra_bits == -1 ) throw "Invalid data"; dist = DIST_BASE_VAL_TBL[dist_code] + getBits(extra_bits); if( dist > window.available() ) throw "Invalid data"; state = (dist == 1) ? DistOne : Dist; return true; } } } public static function run( i : haxe.io.Input, ?bufsize = 65536 ) { var buf = haxe.io.Bytes.alloc(bufsize); var output = new haxe.io.BytesBuffer(); var inflate = new InflateImpl(i); while( true ) { var len = inflate.readBytes(buf,0,bufsize); output.addBytes(buf,0,len); if( len < bufsize ) break; } return output.getBytes(); } } haxe_3.2.1+dfsg.orig/std/haxe/zip/Reader.hx0000664000175000017500000001406112607337712020412 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; import haxe.zip.Entry; // see http://www.pkware.com/documents/casestudies/APPNOTE.TXT class Reader { var i : haxe.io.Input; public function new(i) { this.i = i; } function readZipDate() { var t = i.readUInt16(); var hour = (t >> 11) & 31; var min = (t >> 5) & 63; var sec = t & 31; var d = i.readUInt16(); var year = d >> 9; var month = (d >> 5) & 15; var day = d & 31; return new Date(year + 1980, month-1, day, hour, min, sec << 1); } function readExtraFields(length) { var fields = new List(); while( length > 0 ) { if( length < 4 ) throw "Invalid extra fields data"; var tag = i.readUInt16(); var len = i.readUInt16(); if( length < len ) throw "Invalid extra fields data"; switch( tag ) { case 0x7075: var version = i.readByte(); if( version != 1 ) { var data = new haxe.io.BytesBuffer(); data.addByte(version); data.add(i.read(len-1)); fields.add(FUnknown(tag,data.getBytes())); } else { var crc = i.readInt32(); var name = i.read(len - 5).toString(); fields.add(FInfoZipUnicodePath(name,crc)); } default: fields.add(FUnknown(tag,i.read(len))); } length -= 4 + len; } return fields; } public function readEntryHeader() : Entry { var i = this.i; var h = i.readInt32(); if( h == 0x02014B50 || h == 0x06054B50 ) return null; if( h != 0x04034B50 ) throw "Invalid Zip Data"; var version = i.readUInt16(); var flags = i.readUInt16(); var utf8 = flags & 0x800 != 0; if( (flags & 0xF7F1) != 0 ) throw "Unsupported flags "+flags; var compression = i.readUInt16(); var compressed = (compression != 0); if( compressed && compression != 8 ) throw "Unsupported compression "+compression; var mtime = readZipDate(); var crc32 : Null = i.readInt32(); var csize = i.readInt32(); var usize = i.readInt32(); var fnamelen = i.readInt16(); var elen = i.readInt16(); var fname = i.readString(fnamelen); var fields = readExtraFields(elen); if( utf8 ) fields.push(FUtf8); var data = null; // we have a data descriptor that store the real crc/sizes // after the compressed data, let's wait for it if( (flags & 8) != 0 ) crc32 = null; return { fileName : fname, fileSize : usize, fileTime : mtime, compressed : compressed, dataSize : csize, data : data, crc32 : crc32, extraFields : fields, }; } public function read() : List { var l = new List(); var buf = null; var tmp = null; while( true ) { var e = readEntryHeader(); if( e == null ) break; // do we have a data descriptor? (see readEntryHeader) if( e.crc32 == null ) { if( e.compressed ) { #if neko // enter progressive mode : we use a different input which has // a temporary buffer, this is necessary since we have to uncompress // progressively, and after that we might have pending readed data // that needs to be processed var bufSize = 65536; if( buf == null ) { buf = new haxe.io.BufferInput(i, haxe.io.Bytes.alloc(bufSize)); tmp = haxe.io.Bytes.alloc(bufSize); i = buf; } var out = new haxe.io.BytesBuffer(); var z = new neko.zip.Uncompress(-15); z.setFlushMode(neko.zip.Flush.SYNC); while( true ) { if( buf.available == 0 ) buf.refill(); var p = bufSize - buf.available; if( p != buf.pos ) { // because of lack of "srcLen" in zip api, we need to always be stuck to the buffer end buf.buf.blit(p, buf.buf, buf.pos, buf.available); buf.pos = p; } var r = z.execute(buf.buf, buf.pos, tmp, 0); out.addBytes(tmp, 0, r.write); buf.pos += r.read; buf.available -= r.read; if( r.done ) break; } e.data = out.getBytes(); #else var bufSize = 65536; if( tmp == null ) tmp = haxe.io.Bytes.alloc(bufSize); var out = new haxe.io.BytesBuffer(); var z = new InflateImpl(i, false, false); while( true ) { var n = z.readBytes(tmp, 0, bufSize); out.addBytes(tmp, 0, n); if( n < bufSize ) break; } e.data = out.getBytes(); #end } else e.data = i.read(e.dataSize); e.crc32 = i.readInt32(); if( e.crc32 == 0x08074b50 ) e.crc32 = i.readInt32(); e.dataSize = i.readInt32(); e.fileSize = i.readInt32(); // set data to uncompressed e.dataSize = e.fileSize; e.compressed = false; } else e.data = i.read(e.dataSize); l.add(e); } return l; } public static function readZip( i : haxe.io.Input ) { var r = new Reader(i); return r.read(); } public static function unzip( f : Entry ) { if( !f.compressed ) return f.data; var c = new haxe.zip.Uncompress(-15); var s = haxe.io.Bytes.alloc(f.fileSize); var r = c.execute(f.data,0,s,0); c.close(); if( !r.done || r.read != f.data.length || r.write != f.fileSize ) throw "Invalid compressed data for "+f.fileName; f.compressed = false; f.dataSize = f.fileSize; f.data = s; return f.data; } } haxe_3.2.1+dfsg.orig/std/haxe/zip/Tools.hx0000664000175000017500000000301612607337712020306 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; class Tools { public static function compress( f : Entry, level : Int ) { if( f.compressed ) return; // this should be optimized with a temp buffer // that would discard the first two bytes // (in order to prevent 2x mem usage for large files) var data = haxe.zip.Compress.run( f.data, level ); f.compressed = true; f.data = data.sub(2,data.length-6); f.dataSize = f.data.length; } } haxe_3.2.1+dfsg.orig/std/haxe/zip/Uncompress.hx0000664000175000017500000000316712607337712021353 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; class Uncompress { public function new( ?windowBits : Int ) { throw "Not implemented for this platform"; } public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } { return null; } public function setFlushMode( f : FlushMode ) { } public function close() { } public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes { return InflateImpl.run(new haxe.io.BytesInput(src),bufsize); } } haxe_3.2.1+dfsg.orig/std/haxe/zip/Writer.hx0000664000175000017500000001311712607337712020465 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; class Writer { /* * The next constant is required for computing the Central * Directory Record(CDR) size. CDR consists of some fields * of constant size and a filename. Constant represents * total length of all fields with constant size for each * file in archive */ inline static var CENTRAL_DIRECTORY_RECORD_FIELDS_SIZE = 46; /* * The following constant is the total size of all fields * of Local File Header. It's required for calculating * offset of start of central directory record */ inline static var LOCAL_FILE_HEADER_FIELDS_SIZE = 30; var o : haxe.io.Output; var files : List<{ name : String, compressed : Bool, clen : Int, size : Int, crc : Int, date : Date, fields : haxe.io.Bytes }>; public function new( o : haxe.io.Output ) { this.o = o; files = new List(); } function writeZipDate( date : Date ) { var hour = date.getHours(); var min = date.getMinutes(); var sec = date.getSeconds() >> 1; o.writeUInt16( (hour << 11) | (min << 5) | sec ); var year = date.getFullYear() - 1980; var month = date.getMonth() + 1; var day = date.getDate(); o.writeUInt16( (year << 9) | (month << 5) | day ); } public function writeEntryHeader( f : Entry ) { var o = this.o; var flags = 0; if (f.extraFields != null) { for( e in f.extraFields ) switch( e ) { case FUtf8: flags |= 0x800; default: } } o.writeInt32(0x04034B50); o.writeUInt16(0x0014); // version o.writeUInt16(flags); // flags if( f.data == null ) { f.fileSize = 0; f.dataSize = 0; f.crc32 = 0; f.compressed = false; f.data = haxe.io.Bytes.alloc(0); } else { if( f.crc32 == null ) { if( f.compressed ) throw "CRC32 must be processed before compression"; f.crc32 = haxe.crypto.Crc32.make(f.data); } if( !f.compressed ) f.fileSize = f.data.length; f.dataSize = f.data.length; } o.writeUInt16(f.compressed?8:0); writeZipDate(f.fileTime); o.writeInt32(f.crc32); o.writeInt32(f.dataSize); o.writeInt32(f.fileSize); o.writeUInt16(f.fileName.length); var e = new haxe.io.BytesOutput(); if (f.extraFields != null) { for( f in f.extraFields ) switch( f ) { case FInfoZipUnicodePath(name,crc): var namebytes = haxe.io.Bytes.ofString(name); e.writeUInt16(0x7075); e.writeUInt16(namebytes.length + 5); e.writeByte(1); // version e.writeInt32(crc); e.write(namebytes); case FUnknown(tag,bytes): e.writeUInt16(tag); e.writeUInt16(bytes.length); e.write(bytes); case FUtf8: // nothing } } var ebytes = e.getBytes(); o.writeUInt16(ebytes.length); o.writeString(f.fileName); o.write(ebytes); files.add({ name : f.fileName, compressed : f.compressed, clen : f.data.length, size : f.fileSize, crc : f.crc32, date : f.fileTime, fields : ebytes }); } public function write( files : List ) { for( f in files ) { writeEntryHeader(f); o.writeFullBytes(f.data,0,f.data.length); } writeCDR(); } public function writeCDR() { var cdr_size = 0; var cdr_offset = 0; for ( f in files ) { var namelen = f.name.length; var extraFieldsLength = f.fields.length; o.writeInt32(0x02014B50); // header o.writeUInt16(0x0014); // version made-by o.writeUInt16(0x0014); // version o.writeUInt16(0); // flags o.writeUInt16(f.compressed?8:0); writeZipDate(f.date); o.writeInt32(f.crc); o.writeInt32(f.clen); o.writeInt32(f.size); o.writeUInt16(namelen); o.writeUInt16(extraFieldsLength); o.writeUInt16(0); //comment length always 0 o.writeUInt16(0); //disk number start o.writeUInt16(0); //internal file attributes o.writeInt32(0); //external file attributes o.writeInt32(cdr_offset); //relative offset of local header o.writeString(f.name); o.write(f.fields); cdr_size += CENTRAL_DIRECTORY_RECORD_FIELDS_SIZE + namelen + extraFieldsLength; cdr_offset += LOCAL_FILE_HEADER_FIELDS_SIZE + namelen + extraFieldsLength + f.clen; } //end of central dir signature o.writeInt32(0x06054B50); //number of this disk o.writeUInt16(0); //number of the disk with the start of the central directory o.writeUInt16(0); //total number of entries in the central directory on this disk o.writeUInt16(files.length); //total number of entries in the central directory o.writeUInt16(files.length); //size of the central directory record o.writeInt32(cdr_size); //offset of start of central directory with respect to the starting disk number o.writeInt32(cdr_offset); // .ZIP file comment length o.writeUInt16(0); } } haxe_3.2.1+dfsg.orig/std/java/Boot.hx0000664000175000017500000000337512607337712017313 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java; import java.internal.Exceptions; import java.internal.Function; import java.internal.HxObject; import java.internal.Runtime; import java.internal.Iterator; import java.Lib; //import java.internal.StringExt; import java.StdTypes; import Reflect; import Map; import haxe.ds.StringMap; import java.lang.Boolean; import java.lang.Character; import java.lang.Class; import java.lang.Number; import java.lang.Byte; import java.lang.Double; import java.lang.Float; import java.lang.Integer; import java.lang.Long; import java.lang.Short; import java.lang.Throwable; import java.internal.StringExt; import java.internal.FieldLookup; extern class Boot { } haxe_3.2.1+dfsg.orig/std/java/Lib.hx0000664000175000017500000001256412607337712017116 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java; /** Platform-specific Java Library. Provides some platform-specific functions for the Java target, such as conversion from haxe types to native types and vice-versa. **/ //we cannot use the java package for custom classes, so we're redefining it as "haxe.java.Lib" @:native('haxe.java.Lib') class Lib { /** Returns a native array from the supplied Array. This native array is unsafe to be written on, as it may or may not be linked to the actual Array implementation. If equalLengthRequired is true, the result might be a copy of an array with the correct size. **/ inline public static function nativeArray(arr:Array, equalLengthRequired:Bool):NativeArray { var ret = new NativeArray(arr.length); for (i in 0...arr.length) { ret[i] = arr[i]; } return ret; } /** Gets the native `java.lang.Class` from the supplied object. Will throw an exception in case of null being passed. [deprecated] - use `getNativeType` instead **/ @:deprecated('The function `nativeType` is deprecated and will be removed in later versions. Please use `getNativeType` instead') inline public static function nativeType(obj:T):java.lang.Class { return untyped obj.getClass(); } /** Gets the native `java.lang.Class` from the supplied object. Will throw an exception in case of null being passed. [deprecated] - use `getNativeType` instead **/ inline public static function getNativeType(obj:T):java.lang.Class { return untyped obj.getClass(); } /** Returns a Class<> equivalent to the native java.lang.Class type. **/ public static inline function fromNativeType(t:java.lang.Class):Class { return untyped t; } /** Returns a java.lang.Class equivalent to the Haxe Class<> type. **/ public static inline function toNativeType(cl:Class):java.lang.Class { return untyped cl; } /** Returns a java.lang.Class equivalent to the Haxe Enum<> type. **/ public static inline function toNativeEnum(cl:Enum):java.lang.Class { return untyped cl; } /** Returns a Haxe Array of a native Array. Unless `copy` is true, it won't copy the contents of the native array, so unless any operation triggers an array resize, all changes made to the Haxe array will affect the native array argument. **/ @:generic public static function array(native:java.NativeArray):Array { return untyped Array.ofNative(native); } @:extern inline private static function doArray(native:java.NativeArray):Array { var ret:NativeArray = new NativeArray(native.length); for (i in 0...native.length) { ret[i] = native[i]; } return untyped Array.ofNative(ret); } public static function array_Int(native:java.NativeArray):Array { return doArray(native); } public static function array_Float(native:java.NativeArray):Array { return doArray(native); } public static function array_Bool(native:java.NativeArray):Array { return doArray(native); } public static function array_java_Int8(native:java.NativeArray):Array { return doArray(native); } public static function array_java_Int16(native:java.NativeArray):Array { return doArray(native); } public static function array_java_Char16(native:java.NativeArray):Array { return doArray(native); } public static function array_Single(native:java.NativeArray):Array { return doArray(native); } public static function array_haxe_Int64(native:java.NativeArray):Array { return doArray(native); } /** Allocates a new Haxe Array with a predetermined size **/ public static function arrayAlloc(size:Int):Array { return untyped Array.alloc(size); } /** Ensures that one thread does not enter a critical section of code while another thread is in the critical section. If another thread attempts to enter a locked code, it will wait, block, until the object is released. This is the equivalent to "synchronized" in java code. This method only exists at compile-time, so it can't be called via reflection. **/ @:extern public static inline function lock(obj:Dynamic, block:T):Void { untyped __lock__(obj, block); } } haxe_3.2.1+dfsg.orig/std/java/NativeArray.hx0000664000175000017500000000316612607337712020633 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java; import haxe.extern.Rest; /** Represents a java fixed-size Array (`T[]`) **/ @:nativeGen extern class NativeArray implements ArrayAccess { /** Creates a new array with the specified elements. Usage: ```haxe var elements = NativeArray.make(1,2,3,4,5,6); ``` **/ public static function make(elements:Rest):NativeArray; /** The length of the array **/ public var length(default, null):Int; /** Allocates a new array with size `len` **/ public function new(len:Int):Void; } haxe_3.2.1+dfsg.orig/std/java/StdTypes.hx0000664000175000017500000000665612607337712020174 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java; @:notNull @:runtimeValue @:coreType abstract Int8 from Int {} @:notNull @:runtimeValue @:coreType abstract Int16 from Int {} @:notNull @:runtimeValue @:coreType abstract Char16 from Int {} @:notNull @:runtimeValue @:coreType abstract Int64 from Int from Float { @:op(A+B) public static function addI(lhs:Int64, rhs:Int):Int64; @:op(A+B) public static function add(lhs:Int64, rhs:Int64):Int64; @:op(A*B) public static function mulI(lhs:Int64, rhs:Int):Int64; @:op(A*B) public static function mul(lhs:Int64, rhs:Int64):Int64; @:op(A%B) public static function modI(lhs:Int64, rhs:Int):Int64; @:op(A%B) public static function mod(lhs:Int64, rhs:Int64):Int64; @:op(A-B) public static function subI(lhs:Int64, rhs:Int):Int64; @:op(A-B) public static function sub(lhs:Int64, rhs:Int64):Int64; @:op(A/B) public static function divI(lhs:Int64, rhs:Int):Int64; @:op(A/B) public static function div(lhs:Int64, rhs:Int64):Int64; @:op(A|B) public static function orI(lhs:Int64, rhs:Int):Int64; @:op(A|B) public static function or(lhs:Int64, rhs:Int64):Int64; @:op(A^B) public static function xorI(lhs:Int64, rhs:Int):Int64; @:op(A^B) public static function xor(lhs:Int64, rhs:Int64):Int64; @:op(A&B) public static function andI(lhs:Int64, rhs:Int):Int64; @:op(A&B) public static function and(lhs:Int64, rhs:Int64):Int64; @:op(A<>B) public static function shrI(lhs:Int64, rhs:Int):Int64; @:op(A>>B) public static function shr(lhs:Int64, rhs:Int64):Int64; @:op(A>>>B) public static function ushrI(lhs:Int64, rhs:Int):Int64; @:op(A>>>B) public static function ushr(lhs:Int64, rhs:Int64):Int64; @:op(A>B) public static function gt(lhs:Int64, rhs:Int64):Bool; @:op(A>=B) public static function gte(lhs:Int64, rhs:Int64):Bool; @:op(A implements ArrayAccess { public var length(default,null) : Int; private var __a:NativeArray; @:functionCode(' return new Array(_native); ') private static function ofNative(native:NativeArray):Array { return null; } @:functionCode(' return new Array((Y[]) ((java.lang.Object)new java.lang.Object[size])); ') private static function alloc(size:Int):Array { return null; } public function new() : Void { this.length = 0; this.__a = new NativeArray(0); } public function concat( a : Array ) : Array { var length = length; var len = length + a.length; var retarr = new NativeArray(len); System.arraycopy(__a, 0, retarr, 0, length); System.arraycopy(a.__a, 0, retarr, length, a.length); return ofNative(retarr); } private function concatNative( a : NativeArray ) : Void { var __a = __a; var length = length; var len = length + a.length; if (__a.length >= len) { System.arraycopy(a, 0, __a, length, length); } else { var newarr = new NativeArray(len); System.arraycopy(__a, 0, newarr, 0, length); System.arraycopy(a, 0, newarr, length, a.length); this.__a = newarr; } this.length = len; } public function join( sep : String ) : String { var buf = new StringBuf(); var i = -1; var first = true; var length = length; while (++i < length) { if (first) first = false; else buf.add(sep); buf.add(__a[i]); } return buf.toString(); } public function pop() : Null { var __a = __a; var length = length; if (length > 0) { var val = __a[--length]; __a[length] = null; this.length = length; return val; } else { return null; } } public function push(x : T) : Int { var length = length; if (length >= __a.length) { var newLen = (length << 1) + 1; var newarr = new NativeArray(newLen); System.arraycopy(__a, 0, newarr, 0, __a.length); this.__a = newarr; } __a[length] = x; return ++this.length; } public function reverse() : Void { var i = 0; var l = this.length; var a = this.__a; var half = l >> 1; l -= 1; while ( i < half ) { var tmp = a[i]; a[i] = a[l-i]; a[l-i] = tmp; i += 1; } } public function shift() : Null { var l = this.length; if( l == 0 ) return null; var a = this.__a; var x = a[0]; l -= 1; System.arraycopy(a, 1, a, 0, length-1); a[l] = null; this.length = l; return x; } public function slice( pos : Int, ?end : Int ) : Array { if( pos < 0 ){ pos = this.length + pos; if( pos < 0 ) pos = 0; } if( end == null ) end = this.length; else if( end < 0 ) end = this.length + end; if( end > this.length ) end = this.length; var len = end - pos; if ( len < 0 ) return new Array(); var newarr = new NativeArray(len); System.arraycopy(__a, pos, newarr, 0, len); return ofNative(newarr); } public function sort( f : T -> T -> Int ) : Void { if (length == 0) return; quicksort(0, length - 1, f); } private function quicksort( lo : Int, hi : Int, f : T -> T -> Int ) : Void { var buf = __a; var i = lo, j = hi; var p = buf[(i + j) >> 1]; while ( i <= j ) { while ( i < hi && f(buf[i], p) < 0 ) i++; while ( j > lo && f(buf[j], p) > 0 ) j--; if ( i <= j ) { var t = buf[i]; buf[i++] = buf[j]; buf[j--] = t; } } if( lo < j ) quicksort( lo, j, f ); if( i < hi ) quicksort( i, hi, f ); } public function splice( pos : Int, len : Int ) : Array { if( len < 0 ) return new Array(); if( pos < 0 ) { pos = this.length + pos; if( pos < 0 ) pos = 0; } if( pos > this.length ) { pos = 0; len = 0; } else if( pos + len > this.length ) { len = this.length - pos; if( len < 0 ) len = 0; } var a = this.__a; var ret = new NativeArray(len); System.arraycopy(a, pos, ret, 0, len); var ret = ofNative(ret); var end = pos + len; System.arraycopy(a, end, a, pos, this.length - end); this.length -= len; while( --len >= 0 ) a[this.length + len] = null; return ret; } private function spliceVoid( pos : Int, len : Int ) : Void { if( len < 0 ) return; if( pos < 0 ) { pos = this.length + pos; if( pos < 0 ) pos = 0; } if( pos > this.length ) { pos = 0; len = 0; } else if( pos + len > this.length ) { len = this.length - pos; if( len < 0 ) len = 0; } var a = this.__a; var end = pos + len; System.arraycopy(a, end, a, pos, this.length - end); this.length -= len; while( --len >= 0 ) a[this.length + len] = null; } public function toString() : String { var ret = new StringBuf(); var a = __a; ret.add("["); var first = true; for (i in 0...length) { if (first) first = false; else ret.add(","); ret.add(a[i]); } ret.add("]"); return ret.toString(); } public function unshift( x : T ) : Void { var __a = __a; var length = length; if (length >= __a.length) { var newLen = (length << 1) + 1; var newarr = new NativeArray(newLen); System.arraycopy(__a, 0, newarr, 1, length); this.__a = newarr; } else { System.arraycopy(__a, 0, __a, 1, length); } this.__a[0] = x; ++this.length; } public function insert( pos : Int, x : T ) : Void { var l = this.length; if( pos < 0 ) { pos = l + pos; if( pos < 0 ) pos = 0; } if ( pos >= l ) { this.push(x); return; } else if (pos == 0) { this.unshift(x); return; } if (l >= __a.length) { var newLen = (length << 1) + 1; var newarr = new NativeArray(newLen); System.arraycopy(__a, 0, newarr, 0, pos); newarr[pos] = x; System.arraycopy(__a, pos, newarr, pos + 1, l - pos); this.__a = newarr; ++this.length; } else { var __a = __a; System.arraycopy(__a, pos, __a, pos + 1, l - pos); System.arraycopy(__a, 0, __a, 0, pos); __a[pos] = x; ++this.length; } } public function remove( x : T ) : Bool { var __a = __a; var i = -1; var length = length; while (++i < length) { if (__a[i] == x) { System.arraycopy(__a, i + 1, __a, i, length - i - 1); __a[--this.length] = null; return true; } } return false; } public function indexOf(x : T, ?fromIndex:Int) : Int { var len = length, a = __a, i:Int = (fromIndex == null) ? 0 : fromIndex; if (i < 0) { i += len; if (i < 0) i = 0; } while (i < len) { if (a[i] == x) return i; i++; } return -1; } public function lastIndexOf(x : T, ?fromIndex:Int) : Int { var len = length, a = __a, i:Int = (fromIndex == null) ? len - 1 : fromIndex; if (i >= len) i = len - 1; else if (i < 0) i += len; while (i >= 0) { if (a[i] == x) return i; i--; } return -1; } public function copy() : Array { var len = length; var __a = __a; var newarr = new NativeArray(len); System.arraycopy(__a, 0, newarr, 0, len); return ofNative(newarr); } public inline function iterator() : Iterator { return new ArrayIterator(this); } public function map( f : T -> S ) : Array { var ret = []; for (elt in this) ret.push(f(elt)); return ret; } public function filter( f : T -> Bool ) : Array { var ret = []; for (elt in this) if (f(elt)) ret.push(elt); return ret; } private function __get(idx:Int):T { var __a = __a; if (idx >= __a.length || idx < 0) return null; return __a[idx]; } private function __set(idx:Int, v:T):T { var __a = __a; if (idx >= __a.length) { var newl = idx + 1; if (idx == __a.length) newl = (idx << 1) + 1; var newArr = new NativeArray(newl); if (length > 0) System.arraycopy(__a, 0, newArr, 0, length); this.__a = __a = newArr; } if (idx >= length) this.length = idx + 1; return __a[idx] = v; } private inline function __unsafe_get(idx:Int):T { return __a[idx]; } private inline function __unsafe_set(idx:Int, val:T):T { return __a[idx] = val; } } @:final private class ArrayIterator { var arr:Array; var len:Int; var i:Int; public inline function new(a:Array) { arr = a; len = a.length; i = 0; } public inline function hasNext():Bool return i < len; public inline function next():T return arr[i++]; } haxe_3.2.1+dfsg.orig/std/java/_std/Date.hx0000664000175000017500000000663312607337712020216 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package; import haxe.Int64; @:SuppressWarnings("deprecation") @:coreApi class Date { private var date:java.util.Date; public function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void { //issue #1769 year = year != 0 ? year - 1900 : 0; date = new java.util.Date(year, month, day, hour, min, sec); } public inline function getTime() : Float { return cast date.getTime(); } public inline function getHours() : Int { return date.getHours(); } public inline function getMinutes() : Int { return date.getMinutes(); } public inline function getSeconds() : Int { return date.getSeconds(); } public inline function getFullYear() : Int { return date.getYear() + 1900; } public inline function getMonth() : Int { return date.getMonth(); } public inline function getDate() : Int { return date.getDate(); } public inline function getDay() : Int { return date.getDay(); } public function toString():String { var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); var mi = date.getMinutes(); var s = date.getSeconds(); return (date.getYear() + 1900) +"-"+(if( m < 10 ) "0"+m else ""+m) +"-"+(if( d < 10 ) "0"+d else ""+d) +" "+(if( h < 10 ) "0"+h else ""+h) +":"+(if( mi < 10 ) "0"+mi else ""+mi) +":"+(if( s < 10 ) "0"+s else ""+s); } static public function now() : Date { var d = new Date(0, 0, 0, 0, 0, 0); d.date = new java.util.Date(); return d; } static public function fromTime( t : Float ) : Date { var d = new Date(0, 0, 0, 0, 0, 0); d.date = new java.util.Date(cast(t, Int64)); return d; } static public function fromString( s : String ) : Date { switch( s.length ) { case 8: // hh:mm:ss var k = s.split(":"); var d : Date = new Date(0, 0, 0, Std.parseInt(k[0]), Std.parseInt(k[1]), Std.parseInt(k[2])); return d; case 10: // YYYY-MM-DD var k = s.split("-"); return new Date(Std.parseInt(k[0]),Std.parseInt(k[1]) - 1,Std.parseInt(k[2]),0,0,0); case 19: // YYYY-MM-DD hh:mm:ss var k = s.split(" "); var y = k[0].split("-"); var t = k[1].split(":"); return new Date(Std.parseInt(y[0]),Std.parseInt(y[1]) - 1,Std.parseInt(y[2]),Std.parseInt(t[0]),Std.parseInt(t[1]),Std.parseInt(t[2])); default: throw "Invalid date format : " + s; } } } haxe_3.2.1+dfsg.orig/std/java/_std/EReg.hx0000664000175000017500000001060112607337712020151 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import java.util.regex.*; @:coreApi class EReg { private var pattern:String; private var matcher:Matcher; private var cur:String; private var isGlobal:Bool; public function new( r : String, opt : String ) { var flags = 0; for (i in 0...opt.length) { switch(StringTools.fastCodeAt(opt, i)) { case 'i'.code: flags |= Pattern.CASE_INSENSITIVE; case 'm'.code: flags |= Pattern.MULTILINE; case 's'.code: flags |= Pattern.DOTALL; case 'g'.code: isGlobal = true; } } matcher = Pattern.compile(convert(r), flags).matcher(""); pattern = r; } private static function convert(r:String):String { //some references of the implementation: //http://stackoverflow.com/questions/809647/java-vs-javascript-regex-problem //http://stackoverflow.com/questions/4788413/how-to-convert-javascript-regex-to-safe-java-regex //Some necessary changes: // // \0 -> \x00 // \v -> \x0b // [^] -> [\s\S] // unescaped ', " -> \', \" /* FIXME var pat = new StringBuf(); var len = r.length; var i = 0; while (i < len) { var c = StringTools.fastCodeAt(r, i++); switch(c) { case '\\'.code: //escape-sequence } } */ return r; } public function match( s : String ) : Bool { cur = s; matcher = matcher.reset(s); return matcher.find(); } public function matched( n : Int ) : String { if (n == 0) return matcher.group(); else return matcher.group(n); } public function matchedLeft() : String { return untyped cur.substring(0, matcher.start()); } public function matchedRight() : String { return untyped cur.substring(matcher.end(), cur.length); } public function matchedPos() : { pos : Int, len : Int } { var start = matcher.start(); return { pos : start, len : matcher.end() - start }; } public function matchSub( s : String, pos : Int, len : Int = -1):Bool { matcher = matcher.reset(len < 0 ? s : s.substr(0,pos + len)); cur = s; return matcher.find(pos); } public function split( s : String ) : Array { if (isGlobal) { var ret = []; while(this.match(s)) { ret.push(matchedLeft()); s = matchedRight(); } ret.push(s); return ret; } else { var m = matcher; m.reset(s); if (m.find()) { return untyped [s.substring(0, m.start()), s.substring(m.end(), s.length)]; } else { return [s]; } } } inline function start(group:Int) : Int { return matcher.start(group); } inline function len(group:Int) : Int { return matcher.end(group) - matcher.start(group); } public function replace( s : String, by : String ) : String { matcher.reset(s); by = by.split("$$").join("\\$"); return isGlobal ? matcher.replaceAll(by) : matcher.replaceFirst(by); } public function map( s : String, f : EReg -> String ) : String { var offset = 0; var buf = new StringBuf(); do { if (offset >= s.length) break; else if (!matchSub(s, offset)) { buf.add(s.substr(offset)); break; } var p = matchedPos(); buf.add(s.substr(offset, p.pos - offset)); buf.add(f(this)); if (p.len == 0) { buf.add(s.substr(p.pos, 1)); offset = p.pos + 1; } else offset = p.pos + p.len; } while (isGlobal); if (!isGlobal && offset > 0 && offset < s.length) buf.add(s.substr(offset)); return buf.toString(); } } haxe_3.2.1+dfsg.orig/std/java/_std/Math.hx0000664000175000017500000000442112607337712020223 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi @:native("java.lang.Math") extern class Math { static var PI(default,null) : Float; static var NaN(default,null) : Float; static var NEGATIVE_INFINITY(default,null) : Float; static var POSITIVE_INFINITY(default,null) : Float; static function abs(v:Float):Float; static function min(a:Float,b:Float):Float; static function max(a:Float,b:Float):Float; static function sin(v:Float):Float; static function cos(v:Float):Float; static function atan2(y:Float,x:Float):Float; static function tan(v:Float):Float; static function exp(v:Float):Float; static function log(v:Float):Float; static function sqrt(v:Float):Float; static function round(v:Float):Int; static function floor(v:Float):Int; static function ceil(v:Float):Int; static function atan(v:Float):Float; inline static function fround(v:Float):Float { return ffloor(v + 0.5); } static function ffloor(v:Float):Float; static function fceil(v:Float):Float; static function asin(v:Float):Float; static function acos(v:Float):Float; static function pow(v:Float,exp:Float):Float; static function random() : Float; static function isFinite( f : Float ) : Bool; static function isNaN( f : Float ) : Bool; } haxe_3.2.1+dfsg.orig/std/java/_std/Reflect.hx0000664000175000017500000001104112607337712020712 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import java.internal.Function; import java.internal.HxObject; import java.internal.Runtime; import java.Boot; @:keep @:coreApi class Reflect { public static function hasField( o : Dynamic, field : String ) : Bool { if (Std.is(o, IHxObject)) { return untyped (o : IHxObject).__hx_getField(field, false, true, false) != Runtime.undefined; } return Runtime.slowHasField(o, field); } public static function field( o : Dynamic, field : String ) : Dynamic { if (Std.is(o, IHxObject)) { return untyped (o : IHxObject).__hx_getField(field, false, false, false); } return Runtime.slowGetField(o, field, false); } public static function setField( o : Dynamic, field : String, value : Dynamic ) : Void { if (Std.is(o, IHxObject)) { untyped (o : IHxObject).__hx_setField(field, value, false); } else { Runtime.slowSetField(o, field, value); } } public static function getProperty( o : Dynamic, field : String ) : Dynamic { if (Std.is(o, IHxObject)) { return untyped (o : IHxObject).__hx_getField(field, false, false, true); } if (Runtime.slowHasField(o, "get_" + field)) { return Runtime.slowCallField(o, "get_" + field, null); } return Runtime.slowGetField(o, field, false); } public static function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void { if (Std.is(o, IHxObject)) { untyped (o : IHxObject).__hx_setField(field, value, true); } else if (Runtime.slowHasField(o, "set_" + field)) { Runtime.slowCallField(o, "set_" + field, [value]); } else { Runtime.slowSetField(o, field, value); } } public static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array ) : Dynamic { return untyped (func : Function).__hx_invokeDynamic(args); } public static function fields( o : Dynamic ) : Array { if (Std.is(o, IHxObject)) { var ret:Array = []; untyped (o : IHxObject).__hx_getFields(ret); return ret; } else if (Std.is(o, java.lang.Class)) { return Type.getClassFields(cast o); } else { return []; } } public static function isFunction( f : Dynamic ) : Bool { return Std.is(f, Function); } public static function compare( a : T, b : T ) : Int { return Runtime.compare(a, b); } @:access(java.internal.Closure) public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool { if (f1 == f2) { return true; } if (Std.is(f1, Closure) && Std.is(f2, Closure)) { var f1c:Closure = cast f1; var f2c:Closure = cast f2; return Runtime.refEq(f1c.obj, f2c.obj) && f1c.field == f2c.field; } return false; } public static function isObject( v : Dynamic ) : Bool { return v != null && !(Std.is(v, HxEnum) || Std.is(v, Function) || Std.is(v, java.lang.Enum) || Std.is(v, java.lang.Number) || Std.is(v, java.lang.Boolean.BooleanClass)); } public static function isEnumValue( v : Dynamic ) : Bool { return v != null && (Std.is(v, HxEnum) || Std.is(v, java.lang.Enum)); } public static function deleteField( o : Dynamic, field : String ) : Bool { return (Std.is(o, DynamicObject) && (o : DynamicObject).__hx_deleteField(field)); } public static function copy( o : T ) : T { var o2 : Dynamic = {}; for( f in Reflect.fields(o) ) Reflect.setField(o2,f,Reflect.field(o,f)); return cast o2; } @:overload(function( f : Array -> Void ) : Dynamic {}) public static function makeVarArgs( f : Array -> Dynamic ) : Dynamic { return new VarArgsFunction(f); } } haxe_3.2.1+dfsg.orig/std/java/_std/Std.hx0000664000175000017500000001114612607337712020066 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import java.Boot; import java.Lib; import java.internal.Exceptions; @:coreApi @:nativeGen class Std { public static function is( v : Dynamic, t : Dynamic ) : Bool { if (v == null) return t == Dynamic; if (t == null) return false; var clt:java.lang.Class = cast t; if (clt == null) return false; var name:String = clt.getName(); switch(name) { case "double", "java.lang.Double": return untyped __java__('haxe.lang.Runtime.isDouble(v)'); case "int", "java.lang.Integer": return untyped __java__('haxe.lang.Runtime.isInt(v)'); case "boolean", "java.lang.Boolean": return untyped __java__('v instanceof java.lang.Boolean'); case "java.lang.Object": return true; } var clv:java.lang.Class = untyped __java__('v.getClass()'); return clt.isAssignableFrom(clv); } public static function string( s : Dynamic ) : String { return cast(s, String) + ""; } public static inline function int( x : Float ) : Int { return cast x; } @:functionCode(' if (x == null) return null; int ret = 0; int base = 10; int i = 0; int len = x.length(); if (x.startsWith("0") && len > 2) { char c = x.charAt(1); if (c == \'x\' || c == \'X\') { i = 2; base = 16; } } boolean foundAny = i != 0; boolean isNeg = false; for (; i < len; i++) { char c = x.charAt(i); if (!foundAny) { switch(c) { case \'-\': isNeg = true; continue; case \'+\': case \'\\n\': case \'\\t\': case \'\\r\': case \' \': if (isNeg) return null; continue; } } if (c >= \'0\' && c <= \'9\') { if (!foundAny && c == \'0\') { foundAny = true; continue; } ret *= base; foundAny = true; ret += ((int) (c - \'0\')); } else if (base == 16) { if (c >= \'a\' && c <= \'f\') { ret *= base; foundAny = true; ret += ((int) (c - \'a\')) + 10; } else if (c >= \'A\' && c <= \'F\') { ret *= base; foundAny = true; ret += ((int) (c - \'A\')) + 10; } else { break; } } else { break; } } if (foundAny) return isNeg ? -ret : ret; else return null; ') public static function parseInt( x : String ) : Null { return null; } public static function parseFloat( x : String ) : Float { if (x == null) return Math.NaN; x = StringTools.ltrim(x); var found = false, hasDot = false, hasSign = false, hasE = false, hasESign = false, hasEData = false; var i = -1; inline function getch(i:Int):Int return cast (untyped x._charAt(i) : java.StdTypes.Char16); while (++i < x.length) { var chr = getch(i); if (chr >= '0'.code && chr <= '9'.code) { if (hasE) { hasEData = true; } found = true; } else switch (chr) { case 'e'.code | 'E'.code if(!hasE): hasE = true; case '.'.code if (!hasDot): hasDot = true; case '-'.code, '+'.code if (!found && !hasSign): hasSign = true; case '-'.code | '+'.code if (found && !hasESign && hasE && !hasEData): hasESign = true; case _: break; } } if (hasE && !hasEData) { i--; if (hasESign) i--; } if (i != x.length) { x = x.substr(0,i); } return try java.lang.Double.DoubleClass.parseDouble(x) catch(e:Dynamic) Math.NaN; } inline public static function instance( value : T, c : Class ) : S { return Std.is(value, c) ? cast value : null; } public static function random( x : Int ) : Int { if (x <= 0) return 0; return Std.int(Math.random() * x); } } haxe_3.2.1+dfsg.orig/std/java/_std/String.hx0000664000175000017500000000425012607337712020600 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi extern class String implements java.lang.CharSequence { var length(default,null) : Int; @:overload(function(b:haxe.io.BytesData, offset:Int, length:Int, charsetName:String):Void { }) @:overload(function(b:haxe.io.BytesData, offset:Int, length:Int):Void { }) function new(string:String) : Void; function toUpperCase() : String; function toLowerCase() : String; function charAt( index : Int) : String; function charCodeAt( index : Int) : Null; function indexOf( str : String, ?startIndex : Int ) : Int; function lastIndexOf( str : String, ?startIndex : Int ) : Int; function split( delimiter : String ) : Array; function substr( pos : Int, ?len : Int ) : String; function substring( startIndex : Int, ?endIndex : Int ) : String; function toString() : String; private function compareTo( anotherString : String ) : Int; private function codePointAt( idx : Int ) : Int; @:overload(function() : haxe.io.BytesData { }) private function getBytes(encoding:String) : haxe.io.BytesData; static function fromCharCode( code : Int ) : String; } haxe_3.2.1+dfsg.orig/std/java/_std/StringBuf.hx0000664000175000017500000000350412607337712021236 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class StringBuf { private var b : java.lang.StringBuilder; public var length(get,never) : Int; public function new() : Void { b = new java.lang.StringBuilder(); } inline function get_length() : Int { return b.length(); } public function add( x : T ) : Void { if (Std.is(x, Int)) { var x:Int = cast x; var xd:Dynamic = x; b.append(xd); } else { b.append(x); } } public function addSub( s : String, pos : Int, ?len : Int ) : Void { var l:Int = (len == null) ? s.length - pos : len; b.append(s, pos, pos + l); } public function addChar( c : Int ) : Void untyped { b.append(cast(c, java.StdTypes.Char16)); } public function toString() : String { return b.toString(); } } haxe_3.2.1+dfsg.orig/std/java/_std/Sys.hx0000664000175000017500000001011012607337712020100 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import java.lang.System; import sys.io.Process; using haxe.Int64; @:coreApi class Sys { private static var _args:java.NativeArray; private static var _env:haxe.ds.StringMap; private static var _sysName:String; public static inline function print( v : Dynamic ) : Void { java.lang.System.out.print(v); } public static inline function println( v : Dynamic ) : Void { java.lang.System.out.println(v); } public static function args() : Array { if (_args == null) return []; return java.Lib.array(_args); } public static function getEnv( s : String ) : String { return java.lang.System.getenv(s); } public static function putEnv( s : String, v : String ) : Void { //java offers no support for it (!) throw "Not implemented in this platform"; } public static function environment() : Map { if (_env != null) return _env; var _env = _env = new haxe.ds.StringMap(); for (mv in java.lang.System.getenv().entrySet()) { _env.set(mv.getKey(), mv.getValue()); } return _env; } public static function sleep( seconds : Float ) : Void { try java.lang.Thread.sleep(cast seconds * 1000) catch (e:Dynamic) throw e; } public static function setTimeLocale( loc : String ) : Bool { return false; } public static function getCwd() : String { return new java.io.File(".").getAbsolutePath().substr(0,-1); } public static function setCwd( s : String ) : Void { //java offers no support for it (!) throw "not implemented"; } public static function systemName() : String { if (_sysName != null) return _sysName; var sname = System.getProperty("os.name").toLowerCase(); if (sname.indexOf("win") >= 0) return _sysName = "Windows"; if (sname.indexOf("mac") >= 0) return _sysName = "Mac"; if (sname.indexOf("nux") >= 0) return _sysName = "Linux"; if (sname.indexOf("nix") >= 0) return _sysName = "BSD"; return _sysName = System.getProperty("os.name"); } public static function command( cmd : String, ?args : Array ) : Int { var proc:Process = new Process(cmd, args == null ? [] : args); var ret = proc.exitCode(); proc.close(); return ret; } public static function exit( code : Int ) : Void { System.exit(code); } public static function time() : Float { return cast(System.currentTimeMillis().div(Int64.ofInt(1000)), Float); } public static function cpuTime() : Float { return cast(System.nanoTime(), Float) / 1000000000; } public static function executablePath() : String { return getCwd(); } public static function getChar( echo : Bool ) : Int { //TODO return throw "Not implemented"; } public static function stdin() : haxe.io.Input { var _in:java.io.InputStream = Reflect.field(System, "in"); return new java.io.NativeInput(_in); } public static function stdout() : haxe.io.Output { return new java.io.NativeOutput(System.out); } public static function stderr() : haxe.io.Output { return new java.io.NativeOutput(System.err); } } haxe_3.2.1+dfsg.orig/std/java/_std/Type.hx0000664000175000017500000002644012607337712020260 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import java.internal.HxObject; using StringTools; @:keep enum ValueType { TNull; TInt; TFloat; TBool; TObject; TFunction; TClass( c : Class ); TEnum( e : Enum ); TUnknown; } @:keep @:coreApi class Type { public static function getClass( o : T ) : Class { if (o == null || Std.is(o, DynamicObject) || Std.is(o, java.lang.Class)) { return null; } return cast java.Lib.getNativeType(o); } public static function getEnum( o : EnumValue ) : Enum { if (Std.is(o, java.lang.Enum) || Std.is(o, HxEnum)) { return untyped o.getClass(); } return null; } public static function getSuperClass( c : Class ) : Class { var c = java.Lib.toNativeType(c); var cl:java.lang.Class = c == null ? null : untyped c.getSuperclass(); if (cl != null && cl.getName() != "haxe.lang.HxObject" && cl.getName() != "java.lang.Object") { return cast cl; } return null; } public static function getClassName( c : Class ) : String { var c : java.lang.Class = cast c; var name:String = c.getName(); if (name.startsWith("haxe.root.")) return name.substr(10); if (name.startsWith("java.lang")) name = name.substr(10); return switch(name) { case "int", "Integer": "Int"; case "double", "Double": "Float"; case "Object": "Dynamic"; default: name; } } public static function getEnumName( e : Enum ) : String { var c : java.lang.Class = cast e; var ret:String = c.getName(); if (ret.startsWith("haxe.root.")) return ret.substr(10); else if (ret == "boolean" || ret == "java.lang.Boolean") return "Bool"; return ret; } public static function resolveClass( name : String ) : Class { try { if (name.indexOf(".") == -1) { name = "haxe.root." +name; } return cast java.lang.Class.forName(name); } catch (e:java.lang.ClassNotFoundException) { return untyped switch (name) { case "haxe.root.Int": Int; case "haxe.root.Float": Float; case "haxe.root.String": String; case "haxe.root.Math": java.lang.Math; case "haxe.root.Class": java.lang.Class; case "haxe.root.Dynamic": java.lang.Object; case _: null; } } } @:functionCode(' if ("Bool".equals(name)) return boolean.class; Class r = resolveClass(name); if (r != null && (r.getSuperclass() == java.lang.Enum.class || haxe.lang.Enum.class.isAssignableFrom(r))) return r; return null; ') public static function resolveEnum( name : String ) : Enum untyped { if (name == "Bool") return Bool; return resolveClass(name); } @:functionCode(' int len = args.length; java.lang.Class[] cls = new java.lang.Class[len]; java.lang.Object[] objs = new java.lang.Object[len]; java.lang.reflect.Constructor[] ms = cl.getConstructors(); int msl = ms.length; int realMsl = 0; for(int i =0; i < msl; i++) { if (!ms[i].isVarArgs() && ms[i].getParameterTypes().length != len) { ms[i] = null; } else { ms[realMsl] = ms[i]; if (realMsl != i) ms[i] = null; realMsl++; } } boolean hasNumber = false; for (int i = 0; i < len; i++) { Object o = args.__get(i); objs[i]= o; cls[i] = o.getClass(); boolean isNum = false; if (o instanceof java.lang.Number) { cls[i] = java.lang.Number.class; isNum = hasNumber = true; } msl = realMsl; realMsl = 0; for (int j = 0; j < msl; j++) { java.lang.Class[] allcls = ms[j].getParameterTypes(); if (i < allcls.length) { if (! ((isNum && allcls[i].isPrimitive()) || allcls[i].isAssignableFrom(cls[i])) ) { ms[j] = null; } else { ms[realMsl] = ms[j]; if (realMsl != j) ms[j] = null; realMsl++; } } } } java.lang.reflect.Constructor found = ms[0]; if (hasNumber) { java.lang.Class[] allcls = found.getParameterTypes(); for (int i = 0; i < len; i++) { java.lang.Object o = objs[i]; if (o instanceof java.lang.Number) { java.lang.Class curCls = null; if (i < allcls.length) { curCls = allcls[i]; if (!curCls.isAssignableFrom(o.getClass())) { String name = curCls.getName(); if (name.equals("double") || name.equals("java.lang.Double")) { objs[i] = ((java.lang.Number)o).doubleValue(); } else if (name.equals("int") || name.equals("java.lang.Integer")) { objs[i] = ((java.lang.Number)o).intValue(); } else if (name.equals("float") || name.equals("java.lang.Float")) { objs[i] = ((java.lang.Number)o).floatValue(); } else if (name.equals("byte") || name.equals("java.lang.Byte")) { objs[i] = ((java.lang.Number)o).byteValue(); } else if (name.equals("short") || name.equals("java.lang.Short")) { objs[i] = ((java.lang.Number)o).shortValue(); } } } //else varargs not handled TODO } } } try { found.setAccessible(true); return (T) found.newInstance(objs); } catch (java.lang.reflect.InvocationTargetException e) { throw haxe.lang.HaxeException.wrap(e.getCause()); } catch (Throwable t) { throw haxe.lang.HaxeException.wrap(t); } ') public static function createInstance( cl : Class, args : Array ) : T untyped { return null; } public static function createEmptyInstance( cl : Class ) : T untyped { if (Reflect.hasField(cl, "__hx_createEmpty")) return cl.__hx_createEmpty(); return createInstance(cl, []); } @:functionCode(' if (params == null || params.length == 0) { java.lang.Object ret = haxe.lang.Runtime.slowGetField(e, constr, true); if (ret instanceof haxe.lang.Function) throw haxe.lang.HaxeException.wrap("Constructor " + constr + " needs parameters"); return (T) ret; } else { return (T) haxe.lang.Runtime.slowCallField(e, constr, params); } ') public static function createEnum( e : Enum, constr : String, ?params : Array ) : T { return null; } public static function createEnumIndex( e : Enum, index : Int, ?params : Array ) : T { var constr = getEnumConstructs(e); return createEnum(e, constr[index], params); } @:functionCode(' if (c == java.lang.String.class) { return haxe.lang.StringRefl.fields; } Array ret = new Array(); for (java.lang.reflect.Field f : c.getFields()) { java.lang.String fname = f.getName(); if (!java.lang.reflect.Modifier.isStatic(f.getModifiers()) && !fname.startsWith("__hx_")) ret.push(fname); } for (java.lang.reflect.Method m : c.getMethods()) { if (m.getDeclaringClass() == java.lang.Object.class) continue; java.lang.String mname = m.getName(); if (!java.lang.reflect.Modifier.isStatic(m.getModifiers()) && !mname.startsWith("__hx_")) ret.push(mname); } return ret; ') public static function getInstanceFields( c : Class ) : Array { return null; } @:functionCode(' Array ret = new Array(); if (c == java.lang.String.class) { ret.push("fromCharCode"); return ret; } for (java.lang.reflect.Field f : c.getDeclaredFields()) { java.lang.String fname = f.getName(); if (java.lang.reflect.Modifier.isStatic(f.getModifiers()) && !fname.startsWith("__hx_")) ret.push(fname); } for (java.lang.reflect.Method m : c.getDeclaredMethods()) { if (m.getDeclaringClass() == java.lang.Object.class) continue; java.lang.String mname = m.getName(); if (java.lang.reflect.Modifier.isStatic(m.getModifiers()) && !mname.startsWith("__hx_")) ret.push(mname); } return ret; ') public static function getClassFields( c : Class ) : Array { return null; } public static function getEnumConstructs( e : Enum ) : Array { if (Reflect.hasField(e, "__hx_constructs")) { var ret:Array = java.Lib.array(untyped e.__hx_constructs); return ret.copy(); } var vals:java.NativeArray> = untyped e.values(), ret = []; for (i in 0...vals.length) ret[i] = vals[i].name(); return ret; } @:functionCode(' if (v == null) return ValueType.TNull; if (v instanceof haxe.lang.IHxObject) { haxe.lang.IHxObject vobj = (haxe.lang.IHxObject) v; java.lang.Class cl = vobj.getClass(); if (v instanceof haxe.lang.DynamicObject) return ValueType.TObject; else return ValueType.TClass(cl); } else if (v instanceof java.lang.Number) { java.lang.Number n = (java.lang.Number) v; if (n.intValue() == n.doubleValue()) return ValueType.TInt; else return ValueType.TFloat; } else if (v instanceof haxe.lang.Function) { return ValueType.TFunction; } else if (v instanceof java.lang.Enum || v instanceof haxe.lang.Enum) { return ValueType.TEnum(v.getClass()); } else if (v instanceof java.lang.Boolean) { return ValueType.TBool; } else if (v instanceof java.lang.Class) { return ValueType.TObject; } else { return ValueType.TClass(v.getClass()); } ') public static function typeof( v : Dynamic ) : ValueType untyped { return null; } @:functionCode(' if (a instanceof haxe.lang.Enum) return a.equals(b); else return haxe.lang.Runtime.eq(a, b); ') public static function enumEq( a : T, b : T ) : Bool untyped { return a == b; } @:functionCode(' if (e instanceof java.lang.Enum) return ((java.lang.Enum) e).name(); else return ((haxe.lang.Enum) e).getTag(); ') public static function enumConstructor( e : EnumValue ) : String untyped { return null; } @:functionCode(' return ( e instanceof java.lang.Enum ) ? new haxe.root.Array() : ((haxe.lang.Enum) e).getParams(); ') public static function enumParameters( e : EnumValue ) : Array untyped { return null; } @:functionCode(' if (e instanceof java.lang.Enum) return ((java.lang.Enum) e).ordinal(); else return ((haxe.lang.Enum) e).index; ') public static function enumIndex( e : EnumValue ) : Int untyped { return e.index; } public static function allEnums( e : Enum ) : Array { var ctors = getEnumConstructs(e); var ret = []; for (ctor in ctors) { var v = Reflect.field(e, ctor); if (Std.is(v, e)) ret.push(v); } return ret; } } haxe_3.2.1+dfsg.orig/std/java/_std/haxe/Int64.hx0000664000175000017500000001634612607337712021174 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; using haxe.Int64; private typedef __Int64 = java.StdTypes.Int64; @:coreApi abstract Int64(__Int64) from __Int64 to __Int64 { public static inline function make( high : Int32, low : Int32 ) : Int64 return new Int64( (cast(high, __Int64) << 32) | (cast(low, __Int64)& untyped __java__('0xffffffffL')) ); private inline function new(x : __Int64) this = x; private var val( get, set ) : __Int64; inline function get_val() : __Int64 return this; inline function set_val( x : __Int64 ) : __Int64 return this = x; public var high( get, never ):Int32; public inline function get_high():Int32 return cast(this >> 32); public var low( get, never ):Int32; public inline function get_low():Int32 return cast this; public inline function copy():Int64 return new Int64( this ); @:from public static inline function ofInt( x : Int ) : Int64 return cast x; inline public static function is( val : Dynamic ) : Bool return Std.is(val,java.lang.Long.LongClass); public static inline function toInt( x : Int64 ) : Int { if( x.val < 0x80000000 || x.val > 0x7FFFFFFF ) throw "Overflow"; return cast x.val; } public static inline function getHigh( x : Int64 ) : Int32 return cast( x.val >> 32 ); public static inline function getLow( x : Int64 ) : Int32 return cast( x.val ); public static inline function isNeg( x : Int64 ) : Bool return x.val < 0; public static inline function isZero( x : Int64 ) : Bool return x.val == 0; public static inline function compare( a : Int64, b : Int64 ) : Int { if( a.val < b.val ) return -1; if( a.val > b.val ) return 1; return 0; } public static inline function ucompare( a : Int64, b : Int64 ) : Int { if( a.val < 0 ) return ( b.val < 0 ) ? compare( a, b ) : 1; return ( b.val < 0 ) ? -1 : compare( a, b ); } public static inline function toStr( x : Int64 ) : String return '${x.val}'; public static inline function divMod( dividend : Int64, divisor : Int64 ) : { quotient : Int64, modulus : Int64 } return { quotient: dividend / divisor, modulus: dividend % divisor }; private inline function toString() : String return '$this'; @:op(-A) public static function neg( x : Int64 ) : Int64 return -x.val; @:op(++A) private inline function preIncrement() : Int64 return ++this; @:op(A++) private inline function postIncrement() : Int64 return this++; @:op(--A) private inline function preDecrement() : Int64 return --this; @:op(A--) private inline function postDecrement() : Int64 return this--; @:op(A + B) public static inline function add( a : Int64, b : Int64 ) : Int64 return a.val + b.val; @:op(A + B) @:commutative private static inline function addInt( a : Int64, b : Int ) : Int64 return a.val + b; @:op(A - B) public static inline function sub( a : Int64, b : Int64 ) : Int64 return a.val - b.val; @:op(A - B) private static inline function subInt( a : Int64, b : Int ) : Int64 return a.val - b; @:op(A - B) private static inline function intSub( a : Int, b : Int64 ) : Int64 return a - b.val; @:op(A * B) public static inline function mul( a : Int64, b : Int64 ) : Int64 return a.val * b.val; @:op(A * B) @:commutative private static inline function mulInt( a : Int64, b : Int ) : Int64 return a.val * b; @:op(A / B) public static inline function div( a : Int64, b : Int64 ) : Int64 return a.val / b.val; @:op(A / B) private static inline function divInt( a : Int64, b : Int ) : Int64 return a.val / b; @:op(A / B) private static inline function intDiv( a : Int, b : Int64 ) : Int64 return a / b.val; @:op(A % B) public static inline function mod( a : Int64, b : Int64 ) : Int64 return a.val % b.val; @:op(A % B) private static inline function modInt( a : Int64, b : Int ) : Int64 return a.val % b; @:op(A % B) private static inline function intMod( a : Int, b : Int64 ) : Int64 return a % b.val; @:op(A == B) public static inline function eq( a : Int64, b : Int64 ) : Bool return a.val == b.val; @:op(A == B) @:commutative private static inline function eqInt( a : Int64, b : Int ) : Bool return a.val == b; @:op(A != B) public static inline function neq( a : Int64, b : Int64 ) : Bool return a.val != b.val; @:op(A != B) @:commutative private static inline function neqInt( a : Int64, b : Int ) : Bool return a.val != b; @:op(A < B) private static inline function lt( a : Int64, b : Int64 ) : Bool return a.val < b.val; @:op(A < B) private static inline function ltInt( a : Int64, b : Int ) : Bool return a.val < b; @:op(A < B) private static inline function intLt( a : Int, b : Int64 ) : Bool return a < b.val; @:op(A <= B) private static inline function lte( a : Int64, b : Int64 ) : Bool return a.val <= b.val; @:op(A <= B) private static inline function lteInt( a : Int64, b : Int ) : Bool return a.val <= b; @:op(A <= B) private static inline function intLte( a : Int, b : Int64 ) : Bool return a <= b.val; @:op(A > B) private static inline function gt( a : Int64, b : Int64 ) : Bool return a.val > b.val; @:op(A > B) private static inline function gtInt( a : Int64, b : Int ) : Bool return a.val > b; @:op(A > B) private static inline function intGt( a : Int, b : Int64 ) : Bool return a > b.val; @:op(A >= B) private static inline function gte( a : Int64, b : Int64 ) : Bool return a.val >= b.val; @:op(A >= B) private static inline function gteInt( a : Int64, b : Int ) : Bool return a.val >= b; @:op(A >= B) private static inline function intGte( a : Int, b : Int64 ) : Bool return a >= b.val; @:op(~A) private static inline function complement( x : Int64 ) : Int64 return ~x.val; @:op(A & B) public static inline function and( a : Int64, b : Int64 ) : Int64 return a.val & b.val; @:op(A | B) public static inline function or( a : Int64, b : Int64 ) : Int64 return a.val | b.val; @:op(A ^ B) public static inline function xor( a : Int64, b : Int64 ) : Int64 return a.val ^ b.val; @:op(A << B) public static inline function shl( a : Int64, b : Int ) : Int64 return a.val << b; @:op(A >> B) public static inline function shr( a : Int64, b : Int ) : Int64 return a.val >> b; @:op(A >>> B) public static inline function ushr( a : Int64, b : Int ) : Int64 return a.val >>> b; } haxe_3.2.1+dfsg.orig/std/java/_std/haxe/Resource.hx0000664000175000017500000000372212607337712022051 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; @:coreApi class Resource { @:keep static var content : Array; public static inline function listNames() : Array { return content.copy(); } @:access(haxe.io.Path.escape) public static function getString( name : String ) : String { name = haxe.io.Path.escape(name, true); var stream = cast(Resource, java.lang.Class).getResourceAsStream("/" + name); if (stream == null) return null; var stream = new java.io.NativeInput(stream); return stream.readAll().toString(); } @:access(haxe.io.Path.escape) public static function getBytes( name : String ) : haxe.io.Bytes { name = haxe.io.Path.escape(name, true); var stream = cast(Resource, java.lang.Class).getResourceAsStream("/" + name); if (stream == null) return null; var stream = new java.io.NativeInput(stream); return stream.readAll(); } } haxe_3.2.1+dfsg.orig/std/java/_std/haxe/ds/IntMap.hx0000664000175000017500000002456312607337712022066 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; import java.NativeArray; /* * This IntMap implementation is based on khash (https://github.com/attractivechaos/klib/blob/master/khash.h) * Copyright goes to Attractive Chaos and his contributors * * Thanks also to Jonas Malaco Filho for his Haxe-written IntMap code inspired by Python tables. * (https://jonasmalaco.com/fossil/test/jonas-haxe/artifact/887b53126e237d6c68951111d594033403889304) */ @:coreApi class IntMap implements haxe.Constraints.IMap { private static inline var HASH_UPPER = 0.7; private var flags:NativeArray; private var _keys:NativeArray; private var vals:NativeArray; private var nBuckets:Int; private var size:Int; private var nOccupied:Int; private var upperBound:Int; private var cachedKey:Int; private var cachedIndex:Int; public function new() : Void { cachedIndex = -1; } public function set( key : Int, value : T ) : Void { var x:Int; if (nOccupied >= upperBound) { if (nBuckets > (size << 1)) resize(nBuckets - 1); //clear "deleted" elements else resize(nBuckets + 1); } var flags = flags, _keys = _keys; { var mask = nBuckets - 1; var site = x = nBuckets; var k = hash(key); var i = k & mask; var delKey = -1; //for speed up if (flagIsEmpty(flags, i)) { x = i; } else { var inc = getInc(k, mask); var last = i; while (! (flagIsEmpty(flags, i) || _keys[i] == key) ) { if (flagIsDel(flags,i) && delKey == -1) delKey = i; i = (i + inc) & mask; #if DEBUG_HASHTBL if (i == last) { throw "assert"; } #end } if (flagIsEmpty(flags, i) && delKey != -1) x = delKey; else x = i; } } if (flagIsEmpty(flags, x)) { _keys[x] = key; vals[x] = value; setIsBothFalse(flags, x); size++; nOccupied++; } else if (flagIsDel(flags, x)) { _keys[x] = key; vals[x] = value; setIsBothFalse(flags, x); size++; } else { assert(_keys[x] == key); vals[x] = value; } } @:final private function lookup( key : Int ) : Int { if (nBuckets != 0) { var flags = flags, _keys = _keys; var mask = nBuckets - 1, k = hash(key); var i = k & mask; var inc = getInc(k, mask); /* inc == 1 for linear probing */ var last = i; while (!flagIsEmpty(flags, i) && (flagIsDel(flags, i) || _keys[i] != key)) { i = (i + inc) & mask; if (i == last) return -1; } return isEither(flags, i) ? -1 : i; } return -1; } public function get( key : Int ) : Null { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return vals[idx]; } return null; } private function getDefault( key : Int, def : T ) : T { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return vals[idx]; } return def; } public function exists( key : Int ) : Bool { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return true; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return true; } return false; } public function remove( key : Int ) : Bool { var idx = -1; if (! (cachedKey == key && ( (idx = cachedIndex) != -1 ))) { idx = lookup(key); } if (idx == -1) { return false; } else { if (cachedKey == key) cachedIndex = -1; if (!isEither(flags, idx)) { setIsDelTrue(flags, idx); --size; vals[idx] = null; _keys[idx] = 0; } return true; } } @:final private function resize(newNBuckets:Int) : Void { //This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. var newFlags = null; var j = 1; { newNBuckets = roundUp(newNBuckets); if (newNBuckets < 4) newNBuckets = 4; if (size >= (newNBuckets * HASH_UPPER + 0.5)) /* requested size is too small */ { j = 0; } else { /* hash table size to be changed (shrink or expand); rehash */ var nfSize = flagsSize(newNBuckets); newFlags = new NativeArray( nfSize ); for (i in 0...nfSize) newFlags[i] = 0xaaaaaaaa; if (nBuckets < newNBuckets) //expand { var k = new NativeArray(newNBuckets); if (_keys != null) arrayCopy(_keys, 0, k, 0, nBuckets); _keys = k; var v = new NativeArray(newNBuckets); if (vals != null) arrayCopy(vals, 0, v, 0, nBuckets); vals = v; } //otherwise shrink } } if (j != 0) { //rehashing is required //resetting cache cachedKey = 0; cachedIndex = -1; j = -1; var nBuckets = nBuckets, _keys = _keys, vals = vals, flags = flags; var newMask = newNBuckets - 1; while (++j < nBuckets) { if (!isEither(flags, j)) { var key = _keys[j]; var val = vals[j]; setIsDelTrue(flags, j); while (true) /* kick-out process; sort of like in Cuckoo hashing */ { var k = hash(key); var inc = getInc(k, newMask); var i = k & newMask; while (!flagIsEmpty(newFlags, i)) i = (i + inc) & newMask; setIsEmptyFalse(newFlags, i); if (i < nBuckets && !isEither(flags, i)) /* kick out the existing element */ { { var tmp = _keys[i]; _keys[i] = key; key = tmp; } { var tmp = vals[i]; vals[i] = val; val = tmp; } setIsDelTrue(flags, i); /* mark it as deleted in the old hash table */ } else { /* write the element and jump out of the loop */ _keys[i] = key; vals[i] = val; break; } } } } if (nBuckets > newNBuckets) /* shrink the hash table */ { { var k = new NativeArray(newNBuckets); arrayCopy(_keys, 0, k, 0, newNBuckets); this._keys = k; } { var v = new NativeArray(newNBuckets); arrayCopy(vals, 0, v, 0, newNBuckets); this.vals = v; } } this.flags = newFlags; this.nBuckets = newNBuckets; this.nOccupied = size; this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5); } } /** Returns an iterator of all keys in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function keys() : Iterator { var i = 0; var len = nBuckets; return { hasNext: function() { for (j in i...len) { if (!isEither(flags, j)) { i = j; return true; } } return false; }, next: function() { var ret = _keys[i]; cachedIndex = i; cachedKey = ret; i = i + 1; return ret; } }; } /** Returns an iterator of all values in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function iterator() : Iterator { var i = 0; var len = nBuckets; return { hasNext: function() { for (j in i...len) { if (!isEither(flags, j)) { i = j; return true; } } return false; }, next: function() { var ret = vals[i]; i = i + 1; return ret; } }; } /** Returns an displayable representation of the hashtable content. **/ public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(i); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } private static inline function assert(x:Bool):Void { #if debug if (!x) throw "assert failed"; #end } private static inline function defaultK():Int return 0; private static inline function arrayCopy(sourceArray:Dynamic, sourceIndex:Int, destinationArray:Dynamic, destinationIndex:Int, length:Int):Void java.lang.System.arraycopy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); private static inline function getInc(k:Int, mask:Int):Int return (((k) >> 3 ^ (k) << 3) | 1) & (mask); private static inline function hash(i:Int):Int return i; private static inline function flagIsEmpty(flag:NativeArray, i:Int):Bool return ( (flag[i >> 4] >>> ((i & 0xf) << 1)) & 2 ) != 0; private static inline function flagIsDel(flag:NativeArray, i:Int):Bool return ((flag[i >> 4] >>> ((i & 0xf) << 1)) & 1) != 0; private static inline function isEither(flag:NativeArray, i:Int):Bool return ((flag[i >> 4] >>> ((i & 0xf) << 1)) & 3) != 0; private static inline function setIsDelFalse(flag:NativeArray, i:Int):Void flag[i >> 4] &= ~(1 << ((i & 0xf) << 1)); private static inline function setIsEmptyFalse(flag:NativeArray, i:Int):Void flag[i >> 4] &= ~(2 << ((i & 0xf) << 1)); private static inline function setIsBothFalse(flag:NativeArray, i:Int):Void flag[i >> 4] &= ~(3 << ((i & 0xf) << 1)); private static inline function setIsDelTrue(flag:NativeArray, i:Int):Void flag[i >> 4] |= 1 << ((i & 0xf) << 1); private static inline function roundUp(x:Int):Int { --x; x |= (x) >>> 1; x |= (x) >>> 2; x |= (x) >>> 4; x |= (x) >>> 8; x |= (x) >>> 16; return ++x; } private static inline function flagsSize(m:Int):Int return ((m) < 16? 1 : (m) >> 4); } haxe_3.2.1+dfsg.orig/std/java/_std/haxe/ds/ObjectMap.hx0000664000175000017500000002535512607337712022542 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; import java.NativeArray; @:coreApi class ObjectMap implements haxe.Constraints.IMap { @:extern private static inline var HASH_UPPER = 0.77; @:extern private static inline var FLAG_EMPTY = 0; @:extern private static inline var FLAG_DEL = 1; /** * This is the most important structure here and the reason why it's so fast. * It's an array of all the hashes contained in the table. These hashes cannot be 0 nor 1, * which stand for "empty" and "deleted" states. * * The lookup algorithm will keep looking until a 0 or the key wanted is found; * The insertion algorithm will do the same but will also break when FLAG_DEL is found; */ private var hashes:NativeArray; private var _keys:NativeArray; private var vals:NativeArray; private var nBuckets:Int; private var size:Int; private var nOccupied:Int; private var upperBound:Int; private var cachedKey:K; private var cachedIndex:Int; #if DEBUG_HASHTBL private var totalProbes:Int; private var probeTimes:Int; private var sameHash:Int; private var maxProbe:Int; #end public function new() : Void { cachedIndex = -1; } public function set( key : K, value : V ) : Void { var x:Int, k:Int; if (nOccupied >= upperBound) { if (nBuckets > (size << 1)) resize(nBuckets - 1); //clear "deleted" elements else resize(nBuckets + 2); } var hashes = hashes, keys = _keys, hashes = hashes; { var mask = (nBuckets == 0) ? 0 : nBuckets - 1; var site = x = nBuckets; k = hash(key); var i = k & mask, nProbes = 0; var delKey = -1; //for speed up if (isEmpty(hashes[i])) { x = i; } else { //var inc = getInc(k, mask); var last = i, flag; while(! (isEmpty(flag = hashes[i]) || (flag == k && untyped keys[i].equals(key))) ) { if (isDel(flag) && delKey == -1) delKey = i; i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } if (isEmpty(flag) && delKey != -1) x = delKey; else x = i; } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end } var flag = hashes[x]; if (isEmpty(flag)) { keys[x] = key; vals[x] = value; hashes[x] = k; size++; nOccupied++; } else if (isDel(flag)) { keys[x] = key; vals[x] = value; hashes[x] = k; size++; } else { assert(keys[x] == key); vals[x] = value; } cachedIndex = x; cachedKey = key; } @:final private function lookup( key : K ) : Int { if (nBuckets != 0) { var hashes = hashes, keys = _keys; var mask = nBuckets - 1, hash = hash(key), k = hash, nProbes = 0; var i = k & mask; var last = i, flag; //var inc = getInc(k, mask); while (!isEmpty(flag = hashes[i]) && (isDel(flag) || flag != k || !(untyped keys[i].equals(key)))) { i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end return isEither(flag) ? -1 : i; } return -1; } @:final @:private function resize(newNBuckets:Int) : Void { //This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. var newHash = null; var j = 1; { newNBuckets = roundUp(newNBuckets); if (newNBuckets < 4) newNBuckets = 4; if (size >= (newNBuckets * HASH_UPPER + 0.5)) /* requested size is too small */ { j = 0; } else { /* hash table size to be changed (shrink or expand); rehash */ var nfSize = newNBuckets; newHash = new NativeArray( nfSize ); if (nBuckets < newNBuckets) //expand { var k = new NativeArray(newNBuckets); if (_keys != null) arrayCopy(_keys, 0, k, 0, nBuckets); _keys = k; var v = new NativeArray(newNBuckets); if (vals != null) arrayCopy(vals, 0, v, 0, nBuckets); vals = v; } //otherwise shrink } } if (j != 0) { //rehashing is required //resetting cache cachedKey = null; cachedIndex = -1; j = -1; var nBuckets = nBuckets, _keys = _keys, vals = vals, hashes = hashes; var newMask = newNBuckets - 1; while (++j < nBuckets) { var k; if (!isEither(k = hashes[j])) { var key = _keys[j]; var val = vals[j]; hashes[j] = FLAG_DEL; while (true) /* kick-out process; sort of like in Cuckoo hashing */ { var nProbes = 0; //var inc = getInc(k, newMask); var i = k & newMask; while (!isEmpty(newHash[i])) i = (i + ++nProbes) & newMask; newHash[i] = k; if (i < nBuckets && !isEither(k = hashes[i])) /* kick out the existing element */ { { var tmp = _keys[i]; _keys[i] = key; key = tmp; } { var tmp = vals[i]; vals[i] = val; val = tmp; } hashes[i] = FLAG_DEL; /* mark it as deleted in the old hash table */ } else { /* write the element and jump out of the loop */ _keys[i] = key; vals[i] = val; break; } } } } if (nBuckets > newNBuckets) /* shrink the hash table */ { { var k = new NativeArray(newNBuckets); arrayCopy(_keys, 0, k, 0, newNBuckets); this._keys = k; } { var v = new NativeArray(newNBuckets); arrayCopy(vals, 0, v, 0, newNBuckets); this.vals = v; } } this.hashes = newHash; this.nBuckets = newNBuckets; this.nOccupied = size; this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5); } } public function get( key : K ) : Null { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return vals[idx]; } return null; } private function getDefault( key : K, def : V ) : V { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return vals[idx]; } return def; } public function exists( key : K ) : Bool { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return true; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return true; } return false; } public function remove( key : K ) : Bool { var idx = -1; if (! (cachedKey == key && ( (idx = cachedIndex) != -1 ))) { idx = lookup(key); } if (idx == -1) { return false; } else { if (cachedKey == key) cachedIndex = -1; hashes[idx] = FLAG_DEL; _keys[idx] = null; vals[idx] = null; --size; return true; } } /** Returns an iterator of all keys in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function keys() : Iterator { var i = 0; var len = nBuckets; return { hasNext: function() { for (j in i...len) { if (!isEither(hashes[j])) { i = j; return true; } } return false; }, next: function() { var ret = _keys[i]; cachedIndex = i; cachedKey = ret; i = i + 1; return ret; } }; } /** Returns an iterator of all values in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function iterator() : Iterator { var i = 0; var len = nBuckets; return { hasNext: function() { for (j in i...len) { if (!isEither(hashes[j])) { i = j; return true; } } return false; }, next: function() { var ret = vals[i]; i = i + 1; return ret; } }; } /** Returns an displayable representation of the hashtable content. **/ public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(Std.string(i)); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } @:extern private static inline function roundUp(x:Int):Int { --x; x |= (x) >>> 1; x |= (x) >>> 2; x |= (x) >>> 4; x |= (x) >>> 8; x |= (x) >>> 16; return ++x; } @:extern private static inline function getInc(k:Int, mask:Int):Int //return 1 for linear probing return (((k) >> 3 ^ (k) << 3) | 1) & (mask); @:extern private static inline function isEither(v:HashType):Bool return (v & 0xFFFFFFFE) == 0; @:extern private static inline function isEmpty(v:HashType):Bool return v == FLAG_EMPTY; @:extern private static inline function isDel(v:HashType):Bool return v == FLAG_DEL; //guarantee: Whatever this function is, it will never return 0 nor 1 @:extern private static inline function hash(s:Dynamic):HashType { var k:Int = untyped s.hashCode(); //k *= 357913941; //k ^= k << 24; //k += ~357913941; //k ^= k >> 31; //k ^= k << 31; k = (k+0x7ed55d16) + (k<<12); k = (k^0xc761c23c) ^ (k>>19); k = (k+0x165667b1) + (k<<5); k = (k+0xd3a2646c) ^ (k<<9); k = (k+0xfd7046c5) + (k<<3); k = (k^0xb55a4f09) ^ (k>>16); var ret = k; if (isEither(ret)) { if (ret == 0) ret = 2; else ret = 0xFFFFFFFF; } return ret; } @:extern private static inline function arrayCopy(sourceArray:Dynamic, sourceIndex:Int, destinationArray:Dynamic, destinationIndex:Int, length:Int):Void java.lang.System.arraycopy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); @:extern private static inline function assert(x:Bool):Void { #if DEBUG_HASHTBL if (!x) throw "assert failed"; #end } } private typedef HashType = Int; haxe_3.2.1+dfsg.orig/std/java/_std/haxe/ds/StringMap.hx0000664000175000017500000002536112607337712022577 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; import java.NativeArray; @:coreApi class StringMap implements haxe.Constraints.IMap { @:extern private static inline var HASH_UPPER = 0.77; @:extern private static inline var FLAG_EMPTY = 0; @:extern private static inline var FLAG_DEL = 1; /** * This is the most important structure here and the reason why it's so fast. * It's an array of all the hashes contained in the table. These hashes cannot be 0 nor 1, * which stand for "empty" and "deleted" states. * * The lookup algorithm will keep looking until a 0 or the key wanted is found; * The insertion algorithm will do the same but will also break when FLAG_DEL is found; */ private var hashes:NativeArray; private var _keys:NativeArray; private var vals:NativeArray; private var nBuckets:Int; private var size:Int; private var nOccupied:Int; private var upperBound:Int; private var cachedKey:String; private var cachedIndex:Int; #if DEBUG_HASHTBL private var totalProbes:Int; private var probeTimes:Int; private var sameHash:Int; private var maxProbe:Int; #end public function new() : Void { cachedIndex = -1; } public function set( key : String, value : T ) : Void { var x:Int, k:Int; if (nOccupied >= upperBound) { if (nBuckets > (size << 1)) resize(nBuckets - 1); //clear "deleted" elements else resize(nBuckets + 2); } var hashes = hashes, keys = _keys, hashes = hashes; { var mask = (nBuckets == 0) ? 0 : nBuckets - 1; var site = x = nBuckets; k = hash(key); var i = k & mask, nProbes = 0; var delKey = -1; //for speed up if (isEmpty(hashes[i])) { x = i; } else { //var inc = getInc(k, mask); var last = i, flag; while(! (isEmpty(flag = hashes[i]) || (flag == k && _keys[i] == key)) ) { if (isDel(flag) && delKey == -1) delKey = i; i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } if (isEmpty(flag) && delKey != -1) x = delKey; else x = i; } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end } var flag = hashes[x]; if (isEmpty(flag)) { keys[x] = key; vals[x] = value; hashes[x] = k; size++; nOccupied++; } else if (isDel(flag)) { keys[x] = key; vals[x] = value; hashes[x] = k; size++; } else { assert(_keys[x] == key); vals[x] = value; } cachedIndex = x; cachedKey = key; } @:final private function lookup( key : String ) : Int { if (nBuckets != 0) { var hashes = hashes, keys = _keys; var mask = nBuckets - 1, hash = hash(key), k = hash, nProbes = 0; var i = k & mask; var last = i, flag; //var inc = getInc(k, mask); while (!isEmpty(flag = hashes[i]) && (isDel(flag) || flag != k || keys[i] != key)) { i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end return isEither(flag) ? -1 : i; } return -1; } @:final @:private function resize(newNBuckets:Int) : Void { //This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. var newHash = null; var j = 1; { newNBuckets = roundUp(newNBuckets); if (newNBuckets < 4) newNBuckets = 4; if (size >= (newNBuckets * HASH_UPPER + 0.5)) /* requested size is too small */ { j = 0; } else { /* hash table size to be changed (shrink or expand); rehash */ var nfSize = newNBuckets; newHash = new NativeArray( nfSize ); if (nBuckets < newNBuckets) //expand { var k = new NativeArray(newNBuckets); if (_keys != null) arrayCopy(_keys, 0, k, 0, nBuckets); _keys = k; var v = new NativeArray(newNBuckets); if (vals != null) arrayCopy(vals, 0, v, 0, nBuckets); vals = v; } //otherwise shrink } } if (j != 0) { //rehashing is required //resetting cache cachedKey = null; cachedIndex = -1; j = -1; var nBuckets = nBuckets, _keys = _keys, vals = vals, hashes = hashes; var newMask = newNBuckets - 1; while (++j < nBuckets) { var k; if (!isEither(k = hashes[j])) { var key = _keys[j]; var val = vals[j]; hashes[j] = FLAG_DEL; while (true) /* kick-out process; sort of like in Cuckoo hashing */ { var nProbes = 0; //var inc = getInc(k, newMask); var i = k & newMask; while (!isEmpty(newHash[i])) i = (i + ++nProbes) & newMask; newHash[i] = k; if (i < nBuckets && !isEither(k = hashes[i])) /* kick out the existing element */ { { var tmp = _keys[i]; _keys[i] = key; key = tmp; } { var tmp = vals[i]; vals[i] = val; val = tmp; } hashes[i] = FLAG_DEL; /* mark it as deleted in the old hash table */ } else { /* write the element and jump out of the loop */ _keys[i] = key; vals[i] = val; break; } } } } if (nBuckets > newNBuckets) /* shrink the hash table */ { { var k = new NativeArray(newNBuckets); arrayCopy(_keys, 0, k, 0, newNBuckets); this._keys = k; } { var v = new NativeArray(newNBuckets); arrayCopy(vals, 0, v, 0, newNBuckets); this.vals = v; } } this.hashes = newHash; this.nBuckets = newNBuckets; this.nOccupied = size; this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5); } } public function get( key : String ) : Null { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return vals[idx]; } return null; } private function getDefault( key : String, def : T ) : T { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return vals[idx]; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return vals[idx]; } return def; } public function exists( key : String ) : Bool { var idx = -1; if (cachedKey == key && ( (idx = cachedIndex) != -1 )) { return true; } idx = lookup(key); if (idx != -1) { cachedKey = key; cachedIndex = idx; return true; } return false; } public function remove( key : String ) : Bool { var idx = -1; if (! (cachedKey == key && ( (idx = cachedIndex) != -1 ))) { idx = lookup(key); } if (idx == -1) { return false; } else { if (cachedKey == key) cachedIndex = -1; hashes[idx] = FLAG_DEL; _keys[idx] = null; vals[idx] = null; --size; return true; } } /** Returns an iterator of all keys in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function keys() : Iterator { var i = 0; var len = nBuckets; return { hasNext: function() { for (j in i...len) { if (!isEither(hashes[j])) { i = j; return true; } } return false; }, next: function() { var ret = _keys[i]; cachedIndex = i; cachedKey = ret; i = i + 1; return ret; } }; } /** Returns an iterator of all values in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function iterator() : Iterator { var i = 0; var len = nBuckets; return { hasNext: function() { for (j in i...len) { if (!isEither(hashes[j])) { i = j; return true; } } return false; }, next: function() { var ret = vals[i]; i = i + 1; return ret; } }; } /** Returns an displayable representation of the hashtable content. **/ public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(i); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } @:extern private static inline function roundUp(x:Int):Int { --x; x |= (x) >>> 1; x |= (x) >>> 2; x |= (x) >>> 4; x |= (x) >>> 8; x |= (x) >>> 16; return ++x; } @:extern private static inline function getInc(k:Int, mask:Int):Int //return 1 for linear probing return (((k) >> 3 ^ (k) << 3) | 1) & (mask); @:extern private static inline function isEither(v:HashType):Bool return (v & 0xFFFFFFFE) == 0; @:extern private static inline function isEmpty(v:HashType):Bool return v == FLAG_EMPTY; @:extern private static inline function isDel(v:HashType):Bool return v == FLAG_DEL; //guarantee: Whatever this function is, it will never return 0 nor 1 @:extern private static inline function hash(s:String):HashType { var k:Int = untyped s.hashCode(); //k *= 357913941; //k ^= k << 24; //k += ~357913941; //k ^= k >> 31; //k ^= k << 31; k = (k+0x7ed55d16) + (k<<12); k = (k^0xc761c23c) ^ (k>>19); k = (k+0x165667b1) + (k<<5); k = (k+0xd3a2646c) ^ (k<<9); k = (k+0xfd7046c5) + (k<<3); k = (k^0xb55a4f09) ^ (k>>16); var ret = k; if (isEither(ret)) { if (ret == 0) ret = 2; else ret = 0xFFFFFFFF; } return ret; } @:extern private static inline function arrayCopy(sourceArray:Dynamic, sourceIndex:Int, destinationArray:Dynamic, destinationIndex:Int, length:Int):Void java.lang.System.arraycopy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); @:extern private static inline function assert(x:Bool):Void { #if DEBUG_HASHTBL if (!x) throw "assert failed"; #end } } private typedef HashType = Int; haxe_3.2.1+dfsg.orig/std/java/_std/haxe/ds/WeakMap.hx0000664000175000017500000003037312607337712022217 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; import java.NativeArray; import java.lang.ref.WeakReference; import java.lang.ref.ReferenceQueue; @:coreApi class WeakMap implements haxe.Constraints.IMap { @:extern private static inline var HASH_UPPER = 0.77; @:extern private static inline var FLAG_EMPTY = 0; @:extern private static inline var FLAG_DEL = 1; /** * This is the most important structure here and the reason why it's so fast. * It's an array of all the hashes contained in the table. These hashes cannot be 0 nor 1, * which stand for "empty" and "deleted" states. * * The lookup algorithm will keep looking until a 0 or the key wanted is found; * The insertion algorithm will do the same but will also break when FLAG_DEL is found; */ private var hashes:NativeArray; private var entries:NativeArray>; //weak map specific private var queue:ReferenceQueue; private var nBuckets:Int; private var size:Int; private var nOccupied:Int; private var upperBound:Int; private var cachedEntry:Entry; private var cachedIndex:Int; #if DEBUG_HASHTBL private var totalProbes:Int; private var probeTimes:Int; private var sameHash:Int; private var maxProbe:Int; #end public function new() : Void { cachedIndex = -1; queue = new ReferenceQueue(); } @:analyzer(ignore) private function cleanupRefs():Void { var x:Dynamic = null, nOccupied = nOccupied; while (( x = queue.poll()) != null) { //even if not found on hashtable (already removed), release value var x:Entry = cast x; x.value = null; //lookup index if (nOccupied != 0) { var mask = nBuckets - 1, hash = x.hash, nProbes = 0; var i = hash & mask; var last = i, flag; while(!isEmpty(flag = hashes[i]) && (isDel(flag) || flag != hash || entries[i] != x)) { i = (i + ++nProbes) & mask; } if (entries[i] == x) { if (cachedIndex == i) { cachedIndex = -1; cachedEntry = null; } entries[i] = null; hashes[i] = FLAG_DEL; --size; } } } } public function set( key : K, value : V ) : Void { cleanupRefs(); var x:Int, k:Int; if (nOccupied >= upperBound) { if (nBuckets > (size << 1)) resize(nBuckets - 1); //clear "deleted" elements else resize(nBuckets + 2); } k = hash(key); var hashes = hashes, entries = entries; { var mask = (nBuckets == 0) ? 0 : nBuckets - 1; var site = x = nBuckets; var i = k & mask, nProbes = 0; var delKey = -1; //for speed up if (isEmpty(hashes[i])) { x = i; } else { //var inc = getInc(k, mask); var last = i, flag; while(! (isEmpty(flag = hashes[i]) || (flag == k && entries[i].keyEquals(key) )) ) { if (delKey == -1 && isDel(flag)) delKey = i; i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } if (isEmpty(flag) && delKey != -1) x = delKey; else x = i; } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end } var flag = hashes[x], entry = new Entry(key,value,k,queue); if (isEmpty(flag)) { entries[x] = entry; hashes[x] = k; size++; nOccupied++; } else if (isDel(flag)) { entries[x] = entry; hashes[x] = k; size++; } else { assert(entries[x].keyEquals(key)); entries[x] = entry; } cachedIndex = x; cachedEntry = entry; } @:final private function lookup( key : K ) : Int { if (nBuckets != 0) { var hashes = hashes, entries = entries; var mask = nBuckets - 1, hash = hash(key), k = hash, nProbes = 0; var i = k & mask; var last = i, flag; //var inc = getInc(k, mask); while (!isEmpty(flag = hashes[i]) && (isDel(flag) || flag != k || !entries[i].keyEquals(key))) { i = (i + ++nProbes) & mask; #if DEBUG_HASHTBL probeTimes++; if (i == last) throw "assert"; #end } #if DEBUG_HASHTBL if (nProbes > maxProbe) maxProbe = nProbes; totalProbes++; #end return isEither(flag) ? -1 : i; } return -1; } @:final @:private function resize(newNBuckets:Int) : Void { //This function uses 0.25*n_bucktes bytes of working space instead of [sizeof(key_t+val_t)+.25]*n_buckets. var newHash = null; var j = 1; { newNBuckets = roundUp(newNBuckets); if (newNBuckets < 4) newNBuckets = 4; if (size >= (newNBuckets * HASH_UPPER + 0.5)) /* requested size is too small */ { j = 0; } else { /* hash table size to be changed (shrink or expand); rehash */ var nfSize = newNBuckets; newHash = new NativeArray( nfSize ); if (nBuckets < newNBuckets) //expand { var e = new NativeArray(newNBuckets); if (entries != null) arrayCopy(entries, 0, e, 0, nBuckets); entries = e; } //otherwise shrink } } if (j != 0) { //rehashing is required //resetting cache cachedEntry = null; cachedIndex = -1; j = -1; var nBuckets = nBuckets, entries = entries, hashes = hashes; var newMask = newNBuckets - 1; while (++j < nBuckets) { var k; if (!isEither(k = hashes[j])) { var entry = entries[j]; hashes[j] = FLAG_DEL; while (true) /* kick-out process; sort of like in Cuckoo hashing */ { var nProbes = 0; var i = k & newMask; while (!isEmpty(newHash[i])) i = (i + ++nProbes) & newMask; newHash[i] = k; if (i < nBuckets && !isEither(k = hashes[i])) /* kick out the existing element */ { { var tmp = entries[i]; entries[i] = entry; entry = tmp; } hashes[i] = FLAG_DEL; /* mark it as deleted in the old hash table */ } else { /* write the element and jump out of the loop */ entries[i] = entry; break; } } } } if (nBuckets > newNBuckets) /* shrink the hash table */ { { var e = new NativeArray(newNBuckets); arrayCopy(entries, 0, e, 0, newNBuckets); this.entries = e; } } this.hashes = newHash; this.nBuckets = newNBuckets; this.nOccupied = size; this.upperBound = Std.int(newNBuckets * HASH_UPPER + .5); } } public function get( key : K ) : Null { cleanupRefs(); var idx = -1; if (cachedEntry != null && cachedEntry.keyEquals(key) && ( (idx = cachedIndex) != -1 )) { return cachedEntry.value; } idx = lookup(key); if (idx != -1) { var entry = entries[idx]; cachedEntry = entry; cachedIndex = idx; return entry.value; } return null; } private function getDefault( key : K, def : V ) : V { cleanupRefs(); var idx = -1; if (cachedEntry != null && cachedEntry.keyEquals(key) && ( (idx = cachedIndex) != -1 )) { return cachedEntry.value; } idx = lookup(key); if (idx != -1) { var entry = entries[idx]; cachedEntry = entry; cachedIndex = idx; return entry.value; } return def; } public function exists( key : K ) : Bool { cleanupRefs(); var idx = -1; if (cachedEntry != null && cachedEntry.keyEquals(key) && ( (idx = cachedIndex) != -1 )) { return true; } idx = lookup(key); if (idx != -1) { var entry = entries[idx]; cachedEntry = entry; cachedIndex = idx; return true; } return false; } public function remove( key : K ) : Bool { cleanupRefs(); var idx = -1; if ( !(cachedEntry != null && cachedEntry.keyEquals(key) && ( (idx = cachedIndex) != -1 )) ) { idx = lookup(key); } if (idx == -1) { return false; } else { if (cachedEntry != null && cachedEntry.keyEquals(key)) { cachedIndex = -1; cachedEntry = null; } hashes[idx] = FLAG_DEL; entries[idx] = null; --size; return true; } } /** Returns an iterator of all keys in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function keys() : Iterator { cleanupRefs(); var i = 0; var len = nBuckets; var lastKey = null; //keep a strong reference to the key while iterating, so it can't be collected while iterating return { hasNext: function() { for (j in i...len) { if (!isEither(hashes[j])) { var entry = entries[j]; var last = entry.get(); if (last != null) { lastKey = last; cachedIndex = i; cachedEntry = entry; i = j; return true; } } } return false; }, next: function() { i = i + 1; return lastKey; } }; } /** Returns an iterator of all values in the hashtable. Implementation detail: Do not set() any new value while iterating, as it may cause a resize, which will break iteration **/ public function iterator() : Iterator { cleanupRefs(); var i = 0; var len = nBuckets; return { hasNext: function() { for (j in i...len) { if (!isEither(hashes[j])) { i = j; return true; } } return false; }, next: function() { var ret = entries[i].value; i = i + 1; return ret; } }; } /** Returns an displayable representation of the hashtable content. **/ public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(Std.string(i)); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } @:extern private static inline function roundUp(x:Int):Int { --x; x |= (x) >>> 1; x |= (x) >>> 2; x |= (x) >>> 4; x |= (x) >>> 8; x |= (x) >>> 16; return ++x; } @:extern private static inline function getInc(k:Int, mask:Int):Int //return 1 for linear probing return (((k) >> 3 ^ (k) << 3) | 1) & (mask); @:extern private static inline function isEither(v:HashType):Bool return (v & 0xFFFFFFFE) == 0; @:extern private static inline function isEmpty(v:HashType):Bool return v == FLAG_EMPTY; @:extern private static inline function isDel(v:HashType):Bool return v == FLAG_DEL; //guarantee: Whatever this function is, it will never return 0 nor 1 @:extern private static inline function hash(s:Dynamic):HashType { var k:Int = untyped s.hashCode(); //k *= 357913941; //k ^= k << 24; //k += ~357913941; //k ^= k >> 31; //k ^= k << 31; k = (k+0x7ed55d16) + (k<<12); k = (k^0xc761c23c) ^ (k>>19); k = (k+0x165667b1) + (k<<5); k = (k+0xd3a2646c) ^ (k<<9); k = (k+0xfd7046c5) + (k<<3); k = (k^0xb55a4f09) ^ (k>>16); var ret = k; if (isEither(ret)) { if (ret == 0) ret = 2; else ret = 0xFFFFFFFF; } return ret; } @:extern private static inline function arrayCopy(sourceArray:Dynamic, sourceIndex:Int, destinationArray:Dynamic, destinationIndex:Int, length:Int):Void java.lang.System.arraycopy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); @:extern private static inline function assert(x:Bool):Void { #if DEBUG_HASHTBL if (!x) throw "assert failed"; #end } } private class Entry extends WeakReference { public var value:V; public var hash(default, null):Int; public function new(key:K, value:V, hash:Int, queue:ReferenceQueue) { super(key, queue); this.value = value; this.hash = hash; } @:final inline public function keyEquals(k:K):Bool { return k != null && untyped k.equals(get()); } } private typedef HashType = Int; haxe_3.2.1+dfsg.orig/std/java/_std/haxe/zip/Compress.hx0000664000175000017500000000540112607337712022653 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; import java.util.zip.Deflater; class Compress { var deflater:Deflater; var mode:Int; var finish:Bool = false; public function new( level : Int ) { throw "Not implemented for this platform"; //FIXME: Add unit tests for Compress/Uncompress and check current implementation this.deflater = new Deflater(level); this.mode = Deflater.NO_FLUSH; } public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } { deflater.setInput(src.getData(), srcPos, src.length - srcPos); if (finish) deflater.finish(); finish = false; var written = deflater.deflate(dst.getData(), dstPos, dst.length - dstPos); var read = deflater.getTotalIn(); return { done: deflater.finished(), read: read, write: written }; } public function setFlushMode( f : FlushMode ) { this.mode = switch (f) { case NO: Deflater.NO_FLUSH; case SYNC: Deflater.SYNC_FLUSH; case FULL: Deflater.FULL_FLUSH; case FINISH: this.finish = true; Deflater.FULL_FLUSH; case BLOCK: throw "Not Implemented"; } } public function close() { deflater.end(); } public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes { var deflater = new java.util.zip.Deflater(level); deflater.setInput(s.getData()); var outputStream = new java.io.ByteArrayOutputStream(s.length); deflater.finish(); var buffer = haxe.io.Bytes.alloc(1024).getData(); while (!deflater.finished()) { var count = deflater.deflate(buffer); outputStream.write(buffer, 0, count); } outputStream.close(); return haxe.io.Bytes.ofData(outputStream.toByteArray()); } } haxe_3.2.1+dfsg.orig/std/java/_std/haxe/zip/Uncompress.hx0000664000175000017500000000374612607337712023230 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.zip; class Uncompress { public function new( ?windowBits : Int ) { throw "Not implemented for this platform"; } public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } { return null; } public function setFlushMode( f : FlushMode ) { } public function close() { } public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes { var decompresser = new java.util.zip.Inflater(); var buf = haxe.io.Bytes.alloc(bufsize == null ? src.length : bufsize).getData(); var out = new java.io.ByteArrayOutputStream(src.length); decompresser.setInput(src.getData(), 0, src.length); while (!decompresser.finished()) { var count = decompresser.inflate(buf); out.write(buf, 0, count); } out.close(); return haxe.io.Bytes.ofData(out.toByteArray()); } } haxe_3.2.1+dfsg.orig/std/java/_std/sys/FileSystem.hx0000664000175000017500000000644312607337712022242 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys; import java.io.File; import java.Lib; @:coreApi class FileSystem { public static function exists( path : String ) : Bool { return new File(path).exists(); } public static function rename( path : String, newPath : String ) : Void { if (!new File(path).renameTo(new File(newPath))) { throw "Cannot rename " + path + " to " + newPath; } } public static function stat( path : String ) : FileStat { var f = new File(path); if (!f.exists()) throw "Path " + path + " doesn't exist"; return { gid: 0, //java doesn't let you get this info uid: 0, //same atime: Date.now(), //same mtime: Date.fromTime(cast(f.lastModified(), Float)), ctime: Date.fromTime(cast(f.lastModified(), Float)), //same size: cast(f.length(), Int), //TODO: maybe change to Int64 for Haxe 3? dev: 0, //FIXME: not sure what that is ino: 0, //FIXME: not sure what that is nlink: 0, //FIXME: not sure what that is rdev: 0, //FIXME: not sure what that is mode: 0 //FIXME: not sure what that is }; } public static function fullPath( relPath : String ) : String { try { return new File(relPath).getCanonicalPath(); } catch (e: java.io.IOException) { throw new java.lang.RuntimeException(e); } } public static function absolutePath ( relPath : String ) : String { if (haxe.io.Path.isAbsolute(relPath)) return relPath; return haxe.io.Path.join([Sys.getCwd(), relPath]); } public static function isDirectory( path : String ) : Bool { var f = new File(path); if (!f.exists()) throw "Path " + path + " doesn't exist"; return f.isDirectory(); } public static function createDirectory( path : String ) : Void { if (!new File(path).mkdirs()) throw "Cannot create dir " + path; } public static function deleteFile( path : String ) : Void { if (!new File(path).delete()) throw "Cannot delete file " + path; } public static function deleteDirectory( path : String ) : Void { if (!new File(path).delete()) throw "Cannot delete directory " + path; } public static function readDirectory( path : String ) : Array { var f = new File(path); if (!f.exists()) throw "Path " + path + " doesn't exist"; return Lib.array( f.list() ); } } haxe_3.2.1+dfsg.orig/std/java/_std/sys/db/Mysql.hx0000664000175000017500000000347212607337712021647 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.db; class Mysql { static var init = false; public static function connect( params : { host : String, ?port : Int, user : String, pass : String, ?socket : String, database : String } ) : sys.db.Connection { if (!init) { java.lang.Class.forName("com.mysql.jdbc.Driver"); init = true; } var url = new StringBuf(); url.add('jdbc:mysql:'); if (params.socket != null) { url.add(params.socket); } else { url.add('//'); url.add(params.host); if (params.port != null) url.add(':${params.port}'); } url.add('/${params.database}'); var cnx = java.sql.DriverManager.getConnection(url.toString(), params.user, params.pass); return java.db.Jdbc.create(cnx); } } haxe_3.2.1+dfsg.orig/std/java/_std/sys/db/Sqlite.hx0000664000175000017500000000104612607337712021776 0ustar andyandy00000000000000package sys.db; class Sqlite { static var init = false; /** Opens a new SQLite connection on the specified path. Note that you will need a SQLite JDBC driver (like https://bitbucket.org/xerial/sqlite-jdbc). **/ public static function open(file:String):sys.db.Connection { if (!init) { try java.lang.Class.forName("org.sqlite.JDBC") catch(e:Dynamic) throw e; init = true; } try { var cnx = java.sql.DriverManager.getConnection("jdbc:sqlite:" + file); return java.db.Jdbc.create(cnx); } catch(e:Dynamic) throw e; } } haxe_3.2.1+dfsg.orig/std/java/_std/sys/io/File.hx0000664000175000017500000000572612607337712021447 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; @:coreApi class File { public static function getContent( path : String ) : String { var f = read(path, false); var ret = f.readAll().toString(); f.close(); return ret; } public static function saveContent( path : String, content : String ) : Void { var f = write(path, false); f.writeString(content); f.close(); } public static function getBytes( path : String ) : haxe.io.Bytes { var f = read(path, true); var ret = f.readAll(); f.close(); return ret; } public static function saveBytes( path : String, bytes : haxe.io.Bytes ) : Void { var f = write(path, true); f.writeBytes(bytes, 0, bytes.length); f.close(); } public static function read( path : String, binary : Bool = true ) : FileInput { try { return new FileInput( new java.io.RandomAccessFile(new java.io.File(path), "r") ); } catch (e:Dynamic) //swallow checked exceptions { throw e; } } public static function write( path : String, binary : Bool = true ) : FileOutput { var f = new java.io.File(path); if (f.exists()) { f.delete(); } try { return new FileOutput( new java.io.RandomAccessFile(f, "rw") ); } catch (e:Dynamic) //swallow checked exceptions { throw e; } } public static function append( path : String, binary : Bool = true ) : FileOutput { var f = new java.io.File(path); try { var ra = new java.io.RandomAccessFile(f, "rw"); if (f.exists()) { ra.seek(f.length()); } return new FileOutput( ra ); } catch (e:Dynamic) //swallow checked exceptions { throw e; } } public static function copy( srcPath : String, dstPath : String ) : Void { var r:FileInput = null; var w:FileOutput = null; try { r = read(srcPath); w = write(dstPath); w.writeInput(r); } catch (e:Dynamic) { if (r != null) r.close(); if (w != null) w.close(); throw e; } } }haxe_3.2.1+dfsg.orig/std/java/_std/sys/io/FileInput.hx0000664000175000017500000000524712607337712022465 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; import haxe.Int64; import haxe.io.Bytes; import haxe.io.Eof; import haxe.io.Input; import java.io.EOFException; import java.io.IOException; class FileInput extends Input { var f:java.io.RandomAccessFile; var _eof:Bool; public function new(f) { this.f = f; this._eof = false; } override public function close() { try f.close() catch(e:Dynamic) throw e; } override public function readByte():Int { try { return f.readUnsignedByte(); } catch (e:EOFException) { _eof = true; throw new Eof(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } override public function readBytes(s:Bytes, pos:Int, len:Int):Int { var ret = 0; try { ret = f.read(s.getData(), pos, len); } catch (e:EOFException) { _eof = true; throw new Eof(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } if (ret == -1) { _eof = true; throw new Eof(); } return ret; } public function seek( p : Int, pos : FileSeek ) : Void { _eof = false; try { switch(pos) { case SeekBegin: f.seek(cast p); case SeekCur: f.seek(haxe.Int64.add(f.getFilePointer(), cast(p, Int64))); case SeekEnd: f.seek(haxe.Int64.add(f.length(), cast p)); } } catch (e:EOFException) { _eof = true; throw new Eof(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } public function tell() : Int { try { return cast f.getFilePointer(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } public inline function eof() : Bool { return _eof; } } haxe_3.2.1+dfsg.orig/std/java/_std/sys/io/FileOutput.hx0000664000175000017500000000474612607337712022671 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; import haxe.io.Bytes; import haxe.io.Eof; import haxe.io.Output; import java.io.EOFException; import java.io.IOException; class FileOutput extends Output { var f:java.io.RandomAccessFile; public function new(f) { this.f = f; } override public function close() { try f.close() catch(e:Dynamic) throw e; } override public function writeByte(c:Int):Void { try { this.f.write(c); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } override public function write(s:Bytes):Void { try { this.f.write(s.getData()); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } override public function writeBytes(s:Bytes, pos:Int, len:Int):Int { try { this.f.write(s.getData(), pos, len); return len; } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } public function seek( p : Int, pos : FileSeek ) : Void { try { switch(pos) { case SeekBegin: f.seek(cast p); case SeekCur: f.seek(haxe.Int64.add(f.getFilePointer(), cast(p, haxe.Int64))); case SeekEnd: f.seek(haxe.Int64.add(f.length(), cast p)); } } catch (e:EOFException) { throw new Eof(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } public function tell() : Int { try { return cast f.getFilePointer(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } } haxe_3.2.1+dfsg.orig/std/java/_std/sys/io/Process.hx0000664000175000017500000000674312607337712022206 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.io; import haxe.io.Bytes; import haxe.io.BytesInput; import haxe.io.Eof; import java.io.IOException; import java.io.EOFException; import java.NativeArray; @:coreApi class Process { public var stdout(default,null) : haxe.io.Input; public var stderr(default,null) : haxe.io.Input; public var stdin(default, null) : haxe.io.Output; private var proc:java.lang.Process; public function new( cmd : String, args : Array ) : Void { var pargs = new NativeArray(args.length + 1); pargs[0] = cmd; for (i in 0...args.length) { pargs[i + 1] = args[i]; } try { proc = new java.lang.ProcessBuilder(pargs).start(); } catch (e:Dynamic) { throw e; } //wrapping typed exceptions var p = proc; stderr = new ProcessInput(p.getErrorStream()); stdout = new ProcessInput(p.getInputStream()); stdin = new java.io.NativeOutput(p.getOutputStream()); } public function getPid() : Int { if (Reflect.hasField(proc, "pid")) return Reflect.field(proc, "pid"); return -1; } public function exitCode() : Int { cast(stdout, ProcessInput).bufferContents(); cast(stderr, ProcessInput).bufferContents(); try { proc.waitFor(); } catch (e:Dynamic) { throw e; } return proc.exitValue(); } public function close() : Void { proc.destroy(); } public function kill() : Void { proc.destroy(); } } private class ProcessInput extends java.io.NativeInput { private var chained:BytesInput; public function bufferContents():Void { if (chained != null) return; var b = this.readAll(); chained = new BytesInput(b); } override public function readByte():Int { if (chained != null) return chained.readByte(); var ret = 0; try { ret = stream.read(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } if ( ret == -1 ) throw new Eof(); return ret; } override public function readBytes(s:Bytes, pos:Int, len:Int):Int { if (chained != null) return chained.readBytes(s, pos, len); var ret = -1; try { ret = stream.read(s.getData(), pos, len); } catch (e:EOFException) { throw new Eof(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } if (ret == -1) throw new Eof(); return ret; } override public function close():Void { if (chained != null) chained.close(); try { stream.close(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } } haxe_3.2.1+dfsg.orig/std/java/_std/sys/net/Host.hx0000664000175000017500000000355012607337712021655 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.net; import java.net.InetAddress; class Host { public var ip(default,null) : Int; @:allow(sys.net) private var wrapped:InetAddress; public function new( name : String ) : Void { try this.wrapped = InetAddress.getByName(name) catch(e:Dynamic) throw e; var rawIp = wrapped.getAddress(); //network byte order assumed this.ip = cast(rawIp[3], Int) | (cast(rawIp[2], Int) << 8) | (cast(rawIp[1], Int) << 16) | (cast(rawIp[0], Int) << 24); } public function toString() : String { return wrapped.getHostAddress(); } public function reverse() : String { return wrapped.getHostName(); } public static function localhost() : String { try { return InetAddress.getLocalHost().getHostName(); } catch(e:Dynamic) throw e; } } haxe_3.2.1+dfsg.orig/std/java/_std/sys/net/Socket.hx0000664000175000017500000001026412607337712022170 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package sys.net; import java.net.InetSocketAddress; @:coreApi class Socket { public var input(default,null) : haxe.io.Input; public var output(default,null) : haxe.io.Output; public var custom : Dynamic; private var sock:java.net.Socket; private var server:java.net.ServerSocket; private var boundAddr:java.net.SocketAddress; public function new() : Void { create(); } private function create():Void { this.sock = new java.net.Socket(); try { this.server = new java.net.ServerSocket(); } catch(e:Dynamic) throw e; } public function close() : Void { try { if (sock != null) this.sock.close(); if (server != null) this.server.close(); } catch(e:Dynamic) throw e; } public function read() : String { return input.readAll().toString(); } public function write( content : String ) : Void { output.writeString(content); } public function connect( host : Host, port : Int ) : Void { try { sock.connect(new InetSocketAddress( host.wrapped, port)); this.output = new java.io.NativeOutput(sock.getOutputStream()); this.input = new java.io.NativeInput(sock.getInputStream()); } catch(e:Dynamic) throw e; } public function listen( connections : Int ) : Void { if (boundAddr == null) throw "You must bind the Socket to an address!"; try server.bind(boundAddr,connections) catch(e:Dynamic) throw e; } public function shutdown( read : Bool, write : Bool ) : Void { try { if (read) sock.shutdownInput(); if (write) sock.shutdownOutput(); } catch(e:Dynamic) throw e; } public function bind( host : Host, port : Int ) : Void { if (boundAddr != null) { if (server.isBound()) throw "Already bound"; } this.boundAddr = new java.net.InetSocketAddress(host.wrapped, port); } public function accept() : Socket { var ret = try server.accept() catch(e:Dynamic) throw e; var s = new Socket(); s.sock = ret; s.output = new java.io.NativeOutput(ret.getOutputStream()); s.input = new java.io.NativeInput(ret.getInputStream()); return s; } public function peer() : { host : Host, port : Int } { var rem = sock.getInetAddress(); if (rem == null) return null; var host = new Host(null); host.wrapped = rem; return { host: host, port: sock.getPort() }; } public function host() : { host : Host, port : Int } { var local = sock.getLocalAddress(); var host = new Host(null); host.wrapped = local; return { host: host, port: sock.getLocalPort() }; } public function setTimeout( timeout : Float ) : Void { try sock.setSoTimeout( Std.int(timeout * 1000) ) catch(e:Dynamic) throw e; } public function waitForRead() : Void { throw "Not implemented"; } public function setBlocking( b : Bool ) : Void { throw "Not implemented"; } public function setFastSend( b : Bool ) : Void { try sock.setTcpNoDelay(b) catch(e:Dynamic) throw e; } public static function select(read : Array, write : Array, others : Array, ?timeout : Float) : { read: Array,write: Array,others: Array } { throw "Not implemented"; return null; } } haxe_3.2.1+dfsg.orig/std/java/db/Jdbc.hx0000664000175000017500000001505112607337712017631 0ustar andyandy00000000000000package java.db; import java.util.concurrent.atomic.AtomicInteger; import haxe.io.Bytes; import java.sql.Types; @:native('haxe.java.db.Jdbc') class Jdbc { public static function create(cnx:java.sql.Connection):sys.db.Connection { return new JdbcConnection(cnx); } } @:native('haxe.java.db.JdbcConnection') private class JdbcConnection implements sys.db.Connection { private static var ids = new AtomicInteger(0); private var id:Int; private var cnx:java.sql.Connection; private var _lastInsertId:Int; //escape handling private var escapeRegex:EReg; private var escapes:Array; public function new(cnx) { this.id = ids.getAndIncrement(); this.cnx = cnx; this.escapes = []; this.escapeRegex = ~/@@HX_ESCAPE(\d+)_(\d+)@@/; } public function close() { try this.cnx.close() catch(e:Dynamic) throw e; } public function escape(s:String):String { return "@@HX_ESCAPE" + id + "_" +escapes.push(s) + "@@"; } public function quote(s:String):String { return "@@HX_ESCAPE" + id + "_" +escapes.push(s) + "@@"; } public function addValue(s:StringBuf, v:Dynamic) { if (Std.is(v, Date)) { v = Std.string(v); } else if (Std.is(v, Bytes)) { var bt:Bytes = v; v = bt.getData(); } s.add("@@HX_ESCAPE"); s.add(id); s.add("_"); s.add(escapes.push(v)); s.add("@@"); } public function lastInsertId():Int { return _lastInsertId; } public function dbName():String { try { var ret = cnx.getMetaData().getDriverName(); var retc = ret.toLowerCase(); if (retc.indexOf("mysql") != -1) return "MySQL"; else if (retc.indexOf("sqlite") != -1) return "SQLite"; return ret; } catch(e:Dynamic) { throw e; } } public function startTransaction() { try { cnx.setAutoCommit(false); } catch(e:Dynamic) throw e; } public function commit() { try { cnx.commit(); } catch(e:Dynamic) { throw e; } } public function rollback() { try cnx.rollback() catch(e:Dynamic) throw e; } public function request(s:String):sys.db.ResultSet { var newst = new StringBuf(); var sentArray = []; //cycle through the request string, adding any @@HX_ESCAPE@@ reference to the sentArray var r = escapeRegex; var myid = id + "", escapes = escapes, elen = escapes.length; try { while (r.match(s)) { var id = r.matched(1); if (id != myid) throw "Request quotes are only valid for one single request; They can't be cached."; newst.add(r.matchedLeft()); var eid = Std.parseInt(r.matched(2)); if (eid == null || eid > elen) throw "Invalid request quote ID " + eid; sentArray.push(escapes[eid - 1]); newst.add("?"); s = r.matchedRight(); } newst.add(s); var stmt = cnx.prepareStatement(newst.toString(), java.sql.Statement.Statement_Statics.RETURN_GENERATED_KEYS); for (i in 0...sentArray.length) { stmt.setObject(i + 1, sentArray[i]); } var ret = null, dbName = dbName(); if (stmt.execute()) { //is a result set var rs = stmt.getResultSet(); ret = new JdbcResultSet(rs, dbName, stmt.getMetaData()); } else { //is an update var affected = stmt.getUpdateCount(); if (affected == 1) { var autogen = stmt.getGeneratedKeys(); if (autogen.next()) { this._lastInsertId = autogen.getInt(1); } } ret = new JdbcResultSet(null, dbName,null); } if (escapes.length != 0) escapes = []; this.id = ids.getAndIncrement(); return ret; } catch(e:Dynamic) { if (escapes.length != 0) escapes = []; this.id = ids.getAndIncrement(); throw e; } } } @:native('haxe.java.db.JdbcResultSet') private class JdbcResultSet implements sys.db.ResultSet { @:isVar public var length(get,null) : Int; public var nfields(get,null) : Int; private var rs:java.sql.ResultSet; private var names:Array; private var types:java.NativeArray; private var dbName:String; private var didNext:Bool; public function new(rs, dbName, meta:java.sql.ResultSetMetaData) { this.dbName = dbName; this.rs = rs; if (meta != null) { try { var count = meta.getColumnCount(); var names = [], types = new NativeArray(count); for (i in 0...count) { names.push(meta.getColumnName(i+1)); types[i] = meta.getColumnType(i+1); } this.types = types; this.names = names; } catch(e:Dynamic) throw e; } } private function get_length():Int { if (length == 0) { try { var cur = rs.getRow(); rs.last(); this.length = rs.getRow(); rs.absolute(cur); } catch(e:Dynamic) throw e; } return length; } private function get_nfields():Int { return names == null ? 0 : names.length; } public function hasNext() : Bool { try { didNext = true; return rs != null && rs.next(); } catch(e:Dynamic) { return throw e; } } public function next() : Dynamic { try { if (rs == null) return null; if (didNext) { didNext = false; } else { if (!rs.next()) { return null; } } var ret = {}, names = names, types = types; for (i in 0...names.length) { var name = names[i], t = types[i], val:Dynamic = null; if (t == Types.FLOAT) { val = rs.getDouble(i+1); } else if (t == Types.DATE || t == Types.TIME) { if (dbName == "SQLite") { var str = rs.getString(i+1); if (str != null) { var d:Date = Date.fromString(str); val = d; } } else { var d:java.sql.Date = rs.getDate(i+1); if (d != null) val = Date.fromTime(cast d.getTime()); } } else if (t == Types.LONGVARBINARY || t == Types.VARBINARY || t == Types.BINARY || t == Types.BLOB) { var b = rs.getBytes(i+1); if (b != null) val = Bytes.ofData(b); } else { untyped __java__("val = rs.getObject(i + 1)"); //type parameter constraint + overloads } Reflect.setField(ret, name, val); } return ret; } catch(e:Dynamic) throw e; } public function results() : List { var l = new List(); if (rs == null) return l; try { while(hasNext()) l.add(next()); } catch(e:Dynamic) throw e; return l; } public function getResult( n : Int ) : String { try { return rs.getString(n); } catch(e:Dynamic) throw e; } public function getIntResult( n : Int ) : Int { try { return rs.getInt(n); } catch(e:Dynamic) { return throw e; }; } public function getFloatResult( n : Int ) : Float { try { return rs.getFloat(n); } catch(e:Dynamic) { return throw e; }; } public function getFieldsNames() : Null> { return this.names; } } haxe_3.2.1+dfsg.orig/std/java/internal/Exceptions.hx0000664000175000017500000000506412607337712022342 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.internal; import java.lang.Throwable; import java.lang.RuntimeException; import java.lang.Exception; @:native("haxe.lang.Exceptions") class Exceptions { private static var exception = new java.lang.ThreadLocal(); @:keep private static function setException(exc:Throwable) { exception.set(exc); } public static function currentException() { return exception.get(); } } @:classCode("public static final long serialVersionUID = 5956463319488556322L;") @:nativeGen @:keep @:native("haxe.lang.HaxeException") private class HaxeException extends RuntimeException { private var obj:Dynamic; public function new(obj:Dynamic, msg:String, cause:Throwable) { super(msg, cause); if (Std.is(obj, HaxeException)) { var _obj:HaxeException = cast obj; obj = _obj.getObject(); } this.obj = obj; } public function getObject():Dynamic { return obj; } #if !debug @:overload override public function fillInStackTrace():Throwable { return this; } #end @:overload override public function toString():String { return "Haxe Exception: " + obj; } public static function wrap(obj:Dynamic):RuntimeException { var ret:RuntimeException = null; if (Std.is(obj, RuntimeException)) ret = obj; else if (Std.is(obj, String)) ret = new HaxeException(obj, obj, null); else if (Std.is(obj, Throwable)) ret = new HaxeException(obj, null, obj); else ret = new HaxeException(obj, null, null); return ret; } } haxe_3.2.1+dfsg.orig/std/java/internal/FieldLookup.hx0000664000175000017500000000722712607337712022441 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.internal; import java.lang.System; @:native('haxe.lang.FieldLookup') @:keep @:static private class FieldLookup { @:functionCode(' return s.hashCode(); ') public static function hash(s:String):Int { return 0; } public static function findHash(hash:String, hashs:java.NativeArray, length:Int):Int { var min = 0; var max = length; while (min < max) { var mid = Std.int((max + min) / 2); //overflow safe var classify = untyped hash.compareTo(hashs[mid]); if (classify < 0) { max = mid; } else if (classify > 0) { min = mid + 1; } else { return mid; } } //if not found, return a negative value of where it should be inserted return ~min; } static function removeString(a:java.NativeArray, length:Int, pos:Int) { System.arraycopy(a, pos + 1, a, pos, length - pos - 1); a[length - 1] = null; } static function removeFloat(a:java.NativeArray, length:Int, pos:Int) { System.arraycopy(a, pos + 1, a, pos, length - pos - 1); a[length - 1] = 0; } static function removeDynamic(a:java.NativeArray, length:Int, pos:Int) { System.arraycopy(a, pos + 1, a, pos, length - pos - 1); a[length - 1] = null; } @:extern static inline function __insert(a:java.NativeArray, length:Int, pos:Int, x:T):java.NativeArray { var capacity = a.length; if (pos == length) { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); System.arraycopy(a, 0, newarr, 0, a.length); a = newarr; } } else if (pos == 0) { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); System.arraycopy(a, 0, newarr, 1, length); a = newarr; } else { System.arraycopy(a, 0, a, 1, length); } } else { if (capacity == length) { var newarr = new NativeArray((length << 1) + 1); System.arraycopy(a, 0, newarr, 0, pos); System.arraycopy(a, pos, newarr, pos + 1, length - pos); a = newarr; } else { System.arraycopy(a, pos, a, pos + 1, length - pos); System.arraycopy(a, 0, a, 0, pos); } } a[pos] = x; return a; } static function insertString(a:java.NativeArray, length:Int, pos:Int, x:String):java.NativeArray return __insert(a, length, pos, x); static function insertFloat(a:java.NativeArray, length:Int, pos:Int, x:Float):java.NativeArray return __insert(a, length, pos, x); static function insertDynamic(a:java.NativeArray, length:Int, pos:Int, x:Dynamic):java.NativeArray return __insert(a, length, pos, x); } haxe_3.2.1+dfsg.orig/std/java/internal/Function.hx0000664000175000017500000000517512607337712022011 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.internal; import java.internal.Runtime; /** * These classes are automatically generated by the compiler. They are only * here so there is an option for e.g. defining them as externs if you are compiling * in modules (untested) * * @author waneck */ @:abstract @:nativeGen @:native("haxe.lang.Function") @:keep class Function { function new(arity:Int, type:Int) { } } @:nativeGen @:native("haxe.lang.VarArgsBase") @:keep private class VarArgsBase extends Function { public function __hx_invokeDynamic(dynArgs:Array):Dynamic { throw "Abstract implementation"; } } @:nativeGen @:native('haxe.lang.VarArgsFunction') @:keep class VarArgsFunction extends VarArgsBase { private var fun:Array->Dynamic; public function new(fun) { super(-1, -1); this.fun = fun; } override public function __hx_invokeDynamic(dynArgs:Array):Dynamic { return fun(dynArgs); } } @:nativeGen @:native('haxe.lang.Closure') @:keep class Closure extends VarArgsBase { private var obj:Dynamic; private var field:String; public function new(obj:Dynamic, field) { super(-1, -1); this.obj = obj; this.field = field; } override public function __hx_invokeDynamic(dynArgs:Array):Dynamic { return Runtime.callField(obj, field, dynArgs); } public function equals(obj:Dynamic):Bool { if (obj == null) return false; var c:Closure = cast obj; return (c.obj == this.obj && c.field == this.field); } public function hashCode():Int { return obj.hashCode() ^ untyped field.hashCode(); } } haxe_3.2.1+dfsg.orig/std/java/internal/HxObject.hx0000664000175000017500000000741012607337712021724 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.internal; import java.internal.IEquatable; import haxe.ds.Vector; private typedef StdType = Type; @:native('haxe.lang.HxObject') @:keep private class HxObject implements IHxObject { } @:native('haxe.lang.IHxObject') @:keep interface IHxObject { } @:native('haxe.lang.DynamicObject') @:replaceReflection @:keep class DynamicObject extends HxObject implements Dynamic { @:skipReflection public function toString():String { var ts = Reflect.field(this, "toString"); if (ts != null) return ts(); var ret = new StringBuf(); ret.add("{"); var first = true; for (f in Reflect.fields(this)) { if( first ) first = false; else ret.add(","); ret.add(" "); ret.add(f); ret.add(" : "); ret.add(Reflect.field(this, f)); } if (!first) ret.add(" "); ret.add("}"); return ret.toString(); } } @:keep @:native('haxe.lang.Enum') @:nativeGen class HxEnum { @:readOnly private var index(default,never):Int; public function new(index:Int) { untyped this.index = index; } public function getTag():String { return throw 'Not Implemented'; } public function getParams():Array<{}> { return []; } public function toString():String { return getTag(); } } @:keep @:native('haxe.lang.ParamEnum') @:nativeGen private class ParamEnum extends HxEnum { @:readOnly private var params(default,never):Vector; public function new(index:Int, params:Vector) { super(index); untyped this.params = params; } override public function getParams():Array<{}> { return params == null ? [] : cast params.toArray(); } override public function toString():String { if (params == null || params.length == 0) return getTag(); var ret = new StringBuf(); ret.add(getTag()); ret.add("("); var first = true; for (p in params) { if (first) first = false; else ret.add(","); ret.add(p); } ret.add(")"); return ret.toString(); } public function equals(obj:Dynamic) { if (obj == this) //we cannot use == as .Equals ! return true; var obj:ParamEnum = Std.is(obj,ParamEnum) ? cast obj : null; var ret = obj != null && Std.is(obj, StdType.getEnum(cast this)) && obj.index == this.index; if (!ret) return false; if (obj.params == this.params) return true; var len = 0; if (obj.params == null || this.params == null || (len = this.params.length) != obj.params.length) return false; for (i in 0...len) { if (!StdType.enumEq(obj.params[i], this.params[i])) return false; } return true; } public function hashCode():Int { var h = 19; if (params != null) for (p in params) { h = h * 31; if (p != null) untyped h += p.hashCode(); } h += index; return h; } } haxe_3.2.1+dfsg.orig/std/java/internal/IEquatable.hx0000664000175000017500000000236512607337712022236 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.internal; @:native('haxe.lang.IEquatable') @:keep @:nativeGen interface IEquatable { public function equals(to:Dynamic):Bool; } haxe_3.2.1+dfsg.orig/std/java/internal/Iterator.hx0000664000175000017500000000254612607337712022014 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.internal; @:native('haxe.lang.Iterator') @:keep interface Iterator { public function hasNext():Bool; public function next():T; } @:native('haxe.lang.Iterable') @:keep interface Iterable { public function iterator():Iterator; }haxe_3.2.1+dfsg.orig/std/java/internal/Runtime.hx0000664000175000017500000003406612607337712021650 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.internal; /** This class is meant for internal compiler use only. It provides the Haxe runtime compatibility to the host language. Do not access it directly. **/ @:native('haxe.lang.Runtime') @:nativeGen @:classCode(' public static java.lang.Object getField(haxe.lang.IHxObject obj, java.lang.String field, boolean throwErrors) { if (obj == null && !throwErrors) return null; return obj.__hx_getField(field, throwErrors, false, false); } public static double getField_f(haxe.lang.IHxObject obj, java.lang.String field, boolean throwErrors) { if (obj == null && !throwErrors) return 0.0; return obj.__hx_getField_f(field, throwErrors, false); } public static java.lang.Object setField(haxe.lang.IHxObject obj, java.lang.String field, java.lang.Object value) { return obj.__hx_setField(field, value, false); } public static double setField_f(haxe.lang.IHxObject obj, java.lang.String field, double value) { return obj.__hx_setField_f(field, value, false); } public static java.lang.Object callField(haxe.lang.IHxObject obj, java.lang.String field, Array args) { return obj.__hx_invokeField(field, args); } ') @:keep class Runtime { public static var undefined:Dynamic = { }; @:functionCode(' return new haxe.lang.Closure(obj, field); ') public static function closure(obj:Dynamic, field:String):Dynamic { return null; } @:functionCode(' if (v1 == v2) return true; if (v1 == null || v2 == null) return false; if (v1 instanceof java.lang.Number) { if (!(v2 instanceof java.lang.Number)) return false; java.lang.Number v1c = (java.lang.Number) v1; java.lang.Number v2c = (java.lang.Number) v2; if (v1 instanceof java.lang.Long || v2 instanceof java.lang.Long) return v1c.longValue() == v2c.longValue(); return v1c.doubleValue() == v2c.doubleValue(); } else if (v1 instanceof java.lang.String || v1 instanceof haxe.lang.IEquatable) { //TODO see what happens with Boolean cases return v1.equals(v2); } return false; ') public static function eq(v1:Dynamic, v2:Dynamic):Bool { return false; } @:functionCode(' if (v1 == v2) return true; if (v1 instanceof java.lang.String || v1 instanceof haxe.lang.IEquatable) { return v1 != null && v1.equals(v2); } else { return v1 == v2; } ') public static function refEq(v1: { }, v2: { } ):Bool { return false; } @:functionCode(' return v1 == v2 || (v1 != null && v1.equals(v2)); ') public static function valEq(v1: { }, v2: { } ):Bool { return false; } @:functionCode(' return (obj == null) ? 0.0 : ((java.lang.Number) obj).doubleValue(); ') public static function toDouble(obj:Dynamic):Float { return 0.0; } @:functionCode(' return (obj == null) ? false : ((java.lang.Boolean) obj).booleanValue(); ') public static function toBool(obj:Dynamic):Bool { return false; } @:functionCode(' return (obj == null) ? 0 : ((java.lang.Number) obj).intValue(); ') public static function toInt(obj:Dynamic):Int { return 0; } @:functionCode(' if (obj != null && obj instanceof java.lang.Number) { return true; } else { return false; } ') public static function isDouble(obj:Dynamic):Bool { return false; } @:functionCode(' if (obj != null && obj instanceof java.lang.Number) { java.lang.Number n = (java.lang.Number) obj; return n.doubleValue() == n.intValue(); } else { return false; } ') public static function isInt(obj:Dynamic):Bool { return false; } @:functionCode(' java.lang.Class cl = null; if (o instanceof java.lang.Class) { if (o == java.lang.String.class) return field.equals("fromCharCode"); cl = (java.lang.Class) o; } else if (o instanceof java.lang.String) { return haxe.lang.StringRefl.handleGetField( (java.lang.String) o, field, false) != null; } else { cl = o.getClass(); } try { java.lang.reflect.Field f = cl.getField(field); return true; } catch(Throwable t) { java.lang.reflect.Method[] ms = cl.getMethods(); for (int i = 0; i < ms.length; i++) { if (ms[i].getName().equals(field)) { return true; } } } return false; ') public static function slowHasField(o:Dynamic, field:String):Bool { return false; } @:functionCode(' if (v1 == v2) return 0; if (v1 == null) return -1; if (v2 == null) return 1; if (v1 instanceof java.lang.Number || v2 instanceof java.lang.Number) { java.lang.Number v1c = (java.lang.Number) v1; java.lang.Number v2c = (java.lang.Number) v2; if (v1 instanceof java.lang.Long || v2 instanceof java.lang.Long) { long l1 = (v1 == null) ? 0L : v1c.longValue(); long l2 = (v2 == null) ? 0L : v2c.longValue(); return (l1 < l2) ? -1 : (l1 > l2) ? 1 : 0; } else { double d1 = (v1 == null) ? 0.0 : v1c.doubleValue(); double d2 = (v2 == null) ? 0.0 : v2c.doubleValue(); return (d1 < d2) ? -1 : (d1 > d2) ? 1 : 0; } } //if it\'s not a number it must be a String return ((java.lang.String) v1).compareTo((java.lang.String) v2); ') public static function compare(v1:Dynamic, v2:Dynamic):Int { return 0; } @:functionCode(' if (v1 instanceof java.lang.String || v2 instanceof java.lang.String) return toString(v1) + toString(v2); if (v1 instanceof java.lang.Number || v2 instanceof java.lang.Number) { java.lang.Number v1c = (java.lang.Number) v1; java.lang.Number v2c = (java.lang.Number) v2; double d1 = (v1 == null) ? 0.0 : v1c.doubleValue(); double d2 = (v2 == null) ? 0.0 : v2c.doubleValue(); return d1 + d2; } throw new java.lang.IllegalArgumentException("Cannot dynamically add " + v1 + " and " + v2); ') public static function plus(v1:Dynamic, v2:Dynamic):Dynamic { return null; } @:functionCode(' if (obj == null) if (throwErrors) throw new java.lang.NullPointerException("Cannot access field \'" + field + "\' of null."); else return null; java.lang.Class cl = null; try { if (obj instanceof java.lang.Class) { if (obj == java.lang.String.class && field.equals("fromCharCode")) return new haxe.lang.Closure(haxe.lang.StringExt.class, field); cl = (java.lang.Class) obj; obj = null; } else if (obj instanceof java.lang.String) { return haxe.lang.StringRefl.handleGetField((java.lang.String) obj, field, throwErrors); } else { cl = obj.getClass(); } java.lang.reflect.Field f = cl.getField(field); f.setAccessible(true); return f.get(obj); } catch (Throwable t) { try { java.lang.reflect.Method[] ms = cl.getMethods(); for (int i = 0; i < ms.length; i++) { if (ms[i].getName().equals(field)) { return new haxe.lang.Closure(obj != null ? obj : cl, field); } } } catch (Throwable t2) { } if (throwErrors) throw HaxeException.wrap(t); return null; } ') public static function slowGetField(obj:Dynamic, field:String, throwErrors:Bool):Dynamic { return null; } @:functionCode(' java.lang.Class cl = null; if (obj instanceof java.lang.Class) { cl = (java.lang.Class) obj; obj = null; } else { cl = obj.getClass(); } try { java.lang.reflect.Field f = cl.getField(field); f.setAccessible(true); //FIXME we must evaluate if field to be set receives either int or double if (isInt(value)) { f.setInt(obj, toInt(value)); } else if (isDouble(value)) { f.setDouble(obj, toDouble(value)); } else { f.set(obj, value); } return value; } catch (Throwable t) { throw HaxeException.wrap(t); } ') public static function slowSetField(obj:Dynamic, field:String, value:Dynamic):Dynamic { return null; } @:functionCode(' java.lang.Class cl = null; if (obj instanceof java.lang.Class) { if (obj == java.lang.String.class && field.equals("fromCharCode")) return haxe.lang.StringExt.fromCharCode(toInt(args.__get(0))); cl = (java.lang.Class) obj; obj = null; } else if (obj instanceof java.lang.String) { return haxe.lang.StringRefl.handleCallField((java.lang.String) obj, field, args); } else { cl = obj.getClass(); } if (args == null) args = new Array(); int len = args.length; java.lang.Class[] cls = new java.lang.Class[len]; java.lang.Object[] objs = new java.lang.Object[len]; java.lang.reflect.Method[] ms = cl.getMethods(); int msl = ms.length; int realMsl = 0; for(int i =0; i < msl; i++) { if (!ms[i].getName().equals(field) || (!ms[i].isVarArgs() && ms[i].getParameterTypes().length != len)) { ms[i] = null; } else { ms[realMsl] = ms[i]; if (realMsl != i) ms[i] = null; realMsl++; } } boolean hasNumber = false; for (int i = 0; i < len; i++) { Object o = args.__get(i); if (o == null) { continue; //can be anything } objs[i]= o; cls[i] = o.getClass(); boolean isNum = false; if (o instanceof java.lang.Number) { cls[i] = java.lang.Number.class; isNum = hasNumber = true; } else if (o instanceof java.lang.Boolean) { cls[i] = java.lang.Boolean.class; isNum = true; } msl = realMsl; realMsl = 0; for (int j = 0; j < msl; j++) { java.lang.Class[] allcls = ms[j].getParameterTypes(); if (i < allcls.length) { if (! ((isNum && allcls[i].isPrimitive()) || allcls[i].isAssignableFrom(cls[i])) ) { ms[j] = null; } else { ms[realMsl] = ms[j]; if (realMsl != j) ms[j] = null; realMsl++; } } } } java.lang.reflect.Method found; if (ms.length == 0 || (found = ms[0]) == null) throw haxe.lang.HaxeException.wrap("No compatible method found for: " + field); if (hasNumber) { java.lang.Class[] allcls = found.getParameterTypes(); for (int i = 0; i < len; i++) { java.lang.Object o = objs[i]; if (o instanceof java.lang.Number) { java.lang.Class curCls = null; if (i < allcls.length) { curCls = allcls[i]; if (!curCls.isAssignableFrom(o.getClass())) { String name = curCls.getName(); if (name.equals("double") || name.equals("java.lang.Double")) { objs[i] = ((java.lang.Number)o).doubleValue(); } else if (name.equals("int") || name.equals("java.lang.Integer")) { objs[i] = ((java.lang.Number)o).intValue(); } else if (name.equals("float") || name.equals("java.lang.Float")) { objs[i] = ((java.lang.Number)o).floatValue(); } else if (name.equals("byte") || name.equals("java.lang.Byte")) { objs[i] = ((java.lang.Number)o).byteValue(); } else if (name.equals("short") || name.equals("java.lang.Short")) { objs[i] = ((java.lang.Number)o).shortValue(); } else if (name.equals("long") || name.equals("java.lang.Long")) { objs[i] = ((java.lang.Number)o).longValue(); } } } //else varargs not handled TODO } } } try { found.setAccessible(true); return found.invoke(obj, objs); } catch (java.lang.reflect.InvocationTargetException e) { throw haxe.lang.HaxeException.wrap(e.getCause()); } catch (Throwable t) { throw haxe.lang.HaxeException.wrap(t); } ') public static function slowCallField(obj:Dynamic, field:String, args:Array):Dynamic { return null; } @:functionCode(' if (obj instanceof haxe.lang.IHxObject) { return ((haxe.lang.IHxObject) obj).__hx_invokeField(field, args); } return slowCallField(obj, field, args); ') public static function callField(obj:Dynamic, field:String, args:Array):Dynamic { return null; } @:functionCode(' if (obj instanceof haxe.lang.IHxObject) return ((haxe.lang.IHxObject) obj).__hx_getField(field, throwErrors, false, false); return slowGetField(obj, field, throwErrors); ') public static function getField(obj:Dynamic, field:String, throwErrors:Bool):Dynamic { return null; } @:functionCode(' if (obj instanceof haxe.lang.IHxObject) return ((haxe.lang.IHxObject) obj).__hx_getField_f(field, throwErrors, false); return toDouble(slowGetField(obj, field, throwErrors)); ') public static function getField_f(obj:Dynamic, field:String, throwErrors:Bool):Float { return 0.0; } @:functionCode(' if (obj instanceof haxe.lang.IHxObject) return ((haxe.lang.IHxObject) obj).__hx_setField(field, value, false); return slowSetField(obj, field, value); ') public static function setField(obj:Dynamic, field:String, value:Dynamic):Dynamic { return null; } @:functionCode(' if (obj instanceof haxe.lang.IHxObject) return ((haxe.lang.IHxObject) obj).__hx_setField_f(field, value, false); return toDouble(slowSetField(obj, field, value)); ') public static function setField_f(obj:Dynamic, field:String, value:Float):Float { return 0.0; } public static function toString(obj:Dynamic):String { if (obj == null) return null; if (isInt(obj)) return (cast(obj, Int)) + ""; return untyped obj.toString(); } public static function isFinite(v:Float):Bool { return (v == v) && !java.lang.Double.DoubleClass._isInfinite(v); } } @:keep @:native("haxe.lang.EmptyObject") private enum EmptyObject { EMPTY; } haxe_3.2.1+dfsg.orig/std/java/internal/StringExt.hx0000664000175000017500000001511612607337712022147 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.internal; import java.internal.Function; private typedef NativeString = String; @:keep @:nativeGen @:native("haxe.lang.StringExt") private class StringExt { @:functionCode(' if ( index >= me.length() || index < 0 ) return ""; else return java.lang.Character.toString(me.charAt(index)); ') public static function charAt(me:NativeString, index:Int):NativeString { return null; } @:functionCode(' if ( index >= me.length() || index < 0 ) return null; else return me.codePointAt(index); ') public static function charCodeAt(me:NativeString, index:Int):Null { return null; } @:functionCode(' int sIndex = (startIndex != null ) ? (haxe.lang.Runtime.toInt(startIndex)) : 0; if (sIndex >= me.length() || sIndex < 0) return -1; return me.indexOf(str, sIndex); ') public static function indexOf(me:NativeString, str:NativeString, ?startIndex:Int):Int { return -1; } @:functionCode(' int sIndex = (startIndex != null ) ? (haxe.lang.Runtime.toInt(startIndex)) : (me.length() - 1); if (sIndex > me.length() || sIndex < 0) sIndex = me.length() - 1; else if (sIndex < 0) return -1; return me.lastIndexOf(str, sIndex); ') public static function lastIndexOf(me:NativeString, str:NativeString, ?startIndex:Int):Int { return -1; } @:functionCode(' Array ret = new Array(); int slen = delimiter.length(); if (slen == 0) { int len = me.length(); for (int i = 0; i < len; i++) { ret.push(me.substring(i, i + 1)); } } else { int start = 0; int pos = me.indexOf(delimiter, start); while (pos >= 0) { ret.push(me.substring(start, pos)); start = pos + slen; pos = me.indexOf(delimiter, start); } ret.push(me.substring(start)); } return ret; ') public static function split(me:NativeString, delimiter:NativeString):Array { return null; } @:functionCode(' int meLen = me.length(); int targetLen = meLen; if (len != null) { targetLen = haxe.lang.Runtime.toInt(len); if (targetLen == 0) return ""; if( pos != 0 && targetLen < 0 ){ return ""; } } if( pos < 0 ){ pos = meLen + pos; if( pos < 0 ) pos = 0; } else if( targetLen < 0 ){ targetLen = meLen + targetLen - pos; } if( pos + targetLen > meLen ){ targetLen = meLen - pos; } if ( pos < 0 || targetLen <= 0 ) return ""; return me.substring(pos, pos + targetLen); ') public static function substr(me:NativeString, pos:Int, ?len:Int):NativeString { return null; } @:functionCode(' int endIdx; int len = me.length(); if ( endIndex == null) { endIdx = len; } else if ( (endIdx = haxe.lang.Runtime.toInt(endIndex)) < 0 ) { endIdx = 0; } else if ( endIdx > len ) { endIdx = len; } if ( startIndex < 0 ) { startIndex = 0; } else if ( startIndex > len ) { startIndex = len; } if ( startIndex > endIdx ) { int tmp = startIndex; startIndex = endIdx; endIdx = tmp; } return me.substring(startIndex, endIdx); ') public static function substring(me:NativeString, startIndex:Int, ?endIndex:Int):NativeString { return null; } public static function toString(me:NativeString):NativeString { return me; } @:functionCode(' return me.toLowerCase(); ') public static function toLowerCase(me:NativeString):NativeString { return null; } @:functionCode(' return me.toUpperCase(); ') public static function toUpperCase(me:NativeString):NativeString { return null; } public static function toNativeString(me:NativeString):NativeString { return me; } @:functionCode(' return java.lang.Character.toString( (char) code ); ') public static function fromCharCode(code:Int):NativeString { return null; } } @:keep @:nativeGen @:native('haxe.lang.StringRefl') private class StringRefl { public static var fields = ["length", "toUpperCase", "toLowerCase", "charAt", "charCodeAt", "indexOf", "lastIndexOf", "split", "substr", "substring"]; public static function handleGetField(str:NativeString, f:NativeString, throwErrors:Bool):Dynamic { switch(f) { case "length": return str.length; case "toUpperCase", "toLowerCase", "charAt", "charCodeAt", "indexOf", "lastIndexOf", "split", "substr", "substring": return new Closure(str, f); default: if (throwErrors) throw "Field not found: '" + f + "' in String"; else return null; } } public static function handleCallField(str:NativeString, f:NativeString, args:Array):Dynamic { var _args:Array = [str]; if (args == null) args = _args; else args = _args.concat(args); return Runtime.slowCallField(StringExt, f, args); } } @:keep @:native('haxe.lang.NativeString') private extern class JavaString { //name collides with Haxe's function _charAt(idx:Int):java.StdTypes.Char16; function codePointAt(idx:Int):Int; function codePointBefore(idx:Int):Int; function codePointCount(begin:Int, end:Int):Int; function offsetByCodePoints(index:Int, codePointOffset:Int):Int; function getChars(srcBegin:Int, srcEnd:Int, dst:java.NativeArray, dstBegin:Int):Void; function startsWith(prefix:String):Bool; function endsWith(suffix:String):Bool; function _indexOf(str:String, fromIndex:Int):Int; function _lastIndexOf(str:String, fromIndex:Int):Int; function _substring(begin:Int, end:Int):String; function replace(old:String, nw:String):String; function _split(regex:String):java.NativeArray; function trim():String; } haxe_3.2.1+dfsg.orig/std/java/io/NativeInput.hx0000664000175000017500000000411612607337712021257 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.io; import haxe.Int64; import haxe.io.Bytes; import haxe.io.Eof; import haxe.io.Input; import java.io.IOException; import java.io.EOFException; @:native('haxe.java.io.NativeInput') class NativeInput extends Input { var stream:java.io.InputStream; public function new(stream) { this.stream = stream; } override public function readByte():Int { var ret = 0; try { ret = stream.read(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } if ( ret == -1 ) throw new Eof(); return ret; } override public function readBytes(s:Bytes, pos:Int, len:Int):Int { var ret = 0; try { ret = stream.read(s.getData(), pos, len); } catch (e:EOFException) { throw new Eof(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } if (ret == -1) throw new Eof(); return ret; } override public function close():Void { try { stream.close(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } } haxe_3.2.1+dfsg.orig/std/java/io/NativeOutput.hx0000664000175000017500000000363212607337712021462 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.io; import haxe.Int64; import haxe.io.Bytes; import haxe.io.Eof; import haxe.io.Output; import java.io.IOException; import java.io.EOFException; @:native('haxe.java.io.NativeOutput') class NativeOutput extends Output { var stream:java.io.OutputStream; public function new(stream) { this.stream = stream; } override public function writeByte(c:Int):Void { try { stream.write(c); } catch (e:EOFException) { throw new Eof(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } override public function close():Void { try { stream.close(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } override public function flush():Void { try { stream.flush(); } catch (e:IOException) { throw haxe.io.Error.Custom(e); } } } haxe_3.2.1+dfsg.orig/std/java/lang/Boolean.hx0000664000175000017500000000543112607337712020703 0ustar andyandy00000000000000package java.lang; @:native("") // make sure the generator won't see this @:forward abstract Boolean(BooleanClass) from BooleanClass to BooleanClass { @:to @:extern inline public function toBool():Bool return this.booleanValue(); @:from @:extern inline public static function fromBool(b:Bool):Boolean return BooleanClass.valueOf(b); @:extern public static var FALSE(get,set):Boolean; @:extern static inline function get_FALSE():Boolean return BooleanClass.FALSE; @:extern static inline function set_FALSE(val:Boolean):Boolean return BooleanClass.FALSE = val; @:extern public static var TRUE(get,set):Boolean; @:extern static inline function get_TRUE():Boolean return BooleanClass.TRUE; @:extern static inline function set_TRUE(val:Boolean):Boolean return BooleanClass.TRUE = val; @:extern public static var TYPE(get,set):Class; @:extern static inline function get_TYPE():Class return BooleanClass.TYPE; @:extern static inline function set_TYPE(val:Class):Class return BooleanClass.TYPE = val; @:extern @:overload inline public static function compare(param1:Bool, param2:Bool):Int return BooleanClass.compare(param1, param2); @:extern @:overload inline public static function getBoolean(param1:String):Bool return BooleanClass.getBoolean(param1); @:extern @:overload inline public static function parseBoolean(param1:String):Bool return BooleanClass.parseBoolean(param1); @:extern @:overload inline public static function _toString(param1:Bool):String return BooleanClass._toString(param1); @:extern @:overload inline public static function valueOf(param1:Bool):Boolean return BooleanClass.valueOf(param1); } @:native("java.lang.Boolean") extern class BooleanClass extends Number implements Comparable { @:overload public function new(bool:Bool):Void; @:overload public function new(string:String):Void; @:overload public function booleanValue() : Bool; @:overload public function compareTo(param1 : Boolean) : Int; @:overload public function compareTo(param1 : Dynamic) : Int; @:overload public function equals(param1 : Dynamic) : Bool; @:overload public function hashCode() : Int; @:overload public function toString() : String; @:final public static var FALSE : Boolean; @:final public static var TRUE : Boolean; @:final public static var TYPE : Class; @:overload public static function compare(param1 : Bool, param2 : Bool) : Int; @:overload public static function getBoolean(param1 : String) : Bool; @:overload public static function parseBoolean(param1 : String) : Bool; @:native("toString") @:overload public static function _toString(param1 : Bool) : String; @:overload public static function valueOf(param1 : Bool) : Boolean; @:overload public static function valueOf(param1 : String) : Boolean; } haxe_3.2.1+dfsg.orig/std/java/lang/Byte.hx0000664000175000017500000000654712607337712020240 0ustar andyandy00000000000000package java.lang; @:native("") // make sure the generator won't see this @:forward abstract Byte(ByteClass) from ByteClass to ByteClass { @:to @:extern inline public function toByte():java.types.Int8 return this.byteValue(); @:from @:extern inline public static function fromByte(b:java.types.Int8):Byte return ByteClass.valueOf(b); @:extern public static var MAX_VALUE(get,never):java.types.Int8; @:extern static inline function get_MAX_VALUE():java.types.Int8 return ByteClass.MAX_VALUE; @:extern public static var MIN_VALUE(get,never):java.types.Int8; @:extern static inline function get_MIN_VALUE():java.types.Int8 return ByteClass.MIN_VALUE; @:extern public static var SIZE(get,never):Int; @:extern static inline function get_SIZE():Int return ByteClass.SIZE; @:extern public static var TYPE(get,set):Class; @:extern static inline function get_TYPE():Class return ByteClass.TYPE; @:extern static inline function set_TYPE(val:Class):Class return ByteClass.TYPE = val; @:extern @:overload inline public static function compare(param1:java.types.Int8, param2:java.types.Int8):Int return ByteClass.compare(param1, param2); @:extern @:overload inline public static function decode(param1:String):Byte return ByteClass.decode(param1); @:extern @:overload inline public static function parseByte(param1:String, param2:Int):java.types.Int8 return ByteClass.parseByte(param1, param2); @:extern @:overload inline public static function _toString(param1:java.types.Int8):String return ByteClass._toString(param1); @:extern @:overload inline public static function valueOf(param1:java.types.Int8):Byte return ByteClass.valueOf(param1); } @:native("java.lang.Byte") extern class ByteClass extends Number implements Comparable { @:overload function new(param1 : java.types.Int8) : Void; @:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void; @:overload function compareTo(param1 : Byte) : Int; @:overload function compareTo(param1 : Dynamic) : Int; @:overload function equals(param1 : Dynamic) : Bool; @:overload function hashCode() : Int; @:overload function toString() : String; @:final static var MAX_VALUE(default,null) : java.types.Int8; @:final static var MIN_VALUE(default,null) : java.types.Int8; @:final static var SIZE(default,null) : Int; @:final static var TYPE : Class; @:overload static function compare(param1 : java.types.Int8, param2 : java.types.Int8) : Int; @:overload @:throws("java.lang.NumberFormatException") static function decode(param1 : String) : Byte; @:overload @:throws("java.lang.NumberFormatException") static function parseByte(param1 : String, param2 : Int) : java.types.Int8; @:overload @:throws("java.lang.NumberFormatException") static function parseByte(param1 : String) : java.types.Int8; @:native("toString") @:overload static function _toString(param1 : java.types.Int8) : String; @:overload static function valueOf(param1 : java.types.Int8) : Byte; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Byte; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Byte; } @:realPath("java.lang.Byte_ByteCache") @:javaNative @:native("java.lang.Byte$ByteCache") @:javaCanonical("java.lang","Byte.ByteCache") extern class Byte_ByteCache { } haxe_3.2.1+dfsg.orig/std/java/lang/Character.hx0000664000175000017500000013470212607337712021224 0ustar andyandy00000000000000package java.lang; @:native("") // make sure the generator won't see this @:forward abstract Character(CharacterClass) from CharacterClass to CharacterClass { @:to @:extern inline public function toCharacter():java.types.Char16 return this.charValue(); @:from @:extern inline public static function fromCharacter(b:java.types.Char16):Character return CharacterClass.valueOf(b); @:extern public static var COMBINING_SPACING_MARK(get,never):java.types.Char16; @:extern static inline function get_COMBINING_SPACING_MARK():java.types.Char16 return CharacterClass.COMBINING_SPACING_MARK; @:extern public static var CONNECTOR_PUNCTUATION(get,never):java.types.Char16; @:extern static inline function get_CONNECTOR_PUNCTUATION():java.types.Char16 return CharacterClass.CONNECTOR_PUNCTUATION; @:extern public static var CONTROL(get,never):java.types.Char16; @:extern static inline function get_CONTROL():java.types.Char16 return CharacterClass.CONTROL; @:extern public static var CURRENCY_SYMBOL(get,never):java.types.Char16; @:extern static inline function get_CURRENCY_SYMBOL():java.types.Char16 return CharacterClass.CURRENCY_SYMBOL; @:extern public static var DASH_PUNCTUATION(get,never):java.types.Char16; @:extern static inline function get_DASH_PUNCTUATION():java.types.Char16 return CharacterClass.DASH_PUNCTUATION; @:extern public static var DECIMAL_DIGIT_NUMBER(get,never):java.types.Char16; @:extern static inline function get_DECIMAL_DIGIT_NUMBER():java.types.Char16 return CharacterClass.DECIMAL_DIGIT_NUMBER; @:extern public static var DIRECTIONALITY_ARABIC_NUMBER(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_ARABIC_NUMBER():java.types.Char16 return CharacterClass.DIRECTIONALITY_ARABIC_NUMBER; @:extern public static var DIRECTIONALITY_BOUNDARY_NEUTRAL(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_BOUNDARY_NEUTRAL():java.types.Char16 return CharacterClass.DIRECTIONALITY_BOUNDARY_NEUTRAL; @:extern public static var DIRECTIONALITY_COMMON_NUMBER_SEPARATOR(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_COMMON_NUMBER_SEPARATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_COMMON_NUMBER_SEPARATOR; @:extern public static var DIRECTIONALITY_EUROPEAN_NUMBER(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_EUROPEAN_NUMBER():java.types.Char16 return CharacterClass.DIRECTIONALITY_EUROPEAN_NUMBER; @:extern public static var DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR; @:extern public static var DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR; @:extern public static var DIRECTIONALITY_LEFT_TO_RIGHT(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_LEFT_TO_RIGHT():java.types.Char16 return CharacterClass.DIRECTIONALITY_LEFT_TO_RIGHT; @:extern public static var DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING():java.types.Char16 return CharacterClass.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING; @:extern public static var DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE():java.types.Char16 return CharacterClass.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE; @:extern public static var DIRECTIONALITY_NONSPACING_MARK(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_NONSPACING_MARK():java.types.Char16 return CharacterClass.DIRECTIONALITY_NONSPACING_MARK; @:extern public static var DIRECTIONALITY_OTHER_NEUTRALS(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_OTHER_NEUTRALS():java.types.Char16 return CharacterClass.DIRECTIONALITY_OTHER_NEUTRALS; @:extern public static var DIRECTIONALITY_PARAGRAPH_SEPARATOR(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_PARAGRAPH_SEPARATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_PARAGRAPH_SEPARATOR; @:extern public static var DIRECTIONALITY_POP_DIRECTIONAL_FORMAT(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_POP_DIRECTIONAL_FORMAT():java.types.Char16 return CharacterClass.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT; @:extern public static var DIRECTIONALITY_RIGHT_TO_LEFT(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_RIGHT_TO_LEFT():java.types.Char16 return CharacterClass.DIRECTIONALITY_RIGHT_TO_LEFT; @:extern public static var DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC():java.types.Char16 return CharacterClass.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; @:extern public static var DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING():java.types.Char16 return CharacterClass.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING; @:extern public static var DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE():java.types.Char16 return CharacterClass.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE; @:extern public static var DIRECTIONALITY_SEGMENT_SEPARATOR(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_SEGMENT_SEPARATOR():java.types.Char16 return CharacterClass.DIRECTIONALITY_SEGMENT_SEPARATOR; @:extern public static var DIRECTIONALITY_UNDEFINED(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_UNDEFINED():java.types.Char16 return CharacterClass.DIRECTIONALITY_UNDEFINED; @:extern public static var DIRECTIONALITY_WHITESPACE(get,never):java.types.Char16; @:extern static inline function get_DIRECTIONALITY_WHITESPACE():java.types.Char16 return CharacterClass.DIRECTIONALITY_WHITESPACE; @:extern public static var ENCLOSING_MARK(get,never):java.types.Char16; @:extern static inline function get_ENCLOSING_MARK():java.types.Char16 return CharacterClass.ENCLOSING_MARK; @:extern public static var END_PUNCTUATION(get,never):java.types.Char16; @:extern static inline function get_END_PUNCTUATION():java.types.Char16 return CharacterClass.END_PUNCTUATION; @:extern public static var FINAL_QUOTE_PUNCTUATION(get,never):java.types.Char16; @:extern static inline function get_FINAL_QUOTE_PUNCTUATION():java.types.Char16 return CharacterClass.FINAL_QUOTE_PUNCTUATION; @:extern public static var FORMAT(get,never):java.types.Char16; @:extern static inline function get_FORMAT():java.types.Char16 return CharacterClass.FORMAT; @:extern public static var INITIAL_QUOTE_PUNCTUATION(get,never):java.types.Char16; @:extern static inline function get_INITIAL_QUOTE_PUNCTUATION():java.types.Char16 return CharacterClass.INITIAL_QUOTE_PUNCTUATION; @:extern public static var LETTER_NUMBER(get,never):java.types.Char16; @:extern static inline function get_LETTER_NUMBER():java.types.Char16 return CharacterClass.LETTER_NUMBER; @:extern public static var LINE_SEPARATOR(get,never):java.types.Char16; @:extern static inline function get_LINE_SEPARATOR():java.types.Char16 return CharacterClass.LINE_SEPARATOR; @:extern public static var LOWERCASE_LETTER(get,never):java.types.Char16; @:extern static inline function get_LOWERCASE_LETTER():java.types.Char16 return CharacterClass.LOWERCASE_LETTER; @:extern public static var MATH_SYMBOL(get,never):java.types.Char16; @:extern static inline function get_MATH_SYMBOL():java.types.Char16 return CharacterClass.MATH_SYMBOL; @:extern public static var MAX_CODE_POINT(get,never):Int; @:extern static inline function get_MAX_CODE_POINT():Int return CharacterClass.MAX_CODE_POINT; @:extern public static var MAX_HIGH_SURROGATE(get,never):java.types.Char16; @:extern static inline function get_MAX_HIGH_SURROGATE():java.types.Char16 return CharacterClass.MAX_HIGH_SURROGATE; @:extern public static var MAX_LOW_SURROGATE(get,never):java.types.Char16; @:extern static inline function get_MAX_LOW_SURROGATE():java.types.Char16 return CharacterClass.MAX_LOW_SURROGATE; @:extern public static var MAX_RADIX(get,never):Int; @:extern static inline function get_MAX_RADIX():Int return CharacterClass.MAX_RADIX; @:extern public static var MAX_SURROGATE(get,never):java.types.Char16; @:extern static inline function get_MAX_SURROGATE():java.types.Char16 return CharacterClass.MAX_SURROGATE; @:extern public static var MAX_VALUE(get,never):java.types.Char16; @:extern static inline function get_MAX_VALUE():java.types.Char16 return CharacterClass.MAX_VALUE; @:extern public static var MIN_CODE_POINT(get,never):Int; @:extern static inline function get_MIN_CODE_POINT():Int return CharacterClass.MIN_CODE_POINT; @:extern public static var MIN_HIGH_SURROGATE(get,never):java.types.Char16; @:extern static inline function get_MIN_HIGH_SURROGATE():java.types.Char16 return CharacterClass.MIN_HIGH_SURROGATE; @:extern public static var MIN_LOW_SURROGATE(get,never):java.types.Char16; @:extern static inline function get_MIN_LOW_SURROGATE():java.types.Char16 return CharacterClass.MIN_LOW_SURROGATE; @:extern public static var MIN_RADIX(get,never):Int; @:extern static inline function get_MIN_RADIX():Int return CharacterClass.MIN_RADIX; @:extern public static var MIN_SUPPLEMENTARY_CODE_POINT(get,never):Int; @:extern static inline function get_MIN_SUPPLEMENTARY_CODE_POINT():Int return CharacterClass.MIN_SUPPLEMENTARY_CODE_POINT; @:extern public static var MIN_SURROGATE(get,never):java.types.Char16; @:extern static inline function get_MIN_SURROGATE():java.types.Char16 return CharacterClass.MIN_SURROGATE; @:extern public static var MIN_VALUE(get,never):java.types.Char16; @:extern static inline function get_MIN_VALUE():java.types.Char16 return CharacterClass.MIN_VALUE; @:extern public static var MODIFIER_LETTER(get,never):java.types.Char16; @:extern static inline function get_MODIFIER_LETTER():java.types.Char16 return CharacterClass.MODIFIER_LETTER; @:extern public static var MODIFIER_SYMBOL(get,never):java.types.Char16; @:extern static inline function get_MODIFIER_SYMBOL():java.types.Char16 return CharacterClass.MODIFIER_SYMBOL; @:extern public static var NON_SPACING_MARK(get,never):java.types.Char16; @:extern static inline function get_NON_SPACING_MARK():java.types.Char16 return CharacterClass.NON_SPACING_MARK; @:extern public static var OTHER_LETTER(get,never):java.types.Char16; @:extern static inline function get_OTHER_LETTER():java.types.Char16 return CharacterClass.OTHER_LETTER; @:extern public static var OTHER_NUMBER(get,never):java.types.Char16; @:extern static inline function get_OTHER_NUMBER():java.types.Char16 return CharacterClass.OTHER_NUMBER; @:extern public static var OTHER_PUNCTUATION(get,never):java.types.Char16; @:extern static inline function get_OTHER_PUNCTUATION():java.types.Char16 return CharacterClass.OTHER_PUNCTUATION; @:extern public static var OTHER_SYMBOL(get,never):java.types.Char16; @:extern static inline function get_OTHER_SYMBOL():java.types.Char16 return CharacterClass.OTHER_SYMBOL; @:extern public static var PARAGRAPH_SEPARATOR(get,never):java.types.Char16; @:extern static inline function get_PARAGRAPH_SEPARATOR():java.types.Char16 return CharacterClass.PARAGRAPH_SEPARATOR; @:extern public static var PRIVATE_USE(get,never):java.types.Char16; @:extern static inline function get_PRIVATE_USE():java.types.Char16 return CharacterClass.PRIVATE_USE; @:extern public static var SIZE(get,never):Int; @:extern static inline function get_SIZE():Int return CharacterClass.SIZE; @:extern public static var SPACE_SEPARATOR(get,never):java.types.Char16; @:extern static inline function get_SPACE_SEPARATOR():java.types.Char16 return CharacterClass.SPACE_SEPARATOR; @:extern public static var START_PUNCTUATION(get,never):java.types.Char16; @:extern static inline function get_START_PUNCTUATION():java.types.Char16 return CharacterClass.START_PUNCTUATION; @:extern public static var SURROGATE(get,never):java.types.Char16; @:extern static inline function get_SURROGATE():java.types.Char16 return CharacterClass.SURROGATE; @:extern public static var TITLECASE_LETTER(get,never):java.types.Char16; @:extern static inline function get_TITLECASE_LETTER():java.types.Char16 return CharacterClass.TITLECASE_LETTER; @:extern public static var TYPE(get,set):Class; @:extern static inline function get_TYPE():Class return CharacterClass.TYPE; @:extern static inline function set_TYPE(val:Class):Class return CharacterClass.TYPE = val; @:extern public static var UNASSIGNED(get,never):java.types.Char16; @:extern static inline function get_UNASSIGNED():java.types.Char16 return CharacterClass.UNASSIGNED; @:extern public static var UPPERCASE_LETTER(get,never):java.types.Char16; @:extern static inline function get_UPPERCASE_LETTER():java.types.Char16 return CharacterClass.UPPERCASE_LETTER; @:extern @:overload inline public static function charCount(param1:Int):Int return CharacterClass.charCount(param1); @:extern @:overload inline public static function codePointAt(param1:CharSequence, param2:Int):Int return CharacterClass.codePointAt(param1, param2); @:extern @:overload inline public static function codePointBefore(param1:CharSequence, param2:Int):Int return CharacterClass.codePointBefore(param1, param2); @:extern @:overload inline public static function codePointCount(param1:CharSequence, param2:Int, param3:Int):Int return CharacterClass.codePointCount(param1, param2, param3); @:extern @:overload inline public static function compare(param1:java.types.Char16, param2:java.types.Char16):Int return CharacterClass.compare(param1, param2); @:extern @:overload inline public static function digit(param1:java.types.Char16, param2:Int):Int return CharacterClass.digit(param1, param2); @:extern @:overload inline public static function forDigit(param1:Int, param2:Int):java.types.Char16 return CharacterClass.forDigit(param1, param2); @:extern @:overload inline public static function getDirectionality(param1:java.types.Char16):java.types.Char16 return CharacterClass.getDirectionality(param1); @:extern @:overload inline public static function getName(param1:Int):String return CharacterClass.getName(param1); @:extern @:overload inline public static function getNumericValue(param1:java.types.Char16):Int return CharacterClass.getNumericValue(param1); @:extern @:overload inline public static function getType(param1:java.types.Char16):Int return CharacterClass.getType(param1); @:extern @:overload inline public static function highSurrogate(param1:Int):java.types.Char16 return CharacterClass.highSurrogate(param1); @:extern @:overload inline public static function isAlphabetic(param1:Int):Bool return CharacterClass.isAlphabetic(param1); @:extern @:overload inline public static function isBmpCodePoint(param1:Int):Bool return CharacterClass.isBmpCodePoint(param1); @:extern @:overload inline public static function isDefined(param1:java.types.Char16):Bool return CharacterClass.isDefined(param1); @:extern @:overload inline public static function isDigit(param1:java.types.Char16):Bool return CharacterClass.isDigit(param1); @:extern @:overload inline public static function isHighSurrogate(param1:java.types.Char16):Bool return CharacterClass.isHighSurrogate(param1); @:extern @:overload inline public static function isISOControl(param1:java.types.Char16):Bool return CharacterClass.isISOControl(param1); @:extern @:overload inline public static function isIdentifierIgnorable(param1:java.types.Char16):Bool return CharacterClass.isIdentifierIgnorable(param1); @:extern @:overload inline public static function isIdeographic(param1:Int):Bool return CharacterClass.isIdeographic(param1); @:extern @:overload inline public static function isJavaIdentifierPart(param1:java.types.Char16):Bool return CharacterClass.isJavaIdentifierPart(param1); @:extern @:overload inline public static function isJavaIdentifierStart(param1:java.types.Char16):Bool return CharacterClass.isJavaIdentifierStart(param1); @:extern @:overload inline public static function isLetter(param1:java.types.Char16):Bool return CharacterClass.isLetter(param1); @:extern @:overload inline public static function isLetterOrDigit(param1:java.types.Char16):Bool return CharacterClass.isLetterOrDigit(param1); @:extern @:overload inline public static function isLowSurrogate(param1:java.types.Char16):Bool return CharacterClass.isLowSurrogate(param1); @:extern @:overload inline public static function isLowerCase(param1:java.types.Char16):Bool return CharacterClass.isLowerCase(param1); @:extern @:overload inline public static function isMirrored(param1:java.types.Char16):Bool return CharacterClass.isMirrored(param1); @:extern @:overload inline public static function isSpaceChar(param1:java.types.Char16):Bool return CharacterClass.isSpaceChar(param1); @:extern @:overload inline public static function isSupplementaryCodePoint(param1:Int):Bool return CharacterClass.isSupplementaryCodePoint(param1); @:extern @:overload inline public static function isSurrogate(param1:java.types.Char16):Bool return CharacterClass.isSurrogate(param1); @:extern @:overload inline public static function isSurrogatePair(param1:java.types.Char16, param2:java.types.Char16):Bool return CharacterClass.isSurrogatePair(param1, param2); @:extern @:overload inline public static function isTitleCase(param1:java.types.Char16):Bool return CharacterClass.isTitleCase(param1); @:extern @:overload inline public static function isUnicodeIdentifierPart(param1:java.types.Char16):Bool return CharacterClass.isUnicodeIdentifierPart(param1); @:extern @:overload inline public static function isUnicodeIdentifierStart(param1:java.types.Char16):Bool return CharacterClass.isUnicodeIdentifierStart(param1); @:extern @:overload inline public static function isUpperCase(param1:java.types.Char16):Bool return CharacterClass.isUpperCase(param1); @:extern @:overload inline public static function isValidCodePoint(param1:Int):Bool return CharacterClass.isValidCodePoint(param1); @:extern @:overload inline public static function isWhitespace(param1:java.types.Char16):Bool return CharacterClass.isWhitespace(param1); @:extern @:overload inline public static function lowSurrogate(param1:Int):java.types.Char16 return CharacterClass.lowSurrogate(param1); @:extern @:overload inline public static function offsetByCodePoints(param1:CharSequence, param2:Int, param3:Int):Int return CharacterClass.offsetByCodePoints(param1, param2, param3); @:extern @:overload inline public static function reverseBytes(param1:java.types.Char16):java.types.Char16 return CharacterClass.reverseBytes(param1); @:extern @:overload inline public static function toChars(param1:Int, param2:java.NativeArray, param3:Int):Int return CharacterClass.toChars(param1, param2, param3); @:extern @:overload inline public static function toCodePoint(param1:java.types.Char16, param2:java.types.Char16):Int return CharacterClass.toCodePoint(param1, param2); @:extern @:overload inline public static function toLowerCase(param1:java.types.Char16):java.types.Char16 return CharacterClass.toLowerCase(param1); @:extern @:overload inline public static function _toString(param1:java.types.Char16):String return CharacterClass._toString(param1); @:extern @:overload inline public static function toTitleCase(param1:java.types.Char16):java.types.Char16 return CharacterClass.toTitleCase(param1); @:extern @:overload inline public static function toUpperCase(param1:java.types.Char16):java.types.Char16 return CharacterClass.toUpperCase(param1); @:extern @:overload inline public static function valueOf(param1:java.types.Char16):Character return CharacterClass.valueOf(param1); } @:native("java.lang.Character") extern class CharacterClass implements Comparable { @:overload function new(param1 : java.types.Char16) : Void; @:overload function charValue() : java.types.Char16; @:overload function compareTo(param1 : Character) : Int; @:overload function compareTo(param1 : Dynamic) : Int; @:overload function equals(param1 : Dynamic) : Bool; @:overload function hashCode() : Int; @:overload function toString() : String; @:final static var COMBINING_SPACING_MARK(default,null) : java.types.Char16; @:final static var CONNECTOR_PUNCTUATION(default,null) : java.types.Char16; @:final static var CONTROL(default,null) : java.types.Char16; @:final static var CURRENCY_SYMBOL(default,null) : java.types.Char16; @:final static var DASH_PUNCTUATION(default,null) : java.types.Char16; @:final static var DECIMAL_DIGIT_NUMBER(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_ARABIC_NUMBER(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_BOUNDARY_NEUTRAL(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_COMMON_NUMBER_SEPARATOR(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_EUROPEAN_NUMBER(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_LEFT_TO_RIGHT(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_NONSPACING_MARK(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_OTHER_NEUTRALS(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_PARAGRAPH_SEPARATOR(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_POP_DIRECTIONAL_FORMAT(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_RIGHT_TO_LEFT(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_SEGMENT_SEPARATOR(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_UNDEFINED(default,null) : java.types.Char16; @:final static var DIRECTIONALITY_WHITESPACE(default,null) : java.types.Char16; @:final static var ENCLOSING_MARK(default,null) : java.types.Char16; @:final static var END_PUNCTUATION(default,null) : java.types.Char16; @:final static var FINAL_QUOTE_PUNCTUATION(default,null) : java.types.Char16; @:final static var FORMAT(default,null) : java.types.Char16; @:final static var INITIAL_QUOTE_PUNCTUATION(default,null) : java.types.Char16; @:final static var LETTER_NUMBER(default,null) : java.types.Char16; @:final static var LINE_SEPARATOR(default,null) : java.types.Char16; @:final static var LOWERCASE_LETTER(default,null) : java.types.Char16; @:final static var MATH_SYMBOL(default,null) : java.types.Char16; @:final static var MAX_CODE_POINT(default,null) : Int; @:final static var MAX_HIGH_SURROGATE(default,null) : java.types.Char16; @:final static var MAX_LOW_SURROGATE(default,null) : java.types.Char16; @:final static var MAX_RADIX(default,null) : Int; @:final static var MAX_SURROGATE(default,null) : java.types.Char16; @:final static var MAX_VALUE(default,null) : java.types.Char16; @:final static var MIN_CODE_POINT(default,null) : Int; @:final static var MIN_HIGH_SURROGATE(default,null) : java.types.Char16; @:final static var MIN_LOW_SURROGATE(default,null) : java.types.Char16; @:final static var MIN_RADIX(default,null) : Int; @:final static var MIN_SUPPLEMENTARY_CODE_POINT(default,null) : Int; @:final static var MIN_SURROGATE(default,null) : java.types.Char16; @:final static var MIN_VALUE(default,null) : java.types.Char16; @:final static var MODIFIER_LETTER(default,null) : java.types.Char16; @:final static var MODIFIER_SYMBOL(default,null) : java.types.Char16; @:final static var NON_SPACING_MARK(default,null) : java.types.Char16; @:final static var OTHER_LETTER(default,null) : java.types.Char16; @:final static var OTHER_NUMBER(default,null) : java.types.Char16; @:final static var OTHER_PUNCTUATION(default,null) : java.types.Char16; @:final static var OTHER_SYMBOL(default,null) : java.types.Char16; @:final static var PARAGRAPH_SEPARATOR(default,null) : java.types.Char16; @:final static var PRIVATE_USE(default,null) : java.types.Char16; @:final static var SIZE(default,null) : Int; @:final static var SPACE_SEPARATOR(default,null) : java.types.Char16; @:final static var START_PUNCTUATION(default,null) : java.types.Char16; @:final static var SURROGATE(default,null) : java.types.Char16; @:final static var TITLECASE_LETTER(default,null) : java.types.Char16; @:final static var TYPE : Class; @:final static var UNASSIGNED(default,null) : java.types.Char16; @:final static var UPPERCASE_LETTER(default,null) : java.types.Char16; @:overload static function charCount(param1 : Int) : Int; @:overload static function codePointAt(param1 : CharSequence, param2 : Int) : Int; @:overload static function codePointAt(param1 : java.NativeArray, param2 : Int, param3 : Int) : Int; @:overload static function codePointAt(param1 : java.NativeArray, param2 : Int) : Int; @:overload static function codePointBefore(param1 : CharSequence, param2 : Int) : Int; @:overload static function codePointBefore(param1 : java.NativeArray, param2 : Int, param3 : Int) : Int; @:overload static function codePointBefore(param1 : java.NativeArray, param2 : Int) : Int; @:overload static function codePointCount(param1 : CharSequence, param2 : Int, param3 : Int) : Int; @:overload static function codePointCount(param1 : java.NativeArray, param2 : Int, param3 : Int) : Int; @:overload static function compare(param1 : java.types.Char16, param2 : java.types.Char16) : Int; @:overload static function digit(param1 : java.types.Char16, param2 : Int) : Int; @:overload static function digit(param1 : Int, param2 : Int) : Int; @:overload static function forDigit(param1 : Int, param2 : Int) : java.types.Char16; @:overload static function getDirectionality(param1 : java.types.Char16) : java.types.Char16; @:overload static function getDirectionality(param1 : Int) : java.types.Char16; @:overload static function getName(param1 : Int) : String; @:overload static function getNumericValue(param1 : java.types.Char16) : Int; @:overload static function getNumericValue(param1 : Int) : Int; @:overload static function getType(param1 : java.types.Char16) : Int; @:overload static function getType(param1 : Int) : Int; @:overload static function highSurrogate(param1 : Int) : java.types.Char16; @:overload static function isAlphabetic(param1 : Int) : Bool; @:overload static function isBmpCodePoint(param1 : Int) : Bool; @:overload static function isDefined(param1 : java.types.Char16) : Bool; @:overload static function isDefined(param1 : Int) : Bool; @:overload static function isDigit(param1 : java.types.Char16) : Bool; @:overload static function isDigit(param1 : Int) : Bool; @:overload static function isHighSurrogate(param1 : java.types.Char16) : Bool; @:overload static function isISOControl(param1 : java.types.Char16) : Bool; @:overload static function isISOControl(param1 : Int) : Bool; @:overload static function isIdentifierIgnorable(param1 : java.types.Char16) : Bool; @:overload static function isIdentifierIgnorable(param1 : Int) : Bool; @:overload static function isIdeographic(param1 : Int) : Bool; @:overload static function isJavaIdentifierPart(param1 : java.types.Char16) : Bool; @:overload static function isJavaIdentifierPart(param1 : Int) : Bool; @:overload static function isJavaIdentifierStart(param1 : java.types.Char16) : Bool; @:overload static function isJavaIdentifierStart(param1 : Int) : Bool; @:overload @:deprecated static function isJavaLetter(param1 : java.types.Char16) : Bool; @:overload @:deprecated static function isJavaLetterOrDigit(param1 : java.types.Char16) : Bool; @:overload static function isLetter(param1 : java.types.Char16) : Bool; @:overload static function isLetter(param1 : Int) : Bool; @:overload static function isLetterOrDigit(param1 : java.types.Char16) : Bool; @:overload static function isLetterOrDigit(param1 : Int) : Bool; @:overload static function isLowSurrogate(param1 : java.types.Char16) : Bool; @:overload static function isLowerCase(param1 : java.types.Char16) : Bool; @:overload static function isLowerCase(param1 : Int) : Bool; @:overload static function isMirrored(param1 : java.types.Char16) : Bool; @:overload static function isMirrored(param1 : Int) : Bool; @:overload @:deprecated static function isSpace(param1 : java.types.Char16) : Bool; @:overload static function isSpaceChar(param1 : java.types.Char16) : Bool; @:overload static function isSpaceChar(param1 : Int) : Bool; @:overload static function isSupplementaryCodePoint(param1 : Int) : Bool; @:overload static function isSurrogate(param1 : java.types.Char16) : Bool; @:overload static function isSurrogatePair(param1 : java.types.Char16, param2 : java.types.Char16) : Bool; @:overload static function isTitleCase(param1 : java.types.Char16) : Bool; @:overload static function isTitleCase(param1 : Int) : Bool; @:overload static function isUnicodeIdentifierPart(param1 : java.types.Char16) : Bool; @:overload static function isUnicodeIdentifierPart(param1 : Int) : Bool; @:overload static function isUnicodeIdentifierStart(param1 : java.types.Char16) : Bool; @:overload static function isUnicodeIdentifierStart(param1 : Int) : Bool; @:overload static function isUpperCase(param1 : java.types.Char16) : Bool; @:overload static function isUpperCase(param1 : Int) : Bool; @:overload static function isValidCodePoint(param1 : Int) : Bool; @:overload static function isWhitespace(param1 : java.types.Char16) : Bool; @:overload static function isWhitespace(param1 : Int) : Bool; @:overload static function lowSurrogate(param1 : Int) : java.types.Char16; @:overload static function offsetByCodePoints(param1 : CharSequence, param2 : Int, param3 : Int) : Int; @:overload static function offsetByCodePoints(param1 : java.NativeArray, param2 : Int, param3 : Int, param4 : Int, param5 : Int) : Int; @:overload static function reverseBytes(param1 : java.types.Char16) : java.types.Char16; @:overload static function toChars(param1 : Int, param2 : java.NativeArray, param3 : Int) : Int; @:overload static function toChars(param1 : Int) : java.NativeArray; @:overload static function toCodePoint(param1 : java.types.Char16, param2 : java.types.Char16) : Int; @:overload static function toLowerCase(param1 : java.types.Char16) : java.types.Char16; @:overload static function toLowerCase(param1 : Int) : Int; @:native("toString") @:overload static function _toString(param1 : java.types.Char16) : String; @:overload static function toTitleCase(param1 : java.types.Char16) : java.types.Char16; @:overload static function toTitleCase(param1 : Int) : Int; @:overload static function toUpperCase(param1 : java.types.Char16) : java.types.Char16; @:overload static function toUpperCase(param1 : Int) : Int; @:overload static function valueOf(param1 : java.types.Char16) : Character; } @:realPath("java.lang.Character_CharacterCache") @:javaNative @:native("java.lang.Character$CharacterCache") @:javaCanonical("java.lang","Character.CharacterCache") extern class Character_CharacterCache { } @:realPath("java.lang.Character_Subset") @:javaNative @:native("java.lang.Character$Subset") @:javaCanonical("java.lang","Character.Subset") extern class Character_Subset { @:overload @:final function equals(param1 : Dynamic) : Bool; @:overload @:final function hashCode() : Int; @:overload @:final function toString() : String; } @:realPath("java.lang.Character_UnicodeBlock") @:final @:javaNative @:native("java.lang.Character$UnicodeBlock") @:javaCanonical("java.lang","Character.UnicodeBlock") extern class Character_UnicodeBlock extends Character_Subset { @:final static var AEGEAN_NUMBERS : Character_UnicodeBlock; @:final static var ALCHEMICAL_SYMBOLS : Character_UnicodeBlock; @:final static var ALPHABETIC_PRESENTATION_FORMS : Character_UnicodeBlock; @:final static var ANCIENT_GREEK_MUSICAL_NOTATION : Character_UnicodeBlock; @:final static var ANCIENT_GREEK_NUMBERS : Character_UnicodeBlock; @:final static var ANCIENT_SYMBOLS : Character_UnicodeBlock; @:final static var ARABIC : Character_UnicodeBlock; @:final static var ARABIC_PRESENTATION_FORMS_A : Character_UnicodeBlock; @:final static var ARABIC_PRESENTATION_FORMS_B : Character_UnicodeBlock; @:final static var ARABIC_SUPPLEMENT : Character_UnicodeBlock; @:final static var ARMENIAN : Character_UnicodeBlock; @:final static var ARROWS : Character_UnicodeBlock; @:final static var AVESTAN : Character_UnicodeBlock; @:final static var BALINESE : Character_UnicodeBlock; @:final static var BAMUM : Character_UnicodeBlock; @:final static var BAMUM_SUPPLEMENT : Character_UnicodeBlock; @:final static var BASIC_LATIN : Character_UnicodeBlock; @:final static var BATAK : Character_UnicodeBlock; @:final static var BENGALI : Character_UnicodeBlock; @:final static var BLOCK_ELEMENTS : Character_UnicodeBlock; @:final static var BOPOMOFO : Character_UnicodeBlock; @:final static var BOPOMOFO_EXTENDED : Character_UnicodeBlock; @:final static var BOX_DRAWING : Character_UnicodeBlock; @:final static var BRAHMI : Character_UnicodeBlock; @:final static var BRAILLE_PATTERNS : Character_UnicodeBlock; @:final static var BUGINESE : Character_UnicodeBlock; @:final static var BUHID : Character_UnicodeBlock; @:final static var BYZANTINE_MUSICAL_SYMBOLS : Character_UnicodeBlock; @:final static var CARIAN : Character_UnicodeBlock; @:final static var CHAM : Character_UnicodeBlock; @:final static var CHEROKEE : Character_UnicodeBlock; @:final static var CJK_COMPATIBILITY : Character_UnicodeBlock; @:final static var CJK_COMPATIBILITY_FORMS : Character_UnicodeBlock; @:final static var CJK_COMPATIBILITY_IDEOGRAPHS : Character_UnicodeBlock; @:final static var CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT : Character_UnicodeBlock; @:final static var CJK_RADICALS_SUPPLEMENT : Character_UnicodeBlock; @:final static var CJK_STROKES : Character_UnicodeBlock; @:final static var CJK_SYMBOLS_AND_PUNCTUATION : Character_UnicodeBlock; @:final static var CJK_UNIFIED_IDEOGRAPHS : Character_UnicodeBlock; @:final static var CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A : Character_UnicodeBlock; @:final static var CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B : Character_UnicodeBlock; @:final static var CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C : Character_UnicodeBlock; @:final static var CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D : Character_UnicodeBlock; @:final static var COMBINING_DIACRITICAL_MARKS : Character_UnicodeBlock; @:final static var COMBINING_DIACRITICAL_MARKS_SUPPLEMENT : Character_UnicodeBlock; @:final static var COMBINING_HALF_MARKS : Character_UnicodeBlock; @:final static var COMBINING_MARKS_FOR_SYMBOLS : Character_UnicodeBlock; @:final static var COMMON_INDIC_NUMBER_FORMS : Character_UnicodeBlock; @:final static var CONTROL_PICTURES : Character_UnicodeBlock; @:final static var COPTIC : Character_UnicodeBlock; @:final static var COUNTING_ROD_NUMERALS : Character_UnicodeBlock; @:final static var CUNEIFORM : Character_UnicodeBlock; @:final static var CUNEIFORM_NUMBERS_AND_PUNCTUATION : Character_UnicodeBlock; @:final static var CURRENCY_SYMBOLS : Character_UnicodeBlock; @:final static var CYPRIOT_SYLLABARY : Character_UnicodeBlock; @:final static var CYRILLIC : Character_UnicodeBlock; @:final static var CYRILLIC_EXTENDED_A : Character_UnicodeBlock; @:final static var CYRILLIC_EXTENDED_B : Character_UnicodeBlock; @:final static var CYRILLIC_SUPPLEMENTARY : Character_UnicodeBlock; @:final static var DESERET : Character_UnicodeBlock; @:final static var DEVANAGARI : Character_UnicodeBlock; @:final static var DEVANAGARI_EXTENDED : Character_UnicodeBlock; @:final static var DINGBATS : Character_UnicodeBlock; @:final static var DOMINO_TILES : Character_UnicodeBlock; @:final static var EGYPTIAN_HIEROGLYPHS : Character_UnicodeBlock; @:final static var EMOTICONS : Character_UnicodeBlock; @:final static var ENCLOSED_ALPHANUMERICS : Character_UnicodeBlock; @:final static var ENCLOSED_ALPHANUMERIC_SUPPLEMENT : Character_UnicodeBlock; @:final static var ENCLOSED_CJK_LETTERS_AND_MONTHS : Character_UnicodeBlock; @:final static var ENCLOSED_IDEOGRAPHIC_SUPPLEMENT : Character_UnicodeBlock; @:final static var ETHIOPIC : Character_UnicodeBlock; @:final static var ETHIOPIC_EXTENDED : Character_UnicodeBlock; @:final static var ETHIOPIC_EXTENDED_A : Character_UnicodeBlock; @:final static var ETHIOPIC_SUPPLEMENT : Character_UnicodeBlock; @:final static var GENERAL_PUNCTUATION : Character_UnicodeBlock; @:final static var GEOMETRIC_SHAPES : Character_UnicodeBlock; @:final static var GEORGIAN : Character_UnicodeBlock; @:final static var GEORGIAN_SUPPLEMENT : Character_UnicodeBlock; @:final static var GLAGOLITIC : Character_UnicodeBlock; @:final static var GOTHIC : Character_UnicodeBlock; @:final static var GREEK : Character_UnicodeBlock; @:final static var GREEK_EXTENDED : Character_UnicodeBlock; @:final static var GUJARATI : Character_UnicodeBlock; @:final static var GURMUKHI : Character_UnicodeBlock; @:final static var HALFWIDTH_AND_FULLWIDTH_FORMS : Character_UnicodeBlock; @:final static var HANGUL_COMPATIBILITY_JAMO : Character_UnicodeBlock; @:final static var HANGUL_JAMO : Character_UnicodeBlock; @:final static var HANGUL_JAMO_EXTENDED_A : Character_UnicodeBlock; @:final static var HANGUL_JAMO_EXTENDED_B : Character_UnicodeBlock; @:final static var HANGUL_SYLLABLES : Character_UnicodeBlock; @:final static var HANUNOO : Character_UnicodeBlock; @:final static var HEBREW : Character_UnicodeBlock; @:final static var HIGH_PRIVATE_USE_SURROGATES : Character_UnicodeBlock; @:final static var HIGH_SURROGATES : Character_UnicodeBlock; @:final static var HIRAGANA : Character_UnicodeBlock; @:final static var IDEOGRAPHIC_DESCRIPTION_CHARACTERS : Character_UnicodeBlock; @:final static var IMPERIAL_ARAMAIC : Character_UnicodeBlock; @:final static var INSCRIPTIONAL_PAHLAVI : Character_UnicodeBlock; @:final static var INSCRIPTIONAL_PARTHIAN : Character_UnicodeBlock; @:final static var IPA_EXTENSIONS : Character_UnicodeBlock; @:final static var JAVANESE : Character_UnicodeBlock; @:final static var KAITHI : Character_UnicodeBlock; @:final static var KANA_SUPPLEMENT : Character_UnicodeBlock; @:final static var KANBUN : Character_UnicodeBlock; @:final static var KANGXI_RADICALS : Character_UnicodeBlock; @:final static var KANNADA : Character_UnicodeBlock; @:final static var KATAKANA : Character_UnicodeBlock; @:final static var KATAKANA_PHONETIC_EXTENSIONS : Character_UnicodeBlock; @:final static var KAYAH_LI : Character_UnicodeBlock; @:final static var KHAROSHTHI : Character_UnicodeBlock; @:final static var KHMER : Character_UnicodeBlock; @:final static var KHMER_SYMBOLS : Character_UnicodeBlock; @:final static var LAO : Character_UnicodeBlock; @:final static var LATIN_1_SUPPLEMENT : Character_UnicodeBlock; @:final static var LATIN_EXTENDED_A : Character_UnicodeBlock; @:final static var LATIN_EXTENDED_ADDITIONAL : Character_UnicodeBlock; @:final static var LATIN_EXTENDED_B : Character_UnicodeBlock; @:final static var LATIN_EXTENDED_C : Character_UnicodeBlock; @:final static var LATIN_EXTENDED_D : Character_UnicodeBlock; @:final static var LEPCHA : Character_UnicodeBlock; @:final static var LETTERLIKE_SYMBOLS : Character_UnicodeBlock; @:final static var LIMBU : Character_UnicodeBlock; @:final static var LINEAR_B_IDEOGRAMS : Character_UnicodeBlock; @:final static var LINEAR_B_SYLLABARY : Character_UnicodeBlock; @:final static var LISU : Character_UnicodeBlock; @:final static var LOW_SURROGATES : Character_UnicodeBlock; @:final static var LYCIAN : Character_UnicodeBlock; @:final static var LYDIAN : Character_UnicodeBlock; @:final static var MAHJONG_TILES : Character_UnicodeBlock; @:final static var MALAYALAM : Character_UnicodeBlock; @:final static var MANDAIC : Character_UnicodeBlock; @:final static var MATHEMATICAL_ALPHANUMERIC_SYMBOLS : Character_UnicodeBlock; @:final static var MATHEMATICAL_OPERATORS : Character_UnicodeBlock; @:final static var MEETEI_MAYEK : Character_UnicodeBlock; @:final static var MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A : Character_UnicodeBlock; @:final static var MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B : Character_UnicodeBlock; @:final static var MISCELLANEOUS_SYMBOLS : Character_UnicodeBlock; @:final static var MISCELLANEOUS_SYMBOLS_AND_ARROWS : Character_UnicodeBlock; @:final static var MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS : Character_UnicodeBlock; @:final static var MISCELLANEOUS_TECHNICAL : Character_UnicodeBlock; @:final static var MODIFIER_TONE_LETTERS : Character_UnicodeBlock; @:final static var MONGOLIAN : Character_UnicodeBlock; @:final static var MUSICAL_SYMBOLS : Character_UnicodeBlock; @:final static var MYANMAR : Character_UnicodeBlock; @:final static var MYANMAR_EXTENDED_A : Character_UnicodeBlock; @:final static var NEW_TAI_LUE : Character_UnicodeBlock; @:final static var NKO : Character_UnicodeBlock; @:final static var NUMBER_FORMS : Character_UnicodeBlock; @:final static var OGHAM : Character_UnicodeBlock; @:final static var OLD_ITALIC : Character_UnicodeBlock; @:final static var OLD_PERSIAN : Character_UnicodeBlock; @:final static var OLD_SOUTH_ARABIAN : Character_UnicodeBlock; @:final static var OLD_TURKIC : Character_UnicodeBlock; @:final static var OL_CHIKI : Character_UnicodeBlock; @:final static var OPTICAL_CHARACTER_RECOGNITION : Character_UnicodeBlock; @:final static var ORIYA : Character_UnicodeBlock; @:final static var OSMANYA : Character_UnicodeBlock; @:final static var PHAGS_PA : Character_UnicodeBlock; @:final static var PHAISTOS_DISC : Character_UnicodeBlock; @:final static var PHOENICIAN : Character_UnicodeBlock; @:final static var PHONETIC_EXTENSIONS : Character_UnicodeBlock; @:final static var PHONETIC_EXTENSIONS_SUPPLEMENT : Character_UnicodeBlock; @:final static var PLAYING_CARDS : Character_UnicodeBlock; @:final static var PRIVATE_USE_AREA : Character_UnicodeBlock; @:final static var REJANG : Character_UnicodeBlock; @:final static var RUMI_NUMERAL_SYMBOLS : Character_UnicodeBlock; @:final static var RUNIC : Character_UnicodeBlock; @:final static var SAMARITAN : Character_UnicodeBlock; @:final static var SAURASHTRA : Character_UnicodeBlock; @:final static var SHAVIAN : Character_UnicodeBlock; @:final static var SINHALA : Character_UnicodeBlock; @:final static var SMALL_FORM_VARIANTS : Character_UnicodeBlock; @:final static var SPACING_MODIFIER_LETTERS : Character_UnicodeBlock; @:final static var SPECIALS : Character_UnicodeBlock; @:final static var SUNDANESE : Character_UnicodeBlock; @:final static var SUPERSCRIPTS_AND_SUBSCRIPTS : Character_UnicodeBlock; @:final static var SUPPLEMENTAL_ARROWS_A : Character_UnicodeBlock; @:final static var SUPPLEMENTAL_ARROWS_B : Character_UnicodeBlock; @:final static var SUPPLEMENTAL_MATHEMATICAL_OPERATORS : Character_UnicodeBlock; @:final static var SUPPLEMENTAL_PUNCTUATION : Character_UnicodeBlock; @:final static var SUPPLEMENTARY_PRIVATE_USE_AREA_A : Character_UnicodeBlock; @:final static var SUPPLEMENTARY_PRIVATE_USE_AREA_B : Character_UnicodeBlock; @:deprecated @:final static var SURROGATES_AREA : Character_UnicodeBlock; @:final static var SYLOTI_NAGRI : Character_UnicodeBlock; @:final static var SYRIAC : Character_UnicodeBlock; @:final static var TAGALOG : Character_UnicodeBlock; @:final static var TAGBANWA : Character_UnicodeBlock; @:final static var TAGS : Character_UnicodeBlock; @:final static var TAI_LE : Character_UnicodeBlock; @:final static var TAI_THAM : Character_UnicodeBlock; @:final static var TAI_VIET : Character_UnicodeBlock; @:final static var TAI_XUAN_JING_SYMBOLS : Character_UnicodeBlock; @:final static var TAMIL : Character_UnicodeBlock; @:final static var TELUGU : Character_UnicodeBlock; @:final static var THAANA : Character_UnicodeBlock; @:final static var THAI : Character_UnicodeBlock; @:final static var TIBETAN : Character_UnicodeBlock; @:final static var TIFINAGH : Character_UnicodeBlock; @:final static var TRANSPORT_AND_MAP_SYMBOLS : Character_UnicodeBlock; @:final static var UGARITIC : Character_UnicodeBlock; @:final static var UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS : Character_UnicodeBlock; @:final static var UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED : Character_UnicodeBlock; @:final static var VAI : Character_UnicodeBlock; @:final static var VARIATION_SELECTORS : Character_UnicodeBlock; @:final static var VARIATION_SELECTORS_SUPPLEMENT : Character_UnicodeBlock; @:final static var VEDIC_EXTENSIONS : Character_UnicodeBlock; @:final static var VERTICAL_FORMS : Character_UnicodeBlock; @:final static var YIJING_HEXAGRAM_SYMBOLS : Character_UnicodeBlock; @:final static var YI_RADICALS : Character_UnicodeBlock; @:final static var YI_SYLLABLES : Character_UnicodeBlock; @:overload @:final static function forName(param1 : String) : Character_UnicodeBlock; @:overload static function of(param1 : java.types.Char16) : Character_UnicodeBlock; @:overload static function of(param1 : Int) : Character_UnicodeBlock; } @:realPath("java.lang.Character_UnicodeScript") @:javaCanonical("java.lang","Character.UnicodeScript") @:native("java.lang.Character$UnicodeScript") extern enum Character_UnicodeScript { COMMON; LATIN; GREEK; CYRILLIC; ARMENIAN; HEBREW; ARABIC; SYRIAC; THAANA; DEVANAGARI; BENGALI; GURMUKHI; GUJARATI; ORIYA; TAMIL; TELUGU; KANNADA; MALAYALAM; SINHALA; THAI; LAO; TIBETAN; MYANMAR; GEORGIAN; HANGUL; ETHIOPIC; CHEROKEE; CANADIAN_ABORIGINAL; OGHAM; RUNIC; KHMER; MONGOLIAN; HIRAGANA; KATAKANA; BOPOMOFO; HAN; YI; OLD_ITALIC; GOTHIC; DESERET; INHERITED; TAGALOG; HANUNOO; BUHID; TAGBANWA; LIMBU; TAI_LE; LINEAR_B; UGARITIC; SHAVIAN; OSMANYA; CYPRIOT; BRAILLE; BUGINESE; COPTIC; NEW_TAI_LUE; GLAGOLITIC; TIFINAGH; SYLOTI_NAGRI; OLD_PERSIAN; KHAROSHTHI; BALINESE; CUNEIFORM; PHOENICIAN; PHAGS_PA; NKO; SUNDANESE; BATAK; LEPCHA; OL_CHIKI; VAI; SAURASHTRA; KAYAH_LI; REJANG; LYCIAN; CARIAN; LYDIAN; CHAM; TAI_THAM; TAI_VIET; AVESTAN; EGYPTIAN_HIEROGLYPHS; SAMARITAN; MANDAIC; LISU; BAMUM; JAVANESE; MEETEI_MAYEK; IMPERIAL_ARAMAIC; OLD_SOUTH_ARABIAN; INSCRIPTIONAL_PARTHIAN; INSCRIPTIONAL_PAHLAVI; OLD_TURKIC; BRAHMI; KAITHI; UNKNOWN; } haxe_3.2.1+dfsg.orig/std/java/lang/Double.hx0000664000175000017500000001210312607337712020530 0ustar andyandy00000000000000package java.lang; @:native("") // make sure the generator won't see this @:forward abstract Double(DoubleClass) from DoubleClass to DoubleClass { @:to @:extern inline public function toFloat():Float return this.doubleValue(); @:from @:extern inline public static function fromFloat(b:Float):Double return DoubleClass.valueOf(b); @:extern public static var MAX_EXPONENT(get,never):Int; @:extern static inline function get_MAX_EXPONENT():Int return DoubleClass.MAX_EXPONENT; @:extern public static var MAX_VALUE(get,never):Float; @:extern static inline function get_MAX_VALUE():Float return DoubleClass.MAX_VALUE; @:extern public static var MIN_EXPONENT(get,never):Int; @:extern static inline function get_MIN_EXPONENT():Int return DoubleClass.MIN_EXPONENT; @:extern public static var MIN_NORMAL(get,never):Float; @:extern static inline function get_MIN_NORMAL():Float return DoubleClass.MIN_NORMAL; @:extern public static var MIN_VALUE(get,never):Float; @:extern static inline function get_MIN_VALUE():Float return DoubleClass.MIN_VALUE; @:extern public static var NEGATIVE_INFINITY(get,never):Float; @:extern static inline function get_NEGATIVE_INFINITY():Float return DoubleClass.NEGATIVE_INFINITY; @:extern public static var NaN(get,never):Float; @:extern static inline function get_NaN():Float return DoubleClass.NaN; @:extern public static var POSITIVE_INFINITY(get,never):Float; @:extern static inline function get_POSITIVE_INFINITY():Float return DoubleClass.POSITIVE_INFINITY; @:extern public static var SIZE(get,never):Int; @:extern static inline function get_SIZE():Int return DoubleClass.SIZE; @:extern public static var TYPE(get,set):Class; @:extern static inline function get_TYPE():Class return DoubleClass.TYPE; @:extern static inline function set_TYPE(val:Class):Class return DoubleClass.TYPE = val; @:extern @:overload inline public static function compare(param1:Float, param2:Float):Int return DoubleClass.compare(param1, param2); @:extern @:overload inline public static function doubleToLongBits(param1:Float):haxe.Int64 return DoubleClass.doubleToLongBits(param1); @:extern @:overload inline public static function doubleToRawLongBits(param1:Float):haxe.Int64 return DoubleClass.doubleToRawLongBits(param1); @:extern @:overload inline public static function _isInfinite(param1:Float):Bool return DoubleClass._isInfinite(param1); @:extern @:overload inline public static function _isNaN(param1:Float):Bool return DoubleClass._isNaN(param1); @:extern @:overload inline public static function longBitsToDouble(param1:haxe.Int64):Float return DoubleClass.longBitsToDouble(param1); @:extern @:overload inline public static function parseDouble(param1:String):Float return DoubleClass.parseDouble(param1); @:extern @:overload inline public static function toHexString(param1:Float):String return DoubleClass.toHexString(param1); @:extern @:overload inline public static function _toString(param1:Float):String return DoubleClass._toString(param1); @:extern @:overload inline public static function valueOf(param1:String):Double return DoubleClass.valueOf(param1); } @:native("java.lang.Double") extern class DoubleClass extends Number implements Comparable { @:overload function new(param1 : Float) : Void; @:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void; @:overload function compareTo(param1 : Double) : Int; @:overload function compareTo(param1 : Dynamic) : Int; @:overload function equals(param1 : Dynamic) : Bool; @:overload function hashCode() : Int; @:overload function isInfinite() : Bool; @:overload function isNaN() : Bool; @:overload function toString() : String; @:final static var MAX_EXPONENT(default,null) : Int; @:final static var MAX_VALUE(default,null) : Float; @:final static var MIN_EXPONENT(default,null) : Int; @:final static var MIN_NORMAL(default,null) : Float; @:final static var MIN_VALUE(default,null) : Float; @:final static var NEGATIVE_INFINITY(default,null) : Float; @:final static var NaN(default,null) : Float; @:final static var POSITIVE_INFINITY(default,null) : Float; @:final static var SIZE(default,null) : Int; @:final static var TYPE : Class; @:overload static function compare(param1 : Float, param2 : Float) : Int; @:overload static function doubleToLongBits(param1 : Float) : haxe.Int64; @:overload static function doubleToRawLongBits(param1 : Float) : haxe.Int64; @:native("isInfinite") @:overload static function _isInfinite(param1 : Float) : Bool; @:native("isNaN") @:overload static function _isNaN(param1 : Float) : Bool; @:overload static function longBitsToDouble(param1 : haxe.Int64) : Float; @:overload @:throws("java.lang.NumberFormatException") static function parseDouble(param1 : String) : Float; @:overload static function toHexString(param1 : Float) : String; @:native("toString") @:overload static function _toString(param1 : Float) : String; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Double; @:overload static function valueOf(param1 : Float) : Double; } haxe_3.2.1+dfsg.orig/std/java/lang/Float.hx0000664000175000017500000001217012607337712020367 0ustar andyandy00000000000000package java.lang; @:native("") // make sure the generator won't see this @:forward abstract Float(FloatClass) from FloatClass to FloatClass { @:to @:extern inline public function toFloat():std.StdTypes.Float return this.floatValue(); @:from @:extern inline public static function fromFloat(b:std.StdTypes.Single):Float return FloatClass.valueOf(b); @:extern public static var MAX_EXPONENT(get,never):Int; @:extern static inline function get_MAX_EXPONENT():Int return FloatClass.MAX_EXPONENT; @:extern public static var MAX_VALUE(get,never):Single; @:extern static inline function get_MAX_VALUE():Single return FloatClass.MAX_VALUE; @:extern public static var MIN_EXPONENT(get,never):Int; @:extern static inline function get_MIN_EXPONENT():Int return FloatClass.MIN_EXPONENT; @:extern public static var MIN_NORMAL(get,never):Single; @:extern static inline function get_MIN_NORMAL():Single return FloatClass.MIN_NORMAL; @:extern public static var MIN_VALUE(get,never):Single; @:extern static inline function get_MIN_VALUE():Single return FloatClass.MIN_VALUE; @:extern public static var NEGATIVE_INFINITY(get,never):Single; @:extern static inline function get_NEGATIVE_INFINITY():Single return FloatClass.NEGATIVE_INFINITY; @:extern public static var NaN(get,never):Single; @:extern static inline function get_NaN():Single return FloatClass.NaN; @:extern public static var POSITIVE_INFINITY(get,never):Single; @:extern static inline function get_POSITIVE_INFINITY():Single return FloatClass.POSITIVE_INFINITY; @:extern public static var SIZE(get,never):Int; @:extern static inline function get_SIZE():Int return FloatClass.SIZE; @:extern public static var TYPE(get,set):Class; @:extern static inline function get_TYPE():Class return FloatClass.TYPE; @:extern static inline function set_TYPE(val:Class):Class return FloatClass.TYPE = val; @:extern @:overload inline public static function compare(param1:Single, param2:Single):Int return FloatClass.compare(param1, param2); @:extern @:overload inline public static function floatToIntBits(param1:Single):Int return FloatClass.floatToIntBits(param1); @:extern @:overload inline public static function floatToRawIntBits(param1:Single):Int return FloatClass.floatToRawIntBits(param1); @:extern @:overload inline public static function intBitsToFloat(param1:Int):Single return FloatClass.intBitsToFloat(param1); @:extern @:overload inline public static function _isInfinite(param1:Single):Bool return FloatClass._isInfinite(param1); @:extern @:overload inline public static function _isNaN(param1:Single):Bool return FloatClass._isNaN(param1); @:extern @:overload inline public static function parseFloat(param1:String):Single return FloatClass.parseFloat(param1); @:extern @:overload inline public static function toHexString(param1:Single):String return FloatClass.toHexString(param1); @:extern @:overload inline public static function _toString(param1:Single):String return FloatClass._toString(param1); @:extern @:overload inline public static function valueOf(param1:String):Float return FloatClass.valueOf(param1); } @:native("java.lang.Float") extern class FloatClass extends Number implements Comparable { @:overload function new(param1 : Single) : Void; @:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void; @:overload function new(param1 : std.StdTypes.Float) : Void; @:overload function compareTo(param1 : Float) : Int; @:overload function compareTo(param1 : Dynamic) : Int; @:overload function equals(param1 : Dynamic) : Bool; @:overload function hashCode() : Int; @:overload function isInfinite() : Bool; @:overload function isNaN() : Bool; @:overload function toString() : String; @:final static var MAX_EXPONENT(default,null) : Int; @:final static var MAX_VALUE(default,null) : Single; @:final static var MIN_EXPONENT(default,null) : Int; @:final static var MIN_NORMAL(default,null) : Single; @:final static var MIN_VALUE(default,null) : Single; @:final static var NEGATIVE_INFINITY(default,null) : Single; @:final static var NaN(default,null) : Single; @:final static var POSITIVE_INFINITY(default,null) : Single; @:final static var SIZE(default,null) : Int; @:final static var TYPE : Class; @:overload static function compare(param1 : Single, param2 : Single) : Int; @:overload static function floatToIntBits(param1 : Single) : Int; @:overload static function floatToRawIntBits(param1 : Single) : Int; @:overload static function intBitsToFloat(param1 : Int) : Single; @:native("isInfinite") @:overload static function _isInfinite(param1 : Single) : Bool; @:native("isNaN") @:overload static function _isNaN(param1 : Single) : Bool; @:overload @:throws("java.lang.NumberFormatException") static function parseFloat(param1 : String) : Single; @:overload static function toHexString(param1 : Single) : String; @:native("toString") @:overload static function _toString(param1 : Single) : String; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Float; @:overload static function valueOf(param1 : Single) : Float; } haxe_3.2.1+dfsg.orig/std/java/lang/Integer.hx0000664000175000017500000001421312607337712020717 0ustar andyandy00000000000000package java.lang; @:native("") // make sure the generator won't see this @:forward abstract Integer(IntegerClass) from IntegerClass to IntegerClass { @:to @:extern inline public function toInt():Int return this.intValue(); @:from @:extern inline public static function fromInt(b:Int):Integer return IntegerClass.valueOf(b); @:extern public static var MAX_VALUE(get,never):Int; @:extern static inline function get_MAX_VALUE():Int return IntegerClass.MAX_VALUE; @:extern public static var MIN_VALUE(get,never):Int; @:extern static inline function get_MIN_VALUE():Int return IntegerClass.MIN_VALUE; @:extern public static var SIZE(get,never):Int; @:extern static inline function get_SIZE():Int return IntegerClass.SIZE; @:extern public static var TYPE(get,set):Class; @:extern static inline function get_TYPE():Class return IntegerClass.TYPE; @:extern static inline function set_TYPE(val:Class):Class return IntegerClass.TYPE = val; @:extern @:overload inline public static function bitCount(param1:Int):Int return IntegerClass.bitCount(param1); @:extern @:overload inline public static function compare(param1:Int, param2:Int):Int return IntegerClass.compare(param1, param2); @:extern @:overload inline public static function decode(param1:String):Integer return IntegerClass.decode(param1); @:extern @:overload inline public static function getInteger(param1:String):Integer return IntegerClass.getInteger(param1); @:extern @:overload inline public static function highestOneBit(param1:Int):Int return IntegerClass.highestOneBit(param1); @:extern @:overload inline public static function lowestOneBit(param1:Int):Int return IntegerClass.lowestOneBit(param1); @:extern @:overload inline public static function numberOfLeadingZeros(param1:Int):Int return IntegerClass.numberOfLeadingZeros(param1); @:extern @:overload inline public static function numberOfTrailingZeros(param1:Int):Int return IntegerClass.numberOfTrailingZeros(param1); @:extern @:overload inline public static function parseInt(param1:String, param2:Int):Int return IntegerClass.parseInt(param1, param2); @:extern @:overload inline public static function reverse(param1:Int):Int return IntegerClass.reverse(param1); @:extern @:overload inline public static function reverseBytes(param1:Int):Int return IntegerClass.reverseBytes(param1); @:extern @:overload inline public static function rotateLeft(param1:Int, param2:Int):Int return IntegerClass.rotateLeft(param1, param2); @:extern @:overload inline public static function rotateRight(param1:Int, param2:Int):Int return IntegerClass.rotateRight(param1, param2); @:extern @:overload inline public static function signum(param1:Int):Int return IntegerClass.signum(param1); @:extern @:overload inline public static function toBinaryString(param1:Int):String return IntegerClass.toBinaryString(param1); @:extern @:overload inline public static function toHexString(param1:Int):String return IntegerClass.toHexString(param1); @:extern @:overload inline public static function toOctalString(param1:Int):String return IntegerClass.toOctalString(param1); @:extern @:overload inline public static function _toString(param1:Int, param2:Int):String return IntegerClass._toString(param1, param2); @:extern @:overload inline public static function valueOf(param1:String, param2:Int):Integer return IntegerClass.valueOf(param1, param2); } @:native("java.lang.Integer") extern class IntegerClass extends Number implements Comparable { @:overload function new(param1 : Int) : Void; @:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void; @:overload function compareTo(param1 : Integer) : Int; @:overload function compareTo(param1 : Dynamic) : Int; @:overload function equals(param1 : Dynamic) : Bool; @:overload function hashCode() : Int; @:overload function toString() : String; @:final static var MAX_VALUE(default,null) : Int; @:final static var MIN_VALUE(default,null) : Int; @:final static var SIZE(default,null) : Int; @:final static var TYPE : Class; @:overload static function bitCount(param1 : Int) : Int; @:overload static function compare(param1 : Int, param2 : Int) : Int; @:overload @:throws("java.lang.NumberFormatException") static function decode(param1 : String) : Integer; @:overload static function getInteger(param1 : String) : Integer; @:overload static function getInteger(param1 : String, param2 : Integer) : Integer; @:overload static function getInteger(param1 : String, param2 : Int) : Integer; @:overload static function highestOneBit(param1 : Int) : Int; @:overload static function lowestOneBit(param1 : Int) : Int; @:overload static function numberOfLeadingZeros(param1 : Int) : Int; @:overload static function numberOfTrailingZeros(param1 : Int) : Int; @:overload @:throws("java.lang.NumberFormatException") static function parseInt(param1 : String, param2 : Int) : Int; @:overload @:throws("java.lang.NumberFormatException") static function parseInt(param1 : String) : Int; @:overload static function reverse(param1 : Int) : Int; @:overload static function reverseBytes(param1 : Int) : Int; @:overload static function rotateLeft(param1 : Int, param2 : Int) : Int; @:overload static function rotateRight(param1 : Int, param2 : Int) : Int; @:overload static function signum(param1 : Int) : Int; @:overload static function toBinaryString(param1 : Int) : String; @:overload static function toHexString(param1 : Int) : String; @:overload static function toOctalString(param1 : Int) : String; @:native("toString") @:overload static function _toString(param1 : Int, param2 : Int) : String; @:native("toString") @:overload static function _toString(param1 : Int) : String; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Integer; @:overload static function valueOf(param1 : Int) : Integer; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Integer; } @:realPath("java.lang.Integer_IntegerCache") @:javaNative @:native("java.lang.Integer$IntegerCache") @:javaCanonical("java.lang","Integer.IntegerCache") extern class Integer_IntegerCache { } haxe_3.2.1+dfsg.orig/std/java/lang/Long.hx0000664000175000017500000001451712607337712020230 0ustar andyandy00000000000000package java.lang; @:native("") // make sure the generator won't see this @:forward abstract Long(LongClass) from LongClass to LongClass { @:to @:extern inline public function toLong():haxe.Int64 return this.longValue(); @:from @:extern inline public static function fromLong(b:haxe.Int64):Long return LongClass.valueOf(b); @:extern public static var MAX_VALUE(get,never):haxe.Int64; @:extern static inline function get_MAX_VALUE():haxe.Int64 return LongClass.MAX_VALUE; @:extern public static var MIN_VALUE(get,never):haxe.Int64; @:extern static inline function get_MIN_VALUE():haxe.Int64 return LongClass.MIN_VALUE; @:extern public static var SIZE(get,never):Int; @:extern static inline function get_SIZE():Int return LongClass.SIZE; @:extern public static var TYPE(get,set):Class; @:extern static inline function get_TYPE():Class return LongClass.TYPE; @:extern static inline function set_TYPE(val:Class):Class return LongClass.TYPE = val; @:extern @:overload inline public static function bitCount(param1:haxe.Int64):Int return LongClass.bitCount(param1); @:extern @:overload inline public static function compare(param1:haxe.Int64, param2:haxe.Int64):Int return LongClass.compare(param1, param2); @:extern @:overload inline public static function decode(param1:String):Long return LongClass.decode(param1); @:extern @:overload inline public static function getLong(param1:String, param2:Long):Long return LongClass.getLong(param1, param2); @:extern @:overload inline public static function highestOneBit(param1:haxe.Int64):haxe.Int64 return LongClass.highestOneBit(param1); @:extern @:overload inline public static function lowestOneBit(param1:haxe.Int64):haxe.Int64 return LongClass.lowestOneBit(param1); @:extern @:overload inline public static function numberOfLeadingZeros(param1:haxe.Int64):Int return LongClass.numberOfLeadingZeros(param1); @:extern @:overload inline public static function numberOfTrailingZeros(param1:haxe.Int64):Int return LongClass.numberOfTrailingZeros(param1); @:extern @:overload inline public static function parseLong(param1:String):haxe.Int64 return LongClass.parseLong(param1); @:extern @:overload inline public static function reverse(param1:haxe.Int64):haxe.Int64 return LongClass.reverse(param1); @:extern @:overload inline public static function reverseBytes(param1:haxe.Int64):haxe.Int64 return LongClass.reverseBytes(param1); @:extern @:overload inline public static function rotateLeft(param1:haxe.Int64, param2:Int):haxe.Int64 return LongClass.rotateLeft(param1, param2); @:extern @:overload inline public static function rotateRight(param1:haxe.Int64, param2:Int):haxe.Int64 return LongClass.rotateRight(param1, param2); @:extern @:overload inline public static function signum(param1:haxe.Int64):Int return LongClass.signum(param1); @:extern @:overload inline public static function toBinaryString(param1:haxe.Int64):String return LongClass.toBinaryString(param1); @:extern @:overload inline public static function toHexString(param1:haxe.Int64):String return LongClass.toHexString(param1); @:extern @:overload inline public static function toOctalString(param1:haxe.Int64):String return LongClass.toOctalString(param1); @:extern @:overload inline public static function _toString(param1:haxe.Int64):String return LongClass._toString(param1); @:extern @:overload inline public static function valueOf(param1:haxe.Int64):Long return LongClass.valueOf(param1); } @:native("java.lang.Long") extern class LongClass extends Number implements Comparable { @:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void; @:overload function new(param1 : haxe.Int64) : Void; @:overload function compareTo(param1 : Dynamic) : Int; @:overload function compareTo(param1 : Long) : Int; @:overload function equals(param1 : Dynamic) : Bool; @:overload function hashCode() : Int; @:overload function toString() : String; @:final static var MAX_VALUE(default,null) : haxe.Int64; @:final static var MIN_VALUE(default,null) : haxe.Int64; @:final static var SIZE(default,null) : Int; @:final static var TYPE : Class; @:overload static function bitCount(param1 : haxe.Int64) : Int; @:overload static function compare(param1 : haxe.Int64, param2 : haxe.Int64) : Int; @:overload @:throws("java.lang.NumberFormatException") static function decode(param1 : String) : Long; @:overload static function getLong(param1 : String, param2 : Long) : Long; @:overload static function getLong(param1 : String) : Long; @:overload static function getLong(param1 : String, param2 : haxe.Int64) : Long; @:overload static function highestOneBit(param1 : haxe.Int64) : haxe.Int64; @:overload static function lowestOneBit(param1 : haxe.Int64) : haxe.Int64; @:overload static function numberOfLeadingZeros(param1 : haxe.Int64) : Int; @:overload static function numberOfTrailingZeros(param1 : haxe.Int64) : Int; @:overload @:throws("java.lang.NumberFormatException") static function parseLong(param1 : String) : haxe.Int64; @:overload @:throws("java.lang.NumberFormatException") static function parseLong(param1 : String, param2 : Int) : haxe.Int64; @:overload static function reverse(param1 : haxe.Int64) : haxe.Int64; @:overload static function reverseBytes(param1 : haxe.Int64) : haxe.Int64; @:overload static function rotateLeft(param1 : haxe.Int64, param2 : Int) : haxe.Int64; @:overload static function rotateRight(param1 : haxe.Int64, param2 : Int) : haxe.Int64; @:overload static function signum(param1 : haxe.Int64) : Int; @:overload static function toBinaryString(param1 : haxe.Int64) : String; @:overload static function toHexString(param1 : haxe.Int64) : String; @:overload static function toOctalString(param1 : haxe.Int64) : String; @:native("toString") @:overload static function _toString(param1 : haxe.Int64) : String; @:native("toString") @:overload static function _toString(param1 : haxe.Int64, param2 : Int) : String; @:overload static function valueOf(param1 : haxe.Int64) : Long; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Long; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Long; } @:realPath("java.lang.Long_LongCache") @:javaNative @:native("java.lang.Long$LongCache") @:javaCanonical("java.lang","Long.LongCache") extern class Long_LongCache { } haxe_3.2.1+dfsg.orig/std/java/lang/Short.hx0000664000175000017500000000723512607337712020427 0ustar andyandy00000000000000package java.lang; @:native("") // make sure the generator won't see this @:forward abstract Short(ShortClass) from ShortClass to ShortClass { @:to @:extern inline public function toShort():java.types.Int16 return this.shortValue(); @:from @:extern inline public static function fromShort(b:java.types.Int16):Short return ShortClass.valueOf(b); @:extern public static var MAX_VALUE(get,never):java.types.Int16; @:extern static inline function get_MAX_VALUE():java.types.Int16 return ShortClass.MAX_VALUE; @:extern public static var MIN_VALUE(get,never):java.types.Int16; @:extern static inline function get_MIN_VALUE():java.types.Int16 return ShortClass.MIN_VALUE; @:extern public static var SIZE(get,never):Int; @:extern static inline function get_SIZE():Int return ShortClass.SIZE; @:extern public static var TYPE(get,set):Class; @:extern static inline function get_TYPE():Class return ShortClass.TYPE; @:extern static inline function set_TYPE(val:Class):Class return ShortClass.TYPE = val; @:extern @:overload inline public static function compare(param1:java.types.Int16, param2:java.types.Int16):Int return ShortClass.compare(param1, param2); @:extern @:overload inline public static function decode(param1:String):Short return ShortClass.decode(param1); @:extern @:overload inline public static function parseShort(param1:String, param2:Int):java.types.Int16 return ShortClass.parseShort(param1, param2); @:extern @:overload inline public static function reverseBytes(param1:java.types.Int16):java.types.Int16 return ShortClass.reverseBytes(param1); @:extern @:overload inline public static function _toString(param1:java.types.Int16):String return ShortClass._toString(param1); @:extern @:overload inline public static function valueOf(param1:String, param2:Int):Short return ShortClass.valueOf(param1, param2); } @:native("java.lang.Short") extern class ShortClass extends Number implements Comparable { @:overload function new(param1 : java.types.Int16) : Void; @:overload @:throws("java.lang.NumberFormatException") function new(param1 : String) : Void; @:overload function compareTo(param1 : Short) : Int; @:overload function compareTo(param1 : Dynamic) : Int; @:overload function equals(param1 : Dynamic) : Bool; @:overload function hashCode() : Int; @:overload function toString() : String; @:final static var MAX_VALUE(default,null) : java.types.Int16; @:final static var MIN_VALUE(default,null) : java.types.Int16; @:final static var SIZE(default,null) : Int; @:final static var TYPE : Class; @:overload static function compare(param1 : java.types.Int16, param2 : java.types.Int16) : Int; @:overload @:throws("java.lang.NumberFormatException") static function decode(param1 : String) : Short; @:overload @:throws("java.lang.NumberFormatException") static function parseShort(param1 : String, param2 : Int) : java.types.Int16; @:overload @:throws("java.lang.NumberFormatException") static function parseShort(param1 : String) : java.types.Int16; @:overload static function reverseBytes(param1 : java.types.Int16) : java.types.Int16; @:native("toString") @:overload static function _toString(param1 : java.types.Int16) : String; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String, param2 : Int) : Short; @:overload static function valueOf(param1 : java.types.Int16) : Short; @:overload @:throws("java.lang.NumberFormatException") static function valueOf(param1 : String) : Short; } @:realPath("java.lang.Short_ShortCache") @:javaNative @:native("java.lang.Short$ShortCache") @:javaCanonical("java.lang","Short.ShortCache") extern class Short_ShortCache { } haxe_3.2.1+dfsg.orig/std/java/net/SslSocket.hx0000664000175000017500000000271712607337712021107 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package java.net; @:native('haxe.java.net.SslSocket') class SslSocket extends sys.net.Socket { override private function create() : Void { try { this.sock = java.javax.net.ssl.SSLSocketFactory.getDefault().createSocket(); this.server = java.javax.net.ssl.SSLServerSocketFactory.getDefault().createServerSocket(); } catch(e:Dynamic) throw e; } } haxe_3.2.1+dfsg.orig/std/java/types/Char16.hx0000664000175000017500000000007412607337712020571 0ustar andyandy00000000000000package java.types; typedef Char16 = java.StdTypes.Char16; haxe_3.2.1+dfsg.orig/std/java/types/Int16.hx0000664000175000017500000000007212607337712020444 0ustar andyandy00000000000000package java.types; typedef Int16 = java.StdTypes.Int16; haxe_3.2.1+dfsg.orig/std/java/types/Int8.hx0000664000175000017500000000007012607337712020363 0ustar andyandy00000000000000package java.types; typedef Int8 = java.StdTypes.Int8; haxe_3.2.1+dfsg.orig/std/java/vm/AtomicList.hx0000664000175000017500000000243512607337712021076 0ustar andyandy00000000000000package java.vm; import java.util.concurrent.atomic.AtomicReference; /** A lock-free queue implementation **/ @:native('haxe.java.vm.AtomicList') @:nativeGen class AtomicList { @:volatile @:private var head:AtomicNode; @:volatile @:private var tail:AtomicReference>; public function new() { this.head = new AtomicNode(null); this.head.set(new AtomicNode(null)); this.tail = new AtomicReference(head); } public function add(v:T) { var n = new AtomicNode(v), tail = this.tail; var p = null; while( !((p = tail.get()).compareAndSet(null, n)) ) { tail.compareAndSet(p, p.get()); } tail.compareAndSet(p, n); } public function pop():Null { var p = null, pget = null, head = head; do { p = head.get(); if ( (pget = p.get()) == null) return null; //empty } while(!head.compareAndSet(p, pget)); var ret = pget.value; pget.value = null; return ret; } public function peek() { var ret = head.get(); if (ret == null) return null; //empty return ret.value; } public function peekLast() { return tail.get().value; } } @:native('haxe.java.vm.AtomicNode') @:nativeGen class AtomicNode extends AtomicReference> { public var value:T; public function new(value) { super(); this.value = value; } } haxe_3.2.1+dfsg.orig/std/java/vm/Deque.hx0000664000175000017500000000226512607337712020072 0ustar andyandy00000000000000package java.vm; import java.Lib; /** A Lock-free Queue implementation **/ @:native('haxe.java.vm.Deque') @:nativeGen class Deque { @:private var head:Node; @:private var tail:Node; public function new() { this.head = this.tail = new Node(null); } public function add(i : T) { var n = new Node(i); untyped __lock__(this, { tail.next = n; tail = n; try { untyped this.notify(); } catch(e:Dynamic) { throw e; } }); } public function push(i : T) { var n = new Node(i); untyped __lock__(this, { n.next = head.next; head.next = n; try { untyped this.notify(); } catch(e:Dynamic) { throw e; } }); } public function pop(block : Bool) : Null { var ret = null; untyped __lock__(this, { var n = null; do { n = head.next; if (n != null) { ret = n.value; n.value = null; head = n; } else if (block) { //block try { untyped this.wait(); } catch(e:Dynamic) { throw e; } } } while( block && n == null ); }); return ret; } } @:native('haxe.java.vm.DequeNode') @:nativeGen class Node { public var value:T; public var next:Node; public function new(val) { this.value = val; } } haxe_3.2.1+dfsg.orig/std/java/vm/Gc.hx0000664000175000017500000000047212607337712017356 0ustar andyandy00000000000000package java.vm; @:native('haxe.java.vm.Gc') class Gc { public static function run( major : Bool ) { java.lang.System.gc(); } public static function stats() : { heap : Int, free : Int } { var r = java.lang.Runtime.getRuntime(); return { heap : cast r.totalMemory(), free : cast r.freeMemory() }; } } haxe_3.2.1+dfsg.orig/std/java/vm/Lock.hx0000664000175000017500000000355512607337712017722 0ustar andyandy00000000000000package java.vm; import java.Lib; import java.lang.System; using haxe.Int64; @:native('haxe.java.vm.Lock') class Lock { @:private @:volatile var releasedCount = 0; /** Creates a new lock, which is initially locked **/ public function new() { } /** Waits for a lock to be released and acquire it. If `timeout` (in seconds) is not null and expires then the returned value is false **/ public function wait(?timeout : Float) : Bool { var ret = false; java.Lib.lock(this, { if (--releasedCount < 0) { if (timeout == null) { // since .notify() is asynchronous, this `while` is needed // because there is a very remote possibility of release() awaking a thread, // but before it releases, another thread calls wait - and since the release count // is still positive, it will get the lock. while( releasedCount < 0 ) { try { untyped __java__("this.wait()"); } catch(e:java.lang.InterruptedException) { } } } else { var timeout:haxe.Int64 = cast timeout * 1000; var cur = System.currentTimeMillis(), max = cur.add(timeout); // see above comment about this while loop while ( releasedCount < 0 && cur.compare(max) < 0 ) { try { var t = max.sub(cur); untyped __java__("this.wait({0})",t); cur = System.currentTimeMillis(); } catch(e:java.lang.InterruptedException) { } } } } ret = this.releasedCount >= 0; if (!ret) this.releasedCount++; //timed out }); return ret; } /** Release a lock. The thread does not need to own the lock to be able to release it. If a lock is released several times, it can be acquired as many times **/ public function release() { untyped __lock__(this, { if (++releasedCount >= 0) { untyped this.notify(); } }); } } haxe_3.2.1+dfsg.orig/std/java/vm/Mutex.hx0000664000175000017500000000202212607337712020120 0ustar andyandy00000000000000package java.vm; import java.util.concurrent.Semaphore; @:native('haxe.java.vm.Mutex') class Mutex { @:private var lock:Semaphore; /** Creates a mutex, which can be used to acquire a temporary lock to access some resource. The main difference with a lock is that a mutex must always be released by the owner thread **/ public function new() { this.lock = new Semaphore(1); } /** Try to acquire the mutex, returns true if acquire or false if it's already locked by another thread. **/ public function tryAcquire():Bool { return this.lock.tryAcquire(); } /** The current thread acquire the mutex or wait if not available. The same thread can acquire several times the same mutex, but must release it as many times it has been acquired. **/ public function acquire():Void { this.lock.acquire(); } /** Release a mutex that has been acquired by the current thread. If the current thread does not own the mutex, an exception will be thrown **/ public function release():Void { this.lock.release(); } } haxe_3.2.1+dfsg.orig/std/java/vm/Thread.hx0000664000175000017500000000332312607337712020232 0ustar andyandy00000000000000package java.vm; import java.Lib; @:native('haxe.java.vm.Thread') class Thread { @:private static var javaThreadToHaxe = new haxe.ds.WeakMap(); @:private static var mainJavaThread = java.lang.Thread.currentThread(); @:private static var mainHaxeThread = { var ret = new Thread(); javaThreadToHaxe.set(mainJavaThread, ret); ret; }; private static function getThread(jt:java.lang.Thread):Thread { if (Std.is(jt, HaxeThread)) { var t:HaxeThread = cast jt; return t.threadObject; } else if (jt == mainJavaThread) { return mainHaxeThread; } else { var ret = null; untyped __lock__(javaThreadToHaxe, { ret = javaThreadToHaxe.get(jt); if (ret == null) { ret = new Thread(); javaThreadToHaxe.set(jt, ret); } }); return ret; } } private var messages:Deque; function new() { this.messages = new Deque(); } public function sendMessage(obj:Dynamic) { messages.add(obj); } public static function current():Thread { return getThread( java.lang.Thread.currentThread() ); } public static function readMessage(block : Bool) : Dynamic { return current().messages.pop(block); } public static function create(fn:Void->Void):Thread { var ret = new Thread(); var t = new HaxeThread(ret, fn); t.start(); return ret; } } @:native('haxe.java.vm.HaxeThread') private class HaxeThread extends java.lang.Thread { public var threadObject(default, null):Thread; private var runFunction:Void->Void; @:overload override public function run():Void { runFunction(); } public function new(hxThread:Thread, run:Void->Void) { super(); threadObject = hxThread; runFunction = run; setDaemon(true); } } haxe_3.2.1+dfsg.orig/std/java/vm/Tls.hx0000664000175000017500000000057612607337712017574 0ustar andyandy00000000000000package java.vm; /** Thread-local Storage implementation **/ @:native('haxe.java.vm.Tls') class Tls { var t : java.lang.ThreadLocal; public var value(get,set):T; public function new() { this.t = new java.lang.ThreadLocal(); } inline private function get_value():T { return t.get(); } inline private function set_value(v:T):T { t.set(v); return v; } } haxe_3.2.1+dfsg.orig/std/js/Boot.hx0000775000175000017500000001632312607337712017006 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; private class HaxeError extends js.Error { var val:Dynamic; public function new(val:Dynamic) untyped { super(); this.val = __define_feature__("js.Boot.HaxeError", val); this.message = String(val); if (js.Error.captureStackTrace) js.Error.captureStackTrace(this, HaxeError); } } @:dox(hide) class Boot { private static function __unhtml(s : String) { return s.split("&").join("&").split("<").join("<").split(">").join(">"); } private static function __trace(v,i : haxe.PosInfos) { untyped { var msg = if( i != null ) i.fileName+":"+i.lineNumber+": " else ""; #if jsfl msg += __string_rec(v,""); fl.trace(msg); #else msg += __string_rec(v, ""); if( i != null && i.customParams != null ) for( v in i.customParams ) msg += "," + __string_rec(v, ""); var d; if( __js__("typeof")(document) != "undefined" && (d = document.getElementById("haxe:trace")) != null ) d.innerHTML += __unhtml(msg)+"
"; else if( __js__("typeof console") != "undefined" && __js__("console").log != null ) __js__("console").log(msg); #end } } private static function __clear_trace() { untyped { #if jsfl fl.outputPanel.clear(); #else var d = document.getElementById("haxe:trace"); if( d != null ) d.innerHTML = ""; #end } } static inline function isClass(o:Dynamic) : Bool { return untyped __define_feature__("js.Boot.isClass", o.__name__); } static inline function isEnum(e:Dynamic) : Bool { return untyped __define_feature__("js.Boot.isEnum", e.__ename__); } static function getClass(o:Dynamic) : Dynamic { if (Std.is(o, Array)) return Array; else { var cl = untyped __define_feature__("js.Boot.getClass", o.__class__); if (cl != null) return cl; var name = __nativeClassName(o); if (name != null) return __resolveNativeClass(name); return null; } } @:ifFeature("has_enum") private static function __string_rec(o,s:String) { untyped { if( o == null ) return "null"; if( s.length >= 5 ) return "<...>"; // too much deep recursion var t = __js__("typeof(o)"); if( t == "function" && (isClass(o) || isEnum(o)) ) t = "object"; switch( t ) { case "object": if( __js__("o instanceof Array") ) { if( o.__enum__ ) { if( o.length == 2 ) return o[0]; var str = o[0]+"("; s += "\t"; for( i in 2...o.length ) { if( i != 2 ) str += "," + __string_rec(o[i],s); else str += __string_rec(o[i],s); } return str + ")"; } var l = o.length; var i; var str = "["; s += "\t"; for( i in 0...l ) str += (if (i > 0) "," else "")+__string_rec(o[i],s); str += "]"; return str; } var tostr; try { tostr = untyped o.toString; } catch( e : Dynamic ) { // strange error on IE return "???"; } if( tostr != null && tostr != __js__("Object.toString") && __typeof__(tostr) == "function" ) { var s2 = o.toString(); if( s2 != "[object Object]") return s2; } var k : String = null; var str = "{\n"; s += "\t"; var hasp = (o.hasOwnProperty != null); __js__("for( var k in o ) {"); if( hasp && !o.hasOwnProperty(k) ) __js__("continue"); if( k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__" ) __js__("continue"); if( str.length != 2 ) str += ", \n"; str += s + k + " : "+__string_rec(o[k],s); __js__("}"); s = s.substring(1); str += "\n" + s + "}"; return str; case "function": return ""; case "string": return o; default: return String(o); } } } private static function __interfLoop(cc : Dynamic,cl : Dynamic) { if( cc == null ) return false; if( cc == cl ) return true; var intf : Dynamic = cc.__interfaces__; if( intf != null ) for( i in 0...intf.length ) { var i : Dynamic = intf[i]; if( i == cl || __interfLoop(i,cl) ) return true; } return __interfLoop(cc.__super__,cl); } @:ifFeature("typed_catch") private static function __instanceof(o : Dynamic,cl : Dynamic) { if( cl == null ) return false; switch( cl ) { case Int: return (untyped __js__("(o|0) === o")); case Float: return (untyped __js__("typeof"))(o) == "number"; case Bool: return (untyped __js__("typeof"))(o) == "boolean"; case String: return (untyped __js__("typeof"))(o) == "string"; case Array: return (untyped __js__("(o instanceof Array)")) && o.__enum__ == null; case Dynamic: return true; default: if( o != null ) { // Check if o is an instance of a Haxe class or a native JS object if( (untyped __js__("typeof"))(cl) == "function" ) { if( untyped __js__("o instanceof cl") ) return true; if( __interfLoop(getClass(o),cl) ) return true; } else if ( (untyped __js__("typeof"))(cl) == "object" && __isNativeObj(cl) ) { if( untyped __js__("o instanceof cl") ) return true; } } else { return false; } // do not use isClass/isEnum here untyped __feature__("Class.*",if( cl == Class && o.__name__ != null ) return true); untyped __feature__("Enum.*",if( cl == Enum && o.__ename__ != null ) return true); return o.__enum__ == cl; } } @:ifFeature("typed_cast") private static function __cast(o : Dynamic, t : Dynamic) { if (__instanceof(o, t)) return o; else throw "Cannot cast " +Std.string(o) + " to " +Std.string(t); } static var __toStr = untyped __js__("{}.toString"); // get native JS [[Class]] static function __nativeClassName(o:Dynamic):String { var name = untyped __toStr.call(o).slice(8, -1); // exclude general Object and Function // also exclude Math and JSON, because instanceof cannot be called on them if (name == "Object" || name == "Function" || name == "Math" || name == "JSON") return null; return name; } // check for usable native JS object static function __isNativeObj(o:Dynamic):Bool { return __nativeClassName(o) != null; } // resolve native JS class in the global scope: static function __resolveNativeClass(name:String) { return untyped js.Lib.global[name]; } } haxe_3.2.1+dfsg.orig/std/js/Browser.hx0000664000175000017500000000713612607337712017525 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; import js.html.Storage; import js.html.XMLHttpRequest; class Browser { /** The global window object. */ public static var window(get, never):js.html.Window; inline static function get_window() return untyped __js__("window"); /** Shortcut to Window.document. */ public static var document(get, never):js.html.HTMLDocument; inline static function get_document() return untyped __js__("window.document"); /** Shortcut to Window.location. */ public static var location(get, never):js.html.Location; inline static function get_location() return untyped __js__("window.location"); /** Shortcut to Window.navigator. */ public static var navigator(get, never):js.html.Navigator; inline static function get_navigator() return untyped __js__("window.navigator"); /** Shortcut to Window.console. */ public static var console(get, never):js.html.Console; inline static function get_console() return untyped __js__("window.console"); /** * True if a window object exists, false otherwise. * * This can be used to check if the code is being executed in a non-browser * environment such as node.js. */ public static var supported(get, never):Bool; inline static function get_supported() return untyped __typeof__(window) != "undefined"; /** * Safely gets the browser's local storage, or returns null if localStorage is unsupported or * disabled. */ public static function getLocalStorage() : Storage { try { var s = window.localStorage; s.getItem(""); return s; } catch( e : Dynamic ) { return null; } } /** * Safely gets the browser's session storage, or returns null if sessionStorage is unsupported * or disabled. */ public static function getSessionStorage() : Storage { try { var s = window.sessionStorage; s.getItem(""); return s; } catch( e : Dynamic ) { return null; } } /** * Creates an XMLHttpRequest, with a fallback to ActiveXObject for ancient versions of Internet * Explorer. */ public static function createXMLHttpRequest() : XMLHttpRequest { if( untyped __js__("typeof XMLHttpRequest") != "undefined" ) { return new XMLHttpRequest(); } if( untyped __js__("typeof ActiveXObject") != "undefined" ) { return untyped __new__("ActiveXObject","Microsoft.XMLHTTP"); } throw "Unable to create XMLHttpRequest object."; } /** Display an alert message box containing the given message. See also `Window.alert()`. **/ public static function alert( v : Dynamic ) { @:privateAccess window.alert(Boot.__string_rec(v,"")); } } haxe_3.2.1+dfsg.orig/std/js/Cookie.hx0000664000175000017500000000455612607337712017316 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; class Cookie { /** Create or update a cookie. expireDelay (seconds), if null, the cookie expires at end of session **/ public static function set( name : String, value : String, ?expireDelay : Int, ?path : String, ?domain : String ){ var s = name+"="+StringTools.urlEncode(value); if( expireDelay != null ){ var d = DateTools.delta(Date.now(),expireDelay*1000); s += ";expires=" + untyped d.toGMTString(); } if( path != null ){ s += ";path="+path; } if( domain != null ){ s += ";domain="+domain; } Browser.document.cookie = s; } /** Returns all cookies **/ public static function all(){ var h = new haxe.ds.StringMap(); var a = Browser.document.cookie.split(";"); for( e in a ){ e = StringTools.ltrim(e); var t = e.split("="); if( t.length < 2 ) continue; h.set(t[0],StringTools.urlDecode(t[1])); } return h; } /** Returns value of a cookie. **/ public static function get( name : String ){ return all().get(name); } /** Returns true if a cookie [name] exists **/ public static function exists( name : String ){ return all().exists(name); } /** Remove a cookie **/ public static function remove( name : String, ?path : String, ?domain : String ){ set(name,"",-10,path,domain); } } haxe_3.2.1+dfsg.orig/std/js/Error.hx0000664000175000017500000000362612607337712017173 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; @:native("Error") extern class Error { var message : String; var name : String; var stack(default,null) : String; function new(?message : String) : Void; } @:native("EvalError") extern class EvalError extends Error { function new(?message : String) : Void; } @:native("RangeError") extern class RangeError extends Error { function new(?message : String) : Void; } @:native("ReferenceError") extern class ReferenceError extends Error { function new(?message : String) : Void; } @:native("SyntaxError") extern class SyntaxError extends Error { function new(?message : String) : Void; } @:native("TypeError") extern class TypeError extends Error { function new(?message : String) : Void; } @:native("URIError") extern class URIError extends Error { function new(?message : String) : Void; } haxe_3.2.1+dfsg.orig/std/js/JQuery.hx0000664000175000017500000003561512607337712017324 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; import js.html.Window; import js.html.Element; typedef JqEvent = { var target : Element; var currentTarget : Element; var relatedTarget : Element; var delegateTarget : Element; var type : String; var timeStamp : Int; //var data : Dynamic; //var namespace : String; //var result : Dynamic; // position var pageX : Int; var pageY : Int; var wheelDelta : Int; // keys var keyCode : Int; var charCode : Int; var shiftKey : Bool; var ctrlKey : Bool; var altKey : Bool; var metaKey : Bool; var which : Int; // propagation function isDefaultPrevented() : Bool; function isImmediatePropagationStopped() : Bool; function isPropagationStopped() : Bool; function preventDefault() : Void; function stopImmediatePropagation() : Void; function stopPropagation() : Void; } extern class JQueryHelper { @:overload(function(j:JQuery):JQuery{}) @:overload(function(j:Window):JQuery{}) @:overload(function(j:Element):JQuery { } ) public static inline function J( html : haxe.extern.EitherType>> ) : JQuery { return new JQuery(cast html); } public static var JTHIS(get, null) : JQuery; static inline function get_JTHIS() : JQuery { return new JQuery(js.Lib.nativeThis); } } @:initPackage extern class JQuery implements ArrayAccess { var context(default,null) : Element; var length(default, null) : Int; @:selfCall @:overload(function(j:JQuery):Void{}) @:overload(function(j:Window):Void{}) @:overload(function(j:Element):Void{}) function new( html : String ) : Void; // attributes function addClass( className : String ) : JQuery; function removeClass( ?className : String ) : JQuery; function hasClass( className : String ) : Bool; function toggleClass( className : String, ?addRemove : Bool ) : JQuery; @:overload(function(name:String,value:String):JQuery{}) function attr( name : String ) : String; function removeAttr( attr : String ) : JQuery; @:overload(function(name:String,value:Dynamic):JQuery{}) function prop( name : String ) : Dynamic; @:overload(function(prop:String,value:String):JQuery{}) @:overload(function(map:{}):JQuery{}) function css( prop : String ) : String; @:overload(function(html:String):JQuery{}) @:overload(function(html:JQuery):JQuery{}) function html() : String; @:overload(function(value:String):JQuery{}) function val() : String; @:overload(function(text:String):JQuery{}) function text() : String; // Size & Position @:overload(function(value:Int):JQuery{}) function width() : Int; @:overload(function(value:Int):JQuery{}) function height() : Int; @:overload(function(value:Int):JQuery{}) function innerWidth() : Int; @:overload(function(value:Int):JQuery{}) function innerHeight() : Int; function outerWidth( ?includeMargin : Bool ) : Int; function outerHeight( ?includeMargin : Bool ) : Int; @:overload(function(value:Int):JQuery{}) function scrollLeft() : Int; @:overload(function(value:Int):JQuery{}) function scrollTop() : Int; @:overload(function(value: { left : Int, top : Int }):JQuery{}) function offset() : { left : Int, top : Int }; function offsetParent() : JQuery; @:overload(function(value: { left : Int, top : Int }):JQuery{}) function position() : { left : Int, top : Int }; // current group manipulation @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) @:overload(function(value:Array):JQuery{}) function add( selector : String, ?context : JQuery ) : JQuery; function andSelf() : JQuery; function children( ?selector : String ) : JQuery; function clone( ?withDataAndEvents : Bool ) : JQuery; function closest( selector : String, ?context : JQuery ) : JQuery; function contents() : JQuery; @:overload(function( f : Int -> Element -> Void ):JQuery{}) function each( f : Void -> Void ) : JQuery; function end() : JQuery; function eq( index : Int ) : JQuery; function filter( selector : String ) : JQuery; function find( selector : String ) : JQuery; function first() : JQuery; function index( ?selector : String ) : Int; function last( ?selector : String ) : JQuery; function has( selector : String ) : JQuery; function next( ?selector : String ) : JQuery; function nextAll( ?selector : String ) : JQuery; function nextUntil( ?selector : String ) : JQuery; function parent( ?selector : String ) : JQuery; function parents( ?selector : String ) : JQuery; function parentsUntil( ?selector : String ) : JQuery; @:overload(function(value:Element):JQuery{}) function not( selector : String ) : JQuery; function prev( ?selector : String ) : JQuery; function prevAll( ?selector : String ) : JQuery; function prevUntil( ?selector : String ) : JQuery; function pushStack( elements : Array ) : JQuery; function siblings( ?selector : String ) : JQuery; function size() : Int; function slice( start : Int, ?end : Int ) : JQuery; function toArray() : Array; // DOM changes @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function before( html : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function after( html : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function append( html : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function appendTo( html : String ) : JQuery; function detach( ?selector : String ) : JQuery; function empty() : JQuery; // remove all texts @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function insertBefore( html : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function insertAfter( html : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function prepend( html : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function prependTo( html : String ) : JQuery; function remove( ?selector : String ) : JQuery; function replaceAll( selector : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function replaceWith( html : String ) : JQuery; function unwrap() : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function wrap( html : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function wrapAll( html : String ) : JQuery; @:overload(function(value:JQuery):JQuery{}) @:overload(function(value:Element):JQuery{}) function wrapInner( html : String ) : JQuery; // animation @:overload(function(properties:{},?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function animate( properties : { }, ?duration : Int, ?callb : Void -> Void ) : JQuery; function delay( duration : Int, ?queueName : String ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function hide( ?duration : Int, ?call : Void -> Void ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function fadeIn( ?duration : Int, ?call : Void -> Void ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function fadeOut( ?duration : Int, ?call : Void -> Void ) : JQuery; @:overload(function(duration:Int,opacity:Float,?easing:String,?call:Void->Void) : JQuery{}) function fadeTo( duration : Int, opacity : Float, ?call : Void -> Void ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function fadeToggle( ?duration : Int, ?call : Void -> Void ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function show( ?duration : Int, ?call : Void -> Void ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function slideDown( ?duration : Int, ?call : Void -> Void ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function slideToggle( ?duration : Int, ?call : Void -> Void ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function slideUp( ?duration : Int, ?call : Void -> Void ) : JQuery; function stop( ?clearQueue : Bool, ?jumpToEnd : Bool ) : JQuery; @:overload(function(?duration:Int,?easing:String,?call:Void->Void) : JQuery{}) function toggle( ?duration : Int, ?call : Void -> Void ) : JQuery; // Events function blur( ?callb : JqEvent -> Void ) : JQuery; function change( ?callb : JqEvent -> Void ) : JQuery; @:overload(function(callb:Void->Void):JQuery { } ) @:overload(function(callb:JQuery.JqEvent->Void):JQuery{}) @:overload(function(callb:Void->Bool):JQuery{}) function click( ?callb : JqEvent -> Void ) : JQuery; function dblclick( ?callb : JqEvent -> Void ) : JQuery; function error( ?callb : JqEvent -> Void ) : JQuery; function focus( ?callb : JqEvent -> Void ) : JQuery; function focusin( ?callb : JqEvent -> Void ) : JQuery; function focusout( ?callb : JqEvent -> Void ) : JQuery; @:overload(function(onInOut:JqEvent->Void):JQuery{}) function hover( onIn : JqEvent -> Void, ?onOut : JqEvent -> Void ) : JQuery; @:overload(function( callb : JQuery.JqEvent -> Bool ) : JQuery {}) function keydown( ?callb : JqEvent -> Void ) : JQuery; @:overload(function( callb : JQuery.JqEvent -> Bool ) : JQuery {}) function keypress( ?callb : JqEvent -> Void ) : JQuery; @:overload(function( callb : JQuery.JqEvent -> Bool ) : JQuery {}) function keyup( ?callb : JqEvent -> Void ) : JQuery; function mousedown( ?callb : JqEvent -> Void ) : JQuery; function mouseenter( ?callb : JqEvent -> Void ) : JQuery; function mouseleave( ?callb : JqEvent -> Void ) : JQuery; function mouseout( ?callb : JqEvent -> Void ) : JQuery; function mouseover( ?callb : JqEvent -> Void ) : JQuery; function mousemove( ?callb : JqEvent -> Void ) : JQuery; function mouseup( ?callb : JqEvent -> Void ) : JQuery; // AJAX overloads @:overload(function( url:String, ?data : {}, ?callb : String -> String -> Void ) : JQuery {}) @:overload(function( url:String, ?data : {}, ?callb : String -> Void ) : JQuery {}) @:overload(function( url:String, ?data : {}, ?callb : Void -> Void ) : JQuery {}) function load( ?callb : JqEvent -> Void ) : JQuery; function ready( callb : JqEvent -> Void ) : JQuery; function resize( ?callb : JqEvent -> Void ) : JQuery; function scroll( ?callb : JqEvent -> Void ) : JQuery; function select( ?callb : JqEvent -> Void ) : JQuery; function submit( ?callb : JqEvent -> Void ) : JQuery; function unload( ?callb : JqEvent -> Void ) : JQuery; function bind( events : String, callb : JqEvent -> Void ) : JQuery; function delegate( selector : String, events : String, callb : JqEvent -> Void ) : JQuery; function die( ?events : String, ?callb : JqEvent -> Void ) : JQuery; function one( events : String, callb : JqEvent -> Void ) : JQuery; function live( events : String, callb : JqEvent -> Void ) : JQuery; function trigger( events : String ) : JQuery; function triggerHandler( events : String ) : JQuery; function unbind( ?events : String, ?callb : JqEvent -> Void ) : JQuery; function undelegate( ?selector : String, ?events : String, ?callb : JqEvent -> Void ) : JQuery; // JQuery 1.7+ @:overload(function(events:DynamicVoid>):JQuery{}) function on( events : String, callb : JqEvent -> Void ) : JQuery; // queue function clearQueue( ?queueName : String ) : JQuery; function dequeue( ?queueName : String ) : JQuery; function queue( ?queueName : String, ?callb : (Void -> Void) -> Void ) : { length : Int }; // ajax // TODO // deferred // TODO // other tools @:overload(function(index:Int):Element{}) function get() : Array; @:overload(function(j:JQuery):Bool{}) function is( selector : String ) : Bool; @:overload(function() : Dynamic {}) @:overload(function( key : String ) : Dynamic {}) function data( key : String, value : Dynamic ) : JQuery; function removeData( ?key : String ) : JQuery; function serialize() : String; function serializeArray() : Array<{ name : String, value : String }>; //inline function map( f : JQuery -> T ) : Array { // return untyped this["map"](function() return f(cur)).get(); //} // Haxe addition @:runtime inline function iterator() : Iterator { return untyped __define_feature__('js.JQuery.iterator', this["iterator"])(); } /** Return the current JQuery element (in a callback), similar to $(this) in JS. **/ static var cur(get, null) : JQuery; static var fx(default, null) : { off : Bool, interval : Int }; static var browser(default, null) : { webkit : Bool, opera : Bool, msie : Bool, mozilla : Bool, version : String }; static function contains( parent : Element, child : Element ) : Bool; static function noConflict( ?removeAll : Bool ) : Void; static function parseJSON( json : String ) : Dynamic; static function globalEval( js : String ) : Void; //static function parseXML //static function get, post //static function getJSON, getScript, grep //static function is*, makeArray, map, merge, noop, now, param, proxy, sub, trim, type, unique private static inline function get_cur() : JQuery { return new js.JQuery(js.Lib.nativeThis); } private static function __init__() : Void untyped { #if embed_js if( untyped __js__("typeof($) == 'undefined'") ) haxe.macro.Compiler.includeFile("js/jquery-latest.min.js"); #end var q : Dynamic = (untyped js.Browser.window).jQuery; untyped __js__("var js = js || {}"); js.JQuery = q; __feature__('js.JQuery.iterator', q.fn.iterator = function() return { pos : 0, j : __this__, hasNext : function() return __this__.pos < __this__.j.length, next : function() return $(__this__.j[__this__.pos++]) } ); } } haxe_3.2.1+dfsg.orig/std/js/Lib.hx0000664000175000017500000000706012607337712016604 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; class Lib { /** Inserts a 'debugger' statement that will make a breakpoint if a debugger is available. **/ public static inline function debug() { untyped __js__("debugger"); } /** Display an alert message box containing the given message. @deprecated Use Browser.alert() instead. **/ @:deprecated("Lib.alert() is deprecated, use Browser.alert() instead") public static function alert( v : Dynamic ) { untyped __js__("alert")(js.Boot.__string_rec(v,"")); } public static inline function eval( code : String ) : Dynamic { return untyped __js__("eval")(code); } /** Inserts a `require` expression that loads JavaScript object from a module or file specified in the `module` argument. This is only supported in environments where `require` function is available, such as Node.js or RequireJS. **/ public static inline function require( module:String ) : Dynamic { return untyped __js__("require")(module); } /** Returns JavaScript `undefined` value. Note that this is only needed in very rare cases when working with external JavaScript code. In Haxe, `null` is used to represent the absence of a value. **/ public static var undefined(get,never) : Dynamic; static inline function get_undefined() : Dynamic { return untyped __js__("undefined"); } /** `nativeThis` is the JavaScript `this`, which is semantically different from the Haxe `this`. Use `nativeThis` only when working with external JavaScript code. In Haxe, `this` is always bound to a class instance. In JavaScript, `this` in a function can be bound to an arbitrary variable when the function is called using `func.call(thisObj, ...)` or `func.apply(thisObj, [...])`. Read more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this **/ public static var nativeThis(get,never) : Dynamic; @:extern static inline function get_nativeThis() : Dynamic { return untyped __js__("this"); } /** An alias of the JS "global" object. Concretely, it is set as the first defined value in the list of `window`, `global`, `self`, and `this` in the top-level of the compiled output. **/ #if (haxe_ver >= 3.3) public #else // hide it since we should not add new feature in 3.2.1 @:allow(js) private #end static var global(get,never) : Dynamic; @:extern static inline function get_global() : Dynamic { return untyped __define_feature__("js.Lib.global", __js__("$global")); // $global is generated by the compiler } } haxe_3.2.1+dfsg.orig/std/js/Promise.hx0000664000175000017500000000424112607337712017512 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; import haxe.extern.EitherType; @:native("Promise") extern class Promise { @:overload(function(promise : Promise) : Promise {}) @:overload(function(thenable : Thenable) : Promise {}) static function resolve( value : T ) : Promise; static function reject( ?value : Dynamic ) : Promise; static function all( iterable : Array ) : Promise>; static function race( iterable : Array ) : Promise; /** @throws DOMError */ function new( init : (T -> Void) -> (Dynamic -> Void) -> Void ) : Void; function then( ?fulfillCallback : PromiseCallback, ?rejectCallback : EitherType Void, PromiseCallback> ) : Promise; @:native("catch") function catchError( rejectCallback : EitherType Void, PromiseCallback> ) : Promise; } typedef PromiseCallback = EitherType TOut, T -> Promise>; typedef Thenable = { then : EitherType<(T -> Void) -> (Dynamic -> Void) -> Void, (T -> Void) -> Void> } haxe_3.2.1+dfsg.orig/std/js/RegExp.hx0000664000175000017500000000332612607337712017271 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; /** Native JavaScript regular expressions. For cross-platform regular expressions, use haxe `EReg` class or regexp literals. **/ @:native("RegExp") extern class RegExp { var global(default,null):Bool; var ignoreCase(default,null):Bool; var multiline(default,null):Bool; var source(default,null):String; var lastIndex:Int; function new(pattern:String, ?flags:String); function exec(str:String):Null; function test(str:String):Bool; function toString():String; } extern class RegExpMatch extends Array { var index:Int; var input:String; } haxe_3.2.1+dfsg.orig/std/js/SWFObject.hx0000664000175000017500000000331012607337712017656 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; @:initPackage extern class SWFObject { function new( swf : String, id : String, width : Int, height : Int, ver : String, color : String /*...*/ ) : Void; function addParam( param : String, value : String ) : Void; function getSWFHTML() : String; function write( elementId : String ) : Bool; function addVariable( param : String, value : String ) : Void; function setAttribute( id : String, value : String ) : Void; private static function __init__() : Void untyped { #if embed_js haxe.macro.Compiler.includeFile("js/swfobject-1.5.js"); #end js.SWFObject = deconcept.SWFObject; } }haxe_3.2.1+dfsg.orig/std/js/Selection.hx0000664000175000017500000000577312607337712020034 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; import js.html.TextAreaElement; class Selection { var doc : Dynamic; public function new( doc : TextAreaElement ) { this.doc = doc; } public function get() { // Mozilla if( doc.selectionStart != null ) return doc.value.substring(doc.selectionStart,doc.selectionEnd); // IE var range = untyped js.Lib.document.selection.createRange(); if( range.parentElement() != doc ) return ""; return range.text; } public function select( start : Int, end : Int ) { doc.focus(); // Mozilla if( doc.selectionStart != null ) { doc.selectionStart = start; doc.selectionEnd = end; return; } // FIX : IE count \r\n as one single char for selection // operations, we must then deal with it var value : String = doc.value; var p = 0, delta = 0; while( true ) { var i = value.indexOf("\r\n", p); if( i < 0 || i > start ) break; delta++; p = i + 2; } start -= delta; while( true ) { var i = value.indexOf("\r\n", p); if( i < 0 || i > end ) break; delta++; p = i + 2; } end -= delta; // IE var r = doc.createTextRange(); r.moveEnd('textedit',-1); r.moveStart('character',start); r.moveEnd('character',end - start); r.select(); } public function insert( left : String, text : String, right : String ) { doc.focus(); // Mozilla if( doc.selectionStart != null ) { var top = doc.scrollTop; var start = doc.selectionStart; var end = doc.selectionEnd; doc.value = doc.value.substr(0,start) + left + text + right + doc.value.substr(end); doc.selectionStart = start + left.length; doc.selectionEnd = start + left.length + text.length; doc.scrollTop = top; return; } // IE var range = untyped js.Lib.document.selection.createRange(); range.text = left + text + right; range.moveStart('character',-text.length-right.length); range.moveEnd('character',-right.length); range.select(); } } haxe_3.2.1+dfsg.orig/std/js/XMLSocket.hx0000664000175000017500000000411412607337712017704 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js; /** By compiling the [haxe.remoting.SocketWrapper] into a SWF, you can create and use XMLSockets directly from Javascript. **/ class XMLSocket { var cnx : haxe.remoting.ExternalConnection; public function new( flashObject : String ) { var ctx = new haxe.remoting.Context(); var cnx = haxe.remoting.ExternalConnection.flashConnect("SocketWrapper",flashObject,ctx); var sockId = cnx.api.create.call([flashObject]); cnx.close(); ctx.addObject("api",this,false); this.cnx = haxe.remoting.ExternalConnection.flashConnect(sockId,flashObject,ctx); } public function connect( host : String, port : Int ) { cnx.sock.connect.call([host,port]); } public function send( data : String ) { cnx.sock.send.call([data]); } public function close() { cnx.sock.close.call([]); cnx.api.destroy.call([]); cnx.close(); } public dynamic function onData( data : String ) { } public dynamic function onClose() { } public dynamic function onConnect( b : Bool ) { } } haxe_3.2.1+dfsg.orig/std/js/_std/Array.hx0000664000175000017500000000471212607337712020106 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi extern class Array { var length(default,null) : Int; function new() : Void; function concat( a : Array ) : Array; function join( sep : String ) : String; function pop() : Null; function push(x : T) : Int; function reverse() : Void; function shift() : Null; function slice( pos : Int, ?end : Int ) : Array; function sort( f : T -> T -> Int ) : Void; function splice( pos : Int, len : Int ) : Array; function toString() : String; function unshift( x : T ) : Void; inline function insert( pos : Int, x : T ) : Void { (untyped this).splice(pos,0,x); } inline function remove( x : T ) : Bool { return @:privateAccess HxOverrides.remove(this,x); } #if js_es5 function indexOf( x : T, ?fromIndex:Int ) : Int; function lastIndexOf( x : T, ?fromIndex:Int ) : Int; #else inline function indexOf( x : T, ?fromIndex:Int ) : Int { return @:privateAccess HxOverrides.indexOf(this,x,(fromIndex!=null)?fromIndex:0); } inline function lastIndexOf( x : T, ?fromIndex:Int ) : Int { return @:privateAccess HxOverrides.lastIndexOf(this,x,(fromIndex!=null)?fromIndex:length-1); } #end inline function copy() : Array { return (untyped this).slice(); } function map(f:T->S):Array; function filter(f:T->Bool):Array; @:runtime inline function iterator() : Iterator { return untyped HxOverrides.iter(this); } } haxe_3.2.1+dfsg.orig/std/js/_std/Date.hx0000664000175000017500000000353412607337712017706 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi extern class Date { function new(year : Int, month : Int, day : Int, hour : Int, min : Int, sec : Int ) : Void; function getTime() : Float; function getHours() : Int; function getMinutes() : Int; function getSeconds() : Int; function getFullYear() : Int; function getMonth() : Int; function getDate() : Int; function getDay() : Int; inline function toString() : String { return untyped HxOverrides.dateStr(this); } static inline function now() : Date { return untyped __new__(Date); } static inline function fromTime( t : Float ) : Date { var d : Date = untyped __new__(Date); untyped d["setTime"]( t ); return d; } static inline function fromString( s : String ) : Date { return untyped HxOverrides.strDate(s); } } haxe_3.2.1+dfsg.orig/std/js/_std/EReg.hx0000664000175000017500000000665612607337712017663 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class EReg { var r : HaxeRegExp; public function new( r : String, opt : String ) : Void { opt = opt.split("u").join(""); // 'u' (utf8) depends on page encoding this.r = new HaxeRegExp(r, opt); } public function match( s : String ) : Bool { if( r.global ) r.lastIndex = 0; r.m = r.exec(s); r.s = s; return (r.m != null); } public function matched( n : Int ) : String { return if( r.m != null && n >= 0 && n < r.m.length ) r.m[n] else throw "EReg::matched"; } public function matchedLeft() : String { if( r.m == null ) throw "No string matched"; return r.s.substr(0,r.m.index); } public function matchedRight() : String { if( r.m == null ) throw "No string matched"; var sz = r.m.index+r.m[0].length; return r.s.substr(sz,r.s.length-sz); } public function matchedPos() : { pos : Int, len : Int } { if( r.m == null ) throw "No string matched"; return { pos : r.m.index, len : r.m[0].length }; } public function matchSub( s : String, pos : Int, len : Int = -1):Bool { return if (r.global) { r.lastIndex = pos; r.m = r.exec(len < 0 ? s : s.substr(0, pos + len)); var b = r.m != null; if (b) { r.s = s; } b; } else { // TODO: check some ^/$ related corner cases var b = match( len < 0 ? s.substr(pos) : s.substr(pos,len) ); if (b) { r.s = s; r.m.index += pos; } b; } } public function split( s : String ) : Array { // we can't use directly s.split because it's ignoring the 'g' flag var d = "#__delim__#"; return untyped s.replace(r,d).split(d); } public function replace( s : String, by : String ) : String { return untyped s.replace(r,by); } public function map( s : String, f : EReg -> String ) : String { var offset = 0; var buf = new StringBuf(); do { if (offset >= s.length) break; else if (!matchSub(s, offset)) { buf.add(s.substr(offset)); break; } var p = matchedPos(); buf.add(s.substr(offset, p.pos - offset)); buf.add(f(this)); if (p.len == 0) { buf.add(s.substr(p.pos, 1)); offset = p.pos + 1; } else offset = p.pos + p.len; } while (r.global); if (!r.global && offset > 0 && offset < s.length) buf.add(s.substr(offset)); return buf.toString(); } } @:native("RegExp") private extern class HaxeRegExp extends js.RegExp { var m:js.RegExp.RegExpMatch; var s:String; } haxe_3.2.1+dfsg.orig/std/js/_std/HxOverrides.hx0000664000175000017500000001003512607337712021265 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:noDoc class HxOverrides { static function dateStr( date :Date ) : String { var m = date.getMonth() + 1; var d = date.getDate(); var h = date.getHours(); var mi = date.getMinutes(); var s = date.getSeconds(); return date.getFullYear() +"-"+(if( m < 10 ) "0"+m else ""+m) +"-"+(if( d < 10 ) "0"+d else ""+d) +" "+(if( h < 10 ) "0"+h else ""+h) +":"+(if( mi < 10 ) "0"+mi else ""+mi) +":"+(if( s < 10 ) "0"+s else ""+s); } static function strDate( s : String ) : Date { switch( s.length ) { case 8: // hh:mm:ss var k = s.split(":"); var d : Date = untyped __new__(Date); untyped d["setTime"](0); untyped d["setUTCHours"](k[0]); untyped d["setUTCMinutes"](k[1]); untyped d["setUTCSeconds"](k[2]); return d; case 10: // YYYY-MM-DD var k = s.split("-"); return new Date(cast k[0],cast untyped k[1] - 1,cast k[2],0,0,0); case 19: // YYYY-MM-DD hh:mm:ss var k = s.split(" "); var y = k[0].split("-"); var t = k[1].split(":"); return new Date(cast y[0],cast untyped y[1] - 1,cast y[2],cast t[0],cast t[1],cast t[2]); default: throw "Invalid date format : " + s; } } static function cca( s : String, index : Int ) : Null { var x = (cast s).charCodeAt(index); if( x != x ) // fast isNaN return untyped undefined; // isNaN will still return true return x; } static function substr( s : String, pos : Int, ?len : Int ) : String { if( pos != null && pos != 0 && len != null && len < 0 ) return ""; if( len == null ) len = s.length; if( pos < 0 ){ pos = s.length + pos; if( pos < 0 ) pos = 0; }else if( len < 0 ){ len = s.length + len - pos; } return (untyped s).substr(pos, len); } static function indexOf( a : Array, obj : T, i : Int) { var len = a.length; if (i < 0) { i += len; if (i < 0) i = 0; } while (i < len) { if (untyped __js__("a[i] === obj")) return i; i++; } return -1; } static function lastIndexOf( a : Array, obj : T, i : Int) { var len = a.length; if (i >= len) i = len - 1; else if (i < 0) i += len; while (i >= 0) { if (untyped __js__("a[i] === obj")) return i; i--; } return -1; } static function remove( a : Array, obj : T ) { var i = a.indexOf(obj); if( i == -1 ) return false; a.splice(i,1); return true; } static function iter( a : Array ) : Iterator untyped { return { cur : 0, arr : a, hasNext : function() { return __this__.cur < __this__.arr.length; }, next : function() { return __this__.arr[__this__.cur++]; } }; } static function __init__() untyped { #if !js_es5 __feature__('HxOverrides.indexOf', if( Array.prototype.indexOf ) __js__("HxOverrides").indexOf = function(a,o,i) return Array.prototype.indexOf.call(a, o, i)); __feature__('HxOverrides.lastIndexOf', if( Array.prototype.lastIndexOf ) __js__("HxOverrides").lastIndexOf = function(a,o,i) return Array.prototype.lastIndexOf.call(a, o, i)); #end } } haxe_3.2.1+dfsg.orig/std/js/_std/Math.hx0000664000175000017500000000564312607337712017725 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package; // Can't enable @:coreApi because some fields are now inline getters // @:coreApi @:keepInit extern class Math { static var PI(default,null) : Float; static var NEGATIVE_INFINITY(get, null) : Float; private static inline function get_NEGATIVE_INFINITY () : Float { return -(untyped __js__("Infinity")); } static var POSITIVE_INFINITY(get,null) : Float; private static inline function get_POSITIVE_INFINITY () : Float { return (untyped __js__("Infinity")); } static var NaN(get, null) : Float; private static inline function get_NaN () : Float { return (untyped __js__("NaN")); } static function abs(v:Float):Float; static function acos(v:Float):Float; static function asin(v:Float):Float; static function atan(v:Float):Float; static function atan2(y:Float, x:Float):Float; static function ceil(v:Float):Int; static function cos(v:Float):Float; static function exp(v:Float):Float; static function floor(v:Float):Int; static function log(v:Float):Float; static function max(a:Float, b:Float):Float; static function min(a:Float, b:Float):Float; static function pow(v:Float, exp:Float):Float; static function random() : Float; static function round(v:Float):Int; static function sin(v:Float):Float; static function sqrt(v:Float):Float; static function tan(v:Float):Float; static inline function ffloor( v : Float ) : Float { return floor(v); } static inline function fceil( v : Float ) : Float { return ceil(v); } static inline function fround( v : Float ) : Float { return round(v); } static inline function isFinite( f : Float ) : Bool { return (untyped __js__("isFinite"))(f); } static inline function isNaN( f : Float ) : Bool { return (untyped __js__("isNaN"))(f); } static function __init__() : Void { untyped __feature__("Type.resolveClass", $hxClasses["Math"] = Math); } } haxe_3.2.1+dfsg.orig/std/js/_std/Reflect.hx0000664000175000017500000001005412607337712020410 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi class Reflect { public inline static function hasField( o : Dynamic, field : String ) : Bool { return untyped __js__('Object').prototype.hasOwnProperty.call(o, field); } public static function field( o : Dynamic, field : String ) : Dynamic { try return untyped o[field] catch( e : Dynamic ) return null; } public inline static function setField( o : Dynamic, field : String, value : Dynamic ) : Void untyped { o[field] = value; } public static inline function getProperty( o : Dynamic, field : String ) : Dynamic untyped { var tmp; return if( o == null ) __define_feature__("Reflect.getProperty",null) else if( o.__properties__ && (tmp=o.__properties__["get_"+field]) ) o[tmp]() else o[field]; } public static inline function setProperty( o : Dynamic, field : String, value : Dynamic ) : Void untyped { var tmp; if( o.__properties__ && (tmp=o.__properties__["set_"+field]) ) o[tmp](value) else o[field] = __define_feature__("Reflect.setProperty",value); } public inline static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array ) : Dynamic untyped { return func.apply(o,args); } public static function fields( o : Dynamic ) : Array { var a = []; if (o != null) untyped { var hasOwnProperty = __js__('Object').prototype.hasOwnProperty; __js__("for( var f in o ) {"); if( f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o, f) ) a.push(f); __js__("}"); } return a; } public static function isFunction( f : Dynamic ) : Bool untyped { return __js__("typeof(f)") == "function" && !(js.Boot.isClass(f) || js.Boot.isEnum(f)); } public static function compare( a : T, b : T ) : Int { return ( a == b ) ? 0 : (((cast a) > (cast b)) ? 1 : -1); } public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool { if( f1 == f2 ) return true; if( !isFunction(f1) || !isFunction(f2) ) return false; return f1.scope == f2.scope && f1.method == f2.method && f1.method != null; } public static function isObject( v : Dynamic ) : Bool untyped { if( v == null ) return false; var t = __js__("typeof(v)"); return (t == "string" || (t == "object" && v.__enum__ == null)) || (t == "function" && (js.Boot.isClass(v) || js.Boot.isEnum(v)) != null); } public static function isEnumValue( v : Dynamic ) : Bool { return v != null && v.__enum__ != null; } public static function deleteField( o : Dynamic, field : String ) : Bool untyped { if( !hasField(o,field) ) return false; __js__("delete")(o[field]); return true; } public static function copy( o : T ) : T { var o2 : Dynamic = {}; for( f in Reflect.fields(o) ) Reflect.setField(o2,f,Reflect.field(o,f)); return o2; } @:overload(function( f : Array -> Void ) : Dynamic {}) public static function makeVarArgs( f : Array -> Dynamic ) : Dynamic { return function() { var a = untyped Array.prototype.slice.call(__js__("arguments")); return f(a); }; } } haxe_3.2.1+dfsg.orig/std/js/_std/Std.hx0000664000175000017500000001043612607337712017562 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ import js.Boot; @:keepInit @:coreApi class Std { public static inline function is( v : Dynamic, t : Dynamic ) : Bool { return untyped js.Boot.__instanceof(v,t); } public static inline function instance( value : T, c : Class ) : S { return untyped __instanceof__(value, c) ? cast value : null; } public static function string( s : Dynamic ) : String { return untyped js.Boot.__string_rec(s,""); } public static inline function int( x : Float ) : Int { return (cast x) | 0; } public static function parseInt( x : String ) : Null { var v = untyped __js__("parseInt")(x, 10); // parse again if hexadecimal if( v == 0 && (x.charCodeAt(1) == 'x'.code || x.charCodeAt(1) == 'X'.code) ) v = untyped __js__("parseInt")(x); if( untyped __js__("isNaN")(v) ) return null; return cast v; } public static inline function parseFloat( x : String ) : Float { return untyped __js__("parseFloat")(x); } public static function random( x : Int ) : Int { return untyped x <= 0 ? 0 : Math.floor(Math.random()*x); } static function __init__() : Void untyped { __feature__("js.Boot.getClass",String.prototype.__class__ = __feature__("Type.resolveClass",$hxClasses["String"] = String,String)); __feature__("js.Boot.isClass",String.__name__ = __feature__("Type.getClassName",["String"],true)); __feature__("Type.resolveClass",$hxClasses["Array"] = Array); __feature__("js.Boot.isClass",Array.__name__ = __feature__("Type.getClassName",["Array"],true)); __feature__("Date.*", { __feature__("js.Boot.getClass",__js__('Date').prototype.__class__ = __feature__("Type.resolveClass",$hxClasses["Date"] = __js__('Date'),__js__('Date'))); __feature__("js.Boot.isClass",__js__('Date').__name__ = ["Date"]); }); __feature__("Int.*",{ var Int = __feature__("Type.resolveClass", $hxClasses["Int"] = { __name__ : ["Int"] }, { __name__ : ["Int"] }); }); __feature__("Dynamic.*",{ var Dynamic = __feature__("Type.resolveClass", $hxClasses["Dynamic"] = { __name__ : ["Dynamic"] }, { __name__ : ["Dynamic"] }); }); __feature__("Float.*",{ var Float = __feature__("Type.resolveClass", $hxClasses["Float"] = __js__("Number"), __js__("Number")); Float.__name__ = ["Float"]; }); __feature__("Bool.*",{ var Bool = __feature__("Type.resolveEnum",$hxClasses["Bool"] = __js__("Boolean"), __js__("Boolean")); Bool.__ename__ = ["Bool"]; }); __feature__("Class.*",{ var Class = __feature__("Type.resolveClass", $hxClasses["Class"] = { __name__ : ["Class"] }, { __name__ : ["Class"] }); }); __feature__("Enum.*",{ var Enum = {}; }); __feature__("Void.*",{ var Void = __feature__("Type.resolveEnum", $hxClasses["Void"] = { __ename__ : ["Void"] }, { __ename__ : ["Void"] }); }); #if !js_es5 __feature__("Array.map", if( Array.prototype.map == null ) Array.prototype.map = function(f) { var a = []; for( i in 0...__this__.length ) a[i] = f(__this__[i]); return a; } ); __feature__("Array.filter", if( Array.prototype.filter == null ) Array.prototype.filter = function(f) { var a = []; for( i in 0...__this__.length ) { var e = __this__[i]; if( f(e) ) a.push(e); } return a; } ); #end } } haxe_3.2.1+dfsg.orig/std/js/_std/String.hx0000664000175000017500000000354612607337712020302 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @:coreApi extern class String { var length(default,null) : Int; function new(string:String) : Void; function toUpperCase() : String; function toLowerCase() : String; function charAt( index : Int) : String; function indexOf( str : String, ?startIndex : Int ) : Int; function lastIndexOf( str : String, ?startIndex : Int ) : Int; function split( delimiter : String ) : Array; function toString() : String; function substring( startIndex : Int, ?endIndex : Int ) : String; inline function charCodeAt( index : Int) : Null { return untyped HxOverrides.cca(this, index); } inline function substr( pos : Int, ?len : Int ) : String { return untyped HxOverrides.substr(this, pos, len); } static function fromCharCode( code : Int ) : String; } haxe_3.2.1+dfsg.orig/std/js/_std/Type.hx0000775000175000017500000001427112607337712017755 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ enum ValueType { TNull; TInt; TFloat; TBool; TObject; TFunction; TClass( c : Class ); TEnum( e : Enum ); TUnknown; } @:coreApi class Type { public static inline function getClass( o : T ) : Class { return if (o == null) null else @:privateAccess js.Boot.getClass(o); } public static function getEnum( o : EnumValue ) : Enum untyped { if( o == null ) return null; return o.__enum__; } public static function getSuperClass( c : Class ) : Class untyped { return c.__super__; } public static function getClassName( c : Class ) : String { var a : Array = untyped c.__name__; if (a == null) return null; return a.join("."); } public static function getEnumName( e : Enum ) : String { var a : Array = untyped e.__ename__; return a.join("."); } public static function resolveClass( name : String ) : Class untyped { var cl : Class = $hxClasses[name]; // ensure that this is a class if( cl == null || !js.Boot.isClass(cl) ) return null; return cl; } public static function resolveEnum( name : String ) : Enum untyped { var e : Dynamic = $hxClasses[name]; // ensure that this is an enum if( e == null || !js.Boot.isEnum(e) ) return null; return e; } public static function createInstance( cl : Class, args : Array ) : T untyped { switch( args.length ) { case 0: return __new__(cl); case 1: return __new__(cl,args[0]); case 2: return __new__(cl,args[0],args[1]); case 3: return __new__(cl,args[0],args[1],args[2]); case 4: return __new__(cl,args[0],args[1],args[2],args[3]); case 5: return __new__(cl,args[0],args[1],args[2],args[3],args[4]); case 6: return __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5]); case 7: return __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6]); case 8: return __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]); default: throw "Too many arguments"; } return null; } public static function createEmptyInstance( cl : Class ) : T untyped { __js__("function empty() {}; empty.prototype = cl.prototype"); return __js__("new empty()"); } public static function createEnum( e : Enum, constr : String, ?params : Array ) : T { var f:Dynamic = Reflect.field(e,constr); if( f == null ) throw "No such constructor "+constr; if( Reflect.isFunction(f) ) { if( params == null ) throw "Constructor "+constr+" need parameters"; return Reflect.callMethod(e,f,params); } if( params != null && params.length != 0 ) throw "Constructor "+constr+" does not need parameters"; return f; } public static function createEnumIndex( e : Enum, index : Int, ?params : Array ) : T { var c : String = (untyped e.__constructs__)[index]; if( c == null ) throw index+" is not a valid enum constructor index"; return createEnum(e,c,params); } public static function getInstanceFields( c : Class ) : Array { var a = []; untyped __js__("for(var i in c.prototype) a.push(i)"); a.remove("__class__"); a.remove("__properties__"); return a; } public static function getClassFields( c : Class ) : Array { var a = Reflect.fields(c); a.remove("__name__"); a.remove("__interfaces__"); a.remove("__properties__"); a.remove("__super__"); a.remove("__meta__"); a.remove("prototype"); return a; } public static function getEnumConstructs( e : Enum ) : Array { var a : Array = untyped e.__constructs__; return a.copy(); } public static function typeof( v : Dynamic ) : ValueType untyped { switch( __js__("typeof")(v) ) { case "boolean": return TBool; case "string": return TClass(String); case "number": // this should handle all cases : NaN, +/-Inf and Floats outside range if( Math.ceil(v) == v%2147483648.0 ) return TInt; return TFloat; case "object": if( v == null ) return TNull; var e = v.__enum__; if( e != null ) return TEnum(e); var c = js.Boot.getClass(v); if( c != null ) return TClass(c); return TObject; case "function": if( js.Boot.isClass(v) || js.Boot.isEnum(v) ) return TObject; return TFunction; case "undefined": return TNull; default: return TUnknown; } } public static function enumEq( a : T, b : T ) : Bool untyped { if( a == b ) return true; try { if( a[0] != b[0] ) return false; for( i in 2...a.length ) if( !enumEq(a[i],b[i]) ) return false; var e = a.__enum__; if( e != b.__enum__ || e == null ) return false; } catch( e : Dynamic ) { return false; } return true; } public inline static function enumConstructor( e : EnumValue ) : String { return untyped e[0]; } public inline static function enumParameters( e : EnumValue ) : Array { return untyped e.slice(2); } public inline static function enumIndex( e : EnumValue ) : Int { return untyped e[1]; } public static function allEnums( e : Enum ) : Array { return untyped e.__empty_constructs__; } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/Json.hx0000664000175000017500000000330312607337712020661 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe; @:coreApi #if (!haxeJSON && !old_browser) @:native("JSON") extern #end class Json { #if haxeJSON inline #end public static function parse( text : String ) : Dynamic { return haxe.format.JsonParser.parse(text); } #if haxeJSON inline #end public static function stringify( value : Dynamic, ?replacer:Dynamic -> Dynamic -> Dynamic, ?space:String ) : String { return haxe.format.JsonPrinter.print(value, replacer, space); } #if (!haxeJSON && old_browser) static function __init__():Void untyped { if( __js__('typeof(JSON)') != 'undefined' ) Json = __js__('JSON'); } #end } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/ds/IntMap.hx0000664000175000017500000000457112607337712021556 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; @:coreApi class IntMap implements haxe.Constraints.IMap { private var h : Dynamic; public inline function new() : Void { h = {}; } public inline function set( key : Int, value : T ) : Void { untyped h[key] = value; } public inline function get( key : Int ) : Null { return untyped h[key]; } public inline function exists( key : Int ) : Bool { return untyped h.hasOwnProperty(key); } public function remove( key : Int ) : Bool { if( untyped !h.hasOwnProperty(key) ) return false; untyped __js__("delete")(h[key]); return true; } public function keys() : Iterator { var a = []; untyped { __js__("for( var key in this.h ) {"); if( h.hasOwnProperty(key) ) a.push(key|0); __js__("}"); } return a.iterator(); } public function iterator() : Iterator { return untyped { ref : h, it : keys(), hasNext : function() { return __this__.it.hasNext(); }, next : function() { var i = __this__.it.next(); return __this__.ref[i]; } }; } public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(i); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/ds/ObjectMap.hx0000664000175000017500000000535312607337712022231 0ustar andyandy00000000000000/* * Copyright (C)2005-2013 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of h 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 h permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; @:coreApi class ObjectMap implements haxe.Constraints.IMap { static var count = 0; static inline function assignId(obj: { } ):Int { return untyped obj.__id__ = ++count; } static inline function getId(obj: { } ):Int { return untyped obj.__id__; } var h : { }; public function new() : Void { h = { }; untyped h.__keys__ = { }; } public function set(key:K, value:V):Void untyped { var id : Int = untyped key.__id__ || assignId(key); h[id] = value; h.__keys__[id] = key; } public inline function get(key:K):Null { return untyped h[getId(key)]; } public inline function exists(key:K):Bool { return untyped h.__keys__[getId(key)] != null; } public function remove( key : K ) : Bool { var id = getId(key); if ( untyped h.__keys__[id] == null ) return false; untyped __js__("delete")(h[id]); untyped __js__("delete")(h.__keys__[id]); return true; } public function keys() : Iterator { var a = []; untyped { __js__("for( var key in this.h.__keys__ ) {"); if( h.hasOwnProperty(key) ) a.push(h.__keys__[key]); __js__("}"); } return a.iterator(); } public function iterator() : Iterator { return untyped { ref : h, it : keys(), hasNext : function() { return __this__.it.hasNext(); }, next : function() { var i = __this__.it.next(); return __this__.ref[getId(i)]; } }; } public function toString() : String { var s = new StringBuf(); s.add("{"); var it = keys(); for( i in it ) { s.add(Std.string(i)); s.add(" => "); s.add(Std.string(get(i))); if( it.hasNext() ) s.add(", "); } s.add("}"); return s.toString(); } }haxe_3.2.1+dfsg.orig/std/js/_std/haxe/ds/StringMap.hx0000664000175000017500000000750212607337712022267 0ustar andyandy00000000000000/* * Copyright (C)2005-2012 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.ds; private class StringMapIterator { var map : StringMap; var keys : Array; var index : Int; var count : Int; public inline function new(map:StringMap, keys:Array) { this.map = map; this.keys = keys; this.index = 0; this.count = keys.length; } public inline function hasNext() { return index < count; } public inline function next() { return map.get(keys[index++]); } } @:coreApi class StringMap implements haxe.Constraints.IMap { private var h : Dynamic; private var rh : Dynamic; public inline function new() : Void { h = {}; } inline function isReserved(key:String) : Bool { return untyped __js__("__map_reserved")[key] != null; } public inline function set( key : String, value : T ) : Void { if( isReserved(key) ) setReserved(key, value); else h[cast key] = value; } public inline function get( key : String ) : Null { if( isReserved(key) ) return getReserved(key); return h[cast key]; } public inline function exists( key : String ) : Bool { if( isReserved(key) ) return existsReserved(key); return h.hasOwnProperty(key); } function setReserved( key : String, value : T ) : Void { if( rh == null ) rh = {}; rh[cast "$"+key] = value; } function getReserved( key : String ) : Null { return rh == null ? null : rh[cast "$"+key]; } function existsReserved( key : String ) : Bool { if( rh == null ) return false; return untyped rh.hasOwnProperty("$"+key); } public function remove( key : String ) : Bool { if( isReserved(key) ) { key = "$" + key; if( rh == null || !rh.hasOwnProperty(key) ) return false; untyped __js__("delete")(rh[key]); return true; } else { if( !h.hasOwnProperty(key) ) return false; untyped __js__("delete")(h[key]); return true; } } public function keys() : Iterator { return arrayKeys().iterator(); } function arrayKeys() : Array { var out = []; untyped { __js__("for( var key in this.h ) {"); if( h.hasOwnProperty(key) ) out.push(key); __js__("}"); } if( rh != null ) untyped { __js__("for( var key in this.rh ) {"); if( key.charCodeAt(0) == "$".code ) out.push(key.substr(1)); __js__("}"); } return out; } public inline function iterator() : Iterator { return new StringMapIterator(this, arrayKeys()); } public function toString() : String { var s = new StringBuf(); s.add("{"); var keys = arrayKeys(); for( i in 0...keys.length ) { var k = keys[i]; s.add(k); s.add(" => "); s.add(Std.string(get(k))); if( i < keys.length ) s.add(", "); } s.add("}"); return s.toString(); } static function __init__() : Void { untyped __js__("var __map_reserved = {}"); } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/io/ArrayBufferView.hx0000664000175000017500000000214312607337712023423 0ustar andyandy00000000000000package haxe.io; typedef ArrayBufferViewData = js.html.ArrayBufferView; abstract ArrayBufferView(ArrayBufferViewData) { public static var EMULATED(get,never) : Bool; static function get_EMULATED() { return (cast js.html.ArrayBuffer) == js.html.compat.ArrayBuffer; } public var buffer(get,never) : haxe.io.Bytes; public var byteOffset(get, never) : Int; public var byteLength(get, never) : Int; public inline function new( size : Int ) { this = new js.html.Uint8Array(size); } inline function get_byteOffset() return this.byteOffset; inline function get_byteLength() return this.byteLength; function get_buffer() : haxe.io.Bytes { return haxe.io.Bytes.ofData(this.buffer); } public inline function sub( begin : Int, ?length : Int ) { #if js return fromData(new js.html.Uint8Array(this.buffer.slice(begin, length == null ? null : begin+length))); #else return fromData(this.sub(begin,length)); #end } public inline function getData() : ArrayBufferViewData { return this; } public static inline function fromData( a : ArrayBufferViewData ) : ArrayBufferView { return cast a; } }haxe_3.2.1+dfsg.orig/std/js/_std/haxe/io/Bytes.hx0000664000175000017500000001474112607337712021455 0ustar andyandy00000000000000/* * Copyright (C)2005-2014 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; import js.html.compat.Uint8Array; import js.html.compat.DataView; @:coreApi class Bytes { public var length(default,null) : Int; var b : js.html.Uint8Array; var data : js.html.DataView; function new(data:BytesData) { this.length = data.byteLength; this.b = new js.html.Uint8Array(data); untyped { b.bufferValue = data; // some impl does not return the same instance in .buffer data.hxBytes = this; data.bytes = this.b; } } public inline function get( pos : Int ) : Int { return b[pos]; } public inline function set( pos : Int, v : Int ) : Void { b[pos] = v & 0xFF; // the &0xFF is necessary for js.html.compat support } public function blit( pos : Int, src : Bytes, srcpos : Int, len : Int ) : Void { if( pos < 0 || srcpos < 0 || len < 0 || pos + len > length || srcpos + len > src.length ) throw Error.OutsideBounds; if( srcpos == 0 && len == src.length ) b.set(src.b,pos); else b.set(src.b.subarray(srcpos,srcpos+len),pos); } public function fill( pos : Int, len : Int, value : Int ) : Void { for( i in 0...len ) set(pos++, value); } public function sub( pos : Int, len : Int ) : Bytes { if( pos < 0 || len < 0 || pos + len > length ) throw Error.OutsideBounds; return new Bytes(b.buffer.slice(pos+b.byteOffset,pos+b.byteOffset+len)); } public function compare( other : Bytes ) : Int { var b1 = b; var b2 = other.b; var len = (length < other.length) ? length : other.length; for( i in 0...len ) if( b1[i] != b2[i] ) return b1[i] - b2[i]; return length - other.length; } inline function initData() : Void { if( data == null ) data = new js.html.DataView(b.buffer, b.byteOffset, b.byteLength); } public function getDouble( pos : Int ) : Float { initData(); return data.getFloat64(pos, true); } public function getFloat( pos : Int ) : Float { initData(); return data.getFloat32(pos, true); } public function setDouble( pos : Int, v : Float ) : Void { initData(); data.setFloat64(pos, v, true); } public function setFloat( pos : Int, v : Float ) : Void { initData(); data.setFloat32(pos, v, true); } public function getUInt16( pos : Int ) : Int { initData(); return data.getUint16(pos, true); } public function setUInt16( pos : Int, v : Int ) : Void { initData(); data.setUint16(pos, v, true); } public function getInt32( pos : Int ) : Int { initData(); return data.getInt32(pos, true); } public function setInt32( pos : Int, v : Int ) : Void { initData(); data.setInt32(pos, v, true); } public function getInt64( pos : Int ) : haxe.Int64 { return Int64.make(getInt32(pos + 4),getInt32(pos)); } public function setInt64( pos : Int, v : haxe.Int64 ) : Void { setInt32(pos, v.low); setInt32(pos + 4, v.high); } public function getString( pos : Int, len : Int ) : String { if( pos < 0 || len < 0 || pos + len > length ) throw Error.OutsideBounds; var s = ""; var b = b; var fcc = String.fromCharCode; var i = pos; var max = pos+len; // utf8-decode and utf16-encode while( i < max ) { var c = b[i++]; if( c < 0x80 ) { if( c == 0 ) break; s += fcc(c); } else if( c < 0xE0 ) s += fcc( ((c & 0x3F) << 6) | (b[i++] & 0x7F) ); else if( c < 0xF0 ) { var c2 = b[i++]; s += fcc( ((c & 0x1F) << 12) | ((c2 & 0x7F) << 6) | (b[i++] & 0x7F) ); } else { var c2 = b[i++]; var c3 = b[i++]; var u = ((c & 0x0F) << 18) | ((c2 & 0x7F) << 12) | ((c3 & 0x7F) << 6) | (b[i++] & 0x7F); // surrogate pair s += fcc( (u >> 10) + 0xD7C0 ); s += fcc( (u & 0x3FF) | 0xDC00 ); } } return s; } @:deprecated("readString is deprecated, use getString instead") @:noCompletion public inline function readString(pos:Int, len:Int):String { return getString(pos, len); } public function toString() : String { return getString(0,length); } public function toHex() : String { var s = new StringBuf(); var chars = []; var str = "0123456789abcdef"; for( i in 0...str.length ) chars.push(str.charCodeAt(i)); for( i in 0...length ) { var c = get(i); s.addChar(chars[c >> 4]); s.addChar(chars[c & 15]); } return s.toString(); } public inline function getData() : BytesData { return untyped b.bufferValue; } public static function alloc( length : Int ) : Bytes { return new Bytes(new BytesData(length)); } public static function ofString( s : String ) : Bytes { var a = new Array(); // utf16-decode and utf8-encode var i = 0; while( i < s.length ) { var c : Int = StringTools.fastCodeAt(s,i++); // surrogate pair if( 0xD800 <= c && c <= 0xDBFF ) c = (c - 0xD7C0 << 10) | (StringTools.fastCodeAt(s,i++) & 0x3FF); if( c <= 0x7F ) a.push(c); else if( c <= 0x7FF ) { a.push( 0xC0 | (c >> 6) ); a.push( 0x80 | (c & 63) ); } else if( c <= 0xFFFF ) { a.push( 0xE0 | (c >> 12) ); a.push( 0x80 | ((c >> 6) & 63) ); a.push( 0x80 | (c & 63) ); } else { a.push( 0xF0 | (c >> 18) ); a.push( 0x80 | ((c >> 12) & 63) ); a.push( 0x80 | ((c >> 6) & 63) ); a.push( 0x80 | (c & 63) ); } } return new Bytes(new js.html.Uint8Array(a).buffer); } public static function ofData( b : BytesData ) : Bytes { var hb = untyped b.hxBytes; if( hb != null ) return hb; return new Bytes(b); } public inline static function fastGet( b : BytesData, pos : Int ) : Int { // this requires that we have wrapped it with haxe.io.Bytes beforehand return untyped b.bytes[pos]; } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/io/Float32Array.hx0000664000175000017500000000572512607337712022602 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; import js.html.compat.Float32Array; typedef Float32ArrayData = js.html.Float32Array; @:coreApi abstract Float32Array(Float32ArrayData) { public static inline var BYTES_PER_ELEMENT = 4; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) : Void { this = new Float32ArrayData(elements); } inline function get_length() : Int { return this.length; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Float { return this[index]; } @:arrayAccess public inline function set( index : Int, value : Float ) : Float { return this[index] = value; } public inline function sub( begin : Int, ?length : Int ) : Float32Array { return fromData(this.subarray(begin, length == null ? this.length : begin+length)); } public inline function subarray( ?begin : Int, ?end : Int ) : Float32Array { return fromData(this.subarray(begin, end)); } public inline function getData() : Float32ArrayData { return this; } public static function fromData( d : Float32ArrayData ) : Float32Array { return cast d; } public static function fromArray( a : Array, pos : Int = 0, ?length : Int ) : Float32Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; if( pos == 0 && length == a.length ) return fromData(new Float32ArrayData(a)); var i = new Float32Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : Float32Array { if( length == null ) length = (bytes.length - bytePos) >> 2; return fromData(new Float32ArrayData(bytes.getData(), bytePos, length)); } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/io/Float64Array.hx0000664000175000017500000000572512607337712022607 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; import js.html.compat.Float64Array; typedef Float64ArrayData = js.html.Float64Array; @:coreApi abstract Float64Array(Float64ArrayData) { public static inline var BYTES_PER_ELEMENT = 4; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) : Void { this = new Float64ArrayData(elements); } inline function get_length() : Int { return this.length; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Float { return this[index]; } @:arrayAccess public inline function set( index : Int, value : Float ) : Float { return this[index] = value; } public inline function sub( begin : Int, ?length : Int ) : Float64Array { return fromData(this.subarray(begin, length == null ? this.length : begin+length)); } public inline function subarray( ?begin : Int, ?end : Int ) : Float64Array { return fromData(this.subarray(begin, end)); } public inline function getData() : Float64ArrayData { return this; } public static function fromData( d : Float64ArrayData ) : Float64Array { return cast d; } public static function fromArray( a : Array, pos : Int = 0, ?length : Int ) : Float64Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; if( pos == 0 && length == a.length ) return fromData(new Float64ArrayData(a)); var i = new Float64Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : Float64Array { if( length == null ) length = (bytes.length - bytePos) >> 3; return fromData(new Float64ArrayData(bytes.getData(), bytePos, length)); } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/io/Int32Array.hx0000664000175000017500000000567112607337712022267 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef Int32ArrayData = js.html.Int32Array; @:coreApi abstract Int32Array(Int32ArrayData) { public static inline var BYTES_PER_ELEMENT = 1; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new Int32ArrayData(elements * BYTES_PER_ELEMENT); } inline function get_length() : Int { return this.length; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Int { return this[index]; } @:arrayAccess public inline function set( index : Int, value : Int ) : Int { return this[index] = value | 0; // necessary for html compat } public inline function sub( begin : Int, ?length : Int ) : Int32Array { return fromData(this.subarray(begin, length == null ? this.length : begin+length)); } public inline function subarray( ?begin : Int, ?end : Int ) : Int32Array { return fromData(this.subarray(begin, end)); } public inline function getData() : Int32ArrayData { return this; } public static function fromData( d : Int32ArrayData ) : Int32Array { return cast d; } public static function fromArray( a : Array, pos : Int = 0, ?length : Int ) : Int32Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; if( pos == 0 && length == a.length ) return fromData(new Int32ArrayData(a)); var i = new Int32Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : Int32Array { if( length == null ) length = (bytes.length - bytePos) >> 2; return fromData(new Int32ArrayData(bytes.getData(), bytePos, length)); } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/io/UInt16Array.hx0000664000175000017500000000570112607337712022410 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef UInt16ArrayData = js.html.Uint16Array; @:coreApi abstract UInt16Array(UInt16ArrayData) { public static inline var BYTES_PER_ELEMENT = 2; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new UInt16ArrayData(elements); } inline function get_length() : Int { return this.length; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Int { return this[index]; } @:arrayAccess public inline function set( index : Int, value : Int ) : Int { return this[index] = value & 0xFFFF; // &0xFFFF necessary for html compat } public inline function sub( begin : Int, ?length : Int ) : UInt16Array { return fromData(this.subarray(begin, length == null ? this.length : begin+length)); } public inline function subarray( ?begin : Int, ?end : Int ) : UInt16Array { return fromData(this.subarray(begin, end)); } public inline function getData() : UInt16ArrayData { return this; } public static function fromData( d : UInt16ArrayData ) : UInt16Array { return cast d; } public static function fromArray( a : Array, pos : Int = 0, ?length : Int ) : UInt16Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; if( pos == 0 && length == a.length ) return fromData(new UInt16ArrayData(a)); var i = new UInt16Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : UInt16Array { if( length == null ) length = (bytes.length - bytePos) >> 1; return fromData(new UInt16ArrayData(bytes.getData(), bytePos, length)); } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/io/UInt32Array.hx0000664000175000017500000000567012607337712022413 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef UInt32ArrayData = js.html.Uint32Array; @:coreApi abstract UInt32Array(UInt32ArrayData) { public static inline var BYTES_PER_ELEMENT = 4; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new UInt32ArrayData(elements); } inline function get_length() : Int { return this.length; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : UInt { return this[index]; } @:arrayAccess public inline function set( index : Int, value : UInt ) : UInt { return this[index] = value | 0; // necessary for html compat } public inline function sub( begin : Int, ?length : Int ) : UInt32Array { return fromData(this.subarray(begin, length == null ? this.length : begin+length)); } public inline function subarray( ?begin : Int, ?end : Int ) : UInt32Array { return fromData(this.subarray(begin, end)); } public inline function getData() : UInt32ArrayData { return this; } public static function fromData( d : UInt32ArrayData ) : UInt32Array { return cast d; } public static function fromArray( a : Array, pos : Int = 0, ?length : Int ) : UInt32Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; if( pos == 0 && length == a.length ) return fromData(new UInt32ArrayData(a)); var i = new UInt32Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : UInt32Array { if( length == null ) length = (bytes.length - bytePos) >> 2; return fromData(new UInt32ArrayData(bytes.getData(), bytePos, length)); } } haxe_3.2.1+dfsg.orig/std/js/_std/haxe/io/UInt8Array.hx0000664000175000017500000000564712607337712022342 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package haxe.io; typedef UInt8ArrayData = js.html.Uint8Array; @:coreApi abstract UInt8Array(UInt8ArrayData) { public static inline var BYTES_PER_ELEMENT = 1; public var length(get,never) : Int; public var view(get,never) : ArrayBufferView; public inline function new( elements : Int ) { this = new UInt8ArrayData(elements); } inline function get_length() : Int { return this.length; } public inline function get_view() : ArrayBufferView { return ArrayBufferView.fromData(this); } @:arrayAccess public inline function get( index : Int ) : Int { return this[index]; } @:arrayAccess public inline function set( index : Int, value : Int ) : Int { return this[index] = value & 0xFF; // &0xFF necessary for html compat } public inline function sub( begin : Int, ?length : Int ) : UInt8Array { return fromData(this.subarray(begin, length == null ? this.length : begin+length)); } public inline function subarray( ?begin : Int, ?end : Int ) : UInt8Array { return fromData(this.subarray(begin, end)); } public inline function getData() : UInt8ArrayData { return this; } public static function fromData( d : UInt8ArrayData ) : UInt8Array { return cast d; } public static function fromArray( a : Array, pos : Int = 0, ?length : Int ) : UInt8Array { if( length == null ) length = a.length - pos; if( pos < 0 || length < 0 || pos + length > a.length ) throw Error.OutsideBounds; if( pos == 0 && length == a.length ) return fromData(new UInt8ArrayData(a)); var i = new UInt8Array(a.length); for( idx in 0...length ) i[idx] = a[idx + pos]; return i; } public static function fromBytes( bytes : haxe.io.Bytes, bytePos : Int = 0, ?length : Int ) : UInt8Array { if( length == null ) length = bytes.length - bytePos; return fromData(new UInt8ArrayData(bytes.getData(), bytePos, length)); } } haxe_3.2.1+dfsg.orig/std/js/html/AlignSetting.hx0000664000175000017500000000252712607337712021435 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/VTTCue.webidl line 12:0. Do not edit! package js.html; @:enum abstract AlignSetting(String) { var START = "start"; var MIDDLE = "middle"; var END = "end"; var LEFT = "left"; var RIGHT = "right"; }haxe_3.2.1+dfsg.orig/std/js/html/AnchorElement.hx0000664000175000017500000000355612607337712021574 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLAnchorElement.webidl line 15:0. Do not edit! package js.html; @:native("HTMLAnchorElement") extern class AnchorElement extends Element { var target : String; var download : String; var ping : String; var rel : String; var relList(default,null) : DOMTokenList; var hreflang : String; var type : String; var text : String; var coords : String; var charset : String; var name : String; var rev : String; var shape : String; var href : String; var origin(default,null) : String; var protocol : String; var username : String; var password : String; var host : String; var hostname : String; var port : String; var pathname : String; var search : String; var hash : String; var searchParams : URLSearchParams; }haxe_3.2.1+dfsg.orig/std/js/html/Animation.hx0000664000175000017500000000251412607337712020760 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Animation.webidl line 14:0. Do not edit! package js.html; @:native("Animation") extern class Animation { var effect(default,null) : AnimationEffect; var target(default,null) : Element; }haxe_3.2.1+dfsg.orig/std/js/html/AnimationEffect.hx0000664000175000017500000000245612607337712022102 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AnimationEffect.webidl line 14:0. Do not edit! package js.html; @:native("AnimationEffect") extern class AnimationEffect { var name(default,null) : String; }haxe_3.2.1+dfsg.orig/std/js/html/AnimationEvent.hx0000664000175000017500000000277212607337712021770 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AnimationEvent.webidl line 15:0. Do not edit! package js.html; @:native("AnimationEvent") extern class AnimationEvent extends Event { var animationName(default,null) : String; var elapsedTime(default,null) : Float; var pseudoElement(default,null) : String; /** @throws DOMError */ function new( type : String, ?eventInitDict : AnimationEventInit ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/AnimationEventInit.hx0000664000175000017500000000256012607337712022607 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AnimationEvent.webidl line 21:0. Do not edit! package js.html; typedef AnimationEventInit = { > EventInit, @:optional var animationName : String; @:optional var elapsedTime : Float; @:optional var pseudoElement : String; }haxe_3.2.1+dfsg.orig/std/js/html/AnimationPlayState.hx0000664000175000017500000000257012607337712022611 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AnimationPlayer.webidl line 13:0. Do not edit! package js.html; @:enum abstract AnimationPlayState(String) { var IDLE = "idle"; var PENDING = "pending"; var RUNNING = "running"; var PAUSED = "paused"; var FINISHED = "finished"; }haxe_3.2.1+dfsg.orig/std/js/html/AnimationPlayer.hx0000664000175000017500000000303012607337712022127 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AnimationPlayer.webidl line 16:0. Do not edit! package js.html; @:native("AnimationPlayer") extern class AnimationPlayer { var source(default,null) : Animation; var timeline(default,null) : AnimationTimeline; var startTime(default,null) : Float; var currentTime(default,null) : Float; var playState(default,null) : AnimationPlayState; function play() : Void; function pause() : Void; }haxe_3.2.1+dfsg.orig/std/js/html/AnimationTimeline.hx0000664000175000017500000000247212607337712022452 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AnimationTimeline.webidl line 14:0. Do not edit! package js.html; @:native("AnimationTimeline") extern class AnimationTimeline { var currentTime(default,null) : Float; }haxe_3.2.1+dfsg.orig/std/js/html/AppletElement.hx0000664000175000017500000000300412607337712021573 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLAppletElement.webidl line 16:0. Do not edit! package js.html; @:native("HTMLAppletElement") extern class AppletElement extends Element { var align : String; var alt : String; var archive : String; var code : String; var codeBase : String; var height : String; var hspace : Int; var name : String; var object : String; var vspace : Int; var width : String; }haxe_3.2.1+dfsg.orig/std/js/html/ApplicationCache.hx0000664000175000017500000000404712607337712022233 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/OfflineResourceList.webidl line 5:0. Do not edit! package js.html; @:native("ApplicationCache") extern class ApplicationCache extends EventTarget implements ArrayAccess { static inline var UNCACHED : Int = 0; static inline var IDLE : Int = 1; static inline var CHECKING : Int = 2; static inline var DOWNLOADING : Int = 3; static inline var UPDATEREADY : Int = 4; static inline var OBSOLETE : Int = 5; var status(default,null) : Int; var onchecking : haxe.Constraints.Function; var onerror : haxe.Constraints.Function; var onnoupdate : haxe.Constraints.Function; var ondownloading : haxe.Constraints.Function; var onprogress : haxe.Constraints.Function; var onupdateready : haxe.Constraints.Function; var oncached : haxe.Constraints.Function; var onobsolete : haxe.Constraints.Function; /** @throws DOMError */ function update() : Void; /** @throws DOMError */ function swapCache() : Void; }haxe_3.2.1+dfsg.orig/std/js/html/AreaElement.hx0000664000175000017500000000342112607337712021221 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLAreaElement.webidl line 16:0. Do not edit! package js.html; @:native("HTMLAreaElement") extern class AreaElement extends Element { var alt : String; var coords : String; var shape : String; var target : String; var download : String; var ping : String; var rel : String; var relList(default,null) : DOMTokenList; var noHref : Bool; var href : String; var origin(default,null) : String; var protocol : String; var username : String; var password : String; var host : String; var hostname : String; var port : String; var pathname : String; var search : String; var hash : String; var searchParams : URLSearchParams; }haxe_3.2.1+dfsg.orig/std/js/html/ArrayBuffer.hx0000664000175000017500000000271012607337712021247 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from typedarray.webidl line 12:0. Do not edit! package js.html; @:native("ArrayBuffer") extern class ArrayBuffer { static function isView( value : Dynamic ) : Bool; var byteLength(default,null) : Int; /** @throws DOMError */ function new( length : Int ) : Void; function slice( begin : Int, ?end : Int ) : ArrayBuffer; }haxe_3.2.1+dfsg.orig/std/js/html/ArrayBufferView.hx0000664000175000017500000000256212607337712022107 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from typedarray.webidl line 21:0. Do not edit! package js.html; @:native("ArrayBufferView") extern class ArrayBufferView { var buffer(default,null) : ArrayBuffer; var byteOffset(default,null) : Int; var byteLength(default,null) : Int; }haxe_3.2.1+dfsg.orig/std/js/html/Attr.hx0000664000175000017500000000257712607337712017764 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Attr.webidl line 13:0. Do not edit! package js.html; @:native("Attr") extern class Attr extends Node { var value : String; var name(default,null) : String; var specified(default,null) : Bool; var ownerElement(default,null) : Element; }haxe_3.2.1+dfsg.orig/std/js/html/Audio.hx0000664000175000017500000000250412607337712020101 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from namedConstructors.webidl line 2:0. Do not edit! package js.html; @:native("Audio") extern class Audio extends AudioElement { /** @throws DOMError */ function new( ?src : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/AudioChannel.hx0000664000175000017500000000270512607337712021375 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AudioChannel.webidl line 41:0. Do not edit! package js.html; @:enum abstract AudioChannel(String) { var NORMAL = "normal"; var CONTENT = "content"; var NOTIFICATION = "notification"; var ALARM = "alarm"; var TELEPHONY = "telephony"; var RINGER = "ringer"; var PUBLICNOTIFICATION = "publicnotification"; }haxe_3.2.1+dfsg.orig/std/js/html/AudioElement.hx0000664000175000017500000000243612607337712021417 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLAudioElement.webidl line 15:0. Do not edit! package js.html; @:native("HTMLAudioElement") extern class AudioElement extends MediaElement { }haxe_3.2.1+dfsg.orig/std/js/html/AudioStreamTrack.hx0000664000175000017500000000244612607337712022247 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AudioStreamTrack.webidl line 14:0. Do not edit! package js.html; @:native("AudioStreamTrack") extern class AudioStreamTrack extends MediaStreamTrack { }haxe_3.2.1+dfsg.orig/std/js/html/AudioTrack.hx0000664000175000017500000000263512607337712021073 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AudioTrack.webidl line 11:0. Do not edit! package js.html; @:native("AudioTrack") extern class AudioTrack { var id(default,null) : String; var kind(default,null) : String; var label(default,null) : String; var language(default,null) : String; var enabled : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/AudioTrackList.hx0000664000175000017500000000303512607337712021722 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/AudioTrackList.webidl line 11:0. Do not edit! package js.html; @:native("AudioTrackList") extern class AudioTrackList extends EventTarget implements ArrayAccess { var length(default,null) : Int; var onchange : haxe.Constraints.Function; var onaddtrack : haxe.Constraints.Function; var onremovetrack : haxe.Constraints.Function; function getTrackById( id : String ) : AudioTrack; }haxe_3.2.1+dfsg.orig/std/js/html/BRElement.hx0000664000175000017500000000244712607337712020663 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLBRElement.webidl line 16:0. Do not edit! package js.html; @:native("HTMLBRElement") extern class BRElement extends Element { var clear : String; }haxe_3.2.1+dfsg.orig/std/js/html/BarInfo.hx0000664000175000017500000000236512607337712020365 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use BarProp instead. */ @:deprecated("BarInfo is deprecated, use BarProp instead") typedef BarInfo = BarProp; haxe_3.2.1+dfsg.orig/std/js/html/BarProp.hx0000664000175000017500000000241012607337712020401 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/BarProp.webidl line 7:0. Do not edit! package js.html; @:native("BarProp") extern class BarProp { var visible : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/BaseElement.hx0000664000175000017500000000250212607337712021222 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLBaseElement.webidl line 15:0. Do not edit! package js.html; @:native("HTMLBaseElement") extern class BaseElement extends Element { var href : String; var target : String; }haxe_3.2.1+dfsg.orig/std/js/html/BatteryManager.hx0000664000175000017500000000321412607337712021744 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/BatteryManager.webidl line 13:0. Do not edit! package js.html; @:native("BatteryManager") extern class BatteryManager extends EventTarget { var charging(default,null) : Bool; var chargingTime(default,null) : Float; var dischargingTime(default,null) : Float; var level(default,null) : Float; var onchargingchange : haxe.Constraints.Function; var onchargingtimechange : haxe.Constraints.Function; var ondischargingtimechange : haxe.Constraints.Function; var onlevelchange : haxe.Constraints.Function; }haxe_3.2.1+dfsg.orig/std/js/html/BeforeUnloadEvent.hx0000664000175000017500000000247312607337712022414 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/BeforeUnloadEvent.webidl line 10:0. Do not edit! package js.html; @:native("BeforeUnloadEvent") extern class BeforeUnloadEvent extends Event { var returnValue : String; }haxe_3.2.1+dfsg.orig/std/js/html/BinaryType.hx0000664000175000017500000000244412607337712021131 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/WebSocket.webidl line 13:0. Do not edit! package js.html; @:enum abstract BinaryType(String) { var BLOB = "blob"; var ARRAYBUFFER = "arraybuffer"; }haxe_3.2.1+dfsg.orig/std/js/html/Blob.hx0000664000175000017500000000321212607337712017713 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Blob.webidl line 16:0. Do not edit! package js.html; @:native("Blob") extern class Blob { var size(default,null) : Int; var type(default,null) : String; /** @throws DOMError */ @:overload( function() : Void {} ) function new( blobParts : Array>>>, ?options : BlobPropertyBag ) : Void; /** @throws DOMError */ function slice( ?start : Int, ?end : Int, ?contentType : String = "" ) : Blob; }haxe_3.2.1+dfsg.orig/std/js/html/BlobPropertyBag.hx0000664000175000017500000000247112607337712022100 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Blob.webidl line 37:0. Do not edit! package js.html; typedef BlobPropertyBag = { @:optional var endings : Dynamic/*MISSING EndingTypes*/; @:optional var type : String; }haxe_3.2.1+dfsg.orig/std/js/html/BodyElement.hx0000664000175000017500000000374312607337712021255 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLBodyElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLBodyElement") extern class BodyElement extends Element { var text : String; var link : String; var vLink : String; var aLink : String; var bgColor : String; var background : String; var onafterprint : haxe.Constraints.Function; var onbeforeprint : haxe.Constraints.Function; var onbeforeunload : Event -> String; var onhashchange : haxe.Constraints.Function; var onlanguagechange : haxe.Constraints.Function; var onmessage : haxe.Constraints.Function; var onoffline : haxe.Constraints.Function; var ononline : haxe.Constraints.Function; var onpagehide : haxe.Constraints.Function; var onpageshow : haxe.Constraints.Function; var onpopstate : haxe.Constraints.Function; var onresize : haxe.Constraints.Function; var onunload : haxe.Constraints.Function; }haxe_3.2.1+dfsg.orig/std/js/html/ButtonElement.hx0000664000175000017500000000342012607337712021623 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLButtonElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLButtonElement") extern class ButtonElement extends Element { var autofocus : Bool; var disabled : Bool; var form(default,null) : FormElement; var formAction : String; var formEnctype : String; var formMethod : String; var formNoValidate : Bool; var formTarget : String; var name : String; var type : String; var value : String; var willValidate(default,null) : Bool; var validity(default,null) : ValidityState; var validationMessage(default,null) : String; function checkValidity() : Bool; function setCustomValidity( error : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CDATASection.hx0000664000175000017500000000241512607337712021202 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CDATASection.webidl line 7:0. Do not edit! package js.html; @:native("CDATASection") extern class CDATASection extends Text { }haxe_3.2.1+dfsg.orig/std/js/html/CSS.hx0000664000175000017500000000271712607337712017476 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CSS.webidl line 13:0. Do not edit! package js.html; @:native("CSS") extern class CSS { /** @throws DOMError */ @:overload( function( property : String, value : String ) : Bool {} ) static function supports( conditionText : String ) : Bool; /** @throws DOMError */ static function escape( ident : String ) : String; }haxe_3.2.1+dfsg.orig/std/js/html/CSSCharsetRule.hx0000664000175000017500000000244212607337712021633 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from cssrule.webidl line 62:2. Do not edit! package js.html; @:native("CSSCharsetRule") extern class CSSCharsetRule extends CSSRule { var encoding : String; }haxe_3.2.1+dfsg.orig/std/js/html/CSSFontFaceRule.hx0000664000175000017500000000247412607337712021734 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from cssrule.webidl line 42:2. Do not edit! package js.html; @:native("CSSFontFaceRule") extern class CSSFontFaceRule extends CSSRule { var style(default,null) : CSSStyleDeclaration; }haxe_3.2.1+dfsg.orig/std/js/html/CSSImportRule.hx0000664000175000017500000000257712607337712021525 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from cssrule.webidl line 55:2. Do not edit! package js.html; @:native("CSSImportRule") extern class CSSImportRule extends CSSRule { var href(default,null) : String; var media(default,null) : MediaList; var styleSheet(default,null) : CSSStyleSheet; }haxe_3.2.1+dfsg.orig/std/js/html/CSSMatrix.hx0000664000175000017500000000237712607337712020665 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use DOMMatrix instead. */ @:deprecated("CSSMatrix is deprecated, use DOMMatrix instead") typedef CSSMatrix = DOMMatrix; haxe_3.2.1+dfsg.orig/std/js/html/CSSMediaRule.hx0000664000175000017500000000267512607337712021271 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from cssrule.webidl line 31:2. Do not edit! package js.html; @:native("CSSMediaRule") extern class CSSMediaRule extends CSSRule { var media(default,null) : MediaList; var cssRules(default,null) : CSSRuleList; function insertRule( rule : String, index : Int ) : Int; function deleteRule( index : Int ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CSSPageRule.hx0000664000175000017500000000252012607337712021113 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from cssrule.webidl line 47:2. Do not edit! package js.html; @:native("CSSPageRule") extern class CSSPageRule extends CSSRule { var selectorText : String; var style(default,null) : CSSStyleDeclaration; }haxe_3.2.1+dfsg.orig/std/js/html/CSSPrimitiveValue.hx0000664000175000017500000000555712607337712022371 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CSSPrimitiveValue.webidl line 9:0. Do not edit! package js.html; @:native("CSSPrimitiveValue") extern class CSSPrimitiveValue extends CSSValue { static inline var CSS_UNKNOWN : Int = 0; static inline var CSS_NUMBER : Int = 1; static inline var CSS_PERCENTAGE : Int = 2; static inline var CSS_EMS : Int = 3; static inline var CSS_EXS : Int = 4; static inline var CSS_PX : Int = 5; static inline var CSS_CM : Int = 6; static inline var CSS_MM : Int = 7; static inline var CSS_IN : Int = 8; static inline var CSS_PT : Int = 9; static inline var CSS_PC : Int = 10; static inline var CSS_DEG : Int = 11; static inline var CSS_RAD : Int = 12; static inline var CSS_GRAD : Int = 13; static inline var CSS_MS : Int = 14; static inline var CSS_S : Int = 15; static inline var CSS_HZ : Int = 16; static inline var CSS_KHZ : Int = 17; static inline var CSS_DIMENSION : Int = 18; static inline var CSS_STRING : Int = 19; static inline var CSS_URI : Int = 20; static inline var CSS_IDENT : Int = 21; static inline var CSS_ATTR : Int = 22; static inline var CSS_COUNTER : Int = 23; static inline var CSS_RECT : Int = 24; static inline var CSS_RGBCOLOR : Int = 25; var primitiveType(default,null) : Int; /** @throws DOMError */ function setFloatValue( unitType : Int, floatValue : Float ) : Void; /** @throws DOMError */ function getFloatValue( unitType : Int ) : Float; /** @throws DOMError */ function setStringValue( stringType : Int, stringValue : String ) : Void; /** @throws DOMError */ function getStringValue() : String; /** @throws DOMError */ function getCounterValue() : Dynamic/*MISSING Counter*/; /** @throws DOMError */ function getRectValue() : Rect; /** @throws DOMError */ function getRGBColorValue() : RGBColor; }haxe_3.2.1+dfsg.orig/std/js/html/CSSRule.hx0000664000175000017500000000325012607337712020317 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from cssrule.webidl line 3:2. Do not edit! package js.html; @:native("CSSRule") extern class CSSRule { static inline var UNKNOWN_RULE : Int = 0; static inline var STYLE_RULE : Int = 1; static inline var CHARSET_RULE : Int = 2; static inline var IMPORT_RULE : Int = 3; static inline var MEDIA_RULE : Int = 4; static inline var FONT_FACE_RULE : Int = 5; static inline var PAGE_RULE : Int = 6; var type(default,null) : Int; var cssText : String; var parentStyleSheet(default,null) : CSSStyleSheet; var parentRule(default,null) : CSSRule; }haxe_3.2.1+dfsg.orig/std/js/html/CSSRuleList.hx0000664000175000017500000000255112607337712021156 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CSSRuleList.webidl line 7:0. Do not edit! package js.html; @:native("CSSRuleList") extern class CSSRuleList implements ArrayAccess { var length(default,null) : Int; function item( index : Int ) : CSSRule; }haxe_3.2.1+dfsg.orig/std/js/html/CSSStyleDeclaration.hx0000664000175000017500000007135112607337712022665 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CSSStyleDeclaration.webidl line 12:0. Do not edit! package js.html; @:native("CSSStyleDeclaration") extern class CSSStyleDeclaration implements ArrayAccess { var cssText : String; var length(default,null) : Int; var parentRule(default,null) : CSSRule; /** Shorthand for the "align-content" CSS property. */ var alignContent :String; /** Shorthand for the "align-items" CSS property. */ var alignItems :String; /** Shorthand for the "align-self" CSS property. */ var alignSelf :String; /** Shorthand for the "alignment-adjust" CSS property. */ var alignmentAdjust :String; /** Shorthand for the "alignment-baseline" CSS property. */ var alignmentBaseline :String; /** Shorthand for the "all" CSS property. */ var all :String; /** Shorthand for the "anchor-point" CSS property. */ var anchorPoint :String; /** Shorthand for the "animation" CSS property. */ var animation :String; /** Shorthand for the "animation-delay" CSS property. */ var animationDelay :String; /** Shorthand for the "animation-direction" CSS property. */ var animationDirection :String; /** Shorthand for the "animation-duration" CSS property. */ var animationDuration :String; /** Shorthand for the "animation-fill-mode" CSS property. */ var animationFillMode :String; /** Shorthand for the "animation-iteration-count" CSS property. */ var animationIterationCount :String; /** Shorthand for the "animation-name" CSS property. */ var animationName :String; /** Shorthand for the "animation-play-state" CSS property. */ var animationPlayState :String; /** Shorthand for the "animation-timing-function" CSS property. */ var animationTimingFunction :String; /** Shorthand for the "azimuth" CSS property. */ var azimuth :String; /** Shorthand for the "backface-visibility" CSS property. */ var backfaceVisibility :String; /** Shorthand for the "background" CSS property. */ var background :String; /** Shorthand for the "background-attachment" CSS property. */ var backgroundAttachment :String; /** Shorthand for the "background-clip" CSS property. */ var backgroundClip :String; /** Shorthand for the "background-color" CSS property. */ var backgroundColor :String; /** Shorthand for the "background-image" CSS property. */ var backgroundImage :String; /** Shorthand for the "background-origin" CSS property. */ var backgroundOrigin :String; /** Shorthand for the "background-position" CSS property. */ var backgroundPosition :String; /** Shorthand for the "background-repeat" CSS property. */ var backgroundRepeat :String; /** Shorthand for the "background-size" CSS property. */ var backgroundSize :String; /** Shorthand for the "baseline-shift" CSS property. */ var baselineShift :String; /** Shorthand for the "binding" CSS property. */ var binding :String; /** Shorthand for the "bleed" CSS property. */ var bleed :String; /** Shorthand for the "bookmark-label" CSS property. */ var bookmarkLabel :String; /** Shorthand for the "bookmark-level" CSS property. */ var bookmarkLevel :String; /** Shorthand for the "bookmark-state" CSS property. */ var bookmarkState :String; /** Shorthand for the "border" CSS property. */ var border :String; /** Shorthand for the "border-bottom" CSS property. */ var borderBottom :String; /** Shorthand for the "border-bottom-color" CSS property. */ var borderBottomColor :String; /** Shorthand for the "border-bottom-left-radius" CSS property. */ var borderBottomLeftRadius :String; /** Shorthand for the "border-bottom-right-radius" CSS property. */ var borderBottomRightRadius :String; /** Shorthand for the "border-bottom-style" CSS property. */ var borderBottomStyle :String; /** Shorthand for the "border-bottom-width" CSS property. */ var borderBottomWidth :String; /** Shorthand for the "border-collapse" CSS property. */ var borderCollapse :String; /** Shorthand for the "border-color" CSS property. */ var borderColor :String; /** Shorthand for the "border-image" CSS property. */ var borderImage :String; /** Shorthand for the "border-image-outset" CSS property. */ var borderImageOutset :String; /** Shorthand for the "border-image-repeat" CSS property. */ var borderImageRepeat :String; /** Shorthand for the "border-image-slice" CSS property. */ var borderImageSlice :String; /** Shorthand for the "border-image-source" CSS property. */ var borderImageSource :String; /** Shorthand for the "border-image-width" CSS property. */ var borderImageWidth :String; /** Shorthand for the "border-left" CSS property. */ var borderLeft :String; /** Shorthand for the "border-left-color" CSS property. */ var borderLeftColor :String; /** Shorthand for the "border-left-style" CSS property. */ var borderLeftStyle :String; /** Shorthand for the "border-left-width" CSS property. */ var borderLeftWidth :String; /** Shorthand for the "border-radius" CSS property. */ var borderRadius :String; /** Shorthand for the "border-right" CSS property. */ var borderRight :String; /** Shorthand for the "border-right-color" CSS property. */ var borderRightColor :String; /** Shorthand for the "border-right-style" CSS property. */ var borderRightStyle :String; /** Shorthand for the "border-right-width" CSS property. */ var borderRightWidth :String; /** Shorthand for the "border-spacing" CSS property. */ var borderSpacing :String; /** Shorthand for the "border-style" CSS property. */ var borderStyle :String; /** Shorthand for the "border-top" CSS property. */ var borderTop :String; /** Shorthand for the "border-top-color" CSS property. */ var borderTopColor :String; /** Shorthand for the "border-top-left-radius" CSS property. */ var borderTopLeftRadius :String; /** Shorthand for the "border-top-right-radius" CSS property. */ var borderTopRightRadius :String; /** Shorthand for the "border-top-style" CSS property. */ var borderTopStyle :String; /** Shorthand for the "border-top-width" CSS property. */ var borderTopWidth :String; /** Shorthand for the "border-width" CSS property. */ var borderWidth :String; /** Shorthand for the "bottom" CSS property. */ var bottom :String; /** Shorthand for the "box-decoration-break" CSS property. */ var boxDecorationBreak :String; /** Shorthand for the "box-shadow" CSS property. */ var boxShadow :String; /** Shorthand for the "box-sizing" CSS property. */ var boxSizing :String; /** Shorthand for the "box-snap" CSS property. */ var boxSnap :String; /** Shorthand for the "box-suppress" CSS property. */ var boxSuppress :String; /** Shorthand for the "break-after" CSS property. */ var breakAfter :String; /** Shorthand for the "break-before" CSS property. */ var breakBefore :String; /** Shorthand for the "break-inside" CSS property. */ var breakInside :String; /** Shorthand for the "caption-side" CSS property. */ var captionSide :String; /** Shorthand for the "chains" CSS property. */ var chains :String; /** Shorthand for the "clear" CSS property. */ var clear :String; /** Shorthand for the "clip" CSS property. */ var clip :String; /** Shorthand for the "clip-path" CSS property. */ var clipPath :String; /** Shorthand for the "clip-rule" CSS property. */ var clipRule :String; /** Shorthand for the "color" CSS property. */ var color :String; /** Shorthand for the "color-interpolation-filters" CSS property. */ var colorInterpolationFilters :String; /** Shorthand for the "column-count" CSS property. */ var columnCount :String; /** Shorthand for the "column-fill" CSS property. */ var columnFill :String; /** Shorthand for the "column-gap" CSS property. */ var columnGap :String; /** Shorthand for the "column-rule" CSS property. */ var columnRule :String; /** Shorthand for the "column-rule-color" CSS property. */ var columnRuleColor :String; /** Shorthand for the "column-rule-style" CSS property. */ var columnRuleStyle :String; /** Shorthand for the "column-rule-width" CSS property. */ var columnRuleWidth :String; /** Shorthand for the "column-span" CSS property. */ var columnSpan :String; /** Shorthand for the "column-width" CSS property. */ var columnWidth :String; /** Shorthand for the "columns" CSS property. */ var columns :String; /** Shorthand for the "contain" CSS property. */ var contain :String; /** Shorthand for the "content" CSS property. */ var content :String; /** Shorthand for the "counter-increment" CSS property. */ var counterIncrement :String; /** Shorthand for the "counter-reset" CSS property. */ var counterReset :String; /** Shorthand for the "counter-set" CSS property. */ var counterSet :String; /** Shorthand for the "crop" CSS property. */ var crop :String; /** Shorthand for the "cue" CSS property. */ var cue :String; /** Shorthand for the "cue-after" CSS property. */ var cueAfter :String; /** Shorthand for the "cue-before" CSS property. */ var cueBefore :String; /** Shorthand for the "cursor" CSS property. */ var cursor :String; /** Shorthand for the "direction" CSS property. */ var direction :String; /** Shorthand for the "display" CSS property. */ var display :String; /** Shorthand for the "display-inside" CSS property. */ var displayInside :String; /** Shorthand for the "display-list" CSS property. */ var displayList :String; /** Shorthand for the "display-outside" CSS property. */ var displayOutside :String; /** Shorthand for the "dominant-baseline" CSS property. */ var dominantBaseline :String; /** Shorthand for the "elevation" CSS property. */ var elevation :String; /** Shorthand for the "empty-cells" CSS property. */ var emptyCells :String; /** Shorthand for the "filter" CSS property. */ var filter :String; /** Shorthand for the "flex" CSS property. */ var flex :String; /** Shorthand for the "flex-basis" CSS property. */ var flexBasis :String; /** Shorthand for the "flex-direction" CSS property. */ var flexDirection :String; /** Shorthand for the "flex-flow" CSS property. */ var flexFlow :String; /** Shorthand for the "flex-grow" CSS property. */ var flexGrow :String; /** Shorthand for the "flex-shrink" CSS property. */ var flexShrink :String; /** Shorthand for the "flex-wrap" CSS property. */ var flexWrap :String; /** Shorthand for the "float" CSS property. */ var float :String; /** Shorthand for the "float-offset" CSS property. */ var floatOffset :String; /** Shorthand for the "flood-color" CSS property. */ var floodColor :String; /** Shorthand for the "flood-opacity" CSS property. */ var floodOpacity :String; /** Shorthand for the "flow-from" CSS property. */ var flowFrom :String; /** Shorthand for the "flow-into" CSS property. */ var flowInto :String; /** Shorthand for the "font" CSS property. */ var font :String; /** Shorthand for the "font-family" CSS property. */ var fontFamily :String; /** Shorthand for the "font-feature-settings" CSS property. */ var fontFeatureSettings :String; /** Shorthand for the "font-kerning" CSS property. */ var fontKerning :String; /** Shorthand for the "font-language-override" CSS property. */ var fontLanguageOverride :String; /** Shorthand for the "font-size" CSS property. */ var fontSize :String; /** Shorthand for the "font-size-adjust" CSS property. */ var fontSizeAdjust :String; /** Shorthand for the "font-stretch" CSS property. */ var fontStretch :String; /** Shorthand for the "font-style" CSS property. */ var fontStyle :String; /** Shorthand for the "font-synthesis" CSS property. */ var fontSynthesis :String; /** Shorthand for the "font-variant" CSS property. */ var fontVariant :String; /** Shorthand for the "font-variant-alternates" CSS property. */ var fontVariantAlternates :String; /** Shorthand for the "font-variant-caps" CSS property. */ var fontVariantCaps :String; /** Shorthand for the "font-variant-east-asian" CSS property. */ var fontVariantEastAsian :String; /** Shorthand for the "font-variant-ligatures" CSS property. */ var fontVariantLigatures :String; /** Shorthand for the "font-variant-numeric" CSS property. */ var fontVariantNumeric :String; /** Shorthand for the "font-variant-position" CSS property. */ var fontVariantPosition :String; /** Shorthand for the "font-weight" CSS property. */ var fontWeight :String; /** Shorthand for the "grid" CSS property. */ var grid :String; /** Shorthand for the "grid-area" CSS property. */ var gridArea :String; /** Shorthand for the "grid-auto-columns" CSS property. */ var gridAutoColumns :String; /** Shorthand for the "grid-auto-flow" CSS property. */ var gridAutoFlow :String; /** Shorthand for the "grid-auto-rows" CSS property. */ var gridAutoRows :String; /** Shorthand for the "grid-column" CSS property. */ var gridColumn :String; /** Shorthand for the "grid-column-end" CSS property. */ var gridColumnEnd :String; /** Shorthand for the "grid-column-start" CSS property. */ var gridColumnStart :String; /** Shorthand for the "grid-row" CSS property. */ var gridRow :String; /** Shorthand for the "grid-row-end" CSS property. */ var gridRowEnd :String; /** Shorthand for the "grid-row-start" CSS property. */ var gridRowStart :String; /** Shorthand for the "grid-template" CSS property. */ var gridTemplate :String; /** Shorthand for the "grid-template-areas" CSS property. */ var gridTemplateAreas :String; /** Shorthand for the "grid-template-columns" CSS property. */ var gridTemplateColumns :String; /** Shorthand for the "grid-template-rows" CSS property. */ var gridTemplateRows :String; /** Shorthand for the "hanging-punctuation" CSS property. */ var hangingPunctuation :String; /** Shorthand for the "height" CSS property. */ var height :String; /** Shorthand for the "hyphens" CSS property. */ var hyphens :String; /** Shorthand for the "icon" CSS property. */ var icon :String; /** Shorthand for the "image-orientation" CSS property. */ var imageOrientation :String; /** Shorthand for the "image-resolution" CSS property. */ var imageResolution :String; /** Shorthand for the "ime-mode" CSS property. */ var imeMode :String; /** Shorthand for the "initial-letters" CSS property. */ var initialLetters :String; /** Shorthand for the "inline-box-align" CSS property. */ var inlineBoxAlign :String; /** Shorthand for the "justify-content" CSS property. */ var justifyContent :String; /** Shorthand for the "justify-items" CSS property. */ var justifyItems :String; /** Shorthand for the "justify-self" CSS property. */ var justifySelf :String; /** Shorthand for the "left" CSS property. */ var left :String; /** Shorthand for the "letter-spacing" CSS property. */ var letterSpacing :String; /** Shorthand for the "lighting-color" CSS property. */ var lightingColor :String; /** Shorthand for the "line-box-contain" CSS property. */ var lineBoxContain :String; /** Shorthand for the "line-break" CSS property. */ var lineBreak :String; /** Shorthand for the "line-grid" CSS property. */ var lineGrid :String; /** Shorthand for the "line-height" CSS property. */ var lineHeight :String; /** Shorthand for the "line-snap" CSS property. */ var lineSnap :String; /** Shorthand for the "line-stacking" CSS property. */ var lineStacking :String; /** Shorthand for the "line-stacking-ruby" CSS property. */ var lineStackingRuby :String; /** Shorthand for the "line-stacking-shift" CSS property. */ var lineStackingShift :String; /** Shorthand for the "line-stacking-strategy" CSS property. */ var lineStackingStrategy :String; /** Shorthand for the "list-style" CSS property. */ var listStyle :String; /** Shorthand for the "list-style-image" CSS property. */ var listStyleImage :String; /** Shorthand for the "list-style-position" CSS property. */ var listStylePosition :String; /** Shorthand for the "list-style-type" CSS property. */ var listStyleType :String; /** Shorthand for the "margin" CSS property. */ var margin :String; /** Shorthand for the "margin-bottom" CSS property. */ var marginBottom :String; /** Shorthand for the "margin-left" CSS property. */ var marginLeft :String; /** Shorthand for the "margin-right" CSS property. */ var marginRight :String; /** Shorthand for the "margin-top" CSS property. */ var marginTop :String; /** Shorthand for the "marker-offset" CSS property. */ var markerOffset :String; /** Shorthand for the "marker-side" CSS property. */ var markerSide :String; /** Shorthand for the "marks" CSS property. */ var marks :String; /** Shorthand for the "mask" CSS property. */ var mask :String; /** Shorthand for the "mask-box" CSS property. */ var maskBox :String; /** Shorthand for the "mask-box-outset" CSS property. */ var maskBoxOutset :String; /** Shorthand for the "mask-box-repeat" CSS property. */ var maskBoxRepeat :String; /** Shorthand for the "mask-box-slice" CSS property. */ var maskBoxSlice :String; /** Shorthand for the "mask-box-source" CSS property. */ var maskBoxSource :String; /** Shorthand for the "mask-box-width" CSS property. */ var maskBoxWidth :String; /** Shorthand for the "mask-clip" CSS property. */ var maskClip :String; /** Shorthand for the "mask-image" CSS property. */ var maskImage :String; /** Shorthand for the "mask-origin" CSS property. */ var maskOrigin :String; /** Shorthand for the "mask-position" CSS property. */ var maskPosition :String; /** Shorthand for the "mask-repeat" CSS property. */ var maskRepeat :String; /** Shorthand for the "mask-size" CSS property. */ var maskSize :String; /** Shorthand for the "mask-source-type" CSS property. */ var maskSourceType :String; /** Shorthand for the "mask-type" CSS property. */ var maskType :String; /** Shorthand for the "max-height" CSS property. */ var maxHeight :String; /** Shorthand for the "max-lines" CSS property. */ var maxLines :String; /** Shorthand for the "max-width" CSS property. */ var maxWidth :String; /** Shorthand for the "min-height" CSS property. */ var minHeight :String; /** Shorthand for the "min-width" CSS property. */ var minWidth :String; /** Shorthand for the "move-to" CSS property. */ var moveTo :String; /** Shorthand for the "nav-down" CSS property. */ var navDown :String; /** Shorthand for the "nav-index" CSS property. */ var navIndex :String; /** Shorthand for the "nav-left" CSS property. */ var navLeft :String; /** Shorthand for the "nav-right" CSS property. */ var navRight :String; /** Shorthand for the "nav-up" CSS property. */ var navUp :String; /** Shorthand for the "object-fit" CSS property. */ var objectFit :String; /** Shorthand for the "object-position" CSS property. */ var objectPosition :String; /** Shorthand for the "opacity" CSS property. */ var opacity :String; /** Shorthand for the "order" CSS property. */ var order :String; /** Shorthand for the "orphans" CSS property. */ var orphans :String; /** Shorthand for the "outline" CSS property. */ var outline :String; /** Shorthand for the "outline-color" CSS property. */ var outlineColor :String; /** Shorthand for the "outline-offset" CSS property. */ var outlineOffset :String; /** Shorthand for the "outline-style" CSS property. */ var outlineStyle :String; /** Shorthand for the "outline-width" CSS property. */ var outlineWidth :String; /** Shorthand for the "overflow" CSS property. */ var overflow :String; /** Shorthand for the "overflow-wrap" CSS property. */ var overflowWrap :String; /** Shorthand for the "overflow-x" CSS property. */ var overflowX :String; /** Shorthand for the "overflow-y" CSS property. */ var overflowY :String; /** Shorthand for the "padding" CSS property. */ var padding :String; /** Shorthand for the "padding-bottom" CSS property. */ var paddingBottom :String; /** Shorthand for the "padding-left" CSS property. */ var paddingLeft :String; /** Shorthand for the "padding-right" CSS property. */ var paddingRight :String; /** Shorthand for the "padding-top" CSS property. */ var paddingTop :String; /** Shorthand for the "page" CSS property. */ var page :String; /** Shorthand for the "page-break-after" CSS property. */ var pageBreakAfter :String; /** Shorthand for the "page-break-before" CSS property. */ var pageBreakBefore :String; /** Shorthand for the "page-break-inside" CSS property. */ var pageBreakInside :String; /** Shorthand for the "page-policy" CSS property. */ var pagePolicy :String; /** Shorthand for the "pause" CSS property. */ var pause :String; /** Shorthand for the "pause-after" CSS property. */ var pauseAfter :String; /** Shorthand for the "pause-before" CSS property. */ var pauseBefore :String; /** Shorthand for the "perspective" CSS property. */ var perspective :String; /** Shorthand for the "perspective-origin" CSS property. */ var perspectiveOrigin :String; /** Shorthand for the "pitch" CSS property. */ var pitch :String; /** Shorthand for the "pitch-range" CSS property. */ var pitchRange :String; /** Shorthand for the "play-during" CSS property. */ var playDuring :String; /** Shorthand for the "position" CSS property. */ var position :String; /** Shorthand for the "presentation-level" CSS property. */ var presentationLevel :String; /** Shorthand for the "quotes" CSS property. */ var quotes :String; /** Shorthand for the "region-fragment" CSS property. */ var regionFragment :String; /** Shorthand for the "resize" CSS property. */ var resize :String; /** Shorthand for the "rest" CSS property. */ var rest :String; /** Shorthand for the "rest-after" CSS property. */ var restAfter :String; /** Shorthand for the "rest-before" CSS property. */ var restBefore :String; /** Shorthand for the "richness" CSS property. */ var richness :String; /** Shorthand for the "right" CSS property. */ var right :String; /** Shorthand for the "rotation" CSS property. */ var rotation :String; /** Shorthand for the "rotation-point" CSS property. */ var rotationPoint :String; /** Shorthand for the "ruby-align" CSS property. */ var rubyAlign :String; /** Shorthand for the "ruby-merge" CSS property. */ var rubyMerge :String; /** Shorthand for the "ruby-position" CSS property. */ var rubyPosition :String; /** Shorthand for the "shape-image-threshold" CSS property. */ var shapeImageThreshold :String; /** Shorthand for the "shape-outside" CSS property. */ var shapeOutside :String; /** Shorthand for the "shape-margin" CSS property. */ var shapeMargin :String; /** Shorthand for the "size" CSS property. */ var size :String; /** Shorthand for the "speak" CSS property. */ var speak :String; /** Shorthand for the "speak-as" CSS property. */ var speakAs :String; /** Shorthand for the "speak-header" CSS property. */ var speakHeader :String; /** Shorthand for the "speak-numeral" CSS property. */ var speakNumeral :String; /** Shorthand for the "speak-punctuation" CSS property. */ var speakPunctuation :String; /** Shorthand for the "speech-rate" CSS property. */ var speechRate :String; /** Shorthand for the "stress" CSS property. */ var stress :String; /** Shorthand for the "string-set" CSS property. */ var stringSet :String; /** Shorthand for the "tab-size" CSS property. */ var tabSize :String; /** Shorthand for the "table-layout" CSS property. */ var tableLayout :String; /** Shorthand for the "text-align" CSS property. */ var textAlign :String; /** Shorthand for the "text-align-last" CSS property. */ var textAlignLast :String; /** Shorthand for the "text-combine-upright" CSS property. */ var textCombineUpright :String; /** Shorthand for the "text-decoration" CSS property. */ var textDecoration :String; /** Shorthand for the "text-decoration-color" CSS property. */ var textDecorationColor :String; /** Shorthand for the "text-decoration-line" CSS property. */ var textDecorationLine :String; /** Shorthand for the "text-decoration-skip" CSS property. */ var textDecorationSkip :String; /** Shorthand for the "text-decoration-style" CSS property. */ var textDecorationStyle :String; /** Shorthand for the "text-emphasis" CSS property. */ var textEmphasis :String; /** Shorthand for the "text-emphasis-color" CSS property. */ var textEmphasisColor :String; /** Shorthand for the "text-emphasis-position" CSS property. */ var textEmphasisPosition :String; /** Shorthand for the "text-emphasis-style" CSS property. */ var textEmphasisStyle :String; /** Shorthand for the "text-height" CSS property. */ var textHeight :String; /** Shorthand for the "text-indent" CSS property. */ var textIndent :String; /** Shorthand for the "text-justify" CSS property. */ var textJustify :String; /** Shorthand for the "text-orientation" CSS property. */ var textOrientation :String; /** Shorthand for the "text-overflow" CSS property. */ var textOverflow :String; /** Shorthand for the "text-shadow" CSS property. */ var textShadow :String; /** Shorthand for the "text-space-collapse" CSS property. */ var textSpaceCollapse :String; /** Shorthand for the "text-transform" CSS property. */ var textTransform :String; /** Shorthand for the "text-underline-position" CSS property. */ var textUnderlinePosition :String; /** Shorthand for the "text-wrap" CSS property. */ var textWrap :String; /** Shorthand for the "top" CSS property. */ var top :String; /** Shorthand for the "transform" CSS property. */ var transform :String; /** Shorthand for the "transform-origin" CSS property. */ var transformOrigin :String; /** Shorthand for the "transform-style" CSS property. */ var transformStyle :String; /** Shorthand for the "transition" CSS property. */ var transition :String; /** Shorthand for the "transition-delay" CSS property. */ var transitionDelay :String; /** Shorthand for the "transition-duration" CSS property. */ var transitionDuration :String; /** Shorthand for the "transition-property" CSS property. */ var transitionProperty :String; /** Shorthand for the "transition-timing-function" CSS property. */ var transitionTimingFunction :String; /** Shorthand for the "unicode-bidi" CSS property. */ var unicodeBidi :String; /** Shorthand for the "vertical-align" CSS property. */ var verticalAlign :String; /** Shorthand for the "visibility" CSS property. */ var visibility :String; /** Shorthand for the "voice-balance" CSS property. */ var voiceBalance :String; /** Shorthand for the "voice-duration" CSS property. */ var voiceDuration :String; /** Shorthand for the "voice-family" CSS property. */ var voiceFamily :String; /** Shorthand for the "voice-pitch" CSS property. */ var voicePitch :String; /** Shorthand for the "voice-range" CSS property. */ var voiceRange :String; /** Shorthand for the "voice-rate" CSS property. */ var voiceRate :String; /** Shorthand for the "voice-stress" CSS property. */ var voiceStress :String; /** Shorthand for the "voice-volume" CSS property. */ var voiceVolume :String; /** Shorthand for the "volume" CSS property. */ var volume :String; /** Shorthand for the "white-space" CSS property. */ var whiteSpace :String; /** Shorthand for the "widows" CSS property. */ var widows :String; /** Shorthand for the "width" CSS property. */ var width :String; /** Shorthand for the "will-change" CSS property. */ var willChange :String; /** Shorthand for the "word-break" CSS property. */ var wordBreak :String; /** Shorthand for the "word-spacing" CSS property. */ var wordSpacing :String; /** Shorthand for the "word-wrap" CSS property. */ var wordWrap :String; /** Shorthand for the "wrap-flow" CSS property. */ var wrapFlow :String; /** Shorthand for the "wrap-through" CSS property. */ var wrapThrough :String; /** Shorthand for the "writing-mode" CSS property. */ var writingMode :String; /** Shorthand for the "z-index" CSS property. */ var zIndex :String; function item( index : Int ) : String; /** @throws DOMError */ function getPropertyValue( property : String ) : String; /** @throws DOMError */ function getPropertyCSSValue( property : String ) : CSSValue; function getPropertyPriority( property : String ) : String; /** @throws DOMError */ function setProperty( property : String, value : String, ?priority : String = "" ) : Void; /** @throws DOMError */ function removeProperty( property : String ) : String; }haxe_3.2.1+dfsg.orig/std/js/html/CSSStyleRule.hx0000664000175000017500000000252212607337712021341 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from cssrule.webidl line 23:2. Do not edit! package js.html; @:native("CSSStyleRule") extern class CSSStyleRule extends CSSRule { var selectorText : String; var style(default,null) : CSSStyleDeclaration; }haxe_3.2.1+dfsg.orig/std/js/html/CSSStyleSheet.hx0000664000175000017500000000300412607337712021476 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CSSStyleSheet.webidl line 12:0. Do not edit! package js.html; @:native("CSSStyleSheet") extern class CSSStyleSheet extends StyleSheet { var ownerRule(default,null) : CSSRule; var cssRules(default,null) : CSSRuleList; /** @throws DOMError */ function insertRule( rule : String, index : Int ) : Int; /** @throws DOMError */ function deleteRule( index : Int ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CSSUnknownRule.hx0000664000175000017500000000241012607337712021674 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from cssrule.webidl line 69:2. Do not edit! package js.html; @:native("CSSUnknownRule") extern class CSSUnknownRule extends CSSRule { }haxe_3.2.1+dfsg.orig/std/js/html/CSSValue.hx0000664000175000017500000000275012607337712020470 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CSSValue.webidl line 7:0. Do not edit! package js.html; @:native("CSSValue") extern class CSSValue { static inline var CSS_INHERIT : Int = 0; static inline var CSS_PRIMITIVE_VALUE : Int = 1; static inline var CSS_VALUE_LIST : Int = 2; static inline var CSS_CUSTOM : Int = 3; var cssText : String; var cssValueType(default,null) : Int; }haxe_3.2.1+dfsg.orig/std/js/html/CSSValueList.hx0000664000175000017500000000257712607337712021333 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CSSValueList.webidl line 7:0. Do not edit! package js.html; @:native("CSSValueList") extern class CSSValueList extends CSSValue implements ArrayAccess { var length(default,null) : Int; function item( index : Int ) : CSSValue; }haxe_3.2.1+dfsg.orig/std/js/html/CanvasElement.hx0000664000175000017500000000451512607337712021571 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLCanvasElement.webidl line 17:0. Do not edit! package js.html; @:native("HTMLCanvasElement") extern class CanvasElement extends Element { var width : Int; var height : Int; /** @throws DOMError */ function getContext( contextId : String, ?contextOptions : Dynamic ) : Dynamic/*MISSING nsISupports*/; /** @throws DOMError */ function toDataURL( ?type : String = "", ?encoderOptions : Dynamic ) : String; /** @throws DOMError */ function toBlob( callback : Blob -> Void, ?type : String = "", ?encoderOptions : Dynamic ) : Void; /** Shorthand for getting a CanvasRenderingContext2D. */ inline function getContext2d( ?attribs : {} ) : CanvasRenderingContext2D { return cast getContext("2d", attribs); } /** Shorthand for getting a js.html.webgl.RenderingContext. */ inline function getContextWebGL( ?attribs : js.html.webgl.ContextAttributes ) : js.html.webgl.RenderingContext { return CanvasUtil.getContextWebGL(this, attribs); } } private class CanvasUtil { public static function getContextWebGL( canvas :CanvasElement, attribs :{} ) { for (name in ["webgl", "experimental-webgl"]) { var ctx = canvas.getContext(name, attribs); if (ctx != null) return ctx; } return null; } } haxe_3.2.1+dfsg.orig/std/js/html/CanvasGradient.hx0000664000175000017500000000255412607337712021736 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CanvasRenderingContext2D.webidl line 285:0. Do not edit! package js.html; @:native("CanvasGradient") extern class CanvasGradient { /** @throws DOMError */ function addColorStop( offset : Float, color : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CanvasPattern.hx0000664000175000017500000000251612607337712021614 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CanvasRenderingContext2D.webidl line 292:0. Do not edit! package js.html; @:native("CanvasPattern") extern class CanvasPattern { function setTransform( matrix : js.html.svg.Matrix ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CanvasRenderingContext2D.hx0000664000175000017500000001447612607337712023657 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CanvasRenderingContext2D.webidl line 28:0. Do not edit! package js.html; @:native("CanvasRenderingContext2D") extern class CanvasRenderingContext2D { var canvas(default,null) : CanvasElement; var globalAlpha : Float; var globalCompositeOperation : String; var strokeStyle : haxe.extern.EitherType>; var fillStyle : haxe.extern.EitherType>; var shadowOffsetX : Float; var shadowOffsetY : Float; var shadowBlur : Float; var shadowColor : String; var filter : String; var imageSmoothingEnabled : Bool; var lineWidth : Float; var lineCap : String; var lineJoin : String; var miterLimit : Float; var lineDashOffset : Float; var font : String; var textAlign : String; var textBaseline : String; function save() : Void; function restore() : Void; /** @throws DOMError */ function scale( x : Float, y : Float ) : Void; /** @throws DOMError */ function rotate( angle : Float ) : Void; /** @throws DOMError */ function translate( x : Float, y : Float ) : Void; /** @throws DOMError */ function transform( a : Float, b : Float, c : Float, d : Float, e : Float, f : Float ) : Void; /** @throws DOMError */ function setTransform( a : Float, b : Float, c : Float, d : Float, e : Float, f : Float ) : Void; /** @throws DOMError */ function resetTransform() : Void; function createLinearGradient( x0 : Float, y0 : Float, x1 : Float, y1 : Float ) : CanvasGradient; /** @throws DOMError */ function createRadialGradient( x0 : Float, y0 : Float, r0 : Float, x1 : Float, y1 : Float, r1 : Float ) : CanvasGradient; /** @throws DOMError */ function createPattern( image : haxe.extern.EitherType>, repetition : String ) : CanvasPattern; function clearRect( x : Float, y : Float, w : Float, h : Float ) : Void; function fillRect( x : Float, y : Float, w : Float, h : Float ) : Void; function strokeRect( x : Float, y : Float, w : Float, h : Float ) : Void; function beginPath() : Void; @:overload( function( ?winding : CanvasWindingRule = "nonzero" ) : Void {} ) function fill( path : Path2D, ?winding : CanvasWindingRule = "nonzero" ) : Void; @:overload( function() : Void {} ) function stroke( path : Path2D ) : Void; function drawFocusIfNeeded( element : Element ) : Void; function drawCustomFocusRing( element : Element ) : Bool; @:overload( function( ?winding : CanvasWindingRule = "nonzero" ) : Void {} ) function clip( path : Path2D, ?winding : CanvasWindingRule = "nonzero" ) : Void; @:overload( function( x : Float, y : Float, ?winding : CanvasWindingRule = "nonzero" ) : Bool {} ) function isPointInPath( path : Path2D, x : Float, y : Float, ?winding : CanvasWindingRule = "nonzero" ) : Bool; @:overload( function( x : Float, y : Float ) : Bool {} ) function isPointInStroke( path : Path2D, x : Float, y : Float ) : Bool; /** @throws DOMError */ function fillText( text : String, x : Float, y : Float, ?maxWidth : Float ) : Void; /** @throws DOMError */ function strokeText( text : String, x : Float, y : Float, ?maxWidth : Float ) : Void; /** @throws DOMError */ function measureText( text : String ) : TextMetrics; /** @throws DOMError */ @:overload( function( image : haxe.extern.EitherType>, dx : Float, dy : Float ) : Void {} ) @:overload( function( image : haxe.extern.EitherType>, dx : Float, dy : Float, dw : Float, dh : Float ) : Void {} ) function drawImage( image : haxe.extern.EitherType>, sx : Float, sy : Float, sw : Float, sh : Float, dx : Float, dy : Float, dw : Float, dh : Float ) : Void; /** @throws DOMError */ function addHitRegion( ?options : HitRegionOptions ) : Void; function removeHitRegion( id : String ) : Void; function clearHitRegions() : Void; /** @throws DOMError */ @:overload( function( sw : Float, sh : Float ) : ImageData {} ) function createImageData( imagedata : ImageData ) : ImageData; /** @throws DOMError */ function getImageData( sx : Float, sy : Float, sw : Float, sh : Float ) : ImageData; /** @throws DOMError */ @:overload( function( imagedata : ImageData, dx : Float, dy : Float ) : Void {} ) function putImageData( imagedata : ImageData, dx : Float, dy : Float, dirtyX : Float, dirtyY : Float, dirtyWidth : Float, dirtyHeight : Float ) : Void; function setLineDash( segments : Array ) : Void; function getLineDash() : Array; function closePath() : Void; function moveTo( x : Float, y : Float ) : Void; function lineTo( x : Float, y : Float ) : Void; function quadraticCurveTo( cpx : Float, cpy : Float, x : Float, y : Float ) : Void; function bezierCurveTo( cp1x : Float, cp1y : Float, cp2x : Float, cp2y : Float, x : Float, y : Float ) : Void; /** @throws DOMError */ function arcTo( x1 : Float, y1 : Float, x2 : Float, y2 : Float, radius : Float ) : Void; function rect( x : Float, y : Float, w : Float, h : Float ) : Void; /** @throws DOMError */ function arc( x : Float, y : Float, radius : Float, startAngle : Float, endAngle : Float, ?anticlockwise : Bool = false ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CanvasWindingRule.hx0000664000175000017500000000247012607337712022425 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CanvasRenderingContext2D.webidl line 14:0. Do not edit! package js.html; @:enum abstract CanvasWindingRule(String) { var NONZERO = "nonzero"; var EVENODD = "evenodd"; }haxe_3.2.1+dfsg.orig/std/js/html/CaretPosition.hx0000664000175000017500000000256112607337712021626 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CaretPosition.webidl line 5:0. Do not edit! package js.html; @:native("CaretPosition") extern class CaretPosition { var offsetNode(default,null) : Node; var offset(default,null) : Int; function getClientRect() : DOMRect; }haxe_3.2.1+dfsg.orig/std/js/html/CharacterData.hx0000664000175000017500000000356312607337712021534 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CharacterData.webidl line 13:0. Do not edit! package js.html; @:native("CharacterData") extern class CharacterData extends Node { var data : String; var length(default,null) : Int; var previousElementSibling(default,null) : Element; var nextElementSibling(default,null) : Element; /** @throws DOMError */ function substringData( offset : Int, count : Int ) : String; /** @throws DOMError */ function appendData( data : String ) : Void; /** @throws DOMError */ function insertData( offset : Int, data : String ) : Void; /** @throws DOMError */ function deleteData( offset : Int, count : Int ) : Void; /** @throws DOMError */ function replaceData( offset : Int, count : Int, data : String ) : Void; function remove() : Void; }haxe_3.2.1+dfsg.orig/std/js/html/ChromeFilePropertyBag.hx0000664000175000017500000000247312607337712023241 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/File.webidl line 35:0. Do not edit! package js.html; typedef ChromeFilePropertyBag = { > FilePropertyBag, @:optional var name : String; @:optional var temporary : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/ClientRect.hx0000664000175000017500000000237312607337712021100 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use DOMRect instead. */ @:deprecated("ClientRect is deprecated, use DOMRect instead") typedef ClientRect = DOMRect; haxe_3.2.1+dfsg.orig/std/js/html/ClientRectList.hx0000664000175000017500000000241712607337712021733 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use DOMRectList instead. */ @:deprecated("ClientRectList is deprecated, use DOMRectList instead") typedef ClientRectList = DOMRectList; haxe_3.2.1+dfsg.orig/std/js/html/Clipboard.hx0000664000175000017500000000241012607337712020733 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use DataTransfer instead. */ @:deprecated("Clipboard is deprecated, use DataTransfer instead") typedef Clipboard = DataTransfer; haxe_3.2.1+dfsg.orig/std/js/html/ClipboardEvent.hx0000664000175000017500000000265512607337712021750 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/ClipboardEvent.webidl line 14:0. Do not edit! package js.html; @:native("ClipboardEvent") extern class ClipboardEvent extends Event { var clipboardData(default,null) : DataTransfer; /** @throws DOMError */ function new( type : String, ?eventInitDict : ClipboardEventInit ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/ClipboardEventInit.hx0000664000175000017500000000247512607337712022574 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/ClipboardEvent.webidl line 19:0. Do not edit! package js.html; typedef ClipboardEventInit = { > EventInit, @:optional var data : String; @:optional var dataType : String; }haxe_3.2.1+dfsg.orig/std/js/html/CloseEvent.hx0000664000175000017500000000317512607337712021114 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CloseEvent.webidl line 14:0. Do not edit! package js.html; @:native("CloseEvent") extern class CloseEvent extends Event { var wasClean(default,null) : Bool; var code(default,null) : Int; var reason(default,null) : String; /** @throws DOMError */ function new( type : String, ?eventInitDict : CloseEventInit ) : Void; /** @throws DOMError */ function initCloseEvent( aType : String, aCanBubble : Bool, aCancelable : Bool, aWasClean : Bool, aReasonCode : Int, aReason : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CloseEventInit.hx0000664000175000017500000000252112607337712021732 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CloseEvent.webidl line 29:0. Do not edit! package js.html; typedef CloseEventInit = { > EventInit, @:optional var code : Int; @:optional var reason : String; @:optional var wasClean : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/CommandEvent.hx0000664000175000017500000000264012607337712021421 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CommandEvent.webidl line 7:0. Do not edit! package js.html; @:native("CommandEvent") extern class CommandEvent extends Event { var command(default,null) : String; function initCommandEvent( type : String, canBubble : Bool, cancelable : Bool, command : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/Comment.hx0000664000175000017500000000251612607337712020445 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Comment.webidl line 14:0. Do not edit! package js.html; @:native("Comment") extern class Comment extends CharacterData { /** @throws DOMError */ function new( ?data : String = "" ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CompositionEvent.hx0000664000175000017500000000303412607337712022344 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CompositionEvent.webidl line 12:0. Do not edit! package js.html; @:native("CompositionEvent") extern class CompositionEvent extends UIEvent { var data(default,null) : String; var locale(default,null) : String; /** @throws DOMError */ function initCompositionEvent( typeArg : String, canBubbleArg : Bool, cancelableArg : Bool, viewArg : Window, dataArg : String, localeArg : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/Console.hx0000664000175000017500000000444412607337712020447 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Console.webidl line 9:0. Do not edit! package js.html; @:native("Console") extern class Console { function log( data : haxe.extern.Rest ) : Void; function info( data : haxe.extern.Rest ) : Void; function warn( data : haxe.extern.Rest ) : Void; function error( data : haxe.extern.Rest ) : Void; function exception( data : haxe.extern.Rest ) : Void; function debug( data : haxe.extern.Rest ) : Void; function table( data : haxe.extern.Rest ) : Void; function trace() : Void; function dir( data : haxe.extern.Rest ) : Void; function group( data : haxe.extern.Rest ) : Void; function groupCollapsed( data : haxe.extern.Rest ) : Void; function groupEnd( data : haxe.extern.Rest ) : Void; function time( ?time : Dynamic ) : Void; function timeEnd( ?time : Dynamic ) : Void; function profile( data : haxe.extern.Rest ) : Void; function profileEnd( data : haxe.extern.Rest ) : Void; function assert( condition : Bool, data : haxe.extern.Rest ) : Void; function count( data : haxe.extern.Rest ) : Void; function clear() : Void; }haxe_3.2.1+dfsg.orig/std/js/html/ContentElement.hx0000664000175000017500000000254312607337712021767 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLContentElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLContentElement") extern class ContentElement extends Element { var select : String; function getDistributedNodes() : NodeList; }haxe_3.2.1+dfsg.orig/std/js/html/ConvertCoordinateOptions.hx0000664000175000017500000000254212607337712024046 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/GeometryUtils.webidl line 19:0. Do not edit! package js.html; typedef ConvertCoordinateOptions = { @:optional var fromBox : Dynamic/*MISSING CSSBoxType*/; @:optional var toBox : Dynamic/*MISSING CSSBoxType*/; }haxe_3.2.1+dfsg.orig/std/js/html/Coordinates.hx0000664000175000017500000000301012607337712021303 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Coordinates.webidl line 14:0. Do not edit! package js.html; @:native("Coordinates") extern class Coordinates { var latitude(default,null) : Float; var longitude(default,null) : Float; var altitude(default,null) : Float; var accuracy(default,null) : Float; var altitudeAccuracy(default,null) : Float; var heading(default,null) : Float; var speed(default,null) : Float; }haxe_3.2.1+dfsg.orig/std/js/html/CreateFileOptions.hx0000664000175000017500000000266112607337712022423 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Directory.webidl line 95:0. Do not edit! package js.html; typedef CreateFileOptions = { @:optional var data : haxe.extern.EitherType>>; @:optional var ifExists : Dynamic/*MISSING CreateIfExistsMode*/; }haxe_3.2.1+dfsg.orig/std/js/html/Crypto.hx0000664000175000017500000000257412607337712020327 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Crypto.webidl line 18:0. Do not edit! package js.html; @:native("Crypto") extern class Crypto { var subtle(default,null) : SubtleCrypto; /** @throws DOMError */ function getRandomValues( array : ArrayBufferView ) : ArrayBufferView; }haxe_3.2.1+dfsg.orig/std/js/html/CryptoKey.hx0000664000175000017500000000263212607337712020773 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/SubtleCrypto.webidl line 142:0. Do not edit! package js.html; @:native("CryptoKey") extern class CryptoKey { var type(default,null) : String; var extractable(default,null) : Bool; var algorithm(default,null) : Dynamic; var usages(default,null) : Array; }haxe_3.2.1+dfsg.orig/std/js/html/CustomEvent.hx0000664000175000017500000000303012607337712021307 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CustomEvent.webidl line 14:0. Do not edit! package js.html; @:native("CustomEvent") extern class CustomEvent extends Event { var detail(default,null) : Dynamic; /** @throws DOMError */ function new( type : String, ?eventInitDict : CustomEventInit ) : Void; /** @throws DOMError */ function initCustomEvent( type : String, canBubble : Bool, cancelable : Bool, detail : Dynamic ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/CustomEventInit.hx0000664000175000017500000000242712607337712022144 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/CustomEvent.webidl line 26:0. Do not edit! package js.html; typedef CustomEventInit = { > EventInit, @:optional var detail : Dynamic; }haxe_3.2.1+dfsg.orig/std/js/html/DListElement.hx0000664000175000017500000000246012607337712021372 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLDListElement.webidl line 16:0. Do not edit! package js.html; @:native("HTMLDListElement") extern class DListElement extends Element { var compact : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/DOMApplicationCache.hx0000664000175000017500000000245012607337712022567 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use ApplicationCache instead. */ @:deprecated("DOMApplicationCache is deprecated, use ApplicationCache instead") typedef DOMApplicationCache = ApplicationCache; haxe_3.2.1+dfsg.orig/std/js/html/DOMCoreException.hx0000664000175000017500000000242612607337712022152 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use DOMException instead. */ @:deprecated("DOMCoreException is deprecated, use DOMException instead") typedef DOMCoreException = DOMException; haxe_3.2.1+dfsg.orig/std/js/html/DOMCursor.hx0000664000175000017500000000312012607337712020650 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMCursor.webidl line 6:0. Do not edit! package js.html; @:native("DOMCursor") extern class DOMCursor extends EventTarget { var done(default,null) : Bool; var readyState(default,null) : DOMRequestReadyState; var result(default,null) : Dynamic; var error(default,null) : DOMError; var onsuccess : haxe.Constraints.Function; var onerror : haxe.Constraints.Function; /** @throws DOMError */ @:native("continue") function continue_() : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DOMElement.hx0000664000175000017500000002340712607337712020776 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Element.webidl line 16:0. Do not edit! package js.html; @:native("Element") extern class DOMElement extends Node { var tagName(default,null) : String; var id : String; var className : String; var classList(default,null) : DOMTokenList; var attributes(default,null) : NamedNodeMap; var onwheel : haxe.Constraints.Function; var title : String; var lang : String; var dir : String; var dataset(default,null) : DOMStringMap; var itemScope : Bool; var itemType(default,null) : DOMSettableTokenList; var itemId : String; var itemRef(default,null) : DOMSettableTokenList; var itemProp(default,null) : DOMSettableTokenList; var properties(default,null) : HTMLPropertiesCollection; var itemValue : Dynamic; var hidden : Bool; var tabIndex : Int; var accessKey : String; var accessKeyLabel(default,null) : String; var draggable : Bool; var contentEditable : String; var isContentEditable(default,null) : Bool; var contextMenu(default,null) : MenuElement; var spellcheck : Bool; var style(default,null) : CSSStyleDeclaration; var oncopy : haxe.Constraints.Function; var oncut : haxe.Constraints.Function; var onpaste : haxe.Constraints.Function; var innerText : String; var offsetParent(default,null) : Element; var offsetTop(default,null) : Int; var offsetLeft(default,null) : Int; var offsetWidth(default,null) : Int; var offsetHeight(default,null) : Int; var scrollTop : Int; var scrollLeft : Int; var scrollWidth(default,null) : Int; var scrollHeight(default,null) : Int; var clientTop(default,null) : Int; var clientLeft(default,null) : Int; var clientWidth(default,null) : Int; var clientHeight(default,null) : Int; var scrollTopMax(default,null) : Int; var scrollLeftMax(default,null) : Int; var innerHTML : String; var outerHTML : String; var shadowRoot(default,null) : ShadowRoot; var onabort : haxe.Constraints.Function; var onblur : haxe.Constraints.Function; var onfocus : haxe.Constraints.Function; var oncanplay : haxe.Constraints.Function; var oncanplaythrough : haxe.Constraints.Function; var onchange : haxe.Constraints.Function; var onclick : haxe.Constraints.Function; var oncontextmenu : haxe.Constraints.Function; var ondblclick : haxe.Constraints.Function; var ondrag : haxe.Constraints.Function; var ondragend : haxe.Constraints.Function; var ondragenter : haxe.Constraints.Function; var ondragleave : haxe.Constraints.Function; var ondragover : haxe.Constraints.Function; var ondragstart : haxe.Constraints.Function; var ondrop : haxe.Constraints.Function; var ondurationchange : haxe.Constraints.Function; var onemptied : haxe.Constraints.Function; var onended : haxe.Constraints.Function; var oninput : haxe.Constraints.Function; var oninvalid : haxe.Constraints.Function; var onkeydown : haxe.Constraints.Function; var onkeypress : haxe.Constraints.Function; var onkeyup : haxe.Constraints.Function; var onload : haxe.Constraints.Function; var onloadeddata : haxe.Constraints.Function; var onloadedmetadata : haxe.Constraints.Function; var onloadstart : haxe.Constraints.Function; var onmousedown : haxe.Constraints.Function; var onmouseenter : haxe.Constraints.Function; var onmouseleave : haxe.Constraints.Function; var onmousemove : haxe.Constraints.Function; var onmouseout : haxe.Constraints.Function; var onmouseover : haxe.Constraints.Function; var onmouseup : haxe.Constraints.Function; var onpause : haxe.Constraints.Function; var onplay : haxe.Constraints.Function; var onplaying : haxe.Constraints.Function; var onprogress : haxe.Constraints.Function; var onratechange : haxe.Constraints.Function; var onreset : haxe.Constraints.Function; var onscroll : haxe.Constraints.Function; var onseeked : haxe.Constraints.Function; var onseeking : haxe.Constraints.Function; var onselect : haxe.Constraints.Function; var onshow : haxe.Constraints.Function; var onstalled : haxe.Constraints.Function; var onsubmit : haxe.Constraints.Function; var onsuspend : haxe.Constraints.Function; var ontimeupdate : haxe.Constraints.Function; var onvolumechange : haxe.Constraints.Function; var onwaiting : haxe.Constraints.Function; var onpointercancel : haxe.Constraints.Function; var onpointerdown : haxe.Constraints.Function; var onpointerup : haxe.Constraints.Function; var onpointermove : haxe.Constraints.Function; var onpointerout : haxe.Constraints.Function; var onpointerover : haxe.Constraints.Function; var onpointerenter : haxe.Constraints.Function; var onpointerleave : haxe.Constraints.Function; var ongotpointercapture : haxe.Constraints.Function; var onlostpointercapture : haxe.Constraints.Function; var onpointerlockchange : haxe.Constraints.Function; var onpointerlockerror : haxe.Constraints.Function; var previousElementSibling(default,null) : Element; var nextElementSibling(default,null) : Element; var onerror : haxe.Constraints.Function; var children(default,null) : HTMLCollection; var firstElementChild(default,null) : Element; var lastElementChild(default,null) : Element; var childElementCount(default,null) : Int; var ontouchstart : haxe.Constraints.Function; var ontouchend : haxe.Constraints.Function; var ontouchmove : haxe.Constraints.Function; var ontouchcancel : haxe.Constraints.Function; function getAttribute( name : String ) : String; function getAttributeNS( namespace_ : String, localName : String ) : String; /** @throws DOMError */ function setAttribute( name : String, value : String ) : Void; /** @throws DOMError */ function setAttributeNS( namespace_ : String, name : String, value : String ) : Void; /** @throws DOMError */ function removeAttribute( name : String ) : Void; /** @throws DOMError */ function removeAttributeNS( namespace_ : String, localName : String ) : Void; function hasAttribute( name : String ) : Bool; function hasAttributeNS( namespace_ : String, localName : String ) : Bool; function hasAttributes() : Bool; /** @throws DOMError */ function closest( selector : String ) : Element; /** @throws DOMError */ function matches( selector : String ) : Bool; function getElementsByTagName( localName : String ) : HTMLCollection; /** @throws DOMError */ function getElementsByTagNameNS( namespace_ : String, localName : String ) : HTMLCollection; function getElementsByClassName( classNames : String ) : HTMLCollection; /** @throws DOMError */ function setPointerCapture( pointerId : Int ) : Void; /** @throws DOMError */ function releasePointerCapture( pointerId : Int ) : Void; function setCapture( ?retargetToElement : Bool = false ) : Void; function releaseCapture() : Void; function requestPointerLock() : Void; function getAttributeNode( name : String ) : Attr; /** @throws DOMError */ function setAttributeNode( newAttr : Attr ) : Attr; /** @throws DOMError */ function removeAttributeNode( oldAttr : Attr ) : Attr; function getAttributeNodeNS( namespaceURI : String, localName : String ) : Attr; /** @throws DOMError */ function setAttributeNodeNS( newAttr : Attr ) : Attr; function requestFullscreen() : Void; function click() : Void; /** @throws DOMError */ function focus() : Void; /** @throws DOMError */ function blur() : Void; function getClientRects() : DOMRectList; function getBoundingClientRect() : DOMRect; @:overload( function( top : Bool ) : Void {} ) function scrollIntoView( ?options : ScrollIntoViewOptions ) : Void; @:overload( function( x : Float, y : Float ) : Void {} ) function scroll( ?options : ScrollToOptions ) : Void; @:overload( function( x : Float, y : Float ) : Void {} ) function scrollTo( ?options : ScrollToOptions ) : Void; @:overload( function( x : Float, y : Float ) : Void {} ) function scrollBy( ?options : ScrollToOptions ) : Void; /** @throws DOMError */ function insertAdjacentHTML( position : String, text : String ) : Void; /** @throws DOMError */ function querySelector( selectors : String ) : Element; /** @throws DOMError */ function querySelectorAll( selectors : String ) : NodeList; /** @throws DOMError */ function createShadowRoot() : ShadowRoot; function getDestinationInsertionPoints() : NodeList; function getAnimationPlayers() : Array; function remove() : Void; /** @throws DOMError */ function convertQuadFromNode( quad : DOMQuad, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ function convertRectFromNode( rect : DOMRectReadOnly, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ function convertPointFromNode( point : DOMPointInit, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMPoint; }haxe_3.2.1+dfsg.orig/std/js/html/DOMError.hx0000664000175000017500000000262612607337712020476 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMError.webidl line 15:0. Do not edit! package js.html; @:native("DOMError") extern class DOMError { var name(default,null) : String; var message(default,null) : String; /** @throws DOMError */ function new( name : String, ?message : String = "" ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DOMException.hx0000664000175000017500000000551112607337712021337 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMException.webidl line 78:0. Do not edit! package js.html; @:native("DOMException") extern class DOMException { static inline var INDEX_SIZE_ERR : Int = 1; static inline var DOMSTRING_SIZE_ERR : Int = 2; static inline var HIERARCHY_REQUEST_ERR : Int = 3; static inline var WRONG_DOCUMENT_ERR : Int = 4; static inline var INVALID_CHARACTER_ERR : Int = 5; static inline var NO_DATA_ALLOWED_ERR : Int = 6; static inline var NO_MODIFICATION_ALLOWED_ERR : Int = 7; static inline var NOT_FOUND_ERR : Int = 8; static inline var NOT_SUPPORTED_ERR : Int = 9; static inline var INUSE_ATTRIBUTE_ERR : Int = 10; static inline var INVALID_STATE_ERR : Int = 11; static inline var SYNTAX_ERR : Int = 12; static inline var INVALID_MODIFICATION_ERR : Int = 13; static inline var NAMESPACE_ERR : Int = 14; static inline var INVALID_ACCESS_ERR : Int = 15; static inline var VALIDATION_ERR : Int = 16; static inline var TYPE_MISMATCH_ERR : Int = 17; static inline var SECURITY_ERR : Int = 18; static inline var NETWORK_ERR : Int = 19; static inline var ABORT_ERR : Int = 20; static inline var URL_MISMATCH_ERR : Int = 21; static inline var QUOTA_EXCEEDED_ERR : Int = 22; static inline var TIMEOUT_ERR : Int = 23; static inline var INVALID_NODE_TYPE_ERR : Int = 24; static inline var DATA_CLONE_ERR : Int = 25; var code(default,null) : Int; var message(default,null) : String; var result(default,null) : Int; var name(default,null) : String; var filename(default,null) : String; var lineNumber(default,null) : Int; var columnNumber(default,null) : Int; var inner(default,null) : Dynamic/*MISSING nsISupports*/; var data(default,null) : Dynamic/*MISSING nsISupports*/; var stack(default,null) : String; }haxe_3.2.1+dfsg.orig/std/js/html/DOMFormData.hx0000664000175000017500000000240012607337712021070 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use FormData instead. */ @:deprecated("DOMFormData is deprecated, use FormData instead") typedef DOMFormData = FormData; haxe_3.2.1+dfsg.orig/std/js/html/DOMImplementation.hx0000664000175000017500000000327412607337712022372 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMImplementation.webidl line 14:0. Do not edit! package js.html; @:native("DOMImplementation") extern class DOMImplementation { function hasFeature( feature : String, version : String ) : Bool; /** @throws DOMError */ function createDocumentType( qualifiedName : String, publicId : String, systemId : String ) : DocumentType; /** @throws DOMError */ function createDocument( namespace_ : String, qualifiedName : String, ?doctype : DocumentType ) : HTMLDocument; /** @throws DOMError */ function createHTMLDocument( ?title : String ) : HTMLDocument; }haxe_3.2.1+dfsg.orig/std/js/html/DOMMatrix.hx0000664000175000017500000000526012607337712020646 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMMatrix.webidl line 89:0. Do not edit! package js.html; @:native("DOMMatrix") extern class DOMMatrix extends DOMMatrixReadOnly { /** @throws DOMError */ @:overload( function() : Void {} ) @:overload( function( transformList : String ) : Void {} ) @:overload( function( other : DOMMatrixReadOnly ) : Void {} ) @:overload( function( array32 : Float32Array ) : Void {} ) @:overload( function( array64 : Float64Array ) : Void {} ) function new( numberSequence : Array ) : Void; function multiplySelf( other : DOMMatrix ) : DOMMatrix; function preMultiplySelf( other : DOMMatrix ) : DOMMatrix; function translateSelf( tx : Float, ty : Float, ?tz : Float = 0.0 ) : DOMMatrix; function scaleSelf( scale : Float, ?originX : Float = 0.0, ?originY : Float = 0.0 ) : DOMMatrix; function scale3dSelf( scale : Float, ?originX : Float = 0.0, ?originY : Float = 0.0, ?originZ : Float = 0.0 ) : DOMMatrix; function scaleNonUniformSelf( scaleX : Float, ?scaleY : Float = 1.0, ?scaleZ : Float = 1.0, ?originX : Float = 0.0, ?originY : Float = 0.0, ?originZ : Float = 0.0 ) : DOMMatrix; function rotateSelf( angle : Float, ?originX : Float = 0.0, ?originY : Float = 0.0 ) : DOMMatrix; function rotateFromVectorSelf( x : Float, y : Float ) : DOMMatrix; function rotateAxisAngleSelf( x : Float, y : Float, z : Float, angle : Float ) : DOMMatrix; function skewXSelf( sx : Float ) : DOMMatrix; function skewYSelf( sy : Float ) : DOMMatrix; function invertSelf() : DOMMatrix; /** @throws DOMError */ function setMatrixValue( transformList : String ) : DOMMatrix; }haxe_3.2.1+dfsg.orig/std/js/html/DOMMatrixReadOnly.hx0000664000175000017500000000617512607337712022312 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMMatrix.webidl line 14:0. Do not edit! package js.html; @:native("DOMMatrixReadOnly") extern class DOMMatrixReadOnly { var a(default,null) : Float; var b(default,null) : Float; var c(default,null) : Float; var d(default,null) : Float; var e(default,null) : Float; var f(default,null) : Float; var m11(default,null) : Float; var m12(default,null) : Float; var m13(default,null) : Float; var m14(default,null) : Float; var m21(default,null) : Float; var m22(default,null) : Float; var m23(default,null) : Float; var m24(default,null) : Float; var m31(default,null) : Float; var m32(default,null) : Float; var m33(default,null) : Float; var m34(default,null) : Float; var m41(default,null) : Float; var m42(default,null) : Float; var m43(default,null) : Float; var m44(default,null) : Float; var is2D(default,null) : Bool; var identity(default,null) : Bool; function translate( tx : Float, ty : Float, ?tz : Float = 0.0 ) : DOMMatrix; function scale( scale : Float, ?originX : Float = 0.0, ?originY : Float = 0.0 ) : DOMMatrix; function scale3d( scale : Float, ?originX : Float = 0.0, ?originY : Float = 0.0, ?originZ : Float = 0.0 ) : DOMMatrix; function scaleNonUniform( scaleX : Float, ?scaleY : Float = 1.0, ?scaleZ : Float = 1.0, ?originX : Float = 0.0, ?originY : Float = 0.0, ?originZ : Float = 0.0 ) : DOMMatrix; function rotate( angle : Float, ?originX : Float = 0.0, ?originY : Float = 0.0 ) : DOMMatrix; function rotateFromVector( x : Float, y : Float ) : DOMMatrix; function rotateAxisAngle( x : Float, y : Float, z : Float, angle : Float ) : DOMMatrix; function skewX( sx : Float ) : DOMMatrix; function skewY( sy : Float ) : DOMMatrix; function multiply( other : DOMMatrix ) : DOMMatrix; function flipX() : DOMMatrix; function flipY() : DOMMatrix; function inverse() : DOMMatrix; function transformPoint( ?point : DOMPointInit ) : DOMPoint; /** @throws DOMError */ function toFloat32Array() : Float32Array; /** @throws DOMError */ function toFloat64Array() : Float64Array; }haxe_3.2.1+dfsg.orig/std/js/html/DOMMimeType.hx0000664000175000017500000000240012607337712021124 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use MimeType instead. */ @:deprecated("DOMMimeType is deprecated, use MimeType instead") typedef DOMMimeType = MimeType; haxe_3.2.1+dfsg.orig/std/js/html/DOMMimeTypeArray.hx0000664000175000017500000000243112607337712022127 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use MimeTypeArray instead. */ @:deprecated("DOMMimeTypeArray is deprecated, use MimeTypeArray instead") typedef DOMMimeTypeArray = MimeTypeArray; haxe_3.2.1+dfsg.orig/std/js/html/DOMParser.hx0000664000175000017500000000304512607337712020635 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMParser.webidl line 25:0. Do not edit! package js.html; @:native("DOMParser") extern class DOMParser { /** @throws DOMError */ @:overload( function() : Void {} ) function new( prin : Dynamic/*MISSING Principal*/, ?documentURI : Dynamic/*MISSING URI*/, ?baseURI : Dynamic/*MISSING URI*/ ) : Void; /** @throws DOMError */ function parseFromString( str : String, type : SupportedType ) : HTMLDocument; }haxe_3.2.1+dfsg.orig/std/js/html/DOMPlugin.hx0000664000175000017500000000236612607337712020644 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use Plugin instead. */ @:deprecated("DOMPlugin is deprecated, use Plugin instead") typedef DOMPlugin = Plugin; haxe_3.2.1+dfsg.orig/std/js/html/DOMPluginArray.hx0000664000175000017500000000241712607337712021640 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use PluginArray instead. */ @:deprecated("DOMPluginArray is deprecated, use PluginArray instead") typedef DOMPluginArray = PluginArray; haxe_3.2.1+dfsg.orig/std/js/html/DOMPoint.hx0000664000175000017500000000266412607337712020500 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMPoint.webidl line 25:0. Do not edit! package js.html; @:native("DOMPoint") extern class DOMPoint extends DOMPointReadOnly { /** @throws DOMError */ @:overload( function( ?point : DOMPointInit ) : Void {} ) function new( x : Float, y : Float, ?z : Float = 0.0, ?w : Float = 1.0 ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DOMPointInit.hx0000664000175000017500000000251512607337712021317 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMPoint.webidl line 32:0. Do not edit! package js.html; typedef DOMPointInit = { @:optional var w : Float; @:optional var x : Float; @:optional var y : Float; @:optional var z : Float; }haxe_3.2.1+dfsg.orig/std/js/html/DOMPointReadOnly.hx0000664000175000017500000000257712607337712022141 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMPoint.webidl line 14:0. Do not edit! package js.html; @:native("DOMPointReadOnly") extern class DOMPointReadOnly { var x(default,null) : Float; var y(default,null) : Float; var z(default,null) : Float; var w(default,null) : Float; }haxe_3.2.1+dfsg.orig/std/js/html/DOMQuad.hx0000664000175000017500000000314612607337712020275 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMQuad.webidl line 17:0. Do not edit! package js.html; @:native("DOMQuad") extern class DOMQuad { var p1(default,null) : DOMPoint; var p2(default,null) : DOMPoint; var p3(default,null) : DOMPoint; var p4(default,null) : DOMPoint; var bounds(default,null) : DOMRectReadOnly; /** @throws DOMError */ @:overload( function( ?p1 : DOMPointInit, ?p2 : DOMPointInit, ?p3 : DOMPointInit, ?p4 : DOMPointInit ) : Void {} ) function new( rect : DOMRectReadOnly ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DOMRect.hx0000664000175000017500000000262412607337712020300 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMRect.webidl line 16:0. Do not edit! package js.html; @:native("DOMRect") extern class DOMRect extends DOMRectReadOnly { /** @throws DOMError */ @:overload( function() : Void {} ) function new( x : Float, y : Float, width : Float, height : Float ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DOMRectList.hx0000664000175000017500000000255112607337712021133 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMRectList.webidl line 8:0. Do not edit! package js.html; @:native("DOMRectList") extern class DOMRectList implements ArrayAccess { var length(default,null) : Int; function item( index : Int ) : DOMRect; }haxe_3.2.1+dfsg.orig/std/js/html/DOMRectReadOnly.hx0000664000175000017500000000301312607337712021727 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMRect.webidl line 23:0. Do not edit! package js.html; @:native("DOMRectReadOnly") extern class DOMRectReadOnly { var x(default,null) : Float; var y(default,null) : Float; var width(default,null) : Float; var height(default,null) : Float; var top(default,null) : Float; var right(default,null) : Float; var bottom(default,null) : Float; var left(default,null) : Float; }haxe_3.2.1+dfsg.orig/std/js/html/DOMRequest.hx0000664000175000017500000000314712607337712021034 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMRequest.webidl line 19:0. Do not edit! package js.html; @:native("DOMRequest") extern class DOMRequest extends EventTarget { var readyState(default,null) : DOMRequestReadyState; var result(default,null) : Dynamic; var error(default,null) : DOMError; var onsuccess : haxe.Constraints.Function; var onerror : haxe.Constraints.Function; function then( ?fulfillCallback : haxe.Constraints.Function, ?rejectCallback : haxe.Constraints.Function ) : Promise; }haxe_3.2.1+dfsg.orig/std/js/html/DOMRequestReadyState.hx0000664000175000017500000000244612607337712023023 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMRequest.webidl line 6:0. Do not edit! package js.html; @:enum abstract DOMRequestReadyState(String) { var PENDING = "pending"; var DONE = "done"; }haxe_3.2.1+dfsg.orig/std/js/html/DOMSelection.hx0000664000175000017500000000240512607337712021325 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use Selection instead. */ @:deprecated("DOMSelection is deprecated, use Selection instead") typedef DOMSelection = Selection; haxe_3.2.1+dfsg.orig/std/js/html/DOMSettableTokenList.hx0000664000175000017500000000250512607337712023001 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMSettableTokenList.webidl line 13:0. Do not edit! package js.html; @:native("DOMSettableTokenList") extern class DOMSettableTokenList extends DOMTokenList { var value : String; }haxe_3.2.1+dfsg.orig/std/js/html/DOMStringList.hx0000664000175000017500000000263412607337712021506 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMStringList.webidl line 13:0. Do not edit! package js.html; @:native("DOMStringList") extern class DOMStringList implements ArrayAccess { var length(default,null) : Int; function item( index : Int ) : String; function contains( string : String ) : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/DOMStringMap.hx0000664000175000017500000000243412607337712021306 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMStringMap.webidl line 15:0. Do not edit! package js.html; @:native("DOMStringMap") extern class DOMStringMap implements Dynamic { }haxe_3.2.1+dfsg.orig/std/js/html/DOMTokenList.hx0000664000175000017500000000325712607337712021322 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMTokenList.webidl line 13:0. Do not edit! package js.html; @:native("DOMTokenList") extern class DOMTokenList implements ArrayAccess { var length(default,null) : Int; function item( index : Int ) : String; /** @throws DOMError */ function contains( token : String ) : Bool; /** @throws DOMError */ function add( tokens : haxe.extern.Rest ) : Void; /** @throws DOMError */ function remove( tokens : haxe.extern.Rest ) : Void; /** @throws DOMError */ function toggle( token : String, ?force : Bool ) : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/DOMTransaction.hx0000664000175000017500000000273312607337712021671 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMTransaction.webidl line 15:9. Do not edit! package js.html; @:native("DOMTransaction") extern class DOMTransaction { var label(default,null) : String; var executeAutomatic(default,null) : Void -> Void; var execute(default,null) : Void -> Void; var undo(default,null) : Void -> Void; var redo(default,null) : Void -> Void; }haxe_3.2.1+dfsg.orig/std/js/html/DOMTransactionEvent.hx0000664000175000017500000000267212607337712022675 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMTransactionEvent.webidl line 8:0. Do not edit! package js.html; @:native("DOMTransactionEvent") extern class DOMTransactionEvent extends Event { var transactions(default,null) : Dynamic; /** @throws DOMError */ function new( type : String, ?eventInitDict : DOMTransactionEventInit ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DOMTransactionEventInit.hx0000664000175000017500000000245512607337712023520 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMTransactionEvent.webidl line 13:0. Do not edit! package js.html; typedef DOMTransactionEventInit = { > EventInit, @:optional var transactions : Dynamic; }haxe_3.2.1+dfsg.orig/std/js/html/DOMURL.hx0000664000175000017500000000234712607337712020047 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use URL instead. */ @:deprecated("DOMURL is deprecated, use URL instead") typedef DOMURL = URL; haxe_3.2.1+dfsg.orig/std/js/html/DOMWindow.hx0000664000175000017500000000236612607337712020655 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package js.html; /** @deprecated Use Window instead. */ @:deprecated("DOMWindow is deprecated, use Window instead") typedef DOMWindow = Window; haxe_3.2.1+dfsg.orig/std/js/html/DataElement.hx0000664000175000017500000000245512607337712021230 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLDataElement.webidl line 10:0. Do not edit! package js.html; @:native("HTMLDataElement") extern class DataElement extends Element { var value : String; }haxe_3.2.1+dfsg.orig/std/js/html/DataListElement.hx0000664000175000017500000000252112607337712022056 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLDataListElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLDataListElement") extern class DataListElement extends Element { var options(default,null) : HTMLCollection; }haxe_3.2.1+dfsg.orig/std/js/html/DataTransfer.hx0000664000175000017500000000355712607337712021427 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DataTransfer.webidl line 11:0. Do not edit! package js.html; @:native("DataTransfer") extern class DataTransfer { var dropEffect : String; var effectAllowed : String; var types(default,null) : DOMStringList; var files(default,null) : FileList; /** @throws DOMError */ function new( eventType : String, isExternal : Bool ) : Void; /** @throws DOMError */ function setDragImage( image : Element, x : Int, y : Int ) : Void; /** @throws DOMError */ function getData( format : String ) : String; /** @throws DOMError */ function setData( format : String, data : String ) : Void; /** @throws DOMError */ function clearData( ?format : String ) : Void; /** @throws DOMError */ function addElement( element : Element ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DataView.hx0000664000175000017500000000473712607337712020556 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from typedarray.webidl line 217:0. Do not edit! package js.html; @:native("DataView") extern class DataView extends ArrayBufferView { /** @throws DOMError */ function new( buffer : ArrayBuffer, ?byteOffset : Int, ?byteLength : Int ) : Void; function getInt8( byteOffset : Int ) : Int; function getUint8( byteOffset : Int ) : Int; function getInt16( byteOffset : Int, ?littleEndian : Bool ) : Int; function getUint16( byteOffset : Int, ?littleEndian : Bool ) : Int; function getInt32( byteOffset : Int, ?littleEndian : Bool ) : Int; function getUint32( byteOffset : Int, ?littleEndian : Bool ) : Int; function getFloat32( byteOffset : Int, ?littleEndian : Bool ) : Float; function getFloat64( byteOffset : Int, ?littleEndian : Bool ) : Float; function setInt8( byteOffset : Int, value : Int ) : Void; function setUint8( byteOffset : Int, value : Int ) : Void; function setInt16( byteOffset : Int, value : Int, ?littleEndian : Bool ) : Void; function setUint16( byteOffset : Int, value : Int, ?littleEndian : Bool ) : Void; function setInt32( byteOffset : Int, value : Int, ?littleEndian : Bool ) : Void; function setUint32( byteOffset : Int, value : Int, ?littleEndian : Bool ) : Void; function setFloat32( byteOffset : Int, value : Float, ?littleEndian : Bool ) : Void; function setFloat64( byteOffset : Int, value : Float, ?littleEndian : Bool ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DedicatedWorkerGlobalScope.hx0000664000175000017500000000273312607337712024217 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DedicatedWorkerGlobalScope.webidl line 17:0. Do not edit! package js.html; @:native("DedicatedWorkerGlobalScope") extern class DedicatedWorkerGlobalScope extends WorkerGlobalScope { var onmessage : haxe.Constraints.Function; /** @throws DOMError */ function postMessage( message : Dynamic, ?transfer : Array ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DesktopNotification.hx0000664000175000017500000000266212607337712023025 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DesktopNotification.webidl line 18:0. Do not edit! package js.html; @:native("DesktopNotification") extern class DesktopNotification extends EventTarget { var onclick : haxe.Constraints.Function; var onclose : haxe.Constraints.Function; /** @throws DOMError */ function show() : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DesktopNotificationCenter.hx0000664000175000017500000000262612607337712024166 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DesktopNotification.webidl line 10:0. Do not edit! package js.html; @:native("DesktopNotificationCenter") extern class DesktopNotificationCenter { function createNotification( title : String, description : String, ?iconURL : String = "" ) : DesktopNotification; }haxe_3.2.1+dfsg.orig/std/js/html/DeviceAcceleration.hx0000664000175000017500000000255512607337712022557 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DeviceMotionEvent.webidl line 8:0. Do not edit! package js.html; @:native("DeviceAcceleration") extern class DeviceAcceleration { var x(default,null) : Float; var y(default,null) : Float; var z(default,null) : Float; }haxe_3.2.1+dfsg.orig/std/js/html/DeviceAccelerationInit.hx0000664000175000017500000000250512607337712023376 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DeviceMotionEvent.webidl line 29:0. Do not edit! package js.html; typedef DeviceAccelerationInit = { @:optional var x : Float; @:optional var y : Float; @:optional var z : Float; }haxe_3.2.1+dfsg.orig/std/js/html/DeviceMotionEvent.hx0000664000175000017500000000355512607337712022436 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DeviceMotionEvent.webidl line 22:0. Do not edit! package js.html; @:native("DeviceMotionEvent") extern class DeviceMotionEvent extends Event { var acceleration(default,null) : DeviceAcceleration; var accelerationIncludingGravity(default,null) : DeviceAcceleration; var rotationRate(default,null) : DeviceRotationRate; var interval(default,null) : Float; /** @throws DOMError */ function new( type : String, ?eventInitDict : DeviceMotionEventInit ) : Void; /** @throws DOMError */ function initDeviceMotionEvent( type : String, canBubble : Bool, cancelable : Bool, acceleration : DeviceAccelerationInit, accelerationIncludingGravity : DeviceAccelerationInit, rotationRate : DeviceRotationRateInit, interval : Float ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DeviceMotionEventInit.hx0000664000175000017500000000273012607337712023254 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DeviceMotionEvent.webidl line 41:0. Do not edit! package js.html; typedef DeviceMotionEventInit = { > EventInit, @:optional var acceleration : DeviceAccelerationInit; @:optional var accelerationIncludingGravity : DeviceAccelerationInit; @:optional var interval : Float; @:optional var rotationRate : DeviceRotationRateInit; }haxe_3.2.1+dfsg.orig/std/js/html/DeviceOrientationEvent.hx0000664000175000017500000000333512607337712023460 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DeviceOrientationEvent.webidl line 8:0. Do not edit! package js.html; @:native("DeviceOrientationEvent") extern class DeviceOrientationEvent extends Event { var alpha(default,null) : Float; var beta(default,null) : Float; var gamma(default,null) : Float; var absolute(default,null) : Bool; /** @throws DOMError */ function new( type : String, ?eventInitDict : DeviceOrientationEventInit ) : Void; /** @throws DOMError */ function initDeviceOrientationEvent( type : String, canBubble : Bool, cancelable : Bool, alpha : Float, beta : Float, gamma : Float, absolute : Bool ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DeviceOrientationEventInit.hx0000664000175000017500000000261012607337712024277 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DeviceOrientationEvent.webidl line 26:0. Do not edit! package js.html; typedef DeviceOrientationEventInit = { > EventInit, @:optional var absolute : Bool; @:optional var alpha : Float; @:optional var beta : Float; @:optional var gamma : Float; }haxe_3.2.1+dfsg.orig/std/js/html/DeviceRotationRate.hx0000664000175000017500000000257112607337712022577 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DeviceMotionEvent.webidl line 15:0. Do not edit! package js.html; @:native("DeviceRotationRate") extern class DeviceRotationRate { var alpha(default,null) : Float; var beta(default,null) : Float; var gamma(default,null) : Float; }haxe_3.2.1+dfsg.orig/std/js/html/DeviceRotationRateInit.hx0000664000175000017500000000252012607337712023415 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DeviceMotionEvent.webidl line 35:0. Do not edit! package js.html; typedef DeviceRotationRateInit = { @:optional var alpha : Float; @:optional var beta : Float; @:optional var gamma : Float; }haxe_3.2.1+dfsg.orig/std/js/html/DirectionSetting.hx0000664000175000017500000000244112607337712022316 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/VTTCue.webidl line 20:0. Do not edit! package js.html; @:enum abstract DirectionSetting(String) { var NONE = ""; var RL = "rl"; var LR = "lr"; }haxe_3.2.1+dfsg.orig/std/js/html/Directory.hx0000664000175000017500000000335412607337712021010 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Directory.webidl line 16:0. Do not edit! package js.html; @:native("Directory") extern class Directory { var name(default,null) : String; function createFile( path : String, ?options : CreateFileOptions ) : Promise; function createDirectory( path : String ) : Promise; function get( path : String ) : Promise>; function remove( path : haxe.extern.EitherType> ) : Promise; function removeDeep( path : haxe.extern.EitherType> ) : Promise; }haxe_3.2.1+dfsg.orig/std/js/html/DirectoryElement.hx0000664000175000017500000000247412607337712022324 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLDirectoryElement.webidl line 15:0. Do not edit! package js.html; @:native("HTMLDirectoryElement") extern class DirectoryElement extends Element { var compact : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/DivElement.hx0000664000175000017500000000245212607337712021076 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLDivElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLDivElement") extern class DivElement extends Element { var align : String; }haxe_3.2.1+dfsg.orig/std/js/html/Document.hx0000664000175000017500000002406512607337712020624 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Document.webidl line 18:0. Do not edit! package js.html; @:native("Document") extern class Document extends Node { var implementation(default,null) : DOMImplementation; var URL(default,null) : String; var documentURI(default,null) : String; var compatMode(default,null) : String; var characterSet(default,null) : String; var contentType(default,null) : String; var doctype(default,null) : DocumentType; var documentElement(default,null) : Element; var inputEncoding(default,null) : String; var fullscreenEnabled(default,null) : Bool; var fullscreenElement(default,null) : Element; var onfullscreenchange : haxe.Constraints.Function; var onfullscreenerror : haxe.Constraints.Function; var location(default,null) : Location; var referrer(default,null) : String; var lastModified(default,null) : String; var readyState(default,null) : String; var title : String; var dir : String; var defaultView(default,null) : Window; var activeElement(default,null) : Element; var onreadystatechange : haxe.Constraints.Function; var onwheel : haxe.Constraints.Function; var oncopy : haxe.Constraints.Function; var oncut : haxe.Constraints.Function; var onpaste : haxe.Constraints.Function; var onbeforescriptexecute : haxe.Constraints.Function; var onafterscriptexecute : haxe.Constraints.Function; var currentScript(default,null) : Element; var pointerLockElement(default,null) : Element; var hidden(default,null) : Bool; var visibilityState(default,null) : VisibilityState; var styleSheets(default,null) : StyleSheetList; var selectedStyleSheetSet : String; var lastStyleSheetSet(default,null) : String; var preferredStyleSheetSet(default,null) : String; var styleSheetSets(default,null) : DOMStringList; var timeline(default,null) : AnimationTimeline; var fonts(default,null) : FontFaceSet; var onabort : haxe.Constraints.Function; var onblur : haxe.Constraints.Function; var onfocus : haxe.Constraints.Function; var oncanplay : haxe.Constraints.Function; var oncanplaythrough : haxe.Constraints.Function; var onchange : haxe.Constraints.Function; var onclick : haxe.Constraints.Function; var oncontextmenu : haxe.Constraints.Function; var ondblclick : haxe.Constraints.Function; var ondrag : haxe.Constraints.Function; var ondragend : haxe.Constraints.Function; var ondragenter : haxe.Constraints.Function; var ondragleave : haxe.Constraints.Function; var ondragover : haxe.Constraints.Function; var ondragstart : haxe.Constraints.Function; var ondrop : haxe.Constraints.Function; var ondurationchange : haxe.Constraints.Function; var onemptied : haxe.Constraints.Function; var onended : haxe.Constraints.Function; var oninput : haxe.Constraints.Function; var oninvalid : haxe.Constraints.Function; var onkeydown : haxe.Constraints.Function; var onkeypress : haxe.Constraints.Function; var onkeyup : haxe.Constraints.Function; var onload : haxe.Constraints.Function; var onloadeddata : haxe.Constraints.Function; var onloadedmetadata : haxe.Constraints.Function; var onloadstart : haxe.Constraints.Function; var onmousedown : haxe.Constraints.Function; var onmouseenter : haxe.Constraints.Function; var onmouseleave : haxe.Constraints.Function; var onmousemove : haxe.Constraints.Function; var onmouseout : haxe.Constraints.Function; var onmouseover : haxe.Constraints.Function; var onmouseup : haxe.Constraints.Function; var onpause : haxe.Constraints.Function; var onplay : haxe.Constraints.Function; var onplaying : haxe.Constraints.Function; var onprogress : haxe.Constraints.Function; var onratechange : haxe.Constraints.Function; var onreset : haxe.Constraints.Function; var onscroll : haxe.Constraints.Function; var onseeked : haxe.Constraints.Function; var onseeking : haxe.Constraints.Function; var onselect : haxe.Constraints.Function; var onshow : haxe.Constraints.Function; var onstalled : haxe.Constraints.Function; var onsubmit : haxe.Constraints.Function; var onsuspend : haxe.Constraints.Function; var ontimeupdate : haxe.Constraints.Function; var onvolumechange : haxe.Constraints.Function; var onwaiting : haxe.Constraints.Function; var onpointercancel : haxe.Constraints.Function; var onpointerdown : haxe.Constraints.Function; var onpointerup : haxe.Constraints.Function; var onpointermove : haxe.Constraints.Function; var onpointerout : haxe.Constraints.Function; var onpointerover : haxe.Constraints.Function; var onpointerenter : haxe.Constraints.Function; var onpointerleave : haxe.Constraints.Function; var ongotpointercapture : haxe.Constraints.Function; var onlostpointercapture : haxe.Constraints.Function; var onpointerlockchange : haxe.Constraints.Function; var onpointerlockerror : haxe.Constraints.Function; var onerror : haxe.Constraints.Function; var children(default,null) : HTMLCollection; var firstElementChild(default,null) : Element; var lastElementChild(default,null) : Element; var childElementCount(default,null) : Int; var ontouchstart : haxe.Constraints.Function; var ontouchend : haxe.Constraints.Function; var ontouchmove : haxe.Constraints.Function; var ontouchcancel : haxe.Constraints.Function; /** @throws DOMError */ function new() : Void; function getElementsByTagName( localName : String ) : HTMLCollection; /** @throws DOMError */ function getElementsByTagNameNS( namespace_ : String, localName : String ) : HTMLCollection; function getElementsByClassName( classNames : String ) : HTMLCollection; function getElementById( elementId : String ) : Element; /** @throws DOMError */ @:overload( function( localName : String ) : Element {} ) function createElement( localName : String, typeExtension : String ) : Element; /** @throws DOMError */ @:overload( function( namespace_ : String, qualifiedName : String ) : Element {} ) function createElementNS( namespace_ : String, qualifiedName : String, typeExtension : String ) : Element; function createDocumentFragment() : DocumentFragment; function createTextNode( data : String ) : Text; function createComment( data : String ) : Comment; /** @throws DOMError */ function createProcessingInstruction( target : String, data : String ) : ProcessingInstruction; /** @throws DOMError */ function importNode( node : Node, ?deep : Bool = false ) : Node; /** @throws DOMError */ function adoptNode( node : Node ) : Node; /** @throws DOMError */ function createEvent( interface_ : String ) : Event; /** @throws DOMError */ function createRange() : Range; /** @throws DOMError */ function createNodeIterator( root : Node, ?whatToShow : Int = cast 4294967295, ?filter : NodeFilter ) : NodeIterator; /** @throws DOMError */ function createTreeWalker( root : Node, ?whatToShow : Int = cast 4294967295, ?filter : NodeFilter ) : TreeWalker; /** @throws DOMError */ function createCDATASection( data : String ) : CDATASection; /** @throws DOMError */ function createAttribute( name : String ) : Attr; /** @throws DOMError */ function createAttributeNS( namespace_ : String, name : String ) : Attr; function exitFullscreen() : Void; /** @throws DOMError */ function hasFocus() : Bool; function releaseCapture() : Void; function exitPointerLock() : Void; /** @throws DOMError */ function registerElement( name : String, ?options : ElementRegistrationOptions ) : Dynamic; function enableStyleSheetsForSet( name : String ) : Void; function elementFromPoint( x : Float, y : Float ) : Element; function caretPositionFromPoint( x : Float, y : Float ) : CaretPosition; /** @throws DOMError */ function querySelector( selectors : String ) : Element; /** @throws DOMError */ function querySelectorAll( selectors : String ) : NodeList; function createTouch( ?view : Window, ?target : EventTarget, ?identifier : Int = 0, ?pageX : Int = 0, ?pageY : Int = 0, ?screenX : Int = 0, ?screenY : Int = 0, ?clientX : Int = 0, ?clientY : Int = 0, ?radiusX : Int = 0, ?radiusY : Int = 0, ?rotationAngle : Float = 0.0, ?force : Float = 0.0 ) : Touch; @:overload( function( touch : Touch, touches : haxe.extern.Rest ) : TouchList {} ) @:overload( function() : TouchList {} ) function createTouchList( touches : Array ) : TouchList; /** @throws DOMError */ function convertQuadFromNode( quad : DOMQuad, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ function convertRectFromNode( rect : DOMRectReadOnly, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMQuad; /** @throws DOMError */ function convertPointFromNode( point : DOMPointInit, from : haxe.extern.EitherType>, ?options : ConvertCoordinateOptions ) : DOMPoint; /** @throws DOMError */ function createExpression( expression : String, resolver : XPathNSResolver ) : XPathExpression; function createNSResolver( nodeResolver : Node ) : Node; /** @throws DOMError */ function evaluate( expression : String, contextNode : Node, resolver : XPathNSResolver, type : Int, result : Dynamic ) : XPathResult; }haxe_3.2.1+dfsg.orig/std/js/html/DocumentFragment.hx0000664000175000017500000000335012607337712022302 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DocumentFragment.webidl line 15:0. Do not edit! package js.html; @:native("DocumentFragment") extern class DocumentFragment extends Node { var children(default,null) : HTMLCollection; var firstElementChild(default,null) : Element; var lastElementChild(default,null) : Element; var childElementCount(default,null) : Int; /** @throws DOMError */ function new() : Void; function getElementById( elementId : String ) : Element; /** @throws DOMError */ function querySelector( selectors : String ) : Element; /** @throws DOMError */ function querySelectorAll( selectors : String ) : NodeList; }haxe_3.2.1+dfsg.orig/std/js/html/DocumentType.hx0000664000175000017500000000270512607337712021463 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DocumentType.webidl line 13:0. Do not edit! package js.html; @:native("DocumentType") extern class DocumentType extends Node { var name(default,null) : String; var publicId(default,null) : String; var systemId(default,null) : String; var internalSubset(default,null) : String; function remove() : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DragEvent.hx0000664000175000017500000000323112607337712020715 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DragEvent.webidl line 7:0. Do not edit! package js.html; @:native("DragEvent") extern class DragEvent extends MouseEvent { var dataTransfer(default,null) : DataTransfer; /** @throws DOMError */ function initDragEvent( type : String, canBubble : Bool, cancelable : Bool, aView : Window, aDetail : Int, aScreenX : Int, aScreenY : Int, aClientX : Int, aClientY : Int, aCtrlKey : Bool, aAltKey : Bool, aShiftKey : Bool, aMetaKey : Bool, aButton : Int, aRelatedTarget : EventTarget, aDataTransfer : DataTransfer ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DummyInterface.hx0000664000175000017500000000250712607337712021757 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DummyBinding.webidl line 10:0. Do not edit! package js.html; @:native("DummyInterface") extern class DummyInterface { function lifecycleCallbacks( ?arg : LifecycleCallbacks ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/DummyInterfaceWorkers.hx0000664000175000017500000000242312607337712023331 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DummyBinding.webidl line 14:0. Do not edit! package js.html; @:native("DummyInterfaceWorkers") extern class DummyInterfaceWorkers { }haxe_3.2.1+dfsg.orig/std/js/html/Element.hx0000664000175000017500000000241512607337712020432 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLElement.webidl line 15:0. Do not edit! package js.html; @:native("HTMLElement") extern class Element extends DOMElement { }haxe_3.2.1+dfsg.orig/std/js/html/ElementRegistrationOptions.hx0000664000175000017500000000252112607337712024377 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/WebComponents.webidl line 25:0. Do not edit! package js.html; typedef ElementRegistrationOptions = { @:native("extends") @:optional var extends_ : String; @:optional var prototype : Dynamic; }haxe_3.2.1+dfsg.orig/std/js/html/EmbedElement.hx0000664000175000017500000000270112607337712021365 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLEmbedElement.webidl line 17:0. Do not edit! package js.html; @:native("HTMLEmbedElement") extern class EmbedElement extends Element { var src : String; var type : String; var width : String; var height : String; var align : String; var name : String; function getSVGDocument() : HTMLDocument; }haxe_3.2.1+dfsg.orig/std/js/html/ErrorEvent.hx0000664000175000017500000000303312607337712021131 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/ErrorEvent.webidl line 8:0. Do not edit! package js.html; @:native("ErrorEvent") extern class ErrorEvent extends Event { var message(default,null) : String; var filename(default,null) : String; var lineno(default,null) : Int; var colno(default,null) : Int; var error(default,null) : Dynamic; /** @throws DOMError */ function new( type : String, ?eventInitDict : ErrorEventInit ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/ErrorEventInit.hx0000664000175000017500000000262412607337712021762 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/ErrorEvent.webidl line 17:0. Do not edit! package js.html; typedef ErrorEventInit = { > EventInit, @:optional var colno : Int; @:optional var error : Dynamic; @:optional var filename : String; @:optional var lineno : Int; @:optional var message : String; }haxe_3.2.1+dfsg.orig/std/js/html/Event.hx0000664000175000017500000000454212607337712020125 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Event.webidl line 15:0. Do not edit! package js.html; @:native("Event") extern class Event { static inline var NONE : Int = 0; static inline var CAPTURING_PHASE : Int = 1; static inline var AT_TARGET : Int = 2; static inline var BUBBLING_PHASE : Int = 3; static inline var ALT_MASK : Int = 1; static inline var CONTROL_MASK : Int = 2; static inline var SHIFT_MASK : Int = 4; static inline var META_MASK : Int = 8; var type(default,null) : String; var target(default,null) : EventTarget; var currentTarget(default,null) : EventTarget; var eventPhase(default,null) : Int; var bubbles(default,null) : Bool; var cancelable(default,null) : Bool; var defaultPrevented(default,null) : Bool; var isTrusted(default,null) : Bool; var timeStamp(default,null) : Float; var originalTarget(default,null) : EventTarget; var explicitOriginalTarget(default,null) : EventTarget; /** @throws DOMError */ function new( type : String, ?eventInitDict : EventInit ) : Void; function stopPropagation() : Void; function stopImmediatePropagation() : Void; function preventDefault() : Void; /** @throws DOMError */ function initEvent( type : String, bubbles : Bool, cancelable : Bool ) : Void; function getPreventDefault() : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/EventInit.hx0000664000175000017500000000243612607337712020751 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Event.webidl line 65:0. Do not edit! package js.html; typedef EventInit = { @:optional var bubbles : Bool; @:optional var cancelable : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/EventListener.hx0000664000175000017500000000244412607337712021632 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from events.webidl line 14:0. Do not edit! package js.html; @:native("EventListener") extern class EventListener { function handleEvent( event : Event ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/EventSource.hx0000664000175000017500000000337012607337712021304 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/EventSource.webidl line 16:0. Do not edit! package js.html; @:native("EventSource") extern class EventSource extends EventTarget { static inline var CONNECTING : Int = 0; static inline var OPEN : Int = 1; static inline var CLOSED : Int = 2; var url(default,null) : String; var withCredentials(default,null) : Bool; var readyState(default,null) : Int; var onopen : haxe.Constraints.Function; var onmessage : haxe.Constraints.Function; var onerror : haxe.Constraints.Function; /** @throws DOMError */ function new( url : String, ?eventSourceInitDict : EventSourceInit ) : Void; function close() : Void; }haxe_3.2.1+dfsg.orig/std/js/html/EventSourceInit.hx0000664000175000017500000000241712607337712022131 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/EventSource.webidl line 35:0. Do not edit! package js.html; typedef EventSourceInit = { @:optional var withCredentials : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/EventTarget.hx0000664000175000017500000000350712607337712021274 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/EventTarget.webidl line 14:0. Do not edit! package js.html; @:native("EventTarget") extern class EventTarget { /** @throws DOMError */ @:overload( function( type : String, listener : EventListener, ?capture : Bool = false, ?wantsUntrusted : Bool ) : Void {} ) function addEventListener( type : String, listener : haxe.Constraints.Function, ?capture : Bool = false ) : Void; /** @throws DOMError */ @:overload( function( type : String, listener : EventListener, ?capture : Bool = false ) : Void {} ) function removeEventListener( type : String, listener : haxe.Constraints.Function, ?capture : Bool = false ) : Void; /** @throws DOMError */ function dispatchEvent( event : Event ) : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/Exception.hx0000664000175000017500000000315712607337712021003 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/DOMException.webidl line 67:0. Do not edit! package js.html; @:native("Exception") extern class Exception { var message(default,null) : String; var result(default,null) : Int; var name(default,null) : String; var filename(default,null) : String; var lineNumber(default,null) : Int; var columnNumber(default,null) : Int; var inner(default,null) : Dynamic/*MISSING nsISupports*/; var data(default,null) : Dynamic/*MISSING nsISupports*/; var stack(default,null) : String; }haxe_3.2.1+dfsg.orig/std/js/html/External.hx0000664000175000017500000000276512607337712020633 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/External.webidl line 8:0. Do not edit! package js.html; @:native("External") extern class External { function AddSearchProvider( aDescriptionURL : String ) : Void; function IsSearchProviderInstalled( aSearchURL : String ) : Int; function addSearchEngine( engineURL : String, iconURL : String, suggestedTitle : String, suggestedCategory : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/FieldSetElement.hx0000664000175000017500000000324112607337712022050 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLFieldSetElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLFieldSetElement") extern class FieldSetElement extends Element { var disabled : Bool; var form(default,null) : FormElement; var name : String; var type(default,null) : String; var elements(default,null) : HTMLCollection; var willValidate(default,null) : Bool; var validity(default,null) : ValidityState; var validationMessage(default,null) : String; function checkValidity() : Bool; function setCustomValidity( error : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/File.hx0000664000175000017500000000355512607337712017726 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/File.webidl line 18:0. Do not edit! package js.html; @:native("File") extern class File extends Blob { var name(default,null) : String; var lastModified(default,null) : Int; var lastModifiedDate(default,null) : Date; /** @throws DOMError */ @:overload( function( fileBits : Array>>>, fileName : String, ?options : FilePropertyBag ) : Void {} ) @:overload( function( fileBits : Blob, ?options : ChromeFilePropertyBag ) : Void {} ) @:overload( function( fileBits : Dynamic/*MISSING nsIFile*/, ?options : ChromeFilePropertyBag ) : Void {} ) function new( fileBits : String, ?options : ChromeFilePropertyBag ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/FileList.hx0000664000175000017500000000253312607337712020555 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FileList.webidl line 13:0. Do not edit! package js.html; @:native("FileList") extern class FileList implements ArrayAccess { var length(default,null) : Int; function item( index : Int ) : File; }haxe_3.2.1+dfsg.orig/std/js/html/FileMode.hx0000664000175000017500000000244412607337712020527 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FileMode.webidl line 5:0. Do not edit! package js.html; @:enum abstract FileMode(String) { var READONLY = "readonly"; var READWRITE = "readwrite"; }haxe_3.2.1+dfsg.orig/std/js/html/FilePropertyBag.hx0000664000175000017500000000244312607337712022100 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/File.webidl line 28:0. Do not edit! package js.html; typedef FilePropertyBag = { @:optional var lastModified : Int; @:optional var type : String; }haxe_3.2.1+dfsg.orig/std/js/html/FileReader.hx0000664000175000017500000000422712607337712021046 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FileReader.webidl line 14:0. Do not edit! package js.html; @:native("FileReader") extern class FileReader extends EventTarget { static inline var EMPTY : Int = 0; static inline var LOADING : Int = 1; static inline var DONE : Int = 2; var readyState(default,null) : Int; var result(default,null) : Dynamic; var error(default,null) : DOMError; var onloadstart : haxe.Constraints.Function; var onprogress : haxe.Constraints.Function; var onload : haxe.Constraints.Function; var onabort : haxe.Constraints.Function; var onerror : haxe.Constraints.Function; var onloadend : haxe.Constraints.Function; /** @throws DOMError */ function new() : Void; /** @throws DOMError */ function readAsArrayBuffer( blob : Blob ) : Void; /** @throws DOMError */ function readAsText( blob : Blob, ?label : String = "" ) : Void; /** @throws DOMError */ function readAsDataURL( blob : Blob ) : Void; /** @throws DOMError */ function abort() : Void; /** @throws DOMError */ function readAsBinaryString( filedata : Blob ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/FileReaderSync.hx0000664000175000017500000000317712607337712021706 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FileReaderSync.webidl line 15:0. Do not edit! package js.html; @:native("FileReaderSync") extern class FileReaderSync { /** @throws DOMError */ function new() : Void; /** @throws DOMError */ function readAsArrayBuffer( blob : Blob ) : ArrayBuffer; /** @throws DOMError */ function readAsBinaryString( blob : Blob ) : String; /** @throws DOMError */ function readAsText( blob : Blob, ?encoding : String ) : String; /** @throws DOMError */ function readAsDataURL( blob : Blob ) : String; }haxe_3.2.1+dfsg.orig/std/js/html/Float32Array.hx0000664000175000017500000000367312607337712021261 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from typedarray.webidl line 179:0. Do not edit! package js.html; @:native("Float32Array") extern class Float32Array extends ArrayBufferView implements ArrayAccess { static inline var BYTES_PER_ELEMENT : Int = 4; var length(default,null) : Int; /** @throws DOMError */ @:overload( function( length : Int ) : Void {} ) @:overload( function( array : Float32Array ) : Void {} ) @:overload( function( array : Array ) : Void {} ) function new( buffer : ArrayBuffer, ?byteOffset : Int, ?length : Int ) : Void; function get( index : Int ) : Float; @:overload( function( index : Int, value : Float ) : Void {} ) @:overload( function( array : Float32Array, ?offset : Int ) : Void {} ) function set( array : Array, ?offset : Int ) : Void; function subarray( start : Int, end : Int ) : Float32Array; }haxe_3.2.1+dfsg.orig/std/js/html/Float64Array.hx0000664000175000017500000000367312607337712021266 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from typedarray.webidl line 199:0. Do not edit! package js.html; @:native("Float64Array") extern class Float64Array extends ArrayBufferView implements ArrayAccess { static inline var BYTES_PER_ELEMENT : Int = 8; var length(default,null) : Int; /** @throws DOMError */ @:overload( function( length : Int ) : Void {} ) @:overload( function( array : Float64Array ) : Void {} ) @:overload( function( array : Array ) : Void {} ) function new( buffer : ArrayBuffer, ?byteOffset : Int, ?length : Int ) : Void; function get( index : Int ) : Float; @:overload( function( index : Int, value : Float ) : Void {} ) @:overload( function( array : Float64Array, ?offset : Int ) : Void {} ) function set( array : Array, ?offset : Int ) : Void; function subarray( start : Int, end : Int ) : Float64Array; }haxe_3.2.1+dfsg.orig/std/js/html/FocusEvent.hx0000664000175000017500000000264612607337712021130 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FocusEvent.webidl line 14:0. Do not edit! package js.html; @:native("FocusEvent") extern class FocusEvent extends UIEvent { var relatedTarget(default,null) : EventTarget; /** @throws DOMError */ function new( typeArg : String, ?focusEventInitDict : FocusEventInit ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/FocusEventInit.hx0000664000175000017500000000244212607337712021746 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FocusEvent.webidl line 19:0. Do not edit! package js.html; typedef FocusEventInit = { > UIEventInit, @:optional var relatedTarget : EventTarget; }haxe_3.2.1+dfsg.orig/std/js/html/FontElement.hx0000664000175000017500000000252512607337712021263 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLFontElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLFontElement") extern class FontElement extends Element { var color : String; var face : String; var size : String; }haxe_3.2.1+dfsg.orig/std/js/html/FontFace.hx0000664000175000017500000000340212607337712020523 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FontFace.webidl line 32:0. Do not edit! package js.html; @:native("FontFace") extern class FontFace { var family : String; var style : String; var weight : String; var stretch : String; var unicodeRange : String; var variant : String; var featureSettings : String; var status(default,null) : FontFaceLoadStatus; var loaded(default,null) : Promise; /** @throws DOMError */ function new( family : String, source : haxe.extern.EitherType>, ?descriptors : FontFaceDescriptors ) : Void; /** @throws DOMError */ function load() : Promise; }haxe_3.2.1+dfsg.orig/std/js/html/FontFaceDescriptors.hx0000664000175000017500000000267612607337712022761 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FontFace.webidl line 15:0. Do not edit! package js.html; typedef FontFaceDescriptors = { @:optional var featureSettings : String; @:optional var stretch : String; @:optional var style : String; @:optional var unicodeRange : String; @:optional var variant : String; @:optional var weight : String; }haxe_3.2.1+dfsg.orig/std/js/html/FontFaceLoadStatus.hx0000664000175000017500000000253112607337712022531 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FontFace.webidl line 24:0. Do not edit! package js.html; @:enum abstract FontFaceLoadStatus(String) { var UNLOADED = "unloaded"; var LOADING = "loading"; var LOADED = "loaded"; var ERROR = "error"; }haxe_3.2.1+dfsg.orig/std/js/html/FontFaceSet.hx0000664000175000017500000000361212607337712021202 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FontFaceSet.webidl line 18:0. Do not edit! package js.html; @:native("FontFaceSet") extern class FontFaceSet extends EventTarget implements ArrayAccess { var onloading : haxe.Constraints.Function; var onloadingdone : haxe.Constraints.Function; var onloadingerror : haxe.Constraints.Function; var ready(default,null) : Promise; var status(default,null) : FontFaceSetLoadStatus; var length(default,null) : Int; /** @throws DOMError */ function add( font : FontFace ) : Void; function has( font : FontFace ) : Bool; /** @throws DOMError */ @:native("delete") function delete_( font : FontFace ) : Bool; function clear() : Void; /** @throws DOMError */ function load( font : String, ?text : String = " " ) : Promise>; }haxe_3.2.1+dfsg.orig/std/js/html/FontFaceSetLoadStatus.hx0000664000175000017500000000245512607337712023212 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FontFaceSet.webidl line 13:0. Do not edit! package js.html; @:enum abstract FontFaceSetLoadStatus(String) { var LOADING = "loading"; var LOADED = "loaded"; }haxe_3.2.1+dfsg.orig/std/js/html/FormData.hx0000664000175000017500000000271212607337712020536 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/FormData.webidl line 11:0. Do not edit! package js.html; @:native("FormData") extern class FormData { /** @throws DOMError */ function new( ?form : FormElement ) : Void; @:overload( function( name : String, value : Blob, ?filename : String ) : Void {} ) function append( name : String, value : String ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/FormElement.hx0000664000175000017500000000331512607337712021256 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLFormElement.webidl line 15:0. Do not edit! package js.html; @:native("HTMLFormElement") extern class FormElement extends Element implements ArrayAccess { var acceptCharset : String; var action : String; var autocomplete : String; var enctype : String; var encoding : String; var method : String; var name : String; var noValidate : Bool; var target : String; var elements(default,null) : HTMLCollection; var length(default,null) : Int; /** @throws DOMError */ function submit() : Void; function reset() : Void; function checkValidity() : Bool; }haxe_3.2.1+dfsg.orig/std/js/html/FrameElement.hx0000664000175000017500000000307112607337712021404 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLFrameElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLFrameElement") extern class FrameElement extends Element { var name : String; var scrolling : String; var src : String; var frameBorder : String; var longDesc : String; var noResize : Bool; var contentDocument(default,null) : HTMLDocument; var contentWindow(default,null) : Window; var marginHeight : String; var marginWidth : String; }haxe_3.2.1+dfsg.orig/std/js/html/FrameSetElement.hx0000664000175000017500000000362412607337712022064 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLFrameSetElement.webidl line 14:0. Do not edit! package js.html; @:native("HTMLFrameSetElement") extern class FrameSetElement extends Element { var cols : String; var rows : String; var onafterprint : haxe.Constraints.Function; var onbeforeprint : haxe.Constraints.Function; var onbeforeunload : Event -> String; var onhashchange : haxe.Constraints.Function; var onlanguagechange : haxe.Constraints.Function; var onmessage : haxe.Constraints.Function; var onoffline : haxe.Constraints.Function; var ononline : haxe.Constraints.Function; var onpagehide : haxe.Constraints.Function; var onpageshow : haxe.Constraints.Function; var onpopstate : haxe.Constraints.Function; var onresize : haxe.Constraints.Function; var onunload : haxe.Constraints.Function; }haxe_3.2.1+dfsg.orig/std/js/html/Gamepad.hx0000664000175000017500000000301312607337712020372 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Gamepad.webidl line 18:0. Do not edit! package js.html; @:native("Gamepad") extern class Gamepad { var id(default,null) : String; var index(default,null) : Int; var mapping(default,null) : GamepadMappingType; var connected(default,null) : Bool; var buttons(default,null) : Array; var axes(default,null) : Array; var timestamp(default,null) : Float; }haxe_3.2.1+dfsg.orig/std/js/html/GamepadButton.hx0000664000175000017500000000250412607337712021572 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Gamepad.webidl line 7:0. Do not edit! package js.html; @:native("GamepadButton") extern class GamepadButton { var pressed(default,null) : Bool; var value(default,null) : Float; }haxe_3.2.1+dfsg.orig/std/js/html/GamepadMappingType.hx0000664000175000017500000000244012607337712022553 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Gamepad.webidl line 12:0. Do not edit! package js.html; @:enum abstract GamepadMappingType(String) { var NONE = ""; var STANDARD = "standard"; }haxe_3.2.1+dfsg.orig/std/js/html/Geolocation.hx0000664000175000017500000000316612607337712021310 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Geolocation.webidl line 20:0. Do not edit! package js.html; @:native("Geolocation") extern class Geolocation { /** @throws DOMError */ function getCurrentPosition( successCallback : Position -> Void, ?errorCallback : PositionError -> Void, ?options : PositionOptions ) : Void; /** @throws DOMError */ function watchPosition( successCallback : Position -> Void, ?errorCallback : PositionError -> Void, ?options : PositionOptions ) : Int; function clearWatch( watchId : Int ) : Void; }haxe_3.2.1+dfsg.orig/std/js/html/GetNotificationOptions.hx0000664000175000017500000000241512607337712023503 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/Notification.webidl line 68:0. Do not edit! package js.html; typedef GetNotificationOptions = { @:optional var tag : String; }haxe_3.2.1+dfsg.orig/std/js/html/GetUserMediaRequest.hx0000664000175000017500000000274012607337712022731 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/GetUserMediaRequest.webidl line 10:0. Do not edit! package js.html; @:native("GetUserMediaRequest") extern class GetUserMediaRequest { var windowID(default,null) : Int; var innerWindowID(default,null) : Int; var callID(default,null) : String; var isSecure(default,null) : Bool; function getConstraints() : MediaStreamConstraints; }haxe_3.2.1+dfsg.orig/std/js/html/HRElement.hx0000664000175000017500000000257212607337712020670 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLHRElement.webidl line 15:0. Do not edit! package js.html; @:native("HTMLHRElement") extern class HRElement extends Element { var align : String; var color : String; var noShade : Bool; var size : String; var width : String; }haxe_3.2.1+dfsg.orig/std/js/html/HTMLAllCollection.hx0000664000175000017500000000304312607337712022250 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLAllCollection.webidl line 6:0. Do not edit! package js.html; @:native("HTMLAllCollection") extern class HTMLAllCollection implements ArrayAccess { var length(default,null) : Int; @:overload( function( index : Int ) : Node {} ) function item( name : String ) : haxe.extern.EitherType; function namedItem( name : String ) : haxe.extern.EitherType; }haxe_3.2.1+dfsg.orig/std/js/html/HTMLCollection.hx0000664000175000017500000000264312607337712021624 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLCollection.webidl line 13:0. Do not edit! package js.html; @:native("HTMLCollection") extern class HTMLCollection implements ArrayAccess { var length(default,null) : Int; function item( index : Int ) : Element; function namedItem( name : String ) : Element; }haxe_3.2.1+dfsg.orig/std/js/html/HTMLDocument.hx0000664000175000017500000003074412607337712021312 0ustar andyandy00000000000000/* * Copyright (C)2005-2015 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ // This file is generated from mozilla/HTMLDocument.webidl line 8:0. Do not edit! package js.html; @:native("HTMLDocument") extern class HTMLDocument extends Document { var domain : String; var cookie : String; var body : Element; var head(default,null) : HeadElement; var images(default,null) : HTMLCollection; var embeds(default,null) : HTMLCollection; var plugins(default,null) : HTMLCollection; var links(default,null) : HTMLCollection; var forms(default,null) : HTMLCollection; var scripts(default,null) : HTMLCollection; var designMode : String; var fgColor : String; var linkColor : String; var vlinkColor : String; var alinkColor : String; var bgColor : String; var anchors(default,null) : HTMLCollection; var applets(default,null) : HTMLCollection; var all(default,null) : HTMLAllCollection; function getElementsByName( elementName : String ) : NodeList; function getItems( ?typeNames : String = "" ) : NodeList; /** @throws DOMError */ @:overload( function( ?type : String = "text/html", ?replace : String = "" ) : HTMLDocument {} ) function open( url : String, name : String, features : String, ?replace : Bool = false ) : Window; /** @throws DOMError */ function close() : Void; /** @throws DOMError */ function write( text : haxe.extern.Rest ) : Void; /** @throws DOMError */ function writeln( text : haxe.extern.Rest ) : Void; /** @throws DOMError */ function execCommand( commandId : String, ?showUI : Bool = false, ?value : String = "" ) : Bool; /** @throws DOMError */ function queryCommandEnabled( commandId : String ) : Bool; /** @throws DOMError */ function queryCommandIndeterm( commandId : String ) : Bool; /** @throws DOMError */ function queryCommandState( commandId : String ) : Bool; function queryCommandSupported( commandId : String ) : Bool; /** @throws DOMError */ function queryCommandValue( commandId : String ) : String; function clear() : Void; /** @throws DOMError */ function getSelection() : Selection; function captureEvents() : Void; function releaseEvents() : Void; /** Shorthand for creating an HTML element. */ inline function createTableCellElement() : TableCellElement { return cast createElement("td"); } /** Shorthand for creating an HTML
element. */ inline function createHRElement() : HRElement { return cast createElement("hr"); } /** Shorthand for creating an HTML element. */ inline function createInputElement() : InputElement { return cast createElement("input"); } /** Shorthand for creating an HTML element. */ inline function createEmbedElement() : EmbedElement { return cast createElement("embed"); } /** Shorthand for creating an HTML element. */ inline function createMeterElement() : MeterElement { return cast createElement("meter"); } /** Shorthand for creating an HTML element. */ inline function createPictureElement() : PictureElement { return cast createElement("picture"); } /** Shorthand for creating an HTML
 element. */
	inline function createPreElement() : PreElement { return cast createElement("pre"); }
	/** Shorthand for creating an HTML  element. */
	inline function createTableSectionElement() : TableSectionElement { return cast createElement("thead"); }
	/** Shorthand for creating an HTML  element. */
	inline function createHeadElement() : HeadElement { return cast createElement("head"); }
	/** Shorthand for creating an HTML  element. */
	inline function createBaseElement() : BaseElement { return cast createElement("base"); }
	/** Shorthand for creating an HTML  element. */
	inline function createOptGroupElement() : OptGroupElement { return cast createElement("optgroup"); }
	/** Shorthand for creating an HTML  element. */
	inline function createQuoteElement() : QuoteElement { return cast createElement("quote"); }
	/** Shorthand for creating an HTML