Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed two (!) D1/Tango runtime build systems.

As discussed on IRC, Bob has been the default (and recommended) way to build Tango for LDC for quite some time now. Support for it in the CMake-based build system just created a big maintenance burden for (almost) no benefits. Besides, the build system was currently broken anyway.

The makefiles seemed to support building *.bc libs for Tango though, which Bob probably doesn't, which might be worth keeping in mind.
  • Loading branch information...
commit 38d1bf4cc8ce99401eef22aeb56f5e12c254d905 1 parent 018c477
@klickverbot klickverbot authored
Showing with 113 additions and 13,102 deletions.
  1. +3 −1 CMakeLists.txt
  2. +93 −147 runtime/CMakeLists.txt
  3. +17 −23 runtime/README
  4. +0 −24 runtime/build-sharedlibs.sh
  5. +0 −24 runtime/build.sh
  6. +0 −29 runtime/import/ldc/cstdarg.di
  7. +0 −413 runtime/import/ldc/intrinsics.di
  8. +0 −17 runtime/import/ldc/llvmasm.di
  9. +0 −414 runtime/internal/aApply.d
  10. +0 −975 runtime/internal/aApplyR.d
  11. +0 −798 runtime/internal/aaA.d
  12. +0 −610 runtime/internal/adi.d
  13. +0 −153 runtime/internal/arrayInit.d
  14. +0 −196 runtime/internal/cast.d
  15. +0 −164 runtime/internal/critical.c
  16. +0 −284 runtime/internal/dmain2.d
  17. +0 −430 runtime/internal/eh.d
  18. +0 −1,465 runtime/internal/genobj.d
  19. +0 −28 runtime/internal/invariant.d
  20. +0 −261 runtime/internal/ldc.mak
  21. +0 −81 runtime/internal/ldc/bitmanip.d
  22. +0 −43 runtime/internal/ldc/vararg.d
  23. +0 −1,083 runtime/internal/lifetime.d
  24. +0 −105 runtime/internal/mars.h
  25. +0 −635 runtime/internal/memory.d
  26. +0 −212 runtime/internal/monitor.c
  27. +0 −64 runtime/internal/qsort2.d
  28. +0 −425 runtime/internal/switch.d
  29. +0 −95 runtime/internal/typeinfo/ti_AC.d
  30. +0 −106 runtime/internal/typeinfo/ti_Acdouble.d
  31. +0 −104 runtime/internal/typeinfo/ti_Acfloat.d
  32. +0 −107 runtime/internal/typeinfo/ti_Acreal.d
  33. +0 −116 runtime/internal/typeinfo/ti_Adouble.d
  34. +0 −115 runtime/internal/typeinfo/ti_Afloat.d
  35. +0 −206 runtime/internal/typeinfo/ti_Ag.d
  36. +0 −119 runtime/internal/typeinfo/ti_Aint.d
  37. +0 −109 runtime/internal/typeinfo/ti_Along.d
  38. +0 −117 runtime/internal/typeinfo/ti_Areal.d
  39. +0 −132 runtime/internal/typeinfo/ti_Ashort.d
  40. +0 −74 runtime/internal/typeinfo/ti_C.d
  41. +0 −39 runtime/internal/typeinfo/ti_byte.d
  42. +0 −66 runtime/internal/typeinfo/ti_cdouble.d
  43. +0 −65 runtime/internal/typeinfo/ti_cfloat.d
  44. +0 −42 runtime/internal/typeinfo/ti_char.d
  45. +0 −67 runtime/internal/typeinfo/ti_creal.d
  46. +0 −44 runtime/internal/typeinfo/ti_dchar.d
  47. +0 −39 runtime/internal/typeinfo/ti_delegate.d
  48. +0 −65 runtime/internal/typeinfo/ti_double.d
  49. +0 −64 runtime/internal/typeinfo/ti_float.d
  50. +0 −12 runtime/internal/typeinfo/ti_idouble.d
  51. +0 −12 runtime/internal/typeinfo/ti_ifloat.d
  52. +0 −43 runtime/internal/typeinfo/ti_int.d
  53. +0 −12 runtime/internal/typeinfo/ti_ireal.d
  54. +0 −43 runtime/internal/typeinfo/ti_long.d
  55. +0 −46 runtime/internal/typeinfo/ti_ptr.d
  56. +0 −64 runtime/internal/typeinfo/ti_real.d
  57. +0 −39 runtime/internal/typeinfo/ti_short.d
  58. +0 −43 runtime/internal/typeinfo/ti_ubyte.d
  59. +0 −43 runtime/internal/typeinfo/ti_uint.d
  60. +0 −43 runtime/internal/typeinfo/ti_ulong.d
  61. +0 −39 runtime/internal/typeinfo/ti_ushort.d
  62. +0 −43 runtime/internal/typeinfo/ti_void.d
  63. +0 −43 runtime/internal/typeinfo/ti_wchar.d
  64. +0 −86 runtime/internal/util/console.d
  65. +0 −106 runtime/internal/util/ctype.d
  66. +0 −50 runtime/internal/util/string.d
  67. +0 −851 runtime/internal/util/utf.d
  68. +0 −178 runtime/lib/common/tango/ldc.mak
  69. +0 −127 runtime/lib/gc/basic/ldc.mak
  70. +0 −96 runtime/lib/gc/stub/ldc.mak
  71. +0 −88 runtime/lib/ldc-posix.mak
View
4 CMakeLists.txt
@@ -267,4 +267,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(DIRECTORY bash_completion.d DESTINATION ${CONF_INST_DIR})
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-add_subdirectory(runtime)
+if(D_VERSION EQUAL 2)
+ add_subdirectory(runtime)
+endif()
View
240 runtime/CMakeLists.txt
@@ -6,6 +6,10 @@ cmake_minimum_required(VERSION 2.6)
# Main configuration.
#
+if(D_VERSION EQUAL 1)
+ message(FATAL_ERROR "Please use bob to build Tango for D1.")
+endif()
+
include(CheckTypeSize)
check_type_size(void* ptr_size)
@@ -29,146 +33,97 @@ else(BUILD_SHARED_LIBS)
set(CXX_COMPILE_FLAGS " ")
endif(BUILD_SHARED_LIBS)
-# build tango for D1, druntime for D2
-if(D_VERSION EQUAL 1)
- set(RUNTIME tango)
-elseif(D_VERSION EQUAL 2)
- set(RUNTIME druntime)
-else(D_VERSION EQUAL 1)
- message(FATAL_ERROR "The runtime must be built as part of the main CMake project.")
-endif(D_VERSION EQUAL 1)
get_directory_property(PROJECT_PARENT_DIR DIRECTORY ${PROJECT_SOURCE_DIR} PARENT_DIRECTORY)
-set(RUNTIME_DIR ${PROJECT_PARENT_DIR}/${RUNTIME} CACHE PATH "runtime source dir")
+set(RUNTIME_DIR ${PROJECT_PARENT_DIR}/druntime CACHE PATH "runtime source dir")
#
# Gather source files.
#
-if(D_VERSION EQUAL 1)
- # copy imports to runtime dir
- set(LDC_IMPORTS)
- macro(imports_file SRCARG)
- get_filename_component(DEST ${SRCARG} NAME)
- set(SRC ${PROJECT_PARENT_DIR}/${SRCARG})
- set(DEST ${RUNTIME_DIR}/ldc/${DEST})
-
- list(APPEND LDC_IMPORTS ${DEST})
- add_custom_command(
- OUTPUT ${DEST}
- DEPENDS ${SRC}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRC} ${DEST}
- )
- endmacro(imports_file)
- imports_file(import/ldc/cstdarg.di)
- imports_file(import/ldc/intrinsics.di)
- imports_file(import/ldc/llvmasm.di)
- imports_file(internal/ldc/bitmanip.d)
- imports_file(internal/ldc/vararg.d)
- # library names
- set(RUNTIME_CC tango-cc-tango)
- set(RUNTIME_GC tango-gc-basic)
- set(RUNTIME_DC ldc-runtime)
- set(RUNTIME_AIO tango)
- # set paths to source files, or fill lists directly
- set(RUNTIME_DC_DIR ${RUNTIME_DIR}/internal)
- set(RUNTIME_GC_DIR ${RUNTIME_DIR}/lib/gc/basic)
- set(RUNTIME_INCLUDE ${RUNTIME_DC_DIR})
- file(GLOB CORE_D ${RUNTIME_DIR}/lib/common/tango/core/*.d)
- file(GLOB CORE_C ${RUNTIME_DIR}/lib/common/tango/stdc/*.c)
- file(GLOB_RECURSE GC_D ${RUNTIME_GC_DIR}/*.d)
- file(GLOB_RECURSE DCRT_D ${RUNTIME_DC_DIR}/*.d)
- file(GLOB DCRT_C ${RUNTIME_DC_DIR}/*.c)
- set(CONFIG_NAME ${LDC_EXE})
-elseif(D_VERSION EQUAL 2)
- set(PHOBOS2_DIR ${PROJECT_PARENT_DIR}/phobos CACHE PATH "phobos2 source dir")
- set(RUNTIME_CC druntime-core)
- set(RUNTIME_GC druntime-gc-basic)
- set(RUNTIME_DC druntime-rt-ldc)
- set(RUNTIME_AIO ldruntime)
- set(RUNTIME_DC_DIR ${RUNTIME_DIR}/src/rt)
- set(RUNTIME_GC_DIR ${RUNTIME_DIR}/src/gc)
- set(RUNTIME_INCLUDE ${RUNTIME_DIR}/src)
- file(GLOB CORE_D ${RUNTIME_DIR}/src/core/*.d )
- file(GLOB CORE_D_SYNC ${RUNTIME_DIR}/src/core/sync/*.d )
- file(GLOB CORE_D_STDC ${RUNTIME_DIR}/src/core/stdc/*.d )
- file(GLOB_RECURSE GC_D ${RUNTIME_GC_DIR}/*.d)
- file(GLOB_RECURSE DCRT_D ${RUNTIME_DC_DIR}/*.d)
- file(GLOB_RECURSE LDC_D ${RUNTIME_DIR}/src/ldc/*.d)
- list(REMOVE_ITEM DCRT_D
- ${RUNTIME_DC_DIR}/alloca.d
- ${RUNTIME_DC_DIR}/arraybyte.d
- ${RUNTIME_DC_DIR}/arraycast.d
- ${RUNTIME_DC_DIR}/arraycat.d
- ${RUNTIME_DC_DIR}/arraydouble.d
- ${RUNTIME_DC_DIR}/arrayfloat.d
- ${RUNTIME_DC_DIR}/arrayreal.d
- ${RUNTIME_DC_DIR}/arrayshort.d
- ${RUNTIME_DC_DIR}/critical_.d
- ${RUNTIME_DC_DIR}/deh.d
- ${RUNTIME_DC_DIR}/deh2.d
- ${RUNTIME_DC_DIR}/llmath.d
- ${RUNTIME_DC_DIR}/qsort2.d
- ${RUNTIME_DC_DIR}/trace.d
- )
- file(GLOB DCRT_C ${RUNTIME_DC_DIR}/*.c)
- list(REMOVE_ITEM DCRT_C ${RUNTIME_DC_DIR}/deh.c ${RUNTIME_DC_DIR}/memory_osx.c ${RUNTIME_DC_DIR}/dylib_fixes.c)
+set(PHOBOS2_DIR ${PROJECT_PARENT_DIR}/phobos CACHE PATH "phobos2 source dir")
+set(RUNTIME_CC druntime-core)
+set(RUNTIME_GC druntime-gc-basic)
+set(RUNTIME_DC druntime-rt-ldc)
+set(RUNTIME_AIO ldruntime)
+set(RUNTIME_DC_DIR ${RUNTIME_DIR}/src/rt)
+set(RUNTIME_GC_DIR ${RUNTIME_DIR}/src/gc)
+set(RUNTIME_INCLUDE ${RUNTIME_DIR}/src)
+file(GLOB CORE_D ${RUNTIME_DIR}/src/core/*.d )
+file(GLOB CORE_D_SYNC ${RUNTIME_DIR}/src/core/sync/*.d )
+file(GLOB CORE_D_STDC ${RUNTIME_DIR}/src/core/stdc/*.d )
+file(GLOB_RECURSE GC_D ${RUNTIME_GC_DIR}/*.d)
+file(GLOB_RECURSE DCRT_D ${RUNTIME_DC_DIR}/*.d)
+file(GLOB_RECURSE LDC_D ${RUNTIME_DIR}/src/ldc/*.d)
+list(REMOVE_ITEM DCRT_D
+ ${RUNTIME_DC_DIR}/alloca.d
+ ${RUNTIME_DC_DIR}/arraybyte.d
+ ${RUNTIME_DC_DIR}/arraycast.d
+ ${RUNTIME_DC_DIR}/arraycat.d
+ ${RUNTIME_DC_DIR}/arraydouble.d
+ ${RUNTIME_DC_DIR}/arrayfloat.d
+ ${RUNTIME_DC_DIR}/arrayreal.d
+ ${RUNTIME_DC_DIR}/arrayshort.d
+ ${RUNTIME_DC_DIR}/critical_.d
+ ${RUNTIME_DC_DIR}/deh.d
+ ${RUNTIME_DC_DIR}/deh2.d
+ ${RUNTIME_DC_DIR}/llmath.d
+ ${RUNTIME_DC_DIR}/qsort2.d
+ ${RUNTIME_DC_DIR}/trace.d
+)
+file(GLOB DCRT_C ${RUNTIME_DC_DIR}/*.c)
+list(REMOVE_ITEM DCRT_C ${RUNTIME_DC_DIR}/deh.c ${RUNTIME_DC_DIR}/memory_osx.c ${RUNTIME_DC_DIR}/dylib_fixes.c)
+if(UNIX)
+ file(GLOB_RECURSE CORE_D_SYS ${RUNTIME_DIR}/src/core/sys/posix/*.d)
+elseif(WIN32)
+ file(GLOB_RECURSE CORE_D_SYS ${RUNTIME_DIR}/src/core/sys/windows/*.d)
+elseif(APPLE)
+ file(GLOB_RECURSE CORE_D_SYS ${RUNTIME_DIR}/src/core/sys/osx/*.d)
+endif(UNIX)
+list(APPEND CORE_D ${CORE_D_SYNC} ${CORE_D_SYS} ${CORE_D_STDC} )
+list(APPEND GENERATE_DI ${CORE_D})
+list(APPEND CORE_D ${LDC_D} ${RUNTIME_DIR}/src/object_.d)
+file(GLOB CORE_C ${RUNTIME_DIR}/src/core/stdc/*.c)
+
+if(PHOBOS2_DIR)
+ file(GLOB PHOBOS2_D ${PHOBOS2_DIR}/std/*.d)
+ file(GLOB_RECURSE PHOBOS2_D_INTERNAL ${PHOBOS2_DIR}/std/internal/*.d)
+ file(GLOB PHOBOS2_D_C ${PHOBOS2_DIR}/std/c/*.d)
if(UNIX)
- file(GLOB_RECURSE CORE_D_SYS ${RUNTIME_DIR}/src/core/sys/posix/*.d)
+ file(GLOB PHOBOS2_D_C_SYS ${PHOBOS2_DIR}/std/c/linux/*.d)
elseif(WIN32)
- file(GLOB_RECURSE CORE_D_SYS ${RUNTIME_DIR}/src/core/sys/windows/*.d)
+ file(GLOB PHOBOS2_D_C_SYS ${PHOBOS2_DIR}/std/c/windows/*.d)
elseif(APPLE)
- file(GLOB_RECURSE CORE_D_SYS ${RUNTIME_DIR}/src/core/sys/osx/*.d)
+ file(GLOB PHOBOS2_D_C_SYS ${PHOBOS2_DIR}/std/c/osx/*.d)
endif(UNIX)
- list(APPEND CORE_D ${CORE_D_SYNC} ${CORE_D_SYS} ${CORE_D_STDC} )
- list(APPEND GENERATE_DI ${CORE_D})
- list(APPEND CORE_D ${LDC_D} ${RUNTIME_DIR}/src/object_.d)
- file(GLOB CORE_C ${RUNTIME_DIR}/src/core/stdc/*.c)
-
- if(PHOBOS2_DIR)
- file(GLOB PHOBOS2_D ${PHOBOS2_DIR}/std/*.d)
- file(GLOB_RECURSE PHOBOS2_D_INTERNAL ${PHOBOS2_DIR}/std/internal/*.d)
- file(GLOB PHOBOS2_D_C ${PHOBOS2_DIR}/std/c/*.d)
- if(UNIX)
- file(GLOB PHOBOS2_D_C_SYS ${PHOBOS2_DIR}/std/c/linux/*.d)
- elseif(WIN32)
- file(GLOB PHOBOS2_D_C_SYS ${PHOBOS2_DIR}/std/c/windows/*.d)
- elseif(APPLE)
- file(GLOB PHOBOS2_D_C_SYS ${PHOBOS2_DIR}/std/c/osx/*.d)
- endif(UNIX)
- file(GLOB ZLIB_C ${PHOBOS2_DIR}/etc/c/zlib/*.c)
- list(REMOVE_ITEM ZLIB_C
- ${PHOBOS2_DIR}/etc/c/zlib/minigzip.c
- ${PHOBOS2_DIR}/etc/c/zlib/example.c
- ${PHOBOS2_DIR}/etc/c/zlib/gzio.c
- )
- if(WIN32)
- file(GLOB PHOBOS2_D_WIN ${PHOBOS2_DIR}/std/windows/*.d)
- endif(WIN32)
- list(APPEND PHOBOS2_D
- ${PHOBOS2_D_INTERNAL}
- ${PHOBOS2_D_WIN}
- ${PHOBOS2_D_C}
- ${PHOBOS2_D_C_SYS}
- ${PHOBOS2_DIR}/etc/c/zlib.d
- ${PHOBOS2_DIR}/crc32.d
- )
- list(REMOVE_ITEM PHOBOS2_D
- ${PHOBOS2_DIR}/std/intrinsic.d
- )
- set(CONFIG_NAME ${LDC_EXE}_phobos)
- else(PHOBOS2_DIR)
- set(CONFIG_NAME ${LDC_EXE})
- endif(PHOBOS2_DIR)
-endif(D_VERSION EQUAL 1)
+ file(GLOB ZLIB_C ${PHOBOS2_DIR}/etc/c/zlib/*.c)
+ list(REMOVE_ITEM ZLIB_C
+ ${PHOBOS2_DIR}/etc/c/zlib/minigzip.c
+ ${PHOBOS2_DIR}/etc/c/zlib/example.c
+ ${PHOBOS2_DIR}/etc/c/zlib/gzio.c
+ )
+ if(WIN32)
+ file(GLOB PHOBOS2_D_WIN ${PHOBOS2_DIR}/std/windows/*.d)
+ endif(WIN32)
+ list(APPEND PHOBOS2_D
+ ${PHOBOS2_D_INTERNAL}
+ ${PHOBOS2_D_WIN}
+ ${PHOBOS2_D_C}
+ ${PHOBOS2_D_C_SYS}
+ ${PHOBOS2_DIR}/etc/c/zlib.d
+ ${PHOBOS2_DIR}/crc32.d
+ )
+ list(REMOVE_ITEM PHOBOS2_D
+ ${PHOBOS2_DIR}/std/intrinsic.d
+ )
+ set(CONFIG_NAME ${LDC_EXE}_phobos)
+else(PHOBOS2_DIR)
+ set(CONFIG_NAME ${LDC_EXE})
+endif(PHOBOS2_DIR)
# should only be necessary if run independently from ldc cmake project
if(NOT LDC_LOC)
if(NOT LDC_EXE)
- if(D_VERSION EQUAL 1)
- set(LDC_EXE ldc)
- elseif(D_VERSION EQUAL 2)
- set(LDC_EXE ldc2)
- endif(D_VERSION EQUAL 1)
+ set(LDC_EXE ldc2)
endif(NOT LDC_EXE)
find_program(LDC_LOC ${LDC_EXE} ${PROJECT_BINARY_DIR}/../bin DOC "path to ldc binary")
@@ -264,14 +219,10 @@ macro(build_runtime d_flags c_flags ld_flags lib_suffix path_suffix)
set(DCRT_O "")
set(DCRT_BC "")
foreach(f ${DCRT_D})
- if(D_VERSION EQUAL 1)
- dc(${f} DCRT_O DCRT_BC "${d_flags}" ${RUNTIME_DC_DIR} "${target_suffix}")
- else(D_VERSION EQUAL 1)
- dc(${f} DCRT_O DCRT_BC "${d_flags}" "" "${target_suffix}")
- endif(D_VERSION EQUAL 1)
+ dc(${f} DCRT_O DCRT_BC "${d_flags}" "" "${target_suffix}")
endforeach(f)
- if(EXISTS ${PROJECT_PARENT_DIR}/${RUNTIME})
+ if(EXISTS ${RUNTIME_DIR})
if(BUILD_SINGLE_LIB)
add_library(${RUNTIME_AIO}${target_suffix}
${D_LIBRARY_TYPE}
@@ -296,7 +247,7 @@ macro(build_runtime d_flags c_flags ld_flags lib_suffix path_suffix)
${RUNTIME_DC}${lib_suffix}
)
endif(BUILD_SINGLE_LIB)
- endif(EXISTS ${PROJECT_PARENT_DIR}/${RUNTIME})
+ endif()
if(BUILD_BC_LIBS)
find_program(LLVM_AR_EXE llvm-ar ${LLVM_INSTDIR}/bin DOC "path to llvm-ar tool")
@@ -389,17 +340,12 @@ endif(MULTILIB)
# Install target.
#
-if(D_VERSION EQUAL 2)
- install(DIRECTORY ${CMAKE_BINARY_DIR}/import/core DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.di")
- if(PHOBOS2_DIR)
- install(DIRECTORY ${PHOBOS2_DIR}/std DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
- install(DIRECTORY ${PHOBOS2_DIR}/etc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
- install(FILES ${PHOBOS2_DIR}/crc32.d DESTINATION ${INCLUDE_INSTALL_DIR})
- endif(PHOBOS2_DIR)
- install(FILES ${RUNTIME_DIR}/import/object.di DESTINATION ${INCLUDE_INSTALL_DIR}/ldc)
- install(FILES ${RUNTIME_DIR}/src/ldc/bitop.d DESTINATION ${INCLUDE_INSTALL_DIR}/core)
- install(DIRECTORY ${RUNTIME_DIR}/import/ldc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.di")
-else(D_VERSION EQUAL 2)
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/${RUNTIME}/internal/ldc/ DESTINATION ${INCLUDE_INSTALL_DIR}/ldc)
- install(DIRECTORY ${PROJECT_SOURCE_DIR}/runtime/import/ldc DESTINATION ${INCLUDE_INSTALL_DIR})
-endif(D_VERSION EQUAL 2)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/import/core DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.di")
+if(PHOBOS2_DIR)
+ install(DIRECTORY ${PHOBOS2_DIR}/std DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
+ install(DIRECTORY ${PHOBOS2_DIR}/etc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
+ install(FILES ${PHOBOS2_DIR}/crc32.d DESTINATION ${INCLUDE_INSTALL_DIR})
+endif(PHOBOS2_DIR)
+install(FILES ${RUNTIME_DIR}/import/object.di DESTINATION ${INCLUDE_INSTALL_DIR}/ldc)
+install(FILES ${RUNTIME_DIR}/src/ldc/bitop.d DESTINATION ${INCLUDE_INSTALL_DIR}/core)
+install(DIRECTORY ${RUNTIME_DIR}/import/ldc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.di")
View
40 runtime/README
@@ -1,30 +1,24 @@
-This should help get the runtime built.
-FOR D1:
-=======
-1) Do a checkout of tango trunk into the ldc root dir (along dmd, gen, runtime etc).
+Building druntime/Phobos for D2
+---
- * $ ls
- * dmd dmd2 gen ir ...
- * $ svn co http://svn.dsource.org/projects/tango/trunk tango
+LDC currently needs custom forks of druntime and Phobos. They are integrated
+with the main repository using Git submodules. To build them, make sure you
+have up-to-date copies of the submodules in your local repository:
-2) Compile the runtime
+$ git submodule update -i
- * sh build.sh
+The libraries should then be built and installed automatically along with the
+compiler itself. If, for some reason, you want to build them separately, the
+targets are:
-FOR D2:
-=======
-1) Check http://bitbucket.org/prokhin_alexy/ldc2/wiki/Home for up to date instructions
+$ make runtime
+$ make phobos2
-2) At the time of writing, this works:
- * $ git clone https://github.com/AlexeyProkhin/druntime
- * $ git clone https://github.com/AlexeyProkhin/phobos
+Building Tango for D1
+---
-3) Using cmake, set the D version to 2, then set the correct paths for druntime and phobos
-
-4) Compile ldc2, druntime, and phobos
-
- * $ make phobos2
-
-=======
-Enjoy!
+This directory used to contain scripts for building Tango for LDC/D1, which
+became obsolete after LDC support was added to its build system, and were
+consequently removed. Please use the official Tango build system (bob) from
+now on.
View
24 runtime/build-sharedlibs.sh
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-# I'm no good bash scripter ...
-
-# copy imports
-mkdir -p ../tango/ldc
-cp internal/ldc/bitmanip.d ../tango/ldc/bitmanip.di
-cp internal/ldc/vararg.d ../tango/ldc/vararg.di
-cp import/ldc/* ../tango/ldc
-
-# make the runtime
-cp -R lib ../tango
-cd ../tango/lib
-make -f ldc-posix.mak clean
-make -f ldc-posix.mak sharedlib
-cd ../..
-
-# install the runtime
-rm -f lib/libldc-runtime-shared.so
-cp runtime/internal/libldc-runtime-shared.so lib
-rm -f lib/libtango-gc-basic-shared.so
-cp tango/lib/gc/basic/libtango-gc-basic-shared.so lib
-rm -f lib/libtango-cc-tango-shared.so
-cp tango/lib/common/tango/libtango-cc-tango-shared.so lib
View
24 runtime/build.sh
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-# I'm no good bash scripter ...
-
-# copy imports
-mkdir -p ../tango/ldc
-cp internal/ldc/bitmanip.d ../tango/ldc/bitmanip.di
-cp internal/ldc/vararg.d ../tango/ldc/vararg.di
-cp import/ldc/* ../tango/ldc
-
-# make the runtime
-cp -R lib ../tango
-cd ../tango/lib
-make -f ldc-posix.mak clean
-make -f ldc-posix.mak lib
-cd ../..
-
-# install the runtime
-rm -f lib/libldc-runtime*.a
-cp runtime/internal/libldc-runtime*.a lib
-rm -f lib/libtango-gc-basic*.a
-cp tango/lib/gc/basic/libtango-gc-basic*.a lib
-rm -f lib/libtango-cc-tango*.a
-cp tango/lib/common/tango/libtango-cc-tango*.a lib
View
29 runtime/import/ldc/cstdarg.di
@@ -1,29 +0,0 @@
-/*
- * vararg support for extern(C) functions
- */
-
-module ldc.cstdarg;
-
-// Check for the right compiler
-version(LDC)
-{
- // OK
-}
-else
-{
- static assert(false, "This module is only valid for LDC");
-}
-
-alias void* va_list;
-
-pragma(va_start)
- void va_start(T)(va_list ap, ref T);
-
-pragma(va_arg)
- T va_arg(T)(va_list ap);
-
-pragma(va_end)
- void va_end(va_list args);
-
-pragma(va_copy)
- void va_copy(va_list dst, va_list src);
View
413 runtime/import/ldc/intrinsics.di
@@ -1,413 +0,0 @@
-/*
- * This module holds declarations to LLVM intrinsics.
- *
- * See the LLVM language reference for more information:
- *
- * - http://llvm.org/docs/LangRef.html#intrinsics
- *
- */
-
-module ldc.intrinsics;
-
-// Check for the right compiler
-version(LDC)
-{
- // OK
-}
-else
-{
- static assert(false, "This module is only valid for LDC");
-}
-
-//
-// CODE GENERATOR INTRINSICS
-//
-
-
-// The 'llvm.returnaddress' intrinsic attempts to compute a target-specific
-// value indicating the return address of the current function or one of its
-// callers.
-
-pragma(intrinsic, "llvm.returnaddress")
- void* llvm_returnaddress(uint level);
-
-
-// The 'llvm.frameaddress' intrinsic attempts to return the target-specific
-// frame pointer value for the specified stack frame.
-
-pragma(intrinsic, "llvm.frameaddress")
- void* llvm_frameaddress(uint level);
-
-
-// The 'llvm.stacksave' intrinsic is used to remember the current state of the
-// function stack, for use with llvm.stackrestore. This is useful for
-// implementing language features like scoped automatic variable sized arrays
-// in C99.
-
-pragma(intrinsic, "llvm.stacksave")
- void* llvm_stacksave();
-
-
-// The 'llvm.stackrestore' intrinsic is used to restore the state of the
-// function stack to the state it was in when the corresponding llvm.stacksave
-// intrinsic executed. This is useful for implementing language features like
-// scoped automatic variable sized arrays in C99.
-
-pragma(intrinsic, "llvm.stackrestore")
- void llvm_stackrestore(void* ptr);
-
-
-// The 'llvm.prefetch' intrinsic is a hint to the code generator to insert a
-// prefetch instruction if supported; otherwise, it is a noop. Prefetches have
-// no effect on the behavior of the program but can change its performance
-// characteristics.
-
-pragma(intrinsic, "llvm.prefetch")
- void llvm_prefetch(void* ptr, uint rw, uint locality);
-
-
-// The 'llvm.pcmarker' intrinsic is a method to export a Program Counter (PC)
-// in a region of code to simulators and other tools. The method is target
-// specific, but it is expected that the marker will use exported symbols to
-// transmit the PC of the marker. The marker makes no guarantees that it will
-// remain with any specific instruction after optimizations. It is possible
-// that the presence of a marker will inhibit optimizations. The intended use
-// is to be inserted after optimizations to allow correlations of simulation
-// runs.
-
-pragma(intrinsic, "llvm.pcmarker")
- void llvm_pcmarker(uint id);
-
-
-// The 'llvm.readcyclecounter' intrinsic provides access to the cycle counter
-// register (or similar low latency, high accuracy clocks) on those targets that
-// support it. On X86, it should map to RDTSC. On Alpha, it should map to RPCC.
-// As the backing counters overflow quickly (on the order of 9 seconds on
-// alpha), this should only be used for small timings.
-
-pragma(intrinsic, "llvm.readcyclecounter")
- ulong readcyclecounter();
-
-
-
-
-//
-// STANDARD C LIBRARY INTRINSICS
-//
-
-
-// The 'llvm.memcpy.*' intrinsics copy a block of memory from the source
-// location to the destination location.
-// Note that, unlike the standard libc function, the llvm.memcpy.* intrinsics do
-// not return a value, and takes an extra alignment argument.
-
-pragma(intrinsic, "llvm.memcpy.i#")
- void llvm_memcpy(T)(void* dst, void* src, T len, uint alignment);
-
-deprecated {
- alias llvm_memcpy!(uint) llvm_memcpy_i32;
- alias llvm_memcpy!(ulong) llvm_memcpy_i64;
-}
-
-
-// The 'llvm.memmove.*' intrinsics move a block of memory from the source
-// location to the destination location. It is similar to the 'llvm.memcpy'
-// intrinsic but allows the two memory locations to overlap.
-// Note that, unlike the standard libc function, the llvm.memmove.* intrinsics
-// do not return a value, and takes an extra alignment argument.
-
-pragma(intrinsic, "llvm.memmove.i#")
- void llvm_memmove(T)(void* dst, void* src, T len, uint alignment);
-
-deprecated {
- alias llvm_memmove!(uint) llvm_memmove_i32;
- alias llvm_memmove!(ulong) llvm_memmove_i64;
-}
-
-
-// The 'llvm.memset.*' intrinsics fill a block of memory with a particular byte
-// value.
-// Note that, unlike the standard libc function, the llvm.memset intrinsic does
-// not return a value, and takes an extra alignment argument.
-
-pragma(intrinsic, "llvm.memset.i#")
- void llvm_memset(T)(void* dst, ubyte val, T len, uint alignment);
-
-deprecated {
- alias llvm_memset!(uint) llvm_memset_i32;
- alias llvm_memset!(ulong) llvm_memset_i64;
-}
-
-
-// The 'llvm.sqrt' intrinsics return the sqrt of the specified operand,
-// returning the same value as the libm 'sqrt' functions would. Unlike sqrt in
-// libm, however, llvm.sqrt has undefined behavior for negative numbers other
-// than -0.0 (which allows for better optimization, because there is no need to
-// worry about errno being set). llvm.sqrt(-0.0) is defined to return -0.0 like
-// IEEE sqrt.
-
-pragma(intrinsic, "llvm.sqrt.f#")
- T llvm_sqrt(T)(T val);
-
-deprecated {
- alias llvm_sqrt!(float) llvm_sqrt_f32;
- alias llvm_sqrt!(double) llvm_sqrt_f64;
- alias llvm_sqrt!(real) llvm_sqrt_f80; // may not actually be .f80
-}
-
-
-// The 'llvm.sin.*' intrinsics return the sine of the operand.
-
-pragma(intrinsic, "llvm.sin.f#")
- T llvm_sin(T)(T val);
-
-deprecated {
- alias llvm_sin!(float) llvm_sin_f32;
- alias llvm_sin!(double) llvm_sin_f64;
- alias llvm_sin!(real) llvm_sin_f80; // may not actually be .f80
-}
-
-
-// The 'llvm.cos.*' intrinsics return the cosine of the operand.
-
-pragma(intrinsic, "llvm.cos.f#")
- T llvm_cos(T)(T val);
-
-deprecated {
- alias llvm_cos!(float) llvm_cos_f32;
- alias llvm_cos!(double) llvm_cos_f64;
- alias llvm_cos!(real) llvm_cos_f80; // may not actually be .f80
-}
-
-
-// The 'llvm.powi.*' intrinsics return the first operand raised to the specified
-// (positive or negative) power. The order of evaluation of multiplications is
-// not defined. When a vector of floating point type is used, the second
-// argument remains a scalar integer value.
-
-pragma(intrinsic, "llvm.powi.f#")
- T llvm_powi(T)(T val, int power);
-
-deprecated {
- alias llvm_powi!(float) llvm_powi_f32;
- alias llvm_powi!(double) llvm_powi_f64;
- alias llvm_powi!(real) llvm_powi_f80; // may not actually be .f80
-}
-
-
-// The 'llvm.pow.*' intrinsics return the first operand raised to the specified
-// (positive or negative) power.
-
-pragma(intrinsic, "llvm.pow.f#")
- T llvm_pow(T)(T val, T power);
-
-deprecated {
- alias llvm_pow!(float) llvm_pow_f32;
- alias llvm_pow!(double) llvm_pow_f64;
- alias llvm_pow!(real) llvm_pow_f80; // may not actually be .f80
-}
-
-
-//
-// BIT MANIPULATION INTRINSICS
-//
-
-// The 'llvm.bswap' family of intrinsics is used to byte swap integer values
-// with an even number of bytes (positive multiple of 16 bits). These are
-// useful for performing operations on data that is not in the target's native
-// byte order.
-
-pragma(intrinsic, "llvm.bswap.i#.i#")
- T llvm_bswap(T)(T val);
-
-deprecated {
- alias llvm_bswap!(ushort) llvm_bswap_i16;
- alias llvm_bswap!(uint) llvm_bswap_i32;
- alias llvm_bswap!(ulong) llvm_bswap_i64;
-}
-
-
-// The 'llvm.ctpop' family of intrinsics counts the number of bits set in a
-// value.
-
-pragma(intrinsic, "llvm.ctpop.i#")
- T llvm_ctpop(T)(T src);
-
-deprecated {
- alias llvm_ctpop!(ubyte) llvm_ctpop_i8;
- alias llvm_ctpop!(ushort) llvm_ctpop_i16;
- alias llvm_ctpop!(uint) llvm_ctpop_i32;
- alias llvm_ctpop!(ulong) llvm_ctpop_i64;
-}
-
-
-// The 'llvm.ctlz' family of intrinsic functions counts the number of leading
-// zeros in a variable.
-
-pragma(intrinsic, "llvm.ctlz.i#")
- T llvm_ctlz(T)(T src);
-
-deprecated {
- alias llvm_ctlz!(ubyte) llvm_ctlz_i8;
- alias llvm_ctlz!(ushort) llvm_ctlz_i16;
- alias llvm_ctlz!(uint) llvm_ctlz_i32;
- alias llvm_ctlz!(ulong) llvm_ctlz_i64;
-}
-
-
-// The 'llvm.cttz' family of intrinsic functions counts the number of trailing
-// zeros.
-
-pragma(intrinsic, "llvm.cttz.i#")
- T llvm_cttz(T)(T src);
-
-deprecated {
- alias llvm_cttz!(ubyte) llvm_cttz_i8;
- alias llvm_cttz!(ushort) llvm_cttz_i16;
- alias llvm_cttz!(uint) llvm_cttz_i32;
- alias llvm_cttz!(ulong) llvm_cttz_i64;
-}
-
-
-// The 'llvm.part.select' family of intrinsic functions selects a range of bits
-// from an integer value and returns them in the same bit width as the original
-// value.
-
-pragma(intrinsic, "llvm.part.select.i#")
- T llvm_part_select(T)(T val, uint loBit, uint hiBit);
-
-deprecated {
- alias llvm_part_select!(ubyte) llvm_part_select_i;
- alias llvm_part_select!(ushort) llvm_part_select_i;
- alias llvm_part_select!(uint) llvm_part_select_i;
- alias llvm_part_select!(ulong) llvm_part_select_i;
-}
-
-
-// The 'llvm.part.set' family of intrinsic functions replaces a range of bits
-// in an integer value with another integer value. It returns the integer with
-// the replaced bits.
-
-// TODO
-// declare i17 @llvm.part.set.i17.i9 (i17 %val, i9 %repl, i32 %lo, i32 %hi)
-// declare i29 @llvm.part.set.i29.i9 (i29 %val, i9 %repl, i32 %lo, i32 %hi)
-
-
-
-
-//
-// ATOMIC OPERATIONS AND SYNCHRONIZATION INTRINSICS
-//
-
-// The llvm.memory.barrier intrinsic guarantees ordering between specific
-// pairs of memory access types.
-
-pragma(intrinsic, "llvm.memory.barrier")
- void llvm_memory_barrier(bool ll, bool ls, bool sl, bool ss, bool device);
-
-// This loads a value in memory and compares it to a given value. If they are
-// equal, it stores a new value into the memory.
-
-pragma(intrinsic, "llvm.atomic.cmp.swap.i#.p0i#")
- T llvm_atomic_cmp_swap(T)(T* ptr, T cmp, T val);
-
-// This intrinsic loads the value stored in memory at ptr and yields the value
-// from memory. It then stores the value in val in the memory at ptr.
-
-pragma(intrinsic, "llvm.atomic.swap.i#.p0i#")
- T llvm_atomic_swap(T)(T* ptr, T val);
-
-// This intrinsic adds delta to the value stored in memory at ptr. It yields
-// the original value at ptr.
-
-pragma(intrinsic, "llvm.atomic.load.add.i#.p0i#")
- T llvm_atomic_load_add(T)(T* ptr, T val);
-
-// This intrinsic subtracts delta to the value stored in memory at ptr. It
-// yields the original value at ptr.
-
-pragma(intrinsic, "llvm.atomic.load.sub.i#.p0i#")
- T llvm_atomic_load_sub(T)(T* ptr, T val);
-
-// These intrinsics bitwise the operation (and, nand, or, xor) delta to the
-// value stored in memory at ptr. It yields the original value at ptr.
-
-pragma(intrinsic, "llvm.atomic.load.and.i#.p0i#")
- T llvm_atomic_load_and(T)(T* ptr, T val);
-
-pragma(intrinsic, "llvm.atomic.load.nand.i#.p0i#")
- T llvm_atomic_load_nand(T)(T* ptr, T val);
-
-pragma(intrinsic, "llvm.atomic.load.or.i#.p0i#")
- T llvm_atomic_load_or(T)(T* ptr, T val);
-
-pragma(intrinsic, "llvm.atomic.load.xor.i#.p0i#")
- T llvm_atomic_load_xor(T)(T* ptr, T val);
-
-// These intrinsics takes the signed or unsigned minimum or maximum of delta
-// and the value stored in memory at ptr. It yields the original value at ptr.
-
-pragma(intrinsic, "llvm.atomic.load.max.i#.p0i#")
- T llvm_atomic_load_max(T)(T* ptr, T val);
-
-pragma(intrinsic, "llvm.atomic.load.min.i#.p0i#")
- T llvm_atomic_load_min(T)(T* ptr, T val);
-
-pragma(intrinsic, "llvm.atomic.load.umax.i#.p0i#")
- T llvm_atomic_load_umax(T)(T* ptr, T val);
-
-pragma(intrinsic, "llvm.atomic.load.umin.i#.p0i#")
- T llvm_atomic_load_umin(T)(T* ptr, T val);
-
-
-//
-// ARITHMETIC-WITH-OVERFLOW INTRINSICS
-//
-
-struct OverflowRet(T) {
- static assert(is(T : int), T.stringof ~ " is not an integer type!");
- T result;
- bool overflow;
-}
-
-// Signed and unsigned addition
-pragma(intrinsic, "llvm.sadd.with.overflow.i#")
- OverflowRet!(T) llvm_sadd_with_overflow(T)(T lhs, T rhs);
-
-pragma(intrinsic, "llvm.uadd.with.overflow.i#")
- OverflowRet!(T) llvm_uadd_with_overflow(T)(T lhs, T rhs);
-
-
-// Signed and unsigned subtraction
-pragma(intrinsic, "llvm.ssub.with.overflow.i#")
- OverflowRet!(T) llvm_ssub_with_overflow(T)(T lhs, T rhs);
-
-pragma(intrinsic, "llvm.usub.with.overflow.i#")
- OverflowRet!(T) llvm_usub_with_overflow(T)(T lhs, T rhs);
-
-
-// Signed and unsigned multiplication
-pragma(intrinsic, "llvm.smul.with.overflow.i#")
- OverflowRet!(T) llvm_smul_with_overflow(T)(T lhs, T rhs);
-
-/* Note: LLVM documentations says:
- * Warning: 'llvm.umul.with.overflow' is badly broken.
- * It is actively being fixed, but it should not currently be used!
- *
- * See: http://llvm.org/docs/LangRef.html#int_umul_overflow
- */
-//pragma(intrinsic, "llvm.umul.with.overflow.i#")
-// OverflowRet!(T) llvm_umul_with_overflow(T)(T lhs, T rhs);
-
-
-//
-// GENERAL INTRINSICS
-//
-
-
-// This intrinsics is lowered to the target dependent trap instruction. If the
-// target does not have a trap instruction, this intrinsic will be lowered to
-// the call of the abort() function.
-
-pragma(intrinsic, "llvm.trap")
- void llvm_trap();
View
17 runtime/import/ldc/llvmasm.di
@@ -1,17 +0,0 @@
-module ldc.llvmasm;
-
-struct __asmtuple_t(T...)
-{
- T v;
-}
-
-pragma(llvm_inline_asm)
-{
- void __asm( )(char[] asmcode, char[] constraints, ...);
- T __asm(T)(char[] asmcode, char[] constraints, ...);
-
- template __asmtuple(T...)
- {
- __asmtuple_t!(T) __asmtuple(char[] asmcode, char[] constraints, ...);
- }
-}
View
414 runtime/internal/aApply.d
@@ -1,414 +0,0 @@
-/**
- * Part of the D programming language runtime library.
- */
-
-/*
- * Copyright (C) 2004-2006 by Digital Mars, www.digitalmars.com
- * Written by Walter Bright
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, in both source and binary form, subject to the following
- * restrictions:
- *
- * o The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * o Altered source versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- * o This notice may not be removed or altered from any source
- * distribution.
- */
-
-/*
- * Modified by Sean Kelly <sean@f4.ca> for use with Tango.
- */
-
-/* This code handles decoding UTF strings for foreach loops.
- * There are 6 combinations of conversions between char, wchar,
- * and dchar, and 2 of each of those.
- */
-
-private import util.utf;
-
-//debug = apply;
-debug(apply)
-{
- extern(C) int printf(char*, ...);
-}
-
-/**********************************************
- */
-
-// dg is D, but _aApplycd() is C
-extern (D) typedef int delegate(void *) dg_t;
-
-extern (C) int _aApplycd1(char[] aa, dg_t dg)
-{ int result;
- size_t i;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplycd1(), len = %d\n", len);
- for (i = 0; i < len; )
- { dchar d;
-
- d = aa[i];
- if (d & 0x80)
- d = decode(aa, i);
- else
- i++;
- result = dg(cast(void *)&d);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplywd1(wchar[] aa, dg_t dg)
-{ int result;
- size_t i;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplywd1(), len = %d\n", len);
- for (i = 0; i < len; )
- { dchar d;
-
- d = aa[i];
- if (d & ~0x7F)
- d = decode(aa, i);
- else
- i++;
- result = dg(cast(void *)&d);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplycw1(char[] aa, dg_t dg)
-{ int result;
- size_t i;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplycw1(), len = %d\n", len);
- for (i = 0; i < len; )
- { dchar d;
- wchar w;
-
- w = aa[i];
- if (w & 0x80)
- { d = decode(aa, i);
- if (d <= 0xFFFF)
- w = cast(wchar) d;
- else
- {
- w = cast(wchar)((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
- result = dg(cast(void *)&w);
- if (result)
- break;
- w = cast(wchar)(((d - 0x10000) & 0x3FF) + 0xDC00);
- }
- }
- else
- i++;
- result = dg(cast(void *)&w);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplywc1(wchar[] aa, dg_t dg)
-{ int result;
- size_t i;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplywc1(), len = %d\n", len);
- for (i = 0; i < len; )
- { dchar d;
- wchar w;
- char c;
-
- w = aa[i];
- if (w & ~0x7F)
- {
- char[4] buf;
-
- d = decode(aa, i);
- auto b = toUTF8(buf, d);
- foreach (char c2; b)
- {
- result = dg(cast(void *)&c2);
- if (result)
- return result;
- }
- continue;
- }
- else
- { c = cast(char)w;
- i++;
- }
- result = dg(cast(void *)&c);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplydc1(dchar[] aa, dg_t dg)
-{ int result;
-
- debug(apply) printf("_aApplydc1(), len = %d\n", aa.length);
- foreach (dchar d; aa)
- {
- char c;
-
- if (d & ~0x7F)
- {
- char[4] buf;
-
- auto b = toUTF8(buf, d);
- foreach (char c2; b)
- {
- result = dg(cast(void *)&c2);
- if (result)
- return result;
- }
- continue;
- }
- else
- {
- c = cast(char)d;
- }
- result = dg(cast(void *)&c);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplydw1(dchar[] aa, dg_t dg)
-{ int result;
-
- debug(apply) printf("_aApplydw1(), len = %d\n", aa.length);
- foreach (dchar d; aa)
- {
- wchar w;
-
- if (d <= 0xFFFF)
- w = cast(wchar) d;
- else
- {
- w = cast(wchar)((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
- result = dg(cast(void *)&w);
- if (result)
- break;
- w = cast(wchar)(((d - 0x10000) & 0x3FF) + 0xDC00);
- }
- result = dg(cast(void *)&w);
- if (result)
- break;
- }
- return result;
-}
-
-
-/****************************************************************************/
-
-// dg is D, but _aApplycd2() is C
-extern (D) typedef int delegate(void *, void *) dg2_t;
-
-extern (C) int _aApplycd2(char[] aa, dg2_t dg)
-{ int result;
- size_t i;
- size_t n;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplycd2(), len = %d\n", len);
- for (i = 0; i < len; i += n)
- { dchar d;
-
- d = aa[i];
- if (d & 0x80)
- {
- n = i;
- d = decode(aa, n);
- n -= i;
- }
- else
- n = 1;
- result = dg(&i, cast(void *)&d);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplywd2(wchar[] aa, dg2_t dg)
-{ int result;
- size_t i;
- size_t n;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplywd2(), len = %d\n", len);
- for (i = 0; i < len; i += n)
- { dchar d;
-
- d = aa[i];
- if (d & ~0x7F)
- {
- n = i;
- d = decode(aa, n);
- n -= i;
- }
- else
- n = 1;
- result = dg(&i, cast(void *)&d);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplycw2(char[] aa, dg2_t dg)
-{ int result;
- size_t i;
- size_t n;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplycw2(), len = %d\n", len);
- for (i = 0; i < len; i += n)
- { dchar d;
- wchar w;
-
- w = aa[i];
- if (w & 0x80)
- { n = i;
- d = decode(aa, n);
- n -= i;
- if (d <= 0xFFFF)
- w = cast(wchar) d;
- else
- {
- w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
- result = dg(&i, cast(void *)&w);
- if (result)
- break;
- w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
- }
- }
- else
- n = 1;
- result = dg(&i, cast(void *)&w);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplywc2(wchar[] aa, dg2_t dg)
-{ int result;
- size_t i;
- size_t n;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplywc2(), len = %d\n", len);
- for (i = 0; i < len; i += n)
- { dchar d;
- wchar w;
- char c;
-
- w = aa[i];
- if (w & ~0x7F)
- {
- char[4] buf;
-
- n = i;
- d = decode(aa, n);
- n -= i;
- auto b = toUTF8(buf, d);
- foreach (char c2; b)
- {
- result = dg(&i, cast(void *)&c2);
- if (result)
- return result;
- }
- continue;
- }
- else
- { c = cast(char)w;
- n = 1;
- }
- result = dg(&i, cast(void *)&c);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplydc2(dchar[] aa, dg2_t dg)
-{ int result;
- size_t i;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplydc2(), len = %d\n", len);
- for (i = 0; i < len; i++)
- { dchar d;
- char c;
-
- d = aa[i];
- debug(apply) printf("d = %u\n", d);
- if (d & ~0x7F)
- {
- char[4] buf;
-
- auto b = toUTF8(buf, d);
- foreach (char c2; b)
- {
- debug(apply) printf("c2 = %d\n", c2);
- result = dg(&i, cast(void *)&c2);
- if (result)
- return result;
- }
- continue;
- }
- else
- { c = cast(char)d;
- }
- result = dg(&i, cast(void *)&c);
- if (result)
- break;
- }
- return result;
-}
-
-extern (C) int _aApplydw2(dchar[] aa, dg2_t dg)
-{ int result;
-
- debug(apply) printf("_aApplydw2(), len = %d\n", aa.length);
- foreach (size_t i, dchar d; aa)
- {
- wchar w;
- auto j = i;
-
- if (d <= 0xFFFF)
- w = cast(wchar) d;
- else
- {
- w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
- result = dg(&j, cast(void *)&w);
- if (result)
- break;
- w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
- }
- result = dg(&j, cast(void *)&w);
- if (result)
- break;
- }
- return result;
-}
View
975 runtime/internal/aApplyR.d
@@ -1,975 +0,0 @@
-
-/**
- * Part of the D programming language runtime library.
- */
-
-/*
- * Copyright (C) 2004-2006 by Digital Mars, www.digitalmars.com
- * Written by Walter Bright
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, in both source and binary form, subject to the following
- * restrictions:
- *
- * o The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * o Altered source versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- * o This notice may not be removed or altered from any source
- * distribution.
- */
-
-/*
- * Modified by Sean Kelly <sean@f4.ca> for use with Tango.
- */
-
-/* This code handles decoding UTF strings for foreach_reverse loops.
- * There are 6 combinations of conversions between char, wchar,
- * and dchar, and 2 of each of those.
- */
-
-private import util.utf;
-
-/**********************************************/
-/* 1 argument versions */
-
-// dg is D, but _aApplyRcd() is C
-extern (D) typedef int delegate(void *) dg_t;
-
-extern (C) int _aApplyRcd1(in char[] aa, dg_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRcd1(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d;
-
- i--;
- d = aa[i];
- if (d & 0x80)
- { char c = cast(char)d;
- uint j;
- uint m = 0x3F;
- d = 0;
- while ((c & 0xC0) != 0xC0)
- { if (i == 0)
- onUnicodeError("Invalid UTF-8 sequence", 0);
- i--;
- d |= (c & 0x3F) << j;
- j += 6;
- m >>= 1;
- c = aa[i];
- }
- d |= (c & m) << j;
- }
- result = dg(cast(void *)&d);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRcd1.unittest\n");
-
- char[] s = "hello"c;
- int i;
-
- foreach_reverse(dchar d; s)
- {
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(dchar d; s)
- {
- //printf("i = %d, d = %x\n", i, d);
- switch (i)
- {
- case 0: assert(d == 'b'); break;
- case 1: assert(d == '\U00100456'); break;
- case 2: assert(d == '\u1234'); break;
- case 3: assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 4);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRwd1(in wchar[] aa, dg_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRwd1(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d;
-
- i--;
- d = aa[i];
- if (d >= 0xDC00 && d <= 0xDFFF)
- { if (i == 0)
- onUnicodeError("Invalid UTF-16 sequence", 0);
- i--;
- d = ((aa[i] - 0xD7C0) << 10) + (d - 0xDC00);
- }
- result = dg(cast(void *)&d);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRwd1.unittest\n");
-
- wchar[] s = "hello"w;
- int i;
-
- foreach_reverse(dchar d; s)
- {
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(dchar d; s)
- {
- //printf("i = %d, d = %x\n", i, d);
- switch (i)
- {
- case 0: assert(d == 'b'); break;
- case 1: assert(d == '\U00100456'); break;
- case 2: assert(d == '\u1234'); break;
- case 3: assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 4);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRcw1(in char[] aa, dg_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRcw1(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d;
- wchar w;
-
- i--;
- w = aa[i];
- if (w & 0x80)
- { char c = cast(char)w;
- uint j;
- uint m = 0x3F;
- d = 0;
- while ((c & 0xC0) != 0xC0)
- { if (i == 0)
- onUnicodeError("Invalid UTF-8 sequence", 0);
- i--;
- d |= (c & 0x3F) << j;
- j += 6;
- m >>= 1;
- c = aa[i];
- }
- d |= (c & m) << j;
-
- if (d <= 0xFFFF)
- w = cast(wchar) d;
- else
- {
- w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
- result = dg(cast(void *)&w);
- if (result)
- break;
- w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
- }
- }
- result = dg(cast(void *)&w);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRcw1.unittest\n");
-
- char[] s = "hello"c;
- int i;
-
- foreach_reverse(wchar d; s)
- {
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(wchar d; s)
- {
- //printf("i = %d, d = %x\n", i, d);
- switch (i)
- {
- case 0: assert(d == 'b'); break;
- case 1: assert(d == 0xDBC1); break;
- case 2: assert(d == 0xDC56); break;
- case 3: assert(d == 0x1234); break;
- case 4: assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRwc1(in wchar[] aa, dg_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRwc1(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d;
- char c;
-
- i--;
- d = aa[i];
- if (d >= 0xDC00 && d <= 0xDFFF)
- { if (i == 0)
- onUnicodeError("Invalid UTF-16 sequence", 0);
- i--;
- d = ((aa[i] - 0xD7C0) << 10) + (d - 0xDC00);
- }
-
- if (d & ~0x7F)
- {
- char[4] buf;
-
- auto b = toUTF8(buf, d);
- foreach (char c2; b)
- {
- result = dg(cast(void *)&c2);
- if (result)
- return result;
- }
- continue;
- }
- c = cast(char)d;
- result = dg(cast(void *)&c);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRwc1.unittest\n");
-
- wchar[] s = "hello"w;
- int i;
-
- foreach_reverse(char d; s)
- {
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(char d; s)
- {
- //printf("i = %d, d = %x\n", i, d);
- switch (i)
- {
- case 0: assert(d == 'b'); break;
- case 1: assert(d == 0xF4); break;
- case 2: assert(d == 0x80); break;
- case 3: assert(d == 0x91); break;
- case 4: assert(d == 0x96); break;
- case 5: assert(d == 0xE1); break;
- case 6: assert(d == 0x88); break;
- case 7: assert(d == 0xB4); break;
- case 8: assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 9);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRdc1(in dchar[] aa, dg_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRdc1(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0;)
- { dchar d = aa[--i];
- char c;
-
- if (d & ~0x7F)
- {
- char[4] buf;
-
- auto b = toUTF8(buf, d);
- foreach (char c2; b)
- {
- result = dg(cast(void *)&c2);
- if (result)
- return result;
- }
- continue;
- }
- else
- {
- c = cast(char)d;
- }
- result = dg(cast(void *)&c);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRdc1.unittest\n");
-
- dchar[] s = "hello"d;
- int i;
-
- foreach_reverse(char d; s)
- {
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(char d; s)
- {
- //printf("i = %d, d = %x\n", i, d);
- switch (i)
- {
- case 0: assert(d == 'b'); break;
- case 1: assert(d == 0xF4); break;
- case 2: assert(d == 0x80); break;
- case 3: assert(d == 0x91); break;
- case 4: assert(d == 0x96); break;
- case 5: assert(d == 0xE1); break;
- case 6: assert(d == 0x88); break;
- case 7: assert(d == 0xB4); break;
- case 8: assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 9);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRdw1(in dchar[] aa, dg_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRdw1(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d = aa[--i];
- wchar w;
-
- if (d <= 0xFFFF)
- w = cast(wchar) d;
- else
- {
- w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
- result = dg(cast(void *)&w);
- if (result)
- break;
- w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
- }
- result = dg(cast(void *)&w);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRdw1.unittest\n");
-
- dchar[] s = "hello"d;
- int i;
-
- foreach_reverse(wchar d; s)
- {
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(wchar d; s)
- {
- //printf("i = %d, d = %x\n", i, d);
- switch (i)
- {
- case 0: assert(d == 'b'); break;
- case 1: assert(d == 0xDBC1); break;
- case 2: assert(d == 0xDC56); break;
- case 3: assert(d == 0x1234); break;
- case 4: assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-}
-
-
-/****************************************************************************/
-/* 2 argument versions */
-
-// dg is D, but _aApplyRcd2() is C
-extern (D) typedef int delegate(void *, void *) dg2_t;
-
-extern (C) int _aApplyRcd2(in char[] aa, dg2_t dg)
-{ int result;
- size_t i;
- size_t len = aa.length;
-
- debug(apply) printf("_aApplyRcd2(), len = %d\n", len);
- for (i = len; i != 0; )
- { dchar d;
-
- i--;
- d = aa[i];
- if (d & 0x80)
- { char c = cast(char)d;
- uint j;
- uint m = 0x3F;
- d = 0;
- while ((c & 0xC0) != 0xC0)
- { if (i == 0)
- onUnicodeError("Invalid UTF-8 sequence", 0);
- i--;
- d |= (c & 0x3F) << j;
- j += 6;
- m >>= 1;
- c = aa[i];
- }
- d |= (c & m) << j;
- }
- result = dg(&i, cast(void *)&d);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRcd2.unittest\n");
-
- char[] s = "hello"c;
- int i;
-
- foreach_reverse(k, dchar d; s)
- {
- assert(k == 4 - i);
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(k, dchar d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- switch (i)
- {
- case 0: assert(d == 'b'); assert(k == 8); break;
- case 1: assert(d == '\U00100456'); assert(k == 4); break;
- case 2: assert(d == '\u1234'); assert(k == 1); break;
- case 3: assert(d == 'a'); assert(k == 0); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 4);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRwd2(in wchar[] aa, dg2_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRwd2(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d;
-
- i--;
- d = aa[i];
- if (d >= 0xDC00 && d <= 0xDFFF)
- { if (i == 0)
- onUnicodeError("Invalid UTF-16 sequence", 0);
- i--;
- d = ((aa[i] - 0xD7C0) << 10) + (d - 0xDC00);
- }
- result = dg(&i, cast(void *)&d);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRwd2.unittest\n");
-
- wchar[] s = "hello"w;
- int i;
-
- foreach_reverse(k, dchar d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- assert(k == 4 - i);
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(k, dchar d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- switch (i)
- {
- case 0: assert(k == 4); assert(d == 'b'); break;
- case 1: assert(k == 2); assert(d == '\U00100456'); break;
- case 2: assert(k == 1); assert(d == '\u1234'); break;
- case 3: assert(k == 0); assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 4);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRcw2(in char[] aa, dg2_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRcw2(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d;
- wchar w;
-
- i--;
- w = aa[i];
- if (w & 0x80)
- { char c = cast(char)w;
- uint j;
- uint m = 0x3F;
- d = 0;
- while ((c & 0xC0) != 0xC0)
- { if (i == 0)
- onUnicodeError("Invalid UTF-8 sequence", 0);
- i--;
- d |= (c & 0x3F) << j;
- j += 6;
- m >>= 1;
- c = aa[i];
- }
- d |= (c & m) << j;
-
- if (d <= 0xFFFF)
- w = cast(wchar) d;
- else
- {
- w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
- result = dg(&i, cast(void *)&w);
- if (result)
- break;
- w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
- }
- }
- result = dg(&i, cast(void *)&w);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRcw2.unittest\n");
-
- char[] s = "hello"c;
- int i;
-
- foreach_reverse(k, wchar d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- assert(k == 4 - i);
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(k, wchar d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- switch (i)
- {
- case 0: assert(k == 8); assert(d == 'b'); break;
- case 1: assert(k == 4); assert(d == 0xDBC1); break;
- case 2: assert(k == 4); assert(d == 0xDC56); break;
- case 3: assert(k == 1); assert(d == 0x1234); break;
- case 4: assert(k == 0); assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRwc2(in wchar[] aa, dg2_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRwc2(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d;
- char c;
-
- i--;
- d = aa[i];
- if (d >= 0xDC00 && d <= 0xDFFF)
- { if (i == 0)
- onUnicodeError("Invalid UTF-16 sequence", 0);
- i--;
- d = ((aa[i] - 0xD7C0) << 10) + (d - 0xDC00);
- }
-
- if (d & ~0x7F)
- {
- char[4] buf;
-
- auto b = toUTF8(buf, d);
- foreach (char c2; b)
- {
- result = dg(&i, cast(void *)&c2);
- if (result)
- return result;
- }
- continue;
- }
- c = cast(char)d;
- result = dg(&i, cast(void *)&c);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRwc2.unittest\n");
-
- wchar[] s = "hello"w;
- int i;
-
- foreach_reverse(k, char d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- assert(k == 4 - i);
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(k, char d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- switch (i)
- {
- case 0: assert(k == 4); assert(d == 'b'); break;
- case 1: assert(k == 2); assert(d == 0xF4); break;
- case 2: assert(k == 2); assert(d == 0x80); break;
- case 3: assert(k == 2); assert(d == 0x91); break;
- case 4: assert(k == 2); assert(d == 0x96); break;
- case 5: assert(k == 1); assert(d == 0xE1); break;
- case 6: assert(k == 1); assert(d == 0x88); break;
- case 7: assert(k == 1); assert(d == 0xB4); break;
- case 8: assert(k == 0); assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 9);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRdc2(in dchar[] aa, dg2_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRdc2(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d = aa[--i];
- char c;
-
- if (d & ~0x7F)
- {
- char[4] buf;
-
- auto b = toUTF8(buf, d);
- foreach (char c2; b)
- {
- result = dg(&i, cast(void *)&c2);
- if (result)
- return result;
- }
- continue;
- }
- else
- { c = cast(char)d;
- }
- result = dg(&i, cast(void *)&c);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRdc2.unittest\n");
-
- dchar[] s = "hello"d;
- int i;
-
- foreach_reverse(k, char d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- assert(k == 4 - i);
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(k, char d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- switch (i)
- {
- case 0: assert(k == 3); assert(d == 'b'); break;
- case 1: assert(k == 2); assert(d == 0xF4); break;
- case 2: assert(k == 2); assert(d == 0x80); break;
- case 3: assert(k == 2); assert(d == 0x91); break;
- case 4: assert(k == 2); assert(d == 0x96); break;
- case 5: assert(k == 1); assert(d == 0xE1); break;
- case 6: assert(k == 1); assert(d == 0x88); break;
- case 7: assert(k == 1); assert(d == 0xB4); break;
- case 8: assert(k == 0); assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 9);
-}
-
-/*****************************/
-
-extern (C) int _aApplyRdw2(in dchar[] aa, dg2_t dg)
-{ int result;
-
- debug(apply) printf("_aApplyRdw2(), len = %d\n", aa.length);
- for (size_t i = aa.length; i != 0; )
- { dchar d = aa[--i];
- wchar w;
-
- if (d <= 0xFFFF)
- w = cast(wchar) d;
- else
- {
- w = cast(wchar) ((((d - 0x10000) >> 10) & 0x3FF) + 0xD800);
- result = dg(&i, cast(void *)&w);
- if (result)
- break;
- w = cast(wchar) (((d - 0x10000) & 0x3FF) + 0xDC00);
- }
- result = dg(&i, cast(void *)&w);
- if (result)
- break;
- }
- return result;
-}
-
-unittest
-{
- debug(apply) printf("_aApplyRdw2.unittest\n");
-
- dchar[] s = "hello"d;
- int i;
-
- foreach_reverse(k, wchar d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- assert(k == 4 - i);
- switch (i)
- {
- case 0: assert(d == 'o'); break;
- case 1: assert(d == 'l'); break;
- case 2: assert(d == 'l'); break;
- case 3: assert(d == 'e'); break;
- case 4: assert(d == 'h'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-
- s = "a\u1234\U00100456b";
- i = 0;
- foreach_reverse(k, wchar d; s)
- {
- //printf("i = %d, k = %d, d = %x\n", i, k, d);
- switch (i)
- {
- case 0: assert(k == 3); assert(d == 'b'); break;
- case 1: assert(k == 2); assert(d == 0xDBC1); break;
- case 2: assert(k == 2); assert(d == 0xDC56); break;
- case 3: assert(k == 1); assert(d == 0x1234); break;
- case 4: assert(k == 0); assert(d == 'a'); break;
- default: assert(0);
- }
- i++;
- }
- assert(i == 5);
-}
-
-
View
798 runtime/internal/aaA.d
@@ -1,798 +0,0 @@
-//_ aaA.d
-
-/**
- * Part of the D programming language runtime library.
- * Implementation of associative arrays.
- */
-
-/*
- * Copyright (C) 2000-2008 by Digital Mars, www.digitalmars.com
- * Written by Walter Bright
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * o The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software
- * in a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * o Altered source versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- * o This notice may not be removed or altered from any source
- * distribution.
- */
-
-/*
- * Modified by Sean Kelly <sean@f4.ca> for use with Tango.
- * Modified by Tomas Lindquist Olsen <tomas@famolsen.dk> for use with LDC.
- */
-
-private
-{
- import tango.stdc.stdarg;
- import tango.stdc.string;
-
- enum BlkAttr : uint
- {
- FINALIZE = 0b0000_0001,
- NO_SCAN = 0b0000_0010,
- NO_MOVE = 0b0000_0100,
- ALL_BITS = 0b1111_1111
- }
-
- extern (C) void* gc_malloc( size_t sz, uint ba = 0 );
- extern (C) void* gc_calloc( size_t sz, uint ba = 0 );
- extern (C) void gc_free( void* p );
-}
-
-// Auto-rehash and pre-allocate - Dave Fladebo
-
-static size_t[] prime_list = [
- 97UL, 389UL,
- 1_543UL, 6_151UL,
- 24_593UL, 98_317UL,
- 393_241UL, 1_572_869UL,
- 6_291_469UL, 25_165_843UL,
- 100_663_319UL, 402_653_189UL,
- 1_610_612_741UL, 4_294_967_291UL,
-// 8_589_934_513UL, 17_179_869_143UL
-];
-
-struct aaA
-{
- aaA *left;
- aaA *right;
- hash_t hash;
- /* key */
- /* value */
-}
-
-struct BB
-{
- aaA*[] b;
- size_t nodes; // total number of aaA nodes
- TypeInfo keyti; // TODO: replace this with TypeInfo_AssociativeArray when available in _aaGet()
-}
-
-/* This is the type actually seen by the programmer, although
- * it is completely opaque.
- */