mirror of
https://github.com/love2d/love-android.git
synced 2026-08-13 00:50:56 +02:00
Compare commits
308 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 18c9b3c401 | |||
| face22cff4 | |||
| 8b93b1eea2 | |||
| 29821438ad | |||
| a199d54b50 | |||
| 61ef9802a3 | |||
| ee81c4262d | |||
| 4be53bca65 | |||
| c89ac83e37 | |||
| 29e49d9048 | |||
| 8c701dd3a4 | |||
| 59a5fcb875 | |||
| 05e193ddbd | |||
| 0380160775 | |||
| 376ae96cb1 | |||
| 8186794a03 | |||
| 54b29fca4f | |||
| 45507c5282 | |||
| f18cf70c15 | |||
| 5df17ba075 | |||
| 5090a072b2 | |||
| 117bba5ff2 | |||
| 78e88a7473 | |||
| 2529265eed | |||
| a2c79d95e0 | |||
| f761e43904 | |||
| cd6463b4e4 | |||
| 9298bed843 | |||
| 94d31aefc1 | |||
| 8d71234114 | |||
| 799956e002 | |||
| f8d0890519 | |||
| c065fe9e56 | |||
| 77c7570f55 | |||
| 6d5d8c4540 | |||
| 456273ebf0 | |||
| 7c48033960 | |||
| b8beb8a1f4 | |||
| c1399fc44a | |||
| 077c1a350b | |||
| 40ec52368b | |||
| 605ddefd0e | |||
| 2a23cbd16d | |||
| 0ebc4d9271 | |||
| 07149c0ba8 | |||
| 288f005d86 | |||
| 49ad4632b6 | |||
| 6eafa708f9 | |||
| 53d24a1b5f | |||
| 3b7407ab34 | |||
| e203f7ae4c | |||
| 1349f27bd8 | |||
| 9a11b88572 | |||
| f88e0ba4b9 | |||
| 2fd01541c2 | |||
| fc85623f10 | |||
| 692ce8bb51 | |||
| 0394a380c4 | |||
| 0000c326a8 | |||
| 34e88d43ae | |||
| 94c8a99ddc | |||
| 1ea86d3305 | |||
| 696fae730c | |||
| a19404a902 | |||
| e2c44417d1 | |||
| e23fb2c8ea | |||
| 4de76a9c52 | |||
| 973f9eef89 | |||
| 0ac43aa717 | |||
| c186a70b14 | |||
| 7fbf155d82 | |||
| 7ad34c64f4 | |||
| 3df1807c6f | |||
| 29a493a54b | |||
| c979f65152 | |||
| 75306e8e63 | |||
| 1dba069683 | |||
| ec8b710a93 | |||
| 408778fb8f | |||
| 45ae52f55e | |||
| f8241c1b65 | |||
| 91295b7506 | |||
| 4d8f4f70ce | |||
| ebd4a0ad4f | |||
| f40577c9cb | |||
| ac443d7e2f | |||
| fd60978b7b | |||
| 8c7772cfa4 | |||
| 6ed3ba3810 | |||
| 21ff4b2188 | |||
| ba269a5062 | |||
| 4ffea15ffc | |||
| 74d83c0c13 | |||
| 906a7cc00b | |||
| f12ab60594 | |||
| 5f4aeb2d71 | |||
| fb34e99d9a | |||
| d62a4df5ac | |||
| ad5db40a9d | |||
| 406d0c04e2 | |||
| a00675c4cc | |||
| 0afdf271a2 | |||
| 7ebcf9494e | |||
| cff1a295a6 | |||
| 234bc83aa2 | |||
| 84dc89e264 | |||
| a22628bc1b | |||
| 487f00201e | |||
| 1fe6d7b640 | |||
| 204945586e | |||
| 004ccf4f9c | |||
| f68cf2fcc4 | |||
| f6c360c809 | |||
| 391429367d | |||
| baa595bd51 | |||
| 957330d722 | |||
| ecaf3f7f45 | |||
| b3db9d4839 | |||
| a1aca69aa4 | |||
| 646de828b9 | |||
| 0ffa7f7db7 | |||
| 7d7e1cb1f9 | |||
| ee59b69e01 | |||
| 0ac0e39287 | |||
| 49d7b402a7 | |||
| 529b897fed | |||
| 7ef92ea876 | |||
| 40b2aa6e6a | |||
| 7c8b022dcb | |||
| dbdefdd86a | |||
| c931228238 | |||
| 15474cab41 | |||
| 2a0c579ebf | |||
| af039516c0 | |||
| cc457787f4 | |||
| 76230b01f9 | |||
| 3c922b0ae8 | |||
| ab888ac39f | |||
| fdb360a557 | |||
| d32e6ada77 | |||
| 46d624851b | |||
| 00cfe30282 | |||
| 0cf41c2792 | |||
| 803786eee9 | |||
| c025e5eab4 | |||
| 35cd9f1900 | |||
| 70f63954ed | |||
| f87d73671f | |||
| 967840db16 | |||
| 6dedec28a2 | |||
| 2358b45c27 | |||
| 08b116c09f | |||
| e9a3b2ac59 | |||
| 7345a01f56 | |||
| 42093cfbe9 | |||
| 8244228004 | |||
| 7459285690 | |||
| 7aaeb1485e | |||
| 5e410bca8e | |||
| 19e0b12363 | |||
| 24387a8450 | |||
| 962c894908 | |||
| 26a6c423f9 | |||
| 08d51fbf28 | |||
| eac5db7e10 | |||
| 28d2d92645 | |||
| 66685a2ade | |||
| 8f5ee4a05e | |||
| 686e1d5f3e | |||
| 7e877716d6 | |||
| ec5f068b19 | |||
| 8308a524bc | |||
| 4439a193d6 | |||
| 9cbddc2f5e | |||
| f3dd769e98 | |||
| c91dbb6957 | |||
| 198c2d28de | |||
| 357a7237a4 | |||
| 1924bbdeeb | |||
| d783f5afa1 | |||
| 7eb7db1a85 | |||
| 8af8dffad4 | |||
| a0efc89a7d | |||
| c30e788393 | |||
| 168357e1ad | |||
| d6f1d8bd70 | |||
| 3cfecd46d9 | |||
| f31760c445 | |||
| d0f866e4b0 | |||
| 542c029666 | |||
| 31cd05551e | |||
| 42f6beaa7e | |||
| 36216c16be | |||
| 013df025d0 | |||
| 535a8256ee | |||
| b732d6cc12 | |||
| 54215b7ce4 | |||
| fd9e9758a9 | |||
| f46115e794 | |||
| 29a3e4b566 | |||
| 02dc18a587 | |||
| a034220b10 | |||
| 72b2fcd4eb | |||
| b20f7e7302 | |||
| 6b1fae429b | |||
| 4ec2e26985 | |||
| 8df94d2a8a | |||
| 70eef137ae | |||
| 4f11bd0e7b | |||
| 5048f3ff8c | |||
| 66f600b5ab | |||
| 659b312121 | |||
| b875fffedb | |||
| 45b1fc2509 | |||
| c6ac06c366 | |||
| abb819335b | |||
| aba2f47b31 | |||
| ea459a43da | |||
| 6110de0fa8 | |||
| 8f20cb7cc5 | |||
| b25af54383 | |||
| c27f19c141 | |||
| d1ad6cc5a3 | |||
| afe33f06d2 | |||
| 70cb26bb2a | |||
| 8cb7bac09f | |||
| 49265f0596 | |||
| 1d29da2d80 | |||
| 6459889d32 | |||
| 6be242ef03 | |||
| 97d9154e48 | |||
| c40250e565 | |||
| 684adff826 | |||
| ec9be8a383 | |||
| d637b5c11d | |||
| adc4042d8b | |||
| e96eef4435 | |||
| 8acfb8d91a | |||
| cc829bdd1e | |||
| 7593d64761 | |||
| f09239788a | |||
| c0fd9a6e1b | |||
| 539ca8d4f2 | |||
| fab725ad8b | |||
| 5f6fa8c2b5 | |||
| 4c2846f4bb | |||
| cb2c852f58 | |||
| 60a58f9240 | |||
| 5849e8d369 | |||
| 1703660617 | |||
| 0db55463c9 | |||
| 288b25c585 | |||
| a5284dccf6 | |||
| 8069dc02c6 | |||
| 0bde453b2e | |||
| 667c4750ea | |||
| 38727b5c25 | |||
| 288a851a65 | |||
| 5e3579f680 | |||
| 1dd859c9d1 | |||
| 53d45533e0 | |||
| 3f13dc653f | |||
| 9e7e31ba05 | |||
| 3f268ebedf | |||
| 8fb02e11ab | |||
| 89c54f9712 | |||
| 606da6d0ae | |||
| 52d505624d | |||
| 89c9baf274 | |||
| e4e1a0f59b | |||
| 00052d8067 | |||
| de93ded9bf | |||
| 2da2da2652 | |||
| bfae01300e | |||
| 0b8dd90114 | |||
| 3cabe641d6 | |||
| 351e224815 | |||
| 89c2c014b2 | |||
| c3a21270ab | |||
| 597fad8034 | |||
| bf07caef09 | |||
| c9bb6ec3d6 | |||
| 007b0fc3f0 | |||
| b86319c0f4 | |||
| 9a688b9b37 | |||
| 405c79a8fe | |||
| cf30c31234 | |||
| 175f6f23ae | |||
| f0fa37f4ad | |||
| 33d979caf6 | |||
| 4c481f9933 | |||
| 64100eecfe | |||
| 7a6e597b5a | |||
| 4b6c1b51c9 | |||
| 35f95a0c58 | |||
| 0908325b5b | |||
| f3be0275e6 | |||
| 72cb4722b6 | |||
| 966e7ffd6c | |||
| 24866c5e81 | |||
| 2c932240e4 | |||
| 338f28f6d7 | |||
| ce866b214c | |||
| db9c6925bb | |||
| 2b8c22872f | |||
| 2b99a488d3 | |||
| c8c7bc5853 | |||
| f475455477 |
+13
-1
@@ -12,5 +12,17 @@ local.properties
|
||||
*.o
|
||||
*.so
|
||||
*.a
|
||||
*.orig
|
||||
*.rej
|
||||
|
||||
!jni/LuaJIT-2.0.1/src/libluajit.a
|
||||
|
||||
# Downloaded gradle wrapper
|
||||
.gradle
|
||||
|
||||
# Android Studio project files
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# Gradle build files
|
||||
build
|
||||
.externalNativeBuild
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "love/src/jni/love"]
|
||||
path = love/src/jni/love
|
||||
url = https://github.com/love2d/love
|
||||
@@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>love_android_sdl2</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/[Löve] Generate Internal Scripts.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/ndk-build.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="org.love2d.android"
|
||||
android:versionCode="7"
|
||||
android:versionName="0.9.0-alpha7"
|
||||
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="Löve for Android"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||
<activity
|
||||
android:name="GameActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="Löve for Android"
|
||||
android:screenOrientation="landscape" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<!-- Android 2.3.3 -->
|
||||
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="18" />
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
||||
@@ -1,39 +1,205 @@
|
||||
Android Port of LÖVE, the awesome 2D game engine LÖVE (http://love2d.org)
|
||||
Copyright (c) 2013 Martin Felis <martin@fysx.org>
|
||||
Copyright (c) 2013-2017 Martin Felis <martin@fysx.org>
|
||||
|
||||
Instructions:
|
||||
-------------
|
||||
|
||||
Install the Android NDK and the Android SDK with SDK API 12 and run
|
||||
For detailed instructions please refer to the wiki at [https://bitbucket.org/MartinFelis/love-android-sdl2/wiki/Home](https://bitbucket.org/MartinFelis/love-android-sdl2/wiki/Home).
|
||||
|
||||
ndk-build
|
||||
Download:
|
||||
---------
|
||||
|
||||
and after that
|
||||
You can download pre-built Android packages from
|
||||
[https://bitbucket.org/rude/love/downloads](https://bitbucket.org/rude/love/downloads)
|
||||
that allow you to run .love files by opening them using a file manager of
|
||||
your choice.
|
||||
|
||||
ant debug
|
||||
Quick Start:
|
||||
------------
|
||||
|
||||
in the root folder of this project or load the project using Eclipse and
|
||||
compile/run it using Eclipse.
|
||||
Install the Android NDK and the Android SDK with SDK API 28, set the
|
||||
environment variables:
|
||||
|
||||
This should give you a .apk file in the bin/ subdirectory that you can then
|
||||
install on your phone.
|
||||
* `ANDROID_HOME` to your Android SDK location.
|
||||
|
||||
* `ANDROID_NDK_HOME` to your Android NDK location. NDK r16 or later; r19 also work.
|
||||
|
||||
ndk.dir=/opt/android-ndk
|
||||
sdk.dir=/opt/android-sdk
|
||||
|
||||
(you may have to adjust the paths to the install directories of the Android
|
||||
SDK and Android NDK on your system) and run
|
||||
|
||||
./gradlew assemble
|
||||
|
||||
in the root folder of this project. This should give you a .apk file in the
|
||||
app/build/outputs/apk/ subdirectory that you can then install on your phone.
|
||||
|
||||
Alternatively, you can install Android Studio. After opening it for the first time,
|
||||
open it's SDK Manager and on the tab "SDK Tools", select NDK. After that, open the
|
||||
repository root.
|
||||
|
||||
|
||||
Bugs:
|
||||
-----
|
||||
|
||||
Bugs and feature requests should be reported to the issue tracker at https://bitbucket.org/MartinFelis/love-android-sdl2/issues?status=new&status=open
|
||||
|
||||
Changelog:
|
||||
----------
|
||||
|
||||
11.2:
|
||||
|
||||
* Contains all relevant changes for desktop LÖVE 11.2.
|
||||
* Added support for ARM64 devices to comply with Play Store requirements.
|
||||
* Fixed `love.system.openURL` crashing in some cases.
|
||||
* Changed target SDK to 28 so it comply with Play Store requirements.
|
||||
|
||||
0.10.2:
|
||||
|
||||
* Contains all relevant changes for desktop LÖVE 0.10.2.
|
||||
* Upgrade of SDL2 to 2.0.5 (fixes an issue with the accelerometer)
|
||||
|
||||
0.10.1:
|
||||
|
||||
This release contains all bugfixes of the desktop 0.10.1 release. Android
|
||||
specific fixes are:
|
||||
* Added a new love.conf flag t.externalstorage, which determines whether files are saved in internal or external storage on Android devices.
|
||||
* Fixed audio on Android to pause when the app is inactive, and resume when the app becomes active again.
|
||||
* Fixed a driver bug on some Android devices which caused all objects to show up as black.
|
||||
* Fixed love.graphics.clear(colortable) causing crashes on OpenGL ES 2 systems when a Canvas is active.
|
||||
* New icons
|
||||
|
||||
0.10.0:
|
||||
|
||||
* first official release!
|
||||
* Disabled JIT by default as it can cause performance problems. To enable JIT call jit.on()
|
||||
|
||||
0.10.0-alpha2:
|
||||
|
||||
* Update to the next love API 0.10.0 (not yet officially released)
|
||||
* Added building of libtheora
|
||||
* Updated LuaJIT from 2.0.1 to 2.1
|
||||
* Fixed a compatibility issue with Android 2.3 devices
|
||||
* Updated libogg from 1.3.2. to 1.3.5
|
||||
* Updated OpenAL to 1.17.0
|
||||
* Updated SDL2 to a dev version of 2.0.4
|
||||
|
||||
0.9.2a:
|
||||
|
||||
* Added bugfix for ParticleSystem:clone
|
||||
|
||||
0.9.2:
|
||||
|
||||
* updated API to match that of LÖVE 0.9.2
|
||||
* love.window.setFullscreen can be used to switch between regular and immersive mode without status and navbar
|
||||
* added loading of games by opening a main.lua file
|
||||
* quitting LÖVE now conforms to the Android application lifecycle
|
||||
* stop vibrator when app is paused
|
||||
* fixed battery drain by properly pausing OpenAL device
|
||||
* fixed printing of non-number and non-string values
|
||||
* fixed compilation of Android NDK r10
|
||||
* fixed compilation warnings concerning ```APP_PLATFORM```
|
||||
* old instance is shut down when opening a new game (note: it may crash when opening games at a high frequency, e.g. more than 2 per second)
|
||||
* updated OpenAL-Soft to version 1.16.0
|
||||
* updated to newer SDL version (f9244b2a151)
|
||||
|
||||
0.9.1b:
|
||||
|
||||
* added love.system.vibrate(seconds)
|
||||
* print statements are now redirected to logcat. Output is prefixed with "[LOVE] "
|
||||
* removed DevIL, libpng, libjpeg, libmng, and libtiff
|
||||
* pngs are loaded using lodepng and jpegs using libturbo-jpeg
|
||||
* repeatedly fixed a bug which caused Release builds to crash
|
||||
* update to latest mobile-common branch
|
||||
|
||||
0.9.1a:
|
||||
|
||||
* using latest SDL\_androidgl.c (fixes some random performance issues)
|
||||
* using latest love-android @ changeset 8659be0e75a3 (adds support for
|
||||
compressed textures)
|
||||
|
||||
0.9.1:
|
||||
|
||||
* uses 0.9.1 API
|
||||
* fixed crash on Moto G (and possibly other devices). This was a nasty bug that would just show a blue screen without an error message. The bug was resolved using the help of headchant
|
||||
* fixed loading of jpegs (it probably hasn't worked up to now)
|
||||
* fixed issues with looping over active touches. This fix was sponsored by slime!
|
||||
|
||||
beta2:
|
||||
|
||||
* fixed bug with canvases
|
||||
* fixed writing of files when no identity in conf.lua was set
|
||||
* added file association (somewhat experimental)
|
||||
|
||||
beta1:
|
||||
|
||||
* fixed nasty crash on startup bug
|
||||
* fixed love.filesystem.getDirectoryItems()
|
||||
|
||||
alpha9:
|
||||
|
||||
* Packaged games do not get duplicated for loading, instead are loaded from memory (!!!)
|
||||
* Using inofficial physfs 2.1
|
||||
* Removed love.android.getDisplayMetrics(), instead use love.window.getPixelScale()
|
||||
* Properly link LGPL libraries dynamically. Everything else is linked statically
|
||||
* Added an icon (design by @josefnpat)
|
||||
* Fixed crash on startup on OUYA (and possibly other devices)
|
||||
|
||||
alpha8:
|
||||
|
||||
* Exposing DisplayMetrics in love.android.getDisplayMetrics())
|
||||
* Accelerometer is now available as a joystick
|
||||
* enabled armv6 compilation (larger files, better compatibility with Tegra2 devices)
|
||||
* updated to latest mobile-common branch (including (very) basic multi-touch gesture tracking)
|
||||
* updated OpenAL from 1.13 to 1.15.1
|
||||
* updated jpeg library from 8c to 9a
|
||||
* updated lcms from 2.2 to 2.5
|
||||
* updated libogg from 1.3.0 to 1.3.1
|
||||
* updated libvorbis from 1.3.2 to 1.3.4
|
||||
* updated mpg123 from 1.13.4 to 1.17.0
|
||||
|
||||
alpha7:
|
||||
- love.system.getOS() now returns "Android"
|
||||
- hardware search key is reported as "search"
|
||||
- switched to mobile-common branch
|
||||
- using new love.touch module (love.touchpressed(id,x,y,p), love.touchmoved(id,x,y,p), love.touchmoved(id,x,y,p))
|
||||
- added LOVE_ANDROID define
|
||||
|
||||
* love.system.getOS() now returns "Android"
|
||||
* hardware search key is reported as "search"
|
||||
* switched to mobile-common branch
|
||||
* using new love.touch module (love.touchpressed(id,x,y,p), love.touchmoved(id,x,y,p), love.touchmoved(id,x,y,p))
|
||||
* added LOVE_ANDROID define
|
||||
|
||||
License:
|
||||
--------
|
||||
|
||||
This project contains code from various projects using various licenses.
|
||||
Please look into the folders of jni/<projectname>/ for the respective
|
||||
licenses.
|
||||
This project contains code from multiple projects using various licenses.
|
||||
Please look into the folders of love/src/jni/<projectname>/ for the respective
|
||||
licenses. A possibly incomplete overview of dependent and included
|
||||
libraries and licenses is the following:
|
||||
|
||||
As for the other code and build system files, these are published under the
|
||||
zlib license (same as LÖVE).
|
||||
* FreeType2 (FreeType Project License)
|
||||
* libjpeg-turbo (custom license)
|
||||
* libmodplug (public domain)
|
||||
* libogg (BSD License)
|
||||
* libvorbis (BSD License)
|
||||
* LuaJIT (MIT License)
|
||||
* mpg123 (LGPL 2.1 License)
|
||||
* openal-soft (LGPL 2 License)
|
||||
* physfs (zlib License)
|
||||
* SDL2 (zlib License)
|
||||
|
||||
This project also includes LÖVE, which itself is licensed under the zlib
|
||||
license but includes the following libraries that are subject to other
|
||||
licenses:
|
||||
|
||||
* modified Box2D (original Box2D license is zlib)
|
||||
* ddsparse (MIT License)
|
||||
* enet (MIT License)
|
||||
* glad (MIT License)
|
||||
* lodepng (zlib License)
|
||||
* luasocket (MIT License)
|
||||
* SimplexNoise1234 (public domain)
|
||||
* stb_image (public domain)
|
||||
* utf8 (Boost License)
|
||||
* wuff (public domain)
|
||||
|
||||
As for the other code, modifications to LÖVE, and build system files are
|
||||
are published under the zlib license (same as LÖVE).
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked into Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 28
|
||||
buildToolsVersion "28.0.3"
|
||||
defaultConfig {
|
||||
applicationId "org.love2d.android"
|
||||
versionCode 29
|
||||
versionName "11.3a"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api 'androidx.multidex:multidex:2.0.0'
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api 'androidx.appcompat:appcompat:1.1.0-alpha01'
|
||||
api project(':love')
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/diglet/android-sdk-macosx/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
-keep class br.com.tapps.love.LoveActivity { *; }
|
||||
|
||||
-keepclassmembers class br.com.tapps.love.LoveActivity {
|
||||
public com.naef.jnlua.LuaState createLuaState();
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="org.love2d.android.executable"
|
||||
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<!-- Disabled for PlayStore Build <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/love"
|
||||
android:label="LÖVE for Android"
|
||||
android:usesCleartextTraffic="true" >
|
||||
<service android:name="org.love2d.android.DownloadService" />
|
||||
<activity
|
||||
android:name="org.love2d.android.GameActivity"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:label="LÖVE for Android"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="landscape"
|
||||
android:resizeableActivity="false"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<category android:name="tv.ouya.intent.category.GAME" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="file" />
|
||||
<data android:mimeType="*/*" />
|
||||
<data android:pathPattern=".*\\.love" />
|
||||
<data android:host="*" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="content" />
|
||||
<data android:host="*" />
|
||||
<data android:mimeType="application/x-love-game" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="content" />
|
||||
<data android:host="*" />
|
||||
<data android:mimeType="application/octet-stream" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.love2d.android.DownloadActivity"
|
||||
android:noHistory="true"
|
||||
android:theme="@android:style/Theme.NoTitleBar" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="http"
|
||||
android:host="*"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.love" />
|
||||
<data android:scheme="https"
|
||||
android:host="*"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.love" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,5 @@
|
||||
values/generated_strings.xml
|
||||
values/generated_integers.xml
|
||||
drawable-*/icon.png
|
||||
drawable-*/notificationicon.png
|
||||
mipmap-*/ic_launcher.png
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Executable → Regular
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,29 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked in Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- This should be changed to the name of your project -->
|
||||
<project name="love_android_sdl2" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- if sdk.dir was not set from one of the property file, then
|
||||
get it from the ANDROID_HOME env var.
|
||||
This must be done before we load project.properties since
|
||||
the proguard config can use sdk.dir -->
|
||||
<property environment="env" />
|
||||
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
|
||||
<isset property="env.ANDROID_HOME" />
|
||||
</condition>
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,2 @@
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
Vendored
BIN
Binary file not shown.
+6
@@ -0,0 +1,6 @@
|
||||
#Sun Nov 18 11:20:03 CET 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
Vendored
+90
@@ -0,0 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,7 +0,0 @@
|
||||
# Uncomment this if you're using STL in your project
|
||||
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
|
||||
# APP_STL := stlport_static
|
||||
APP_STL := gnustl_shared
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_CPPFLAGS := -frtti
|
||||
# APP_OPTIM := debug
|
||||
@@ -1,8 +0,0 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libluajit
|
||||
LOCAL_SRC_FILES := src/libluajit.a
|
||||
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
@@ -1,56 +0,0 @@
|
||||
===============================================================================
|
||||
LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
|
||||
|
||||
Copyright (C) 2005-2013 Mike Pall. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
[ MIT license: http://www.opensource.org/licenses/mit-license.php ]
|
||||
|
||||
===============================================================================
|
||||
[ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ]
|
||||
|
||||
Copyright (C) 1994-2012 Lua.org, PUC-Rio.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
===============================================================================
|
||||
[ LuaJIT includes code from dlmalloc, which has this license statement: ]
|
||||
|
||||
This is a version (aka dlmalloc) of malloc/free/realloc written by
|
||||
Doug Lea and released to the public domain, as explained at
|
||||
http://creativecommons.org/licenses/publicdomain
|
||||
|
||||
===============================================================================
|
||||
@@ -1,149 +0,0 @@
|
||||
##############################################################################
|
||||
# LuaJIT top level Makefile for installation. Requires GNU Make.
|
||||
#
|
||||
# Please read doc/install.html before changing any variables!
|
||||
#
|
||||
# Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
|
||||
# Note: src/Makefile has many more configurable options.
|
||||
#
|
||||
# ##### This Makefile is NOT useful for Windows! #####
|
||||
# For MSVC, please follow the instructions given in src/msvcbuild.bat.
|
||||
# For MinGW and Cygwin, cd to src and run make with the Makefile there.
|
||||
#
|
||||
# Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
##############################################################################
|
||||
|
||||
MAJVER= 2
|
||||
MINVER= 0
|
||||
RELVER= 1
|
||||
VERSION= $(MAJVER).$(MINVER).$(RELVER)
|
||||
ABIVER= 5.1
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Change the installation path as needed. This automatically adjusts
|
||||
# the paths in src/luaconf.h, too. Note: PREFIX must be an absolute path!
|
||||
#
|
||||
export PREFIX= /usr/local
|
||||
##############################################################################
|
||||
|
||||
DPREFIX= $(DESTDIR)$(PREFIX)
|
||||
INSTALL_BIN= $(DPREFIX)/bin
|
||||
INSTALL_LIB= $(DPREFIX)/lib
|
||||
INSTALL_SHARE= $(DPREFIX)/share
|
||||
INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER)
|
||||
|
||||
INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION)
|
||||
INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit
|
||||
INSTALL_LMODD= $(INSTALL_SHARE)/lua
|
||||
INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER)
|
||||
INSTALL_CMODD= $(INSTALL_LIB)/lua
|
||||
INSTALL_CMOD= $(INSTALL_CMODD)/$(ABIVER)
|
||||
INSTALL_MAN= $(INSTALL_SHARE)/man/man1
|
||||
INSTALL_PKGCONFIG= $(INSTALL_LIB)/pkgconfig
|
||||
|
||||
INSTALL_TNAME= luajit-$(VERSION)
|
||||
INSTALL_TSYMNAME= luajit
|
||||
INSTALL_ANAME= libluajit-$(ABIVER).a
|
||||
INSTALL_SONAME= libluajit-$(ABIVER).so.$(MAJVER).$(MINVER).$(RELVER)
|
||||
INSTALL_SOSHORT= libluajit-$(ABIVER).so
|
||||
INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib
|
||||
INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib
|
||||
INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib
|
||||
INSTALL_PCNAME= luajit.pc
|
||||
|
||||
INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME)
|
||||
INSTALL_DYN= $(INSTALL_LIB)/$(INSTALL_SONAME)
|
||||
INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_SOSHORT)
|
||||
INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_SOSHORT)
|
||||
INSTALL_T= $(INSTALL_BIN)/$(INSTALL_TNAME)
|
||||
INSTALL_TSYM= $(INSTALL_BIN)/$(INSTALL_TSYMNAME)
|
||||
INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME)
|
||||
|
||||
INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN) \
|
||||
$(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD)
|
||||
UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \
|
||||
$(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD)
|
||||
|
||||
RM= rm -f
|
||||
MKDIR= mkdir -p
|
||||
RMDIR= rmdir 2>/dev/null
|
||||
SYMLINK= ln -sf
|
||||
INSTALL_X= install -m 0755
|
||||
INSTALL_F= install -m 0644
|
||||
UNINSTALL= $(RM)
|
||||
LDCONFIG= ldconfig -n
|
||||
SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|"
|
||||
|
||||
FILE_T= luajit
|
||||
FILE_A= libluajit.a
|
||||
FILE_SO= libluajit.so
|
||||
FILE_MAN= luajit.1
|
||||
FILE_PC= luajit.pc
|
||||
FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h
|
||||
FILES_JITLIB= bc.lua v.lua dump.lua dis_x86.lua dis_x64.lua dis_arm.lua \
|
||||
dis_ppc.lua dis_mips.lua dis_mipsel.lua bcsave.lua vmdef.lua
|
||||
|
||||
ifeq (,$(findstring Windows,$(OS)))
|
||||
ifeq (Darwin,$(shell uname -s))
|
||||
INSTALL_SONAME= $(INSTALL_DYLIBNAME)
|
||||
INSTALL_SHORT1= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT1)
|
||||
INSTALL_SHORT2= $(INSTALL_LIB)/$(INSTALL_DYLIBSHORT2)
|
||||
LDCONFIG= :
|
||||
endif
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
|
||||
INSTALL_DEP= src/luajit
|
||||
|
||||
default all $(INSTALL_DEP):
|
||||
@echo "==== Building LuaJIT $(VERSION) ===="
|
||||
$(MAKE) -C src
|
||||
@echo "==== Successfully built LuaJIT $(VERSION) ===="
|
||||
|
||||
install: $(INSTALL_DEP)
|
||||
@echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ===="
|
||||
$(MKDIR) $(INSTALL_DIRS)
|
||||
cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T)
|
||||
cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || :
|
||||
$(RM) $(INSTALL_TSYM) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2)
|
||||
cd src && test -f $(FILE_SO) && \
|
||||
$(INSTALL_X) $(FILE_SO) $(INSTALL_DYN) && \
|
||||
$(LDCONFIG) $(INSTALL_LIB) && \
|
||||
$(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \
|
||||
$(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || :
|
||||
cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN)
|
||||
cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \
|
||||
$(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \
|
||||
$(RM) $(FILE_PC).tmp
|
||||
cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC)
|
||||
cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB)
|
||||
$(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)
|
||||
@echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ===="
|
||||
|
||||
uninstall:
|
||||
@echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ===="
|
||||
$(UNINSTALL) $(INSTALL_TSYM) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC)
|
||||
for file in $(FILES_JITLIB); do \
|
||||
$(UNINSTALL) $(INSTALL_JITLIB)/$$file; \
|
||||
done
|
||||
for file in $(FILES_INC); do \
|
||||
$(UNINSTALL) $(INSTALL_INC)/$$file; \
|
||||
done
|
||||
$(LDCONFIG) $(INSTALL_LIB)
|
||||
$(RMDIR) $(UNINSTALL_DIRS) || :
|
||||
@echo "==== Successfully uninstalled LuaJIT $(VERSION) from $(PREFIX) ===="
|
||||
|
||||
##############################################################################
|
||||
|
||||
amalg:
|
||||
@echo "Building LuaJIT $(VERSION)"
|
||||
$(MAKE) -C src amalg
|
||||
|
||||
clean:
|
||||
$(MAKE) -C src clean
|
||||
|
||||
.PHONY: all install amalg clean
|
||||
|
||||
##############################################################################
|
||||
@@ -1,16 +0,0 @@
|
||||
README for LuaJIT 2.0.1
|
||||
-----------------------
|
||||
|
||||
LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
|
||||
|
||||
Project Homepage: http://luajit.org/
|
||||
|
||||
LuaJIT is Copyright (C) 2005-2013 Mike Pall.
|
||||
LuaJIT is free software, released under the MIT license.
|
||||
See full Copyright Notice in the COPYRIGHT file or in luajit.h.
|
||||
|
||||
Documentation for LuaJIT is available in HTML format.
|
||||
Please point your favorite browser to:
|
||||
|
||||
doc/luajit.html
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
NDK=${ANDROID_NDK}
|
||||
NDKABI=8
|
||||
NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
|
||||
NDKP=$NDKVER/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
|
||||
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
|
||||
NDKARCH="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3"
|
||||
# NDKARCH="-march=armv7-a"
|
||||
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH"
|
||||
|
||||
# NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
|
||||
# NDKP=$NDKVER/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
|
||||
# NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
|
||||
# NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
|
||||
# make HOST_CC="gcc -m32 -fPIC" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH"
|
||||
@@ -1,862 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>LuaJIT Change History</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Mike Pall">
|
||||
<meta name="Copyright" content="Copyright (C) 2005-2013, Mike Pall">
|
||||
<meta name="Language" content="en">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
|
||||
<style type="text/css">
|
||||
div.major { max-width: 600px; padding: 1em; margin: 1em 0 1em 0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="site">
|
||||
<a href="http://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
|
||||
</div>
|
||||
<div id="head">
|
||||
<h1>LuaJIT Change History</h1>
|
||||
</div>
|
||||
<div id="nav">
|
||||
<ul><li>
|
||||
<a href="luajit.html">LuaJIT</a>
|
||||
<ul><li>
|
||||
<a href="http://luajit.org/download.html">Download <span class="ext">»</span></a>
|
||||
</li><li>
|
||||
<a href="install.html">Installation</a>
|
||||
</li><li>
|
||||
<a href="running.html">Running</a>
|
||||
</li></ul>
|
||||
</li><li>
|
||||
<a href="extensions.html">Extensions</a>
|
||||
<ul><li>
|
||||
<a href="ext_ffi.html">FFI Library</a>
|
||||
<ul><li>
|
||||
<a href="ext_ffi_tutorial.html">FFI Tutorial</a>
|
||||
</li><li>
|
||||
<a href="ext_ffi_api.html">ffi.* API</a>
|
||||
</li><li>
|
||||
<a href="ext_ffi_semantics.html">FFI Semantics</a>
|
||||
</li></ul>
|
||||
</li><li>
|
||||
<a href="ext_jit.html">jit.* Library</a>
|
||||
</li><li>
|
||||
<a href="ext_c_api.html">Lua/C API</a>
|
||||
</li></ul>
|
||||
</li><li>
|
||||
<a href="status.html">Status</a>
|
||||
<ul><li>
|
||||
<a class="current" href="changes.html">Changes</a>
|
||||
</li></ul>
|
||||
</li><li>
|
||||
<a href="faq.html">FAQ</a>
|
||||
</li><li>
|
||||
<a href="http://luajit.org/performance.html">Performance <span class="ext">»</span></a>
|
||||
</li><li>
|
||||
<a href="http://wiki.luajit.org/">Wiki <span class="ext">»</span></a>
|
||||
</li><li>
|
||||
<a href="http://luajit.org/list.html">Mailing List <span class="ext">»</span></a>
|
||||
</li></ul>
|
||||
</div>
|
||||
<div id="main">
|
||||
<p>
|
||||
This is a list of changes between the released versions of LuaJIT.<br>
|
||||
The current <span style="color: #0000c0;">stable version</span> is <strong>LuaJIT 2.0.1</strong>.<br>
|
||||
</p>
|
||||
<p>
|
||||
Please check the
|
||||
<a href="http://luajit.org/changes.html"><span class="ext">»</span> Online Change History</a>
|
||||
to see whether newer versions are available.
|
||||
</p>
|
||||
|
||||
<div class="major" style="background: #d0d0ff;">
|
||||
<h2 id="LuaJIT-2.0.1">LuaJIT 2.0.1 — 2013-02-19</h2>
|
||||
<ul>
|
||||
<li>Don't clear frame for out-of-memory error.</li>
|
||||
<li>Leave hook when resume catches error thrown from hook.</li>
|
||||
<li>Add missing GC steps for template table creation.</li>
|
||||
<li>Fix discharge order of comparisons in Lua parser.</li>
|
||||
<li>Improve buffer handling for <tt>io.read()</tt>.</li>
|
||||
<li>OSX: Add support for Mach-O object files to <tt>-b</tt> option.</li>
|
||||
<li>Fix PS3 port.</li>
|
||||
<li>Fix/enable Xbox 360 port.</li>
|
||||
<li>x86/x64: Always mark ref for shift count as non-weak.</li>
|
||||
<li>x64: Don't fuse implicitly 32-to-64 extended operands.</li>
|
||||
<li>ARM: Fix armhf call argument handling.</li>
|
||||
<li>ARM: Fix code generation for integer math.min/math.max.</li>
|
||||
<li>PPC/e500: Fix <tt>lj_vm_floor()</tt> for Inf/NaN.</li>
|
||||
<li>FFI: Change priority of table initializer variants for structs.</li>
|
||||
<li>FFI: Fix code generation for bool call result check on x86/x64.</li>
|
||||
<li>FFI: Load FFI library on-demand for bytecode with cdata literals.</li>
|
||||
<li>FFI: Fix handling of qualified transparent structs/unions.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0">LuaJIT 2.0.0 — 2012-11-08</h2>
|
||||
<ul>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>Fix Android/x86 build.</li>
|
||||
<li>Fix recording of equality comparisons with <tt>__eq</tt> metamethods.</li>
|
||||
<li>Fix detection of immutable upvalues.</li>
|
||||
<li>Replace error with PANIC for callbacks from JIT-compiled code.</li>
|
||||
<li>Fix builtin string to number conversion for <tt>INT_MIN</tt>.</li>
|
||||
<li>Don't create unneeded array part for template tables.</li>
|
||||
<li>Fix <tt>CONV.num.int</tt> sinking.</li>
|
||||
<li>Don't propagate implicitly widened number to index metamethods.</li>
|
||||
<li>ARM: Fix ordered comparisons of number vs. non-number.</li>
|
||||
<li>FFI: Fix code generation for replay of sunk float fields.</li>
|
||||
<li>FFI: Fix signedness of bool.</li>
|
||||
<li>FFI: Fix recording of bool call result check on x86/x64.</li>
|
||||
<li>FFI: Fix stack-adjustment for <tt>__thiscall</tt> callbacks.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta11">LuaJIT 2.0.0-beta11 — 2012-10-16</h2>
|
||||
<ul>
|
||||
<li>New features:
|
||||
<ul>
|
||||
<li>Use ARM VFP instructions, if available (build-time detection).</li>
|
||||
<li>Add support for ARM hard-float EABI (<tt>armhf</tt>).</li>
|
||||
<li>Add PS3 port.</li>
|
||||
<li>Add many features from Lua 5.2, e.g. <tt>goto</tt>/labels.
|
||||
Refer to <a href="extensions.html#lua52">this list</a>.</li>
|
||||
<li>FFI: Add parameterized C types.</li>
|
||||
<li>FFI: Add support for copy constructors.</li>
|
||||
<li>FFI: Equality comparisons never raise an error (treat as unequal instead).</li>
|
||||
<li>FFI: Box all accessed or returned enums.</li>
|
||||
<li>FFI: Check for <tt>__new</tt> metamethod when calling a constructor.</li>
|
||||
<li>FFI: Handle <tt>__pairs</tt>/<tt>__ipairs</tt> metamethods for cdata objects.</li>
|
||||
<li>FFI: Convert <tt>io.*</tt> file handle to <tt>FILE *</tt> pointer (but as a <tt>void *</tt>).</li>
|
||||
<li>FFI: Detect and support type punning through unions.</li>
|
||||
<li>FFI: Improve various error messages.</li>
|
||||
</ul></li>
|
||||
<li>Build-system reorganization:
|
||||
<ul>
|
||||
<li>Reorganize directory layout:<br>
|
||||
<tt>lib/*</tt> → <tt>src/jit/*</tt><br>
|
||||
<tt>src/buildvm_*.dasc</tt> → <tt>src/vm_*.dasc</tt><br>
|
||||
<tt>src/buildvm_*.h</tt> → removed<br>
|
||||
<tt>src/buildvm*</tt> → <tt>src/host/*</tt></li>
|
||||
<li>Add minified Lua interpreter plus Lua BitOp (<tt>minilua</tt>) to run DynASM.</li>
|
||||
<li>Change DynASM bit operations to use Lua BitOp</li>
|
||||
<li>Translate only <tt>vm_*.dasc</tt> for detected target architecture.</li>
|
||||
<li>Improve target detection for <tt>msvcbuild.bat</tt>.</li>
|
||||
<li>Fix build issues on Cygwin and MinGW with optional MSys.</li>
|
||||
<li>Handle cross-compiles with FPU/no-FPU or hard-fp/soft-fp ABI mismatch.</li>
|
||||
<li>Remove some library functions for no-JIT/no-FFI builds.</li>
|
||||
<li>Add uninstall target to top-level Makefile.</li>
|
||||
</ul></li>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>Preserve snapshot #0 PC for all traces.</li>
|
||||
<li>Fix argument checks for <tt>coroutine.create()</tt>.</li>
|
||||
<li>Command line prints version and JIT status to <tt>stdout</tt>, not <tt>stderr</tt>.</li>
|
||||
<li>Fix userdata <tt>__gc</tt> separations at Lua state close.</li>
|
||||
<li>Fix <tt>TDUP</tt> to <tt>HLOAD</tt> forwarding for <tt>LJ_DUALNUM</tt> builds.</li>
|
||||
<li>Fix buffer check in bytecode writer.</li>
|
||||
<li>Make <tt>os.date()</tt> thread-safe.</li>
|
||||
<li>Add missing declarations for MSVC intrinsics.</li>
|
||||
<li>Fix dispatch table modifications for return hooks.</li>
|
||||
<li>Workaround for MSVC conversion bug (<tt>double</tt> → <tt>uint32_t</tt> → <tt>int32_t</tt>).</li>
|
||||
<li>Fix FOLD rule <tt>(i-j)-i => 0-j</tt>.</li>
|
||||
<li>Never use DWARF unwinder on Windows.</li>
|
||||
<li>Fix shrinking of direct mapped blocks in builtin allocator.</li>
|
||||
<li>Limit recursion depth in <tt>string.match()</tt> et al.</li>
|
||||
<li>Fix late despecialization of <tt>ITERN</tt> after loop has been entered.</li>
|
||||
<li>Fix <tt>'f'</tt> and <tt>'L'</tt> options for <tt>debug.getinfo()</tt> and <tt>lua_getinfo()</tt>.</li>
|
||||
<li>Fix <tt>package.searchpath()</tt>.</li>
|
||||
<li>OSX: Change dylib names to be consistent with other platforms.</li>
|
||||
<li>Android: Workaround for broken <tt>sprintf("%g", -0.0)</tt>.</li>
|
||||
<li>x86: Remove support for ancient CPUs without <tt>CMOV</tt> (before Pentium Pro).</li>
|
||||
<li>x86: Fix register allocation for calls returning register pair.</li>
|
||||
<li>x86/x64: Fix fusion of unsigned byte comparisons with swapped operands.</li>
|
||||
<li>ARM: Fix <tt>tonumber()</tt> argument check.</li>
|
||||
<li>ARM: Fix modulo operator and <tt>math.floor()</tt>/<tt>math.ceil()</tt> for <tt>inf</tt>/<tt>nan</tt>.</li>
|
||||
<li>ARM: Invoke SPLIT pass for leftover <tt>IR_TOBIT</tt>.</li>
|
||||
<li>ARM: Fix BASE register coalescing.</li>
|
||||
<li>PPC: Fix interpreter state setup in callbacks.</li>
|
||||
<li>PPC: Fix <tt>string.sub()</tt> range check.</li>
|
||||
<li>MIPS: Support generation of MIPS/MIPSEL bytecode object files.</li>
|
||||
<li>MIPS: Fix calls to <tt>floor()</tt>/<tt>ceil()</tt><tt>/trunc()</tt>.</li>
|
||||
<li>ARM/PPC: Detect more target architecture variants.</li>
|
||||
<li>ARM/PPC/e500/MIPS: Fix tailcalls from fast functions, esp. <tt>tostring()</tt>.</li>
|
||||
<li>ARM/PPC/MIPS: Fix rematerialization of FP constants.</li>
|
||||
<li>FFI: Don't call <tt>FreeLibrary()</tt> on our own EXE/DLL.</li>
|
||||
<li>FFI: Resolve metamethods for constructors, too.</li>
|
||||
<li>FFI: Properly disable callbacks on iOS (would require executable memory).</li>
|
||||
<li>FFI: Fix cdecl string parsing during recording.</li>
|
||||
<li>FFI: Show address pointed to for <tt>tostring(ref)</tt>, too.</li>
|
||||
<li>FFI: Fix alignment of C call argument/return structure.</li>
|
||||
<li>FFI: Initialize all fields of standard types.</li>
|
||||
<li>FFI: Fix callback handling when new C types are declared in callback.</li>
|
||||
<li>FFI: Fix recording of constructors for pointers.</li>
|
||||
<li>FFI: Always resolve metamethods for pointers to structs.</li>
|
||||
<li>FFI: Correctly propagate alignment when interning nested types.</li>
|
||||
</ul></li>
|
||||
<li>Structural and performance enhancements:
|
||||
<ul>
|
||||
<li>Add allocation sinking and store sinking optimization.</li>
|
||||
<li>Constify immutable upvalues.</li>
|
||||
<li>Add builtin string to integer or FP number conversion. Improves cross-platform consistency and correctness.</li>
|
||||
<li>Create string hash slots in template tables for non-const values, too. Avoids later table resizes.</li>
|
||||
<li>Eliminate <tt>HREFK</tt> guard for template table references.</li>
|
||||
<li>Add various new FOLD rules.</li>
|
||||
<li>Don't use stack unwinding for <tt>lua_yield()</tt> (slow on x64).</li>
|
||||
<li>ARM, PPC, MIPS: Improve <tt>XLOAD</tt> operand fusion and register hinting.</li>
|
||||
<li>PPC, MIPS: Compile <tt>math.sqrt()</tt> to sqrt instruction, if available.</li>
|
||||
<li>FFI: Fold <tt>KPTR</tt> + constant offset in SPLIT pass.</li>
|
||||
<li>FFI: Optimize/inline <tt>ffi.copy()</tt> and <tt>ffi.fill()</tt>.</li>
|
||||
<li>FFI: Compile and optimize array/struct copies.</li>
|
||||
<li>FFI: Compile <tt>ffi.typeof(cdata|ctype)</tt>, <tt>ffi.sizeof()</tt>, <tt>ffi.alignof()</tt>, <tt>ffi.offsetof()</tt> and <tt>ffi.gc()</tt>.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta10">LuaJIT 2.0.0-beta10 — 2012-05-09</h2>
|
||||
<ul>
|
||||
<li>New features:
|
||||
<ul>
|
||||
<li>The MIPS of LuaJIT is complete. It requires a CPU conforming to the
|
||||
MIPS32 R1 architecture with hardware FPU. O32 hard-fp ABI,
|
||||
little-endian or big-endian.</li>
|
||||
<li>Auto-detect target arch via cross-compiler. No need for
|
||||
<tt>TARGET=arch</tt> anymore.</li>
|
||||
<li>Make DynASM compatible with Lua 5.2.</li>
|
||||
<li>From Lua 5.2: Try <tt>__tostring</tt> metamethod on non-string error
|
||||
messages..</li>
|
||||
</ul></li>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>Fix parsing of hex literals with exponents.</li>
|
||||
<li>Fix bytecode dump for certain number constants.</li>
|
||||
<li>Fix argument type in error message for relative arguments.</li>
|
||||
<li>Fix argument error handling on Lua stacks without a frame.</li>
|
||||
<li>Add missing mcode limit check in assembler backend.</li>
|
||||
<li>Fix compilation on OpenBSD.</li>
|
||||
<li>Avoid recursive GC steps after GC-triggered trace exit.</li>
|
||||
<li>Replace <tt><unwind.h></tt> definitions with our own.</li>
|
||||
<li>Fix OSX build issues. Bump minimum required OSX version to 10.4.</li>
|
||||
<li>Fix discharge order of comparisons in Lua parser.</li>
|
||||
<li>Ensure running <tt>__gc</tt> of userdata created in <tt>__gc</tt>
|
||||
at state close.</li>
|
||||
<li>Limit number of userdata <tt>__gc</tt> separations at state close.</li>
|
||||
<li>Fix bytecode <tt>JMP</tt> slot range when optimizing
|
||||
<tt>and</tt>/<tt>or</tt> with constant LHS.</li>
|
||||
<li>Fix DSE of <tt>USTORE</tt>.</li>
|
||||
<li>Make <tt>lua_concat()</tt> work from C hook with partial frame.</li>
|
||||
<li>Add required PHIs for implicit conversions, e.g. via <tt>XREF</tt>
|
||||
forwarding.</li>
|
||||
<li>Add more comparison variants to Valgrind suppressions file.</li>
|
||||
<li>Disable loading bytecode with an extra header (BOM or <tt>#!</tt>).</li>
|
||||
<li>Fix PHI stack slot syncing.</li>
|
||||
<li>ARM: Reorder type/value tests to silence Valgrind.</li>
|
||||
<li>ARM: Fix register allocation for <tt>ldrd</tt>-optimized
|
||||
<tt>HREFK</tt>.</li>
|
||||
<li>ARM: Fix conditional branch fixup for <tt>OBAR</tt>.</li>
|
||||
<li>ARM: Invoke SPLIT pass for <tt>double</tt> args in FFI call.</li>
|
||||
<li>ARM: Handle all <tt>CALL*</tt> ops with <tt>double</tt> results in
|
||||
SPLIT pass.</li>
|
||||
<li>ARM: Fix rejoin of <tt>POW</tt> in SPLIT pass.</li>
|
||||
<li>ARM: Fix compilation of <tt>math.sinh</tt>, <tt>math.cosh</tt>,
|
||||
<tt>math.tanh</tt>.</li>
|
||||
<li>ARM, PPC: Avoid pointless arg clearing in <tt>BC_IFUNCF</tt>.</li>
|
||||
<li>PPC: Fix resume after yield from hook.</li>
|
||||
<li>PPC: Fix argument checking for <tt>rawget()</tt>.</li>
|
||||
<li>PPC: Fix fusion of floating-point <tt>XLOAD</tt>/<tt>XSTORE</tt>.</li>
|
||||
<li>PPC: Fix <tt>HREFK</tt> code generation for huge tables.</li>
|
||||
<li>PPC: Use builtin D-Cache/I-Cache sync code.</li>
|
||||
</ul></li>
|
||||
<li>FFI library:
|
||||
<ul>
|
||||
<li>Ignore empty statements in <tt>ffi.cdef()</tt>.</li>
|
||||
<li>Ignore number parsing errors while skipping definitions.</li>
|
||||
<li>Don't touch frame in callbacks with tailcalls to fast functions.</li>
|
||||
<li>Fix library unloading on POSIX systems.</li>
|
||||
<li>Finalize cdata before userdata when closing the state.</li>
|
||||
<li>Change <tt>ffi.load()</tt> library name resolution for Cygwin.</li>
|
||||
<li>Fix resolving of function name redirects on Windows/x86.</li>
|
||||
<li>Fix symbol resolving error messages on Windows.</li>
|
||||
<li>Fix blacklisting of C functions calling callbacks.</li>
|
||||
<li>Fix result type of pointer difference.</li>
|
||||
<li>Use correct PC in FFI metamethod error message.</li>
|
||||
<li>Allow <tt>'typedef _Bool int BOOL;'</tt> for the Windows API.</li>
|
||||
<li>Don't record test for bool result of call, if ignored.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta9">LuaJIT 2.0.0-beta9 — 2011-12-14</h2>
|
||||
<ul>
|
||||
<li>New features:
|
||||
<ul>
|
||||
<li>PPC port of LuaJIT is complete. Default is the dual-number port
|
||||
(usually faster). Single-number port selectable via <tt>src/Makefile</tt>
|
||||
at build time.</li>
|
||||
<li>Add FFI callback support.</li>
|
||||
<li>Extend <tt>-b</tt> to generate <tt>.c</tt>, <tt>.h</tt> or <tt>.obj/.o</tt>
|
||||
files with embedded bytecode.</li>
|
||||
<li>Allow loading embedded bytecode with <tt>require()</tt>.</li>
|
||||
<li>From Lua 5.2: Change to <tt>'\z'</tt> escape. Reject undefined escape
|
||||
sequences.</li>
|
||||
</ul></li>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>Fix OSX 10.7 build. Fix <tt>install_name</tt> and versioning on OSX.</li>
|
||||
<li>Fix iOS build.</li>
|
||||
<li>Install <tt>dis_arm.lua</tt>, too.</li>
|
||||
<li>Mark installed shared library as executable.</li>
|
||||
<li>Add debug option to <tt>msvcbuild.bat</tt> and improve error handling.</li>
|
||||
<li>Fix data-flow analysis for iterators.</li>
|
||||
<li>Fix forced unwinding triggered by external unwinder.</li>
|
||||
<li>Record missing <tt>for</tt> loop slot loads (return to lower frame).</li>
|
||||
<li>Always use ANSI variants of Windows system functions.</li>
|
||||
<li>Fix GC barrier for multi-result table constructor (<tt>TSETM</tt>).</li>
|
||||
<li>Fix/add various FOLD rules.</li>
|
||||
<li>Add potential PHI for number conversions due to type instability.</li>
|
||||
<li>Do not eliminate PHIs only referenced from other PHIs.</li>
|
||||
<li>Correctly anchor implicit number to string conversions in Lua/C API.</li>
|
||||
<li>Fix various stack limit checks.</li>
|
||||
<li>x64: Use thread-safe exceptions for external unwinding (GCC platforms).</li>
|
||||
<li>x64: Fix result type of cdata index conversions.</li>
|
||||
<li>x64: Fix <tt>math.random()</tt> and <tt>bit.bswap()</tt> code generation.</li>
|
||||
<li>x64: Fix <tt>lightuserdata</tt> comparisons.</li>
|
||||
<li>x64: Always extend stack-passed arguments to pointer size.</li>
|
||||
<li>ARM: Many fixes to code generation backend.</li>
|
||||
<li>PPC/e500: Fix dispatch for binop metamethods.</li>
|
||||
<li>PPC/e500: Save/restore condition registers when entering/leaving the VM.</li>
|
||||
<li>PPC/e500: Fix write barrier in stores of strings to upvalues.</li>
|
||||
</ul></li>
|
||||
<li>FFI library:
|
||||
<ul>
|
||||
<li>Fix C comment parsing.</li>
|
||||
<li>Fix snapshot optimization for cdata comparisons.</li>
|
||||
<li>Fix recording of const/enum lookups in namespaces.</li>
|
||||
<li>Fix call argument and return handling for <tt>I8/U8/I16/U16</tt> types.</li>
|
||||
<li>Fix unfused loads of float fields.</li>
|
||||
<li>Fix <tt>ffi.string()</tt> recording.</li>
|
||||
<li>Save <tt>GetLastError()</tt> around <tt>ffi.load()</tt> and symbol
|
||||
resolving, too.</li>
|
||||
<li>Improve ld script detection in <tt>ffi.load()</tt>.</li>
|
||||
<li>Record loads/stores to external variables in namespaces.</li>
|
||||
<li>Compile calls to stdcall, fastcall and vararg functions.</li>
|
||||
<li>Treat function ctypes like pointers in comparisons.</li>
|
||||
<li>Resolve <tt>__call</tt> metamethod for pointers, too.</li>
|
||||
<li>Record C function calls with bool return values.</li>
|
||||
<li>Record <tt>ffi.errno()</tt>.</li>
|
||||
<li>x86: Fix number to <tt>uint32_t</tt> conversion rounding.</li>
|
||||
<li>x86: Fix 64 bit arithmetic in assembler backend.</li>
|
||||
<li>x64: Fix struct-by-value calling conventions.</li>
|
||||
<li>ARM: Ensure invocation of SPLIT pass for float conversions.</li>
|
||||
</ul></li>
|
||||
<li>Structural and performance enhancements:
|
||||
<ul>
|
||||
<li>Display trace types with <tt>-jv</tt> and <tt>-jdump</tt>.</li>
|
||||
<li>Record isolated calls. But prefer recording loops over calls.</li>
|
||||
<li>Specialize to prototype for non-monomorphic functions. Solves the
|
||||
trace-explosion problem for closure-heavy programming styles.</li>
|
||||
<li>Always generate a portable <tt>vmdef.lua</tt>. Easier for distros.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta8">LuaJIT 2.0.0-beta8 — 2011-06-23</h2>
|
||||
<ul>
|
||||
<li>New features:
|
||||
<ul>
|
||||
<li>Soft-float ARM port of LuaJIT is complete.</li>
|
||||
<li>Add support for bytecode loading/saving and <tt>-b</tt> command line
|
||||
option.</li>
|
||||
<li>From Lua 5.2: <tt>__len</tt> metamethod for tables
|
||||
(disabled by default).</li>
|
||||
</ul></li>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>ARM: Misc. fixes for interpreter.</li>
|
||||
<li>x86/x64: Fix <tt>bit.*</tt> argument checking in interpreter.</li>
|
||||
<li>Catch early out-of-memory in memory allocator initialization.</li>
|
||||
<li>Fix data-flow analysis for paths leading to an upvalue close.</li>
|
||||
<li>Fix check for missing arguments in <tt>string.format()</tt>.</li>
|
||||
<li>Fix Solaris/x86 build (note: not a supported target).</li>
|
||||
<li>Fix recording of loops with instable directions in side traces.</li>
|
||||
<li>x86/x64: Fix fusion of comparisons with <tt>u8</tt>/<tt>u16</tt>
|
||||
<tt>XLOAD</tt>.</li>
|
||||
<li>x86/x64: Fix register allocation for variable shifts.</li>
|
||||
</ul></li>
|
||||
<li>FFI library:
|
||||
<ul>
|
||||
<li>Add <tt>ffi.errno()</tt>. Save <tt>errno</tt>/<tt>GetLastError()</tt>
|
||||
around allocations etc.</li>
|
||||
<li>Fix <tt>__gc</tt> for VLA/VLS cdata objects.</li>
|
||||
<li>Fix recording of casts from 32 bit cdata pointers to integers.</li>
|
||||
<li><tt>tonumber(cdata)</tt> returns <tt>nil</tt> for non-numbers.</li>
|
||||
<li>Show address pointed to for <tt>tostring(pointer)</tt>.</li>
|
||||
<li>Print <tt>NULL</tt> pointers as <tt>"cdata<... *>: NULL"</tt>.</li>
|
||||
<li>Support <tt>__tostring</tt> metamethod for pointers to structs, too.</li>
|
||||
</ul></li>
|
||||
<li>Structural and performance enhancements:
|
||||
<ul>
|
||||
<li>More tuning for loop unrolling heuristics.</li>
|
||||
<li>Flatten and compress in-memory debug info (saves ~70%).</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta7">LuaJIT 2.0.0-beta7 — 2011-05-05</h2>
|
||||
<ul>
|
||||
<li>New features:
|
||||
<ul>
|
||||
<li>ARM port of the LuaJIT interpreter is complete.</li>
|
||||
<li>FFI library: Add <tt>ffi.gc()</tt>, <tt>ffi.metatype()</tt>,
|
||||
<tt>ffi.istype()</tt>.</li>
|
||||
<li>FFI library: Resolve ld script redirection in <tt>ffi.load()</tt>.</li>
|
||||
<li>From Lua 5.2: <tt>package.searchpath()</tt>, <tt>fp:read("*L")</tt>,
|
||||
<tt>load(string)</tt>.</li>
|
||||
<li>From Lua 5.2, disabled by default: empty statement,
|
||||
<tt>table.unpack()</tt>, modified <tt>coroutine.running()</tt>.</li>
|
||||
</ul></li>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>FFI library: numerous fixes.</li>
|
||||
<li>Fix type mismatches in store-to-load forwarding.</li>
|
||||
<li>Fix error handling within metamethods.</li>
|
||||
<li>Fix <tt>table.maxn()</tt>.</li>
|
||||
<li>Improve accuracy of <tt>x^-k</tt> on x64.</li>
|
||||
<li>Fix code generation for Intel Atom in x64 mode.</li>
|
||||
<li>Fix narrowing of POW.</li>
|
||||
<li>Fix recording of retried fast functions.</li>
|
||||
<li>Fix code generation for <tt>bit.bnot()</tt> and multiplies.</li>
|
||||
<li>Fix error location within cpcall frames.</li>
|
||||
<li>Add workaround for old libgcc unwind bug.</li>
|
||||
<li>Fix <tt>lua_yield()</tt> and <tt>getmetatable(lightuserdata)</tt> on x64.</li>
|
||||
<li>Misc. fixes for PPC/e500 interpreter.</li>
|
||||
<li>Fix stack slot updates for down-recursion.</li>
|
||||
</ul></li>
|
||||
<li>Structural and performance enhancements:
|
||||
<ul>
|
||||
<li>Add dual-number mode (int/double) for the VM. Enabled for ARM.</li>
|
||||
<li>Improve narrowing of arithmetic operators and <tt>for</tt> loops.</li>
|
||||
<li>Tune loop unrolling heuristics and increase trace recorder limits.</li>
|
||||
<li>Eliminate dead slots in snapshots using bytecode data-flow analysis.</li>
|
||||
<li>Avoid phantom stores to proxy tables.</li>
|
||||
<li>Optimize lookups in empty proxy tables.</li>
|
||||
<li>Improve bytecode optimization of <tt>and</tt>/<tt>or</tt> operators.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta6">LuaJIT 2.0.0-beta6 — 2011-02-11</h2>
|
||||
<ul>
|
||||
<li>New features:
|
||||
<ul>
|
||||
<li>PowerPC/e500v2 port of the LuaJIT interpreter is complete.</li>
|
||||
<li>Various minor features from Lua 5.2: Hex escapes in literals,
|
||||
<tt>'\*'</tt> escape, reversible <tt>string.format("%q",s)</tt>,
|
||||
<tt>"%g"</tt> pattern, <tt>table.sort</tt> checks callbacks,
|
||||
<tt>os.exit(status|true|false[,close])</tt>.</li>
|
||||
<li>Lua 5.2 <tt>__pairs</tt> and <tt>__ipairs</tt> metamethods
|
||||
(disabled by default).</li>
|
||||
<li>Initial release of the FFI library.</li>
|
||||
</ul></li>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>Fix <tt>string.format()</tt> for non-finite numbers.</li>
|
||||
<li>Fix memory leak when compiled to use the built-in allocator.</li>
|
||||
<li>x86/x64: Fix unnecessary resize in <tt>TSETM</tt> bytecode.</li>
|
||||
<li>Fix various GC issues with traces and <tt>jit.flush()</tt>.</li>
|
||||
<li>x64: Fix fusion of indexes for array references.</li>
|
||||
<li>x86/x64: Fix stack overflow handling for coroutine results.</li>
|
||||
<li>Enable low-2GB memory allocation on FreeBSD/x64.</li>
|
||||
<li>Fix <tt>collectgarbage("count")</tt> result if more than 2GB is in use.</li>
|
||||
<li>Fix parsing of hex floats.</li>
|
||||
<li>x86/x64: Fix loop branch inversion with trailing
|
||||
<tt>HREF+NE/EQ</tt>.</li>
|
||||
<li>Add <tt>jit.os</tt> string.</li>
|
||||
<li><tt>coroutine.create()</tt> permits running C functions, too.</li>
|
||||
<li>Fix OSX build to work with newer ld64 versions.</li>
|
||||
<li>Fix bytecode optimization of <tt>and</tt>/<tt>or</tt> operators.</li>
|
||||
</ul></li>
|
||||
<li>Structural and performance enhancements:
|
||||
<ul>
|
||||
<li>Emit specialized bytecode for <tt>pairs()</tt>/<tt>next()</tt>.</li>
|
||||
<li>Improve bytecode coalescing of <tt>nil</tt> constants.</li>
|
||||
<li>Compile calls to vararg functions.</li>
|
||||
<li>Compile <tt>select()</tt>.</li>
|
||||
<li>Improve alias analysis, esp. for loads from allocations.</li>
|
||||
<li>Tuning of various compiler heuristics.</li>
|
||||
<li>Refactor and extend IR conversion instructions.</li>
|
||||
<li>x86/x64: Various backend enhancements related to the FFI.</li>
|
||||
<li>Add SPLIT pass to split 64 bit IR instructions for 32 bit CPUs.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta5">LuaJIT 2.0.0-beta5 — 2010-08-24</h2>
|
||||
<ul>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>Fix trace exit dispatch to function headers.</li>
|
||||
<li>Fix Windows and OSX builds with LUAJIT_DISABLE_JIT.</li>
|
||||
<li>Reorganize and fix placement of generated machine code on x64.</li>
|
||||
<li>Fix TNEW in x64 interpreter.</li>
|
||||
<li>Do not eliminate PHIs for values only referenced from side exits.</li>
|
||||
<li>OS-independent canonicalization of strings for non-finite numbers.</li>
|
||||
<li>Fix <tt>string.char()</tt> range check on x64.</li>
|
||||
<li>Fix <tt>tostring()</tt> resolving within <tt>print()</tt>.</li>
|
||||
<li>Fix error handling for <tt>next()</tt>.</li>
|
||||
<li>Fix passing of constant arguments to external calls on x64.</li>
|
||||
<li>Fix interpreter argument check for two-argument SSE math functions.</li>
|
||||
<li>Fix C frame chain corruption caused by <tt>lua_cpcall()</tt>.</li>
|
||||
<li>Fix return from <tt>pcall()</tt> within active hook.</li>
|
||||
</ul></li>
|
||||
<li>Structural and performance enhancements:
|
||||
<ul>
|
||||
<li>Replace on-trace GC frame syncing with interpreter exit.</li>
|
||||
<li>Improve hash lookup specialization by not removing dead keys during GC.</li>
|
||||
<li>Turn traces into true GC objects.</li>
|
||||
<li>Avoid starting a GC cycle immediately after library init.</li>
|
||||
<li>Add weak guards to improve dead-code elimination.</li>
|
||||
<li>Speed up string interning.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta4">LuaJIT 2.0.0-beta4 — 2010-03-28</h2>
|
||||
<ul>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>Fix precondition for on-trace creation of table keys.</li>
|
||||
<li>Fix <tt>{f()}</tt> on x64 when table is resized.</li>
|
||||
<li>Fix folding of ordered comparisons with same references.</li>
|
||||
<li>Fix snapshot restores for multi-result bytecodes.</li>
|
||||
<li>Fix potential hang when recording bytecode with nested closures.</li>
|
||||
<li>Fix recording of <tt>getmetatable()</tt>, <tt>tonumber()</tt> and bad argument types.</li>
|
||||
<li>Fix SLOAD fusion across returns to lower frames.</li>
|
||||
</ul></li>
|
||||
<li>Structural and performance enhancements:
|
||||
<ul>
|
||||
<li>Add array bounds check elimination. <tt>-Oabc</tt> is enabled by default.</li>
|
||||
<li>More tuning for x64, e.g. smaller table objects.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta3">LuaJIT 2.0.0-beta3 — 2010-03-07</h2>
|
||||
<ul>
|
||||
<li>LuaJIT x64 port:
|
||||
<ul>
|
||||
<li>Port integrated memory allocator to Linux/x64, Windows/x64 and OSX/x64.</li>
|
||||
<li>Port interpreter and JIT compiler to x64.</li>
|
||||
<li>Port DynASM to x64.</li>
|
||||
<li>Many 32/64 bit cleanups in the VM.</li>
|
||||
<li>Allow building the interpreter with either x87 or SSE2 arithmetics.</li>
|
||||
<li>Add external unwinding and C++ exception interop (default on x64).</li>
|
||||
</ul></li>
|
||||
<li>Correctness and completeness:
|
||||
<ul>
|
||||
<li>Fix constructor bytecode generation for certain conditional values.</li>
|
||||
<li>Fix some cases of ordered string comparisons.</li>
|
||||
<li>Fix <tt>lua_tocfunction()</tt>.</li>
|
||||
<li>Fix cutoff register in JMP bytecode for some conditional expressions.</li>
|
||||
<li>Fix PHI marking algorithm for references from variant slots.</li>
|
||||
<li>Fix <tt>package.cpath</tt> for non-default PREFIX.</li>
|
||||
<li>Fix DWARF2 frame unwind information for interpreter on OSX.</li>
|
||||
<li>Drive the GC forward on string allocations in the parser.</li>
|
||||
<li>Implement call/return hooks (zero-cost if disabled).</li>
|
||||
<li>Implement yield from C hooks.</li>
|
||||
<li>Disable JIT compiler on older non-SSE2 CPUs instead of aborting.</li>
|
||||
</ul></li>
|
||||
<li>Structural and performance enhancements:
|
||||
<ul>
|
||||
<li>Compile recursive code (tail-, up- and down-recursion).</li>
|
||||
<li>Improve heuristics for bytecode penalties and blacklisting.</li>
|
||||
<li>Split CALL/FUNC recording and clean up fast function call semantics.</li>
|
||||
<li>Major redesign of internal function call handling.</li>
|
||||
<li>Improve FOR loop const specialization and integerness checks.</li>
|
||||
<li>Switch to pre-initialized stacks. Avoid frame-clearing.</li>
|
||||
<li>Colocation of prototypes and related data: bytecode, constants, debug info.</li>
|
||||
<li>Cleanup parser and streamline bytecode generation.</li>
|
||||
<li>Add support for weak IR references to register allocator.</li>
|
||||
<li>Switch to compressed, extensible snapshots.</li>
|
||||
<li>Compile returns to frames below the start frame.</li>
|
||||
<li>Improve alias analysis of upvalues using a disambiguation hash value.</li>
|
||||
<li>Compile floor/ceil/trunc to SSE2 helper calls or SSE4.1 instructions.</li>
|
||||
<li>Add generic C call handling to IR and backend.</li>
|
||||
<li>Improve KNUM fuse vs. load heuristics.</li>
|
||||
<li>Compile various <tt>io.*()</tt> functions.</li>
|
||||
<li>Compile <tt>math.sinh()</tt>, <tt>math.cosh()</tt>, <tt>math.tanh()</tt>
|
||||
and <tt>math.random()</tt>.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta2">LuaJIT 2.0.0-beta2 — 2009-11-09</h2>
|
||||
<ul>
|
||||
<li>Reorganize build system. Build static+shared library on POSIX.</li>
|
||||
<li>Allow C++ exception conversion on all platforms
|
||||
using a wrapper function.</li>
|
||||
<li>Automatically catch C++ exceptions and rethrow Lua error
|
||||
(DWARF2 only).</li>
|
||||
<li>Check for the correct x87 FPU precision at strategic points.</li>
|
||||
<li>Always use wrappers for libm functions.</li>
|
||||
<li>Resurrect metamethod name strings before copying them.</li>
|
||||
<li>Mark current trace, even if compiler is idle.</li>
|
||||
<li>Ensure FILE metatable is created only once.</li>
|
||||
<li>Fix type comparisons when different integer types are involved.</li>
|
||||
<li>Fix <tt>getmetatable()</tt> recording.</li>
|
||||
<li>Fix TDUP with dead keys in template table.</li>
|
||||
<li><tt>jit.flush(tr)</tt> returns status.
|
||||
Prevent manual flush of a trace that's still linked.</li>
|
||||
<li>Improve register allocation heuristics for invariant references.</li>
|
||||
<li>Compile the push/pop variants of <tt>table.insert()</tt> and
|
||||
<tt>table.remove()</tt>.</li>
|
||||
<li>Compatibility with MSVC <tt>link /debug</tt>.</li>
|
||||
<li>Fix <tt>lua_iscfunction()</tt>.</li>
|
||||
<li>Fix <tt>math.random()</tt> when compiled with <tt>-fpic</tt> (OSX).</li>
|
||||
<li>Fix <tt>table.maxn()</tt>.</li>
|
||||
<li>Bump <tt>MACOSX_DEPLOYMENT_TARGET</tt> to <tt>10.4</tt></li>
|
||||
<li><tt>luaL_check*()</tt> and <tt>luaL_opt*()</tt> now support
|
||||
negative arguments, too.<br>
|
||||
This matches the behavior of Lua 5.1, but not the specification.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-2.0.0-beta1">LuaJIT 2.0.0-beta1 — 2009-10-31</h2>
|
||||
<ul>
|
||||
<li>This is the first public release of LuaJIT 2.0.</li>
|
||||
<li>The whole VM has been rewritten from the ground up, so there's
|
||||
no point in listing differences over earlier versions.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="major" style="background: #ffff80;">
|
||||
<h2 id="LuaJIT-1.1.8">LuaJIT 1.1.8 — 2012-04-16</h2>
|
||||
<ul>
|
||||
<li>Merged with Lua 5.1.5. Also integrated fixes for all
|
||||
<a href="http://www.lua.org/bugs.html#5.1.5"><span class="ext">»</span> <span class="ext">»</span> currently known bugs in Lua 5.1.5</a>.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-1.1.7">LuaJIT 1.1.7 — 2011-05-05</h2>
|
||||
<ul>
|
||||
<li>Added fixes for the
|
||||
<a href="http://www.lua.org/bugs.html#5.1.4"><span class="ext">»</span> currently known bugs in Lua 5.1.4</a>.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-1.1.6">LuaJIT 1.1.6 — 2010-03-28</h2>
|
||||
<ul>
|
||||
<li>Added fixes for the
|
||||
<a href="http://www.lua.org/bugs.html#5.1.4"><span class="ext">»</span> currently known bugs in Lua 5.1.4</a>.</li>
|
||||
<li>Removed wrong GC check in <tt>jit_createstate()</tt>.
|
||||
Thanks to Tim Mensch.</li>
|
||||
<li>Fixed bad assertions while compiling <tt>table.insert()</tt> and
|
||||
<tt>table.remove()</tt>.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-1.1.5">LuaJIT 1.1.5 — 2008-10-25</h2>
|
||||
<ul>
|
||||
<li>Merged with Lua 5.1.4. Fixes all
|
||||
<a href="http://www.lua.org/bugs.html#5.1.3"><span class="ext">»</span> known bugs in Lua 5.1.3</a>.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-1.1.4">LuaJIT 1.1.4 — 2008-02-05</h2>
|
||||
<ul>
|
||||
<li>Merged with Lua 5.1.3. Fixes all
|
||||
<a href="http://www.lua.org/bugs.html#5.1.2"><span class="ext">»</span> known bugs in Lua 5.1.2</a>.</li>
|
||||
<li>Fixed possible (but unlikely) stack corruption while compiling
|
||||
<tt>k^x</tt> expressions.</li>
|
||||
<li>Fixed DynASM template for cmpss instruction.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-1.1.3">LuaJIT 1.1.3 — 2007-05-24</h2>
|
||||
<ul>
|
||||
<li>Merged with Lua 5.1.2. Fixes all
|
||||
<a href="http://www.lua.org/bugs.html#5.1.1"><span class="ext">»</span> known bugs in Lua 5.1.1</a>.</li>
|
||||
<li>Merged pending Lua 5.1.x fixes: "return -nil" bug, spurious count hook call.</li>
|
||||
<li>Remove a (sometimes) wrong assertion in <tt>luaJIT_findpc()</tt>.</li>
|
||||
<li>DynASM now allows labels for displacements and <tt>.aword</tt>.</li>
|
||||
<li>Fix some compiler warnings for DynASM glue (internal API change).</li>
|
||||
<li>Correct naming for SSSE3 (temporarily known as SSE4) in DynASM and x86 disassembler.</li>
|
||||
<li>The loadable debug modules now handle redirection to stdout
|
||||
(e.g. <tt>-j trace=-</tt>).</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-1.1.2">LuaJIT 1.1.2 — 2006-06-24</h2>
|
||||
<ul>
|
||||
<li>Fix MSVC inline assembly: use only local variables with
|
||||
<tt>lua_number2int()</tt>.</li>
|
||||
<li>Fix "attempt to call a thread value" bug on Mac OS X:
|
||||
make values of consts used as lightuserdata keys unique
|
||||
to avoid joining by the compiler/linker.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="LuaJIT-1.1.1">LuaJIT 1.1.1 — 2006-06-20</h2>
|
||||
<ul>
|
||||
<li>Merged with Lua 5.1.1. Fixes all
|
||||
<a href="http://www.lua.org/bugs.html#5.1"><span class="ext">»</span> known bugs in Lua 5.1</a>.</li>
|
||||
<li>Enforce (dynamic) linker error for EXE/DLL version mismatches.</li>
|
||||
<li>Minor changes to DynASM: faster pre-processing, smaller encoding
|
||||
for some immediates.</li>
|
||||
</ul>
|
||||
<p>
|
||||
This release is in sync with Coco 1.1.1 (see the
|
||||
<a href="http://coco.luajit.org/changes.html"><span class="ext">»</span> Coco Change History</a>).
|
||||
</p>
|
||||
|
||||
<h2 id="LuaJIT-1.1.0">LuaJIT 1.1.0 — 2006-03-13</h2>
|
||||
<ul>
|
||||
<li>Merged with Lua 5.1 (final).</li>
|
||||
|
||||
<li>New JIT call frame setup:
|
||||
<ul>
|
||||
<li>The C stack is kept 16 byte aligned (faster).
|
||||
Mandatory for Mac OS X on Intel, too.</li>
|
||||
<li>Faster calling conventions for internal C helper functions.</li>
|
||||
<li>Better instruction scheduling for function prologue, OP_CALL and
|
||||
OP_RETURN.</li>
|
||||
</ul></li>
|
||||
|
||||
<li>Miscellaneous optimizations:
|
||||
<ul>
|
||||
<li>Faster loads of FP constants. Remove narrow-to-wide store-to-load
|
||||
forwarding stalls.</li>
|
||||
<li>Use (scalar) SSE2 ops (if the CPU supports it) to speed up slot moves
|
||||
and FP to integer conversions.</li>
|
||||
<li>Optimized the two-argument form of <tt>OP_CONCAT</tt> (<tt>a..b</tt>).</li>
|
||||
<li>Inlined <tt>OP_MOD</tt> (<tt>a%b</tt>).
|
||||
With better accuracy than the C variant, too.</li>
|
||||
<li>Inlined <tt>OP_POW</tt> (<tt>a^b</tt>). Unroll <tt>x^k</tt> or
|
||||
use <tt>k^x = 2^(log2(k)*x)</tt> or call <tt>pow()</tt>.</li>
|
||||
</ul></li>
|
||||
|
||||
<li>Changes in the optimizer:
|
||||
<ul>
|
||||
<li>Improved hinting for table keys derived from table values
|
||||
(<tt>t1[t2[x]]</tt>).</li>
|
||||
<li>Lookup hinting now works with arbitrary object types and
|
||||
supports index chains, too.</li>
|
||||
<li>Generate type hints for arithmetic and comparison operators,
|
||||
OP_LEN, OP_CONCAT and OP_FORPREP.</li>
|
||||
<li>Remove several hint definitions in favour of a generic COMBINE hint.</li>
|
||||
<li>Complete rewrite of <tt>jit.opt_inline</tt> module
|
||||
(ex <tt>jit.opt_lib</tt>).</li>
|
||||
</ul></li>
|
||||
|
||||
<li>Use adaptive deoptimization:
|
||||
<ul>
|
||||
<li>If runtime verification of a contract fails, the affected
|
||||
instruction is recompiled and patched on-the-fly.
|
||||
Regular programs will trigger deoptimization only occasionally.</li>
|
||||
<li>This avoids generating code for uncommon fallback cases
|
||||
most of the time. Generated code is up to 30% smaller compared to
|
||||
LuaJIT 1.0.3.</li>
|
||||
<li>Deoptimization is used for many opcodes and contracts:
|
||||
<ul>
|
||||
<li>OP_CALL, OP_TAILCALL: type mismatch for callable.</li>
|
||||
<li>Inlined calls: closure mismatch, parameter number and type mismatches.</li>
|
||||
<li>OP_GETTABLE, OP_SETTABLE: table or key type and range mismatches.</li>
|
||||
<li>All arithmetic and comparison operators, OP_LEN, OP_CONCAT,
|
||||
OP_FORPREP: operand type and range mismatches.</li>
|
||||
</ul></li>
|
||||
<li>Complete redesign of the debug and traceback info
|
||||
(bytecode ↔ mcode) to support deoptimization.
|
||||
Much more flexible and needs only 50% of the space.</li>
|
||||
<li>The modules <tt>jit.trace</tt>, <tt>jit.dumphints</tt> and
|
||||
<tt>jit.dump</tt> handle deoptimization.</li>
|
||||
</ul></li>
|
||||
|
||||
<li>Inlined many popular library functions
|
||||
(for commonly used arguments only):
|
||||
<ul>
|
||||
<li>Most <tt>math.*</tt> functions (the 18 most used ones)
|
||||
[2x-10x faster].</li>
|
||||
<li><tt>string.len</tt>, <tt>string.sub</tt> and <tt>string.char</tt>
|
||||
[2x-10x faster].</li>
|
||||
<li><tt>table.insert</tt>, <tt>table.remove</tt> and <tt>table.getn</tt>
|
||||
[3x-5x faster].</li>
|
||||
<li><tt>coroutine.yield</tt> and <tt>coroutine.resume</tt>
|
||||
[3x-5x faster].</li>
|
||||
<li><tt>pairs</tt>, <tt>ipairs</tt> and the corresponding iterators
|
||||
[8x-15x faster].</li>
|
||||
</ul></li>
|
||||
|
||||
<li>Changes in the core and loadable modules and the stand-alone executable:
|
||||
<ul>
|
||||
<li>Added <tt>jit.version</tt>, <tt>jit.version_num</tt>
|
||||
and <tt>jit.arch</tt>.</li>
|
||||
<li>Reorganized some internal API functions (<tt>jit.util.*mcode*</tt>).</li>
|
||||
<li>The <tt>-j dump</tt> output now shows JSUB names, too.</li>
|
||||
<li>New x86 disassembler module written in pure Lua. No dependency
|
||||
on ndisasm anymore. Flexible API, very compact (500 lines)
|
||||
and complete (x87, MMX, SSE, SSE2, SSE3, SSSE3, privileged instructions).</li>
|
||||
<li><tt>luajit -v</tt> prints the LuaJIT version and copyright
|
||||
on a separate line.</li>
|
||||
</ul></li>
|
||||
|
||||
<li>Added SSE, SSE2, SSE3 and SSSE3 support to DynASM.</li>
|
||||
<li>Miscellaneous doc changes. Added a section about
|
||||
<a href="install.html#embedding">embedding LuaJIT</a>.</li>
|
||||
</ul>
|
||||
<p>
|
||||
This release is in sync with Coco 1.1.0 (see the
|
||||
<a href="http://coco.luajit.org/changes.html"><span class="ext">»</span> Coco Change History</a>).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="major" style="background: #ffffd0;">
|
||||
<h2 id="LuaJIT-1.0.3">LuaJIT 1.0.3 — 2005-09-08</h2>
|
||||
<ul>
|
||||
<li>Even more docs.</li>
|
||||
<li>Unified closure checks in <tt>jit.*</tt>.</li>
|
||||
<li>Fixed some range checks in <tt>jit.util.*</tt>.</li>
|
||||
<li>Fixed __newindex call originating from <tt>jit_settable_str()</tt>.</li>
|
||||
<li>Merged with Lua 5.1 alpha (including early bug fixes).</li>
|
||||
</ul>
|
||||
<p>
|
||||
This is the first public release of LuaJIT.
|
||||
</p>
|
||||
|
||||
<h2 id="LuaJIT-1.0.2">LuaJIT 1.0.2 — 2005-09-02</h2>
|
||||
<ul>
|
||||
<li>Add support for flushing the Valgrind translation cache <br>
|
||||
(<tt>MYCFLAGS= -DUSE_VALGRIND</tt>).</li>
|
||||
<li>Add support for freeing executable mcode memory to the <tt>mmap()</tt>-based
|
||||
variant for POSIX systems.</li>
|
||||
<li>Reorganized the C function signature handling in
|
||||
<tt>jit.opt_lib</tt>.</li>
|
||||
<li>Changed to index-based hints for inlining C functions.
|
||||
Still no support in the backend for inlining.</li>
|
||||
<li>Hardcode <tt>HEAP_CREATE_ENABLE_EXECUTE</tt> value if undefined.</li>
|
||||
<li>Misc. changes to the <tt>jit.*</tt> modules.</li>
|
||||
<li>Misc. changes to the Makefiles.</li>
|
||||
<li>Lots of new docs.</li>
|
||||
<li>Complete doc reorg.</li>
|
||||
</ul>
|
||||
<p>
|
||||
Not released because Lua 5.1 alpha came out today.
|
||||
</p>
|
||||
|
||||
<h2 id="LuaJIT-1.0.1">LuaJIT 1.0.1 — 2005-08-31</h2>
|
||||
<ul>
|
||||
<li>Missing GC step in <tt>OP_CONCAT</tt>.</li>
|
||||
<li>Fix result handling for C –> JIT calls.</li>
|
||||
<li>Detect CPU feature bits.</li>
|
||||
<li>Encode conditional moves (<tt>fucomip</tt>) only when supported.</li>
|
||||
<li>Add fallback instructions for FP compares.</li>
|
||||
<li>Add support for <tt>LUA_COMPAT_VARARG</tt>. Still disabled by default.</li>
|
||||
<li>MSVC needs a specific place for the <tt>CALLBACK</tt> attribute
|
||||
(David Burgess).</li>
|
||||
<li>Misc. doc updates.</li>
|
||||
</ul>
|
||||
<p>
|
||||
Interim non-public release.
|
||||
Special thanks to Adam D. Moss for reporting most of the bugs.
|
||||
</p>
|
||||
|
||||
<h2 id="LuaJIT-1.0.0">LuaJIT 1.0.0 — 2005-08-29</h2>
|
||||
<p>
|
||||
This is the initial non-public release of LuaJIT.
|
||||
</p>
|
||||
</div>
|
||||
<br class="flush">
|
||||
</div>
|
||||
<div id="foot">
|
||||
<hr class="hide">
|
||||
Copyright © 2005-2013 Mike Pall
|
||||
<span class="noprint">
|
||||
·
|
||||
<a href="contact.html">Contact</a>
|
||||
</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,24 +0,0 @@
|
||||
# Package information for LuaJIT to be used by pkg-config.
|
||||
majver=2
|
||||
minver=0
|
||||
relver=1
|
||||
version=${majver}.${minver}.${relver}
|
||||
abiver=5.1
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
libname=luajit-${abiver}
|
||||
includedir=${prefix}/include/luajit-${majver}.${minver}
|
||||
|
||||
INSTALL_LMOD=${prefix}/share/lua/${abiver}
|
||||
INSTALL_CMOD=${prefix}/lib/lua/${abiver}
|
||||
|
||||
Name: LuaJIT
|
||||
Description: Just-in-time compiler for Lua
|
||||
URL: http://luajit.org
|
||||
Version: ${version}
|
||||
Requires:
|
||||
Libs: -L${libdir} -l${libname}
|
||||
Libs.private: -Wl,-E -lm -ldl
|
||||
Cflags: -I${includedir}
|
||||
@@ -1,676 +0,0 @@
|
||||
##############################################################################
|
||||
# LuaJIT Makefile. Requires GNU Make.
|
||||
#
|
||||
# Please read doc/install.html before changing any variables!
|
||||
#
|
||||
# Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
|
||||
# Also works with MinGW and Cygwin on Windows.
|
||||
# Please check msvcbuild.bat for building with MSVC on Windows.
|
||||
#
|
||||
# Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h
|
||||
##############################################################################
|
||||
|
||||
MAJVER= 2
|
||||
MINVER= 0
|
||||
RELVER= 0
|
||||
ABIVER= 5.1
|
||||
NODOTABIVER= 51
|
||||
|
||||
##############################################################################
|
||||
############################# COMPILER OPTIONS #############################
|
||||
##############################################################################
|
||||
# These options mainly affect the speed of the JIT compiler itself, not the
|
||||
# speed of the JIT-compiled code. Turn any of the optional settings on by
|
||||
# removing the '#' in front of them. Make sure you force a full recompile
|
||||
# with "make clean", followed by "make" if you change any options.
|
||||
#
|
||||
# LuaJIT builds as a native 32 or 64 bit binary by default.
|
||||
CC= gcc
|
||||
#
|
||||
# Use this if you want to force a 32 bit build on a 64 bit multilib OS.
|
||||
#CC= gcc -m32
|
||||
#
|
||||
# Since the assembler part does NOT maintain a frame pointer, it's pointless
|
||||
# to slow down the C part by not omitting it. Debugging, tracebacks and
|
||||
# unwinding are not affected -- the assembler part has frame unwind
|
||||
# information and GCC emits it where needed (x64) or with -g (see CCDEBUG).
|
||||
CCOPT= -O2 -fomit-frame-pointer
|
||||
# Use this if you want to generate a smaller binary (but it's slower):
|
||||
#CCOPT= -Os -fomit-frame-pointer
|
||||
# Note: it's no longer recommended to use -O3 with GCC 4.x.
|
||||
# The I-Cache bloat usually outweighs the benefits from aggressive inlining.
|
||||
#
|
||||
# Target-specific compiler options:
|
||||
#
|
||||
# x86 only: it's recommended to compile at least for i686. Better yet,
|
||||
# compile for an architecture that has SSE2, too (-msse -msse2).
|
||||
#
|
||||
# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute
|
||||
# the binaries to a different machine you could also use: -march=native
|
||||
#
|
||||
CCOPT_x86= -march=i686
|
||||
CCOPT_x64=
|
||||
CCOPT_arm=
|
||||
CCOPT_ppc=
|
||||
CCOPT_ppcspe=
|
||||
CCOPT_mips=
|
||||
#
|
||||
CCDEBUG=
|
||||
# Uncomment the next line to generate debug information:
|
||||
#CCDEBUG= -g
|
||||
#
|
||||
CCWARN= -Wall
|
||||
# Uncomment the next line to enable more warnings:
|
||||
#CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
################################ BUILD MODE ################################
|
||||
##############################################################################
|
||||
# The default build mode is mixed mode on POSIX. On Windows this is the same
|
||||
# as dynamic mode.
|
||||
#
|
||||
# Mixed mode creates a static + dynamic library and a statically linked luajit.
|
||||
BUILDMODE= mixed
|
||||
#
|
||||
# Static mode creates a static library and a statically linked luajit.
|
||||
#BUILDMODE= static
|
||||
#
|
||||
# Dynamic mode creates a dynamic library and a dynamically linked luajit.
|
||||
# Note: this executable will only run when the library is installed!
|
||||
#BUILDMODE= dynamic
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
################################# FEATURES #################################
|
||||
##############################################################################
|
||||
# Enable/disable these features as needed, but make sure you force a full
|
||||
# recompile with "make clean", followed by "make".
|
||||
XCFLAGS=
|
||||
#
|
||||
# Permanently disable the FFI extension to reduce the size of the LuaJIT
|
||||
# executable. But please consider that the FFI library is compiled-in,
|
||||
# but NOT loaded by default. It only allocates any memory, if you actually
|
||||
# make use of it.
|
||||
#XCFLAGS+= -DLUAJIT_DISABLE_FFI
|
||||
#
|
||||
# Features from Lua 5.2 that are unlikely to break existing code are
|
||||
# enabled by default. Some other features that *might* break some existing
|
||||
# code (e.g. __pairs or os.execute() return values) can be enabled here.
|
||||
# Note: this does not provide full compatibility with Lua 5.2 at this time.
|
||||
#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
|
||||
#
|
||||
# Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
|
||||
#XCFLAGS+= -DLUAJIT_DISABLE_JIT
|
||||
#
|
||||
# Some architectures (e.g. PPC) can use either single-number (1) or
|
||||
# dual-number (2) mode. Uncomment one of these lines to override the
|
||||
# default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details.
|
||||
#XCFLAGS+= -DLUAJIT_NUMMODE=1
|
||||
#XCFLAGS+= -DLUAJIT_NUMMODE=2
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
############################ DEBUGGING SUPPORT #############################
|
||||
##############################################################################
|
||||
# Enable these options as needed, but make sure you force a full recompile
|
||||
# with "make clean", followed by "make".
|
||||
# Note that most of these are NOT suitable for benchmarking or release mode!
|
||||
#
|
||||
# Use the system provided memory allocator (realloc) instead of the
|
||||
# bundled memory allocator. This is slower, but sometimes helpful for
|
||||
# debugging. It's helpful for Valgrind's memcheck tool, too. This option
|
||||
# cannot be enabled on x64, since the built-in allocator is mandatory.
|
||||
#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
|
||||
#
|
||||
# This define is required to run LuaJIT under Valgrind. The Valgrind
|
||||
# header files must be installed. You should enable debug information, too.
|
||||
# Use --suppressions=lj.supp to avoid some false positives.
|
||||
#XCFLAGS+= -DLUAJIT_USE_VALGRIND
|
||||
#
|
||||
# This is the client for the GDB JIT API. GDB 7.0 or higher is required
|
||||
# to make use of it. See lj_gdbjit.c for details. Enabling this causes
|
||||
# a non-negligible overhead, even when not running under GDB.
|
||||
#XCFLAGS+= -DLUAJIT_USE_GDBJIT
|
||||
#
|
||||
# Turn on assertions for the Lua/C API to debug problems with lua_* calls.
|
||||
# This is rather slow -- use only while developing C libraries/embeddings.
|
||||
#XCFLAGS+= -DLUA_USE_APICHECK
|
||||
#
|
||||
# Turn on assertions for the whole LuaJIT VM. This significantly slows down
|
||||
# everything. Use only if you suspect a problem with LuaJIT itself.
|
||||
#XCFLAGS+= -DLUA_USE_ASSERT
|
||||
#
|
||||
##############################################################################
|
||||
# You probably don't need to change anything below this line!
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Flags and options for host and target.
|
||||
##############################################################################
|
||||
|
||||
# You can override the following variables at the make command line:
|
||||
# CC HOST_CC STATIC_CC DYNAMIC_CC
|
||||
# CFLAGS HOST_CFLAGS TARGET_CFLAGS
|
||||
# LDFLAGS HOST_LDFLAGS TARGET_LDFLAGS TARGET_SHLDFLAGS
|
||||
# LIBS HOST_LIBS TARGET_LIBS
|
||||
# CROSS HOST_SYS TARGET_SYS TARGET_FLAGS
|
||||
#
|
||||
# Cross-compilation examples:
|
||||
# make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
|
||||
# make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
|
||||
|
||||
CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
|
||||
LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
|
||||
|
||||
HOST_CC= $(CC)
|
||||
HOST_RM= rm -f
|
||||
# If left blank, minilua is built and used. You can supply an installed
|
||||
# copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua
|
||||
HOST_LUA=
|
||||
|
||||
HOST_XCFLAGS= -I.
|
||||
HOST_XLDFLAGS=
|
||||
HOST_XLIBS=
|
||||
HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS)
|
||||
HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS)
|
||||
HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS)
|
||||
|
||||
STATIC_CC = $(CROSS)$(CC)
|
||||
DYNAMIC_CC = $(CROSS)$(CC) -fPIC
|
||||
TARGET_CC= $(STATIC_CC)
|
||||
TARGET_STCC= $(STATIC_CC)
|
||||
TARGET_DYNCC= $(DYNAMIC_CC)
|
||||
TARGET_LD= $(CROSS)$(CC)
|
||||
TARGET_AR= $(CROSS)ar rcus
|
||||
TARGET_STRIP= $(CROSS)strip
|
||||
|
||||
TARGET_SONAME= libluajit.so
|
||||
TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib
|
||||
TARGET_DYLIBPATH= $(or $(PREFIX),/usr/local)/lib/$(TARGET_DYLIBNAME)
|
||||
TARGET_DLLNAME= lua$(NODOTABIVER).dll
|
||||
TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
|
||||
TARGET_DYNXLDOPTS=
|
||||
|
||||
TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
|
||||
TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE
|
||||
TARGET_XLDFLAGS=
|
||||
TARGET_XLIBS= -lm
|
||||
TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
|
||||
TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
|
||||
TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
|
||||
TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
|
||||
TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)
|
||||
|
||||
TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM)
|
||||
ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
|
||||
TARGET_LJARCH= x64
|
||||
else
|
||||
ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
|
||||
TARGET_LJARCH= x86
|
||||
else
|
||||
ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
|
||||
TARGET_LJARCH= arm
|
||||
else
|
||||
ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
|
||||
TARGET_LJARCH= ppc
|
||||
else
|
||||
ifneq (,$(findstring LJ_TARGET_PPCSPE ,$(TARGET_TESTARCH)))
|
||||
TARGET_LJARCH= ppcspe
|
||||
else
|
||||
ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
|
||||
ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
|
||||
TARGET_ARCH= -D__MIPSEL__=1
|
||||
endif
|
||||
TARGET_LJARCH= mips
|
||||
else
|
||||
$(error Unsupported target architecture)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
|
||||
TARGET_SYS= PS3
|
||||
TARGET_ARCH+= -D__CELLOS_LV2__
|
||||
TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
|
||||
endif
|
||||
ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
|
||||
TARGET_ARCH+= -DLUAJIT_NO_UNWIND
|
||||
endif
|
||||
|
||||
TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
|
||||
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
|
||||
|
||||
ifneq (,$(PREFIX))
|
||||
ifneq (/usr/local,$(PREFIX))
|
||||
TARGET_XCFLAGS+= -DLUA_XROOT=\"$(PREFIX)/\"
|
||||
ifneq (/usr,$(PREFIX))
|
||||
TARGET_DYNXLDOPTS= -Wl,-rpath,$(PREFIX)/lib
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
# System detection.
|
||||
##############################################################################
|
||||
|
||||
ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM))
|
||||
HOST_SYS= Windows
|
||||
HOST_RM= del
|
||||
else
|
||||
HOST_SYS:= $(shell uname -s)
|
||||
ifneq (,$(findstring MINGW,$(HOST_SYS)))
|
||||
HOST_SYS= Windows
|
||||
HOST_MSYS= mingw
|
||||
endif
|
||||
ifneq (,$(findstring CYGWIN,$(HOST_SYS)))
|
||||
HOST_SYS= Windows
|
||||
HOST_MSYS= cygwin
|
||||
endif
|
||||
endif
|
||||
|
||||
TARGET_SYS?= $(HOST_SYS)
|
||||
ifeq (Windows,$(TARGET_SYS))
|
||||
TARGET_STRIP+= --strip-unneeded
|
||||
TARGET_XSHLDFLAGS= -shared
|
||||
TARGET_DYNXLDOPTS=
|
||||
else
|
||||
ifeq (Darwin,$(TARGET_SYS))
|
||||
ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.4
|
||||
endif
|
||||
TARGET_STRIP+= -x
|
||||
TARGET_AR+= 2>/dev/null
|
||||
TARGET_XCFLAGS+= -fno-stack-protector
|
||||
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
|
||||
TARGET_DYNXLDOPTS=
|
||||
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
|
||||
ifeq (x64,$(TARGET_LJARCH))
|
||||
TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000
|
||||
TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000
|
||||
endif
|
||||
else
|
||||
ifeq (iOS,$(TARGET_SYS))
|
||||
TARGET_STRIP+= -x
|
||||
TARGET_AR+= 2>/dev/null
|
||||
TARGET_XCFLAGS+= -fno-stack-protector
|
||||
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
|
||||
TARGET_DYNXLDOPTS=
|
||||
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
|
||||
else
|
||||
ifneq (,$(findstring stack-protector,$(shell $(TARGET_CC) -dumpspecs)))
|
||||
TARGET_XCFLAGS+= -fno-stack-protector
|
||||
endif
|
||||
ifneq (SunOS,$(TARGET_SYS))
|
||||
ifneq (PS3,$(TARGET_SYS))
|
||||
TARGET_XLDFLAGS+= -Wl,-E
|
||||
endif
|
||||
endif
|
||||
ifeq (Linux,$(TARGET_SYS))
|
||||
TARGET_XLIBS+= -ldl
|
||||
endif
|
||||
ifeq (GNU/kFreeBSD,$(TARGET_SYS))
|
||||
TARGET_XLIBS+= -ldl
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(HOST_SYS),$(TARGET_SYS))
|
||||
ifeq (Windows,$(TARGET_SYS))
|
||||
HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
|
||||
else
|
||||
ifeq (Linux,$(TARGET_SYS))
|
||||
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX
|
||||
else
|
||||
ifeq (Darwin,$(TARGET_SYS))
|
||||
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
|
||||
else
|
||||
ifeq (iOS,$(TARGET_SYS))
|
||||
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
|
||||
else
|
||||
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(CCDEBUG))
|
||||
TARGET_STRIP= @:
|
||||
endif
|
||||
|
||||
##############################################################################
|
||||
# Files and pathnames.
|
||||
##############################################################################
|
||||
|
||||
MINILUA_O= host/minilua.o
|
||||
MINILUA_LIBS= -lm
|
||||
MINILUA_T= host/minilua
|
||||
MINILUA_X= $(MINILUA_T)
|
||||
|
||||
ifeq (,$(HOST_LUA))
|
||||
HOST_LUA= $(MINILUA_X)
|
||||
DASM_DEP= $(MINILUA_T)
|
||||
endif
|
||||
|
||||
DASM_DIR= ../dynasm
|
||||
DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
|
||||
DASM_XFLAGS=
|
||||
DASM_AFLAGS=
|
||||
DASM_ARCH= $(TARGET_LJARCH)
|
||||
|
||||
ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D P64
|
||||
endif
|
||||
ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D JIT
|
||||
endif
|
||||
ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D FFI
|
||||
endif
|
||||
ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D DUALNUM
|
||||
endif
|
||||
ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D FPU
|
||||
TARGET_ARCH+= -DLJ_ARCH_HASFPU=1
|
||||
else
|
||||
TARGET_ARCH+= -DLJ_ARCH_HASFPU=0
|
||||
endif
|
||||
ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D HFABI
|
||||
TARGET_ARCH+= -DLJ_ABI_SOFTFP=0
|
||||
else
|
||||
TARGET_ARCH+= -DLJ_ABI_SOFTFP=1
|
||||
endif
|
||||
DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH))))
|
||||
ifeq (Windows,$(TARGET_SYS))
|
||||
DASM_AFLAGS+= -D WIN
|
||||
endif
|
||||
ifeq (x86,$(TARGET_LJARCH))
|
||||
ifneq (,$(findstring __SSE2__ 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D SSE
|
||||
endif
|
||||
else
|
||||
ifeq (x64,$(TARGET_LJARCH))
|
||||
DASM_ARCH= x86
|
||||
else
|
||||
ifeq (arm,$(TARGET_LJARCH))
|
||||
ifeq (iOS,$(TARGET_SYS))
|
||||
DASM_AFLAGS+= -D IOS
|
||||
endif
|
||||
else
|
||||
ifeq (ppc,$(TARGET_LJARCH))
|
||||
ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D SQRT
|
||||
endif
|
||||
ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D ROUND
|
||||
endif
|
||||
ifneq (,$(findstring LJ_ARCH_PPC64 1,$(TARGET_TESTARCH)))
|
||||
DASM_AFLAGS+= -D GPR64
|
||||
endif
|
||||
ifeq (PS3,$(TARGET_SYS))
|
||||
DASM_AFLAGS+= -D PPE -D TOC
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS)
|
||||
DASM_DASC= vm_$(DASM_ARCH).dasc
|
||||
|
||||
BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \
|
||||
host/buildvm_lib.o host/buildvm_fold.o
|
||||
BUILDVM_T= host/buildvm
|
||||
BUILDVM_X= $(BUILDVM_T)
|
||||
|
||||
HOST_O= $(MINILUA_O) $(BUILDVM_O)
|
||||
HOST_T= $(MINILUA_T) $(BUILDVM_T)
|
||||
|
||||
LJVM_S= lj_vm.s
|
||||
LJVM_O= lj_vm.o
|
||||
LJVM_BOUT= $(LJVM_S)
|
||||
LJVM_MODE= elfasm
|
||||
|
||||
LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
|
||||
lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o
|
||||
LJLIB_C= $(LJLIB_O:.o=.c)
|
||||
|
||||
LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o \
|
||||
lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
|
||||
lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_strscan.o \
|
||||
lj_api.o lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \
|
||||
lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
|
||||
lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \
|
||||
lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
|
||||
lj_asm.o lj_trace.o lj_gdbjit.o \
|
||||
lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \
|
||||
lj_carith.o lj_clib.o lj_cparse.o \
|
||||
lj_lib.o lj_alloc.o lib_aux.o \
|
||||
$(LJLIB_O) lib_init.o
|
||||
|
||||
LJVMCORE_O= $(LJVM_O) $(LJCORE_O)
|
||||
LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o)
|
||||
|
||||
LIB_VMDEF= jit/vmdef.lua
|
||||
LIB_VMDEFP= $(LIB_VMDEF)
|
||||
|
||||
LUAJIT_O= luajit.o
|
||||
LUAJIT_A= libluajit.a
|
||||
LUAJIT_SO= libluajit.so
|
||||
LUAJIT_T= luajit
|
||||
|
||||
ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T)
|
||||
ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
|
||||
host/buildvm_arch.h
|
||||
ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
|
||||
WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
|
||||
ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM)
|
||||
|
||||
##############################################################################
|
||||
# Build mode handling.
|
||||
##############################################################################
|
||||
|
||||
# Mixed mode defaults.
|
||||
TARGET_O= $(LUAJIT_A)
|
||||
TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
|
||||
TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)
|
||||
|
||||
ifeq (Windows,$(TARGET_SYS))
|
||||
TARGET_DYNCC= $(STATIC_CC)
|
||||
LJVM_MODE= coffasm
|
||||
LUAJIT_T= luajit.exe
|
||||
ifeq (cygwin,$(HOST_MSYS))
|
||||
LUAJIT_SO= cyg$(TARGET_DLLNAME)
|
||||
else
|
||||
LUAJIT_SO= $(TARGET_DLLNAME)
|
||||
endif
|
||||
# Mixed mode is not supported on Windows. And static mode doesn't work well.
|
||||
# C modules cannot be loaded, because they bind to lua51.dll.
|
||||
ifneq (static,$(BUILDMODE))
|
||||
BUILDMODE= dynamic
|
||||
TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL
|
||||
endif
|
||||
endif
|
||||
ifeq (Darwin,$(TARGET_SYS))
|
||||
LJVM_MODE= machasm
|
||||
endif
|
||||
ifeq (iOS,$(TARGET_SYS))
|
||||
LJVM_MODE= machasm
|
||||
endif
|
||||
ifeq (SunOS,$(TARGET_SYS))
|
||||
BUILDMODE= static
|
||||
endif
|
||||
ifeq (PS3,$(TARGET_SYS))
|
||||
BUILDMODE= static
|
||||
endif
|
||||
|
||||
ifeq (Windows,$(HOST_SYS))
|
||||
MINILUA_T= host/minilua.exe
|
||||
BUILDVM_T= host/buildvm.exe
|
||||
ifeq (,$(HOST_MSYS))
|
||||
MINILUA_X= host\minilua
|
||||
BUILDVM_X= host\buildvm
|
||||
ALL_RM:= $(subst /,\,$(ALL_RM))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (static,$(BUILDMODE))
|
||||
TARGET_DYNCC= @:
|
||||
TARGET_T= $(LUAJIT_T)
|
||||
TARGET_DEP= $(LIB_VMDEF)
|
||||
else
|
||||
ifeq (dynamic,$(BUILDMODE))
|
||||
ifneq (Windows,$(TARGET_SYS))
|
||||
TARGET_CC= $(DYNAMIC_CC)
|
||||
endif
|
||||
TARGET_DYNCC= @:
|
||||
LJVMCORE_DYNO= $(LJVMCORE_O)
|
||||
TARGET_O= $(LUAJIT_SO)
|
||||
TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS)
|
||||
else
|
||||
ifeq (Darwin,$(TARGET_SYS))
|
||||
TARGET_DYNCC= @:
|
||||
LJVMCORE_DYNO= $(LJVMCORE_O)
|
||||
endif
|
||||
ifeq (iOS,$(TARGET_SYS))
|
||||
TARGET_DYNCC= @:
|
||||
LJVMCORE_DYNO= $(LJVMCORE_O)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
Q= @
|
||||
E= @echo
|
||||
#Q=
|
||||
#E= @:
|
||||
|
||||
##############################################################################
|
||||
# Make targets.
|
||||
##############################################################################
|
||||
|
||||
default all: $(TARGET_T)
|
||||
|
||||
amalg:
|
||||
@grep "^[+|]" ljamalg.c
|
||||
$(MAKE) all "LJCORE_O=ljamalg.o"
|
||||
|
||||
clean:
|
||||
$(HOST_RM) $(ALL_RM)
|
||||
|
||||
depend:
|
||||
@for file in $(ALL_HDRGEN); do \
|
||||
test -f $$file || touch $$file; \
|
||||
done
|
||||
@$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \
|
||||
sed -e "s| [^ ]*/dasm_\S*\.h||g" \
|
||||
-e "s|^\([^l ]\)|host/\1|" \
|
||||
-e "s| lj_target_\S*\.h| lj_target_*.h|g" \
|
||||
-e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \
|
||||
-e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep
|
||||
@for file in $(ALL_HDRGEN); do \
|
||||
test -s $$file || $(HOST_RM) $$file; \
|
||||
done
|
||||
|
||||
.PHONY: default all amalg clean depend
|
||||
|
||||
##############################################################################
|
||||
# Rules for generated files.
|
||||
##############################################################################
|
||||
|
||||
$(MINILUA_T): $(MINILUA_O)
|
||||
$(E) "HOSTLINK $@"
|
||||
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
|
||||
|
||||
host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP)
|
||||
$(E) "DYNASM $@"
|
||||
$(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
|
||||
|
||||
host/buildvm.o: $(DASM_DIR)/dasm_*.h
|
||||
|
||||
$(BUILDVM_T): $(BUILDVM_O)
|
||||
$(E) "HOSTLINK $@"
|
||||
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS)
|
||||
|
||||
$(LJVM_BOUT): $(BUILDVM_T)
|
||||
$(E) "BUILDVM $@"
|
||||
$(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@
|
||||
|
||||
lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
|
||||
$(E) "BUILDVM $@"
|
||||
$(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)
|
||||
|
||||
lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
|
||||
$(E) "BUILDVM $@"
|
||||
$(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)
|
||||
|
||||
lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
|
||||
$(E) "BUILDVM $@"
|
||||
$(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)
|
||||
|
||||
lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
|
||||
$(E) "BUILDVM $@"
|
||||
$(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)
|
||||
|
||||
$(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
|
||||
$(E) "BUILDVM $@"
|
||||
$(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)
|
||||
|
||||
lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
|
||||
$(E) "BUILDVM $@"
|
||||
$(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c
|
||||
|
||||
##############################################################################
|
||||
# Object file rules.
|
||||
##############################################################################
|
||||
|
||||
%.o: %.c
|
||||
$(E) "CC $@"
|
||||
$(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
|
||||
$(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
|
||||
|
||||
%.o: %.s
|
||||
$(E) "ASM $@"
|
||||
$(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
|
||||
$(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
|
||||
|
||||
$(LUAJIT_O):
|
||||
$(E) "CC $@"
|
||||
$(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $<
|
||||
|
||||
$(HOST_O): %.o: %.c
|
||||
$(E) "HOSTCC $@"
|
||||
$(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $<
|
||||
|
||||
include Makefile.dep
|
||||
|
||||
##############################################################################
|
||||
# Target file rules.
|
||||
##############################################################################
|
||||
|
||||
$(LUAJIT_A): $(LJVMCORE_O)
|
||||
$(E) "AR $@"
|
||||
$(Q)$(TARGET_AR) $@ $(LJVMCORE_O)
|
||||
|
||||
# The dependency on _O, but linking with _DYNO is intentional.
|
||||
$(LUAJIT_SO): $(LJVMCORE_O)
|
||||
$(E) "DYNLINK $@"
|
||||
$(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS)
|
||||
$(Q)$(TARGET_STRIP) $@
|
||||
|
||||
$(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP)
|
||||
$(E) "LINK $@"
|
||||
$(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS)
|
||||
$(Q)$(TARGET_STRIP) $@
|
||||
$(E) "OK Successfully built LuaJIT"
|
||||
|
||||
##############################################################################
|
||||
@@ -1,226 +0,0 @@
|
||||
lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \
|
||||
lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_trace.h lj_jit.h lj_ir.h \
|
||||
lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h
|
||||
lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
|
||||
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \
|
||||
lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \
|
||||
lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \
|
||||
lj_lib.h lj_libdef.h
|
||||
lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
||||
lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h
|
||||
lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
|
||||
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_lib.h \
|
||||
lj_libdef.h
|
||||
lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
||||
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h \
|
||||
lj_ctype.h lj_cparse.h lj_cdata.h lj_cconv.h lj_carith.h lj_ccall.h \
|
||||
lj_ccallback.h lj_clib.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h
|
||||
lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h
|
||||
lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
||||
lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h lj_ffdef.h \
|
||||
lj_lib.h lj_libdef.h
|
||||
lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \
|
||||
lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \
|
||||
lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \
|
||||
lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \
|
||||
lj_libdef.h
|
||||
lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
|
||||
lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h
|
||||
lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
||||
lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_libdef.h
|
||||
lib_package.o: lib_package.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
|
||||
lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h
|
||||
lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
|
||||
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h \
|
||||
lj_meta.h lj_state.h lj_ff.h lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \
|
||||
lj_lib.h lj_libdef.h
|
||||
lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
|
||||
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_lib.h \
|
||||
lj_libdef.h
|
||||
lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h
|
||||
lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \
|
||||
lj_meta.h lj_state.h lj_bc.h lj_frame.h lj_trace.h lj_jit.h lj_ir.h \
|
||||
lj_dispatch.h lj_traceerr.h lj_vm.h lj_strscan.h
|
||||
lj_asm.o: lj_asm.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h \
|
||||
lj_ircall.h lj_iropt.h lj_mcode.h lj_trace.h lj_dispatch.h lj_traceerr.h \
|
||||
lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \
|
||||
lj_asm_*.h
|
||||
lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \
|
||||
lj_bcdef.h
|
||||
lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h lj_ctype.h \
|
||||
lj_cdata.h lualib.h lj_lex.h lj_bcdump.h lj_state.h
|
||||
lj_bcwrite.o: lj_bcwrite.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_str.h lj_bc.h lj_ctype.h lj_dispatch.h lj_jit.h lj_ir.h \
|
||||
lj_bcdump.h lj_lex.h lj_err.h lj_errmsg.h lj_vm.h
|
||||
lj_carith.o: lj_carith.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_meta.h lj_ctype.h lj_cconv.h \
|
||||
lj_cdata.h lj_carith.h
|
||||
lj_ccall.o: lj_ccall.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \
|
||||
lj_cdata.h lj_ccall.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \
|
||||
lj_traceerr.h
|
||||
lj_ccallback.o: lj_ccallback.c lj_obj.h lua.h luaconf.h lj_def.h \
|
||||
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_state.h lj_frame.h \
|
||||
lj_bc.h lj_ctype.h lj_cconv.h lj_ccall.h lj_ccallback.h lj_target.h \
|
||||
lj_target_*.h lj_mcode.h lj_jit.h lj_ir.h lj_trace.h lj_dispatch.h \
|
||||
lj_traceerr.h lj_vm.h
|
||||
lj_cconv.o: lj_cconv.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_err.h lj_errmsg.h lj_tab.h lj_ctype.h lj_gc.h lj_cdata.h lj_cconv.h \
|
||||
lj_ccallback.h
|
||||
lj_cdata.o: lj_cdata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cconv.h \
|
||||
lj_cdata.h
|
||||
lj_char.o: lj_char.c lj_char.h lj_def.h lua.h luaconf.h
|
||||
lj_clib.o: lj_clib.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_err.h lj_errmsg.h lj_tab.h lj_str.h lj_udata.h lj_ctype.h lj_cconv.h \
|
||||
lj_cdata.h lj_clib.h
|
||||
lj_cparse.o: lj_cparse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_ctype.h lj_cparse.h lj_frame.h \
|
||||
lj_bc.h lj_vm.h lj_char.h lj_strscan.h
|
||||
lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h \
|
||||
lj_gc.h lj_cdata.h lj_cparse.h lj_cconv.h lj_clib.h lj_ccall.h lj_ff.h \
|
||||
lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
|
||||
lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \
|
||||
lj_crecord.h
|
||||
lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_ccallback.h
|
||||
lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \
|
||||
lj_bc.h lj_jit.h lj_ir.h
|
||||
lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_err.h lj_errmsg.h lj_func.h lj_str.h lj_tab.h lj_meta.h lj_debug.h \
|
||||
lj_state.h lj_frame.h lj_bc.h lj_ff.h lj_ffdef.h lj_jit.h lj_ir.h \
|
||||
lj_ccallback.h lj_ctype.h lj_gc.h lj_trace.h lj_dispatch.h lj_traceerr.h \
|
||||
lj_vm.h luajit.h
|
||||
lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \
|
||||
lj_errmsg.h lj_debug.h lj_str.h lj_func.h lj_state.h lj_frame.h lj_bc.h \
|
||||
lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \
|
||||
lj_traceerr.h lj_vm.h
|
||||
lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \
|
||||
lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
|
||||
lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_crecord.h \
|
||||
lj_vm.h lj_strscan.h lj_recdef.h
|
||||
lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \
|
||||
lj_traceerr.h lj_vm.h
|
||||
lj_gc.o: lj_gc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h \
|
||||
lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h lj_trace.h lj_jit.h \
|
||||
lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h
|
||||
lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_frame.h lj_bc.h lj_jit.h \
|
||||
lj_ir.h lj_dispatch.h
|
||||
lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
|
||||
lj_dispatch.h lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h lj_carith.h \
|
||||
lj_vm.h lj_strscan.h lj_lib.h
|
||||
lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_cdata.h lualib.h \
|
||||
lj_state.h lj_lex.h lj_parse.h lj_char.h lj_strscan.h
|
||||
lj_lib.o: lj_lib.c lauxlib.h lua.h luaconf.h lj_obj.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_bc.h \
|
||||
lj_dispatch.h lj_jit.h lj_ir.h lj_vm.h lj_strscan.h lj_lib.h
|
||||
lj_load.o: lj_load.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \
|
||||
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_func.h lj_frame.h \
|
||||
lj_bc.h lj_vm.h lj_lex.h lj_bcdump.h lj_parse.h
|
||||
lj_mcode.o: lj_mcode.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_jit.h lj_ir.h lj_mcode.h lj_trace.h lj_dispatch.h lj_bc.h \
|
||||
lj_traceerr.h lj_vm.h
|
||||
lj_meta.o: lj_meta.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \
|
||||
lj_vm.h lj_strscan.h
|
||||
lj_obj.o: lj_obj.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h
|
||||
lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_ir.h lj_jit.h lj_iropt.h
|
||||
lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \
|
||||
lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \
|
||||
lj_strscan.h lj_folddef.h
|
||||
lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \
|
||||
lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h
|
||||
lj_opt_mem.o: lj_opt_mem.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_tab.h lj_ir.h lj_jit.h lj_iropt.h
|
||||
lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \
|
||||
lj_arch.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \
|
||||
lj_traceerr.h lj_vm.h lj_strscan.h
|
||||
lj_opt_sink.o: lj_opt_sink.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_ir.h lj_jit.h lj_iropt.h lj_target.h lj_target_*.h
|
||||
lj_opt_split.o: lj_opt_split.c lj_obj.h lua.h luaconf.h lj_def.h \
|
||||
lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_ircall.h \
|
||||
lj_iropt.h lj_vm.h
|
||||
lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h \
|
||||
lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h
|
||||
lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \
|
||||
lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \
|
||||
lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \
|
||||
lj_ffrecord.h lj_snap.h lj_vm.h
|
||||
lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_tab.h lj_state.h lj_frame.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h \
|
||||
lj_trace.h lj_dispatch.h lj_traceerr.h lj_snap.h lj_target.h \
|
||||
lj_target_*.h lj_ctype.h lj_cdata.h
|
||||
lj_state.o: lj_state.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h lj_meta.h \
|
||||
lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_trace.h lj_jit.h lj_ir.h \
|
||||
lj_dispatch.h lj_traceerr.h lj_vm.h lj_lex.h lj_alloc.h
|
||||
lj_str.o: lj_str.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_char.h
|
||||
lj_strscan.o: lj_strscan.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_char.h lj_strscan.h
|
||||
lj_tab.o: lj_tab.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
|
||||
lj_err.h lj_errmsg.h lj_tab.h
|
||||
lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_frame.h lj_bc.h \
|
||||
lj_state.h lj_ir.h lj_jit.h lj_iropt.h lj_mcode.h lj_trace.h \
|
||||
lj_dispatch.h lj_traceerr.h lj_snap.h lj_gdbjit.h lj_record.h lj_asm.h \
|
||||
lj_vm.h lj_vmevent.h lj_target.h lj_target_*.h
|
||||
lj_udata.o: lj_udata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_gc.h lj_udata.h
|
||||
lj_vmevent.o: lj_vmevent.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_str.h lj_tab.h lj_state.h lj_dispatch.h lj_bc.h lj_jit.h lj_ir.h \
|
||||
lj_vm.h lj_vmevent.h
|
||||
lj_vmmath.o: lj_vmmath.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
|
||||
lj_ir.h lj_vm.h
|
||||
ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \
|
||||
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \
|
||||
lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h \
|
||||
lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \
|
||||
lj_debug.h lj_ff.h lj_ffdef.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h \
|
||||
lj_obj.c lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h \
|
||||
lj_debug.c lj_state.c lj_lex.h lj_alloc.h lj_dispatch.c lj_ccallback.h \
|
||||
luajit.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c lj_api.c \
|
||||
lj_lex.c lualib.h lj_parse.h lj_parse.c lj_bcread.c lj_bcdump.h \
|
||||
lj_bcwrite.c lj_load.c lj_ctype.c lj_cdata.c lj_cconv.h lj_cconv.c \
|
||||
lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h lj_target_*.h \
|
||||
lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h lj_cparse.c \
|
||||
lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_ircall.h lj_iropt.h \
|
||||
lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \
|
||||
lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \
|
||||
lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \
|
||||
lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \
|
||||
lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \
|
||||
lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \
|
||||
lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \
|
||||
lib_init.c
|
||||
luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h
|
||||
host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \
|
||||
lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \
|
||||
lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \
|
||||
lj_gc.h lj_ccall.h lj_ctype.h luajit.h \
|
||||
host/buildvm_arch.h lj_traceerr.h
|
||||
host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \
|
||||
lj_arch.h lj_bc.h lj_def.h lj_arch.h
|
||||
host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \
|
||||
luaconf.h lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_ir.h lj_obj.h
|
||||
host/buildvm_lib.o: host/buildvm_lib.c host/buildvm.h lj_def.h lua.h luaconf.h \
|
||||
lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_lib.h lj_obj.h
|
||||
host/buildvm_peobj.o: host/buildvm_peobj.c host/buildvm.h lj_def.h lua.h \
|
||||
luaconf.h lj_arch.h lj_bc.h lj_def.h lj_arch.h
|
||||
host/minilua.o: host/minilua.c
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,20 +0,0 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT MIPSEL disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2013 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
-- This module just exports the little-endian functions from the
|
||||
-- MIPS disassembler module. All the interesting stuff is there.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local require = require
|
||||
|
||||
module(...)
|
||||
|
||||
local dis_mips = require(_PACKAGE.."dis_mips")
|
||||
|
||||
create = dis_mips.create_el
|
||||
disass = dis_mips.disass_el
|
||||
regname = dis_mips.regname
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
----------------------------------------------------------------------------
|
||||
-- LuaJIT x64 disassembler wrapper module.
|
||||
--
|
||||
-- Copyright (C) 2005-2013 Mike Pall. All rights reserved.
|
||||
-- Released under the MIT license. See Copyright Notice in luajit.h
|
||||
----------------------------------------------------------------------------
|
||||
-- This module just exports the 64 bit functions from the combined
|
||||
-- x86/x64 disassembler module. All the interesting stuff is there.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local require = require
|
||||
|
||||
module(...)
|
||||
|
||||
local dis_x86 = require(_PACKAGE.."dis_x86")
|
||||
|
||||
create = dis_x86.create64
|
||||
disass = dis_x86.disass64
|
||||
regname = dis_x86.regname64
|
||||
|
||||
@@ -1,331 +0,0 @@
|
||||
-- This is a generated file. DO NOT EDIT!
|
||||
|
||||
module(...)
|
||||
|
||||
bcnames = "ISLT ISGE ISLE ISGT ISEQV ISNEV ISEQS ISNES ISEQN ISNEN ISEQP ISNEP ISTC ISFC IST ISF MOV NOT UNM LEN ADDVN SUBVN MULVN DIVVN MODVN ADDNV SUBNV MULNV DIVNV MODNV ADDVV SUBVV MULVV DIVVV MODVV POW CAT KSTR KCDATAKSHORTKNUM KPRI KNIL UGET USETV USETS USETN USETP UCLO FNEW TNEW TDUP GGET GSET TGETV TGETS TGETB TSETV TSETS TSETB TSETM CALLM CALL CALLMTCALLT ITERC ITERN VARG ISNEXTRETM RET RET0 RET1 FORI JFORI FORL IFORL JFORL ITERL IITERLJITERLLOOP ILOOP JLOOP JMP FUNCF IFUNCFJFUNCFFUNCV IFUNCVJFUNCVFUNCC FUNCCW"
|
||||
|
||||
irnames = "LT GE LE GT ULT UGE ULE UGT EQ NE ABC RETF NOP BASE PVAL GCSTEPHIOP LOOP USE PHI RENAMEKPRI KINT KGC KPTR KKPTR KNULL KNUM KINT64KSLOT BNOT BSWAP BAND BOR BXOR BSHL BSHR BSAR BROL BROR ADD SUB MUL DIV MOD POW NEG ABS ATAN2 LDEXP MIN MAX FPMATHADDOV SUBOV MULOV AREF HREFK HREF NEWREFUREFO UREFC FREF STRREFALOAD HLOAD ULOAD FLOAD XLOAD SLOAD VLOAD ASTOREHSTOREUSTOREFSTOREXSTORESNEW XSNEW TNEW TDUP CNEW CNEWI TBAR OBAR XBAR CONV TOBIT TOSTR STRTO CALLN CALLL CALLS CALLXSCARG "
|
||||
|
||||
irfpm = { [0]="floor", "ceil", "trunc", "sqrt", "exp", "exp2", "log", "log2", "log10", "sin", "cos", "tan", "other", }
|
||||
|
||||
irfield = { [0]="str.len", "func.env", "func.pc", "tab.meta", "tab.array", "tab.node", "tab.asize", "tab.hmask", "tab.nomm", "udata.meta", "udata.udtype", "udata.file", "cdata.ctypeid", "cdata.ptr", "cdata.int", "cdata.int64", "cdata.int64_4", }
|
||||
|
||||
ircall = {
|
||||
[0]="lj_str_cmp",
|
||||
"lj_str_new",
|
||||
"lj_strscan_num",
|
||||
"lj_str_fromint",
|
||||
"lj_str_fromnum",
|
||||
"lj_tab_new1",
|
||||
"lj_tab_dup",
|
||||
"lj_tab_newkey",
|
||||
"lj_tab_len",
|
||||
"lj_gc_step_jit",
|
||||
"lj_gc_barrieruv",
|
||||
"lj_mem_newgco",
|
||||
"lj_math_random_step",
|
||||
"lj_vm_modi",
|
||||
"sinh",
|
||||
"cosh",
|
||||
"tanh",
|
||||
"fputc",
|
||||
"fwrite",
|
||||
"fflush",
|
||||
"lj_vm_floor",
|
||||
"lj_vm_ceil",
|
||||
"lj_vm_trunc",
|
||||
"sqrt",
|
||||
"exp",
|
||||
"lj_vm_exp2",
|
||||
"log",
|
||||
"lj_vm_log2",
|
||||
"log10",
|
||||
"sin",
|
||||
"cos",
|
||||
"tan",
|
||||
"lj_vm_powi",
|
||||
"pow",
|
||||
"atan2",
|
||||
"ldexp",
|
||||
"lj_vm_tobit",
|
||||
"softfp_add",
|
||||
"softfp_sub",
|
||||
"softfp_mul",
|
||||
"softfp_div",
|
||||
"softfp_cmp",
|
||||
"softfp_i2d",
|
||||
"softfp_d2i",
|
||||
"softfp_ui2d",
|
||||
"softfp_f2d",
|
||||
"softfp_d2ui",
|
||||
"softfp_d2f",
|
||||
"softfp_i2f",
|
||||
"softfp_ui2f",
|
||||
"softfp_f2i",
|
||||
"softfp_f2ui",
|
||||
"fp64_l2d",
|
||||
"fp64_ul2d",
|
||||
"fp64_l2f",
|
||||
"fp64_ul2f",
|
||||
"fp64_d2l",
|
||||
"fp64_d2ul",
|
||||
"fp64_f2l",
|
||||
"fp64_f2ul",
|
||||
"lj_carith_divi64",
|
||||
"lj_carith_divu64",
|
||||
"lj_carith_modi64",
|
||||
"lj_carith_modu64",
|
||||
"lj_carith_powi64",
|
||||
"lj_carith_powu64",
|
||||
"lj_cdata_setfin",
|
||||
"strlen",
|
||||
"memcpy",
|
||||
"memset",
|
||||
"lj_vm_errno",
|
||||
"lj_carith_mul64",
|
||||
}
|
||||
|
||||
traceerr = {
|
||||
[0]="error thrown or hook called during recording",
|
||||
"trace too long",
|
||||
"trace too deep",
|
||||
"too many snapshots",
|
||||
"blacklisted",
|
||||
"NYI: bytecode %d",
|
||||
"leaving loop in root trace",
|
||||
"inner loop in root trace",
|
||||
"loop unroll limit reached",
|
||||
"bad argument type",
|
||||
"call to JIT-disabled function",
|
||||
"call unroll limit reached",
|
||||
"down-recursion, restarting",
|
||||
"NYI: C function %p",
|
||||
"NYI: FastFunc %s",
|
||||
"NYI: unsupported variant of FastFunc %s",
|
||||
"NYI: return to lower frame",
|
||||
"store with nil or NaN key",
|
||||
"missing metamethod",
|
||||
"looping index lookup",
|
||||
"NYI: mixed sparse/dense table",
|
||||
"symbol not in cache",
|
||||
"NYI: unsupported C type conversion",
|
||||
"NYI: unsupported C function type",
|
||||
"guard would always fail",
|
||||
"too many PHIs",
|
||||
"persistent type instability",
|
||||
"failed to allocate mcode memory",
|
||||
"machine code too long",
|
||||
"hit mcode limit (retrying)",
|
||||
"too many spill slots",
|
||||
"inconsistent register allocation",
|
||||
"NYI: cannot assemble IR instruction %d",
|
||||
"NYI: PHI shuffling too complex",
|
||||
"NYI: register coalescing too complex",
|
||||
}
|
||||
|
||||
ffnames = {
|
||||
[0]="Lua",
|
||||
"C",
|
||||
"assert",
|
||||
"type",
|
||||
"next",
|
||||
"pairs",
|
||||
"ipairs_aux",
|
||||
"ipairs",
|
||||
"getmetatable",
|
||||
"setmetatable",
|
||||
"getfenv",
|
||||
"setfenv",
|
||||
"rawget",
|
||||
"rawset",
|
||||
"rawequal",
|
||||
"unpack",
|
||||
"select",
|
||||
"tonumber",
|
||||
"tostring",
|
||||
"error",
|
||||
"pcall",
|
||||
"xpcall",
|
||||
"loadfile",
|
||||
"load",
|
||||
"loadstring",
|
||||
"dofile",
|
||||
"gcinfo",
|
||||
"collectgarbage",
|
||||
"newproxy",
|
||||
"print",
|
||||
"coroutine.status",
|
||||
"coroutine.running",
|
||||
"coroutine.create",
|
||||
"coroutine.yield",
|
||||
"coroutine.resume",
|
||||
"coroutine.wrap_aux",
|
||||
"coroutine.wrap",
|
||||
"math.abs",
|
||||
"math.floor",
|
||||
"math.ceil",
|
||||
"math.sqrt",
|
||||
"math.log10",
|
||||
"math.exp",
|
||||
"math.sin",
|
||||
"math.cos",
|
||||
"math.tan",
|
||||
"math.asin",
|
||||
"math.acos",
|
||||
"math.atan",
|
||||
"math.sinh",
|
||||
"math.cosh",
|
||||
"math.tanh",
|
||||
"math.frexp",
|
||||
"math.modf",
|
||||
"math.log",
|
||||
"math.deg",
|
||||
"math.rad",
|
||||
"math.atan2",
|
||||
"math.pow",
|
||||
"math.fmod",
|
||||
"math.ldexp",
|
||||
"math.min",
|
||||
"math.max",
|
||||
"math.random",
|
||||
"math.randomseed",
|
||||
"bit.tobit",
|
||||
"bit.bnot",
|
||||
"bit.bswap",
|
||||
"bit.lshift",
|
||||
"bit.rshift",
|
||||
"bit.arshift",
|
||||
"bit.rol",
|
||||
"bit.ror",
|
||||
"bit.band",
|
||||
"bit.bor",
|
||||
"bit.bxor",
|
||||
"bit.tohex",
|
||||
"string.len",
|
||||
"string.byte",
|
||||
"string.char",
|
||||
"string.sub",
|
||||
"string.rep",
|
||||
"string.reverse",
|
||||
"string.lower",
|
||||
"string.upper",
|
||||
"string.dump",
|
||||
"string.find",
|
||||
"string.match",
|
||||
"string.gmatch_aux",
|
||||
"string.gmatch",
|
||||
"string.gsub",
|
||||
"string.format",
|
||||
"table.foreachi",
|
||||
"table.foreach",
|
||||
"table.getn",
|
||||
"table.maxn",
|
||||
"table.insert",
|
||||
"table.remove",
|
||||
"table.concat",
|
||||
"table.sort",
|
||||
"io.method.close",
|
||||
"io.method.read",
|
||||
"io.method.write",
|
||||
"io.method.flush",
|
||||
"io.method.seek",
|
||||
"io.method.setvbuf",
|
||||
"io.method.lines",
|
||||
"io.method.__gc",
|
||||
"io.method.__tostring",
|
||||
"io.open",
|
||||
"io.popen",
|
||||
"io.tmpfile",
|
||||
"io.close",
|
||||
"io.read",
|
||||
"io.write",
|
||||
"io.flush",
|
||||
"io.input",
|
||||
"io.output",
|
||||
"io.lines",
|
||||
"io.type",
|
||||
"os.execute",
|
||||
"os.remove",
|
||||
"os.rename",
|
||||
"os.tmpname",
|
||||
"os.getenv",
|
||||
"os.exit",
|
||||
"os.clock",
|
||||
"os.date",
|
||||
"os.time",
|
||||
"os.difftime",
|
||||
"os.setlocale",
|
||||
"debug.getregistry",
|
||||
"debug.getmetatable",
|
||||
"debug.setmetatable",
|
||||
"debug.getfenv",
|
||||
"debug.setfenv",
|
||||
"debug.getinfo",
|
||||
"debug.getlocal",
|
||||
"debug.setlocal",
|
||||
"debug.getupvalue",
|
||||
"debug.setupvalue",
|
||||
"debug.upvalueid",
|
||||
"debug.upvaluejoin",
|
||||
"debug.sethook",
|
||||
"debug.gethook",
|
||||
"debug.debug",
|
||||
"debug.traceback",
|
||||
"jit.on",
|
||||
"jit.off",
|
||||
"jit.flush",
|
||||
"jit.status",
|
||||
"jit.attach",
|
||||
"jit.util.funcinfo",
|
||||
"jit.util.funcbc",
|
||||
"jit.util.funck",
|
||||
"jit.util.funcuvname",
|
||||
"jit.util.traceinfo",
|
||||
"jit.util.traceir",
|
||||
"jit.util.tracek",
|
||||
"jit.util.tracesnap",
|
||||
"jit.util.tracemc",
|
||||
"jit.util.traceexitstub",
|
||||
"jit.util.ircalladdr",
|
||||
"jit.opt.start",
|
||||
"ffi.meta.__index",
|
||||
"ffi.meta.__newindex",
|
||||
"ffi.meta.__eq",
|
||||
"ffi.meta.__len",
|
||||
"ffi.meta.__lt",
|
||||
"ffi.meta.__le",
|
||||
"ffi.meta.__concat",
|
||||
"ffi.meta.__call",
|
||||
"ffi.meta.__add",
|
||||
"ffi.meta.__sub",
|
||||
"ffi.meta.__mul",
|
||||
"ffi.meta.__div",
|
||||
"ffi.meta.__mod",
|
||||
"ffi.meta.__pow",
|
||||
"ffi.meta.__unm",
|
||||
"ffi.meta.__tostring",
|
||||
"ffi.meta.__pairs",
|
||||
"ffi.meta.__ipairs",
|
||||
"ffi.clib.__index",
|
||||
"ffi.clib.__newindex",
|
||||
"ffi.clib.__gc",
|
||||
"ffi.callback.free",
|
||||
"ffi.callback.set",
|
||||
"ffi.cdef",
|
||||
"ffi.new",
|
||||
"ffi.cast",
|
||||
"ffi.typeof",
|
||||
"ffi.istype",
|
||||
"ffi.sizeof",
|
||||
"ffi.alignof",
|
||||
"ffi.offsetof",
|
||||
"ffi.errno",
|
||||
"ffi.string",
|
||||
"ffi.copy",
|
||||
"ffi.fill",
|
||||
"ffi.abi",
|
||||
"ffi.metatype",
|
||||
"ffi.gc",
|
||||
"ffi.load",
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
** Bit manipulation library.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lib_bit_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_err.h"
|
||||
#include "lj_str.h"
|
||||
#include "lj_lib.h"
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#define LJLIB_MODULE_bit
|
||||
|
||||
LJLIB_ASM(bit_tobit) LJLIB_REC(bit_unary IR_TOBIT)
|
||||
{
|
||||
lj_lib_checknumber(L, 1);
|
||||
return FFH_RETRY;
|
||||
}
|
||||
LJLIB_ASM_(bit_bnot) LJLIB_REC(bit_unary IR_BNOT)
|
||||
LJLIB_ASM_(bit_bswap) LJLIB_REC(bit_unary IR_BSWAP)
|
||||
|
||||
LJLIB_ASM(bit_lshift) LJLIB_REC(bit_shift IR_BSHL)
|
||||
{
|
||||
lj_lib_checknumber(L, 1);
|
||||
lj_lib_checkbit(L, 2);
|
||||
return FFH_RETRY;
|
||||
}
|
||||
LJLIB_ASM_(bit_rshift) LJLIB_REC(bit_shift IR_BSHR)
|
||||
LJLIB_ASM_(bit_arshift) LJLIB_REC(bit_shift IR_BSAR)
|
||||
LJLIB_ASM_(bit_rol) LJLIB_REC(bit_shift IR_BROL)
|
||||
LJLIB_ASM_(bit_ror) LJLIB_REC(bit_shift IR_BROR)
|
||||
|
||||
LJLIB_ASM(bit_band) LJLIB_REC(bit_nary IR_BAND)
|
||||
{
|
||||
int i = 0;
|
||||
do { lj_lib_checknumber(L, ++i); } while (L->base+i < L->top);
|
||||
return FFH_RETRY;
|
||||
}
|
||||
LJLIB_ASM_(bit_bor) LJLIB_REC(bit_nary IR_BOR)
|
||||
LJLIB_ASM_(bit_bxor) LJLIB_REC(bit_nary IR_BXOR)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
LJLIB_CF(bit_tohex)
|
||||
{
|
||||
uint32_t b = (uint32_t)lj_lib_checkbit(L, 1);
|
||||
int32_t i, n = L->base+1 >= L->top ? 8 : lj_lib_checkbit(L, 2);
|
||||
const char *hexdigits = "0123456789abcdef";
|
||||
char buf[8];
|
||||
if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; }
|
||||
if (n > 8) n = 8;
|
||||
for (i = n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; }
|
||||
lua_pushlstring(L, buf, (size_t)n);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#include "lj_libdef.h"
|
||||
|
||||
LUALIB_API int luaopen_bit(lua_State *L)
|
||||
{
|
||||
LJ_LIB_REG(L, LUA_BITLIBNAME, bit);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,940 +0,0 @@
|
||||
/*
|
||||
** String library.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define lib_string_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_gc.h"
|
||||
#include "lj_err.h"
|
||||
#include "lj_str.h"
|
||||
#include "lj_tab.h"
|
||||
#include "lj_meta.h"
|
||||
#include "lj_state.h"
|
||||
#include "lj_ff.h"
|
||||
#include "lj_bcdump.h"
|
||||
#include "lj_char.h"
|
||||
#include "lj_lib.h"
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#define LJLIB_MODULE_string
|
||||
|
||||
LJLIB_ASM(string_len) LJLIB_REC(.)
|
||||
{
|
||||
lj_lib_checkstr(L, 1);
|
||||
return FFH_RETRY;
|
||||
}
|
||||
|
||||
LJLIB_ASM(string_byte) LJLIB_REC(string_range 0)
|
||||
{
|
||||
GCstr *s = lj_lib_checkstr(L, 1);
|
||||
int32_t len = (int32_t)s->len;
|
||||
int32_t start = lj_lib_optint(L, 2, 1);
|
||||
int32_t stop = lj_lib_optint(L, 3, start);
|
||||
int32_t n, i;
|
||||
const unsigned char *p;
|
||||
if (stop < 0) stop += len+1;
|
||||
if (start < 0) start += len+1;
|
||||
if (start <= 0) start = 1;
|
||||
if (stop > len) stop = len;
|
||||
if (start > stop) return FFH_RES(0); /* Empty interval: return no results. */
|
||||
start--;
|
||||
n = stop - start;
|
||||
if ((uint32_t)n > LUAI_MAXCSTACK)
|
||||
lj_err_caller(L, LJ_ERR_STRSLC);
|
||||
lj_state_checkstack(L, (MSize)n);
|
||||
p = (const unsigned char *)strdata(s) + start;
|
||||
for (i = 0; i < n; i++)
|
||||
setintV(L->base + i-1, p[i]);
|
||||
return FFH_RES(n);
|
||||
}
|
||||
|
||||
LJLIB_ASM(string_char)
|
||||
{
|
||||
int i, nargs = (int)(L->top - L->base);
|
||||
char *buf = lj_str_needbuf(L, &G(L)->tmpbuf, (size_t)nargs);
|
||||
for (i = 1; i <= nargs; i++) {
|
||||
int32_t k = lj_lib_checkint(L, i);
|
||||
if (!checku8(k))
|
||||
lj_err_arg(L, i, LJ_ERR_BADVAL);
|
||||
buf[i-1] = (char)k;
|
||||
}
|
||||
setstrV(L, L->base-1, lj_str_new(L, buf, (size_t)nargs));
|
||||
return FFH_RES(1);
|
||||
}
|
||||
|
||||
LJLIB_ASM(string_sub) LJLIB_REC(string_range 1)
|
||||
{
|
||||
lj_lib_checkstr(L, 1);
|
||||
lj_lib_checkint(L, 2);
|
||||
setintV(L->base+2, lj_lib_optint(L, 3, -1));
|
||||
return FFH_RETRY;
|
||||
}
|
||||
|
||||
LJLIB_ASM(string_rep)
|
||||
{
|
||||
GCstr *s = lj_lib_checkstr(L, 1);
|
||||
int32_t k = lj_lib_checkint(L, 2);
|
||||
GCstr *sep = lj_lib_optstr(L, 3);
|
||||
int32_t len = (int32_t)s->len;
|
||||
global_State *g = G(L);
|
||||
int64_t tlen;
|
||||
const char *src;
|
||||
char *buf;
|
||||
if (k <= 0) {
|
||||
empty:
|
||||
setstrV(L, L->base-1, &g->strempty);
|
||||
return FFH_RES(1);
|
||||
}
|
||||
if (sep) {
|
||||
tlen = (int64_t)len + sep->len;
|
||||
if (tlen > LJ_MAX_STR)
|
||||
lj_err_caller(L, LJ_ERR_STROV);
|
||||
tlen *= k;
|
||||
if (tlen > LJ_MAX_STR)
|
||||
lj_err_caller(L, LJ_ERR_STROV);
|
||||
} else {
|
||||
tlen = (int64_t)k * len;
|
||||
if (tlen > LJ_MAX_STR)
|
||||
lj_err_caller(L, LJ_ERR_STROV);
|
||||
}
|
||||
if (tlen == 0) goto empty;
|
||||
buf = lj_str_needbuf(L, &g->tmpbuf, (MSize)tlen);
|
||||
src = strdata(s);
|
||||
if (sep) {
|
||||
tlen -= sep->len; /* Ignore trailing separator. */
|
||||
if (k > 1) { /* Paste one string and one separator. */
|
||||
int32_t i;
|
||||
i = 0; while (i < len) *buf++ = src[i++];
|
||||
src = strdata(sep); len = sep->len;
|
||||
i = 0; while (i < len) *buf++ = src[i++];
|
||||
src = g->tmpbuf.buf; len += s->len; k--; /* Now copy that k-1 times. */
|
||||
}
|
||||
}
|
||||
do {
|
||||
int32_t i = 0;
|
||||
do { *buf++ = src[i++]; } while (i < len);
|
||||
} while (--k > 0);
|
||||
setstrV(L, L->base-1, lj_str_new(L, g->tmpbuf.buf, (size_t)tlen));
|
||||
return FFH_RES(1);
|
||||
}
|
||||
|
||||
LJLIB_ASM(string_reverse)
|
||||
{
|
||||
GCstr *s = lj_lib_checkstr(L, 1);
|
||||
lj_str_needbuf(L, &G(L)->tmpbuf, s->len);
|
||||
return FFH_RETRY;
|
||||
}
|
||||
LJLIB_ASM_(string_lower)
|
||||
LJLIB_ASM_(string_upper)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static int writer_buf(lua_State *L, const void *p, size_t size, void *b)
|
||||
{
|
||||
luaL_addlstring((luaL_Buffer *)b, (const char *)p, size);
|
||||
UNUSED(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LJLIB_CF(string_dump)
|
||||
{
|
||||
GCfunc *fn = lj_lib_checkfunc(L, 1);
|
||||
int strip = L->base+1 < L->top && tvistruecond(L->base+1);
|
||||
luaL_Buffer b;
|
||||
L->top = L->base+1;
|
||||
luaL_buffinit(L, &b);
|
||||
if (!isluafunc(fn) || lj_bcwrite(L, funcproto(fn), writer_buf, &b, strip))
|
||||
lj_err_caller(L, LJ_ERR_STRDUMP);
|
||||
luaL_pushresult(&b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/* macro to `unsign' a character */
|
||||
#define uchar(c) ((unsigned char)(c))
|
||||
|
||||
#define CAP_UNFINISHED (-1)
|
||||
#define CAP_POSITION (-2)
|
||||
|
||||
typedef struct MatchState {
|
||||
const char *src_init; /* init of source string */
|
||||
const char *src_end; /* end (`\0') of source string */
|
||||
lua_State *L;
|
||||
int level; /* total number of captures (finished or unfinished) */
|
||||
int depth;
|
||||
struct {
|
||||
const char *init;
|
||||
ptrdiff_t len;
|
||||
} capture[LUA_MAXCAPTURES];
|
||||
} MatchState;
|
||||
|
||||
#define L_ESC '%'
|
||||
#define SPECIALS "^$*+?.([%-"
|
||||
|
||||
static int check_capture(MatchState *ms, int l)
|
||||
{
|
||||
l -= '1';
|
||||
if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
|
||||
lj_err_caller(ms->L, LJ_ERR_STRCAPI);
|
||||
return l;
|
||||
}
|
||||
|
||||
static int capture_to_close(MatchState *ms)
|
||||
{
|
||||
int level = ms->level;
|
||||
for (level--; level>=0; level--)
|
||||
if (ms->capture[level].len == CAP_UNFINISHED) return level;
|
||||
lj_err_caller(ms->L, LJ_ERR_STRPATC);
|
||||
return 0; /* unreachable */
|
||||
}
|
||||
|
||||
static const char *classend(MatchState *ms, const char *p)
|
||||
{
|
||||
switch (*p++) {
|
||||
case L_ESC:
|
||||
if (*p == '\0')
|
||||
lj_err_caller(ms->L, LJ_ERR_STRPATE);
|
||||
return p+1;
|
||||
case '[':
|
||||
if (*p == '^') p++;
|
||||
do { /* look for a `]' */
|
||||
if (*p == '\0')
|
||||
lj_err_caller(ms->L, LJ_ERR_STRPATM);
|
||||
if (*(p++) == L_ESC && *p != '\0')
|
||||
p++; /* skip escapes (e.g. `%]') */
|
||||
} while (*p != ']');
|
||||
return p+1;
|
||||
default:
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
static const unsigned char match_class_map[32] = {
|
||||
0,LJ_CHAR_ALPHA,0,LJ_CHAR_CNTRL,LJ_CHAR_DIGIT,0,0,LJ_CHAR_GRAPH,0,0,0,0,
|
||||
LJ_CHAR_LOWER,0,0,0,LJ_CHAR_PUNCT,0,0,LJ_CHAR_SPACE,0,
|
||||
LJ_CHAR_UPPER,0,LJ_CHAR_ALNUM,LJ_CHAR_XDIGIT,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
static int match_class(int c, int cl)
|
||||
{
|
||||
if ((cl & 0xc0) == 0x40) {
|
||||
int t = match_class_map[(cl&0x1f)];
|
||||
if (t) {
|
||||
t = lj_char_isa(c, t);
|
||||
return (cl & 0x20) ? t : !t;
|
||||
}
|
||||
if (cl == 'z') return c == 0;
|
||||
if (cl == 'Z') return c != 0;
|
||||
}
|
||||
return (cl == c);
|
||||
}
|
||||
|
||||
static int matchbracketclass(int c, const char *p, const char *ec)
|
||||
{
|
||||
int sig = 1;
|
||||
if (*(p+1) == '^') {
|
||||
sig = 0;
|
||||
p++; /* skip the `^' */
|
||||
}
|
||||
while (++p < ec) {
|
||||
if (*p == L_ESC) {
|
||||
p++;
|
||||
if (match_class(c, uchar(*p)))
|
||||
return sig;
|
||||
}
|
||||
else if ((*(p+1) == '-') && (p+2 < ec)) {
|
||||
p+=2;
|
||||
if (uchar(*(p-2)) <= c && c <= uchar(*p))
|
||||
return sig;
|
||||
}
|
||||
else if (uchar(*p) == c) return sig;
|
||||
}
|
||||
return !sig;
|
||||
}
|
||||
|
||||
static int singlematch(int c, const char *p, const char *ep)
|
||||
{
|
||||
switch (*p) {
|
||||
case '.': return 1; /* matches any char */
|
||||
case L_ESC: return match_class(c, uchar(*(p+1)));
|
||||
case '[': return matchbracketclass(c, p, ep-1);
|
||||
default: return (uchar(*p) == c);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *match(MatchState *ms, const char *s, const char *p);
|
||||
|
||||
static const char *matchbalance(MatchState *ms, const char *s, const char *p)
|
||||
{
|
||||
if (*p == 0 || *(p+1) == 0)
|
||||
lj_err_caller(ms->L, LJ_ERR_STRPATU);
|
||||
if (*s != *p) {
|
||||
return NULL;
|
||||
} else {
|
||||
int b = *p;
|
||||
int e = *(p+1);
|
||||
int cont = 1;
|
||||
while (++s < ms->src_end) {
|
||||
if (*s == e) {
|
||||
if (--cont == 0) return s+1;
|
||||
} else if (*s == b) {
|
||||
cont++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL; /* string ends out of balance */
|
||||
}
|
||||
|
||||
static const char *max_expand(MatchState *ms, const char *s,
|
||||
const char *p, const char *ep)
|
||||
{
|
||||
ptrdiff_t i = 0; /* counts maximum expand for item */
|
||||
while ((s+i)<ms->src_end && singlematch(uchar(*(s+i)), p, ep))
|
||||
i++;
|
||||
/* keeps trying to match with the maximum repetitions */
|
||||
while (i>=0) {
|
||||
const char *res = match(ms, (s+i), ep+1);
|
||||
if (res) return res;
|
||||
i--; /* else didn't match; reduce 1 repetition to try again */
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *min_expand(MatchState *ms, const char *s,
|
||||
const char *p, const char *ep)
|
||||
{
|
||||
for (;;) {
|
||||
const char *res = match(ms, s, ep+1);
|
||||
if (res != NULL)
|
||||
return res;
|
||||
else if (s<ms->src_end && singlematch(uchar(*s), p, ep))
|
||||
s++; /* try with one more repetition */
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *start_capture(MatchState *ms, const char *s,
|
||||
const char *p, int what)
|
||||
{
|
||||
const char *res;
|
||||
int level = ms->level;
|
||||
if (level >= LUA_MAXCAPTURES) lj_err_caller(ms->L, LJ_ERR_STRCAPN);
|
||||
ms->capture[level].init = s;
|
||||
ms->capture[level].len = what;
|
||||
ms->level = level+1;
|
||||
if ((res=match(ms, s, p)) == NULL) /* match failed? */
|
||||
ms->level--; /* undo capture */
|
||||
return res;
|
||||
}
|
||||
|
||||
static const char *end_capture(MatchState *ms, const char *s,
|
||||
const char *p)
|
||||
{
|
||||
int l = capture_to_close(ms);
|
||||
const char *res;
|
||||
ms->capture[l].len = s - ms->capture[l].init; /* close capture */
|
||||
if ((res = match(ms, s, p)) == NULL) /* match failed? */
|
||||
ms->capture[l].len = CAP_UNFINISHED; /* undo capture */
|
||||
return res;
|
||||
}
|
||||
|
||||
static const char *match_capture(MatchState *ms, const char *s, int l)
|
||||
{
|
||||
size_t len;
|
||||
l = check_capture(ms, l);
|
||||
len = (size_t)ms->capture[l].len;
|
||||
if ((size_t)(ms->src_end-s) >= len &&
|
||||
memcmp(ms->capture[l].init, s, len) == 0)
|
||||
return s+len;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *match(MatchState *ms, const char *s, const char *p)
|
||||
{
|
||||
if (++ms->depth > LJ_MAX_XLEVEL)
|
||||
lj_err_caller(ms->L, LJ_ERR_STRPATX);
|
||||
init: /* using goto's to optimize tail recursion */
|
||||
switch (*p) {
|
||||
case '(': /* start capture */
|
||||
if (*(p+1) == ')') /* position capture? */
|
||||
s = start_capture(ms, s, p+2, CAP_POSITION);
|
||||
else
|
||||
s = start_capture(ms, s, p+1, CAP_UNFINISHED);
|
||||
break;
|
||||
case ')': /* end capture */
|
||||
s = end_capture(ms, s, p+1);
|
||||
break;
|
||||
case L_ESC:
|
||||
switch (*(p+1)) {
|
||||
case 'b': /* balanced string? */
|
||||
s = matchbalance(ms, s, p+2);
|
||||
if (s == NULL) break;
|
||||
p+=4;
|
||||
goto init; /* else s = match(ms, s, p+4); */
|
||||
case 'f': { /* frontier? */
|
||||
const char *ep; char previous;
|
||||
p += 2;
|
||||
if (*p != '[')
|
||||
lj_err_caller(ms->L, LJ_ERR_STRPATB);
|
||||
ep = classend(ms, p); /* points to what is next */
|
||||
previous = (s == ms->src_init) ? '\0' : *(s-1);
|
||||
if (matchbracketclass(uchar(previous), p, ep-1) ||
|
||||
!matchbracketclass(uchar(*s), p, ep-1)) { s = NULL; break; }
|
||||
p=ep;
|
||||
goto init; /* else s = match(ms, s, ep); */
|
||||
}
|
||||
default:
|
||||
if (lj_char_isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */
|
||||
s = match_capture(ms, s, uchar(*(p+1)));
|
||||
if (s == NULL) break;
|
||||
p+=2;
|
||||
goto init; /* else s = match(ms, s, p+2) */
|
||||
}
|
||||
goto dflt; /* case default */
|
||||
}
|
||||
break;
|
||||
case '\0': /* end of pattern */
|
||||
break; /* match succeeded */
|
||||
case '$':
|
||||
/* is the `$' the last char in pattern? */
|
||||
if (*(p+1) != '\0') goto dflt;
|
||||
if (s != ms->src_end) s = NULL; /* check end of string */
|
||||
break;
|
||||
default: dflt: { /* it is a pattern item */
|
||||
const char *ep = classend(ms, p); /* points to what is next */
|
||||
int m = s<ms->src_end && singlematch(uchar(*s), p, ep);
|
||||
switch (*ep) {
|
||||
case '?': { /* optional */
|
||||
const char *res;
|
||||
if (m && ((res=match(ms, s+1, ep+1)) != NULL)) {
|
||||
s = res;
|
||||
break;
|
||||
}
|
||||
p=ep+1;
|
||||
goto init; /* else s = match(ms, s, ep+1); */
|
||||
}
|
||||
case '*': /* 0 or more repetitions */
|
||||
s = max_expand(ms, s, p, ep);
|
||||
break;
|
||||
case '+': /* 1 or more repetitions */
|
||||
s = (m ? max_expand(ms, s+1, p, ep) : NULL);
|
||||
break;
|
||||
case '-': /* 0 or more repetitions (minimum) */
|
||||
s = min_expand(ms, s, p, ep);
|
||||
break;
|
||||
default:
|
||||
if (m) { s++; p=ep; goto init; } /* else s = match(ms, s+1, ep); */
|
||||
s = NULL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
ms->depth--;
|
||||
return s;
|
||||
}
|
||||
|
||||
static const char *lmemfind(const char *s1, size_t l1,
|
||||
const char *s2, size_t l2)
|
||||
{
|
||||
if (l2 == 0) {
|
||||
return s1; /* empty strings are everywhere */
|
||||
} else if (l2 > l1) {
|
||||
return NULL; /* avoids a negative `l1' */
|
||||
} else {
|
||||
const char *init; /* to search for a `*s2' inside `s1' */
|
||||
l2--; /* 1st char will be checked by `memchr' */
|
||||
l1 = l1-l2; /* `s2' cannot be found after that */
|
||||
while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) {
|
||||
init++; /* 1st char is already checked */
|
||||
if (memcmp(init, s2+1, l2) == 0) {
|
||||
return init-1;
|
||||
} else { /* correct `l1' and `s1' to try again */
|
||||
l1 -= (size_t)(init-s1);
|
||||
s1 = init;
|
||||
}
|
||||
}
|
||||
return NULL; /* not found */
|
||||
}
|
||||
}
|
||||
|
||||
static void push_onecapture(MatchState *ms, int i, const char *s, const char *e)
|
||||
{
|
||||
if (i >= ms->level) {
|
||||
if (i == 0) /* ms->level == 0, too */
|
||||
lua_pushlstring(ms->L, s, (size_t)(e - s)); /* add whole match */
|
||||
else
|
||||
lj_err_caller(ms->L, LJ_ERR_STRCAPI);
|
||||
} else {
|
||||
ptrdiff_t l = ms->capture[i].len;
|
||||
if (l == CAP_UNFINISHED) lj_err_caller(ms->L, LJ_ERR_STRCAPU);
|
||||
if (l == CAP_POSITION)
|
||||
lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
|
||||
else
|
||||
lua_pushlstring(ms->L, ms->capture[i].init, (size_t)l);
|
||||
}
|
||||
}
|
||||
|
||||
static int push_captures(MatchState *ms, const char *s, const char *e)
|
||||
{
|
||||
int i;
|
||||
int nlevels = (ms->level == 0 && s) ? 1 : ms->level;
|
||||
luaL_checkstack(ms->L, nlevels, "too many captures");
|
||||
for (i = 0; i < nlevels; i++)
|
||||
push_onecapture(ms, i, s, e);
|
||||
return nlevels; /* number of strings pushed */
|
||||
}
|
||||
|
||||
static ptrdiff_t posrelat(ptrdiff_t pos, size_t len)
|
||||
{
|
||||
/* relative string position: negative means back from end */
|
||||
if (pos < 0) pos += (ptrdiff_t)len + 1;
|
||||
return (pos >= 0) ? pos : 0;
|
||||
}
|
||||
|
||||
static int str_find_aux(lua_State *L, int find)
|
||||
{
|
||||
size_t l1, l2;
|
||||
const char *s = luaL_checklstring(L, 1, &l1);
|
||||
const char *p = luaL_checklstring(L, 2, &l2);
|
||||
ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
|
||||
if (init < 0) {
|
||||
init = 0;
|
||||
} else if ((size_t)(init) > l1) {
|
||||
#if LJ_52
|
||||
setnilV(L->top-1);
|
||||
return 1;
|
||||
#else
|
||||
init = (ptrdiff_t)l1;
|
||||
#endif
|
||||
}
|
||||
if (find && (lua_toboolean(L, 4) || /* explicit request? */
|
||||
strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */
|
||||
/* do a plain search */
|
||||
const char *s2 = lmemfind(s+init, l1-(size_t)init, p, l2);
|
||||
if (s2) {
|
||||
lua_pushinteger(L, s2-s+1);
|
||||
lua_pushinteger(L, s2-s+(ptrdiff_t)l2);
|
||||
return 2;
|
||||
}
|
||||
} else {
|
||||
MatchState ms;
|
||||
int anchor = (*p == '^') ? (p++, 1) : 0;
|
||||
const char *s1=s+init;
|
||||
ms.L = L;
|
||||
ms.src_init = s;
|
||||
ms.src_end = s+l1;
|
||||
do {
|
||||
const char *res;
|
||||
ms.level = ms.depth = 0;
|
||||
if ((res=match(&ms, s1, p)) != NULL) {
|
||||
if (find) {
|
||||
lua_pushinteger(L, s1-s+1); /* start */
|
||||
lua_pushinteger(L, res-s); /* end */
|
||||
return push_captures(&ms, NULL, 0) + 2;
|
||||
} else {
|
||||
return push_captures(&ms, s1, res);
|
||||
}
|
||||
}
|
||||
} while (s1++ < ms.src_end && !anchor);
|
||||
}
|
||||
lua_pushnil(L); /* not found */
|
||||
return 1;
|
||||
}
|
||||
|
||||
LJLIB_CF(string_find)
|
||||
{
|
||||
return str_find_aux(L, 1);
|
||||
}
|
||||
|
||||
LJLIB_CF(string_match)
|
||||
{
|
||||
return str_find_aux(L, 0);
|
||||
}
|
||||
|
||||
LJLIB_NOREG LJLIB_CF(string_gmatch_aux)
|
||||
{
|
||||
const char *p = strVdata(lj_lib_upvalue(L, 2));
|
||||
GCstr *str = strV(lj_lib_upvalue(L, 1));
|
||||
const char *s = strdata(str);
|
||||
TValue *tvpos = lj_lib_upvalue(L, 3);
|
||||
const char *src = s + tvpos->u32.lo;
|
||||
MatchState ms;
|
||||
ms.L = L;
|
||||
ms.src_init = s;
|
||||
ms.src_end = s + str->len;
|
||||
for (; src <= ms.src_end; src++) {
|
||||
const char *e;
|
||||
ms.level = ms.depth = 0;
|
||||
if ((e = match(&ms, src, p)) != NULL) {
|
||||
int32_t pos = (int32_t)(e - s);
|
||||
if (e == src) pos++; /* Ensure progress for empty match. */
|
||||
tvpos->u32.lo = (uint32_t)pos;
|
||||
return push_captures(&ms, src, e);
|
||||
}
|
||||
}
|
||||
return 0; /* not found */
|
||||
}
|
||||
|
||||
LJLIB_CF(string_gmatch)
|
||||
{
|
||||
lj_lib_checkstr(L, 1);
|
||||
lj_lib_checkstr(L, 2);
|
||||
L->top = L->base+3;
|
||||
(L->top-1)->u64 = 0;
|
||||
lj_lib_pushcc(L, lj_cf_string_gmatch_aux, FF_string_gmatch_aux, 3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void add_s(MatchState *ms, luaL_Buffer *b, const char *s, const char *e)
|
||||
{
|
||||
size_t l, i;
|
||||
const char *news = lua_tolstring(ms->L, 3, &l);
|
||||
for (i = 0; i < l; i++) {
|
||||
if (news[i] != L_ESC) {
|
||||
luaL_addchar(b, news[i]);
|
||||
} else {
|
||||
i++; /* skip ESC */
|
||||
if (!lj_char_isdigit(uchar(news[i]))) {
|
||||
luaL_addchar(b, news[i]);
|
||||
} else if (news[i] == '0') {
|
||||
luaL_addlstring(b, s, (size_t)(e - s));
|
||||
} else {
|
||||
push_onecapture(ms, news[i] - '1', s, e);
|
||||
luaL_addvalue(b); /* add capture to accumulated result */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void add_value(MatchState *ms, luaL_Buffer *b,
|
||||
const char *s, const char *e)
|
||||
{
|
||||
lua_State *L = ms->L;
|
||||
switch (lua_type(L, 3)) {
|
||||
case LUA_TNUMBER:
|
||||
case LUA_TSTRING: {
|
||||
add_s(ms, b, s, e);
|
||||
return;
|
||||
}
|
||||
case LUA_TFUNCTION: {
|
||||
int n;
|
||||
lua_pushvalue(L, 3);
|
||||
n = push_captures(ms, s, e);
|
||||
lua_call(L, n, 1);
|
||||
break;
|
||||
}
|
||||
case LUA_TTABLE: {
|
||||
push_onecapture(ms, 0, s, e);
|
||||
lua_gettable(L, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!lua_toboolean(L, -1)) { /* nil or false? */
|
||||
lua_pop(L, 1);
|
||||
lua_pushlstring(L, s, (size_t)(e - s)); /* keep original text */
|
||||
} else if (!lua_isstring(L, -1)) {
|
||||
lj_err_callerv(L, LJ_ERR_STRGSRV, luaL_typename(L, -1));
|
||||
}
|
||||
luaL_addvalue(b); /* add result to accumulator */
|
||||
}
|
||||
|
||||
LJLIB_CF(string_gsub)
|
||||
{
|
||||
size_t srcl;
|
||||
const char *src = luaL_checklstring(L, 1, &srcl);
|
||||
const char *p = luaL_checkstring(L, 2);
|
||||
int tr = lua_type(L, 3);
|
||||
int max_s = luaL_optint(L, 4, (int)(srcl+1));
|
||||
int anchor = (*p == '^') ? (p++, 1) : 0;
|
||||
int n = 0;
|
||||
MatchState ms;
|
||||
luaL_Buffer b;
|
||||
if (!(tr == LUA_TNUMBER || tr == LUA_TSTRING ||
|
||||
tr == LUA_TFUNCTION || tr == LUA_TTABLE))
|
||||
lj_err_arg(L, 3, LJ_ERR_NOSFT);
|
||||
luaL_buffinit(L, &b);
|
||||
ms.L = L;
|
||||
ms.src_init = src;
|
||||
ms.src_end = src+srcl;
|
||||
while (n < max_s) {
|
||||
const char *e;
|
||||
ms.level = ms.depth = 0;
|
||||
e = match(&ms, src, p);
|
||||
if (e) {
|
||||
n++;
|
||||
add_value(&ms, &b, src, e);
|
||||
}
|
||||
if (e && e>src) /* non empty match? */
|
||||
src = e; /* skip it */
|
||||
else if (src < ms.src_end)
|
||||
luaL_addchar(&b, *src++);
|
||||
else
|
||||
break;
|
||||
if (anchor)
|
||||
break;
|
||||
}
|
||||
luaL_addlstring(&b, src, (size_t)(ms.src_end-src));
|
||||
luaL_pushresult(&b);
|
||||
lua_pushinteger(L, n); /* number of substitutions */
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */
|
||||
#define MAX_FMTITEM 512
|
||||
/* valid flags in a format specification */
|
||||
#define FMT_FLAGS "-+ #0"
|
||||
/*
|
||||
** maximum size of each format specification (such as '%-099.99d')
|
||||
** (+10 accounts for %99.99x plus margin of error)
|
||||
*/
|
||||
#define MAX_FMTSPEC (sizeof(FMT_FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
|
||||
|
||||
static void addquoted(lua_State *L, luaL_Buffer *b, int arg)
|
||||
{
|
||||
GCstr *str = lj_lib_checkstr(L, arg);
|
||||
int32_t len = (int32_t)str->len;
|
||||
const char *s = strdata(str);
|
||||
luaL_addchar(b, '"');
|
||||
while (len--) {
|
||||
uint32_t c = uchar(*s);
|
||||
if (c == '"' || c == '\\' || c == '\n') {
|
||||
luaL_addchar(b, '\\');
|
||||
} else if (lj_char_iscntrl(c)) { /* This can only be 0-31 or 127. */
|
||||
uint32_t d;
|
||||
luaL_addchar(b, '\\');
|
||||
if (c >= 100 || lj_char_isdigit(uchar(s[1]))) {
|
||||
luaL_addchar(b, '0'+(c >= 100)); if (c >= 100) c -= 100;
|
||||
goto tens;
|
||||
} else if (c >= 10) {
|
||||
tens:
|
||||
d = (c * 205) >> 11; c -= d * 10; luaL_addchar(b, '0'+d);
|
||||
}
|
||||
c += '0';
|
||||
}
|
||||
luaL_addchar(b, c);
|
||||
s++;
|
||||
}
|
||||
luaL_addchar(b, '"');
|
||||
}
|
||||
|
||||
static const char *scanformat(lua_State *L, const char *strfrmt, char *form)
|
||||
{
|
||||
const char *p = strfrmt;
|
||||
while (*p != '\0' && strchr(FMT_FLAGS, *p) != NULL) p++; /* skip flags */
|
||||
if ((size_t)(p - strfrmt) >= sizeof(FMT_FLAGS))
|
||||
lj_err_caller(L, LJ_ERR_STRFMTR);
|
||||
if (lj_char_isdigit(uchar(*p))) p++; /* skip width */
|
||||
if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */
|
||||
if (*p == '.') {
|
||||
p++;
|
||||
if (lj_char_isdigit(uchar(*p))) p++; /* skip precision */
|
||||
if (lj_char_isdigit(uchar(*p))) p++; /* (2 digits at most) */
|
||||
}
|
||||
if (lj_char_isdigit(uchar(*p)))
|
||||
lj_err_caller(L, LJ_ERR_STRFMTW);
|
||||
*(form++) = '%';
|
||||
strncpy(form, strfrmt, (size_t)(p - strfrmt + 1));
|
||||
form += p - strfrmt + 1;
|
||||
*form = '\0';
|
||||
return p;
|
||||
}
|
||||
|
||||
static void addintlen(char *form)
|
||||
{
|
||||
size_t l = strlen(form);
|
||||
char spec = form[l - 1];
|
||||
strcpy(form + l - 1, LUA_INTFRMLEN);
|
||||
form[l + sizeof(LUA_INTFRMLEN) - 2] = spec;
|
||||
form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0';
|
||||
}
|
||||
|
||||
static unsigned LUA_INTFRM_T num2intfrm(lua_State *L, int arg)
|
||||
{
|
||||
if (sizeof(LUA_INTFRM_T) == 4) {
|
||||
return (LUA_INTFRM_T)lj_lib_checkbit(L, arg);
|
||||
} else {
|
||||
cTValue *o;
|
||||
lj_lib_checknumber(L, arg);
|
||||
o = L->base+arg-1;
|
||||
if (tvisint(o))
|
||||
return (LUA_INTFRM_T)intV(o);
|
||||
else
|
||||
return (LUA_INTFRM_T)numV(o);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned LUA_INTFRM_T num2uintfrm(lua_State *L, int arg)
|
||||
{
|
||||
if (sizeof(LUA_INTFRM_T) == 4) {
|
||||
return (unsigned LUA_INTFRM_T)lj_lib_checkbit(L, arg);
|
||||
} else {
|
||||
cTValue *o;
|
||||
lj_lib_checknumber(L, arg);
|
||||
o = L->base+arg-1;
|
||||
if (tvisint(o))
|
||||
return (unsigned LUA_INTFRM_T)intV(o);
|
||||
else if ((int32_t)o->u32.hi < 0)
|
||||
return (unsigned LUA_INTFRM_T)(LUA_INTFRM_T)numV(o);
|
||||
else
|
||||
return (unsigned LUA_INTFRM_T)numV(o);
|
||||
}
|
||||
}
|
||||
|
||||
static GCstr *meta_tostring(lua_State *L, int arg)
|
||||
{
|
||||
TValue *o = L->base+arg-1;
|
||||
cTValue *mo;
|
||||
lua_assert(o < L->top); /* Caller already checks for existence. */
|
||||
if (LJ_LIKELY(tvisstr(o)))
|
||||
return strV(o);
|
||||
if (!tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) {
|
||||
copyTV(L, L->top++, mo);
|
||||
copyTV(L, L->top++, o);
|
||||
lua_call(L, 1, 1);
|
||||
L->top--;
|
||||
if (tvisstr(L->top))
|
||||
return strV(L->top);
|
||||
o = L->base+arg-1;
|
||||
copyTV(L, o, L->top);
|
||||
}
|
||||
if (tvisnumber(o)) {
|
||||
return lj_str_fromnumber(L, o);
|
||||
} else if (tvisnil(o)) {
|
||||
return lj_str_newlit(L, "nil");
|
||||
} else if (tvisfalse(o)) {
|
||||
return lj_str_newlit(L, "false");
|
||||
} else if (tvistrue(o)) {
|
||||
return lj_str_newlit(L, "true");
|
||||
} else {
|
||||
if (tvisfunc(o) && isffunc(funcV(o)))
|
||||
lj_str_pushf(L, "function: builtin#%d", funcV(o)->c.ffid);
|
||||
else
|
||||
lj_str_pushf(L, "%s: %p", lj_typename(o), lua_topointer(L, arg));
|
||||
L->top--;
|
||||
return strV(L->top);
|
||||
}
|
||||
}
|
||||
|
||||
LJLIB_CF(string_format)
|
||||
{
|
||||
int arg = 1, top = (int)(L->top - L->base);
|
||||
GCstr *fmt = lj_lib_checkstr(L, arg);
|
||||
const char *strfrmt = strdata(fmt);
|
||||
const char *strfrmt_end = strfrmt + fmt->len;
|
||||
luaL_Buffer b;
|
||||
luaL_buffinit(L, &b);
|
||||
while (strfrmt < strfrmt_end) {
|
||||
if (*strfrmt != L_ESC) {
|
||||
luaL_addchar(&b, *strfrmt++);
|
||||
} else if (*++strfrmt == L_ESC) {
|
||||
luaL_addchar(&b, *strfrmt++); /* %% */
|
||||
} else { /* format item */
|
||||
char form[MAX_FMTSPEC]; /* to store the format (`%...') */
|
||||
char buff[MAX_FMTITEM]; /* to store the formatted item */
|
||||
if (++arg > top)
|
||||
luaL_argerror(L, arg, lj_obj_typename[0]);
|
||||
strfrmt = scanformat(L, strfrmt, form);
|
||||
switch (*strfrmt++) {
|
||||
case 'c':
|
||||
sprintf(buff, form, lj_lib_checkint(L, arg));
|
||||
break;
|
||||
case 'd': case 'i':
|
||||
addintlen(form);
|
||||
sprintf(buff, form, num2intfrm(L, arg));
|
||||
break;
|
||||
case 'o': case 'u': case 'x': case 'X':
|
||||
addintlen(form);
|
||||
sprintf(buff, form, num2uintfrm(L, arg));
|
||||
break;
|
||||
case 'e': case 'E': case 'f': case 'g': case 'G': case 'a': case 'A': {
|
||||
TValue tv;
|
||||
tv.n = lj_lib_checknum(L, arg);
|
||||
if (LJ_UNLIKELY((tv.u32.hi << 1) >= 0xffe00000)) {
|
||||
/* Canonicalize output of non-finite values. */
|
||||
char *p, nbuf[LJ_STR_NUMBUF];
|
||||
size_t len = lj_str_bufnum(nbuf, &tv);
|
||||
if (strfrmt[-1] < 'a') {
|
||||
nbuf[len-3] = nbuf[len-3] - 0x20;
|
||||
nbuf[len-2] = nbuf[len-2] - 0x20;
|
||||
nbuf[len-1] = nbuf[len-1] - 0x20;
|
||||
}
|
||||
nbuf[len] = '\0';
|
||||
for (p = form; *p < 'A' && *p != '.'; p++) ;
|
||||
*p++ = 's'; *p = '\0';
|
||||
sprintf(buff, form, nbuf);
|
||||
break;
|
||||
}
|
||||
sprintf(buff, form, (double)tv.n);
|
||||
break;
|
||||
}
|
||||
case 'q':
|
||||
addquoted(L, &b, arg);
|
||||
continue;
|
||||
case 'p':
|
||||
lj_str_pushf(L, "%p", lua_topointer(L, arg));
|
||||
luaL_addvalue(&b);
|
||||
continue;
|
||||
case 's': {
|
||||
GCstr *str = meta_tostring(L, arg);
|
||||
if (!strchr(form, '.') && str->len >= 100) {
|
||||
/* no precision and string is too long to be formatted;
|
||||
keep original string */
|
||||
setstrV(L, L->top++, str);
|
||||
luaL_addvalue(&b);
|
||||
continue;
|
||||
}
|
||||
sprintf(buff, form, strdata(str));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
lj_err_callerv(L, LJ_ERR_STRFMTO, *(strfrmt -1));
|
||||
break;
|
||||
}
|
||||
luaL_addlstring(&b, buff, strlen(buff));
|
||||
}
|
||||
}
|
||||
luaL_pushresult(&b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#include "lj_libdef.h"
|
||||
|
||||
LUALIB_API int luaopen_string(lua_State *L)
|
||||
{
|
||||
GCtab *mt;
|
||||
global_State *g;
|
||||
LJ_LIB_REG(L, LUA_STRLIBNAME, string);
|
||||
#if defined(LUA_COMPAT_GFIND) && !LJ_52
|
||||
lua_getfield(L, -1, "gmatch");
|
||||
lua_setfield(L, -2, "gfind");
|
||||
#endif
|
||||
mt = lj_tab_new(L, 0, 1);
|
||||
/* NOBARRIER: basemt is a GC root. */
|
||||
g = G(L);
|
||||
setgcref(basemt_it(g, LJ_TSTR), obj2gco(mt));
|
||||
settabV(L, lj_tab_setstr(L, mt, mmname_str(g, MM_index)), tabV(L->top-1));
|
||||
mt->nomm = (uint8_t)(~(1u<<MM_index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
/*
|
||||
** Table library.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#define lib_table_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_gc.h"
|
||||
#include "lj_err.h"
|
||||
#include "lj_tab.h"
|
||||
#include "lj_lib.h"
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#define LJLIB_MODULE_table
|
||||
|
||||
LJLIB_CF(table_foreachi)
|
||||
{
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
GCfunc *func = lj_lib_checkfunc(L, 2);
|
||||
MSize i, n = lj_tab_len(t);
|
||||
for (i = 1; i <= n; i++) {
|
||||
cTValue *val;
|
||||
setfuncV(L, L->top, func);
|
||||
setintV(L->top+1, i);
|
||||
val = lj_tab_getint(t, (int32_t)i);
|
||||
if (val) { copyTV(L, L->top+2, val); } else { setnilV(L->top+2); }
|
||||
L->top += 3;
|
||||
lua_call(L, 2, 1);
|
||||
if (!tvisnil(L->top-1))
|
||||
return 1;
|
||||
L->top--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LJLIB_CF(table_foreach)
|
||||
{
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
GCfunc *func = lj_lib_checkfunc(L, 2);
|
||||
L->top = L->base+3;
|
||||
setnilV(L->top-1);
|
||||
while (lj_tab_next(L, t, L->top-1)) {
|
||||
copyTV(L, L->top+2, L->top);
|
||||
copyTV(L, L->top+1, L->top-1);
|
||||
setfuncV(L, L->top, func);
|
||||
L->top += 3;
|
||||
lua_call(L, 2, 1);
|
||||
if (!tvisnil(L->top-1))
|
||||
return 1;
|
||||
L->top--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LJLIB_ASM(table_getn) LJLIB_REC(.)
|
||||
{
|
||||
lj_lib_checktab(L, 1);
|
||||
return FFH_UNREACHABLE;
|
||||
}
|
||||
|
||||
LJLIB_CF(table_maxn)
|
||||
{
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
TValue *array = tvref(t->array);
|
||||
Node *node;
|
||||
lua_Number m = 0;
|
||||
ptrdiff_t i;
|
||||
for (i = (ptrdiff_t)t->asize - 1; i >= 0; i--)
|
||||
if (!tvisnil(&array[i])) {
|
||||
m = (lua_Number)(int32_t)i;
|
||||
break;
|
||||
}
|
||||
node = noderef(t->node);
|
||||
for (i = (ptrdiff_t)t->hmask; i >= 0; i--)
|
||||
if (!tvisnil(&node[i].val) && tvisnumber(&node[i].key)) {
|
||||
lua_Number n = numberVnum(&node[i].key);
|
||||
if (n > m) m = n;
|
||||
}
|
||||
setnumV(L->top-1, m);
|
||||
return 1;
|
||||
}
|
||||
|
||||
LJLIB_CF(table_insert) LJLIB_REC(.)
|
||||
{
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
int32_t n, i = (int32_t)lj_tab_len(t) + 1;
|
||||
int nargs = (int)((char *)L->top - (char *)L->base);
|
||||
if (nargs != 2*sizeof(TValue)) {
|
||||
if (nargs != 3*sizeof(TValue))
|
||||
lj_err_caller(L, LJ_ERR_TABINS);
|
||||
/* NOBARRIER: This just moves existing elements around. */
|
||||
for (n = lj_lib_checkint(L, 2); i > n; i--) {
|
||||
/* The set may invalidate the get pointer, so need to do it first! */
|
||||
TValue *dst = lj_tab_setint(L, t, i);
|
||||
cTValue *src = lj_tab_getint(t, i-1);
|
||||
if (src) {
|
||||
copyTV(L, dst, src);
|
||||
} else {
|
||||
setnilV(dst);
|
||||
}
|
||||
}
|
||||
i = n;
|
||||
}
|
||||
{
|
||||
TValue *dst = lj_tab_setint(L, t, i);
|
||||
copyTV(L, dst, L->top-1); /* Set new value. */
|
||||
lj_gc_barriert(L, t, dst);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LJLIB_CF(table_remove) LJLIB_REC(.)
|
||||
{
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
int32_t e = (int32_t)lj_tab_len(t);
|
||||
int32_t pos = lj_lib_optint(L, 2, e);
|
||||
if (!(1 <= pos && pos <= e)) /* Nothing to remove? */
|
||||
return 0;
|
||||
lua_rawgeti(L, 1, pos); /* Get previous value. */
|
||||
/* NOBARRIER: This just moves existing elements around. */
|
||||
for (; pos < e; pos++) {
|
||||
cTValue *src = lj_tab_getint(t, pos+1);
|
||||
TValue *dst = lj_tab_setint(L, t, pos);
|
||||
if (src) {
|
||||
copyTV(L, dst, src);
|
||||
} else {
|
||||
setnilV(dst);
|
||||
}
|
||||
}
|
||||
setnilV(lj_tab_setint(L, t, e)); /* Remove (last) value. */
|
||||
return 1; /* Return previous value. */
|
||||
}
|
||||
|
||||
LJLIB_CF(table_concat)
|
||||
{
|
||||
luaL_Buffer b;
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
GCstr *sep = lj_lib_optstr(L, 2);
|
||||
MSize seplen = sep ? sep->len : 0;
|
||||
int32_t i = lj_lib_optint(L, 3, 1);
|
||||
int32_t e = L->base+3 < L->top ? lj_lib_checkint(L, 4) :
|
||||
(int32_t)lj_tab_len(t);
|
||||
luaL_buffinit(L, &b);
|
||||
if (i <= e) {
|
||||
for (;;) {
|
||||
cTValue *o;
|
||||
lua_rawgeti(L, 1, i);
|
||||
o = L->top-1;
|
||||
if (!(tvisstr(o) || tvisnumber(o)))
|
||||
lj_err_callerv(L, LJ_ERR_TABCAT, lj_typename(o), i);
|
||||
luaL_addvalue(&b);
|
||||
if (i++ == e) break;
|
||||
if (seplen)
|
||||
luaL_addlstring(&b, strdata(sep), seplen);
|
||||
}
|
||||
}
|
||||
luaL_pushresult(&b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static void set2(lua_State *L, int i, int j)
|
||||
{
|
||||
lua_rawseti(L, 1, i);
|
||||
lua_rawseti(L, 1, j);
|
||||
}
|
||||
|
||||
static int sort_comp(lua_State *L, int a, int b)
|
||||
{
|
||||
if (!lua_isnil(L, 2)) { /* function? */
|
||||
int res;
|
||||
lua_pushvalue(L, 2);
|
||||
lua_pushvalue(L, a-1); /* -1 to compensate function */
|
||||
lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
|
||||
lua_call(L, 2, 1);
|
||||
res = lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
return res;
|
||||
} else { /* a < b? */
|
||||
return lua_lessthan(L, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
static void auxsort(lua_State *L, int l, int u)
|
||||
{
|
||||
while (l < u) { /* for tail recursion */
|
||||
int i, j;
|
||||
/* sort elements a[l], a[(l+u)/2] and a[u] */
|
||||
lua_rawgeti(L, 1, l);
|
||||
lua_rawgeti(L, 1, u);
|
||||
if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */
|
||||
set2(L, l, u); /* swap a[l] - a[u] */
|
||||
else
|
||||
lua_pop(L, 2);
|
||||
if (u-l == 1) break; /* only 2 elements */
|
||||
i = (l+u)/2;
|
||||
lua_rawgeti(L, 1, i);
|
||||
lua_rawgeti(L, 1, l);
|
||||
if (sort_comp(L, -2, -1)) { /* a[i]<a[l]? */
|
||||
set2(L, i, l);
|
||||
} else {
|
||||
lua_pop(L, 1); /* remove a[l] */
|
||||
lua_rawgeti(L, 1, u);
|
||||
if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */
|
||||
set2(L, i, u);
|
||||
else
|
||||
lua_pop(L, 2);
|
||||
}
|
||||
if (u-l == 2) break; /* only 3 elements */
|
||||
lua_rawgeti(L, 1, i); /* Pivot */
|
||||
lua_pushvalue(L, -1);
|
||||
lua_rawgeti(L, 1, u-1);
|
||||
set2(L, i, u-1);
|
||||
/* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
|
||||
i = l; j = u-1;
|
||||
for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */
|
||||
/* repeat ++i until a[i] >= P */
|
||||
while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
|
||||
if (i>=u) lj_err_caller(L, LJ_ERR_TABSORT);
|
||||
lua_pop(L, 1); /* remove a[i] */
|
||||
}
|
||||
/* repeat --j until a[j] <= P */
|
||||
while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
|
||||
if (j<=l) lj_err_caller(L, LJ_ERR_TABSORT);
|
||||
lua_pop(L, 1); /* remove a[j] */
|
||||
}
|
||||
if (j<i) {
|
||||
lua_pop(L, 3); /* pop pivot, a[i], a[j] */
|
||||
break;
|
||||
}
|
||||
set2(L, i, j);
|
||||
}
|
||||
lua_rawgeti(L, 1, u-1);
|
||||
lua_rawgeti(L, 1, i);
|
||||
set2(L, u-1, i); /* swap pivot (a[u-1]) with a[i] */
|
||||
/* a[l..i-1] <= a[i] == P <= a[i+1..u] */
|
||||
/* adjust so that smaller half is in [j..i] and larger one in [l..u] */
|
||||
if (i-l < u-i) {
|
||||
j=l; i=i-1; l=i+2;
|
||||
} else {
|
||||
j=i+1; i=u; u=j-2;
|
||||
}
|
||||
auxsort(L, j, i); /* call recursively the smaller one */
|
||||
} /* repeat the routine for the larger one */
|
||||
}
|
||||
|
||||
LJLIB_CF(table_sort)
|
||||
{
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
int32_t n = (int32_t)lj_tab_len(t);
|
||||
lua_settop(L, 2);
|
||||
if (!tvisnil(L->base+1))
|
||||
lj_lib_checkfunc(L, 2);
|
||||
auxsort(L, 1, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if LJ_52
|
||||
LJLIB_PUSH("n")
|
||||
LJLIB_CF(table_pack)
|
||||
{
|
||||
TValue *array, *base = L->base;
|
||||
MSize i, n = (uint32_t)(L->top - base);
|
||||
GCtab *t = lj_tab_new(L, n ? n+1 : 0, 1);
|
||||
/* NOBARRIER: The table is new (marked white). */
|
||||
setintV(lj_tab_setstr(L, t, strV(lj_lib_upvalue(L, 1))), (int32_t)n);
|
||||
for (array = tvref(t->array) + 1, i = 0; i < n; i++)
|
||||
copyTV(L, &array[i], &base[i]);
|
||||
settabV(L, base, t);
|
||||
L->top = base+1;
|
||||
lj_gc_check(L);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#include "lj_libdef.h"
|
||||
|
||||
LUALIB_API int luaopen_table(lua_State *L)
|
||||
{
|
||||
LJ_LIB_REG(L, LUA_TABLIBNAME, table);
|
||||
#if LJ_52
|
||||
lua_getglobal(L, "unpack");
|
||||
lua_setfield(L, -2, "unpack");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,26 +0,0 @@
|
||||
# Valgrind suppression file for LuaJIT 2.0.
|
||||
{
|
||||
Optimized string compare
|
||||
Memcheck:Addr4
|
||||
fun:lj_str_cmp
|
||||
}
|
||||
{
|
||||
Optimized string compare
|
||||
Memcheck:Addr1
|
||||
fun:lj_str_cmp
|
||||
}
|
||||
{
|
||||
Optimized string compare
|
||||
Memcheck:Addr4
|
||||
fun:lj_str_new
|
||||
}
|
||||
{
|
||||
Optimized string compare
|
||||
Memcheck:Addr1
|
||||
fun:lj_str_new
|
||||
}
|
||||
{
|
||||
Optimized string compare
|
||||
Memcheck:Cond
|
||||
fun:lj_str_new
|
||||
}
|
||||
@@ -1,419 +0,0 @@
|
||||
/*
|
||||
** Target architecture selection.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_ARCH_H
|
||||
#define _LJ_ARCH_H
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
/* Target endianess. */
|
||||
#define LUAJIT_LE 0
|
||||
#define LUAJIT_BE 1
|
||||
|
||||
/* Target architectures. */
|
||||
#define LUAJIT_ARCH_X86 1
|
||||
#define LUAJIT_ARCH_x86 1
|
||||
#define LUAJIT_ARCH_X64 2
|
||||
#define LUAJIT_ARCH_x64 2
|
||||
#define LUAJIT_ARCH_ARM 3
|
||||
#define LUAJIT_ARCH_arm 3
|
||||
#define LUAJIT_ARCH_PPC 4
|
||||
#define LUAJIT_ARCH_ppc 4
|
||||
#define LUAJIT_ARCH_PPCSPE 5
|
||||
#define LUAJIT_ARCH_ppcspe 5
|
||||
#define LUAJIT_ARCH_MIPS 6
|
||||
#define LUAJIT_ARCH_mips 6
|
||||
|
||||
/* Target OS. */
|
||||
#define LUAJIT_OS_OTHER 0
|
||||
#define LUAJIT_OS_WINDOWS 1
|
||||
#define LUAJIT_OS_LINUX 2
|
||||
#define LUAJIT_OS_OSX 3
|
||||
#define LUAJIT_OS_BSD 4
|
||||
#define LUAJIT_OS_POSIX 5
|
||||
|
||||
/* Select native target if no target defined. */
|
||||
#ifndef LUAJIT_TARGET
|
||||
|
||||
#if defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#define LUAJIT_TARGET LUAJIT_ARCH_X86
|
||||
#elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
|
||||
#define LUAJIT_TARGET LUAJIT_ARCH_X64
|
||||
#elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM)
|
||||
#define LUAJIT_TARGET LUAJIT_ARCH_ARM
|
||||
#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
|
||||
#ifdef __NO_FPRS__
|
||||
#define LUAJIT_TARGET LUAJIT_ARCH_PPCSPE
|
||||
#else
|
||||
#define LUAJIT_TARGET LUAJIT_ARCH_PPC
|
||||
#endif
|
||||
#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS)
|
||||
#define LUAJIT_TARGET LUAJIT_ARCH_MIPS
|
||||
#else
|
||||
#error "No support for this architecture (yet)"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Select native OS if no target OS defined. */
|
||||
#ifndef LUAJIT_OS
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX_VER)
|
||||
#define LUAJIT_OS LUAJIT_OS_WINDOWS
|
||||
#elif defined(__linux__)
|
||||
#define LUAJIT_OS LUAJIT_OS_LINUX
|
||||
#elif defined(__MACH__) && defined(__APPLE__)
|
||||
#define LUAJIT_OS LUAJIT_OS_OSX
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
|
||||
defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#define LUAJIT_OS LUAJIT_OS_BSD
|
||||
#elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)
|
||||
#define LUAJIT_OS LUAJIT_OS_POSIX
|
||||
#else
|
||||
#define LUAJIT_OS LUAJIT_OS_OTHER
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Set target OS properties. */
|
||||
#if LUAJIT_OS == LUAJIT_OS_WINDOWS
|
||||
#define LJ_OS_NAME "Windows"
|
||||
#elif LUAJIT_OS == LUAJIT_OS_LINUX
|
||||
#define LJ_OS_NAME "Linux"
|
||||
#elif LUAJIT_OS == LUAJIT_OS_OSX
|
||||
#define LJ_OS_NAME "OSX"
|
||||
#elif LUAJIT_OS == LUAJIT_OS_BSD
|
||||
#define LJ_OS_NAME "BSD"
|
||||
#elif LUAJIT_OS == LUAJIT_OS_POSIX
|
||||
#define LJ_OS_NAME "POSIX"
|
||||
#else
|
||||
#define LJ_OS_NAME "Other"
|
||||
#endif
|
||||
|
||||
#define LJ_TARGET_WINDOWS (LUAJIT_OS == LUAJIT_OS_WINDOWS)
|
||||
#define LJ_TARGET_LINUX (LUAJIT_OS == LUAJIT_OS_LINUX)
|
||||
#define LJ_TARGET_OSX (LUAJIT_OS == LUAJIT_OS_OSX)
|
||||
#define LJ_TARGET_IOS (LJ_TARGET_OSX && LUAJIT_TARGET == LUAJIT_ARCH_ARM)
|
||||
#define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS)
|
||||
#define LJ_TARGET_DLOPEN LJ_TARGET_POSIX
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
#define LJ_TARGET_PS3 1
|
||||
#define LJ_TARGET_CONSOLE 1
|
||||
#endif
|
||||
|
||||
#if _XBOX_VER >= 200
|
||||
#define LJ_TARGET_XBOX360 1
|
||||
#define LJ_TARGET_CONSOLE 1
|
||||
#endif
|
||||
|
||||
#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */
|
||||
#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */
|
||||
#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */
|
||||
#define LJ_NUMMODE_DUAL_SINGLE 3 /* Default to dual-number mode. */
|
||||
|
||||
/* Set target architecture properties. */
|
||||
#if LUAJIT_TARGET == LUAJIT_ARCH_X86
|
||||
|
||||
#define LJ_ARCH_NAME "x86"
|
||||
#define LJ_ARCH_BITS 32
|
||||
#define LJ_ARCH_ENDIAN LUAJIT_LE
|
||||
#if LJ_TARGET_WINDOWS || __CYGWIN__
|
||||
#define LJ_ABI_WIN 1
|
||||
#else
|
||||
#define LJ_ABI_WIN 0
|
||||
#endif
|
||||
#define LJ_TARGET_X86 1
|
||||
#define LJ_TARGET_X86ORX64 1
|
||||
#define LJ_TARGET_EHRETREG 0
|
||||
#define LJ_TARGET_MASKSHIFT 1
|
||||
#define LJ_TARGET_MASKROT 1
|
||||
#define LJ_TARGET_UNALIGNED 1
|
||||
#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL
|
||||
|
||||
#elif LUAJIT_TARGET == LUAJIT_ARCH_X64
|
||||
|
||||
#define LJ_ARCH_NAME "x64"
|
||||
#define LJ_ARCH_BITS 64
|
||||
#define LJ_ARCH_ENDIAN LUAJIT_LE
|
||||
#define LJ_ABI_WIN LJ_TARGET_WINDOWS
|
||||
#define LJ_TARGET_X64 1
|
||||
#define LJ_TARGET_X86ORX64 1
|
||||
#define LJ_TARGET_EHRETREG 0
|
||||
#define LJ_TARGET_JUMPRANGE 31 /* +-2^31 = +-2GB */
|
||||
#define LJ_TARGET_MASKSHIFT 1
|
||||
#define LJ_TARGET_MASKROT 1
|
||||
#define LJ_TARGET_UNALIGNED 1
|
||||
#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE_DUAL
|
||||
|
||||
#elif LUAJIT_TARGET == LUAJIT_ARCH_ARM
|
||||
|
||||
#define LJ_ARCH_NAME "arm"
|
||||
#define LJ_ARCH_BITS 32
|
||||
#define LJ_ARCH_ENDIAN LUAJIT_LE
|
||||
#if !defined(LJ_ARCH_HASFPU) && __SOFTFP__
|
||||
#define LJ_ARCH_HASFPU 0
|
||||
#endif
|
||||
#if !defined(LJ_ABI_SOFTFP) && !__ARM_PCS_VFP
|
||||
#define LJ_ABI_SOFTFP 1
|
||||
#endif
|
||||
#define LJ_ABI_EABI 1
|
||||
#define LJ_TARGET_ARM 1
|
||||
#define LJ_TARGET_EHRETREG 0
|
||||
#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */
|
||||
#define LJ_TARGET_MASKSHIFT 0
|
||||
#define LJ_TARGET_MASKROT 1
|
||||
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
|
||||
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
|
||||
|
||||
#if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__
|
||||
#define LJ_ARCH_VERSION 70
|
||||
#elif __ARM_ARCH_6T2__
|
||||
#define LJ_ARCH_VERSION 61
|
||||
#elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__
|
||||
#define LJ_ARCH_VERSION 60
|
||||
#else
|
||||
#define LJ_ARCH_VERSION 50
|
||||
#endif
|
||||
|
||||
#elif LUAJIT_TARGET == LUAJIT_ARCH_PPC
|
||||
|
||||
#define LJ_ARCH_NAME "ppc"
|
||||
#if _LP64
|
||||
#define LJ_ARCH_BITS 64
|
||||
#else
|
||||
#define LJ_ARCH_BITS 32
|
||||
#endif
|
||||
#define LJ_ARCH_ENDIAN LUAJIT_BE
|
||||
#define LJ_TARGET_PPC 1
|
||||
#define LJ_TARGET_EHRETREG 3
|
||||
#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */
|
||||
#define LJ_TARGET_MASKSHIFT 0
|
||||
#define LJ_TARGET_MASKROT 1
|
||||
#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */
|
||||
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL_SINGLE
|
||||
|
||||
#if _ARCH_PWR7
|
||||
#define LJ_ARCH_VERSION 70
|
||||
#elif _ARCH_PWR6
|
||||
#define LJ_ARCH_VERSION 60
|
||||
#elif _ARCH_PWR5X
|
||||
#define LJ_ARCH_VERSION 51
|
||||
#elif _ARCH_PWR5
|
||||
#define LJ_ARCH_VERSION 50
|
||||
#elif _ARCH_PWR4
|
||||
#define LJ_ARCH_VERSION 40
|
||||
#else
|
||||
#define LJ_ARCH_VERSION 0
|
||||
#endif
|
||||
#if __PPC64__ || __powerpc64__ || LJ_TARGET_CONSOLE
|
||||
#define LJ_ARCH_PPC64 1
|
||||
#define LJ_ARCH_NOFFI 1
|
||||
#endif
|
||||
#if _ARCH_PPCSQ
|
||||
#define LJ_ARCH_SQRT 1
|
||||
#endif
|
||||
#if _ARCH_PWR5X
|
||||
#define LJ_ARCH_ROUND 1
|
||||
#endif
|
||||
#if __PPU__
|
||||
#define LJ_ARCH_CELL 1
|
||||
#endif
|
||||
#if LJ_TARGET_XBOX360
|
||||
#define LJ_ARCH_XENON 1
|
||||
#endif
|
||||
|
||||
#elif LUAJIT_TARGET == LUAJIT_ARCH_PPCSPE
|
||||
|
||||
#define LJ_ARCH_NAME "ppcspe"
|
||||
#define LJ_ARCH_BITS 32
|
||||
#define LJ_ARCH_ENDIAN LUAJIT_BE
|
||||
#ifndef LJ_ABI_SOFTFP
|
||||
#define LJ_ABI_SOFTFP 1
|
||||
#endif
|
||||
#define LJ_ABI_EABI 1
|
||||
#define LJ_TARGET_PPCSPE 1
|
||||
#define LJ_TARGET_EHRETREG 3
|
||||
#define LJ_TARGET_JUMPRANGE 25 /* +-2^25 = +-32MB */
|
||||
#define LJ_TARGET_MASKSHIFT 0
|
||||
#define LJ_TARGET_MASKROT 1
|
||||
#define LJ_TARGET_UNIFYROT 1 /* Want only IR_BROL. */
|
||||
#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE
|
||||
#define LJ_ARCH_NOFFI 1 /* NYI: comparisons, calls. */
|
||||
#define LJ_ARCH_NOJIT 1
|
||||
|
||||
#elif LUAJIT_TARGET == LUAJIT_ARCH_MIPS
|
||||
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
|
||||
#define LJ_ARCH_NAME "mipsel"
|
||||
#define LJ_ARCH_ENDIAN LUAJIT_LE
|
||||
#else
|
||||
#define LJ_ARCH_NAME "mips"
|
||||
#define LJ_ARCH_ENDIAN LUAJIT_BE
|
||||
#endif
|
||||
#define LJ_ARCH_BITS 32
|
||||
#define LJ_TARGET_MIPS 1
|
||||
#define LJ_TARGET_EHRETREG 4
|
||||
#define LJ_TARGET_JUMPRANGE 27 /* 2*2^27 = 256MB-aligned region */
|
||||
#define LJ_TARGET_MASKSHIFT 1
|
||||
#define LJ_TARGET_MASKROT 1
|
||||
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
|
||||
#define LJ_ARCH_NUMMODE LJ_NUMMODE_SINGLE
|
||||
|
||||
#if _MIPS_ARCH_MIPS32R2
|
||||
#define LJ_ARCH_VERSION 20
|
||||
#else
|
||||
#define LJ_ARCH_VERSION 10
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error "No target architecture defined"
|
||||
#endif
|
||||
|
||||
#ifndef LJ_PAGESIZE
|
||||
#define LJ_PAGESIZE 4096
|
||||
#endif
|
||||
|
||||
/* Check for minimum required compiler versions. */
|
||||
#if defined(__GNUC__)
|
||||
#if LJ_TARGET_X86
|
||||
#if (__GNUC__ < 3) || ((__GNUC__ == 3) && __GNUC_MINOR__ < 4)
|
||||
#error "Need at least GCC 3.4 or newer"
|
||||
#endif
|
||||
#elif LJ_TARGET_X64
|
||||
#if __GNUC__ < 4
|
||||
#error "Need at least GCC 4.0 or newer"
|
||||
#endif
|
||||
#elif LJ_TARGET_ARM
|
||||
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2)
|
||||
#error "Need at least GCC 4.2 or newer"
|
||||
#endif
|
||||
#elif !LJ_TARGET_PS3
|
||||
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
|
||||
#error "Need at least GCC 4.3 or newer"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Check target-specific constraints. */
|
||||
#ifndef _BUILDVM_H
|
||||
#if LJ_TARGET_X64
|
||||
#if __USING_SJLJ_EXCEPTIONS__
|
||||
#error "Need a C compiler with native exception handling on x64"
|
||||
#endif
|
||||
#elif LJ_TARGET_ARM
|
||||
#if defined(__ARMEB__)
|
||||
#error "No support for big-endian ARM"
|
||||
#endif
|
||||
#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__
|
||||
#error "No support for Cortex-M CPUs"
|
||||
#endif
|
||||
#if !(__ARM_EABI__ || LJ_TARGET_IOS)
|
||||
#error "Only ARM EABI or iOS 3.0+ ABI is supported"
|
||||
#endif
|
||||
#elif LJ_TARGET_PPC || LJ_TARGET_PPCSPE
|
||||
#if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE)
|
||||
#error "No support for PowerPC CPUs without double-precision FPU"
|
||||
#endif
|
||||
#if defined(_LITTLE_ENDIAN)
|
||||
#error "No support for little-endian PowerPC"
|
||||
#endif
|
||||
#if defined(_LP64)
|
||||
#error "No support for PowerPC 64 bit mode"
|
||||
#endif
|
||||
#elif LJ_TARGET_MIPS
|
||||
#if defined(__mips_soft_float)
|
||||
#error "No support for MIPS CPUs without FPU"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Enable or disable the dual-number mode for the VM. */
|
||||
#if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \
|
||||
(LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1)
|
||||
#error "No support for this number mode on this architecture"
|
||||
#endif
|
||||
#if LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL || \
|
||||
(LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL_SINGLE && LUAJIT_NUMMODE != 1) || \
|
||||
(LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE_DUAL && LUAJIT_NUMMODE == 2)
|
||||
#define LJ_DUALNUM 1
|
||||
#else
|
||||
#define LJ_DUALNUM 0
|
||||
#endif
|
||||
|
||||
#if LJ_TARGET_IOS || LJ_TARGET_CONSOLE
|
||||
/* Runtime code generation is restricted on iOS. Complain to Apple, not me. */
|
||||
/* Ditto for the consoles. Complain to Sony or MS, not me. */
|
||||
#ifndef LUAJIT_ENABLE_JIT
|
||||
#define LJ_OS_NOJIT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Disable or enable the JIT compiler. */
|
||||
#if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT)
|
||||
#define LJ_HASJIT 0
|
||||
#else
|
||||
#define LJ_HASJIT 1
|
||||
#endif
|
||||
|
||||
/* Disable or enable the FFI extension. */
|
||||
#if defined(LUAJIT_DISABLE_FFI) || defined(LJ_ARCH_NOFFI)
|
||||
#define LJ_HASFFI 0
|
||||
#else
|
||||
#define LJ_HASFFI 1
|
||||
#endif
|
||||
|
||||
#ifndef LJ_ARCH_HASFPU
|
||||
#define LJ_ARCH_HASFPU 1
|
||||
#endif
|
||||
#ifndef LJ_ABI_SOFTFP
|
||||
#define LJ_ABI_SOFTFP 0
|
||||
#endif
|
||||
#define LJ_SOFTFP (!LJ_ARCH_HASFPU)
|
||||
|
||||
#if LJ_ARCH_ENDIAN == LUAJIT_BE
|
||||
#define LJ_LE 0
|
||||
#define LJ_BE 1
|
||||
#define LJ_ENDIAN_SELECT(le, be) be
|
||||
#define LJ_ENDIAN_LOHI(lo, hi) hi lo
|
||||
#else
|
||||
#define LJ_LE 1
|
||||
#define LJ_BE 0
|
||||
#define LJ_ENDIAN_SELECT(le, be) le
|
||||
#define LJ_ENDIAN_LOHI(lo, hi) lo hi
|
||||
#endif
|
||||
|
||||
#if LJ_ARCH_BITS == 32
|
||||
#define LJ_32 1
|
||||
#define LJ_64 0
|
||||
#else
|
||||
#define LJ_32 0
|
||||
#define LJ_64 1
|
||||
#endif
|
||||
|
||||
#ifndef LJ_TARGET_UNALIGNED
|
||||
#define LJ_TARGET_UNALIGNED 0
|
||||
#endif
|
||||
|
||||
/* Various workarounds for embedded operating systems. */
|
||||
#if (defined(__ANDROID__) && !defined(LJ_TARGET_X86ORX64)) || defined(__symbian__) || LJ_TARGET_XBOX360
|
||||
#define LUAJIT_NO_LOG2
|
||||
#endif
|
||||
#if defined(__symbian__)
|
||||
#define LUAJIT_NO_EXP2
|
||||
#endif
|
||||
|
||||
#if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3
|
||||
#define LJ_NO_UNWIND 1
|
||||
#endif
|
||||
|
||||
/* Compatibility with Lua 5.1 vs. 5.2. */
|
||||
#ifdef LUAJIT_ENABLE_LUA52COMPAT
|
||||
#define LJ_52 1
|
||||
#else
|
||||
#define LJ_52 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,226 +0,0 @@
|
||||
/* This is a generated file. DO NOT EDIT! */
|
||||
|
||||
LJ_DATADEF const uint16_t lj_bc_ofs[] = {
|
||||
0,
|
||||
140,
|
||||
280,
|
||||
420,
|
||||
560,
|
||||
704,
|
||||
844,
|
||||
920,
|
||||
996,
|
||||
1136,
|
||||
1276,
|
||||
1336,
|
||||
1396,
|
||||
1452,
|
||||
1508,
|
||||
1560,
|
||||
1612,
|
||||
1648,
|
||||
1700,
|
||||
1768,
|
||||
1836,
|
||||
1956,
|
||||
2076,
|
||||
2200,
|
||||
2272,
|
||||
2400,
|
||||
2520,
|
||||
2640,
|
||||
2764,
|
||||
2836,
|
||||
2964,
|
||||
3084,
|
||||
3204,
|
||||
3328,
|
||||
3400,
|
||||
3528,
|
||||
3588,
|
||||
3668,
|
||||
3708,
|
||||
3748,
|
||||
3784,
|
||||
3820,
|
||||
3856,
|
||||
3916,
|
||||
3968,
|
||||
4076,
|
||||
4176,
|
||||
4232,
|
||||
4284,
|
||||
4348,
|
||||
4412,
|
||||
4516,
|
||||
4604,
|
||||
4624,
|
||||
4644,
|
||||
4784,
|
||||
4944,
|
||||
5052,
|
||||
5240,
|
||||
5516,
|
||||
5672,
|
||||
5820,
|
||||
5836,
|
||||
5896,
|
||||
5908,
|
||||
6088,
|
||||
6168,
|
||||
6352,
|
||||
6560,
|
||||
6672,
|
||||
6692,
|
||||
6860,
|
||||
6968,
|
||||
7084,
|
||||
7232,
|
||||
7396,
|
||||
7424,
|
||||
7568,
|
||||
7708,
|
||||
7736,
|
||||
7780,
|
||||
7820,
|
||||
7848,
|
||||
7872,
|
||||
7904,
|
||||
7936,
|
||||
7964,
|
||||
8032,
|
||||
8084,
|
||||
8084,
|
||||
8200,
|
||||
8204,
|
||||
8284,
|
||||
10124,
|
||||
10188,
|
||||
10600,
|
||||
10696,
|
||||
10744,
|
||||
10864,
|
||||
10224,
|
||||
10372,
|
||||
10448,
|
||||
10492,
|
||||
10516,
|
||||
10916,
|
||||
10956,
|
||||
11580,
|
||||
11020,
|
||||
11324,
|
||||
11960,
|
||||
11624,
|
||||
11784,
|
||||
12096,
|
||||
12164,
|
||||
12192,
|
||||
12220,
|
||||
12248,
|
||||
12276,
|
||||
12304,
|
||||
12332,
|
||||
12360,
|
||||
12388,
|
||||
12416,
|
||||
12444,
|
||||
12656,
|
||||
12712,
|
||||
12136,
|
||||
12580,
|
||||
12580,
|
||||
12508,
|
||||
12472,
|
||||
12544,
|
||||
12616,
|
||||
12756,
|
||||
12908,
|
||||
13880,
|
||||
14148,
|
||||
14104,
|
||||
14180,
|
||||
14228,
|
||||
14276,
|
||||
14324,
|
||||
14372,
|
||||
13908,
|
||||
13968,
|
||||
14028,
|
||||
13060,
|
||||
13092,
|
||||
13144,
|
||||
13224,
|
||||
13368,
|
||||
13472,
|
||||
13556,
|
||||
13656,
|
||||
13756
|
||||
};
|
||||
|
||||
LJ_DATADEF const uint16_t lj_bc_mode[] = {
|
||||
BCDEF(BCMODE)
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF,
|
||||
BCMODE_FF
|
||||
};
|
||||
|
||||
@@ -1,396 +0,0 @@
|
||||
/*
|
||||
** Bytecode writer.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_bcwrite_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_gc.h"
|
||||
#include "lj_str.h"
|
||||
#include "lj_bc.h"
|
||||
#if LJ_HASFFI
|
||||
#include "lj_ctype.h"
|
||||
#endif
|
||||
#if LJ_HASJIT
|
||||
#include "lj_dispatch.h"
|
||||
#include "lj_jit.h"
|
||||
#endif
|
||||
#include "lj_bcdump.h"
|
||||
#include "lj_vm.h"
|
||||
|
||||
/* Context for bytecode writer. */
|
||||
typedef struct BCWriteCtx {
|
||||
SBuf sb; /* Output buffer. */
|
||||
lua_State *L; /* Lua state. */
|
||||
GCproto *pt; /* Root prototype. */
|
||||
lua_Writer wfunc; /* Writer callback. */
|
||||
void *wdata; /* Writer callback data. */
|
||||
int strip; /* Strip debug info. */
|
||||
int status; /* Status from writer callback. */
|
||||
} BCWriteCtx;
|
||||
|
||||
/* -- Output buffer handling ---------------------------------------------- */
|
||||
|
||||
/* Resize buffer if needed. */
|
||||
static LJ_NOINLINE void bcwrite_resize(BCWriteCtx *ctx, MSize len)
|
||||
{
|
||||
MSize sz = ctx->sb.sz * 2;
|
||||
while (ctx->sb.n + len > sz) sz = sz * 2;
|
||||
lj_str_resizebuf(ctx->L, &ctx->sb, sz);
|
||||
}
|
||||
|
||||
/* Need a certain amount of buffer space. */
|
||||
static LJ_AINLINE void bcwrite_need(BCWriteCtx *ctx, MSize len)
|
||||
{
|
||||
if (LJ_UNLIKELY(ctx->sb.n + len > ctx->sb.sz))
|
||||
bcwrite_resize(ctx, len);
|
||||
}
|
||||
|
||||
/* Add memory block to buffer. */
|
||||
static void bcwrite_block(BCWriteCtx *ctx, const void *p, MSize len)
|
||||
{
|
||||
uint8_t *q = (uint8_t *)(ctx->sb.buf + ctx->sb.n);
|
||||
MSize i;
|
||||
ctx->sb.n += len;
|
||||
for (i = 0; i < len; i++) q[i] = ((uint8_t *)p)[i];
|
||||
}
|
||||
|
||||
/* Add byte to buffer. */
|
||||
static LJ_AINLINE void bcwrite_byte(BCWriteCtx *ctx, uint8_t b)
|
||||
{
|
||||
ctx->sb.buf[ctx->sb.n++] = b;
|
||||
}
|
||||
|
||||
/* Add ULEB128 value to buffer. */
|
||||
static void bcwrite_uleb128(BCWriteCtx *ctx, uint32_t v)
|
||||
{
|
||||
MSize n = ctx->sb.n;
|
||||
uint8_t *p = (uint8_t *)ctx->sb.buf;
|
||||
for (; v >= 0x80; v >>= 7)
|
||||
p[n++] = (uint8_t)((v & 0x7f) | 0x80);
|
||||
p[n++] = (uint8_t)v;
|
||||
ctx->sb.n = n;
|
||||
}
|
||||
|
||||
/* -- Bytecode writer ----------------------------------------------------- */
|
||||
|
||||
/* Write a single constant key/value of a template table. */
|
||||
static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow)
|
||||
{
|
||||
bcwrite_need(ctx, 1+10);
|
||||
if (tvisstr(o)) {
|
||||
const GCstr *str = strV(o);
|
||||
MSize len = str->len;
|
||||
bcwrite_need(ctx, 5+len);
|
||||
bcwrite_uleb128(ctx, BCDUMP_KTAB_STR+len);
|
||||
bcwrite_block(ctx, strdata(str), len);
|
||||
} else if (tvisint(o)) {
|
||||
bcwrite_byte(ctx, BCDUMP_KTAB_INT);
|
||||
bcwrite_uleb128(ctx, intV(o));
|
||||
} else if (tvisnum(o)) {
|
||||
if (!LJ_DUALNUM && narrow) { /* Narrow number constants to integers. */
|
||||
lua_Number num = numV(o);
|
||||
int32_t k = lj_num2int(num);
|
||||
if (num == (lua_Number)k) { /* -0 is never a constant. */
|
||||
bcwrite_byte(ctx, BCDUMP_KTAB_INT);
|
||||
bcwrite_uleb128(ctx, k);
|
||||
return;
|
||||
}
|
||||
}
|
||||
bcwrite_byte(ctx, BCDUMP_KTAB_NUM);
|
||||
bcwrite_uleb128(ctx, o->u32.lo);
|
||||
bcwrite_uleb128(ctx, o->u32.hi);
|
||||
} else {
|
||||
lua_assert(tvispri(o));
|
||||
bcwrite_byte(ctx, BCDUMP_KTAB_NIL+~itype(o));
|
||||
}
|
||||
}
|
||||
|
||||
/* Write a template table. */
|
||||
static void bcwrite_ktab(BCWriteCtx *ctx, const GCtab *t)
|
||||
{
|
||||
MSize narray = 0, nhash = 0;
|
||||
if (t->asize > 0) { /* Determine max. length of array part. */
|
||||
ptrdiff_t i;
|
||||
TValue *array = tvref(t->array);
|
||||
for (i = (ptrdiff_t)t->asize-1; i >= 0; i--)
|
||||
if (!tvisnil(&array[i]))
|
||||
break;
|
||||
narray = (MSize)(i+1);
|
||||
}
|
||||
if (t->hmask > 0) { /* Count number of used hash slots. */
|
||||
MSize i, hmask = t->hmask;
|
||||
Node *node = noderef(t->node);
|
||||
for (i = 0; i <= hmask; i++)
|
||||
nhash += !tvisnil(&node[i].val);
|
||||
}
|
||||
/* Write number of array slots and hash slots. */
|
||||
bcwrite_uleb128(ctx, narray);
|
||||
bcwrite_uleb128(ctx, nhash);
|
||||
if (narray) { /* Write array entries (may contain nil). */
|
||||
MSize i;
|
||||
TValue *o = tvref(t->array);
|
||||
for (i = 0; i < narray; i++, o++)
|
||||
bcwrite_ktabk(ctx, o, 1);
|
||||
}
|
||||
if (nhash) { /* Write hash entries. */
|
||||
MSize i = nhash;
|
||||
Node *node = noderef(t->node) + t->hmask;
|
||||
for (;; node--)
|
||||
if (!tvisnil(&node->val)) {
|
||||
bcwrite_ktabk(ctx, &node->key, 0);
|
||||
bcwrite_ktabk(ctx, &node->val, 1);
|
||||
if (--i == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Write GC constants of a prototype. */
|
||||
static void bcwrite_kgc(BCWriteCtx *ctx, GCproto *pt)
|
||||
{
|
||||
MSize i, sizekgc = pt->sizekgc;
|
||||
GCRef *kr = mref(pt->k, GCRef) - (ptrdiff_t)sizekgc;
|
||||
for (i = 0; i < sizekgc; i++, kr++) {
|
||||
GCobj *o = gcref(*kr);
|
||||
MSize tp, need = 1;
|
||||
/* Determine constant type and needed size. */
|
||||
if (o->gch.gct == ~LJ_TSTR) {
|
||||
tp = BCDUMP_KGC_STR + gco2str(o)->len;
|
||||
need = 5+gco2str(o)->len;
|
||||
} else if (o->gch.gct == ~LJ_TPROTO) {
|
||||
lua_assert((pt->flags & PROTO_CHILD));
|
||||
tp = BCDUMP_KGC_CHILD;
|
||||
#if LJ_HASFFI
|
||||
} else if (o->gch.gct == ~LJ_TCDATA) {
|
||||
CTypeID id = gco2cd(o)->ctypeid;
|
||||
need = 1+4*5;
|
||||
if (id == CTID_INT64) {
|
||||
tp = BCDUMP_KGC_I64;
|
||||
} else if (id == CTID_UINT64) {
|
||||
tp = BCDUMP_KGC_U64;
|
||||
} else {
|
||||
lua_assert(id == CTID_COMPLEX_DOUBLE);
|
||||
tp = BCDUMP_KGC_COMPLEX;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
lua_assert(o->gch.gct == ~LJ_TTAB);
|
||||
tp = BCDUMP_KGC_TAB;
|
||||
need = 1+2*5;
|
||||
}
|
||||
/* Write constant type. */
|
||||
bcwrite_need(ctx, need);
|
||||
bcwrite_uleb128(ctx, tp);
|
||||
/* Write constant data (if any). */
|
||||
if (tp >= BCDUMP_KGC_STR) {
|
||||
bcwrite_block(ctx, strdata(gco2str(o)), gco2str(o)->len);
|
||||
} else if (tp == BCDUMP_KGC_TAB) {
|
||||
bcwrite_ktab(ctx, gco2tab(o));
|
||||
#if LJ_HASFFI
|
||||
} else if (tp != BCDUMP_KGC_CHILD) {
|
||||
cTValue *p = (TValue *)cdataptr(gco2cd(o));
|
||||
bcwrite_uleb128(ctx, p[0].u32.lo);
|
||||
bcwrite_uleb128(ctx, p[0].u32.hi);
|
||||
if (tp == BCDUMP_KGC_COMPLEX) {
|
||||
bcwrite_uleb128(ctx, p[1].u32.lo);
|
||||
bcwrite_uleb128(ctx, p[1].u32.hi);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Write number constants of a prototype. */
|
||||
static void bcwrite_knum(BCWriteCtx *ctx, GCproto *pt)
|
||||
{
|
||||
MSize i, sizekn = pt->sizekn;
|
||||
cTValue *o = mref(pt->k, TValue);
|
||||
bcwrite_need(ctx, 10*sizekn);
|
||||
for (i = 0; i < sizekn; i++, o++) {
|
||||
int32_t k;
|
||||
if (tvisint(o)) {
|
||||
k = intV(o);
|
||||
goto save_int;
|
||||
} else {
|
||||
/* Write a 33 bit ULEB128 for the int (lsb=0) or loword (lsb=1). */
|
||||
if (!LJ_DUALNUM) { /* Narrow number constants to integers. */
|
||||
lua_Number num = numV(o);
|
||||
k = lj_num2int(num);
|
||||
if (num == (lua_Number)k) { /* -0 is never a constant. */
|
||||
save_int:
|
||||
bcwrite_uleb128(ctx, 2*(uint32_t)k | ((uint32_t)k & 0x80000000u));
|
||||
if (k < 0) {
|
||||
char *p = &ctx->sb.buf[ctx->sb.n-1];
|
||||
*p = (*p & 7) | ((k>>27) & 0x18);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
bcwrite_uleb128(ctx, 1+(2*o->u32.lo | (o->u32.lo & 0x80000000u)));
|
||||
if (o->u32.lo >= 0x80000000u) {
|
||||
char *p = &ctx->sb.buf[ctx->sb.n-1];
|
||||
*p = (*p & 7) | ((o->u32.lo>>27) & 0x18);
|
||||
}
|
||||
bcwrite_uleb128(ctx, o->u32.hi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Write bytecode instructions. */
|
||||
static void bcwrite_bytecode(BCWriteCtx *ctx, GCproto *pt)
|
||||
{
|
||||
MSize nbc = pt->sizebc-1; /* Omit the [JI]FUNC* header. */
|
||||
#if LJ_HASJIT
|
||||
uint8_t *p = (uint8_t *)&ctx->sb.buf[ctx->sb.n];
|
||||
#endif
|
||||
bcwrite_block(ctx, proto_bc(pt)+1, nbc*(MSize)sizeof(BCIns));
|
||||
#if LJ_HASJIT
|
||||
/* Unpatch modified bytecode containing ILOOP/JLOOP etc. */
|
||||
if ((pt->flags & PROTO_ILOOP) || pt->trace) {
|
||||
jit_State *J = L2J(ctx->L);
|
||||
MSize i;
|
||||
for (i = 0; i < nbc; i++, p += sizeof(BCIns)) {
|
||||
BCOp op = (BCOp)p[LJ_ENDIAN_SELECT(0, 3)];
|
||||
if (op == BC_IFORL || op == BC_IITERL || op == BC_ILOOP ||
|
||||
op == BC_JFORI) {
|
||||
p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_IFORL+BC_FORL);
|
||||
} else if (op == BC_JFORL || op == BC_JITERL || op == BC_JLOOP) {
|
||||
BCReg rd = p[LJ_ENDIAN_SELECT(2, 1)] + (p[LJ_ENDIAN_SELECT(3, 0)] << 8);
|
||||
BCIns ins = traceref(J, rd)->startins;
|
||||
p[LJ_ENDIAN_SELECT(0, 3)] = (uint8_t)(op-BC_JFORL+BC_FORL);
|
||||
p[LJ_ENDIAN_SELECT(2, 1)] = bc_c(ins);
|
||||
p[LJ_ENDIAN_SELECT(3, 0)] = bc_b(ins);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Write prototype. */
|
||||
static void bcwrite_proto(BCWriteCtx *ctx, GCproto *pt)
|
||||
{
|
||||
MSize sizedbg = 0;
|
||||
|
||||
/* Recursively write children of prototype. */
|
||||
if ((pt->flags & PROTO_CHILD)) {
|
||||
ptrdiff_t i, n = pt->sizekgc;
|
||||
GCRef *kr = mref(pt->k, GCRef) - 1;
|
||||
for (i = 0; i < n; i++, kr--) {
|
||||
GCobj *o = gcref(*kr);
|
||||
if (o->gch.gct == ~LJ_TPROTO)
|
||||
bcwrite_proto(ctx, gco2pt(o));
|
||||
}
|
||||
}
|
||||
|
||||
/* Start writing the prototype info to a buffer. */
|
||||
lj_str_resetbuf(&ctx->sb);
|
||||
ctx->sb.n = 5; /* Leave room for final size. */
|
||||
bcwrite_need(ctx, 4+6*5+(pt->sizebc-1)*(MSize)sizeof(BCIns)+pt->sizeuv*2);
|
||||
|
||||
/* Write prototype header. */
|
||||
bcwrite_byte(ctx, (pt->flags & (PROTO_CHILD|PROTO_VARARG|PROTO_FFI)));
|
||||
bcwrite_byte(ctx, pt->numparams);
|
||||
bcwrite_byte(ctx, pt->framesize);
|
||||
bcwrite_byte(ctx, pt->sizeuv);
|
||||
bcwrite_uleb128(ctx, pt->sizekgc);
|
||||
bcwrite_uleb128(ctx, pt->sizekn);
|
||||
bcwrite_uleb128(ctx, pt->sizebc-1);
|
||||
if (!ctx->strip) {
|
||||
if (proto_lineinfo(pt))
|
||||
sizedbg = pt->sizept - (MSize)((char *)proto_lineinfo(pt) - (char *)pt);
|
||||
bcwrite_uleb128(ctx, sizedbg);
|
||||
if (sizedbg) {
|
||||
bcwrite_uleb128(ctx, pt->firstline);
|
||||
bcwrite_uleb128(ctx, pt->numline);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write bytecode instructions and upvalue refs. */
|
||||
bcwrite_bytecode(ctx, pt);
|
||||
bcwrite_block(ctx, proto_uv(pt), pt->sizeuv*2);
|
||||
|
||||
/* Write constants. */
|
||||
bcwrite_kgc(ctx, pt);
|
||||
bcwrite_knum(ctx, pt);
|
||||
|
||||
/* Write debug info, if not stripped. */
|
||||
if (sizedbg) {
|
||||
bcwrite_need(ctx, sizedbg);
|
||||
bcwrite_block(ctx, proto_lineinfo(pt), sizedbg);
|
||||
}
|
||||
|
||||
/* Pass buffer to writer function. */
|
||||
if (ctx->status == 0) {
|
||||
MSize n = ctx->sb.n - 5;
|
||||
MSize nn = (lj_fls(n)+8)*9 >> 6;
|
||||
ctx->sb.n = 5 - nn;
|
||||
bcwrite_uleb128(ctx, n); /* Fill in final size. */
|
||||
lua_assert(ctx->sb.n == 5);
|
||||
ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf+5-nn, nn+n, ctx->wdata);
|
||||
}
|
||||
}
|
||||
|
||||
/* Write header of bytecode dump. */
|
||||
static void bcwrite_header(BCWriteCtx *ctx)
|
||||
{
|
||||
GCstr *chunkname = proto_chunkname(ctx->pt);
|
||||
const char *name = strdata(chunkname);
|
||||
MSize len = chunkname->len;
|
||||
lj_str_resetbuf(&ctx->sb);
|
||||
bcwrite_need(ctx, 5+5+len);
|
||||
bcwrite_byte(ctx, BCDUMP_HEAD1);
|
||||
bcwrite_byte(ctx, BCDUMP_HEAD2);
|
||||
bcwrite_byte(ctx, BCDUMP_HEAD3);
|
||||
bcwrite_byte(ctx, BCDUMP_VERSION);
|
||||
bcwrite_byte(ctx, (ctx->strip ? BCDUMP_F_STRIP : 0) +
|
||||
(LJ_BE ? BCDUMP_F_BE : 0) +
|
||||
((ctx->pt->flags & PROTO_FFI) ? BCDUMP_F_FFI : 0));
|
||||
if (!ctx->strip) {
|
||||
bcwrite_uleb128(ctx, len);
|
||||
bcwrite_block(ctx, name, len);
|
||||
}
|
||||
ctx->status = ctx->wfunc(ctx->L, ctx->sb.buf, ctx->sb.n, ctx->wdata);
|
||||
}
|
||||
|
||||
/* Write footer of bytecode dump. */
|
||||
static void bcwrite_footer(BCWriteCtx *ctx)
|
||||
{
|
||||
if (ctx->status == 0) {
|
||||
uint8_t zero = 0;
|
||||
ctx->status = ctx->wfunc(ctx->L, &zero, 1, ctx->wdata);
|
||||
}
|
||||
}
|
||||
|
||||
/* Protected callback for bytecode writer. */
|
||||
static TValue *cpwriter(lua_State *L, lua_CFunction dummy, void *ud)
|
||||
{
|
||||
BCWriteCtx *ctx = (BCWriteCtx *)ud;
|
||||
UNUSED(dummy);
|
||||
lj_str_resizebuf(L, &ctx->sb, 1024); /* Avoids resize for most prototypes. */
|
||||
bcwrite_header(ctx);
|
||||
bcwrite_proto(ctx, ctx->pt);
|
||||
bcwrite_footer(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Write bytecode for a prototype. */
|
||||
int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, void *data,
|
||||
int strip)
|
||||
{
|
||||
BCWriteCtx ctx;
|
||||
int status;
|
||||
ctx.L = L;
|
||||
ctx.pt = pt;
|
||||
ctx.wfunc = writer;
|
||||
ctx.wdata = data;
|
||||
ctx.strip = strip;
|
||||
ctx.status = 0;
|
||||
lj_str_initbuf(&ctx.sb);
|
||||
status = lj_vm_cpcall(L, NULL, &ctx, cpwriter);
|
||||
if (status == 0) status = ctx.status;
|
||||
lj_str_freebuf(G(ctx.L), &ctx.sb);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
** C data arithmetic.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_CARITH_H
|
||||
#define _LJ_CARITH_H
|
||||
|
||||
#include "lj_obj.h"
|
||||
|
||||
#if LJ_HASFFI
|
||||
|
||||
LJ_FUNC int lj_carith_op(lua_State *L, MMS mm);
|
||||
|
||||
#if LJ_32 && LJ_HASJIT
|
||||
LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k);
|
||||
#endif
|
||||
LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b);
|
||||
LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b);
|
||||
LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b);
|
||||
LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b);
|
||||
LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k);
|
||||
LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,210 +0,0 @@
|
||||
/* This is a generated file. DO NOT EDIT! */
|
||||
|
||||
FFDEF(assert)
|
||||
FFDEF(type)
|
||||
FFDEF(next)
|
||||
FFDEF(pairs)
|
||||
FFDEF(ipairs_aux)
|
||||
FFDEF(ipairs)
|
||||
FFDEF(getmetatable)
|
||||
FFDEF(setmetatable)
|
||||
FFDEF(getfenv)
|
||||
FFDEF(setfenv)
|
||||
FFDEF(rawget)
|
||||
FFDEF(rawset)
|
||||
FFDEF(rawequal)
|
||||
FFDEF(unpack)
|
||||
FFDEF(select)
|
||||
FFDEF(tonumber)
|
||||
FFDEF(tostring)
|
||||
FFDEF(error)
|
||||
FFDEF(pcall)
|
||||
FFDEF(xpcall)
|
||||
FFDEF(loadfile)
|
||||
FFDEF(load)
|
||||
FFDEF(loadstring)
|
||||
FFDEF(dofile)
|
||||
FFDEF(gcinfo)
|
||||
FFDEF(collectgarbage)
|
||||
FFDEF(newproxy)
|
||||
FFDEF(print)
|
||||
FFDEF(coroutine_status)
|
||||
FFDEF(coroutine_running)
|
||||
FFDEF(coroutine_create)
|
||||
FFDEF(coroutine_yield)
|
||||
FFDEF(coroutine_resume)
|
||||
FFDEF(coroutine_wrap_aux)
|
||||
FFDEF(coroutine_wrap)
|
||||
FFDEF(math_abs)
|
||||
FFDEF(math_floor)
|
||||
FFDEF(math_ceil)
|
||||
FFDEF(math_sqrt)
|
||||
FFDEF(math_log10)
|
||||
FFDEF(math_exp)
|
||||
FFDEF(math_sin)
|
||||
FFDEF(math_cos)
|
||||
FFDEF(math_tan)
|
||||
FFDEF(math_asin)
|
||||
FFDEF(math_acos)
|
||||
FFDEF(math_atan)
|
||||
FFDEF(math_sinh)
|
||||
FFDEF(math_cosh)
|
||||
FFDEF(math_tanh)
|
||||
FFDEF(math_frexp)
|
||||
FFDEF(math_modf)
|
||||
FFDEF(math_log)
|
||||
FFDEF(math_deg)
|
||||
FFDEF(math_rad)
|
||||
FFDEF(math_atan2)
|
||||
FFDEF(math_pow)
|
||||
FFDEF(math_fmod)
|
||||
FFDEF(math_ldexp)
|
||||
FFDEF(math_min)
|
||||
FFDEF(math_max)
|
||||
FFDEF(math_random)
|
||||
FFDEF(math_randomseed)
|
||||
FFDEF(bit_tobit)
|
||||
FFDEF(bit_bnot)
|
||||
FFDEF(bit_bswap)
|
||||
FFDEF(bit_lshift)
|
||||
FFDEF(bit_rshift)
|
||||
FFDEF(bit_arshift)
|
||||
FFDEF(bit_rol)
|
||||
FFDEF(bit_ror)
|
||||
FFDEF(bit_band)
|
||||
FFDEF(bit_bor)
|
||||
FFDEF(bit_bxor)
|
||||
FFDEF(bit_tohex)
|
||||
FFDEF(string_len)
|
||||
FFDEF(string_byte)
|
||||
FFDEF(string_char)
|
||||
FFDEF(string_sub)
|
||||
FFDEF(string_rep)
|
||||
FFDEF(string_reverse)
|
||||
FFDEF(string_lower)
|
||||
FFDEF(string_upper)
|
||||
FFDEF(string_dump)
|
||||
FFDEF(string_find)
|
||||
FFDEF(string_match)
|
||||
FFDEF(string_gmatch_aux)
|
||||
FFDEF(string_gmatch)
|
||||
FFDEF(string_gsub)
|
||||
FFDEF(string_format)
|
||||
FFDEF(table_foreachi)
|
||||
FFDEF(table_foreach)
|
||||
FFDEF(table_getn)
|
||||
FFDEF(table_maxn)
|
||||
FFDEF(table_insert)
|
||||
FFDEF(table_remove)
|
||||
FFDEF(table_concat)
|
||||
FFDEF(table_sort)
|
||||
FFDEF(io_method_close)
|
||||
FFDEF(io_method_read)
|
||||
FFDEF(io_method_write)
|
||||
FFDEF(io_method_flush)
|
||||
FFDEF(io_method_seek)
|
||||
FFDEF(io_method_setvbuf)
|
||||
FFDEF(io_method_lines)
|
||||
FFDEF(io_method___gc)
|
||||
FFDEF(io_method___tostring)
|
||||
FFDEF(io_open)
|
||||
FFDEF(io_popen)
|
||||
FFDEF(io_tmpfile)
|
||||
FFDEF(io_close)
|
||||
FFDEF(io_read)
|
||||
FFDEF(io_write)
|
||||
FFDEF(io_flush)
|
||||
FFDEF(io_input)
|
||||
FFDEF(io_output)
|
||||
FFDEF(io_lines)
|
||||
FFDEF(io_type)
|
||||
FFDEF(os_execute)
|
||||
FFDEF(os_remove)
|
||||
FFDEF(os_rename)
|
||||
FFDEF(os_tmpname)
|
||||
FFDEF(os_getenv)
|
||||
FFDEF(os_exit)
|
||||
FFDEF(os_clock)
|
||||
FFDEF(os_date)
|
||||
FFDEF(os_time)
|
||||
FFDEF(os_difftime)
|
||||
FFDEF(os_setlocale)
|
||||
FFDEF(debug_getregistry)
|
||||
FFDEF(debug_getmetatable)
|
||||
FFDEF(debug_setmetatable)
|
||||
FFDEF(debug_getfenv)
|
||||
FFDEF(debug_setfenv)
|
||||
FFDEF(debug_getinfo)
|
||||
FFDEF(debug_getlocal)
|
||||
FFDEF(debug_setlocal)
|
||||
FFDEF(debug_getupvalue)
|
||||
FFDEF(debug_setupvalue)
|
||||
FFDEF(debug_upvalueid)
|
||||
FFDEF(debug_upvaluejoin)
|
||||
FFDEF(debug_sethook)
|
||||
FFDEF(debug_gethook)
|
||||
FFDEF(debug_debug)
|
||||
FFDEF(debug_traceback)
|
||||
FFDEF(jit_on)
|
||||
FFDEF(jit_off)
|
||||
FFDEF(jit_flush)
|
||||
FFDEF(jit_status)
|
||||
FFDEF(jit_attach)
|
||||
FFDEF(jit_util_funcinfo)
|
||||
FFDEF(jit_util_funcbc)
|
||||
FFDEF(jit_util_funck)
|
||||
FFDEF(jit_util_funcuvname)
|
||||
FFDEF(jit_util_traceinfo)
|
||||
FFDEF(jit_util_traceir)
|
||||
FFDEF(jit_util_tracek)
|
||||
FFDEF(jit_util_tracesnap)
|
||||
FFDEF(jit_util_tracemc)
|
||||
FFDEF(jit_util_traceexitstub)
|
||||
FFDEF(jit_util_ircalladdr)
|
||||
FFDEF(jit_opt_start)
|
||||
FFDEF(ffi_meta___index)
|
||||
FFDEF(ffi_meta___newindex)
|
||||
FFDEF(ffi_meta___eq)
|
||||
FFDEF(ffi_meta___len)
|
||||
FFDEF(ffi_meta___lt)
|
||||
FFDEF(ffi_meta___le)
|
||||
FFDEF(ffi_meta___concat)
|
||||
FFDEF(ffi_meta___call)
|
||||
FFDEF(ffi_meta___add)
|
||||
FFDEF(ffi_meta___sub)
|
||||
FFDEF(ffi_meta___mul)
|
||||
FFDEF(ffi_meta___div)
|
||||
FFDEF(ffi_meta___mod)
|
||||
FFDEF(ffi_meta___pow)
|
||||
FFDEF(ffi_meta___unm)
|
||||
FFDEF(ffi_meta___tostring)
|
||||
FFDEF(ffi_meta___pairs)
|
||||
FFDEF(ffi_meta___ipairs)
|
||||
FFDEF(ffi_clib___index)
|
||||
FFDEF(ffi_clib___newindex)
|
||||
FFDEF(ffi_clib___gc)
|
||||
FFDEF(ffi_callback_free)
|
||||
FFDEF(ffi_callback_set)
|
||||
FFDEF(ffi_cdef)
|
||||
FFDEF(ffi_new)
|
||||
FFDEF(ffi_cast)
|
||||
FFDEF(ffi_typeof)
|
||||
FFDEF(ffi_istype)
|
||||
FFDEF(ffi_sizeof)
|
||||
FFDEF(ffi_alignof)
|
||||
FFDEF(ffi_offsetof)
|
||||
FFDEF(ffi_errno)
|
||||
FFDEF(ffi_string)
|
||||
FFDEF(ffi_copy)
|
||||
FFDEF(ffi_fill)
|
||||
FFDEF(ffi_abi)
|
||||
FFDEF(ffi_metatype)
|
||||
FFDEF(ffi_gc)
|
||||
FFDEF(ffi_load)
|
||||
|
||||
#undef FFDEF
|
||||
|
||||
#ifndef FF_NUM_ASMFUNC
|
||||
#define FF_NUM_ASMFUNC 62
|
||||
#endif
|
||||
|
||||
@@ -1,889 +0,0 @@
|
||||
/*
|
||||
** Fast function call recorder.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_ffrecord_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "lj_obj.h"
|
||||
|
||||
#if LJ_HASJIT
|
||||
|
||||
#include "lj_err.h"
|
||||
#include "lj_str.h"
|
||||
#include "lj_tab.h"
|
||||
#include "lj_frame.h"
|
||||
#include "lj_bc.h"
|
||||
#include "lj_ff.h"
|
||||
#include "lj_ir.h"
|
||||
#include "lj_jit.h"
|
||||
#include "lj_ircall.h"
|
||||
#include "lj_iropt.h"
|
||||
#include "lj_trace.h"
|
||||
#include "lj_record.h"
|
||||
#include "lj_ffrecord.h"
|
||||
#include "lj_crecord.h"
|
||||
#include "lj_dispatch.h"
|
||||
#include "lj_vm.h"
|
||||
#include "lj_strscan.h"
|
||||
|
||||
/* Some local macros to save typing. Undef'd at the end. */
|
||||
#define IR(ref) (&J->cur.ir[(ref)])
|
||||
|
||||
/* Pass IR on to next optimization in chain (FOLD). */
|
||||
#define emitir(ot, a, b) (lj_ir_set(J, (ot), (a), (b)), lj_opt_fold(J))
|
||||
|
||||
/* -- Fast function recording handlers ------------------------------------ */
|
||||
|
||||
/* Conventions for fast function call handlers:
|
||||
**
|
||||
** The argument slots start at J->base[0]. All of them are guaranteed to be
|
||||
** valid and type-specialized references. J->base[J->maxslot] is set to 0
|
||||
** as a sentinel. The runtime argument values start at rd->argv[0].
|
||||
**
|
||||
** In general fast functions should check for presence of all of their
|
||||
** arguments and for the correct argument types. Some simplifications
|
||||
** are allowed if the interpreter throws instead. But even if recording
|
||||
** is aborted, the generated IR must be consistent (no zero-refs).
|
||||
**
|
||||
** The number of results in rd->nres is set to 1. Handlers that return
|
||||
** a different number of results need to override it. A negative value
|
||||
** prevents return processing (e.g. for pending calls).
|
||||
**
|
||||
** Results need to be stored starting at J->base[0]. Return processing
|
||||
** moves them to the right slots later.
|
||||
**
|
||||
** The per-ffid auxiliary data is the value of the 2nd part of the
|
||||
** LJLIB_REC() annotation. This allows handling similar functionality
|
||||
** in a common handler.
|
||||
*/
|
||||
|
||||
/* Type of handler to record a fast function. */
|
||||
typedef void (LJ_FASTCALL *RecordFunc)(jit_State *J, RecordFFData *rd);
|
||||
|
||||
/* Get runtime value of int argument. */
|
||||
static int32_t argv2int(jit_State *J, TValue *o)
|
||||
{
|
||||
if (!lj_strscan_numberobj(o))
|
||||
lj_trace_err(J, LJ_TRERR_BADTYPE);
|
||||
return tvisint(o) ? intV(o) : lj_num2int(numV(o));
|
||||
}
|
||||
|
||||
/* Get runtime value of string argument. */
|
||||
static GCstr *argv2str(jit_State *J, TValue *o)
|
||||
{
|
||||
if (LJ_LIKELY(tvisstr(o))) {
|
||||
return strV(o);
|
||||
} else {
|
||||
GCstr *s;
|
||||
if (!tvisnumber(o))
|
||||
lj_trace_err(J, LJ_TRERR_BADTYPE);
|
||||
if (tvisint(o))
|
||||
s = lj_str_fromint(J->L, intV(o));
|
||||
else
|
||||
s = lj_str_fromnum(J->L, &o->n);
|
||||
setstrV(J->L, o, s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return number of results wanted by caller. */
|
||||
static ptrdiff_t results_wanted(jit_State *J)
|
||||
{
|
||||
TValue *frame = J->L->base-1;
|
||||
if (frame_islua(frame))
|
||||
return (ptrdiff_t)bc_b(frame_pc(frame)[-1]) - 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Throw error for unsupported variant of fast function. */
|
||||
LJ_NORET static void recff_nyiu(jit_State *J)
|
||||
{
|
||||
setfuncV(J->L, &J->errinfo, J->fn);
|
||||
lj_trace_err_info(J, LJ_TRERR_NYIFFU);
|
||||
}
|
||||
|
||||
/* Fallback handler for all fast functions that are not recorded (yet). */
|
||||
static void LJ_FASTCALL recff_nyi(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
setfuncV(J->L, &J->errinfo, J->fn);
|
||||
lj_trace_err_info(J, LJ_TRERR_NYIFF);
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* C functions can have arbitrary side-effects and are not recorded (yet). */
|
||||
static void LJ_FASTCALL recff_c(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
setfuncV(J->L, &J->errinfo, J->fn);
|
||||
lj_trace_err_info(J, LJ_TRERR_NYICF);
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* -- Base library fast functions ----------------------------------------- */
|
||||
|
||||
static void LJ_FASTCALL recff_assert(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
/* Arguments already specialized. The interpreter throws for nil/false. */
|
||||
rd->nres = J->maxslot; /* Pass through all arguments. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_type(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
/* Arguments already specialized. Result is a constant string. Neat, huh? */
|
||||
uint32_t t;
|
||||
if (tvisnumber(&rd->argv[0]))
|
||||
t = ~LJ_TNUMX;
|
||||
else if (LJ_64 && tvislightud(&rd->argv[0]))
|
||||
t = ~LJ_TLIGHTUD;
|
||||
else
|
||||
t = ~itype(&rd->argv[0]);
|
||||
J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[t]));
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_getmetatable(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = J->base[0];
|
||||
if (tr) {
|
||||
RecordIndex ix;
|
||||
ix.tab = tr;
|
||||
copyTV(J->L, &ix.tabv, &rd->argv[0]);
|
||||
if (lj_record_mm_lookup(J, &ix, MM_metatable))
|
||||
J->base[0] = ix.mobj;
|
||||
else
|
||||
J->base[0] = ix.mt;
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_setmetatable(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = J->base[0];
|
||||
TRef mt = J->base[1];
|
||||
if (tref_istab(tr) && (tref_istab(mt) || (mt && tref_isnil(mt)))) {
|
||||
TRef fref, mtref;
|
||||
RecordIndex ix;
|
||||
ix.tab = tr;
|
||||
copyTV(J->L, &ix.tabv, &rd->argv[0]);
|
||||
lj_record_mm_lookup(J, &ix, MM_metatable); /* Guard for no __metatable. */
|
||||
fref = emitir(IRT(IR_FREF, IRT_P32), tr, IRFL_TAB_META);
|
||||
mtref = tref_isnil(mt) ? lj_ir_knull(J, IRT_TAB) : mt;
|
||||
emitir(IRT(IR_FSTORE, IRT_TAB), fref, mtref);
|
||||
if (!tref_isnil(mt))
|
||||
emitir(IRT(IR_TBAR, IRT_TAB), tr, 0);
|
||||
J->base[0] = tr;
|
||||
J->needsnap = 1;
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_rawget(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
RecordIndex ix;
|
||||
ix.tab = J->base[0]; ix.key = J->base[1];
|
||||
if (tref_istab(ix.tab) && ix.key) {
|
||||
ix.val = 0; ix.idxchain = 0;
|
||||
settabV(J->L, &ix.tabv, tabV(&rd->argv[0]));
|
||||
copyTV(J->L, &ix.keyv, &rd->argv[1]);
|
||||
J->base[0] = lj_record_idx(J, &ix);
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_rawset(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
RecordIndex ix;
|
||||
ix.tab = J->base[0]; ix.key = J->base[1]; ix.val = J->base[2];
|
||||
if (tref_istab(ix.tab) && ix.key && ix.val) {
|
||||
ix.idxchain = 0;
|
||||
settabV(J->L, &ix.tabv, tabV(&rd->argv[0]));
|
||||
copyTV(J->L, &ix.keyv, &rd->argv[1]);
|
||||
copyTV(J->L, &ix.valv, &rd->argv[2]);
|
||||
lj_record_idx(J, &ix);
|
||||
/* Pass through table at J->base[0] as result. */
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_rawequal(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tra = J->base[0];
|
||||
TRef trb = J->base[1];
|
||||
if (tra && trb) {
|
||||
int diff = lj_record_objcmp(J, tra, trb, &rd->argv[0], &rd->argv[1]);
|
||||
J->base[0] = diff ? TREF_FALSE : TREF_TRUE;
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
#if LJ_52
|
||||
static void LJ_FASTCALL recff_rawlen(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = J->base[0];
|
||||
if (tref_isstr(tr))
|
||||
J->base[0] = emitir(IRTI(IR_FLOAD), tr, IRFL_STR_LEN);
|
||||
else if (tref_istab(tr))
|
||||
J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, tr);
|
||||
/* else: Interpreter will throw. */
|
||||
UNUSED(rd);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Determine mode of select() call. */
|
||||
int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv)
|
||||
{
|
||||
if (tref_isstr(tr) && *strVdata(tv) == '#') { /* select('#', ...) */
|
||||
if (strV(tv)->len == 1) {
|
||||
emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, strV(tv)));
|
||||
} else {
|
||||
TRef trptr = emitir(IRT(IR_STRREF, IRT_P32), tr, lj_ir_kint(J, 0));
|
||||
TRef trchar = emitir(IRT(IR_XLOAD, IRT_U8), trptr, IRXLOAD_READONLY);
|
||||
emitir(IRTG(IR_EQ, IRT_INT), trchar, lj_ir_kint(J, '#'));
|
||||
}
|
||||
return 0;
|
||||
} else { /* select(n, ...) */
|
||||
int32_t start = argv2int(J, tv);
|
||||
if (start == 0) lj_trace_err(J, LJ_TRERR_BADTYPE); /* A bit misleading. */
|
||||
return start;
|
||||
}
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_select(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = J->base[0];
|
||||
if (tr) {
|
||||
ptrdiff_t start = lj_ffrecord_select_mode(J, tr, &rd->argv[0]);
|
||||
if (start == 0) { /* select('#', ...) */
|
||||
J->base[0] = lj_ir_kint(J, J->maxslot - 1);
|
||||
} else if (tref_isk(tr)) { /* select(k, ...) */
|
||||
ptrdiff_t n = (ptrdiff_t)J->maxslot;
|
||||
if (start < 0) start += n;
|
||||
else if (start > n) start = n;
|
||||
rd->nres = n - start;
|
||||
if (start >= 1) {
|
||||
ptrdiff_t i;
|
||||
for (i = 0; i < n - start; i++)
|
||||
J->base[i] = J->base[start+i];
|
||||
} /* else: Interpreter will throw. */
|
||||
} else {
|
||||
recff_nyiu(J);
|
||||
}
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_tonumber(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = J->base[0];
|
||||
TRef base = J->base[1];
|
||||
if (tr && base) {
|
||||
base = lj_opt_narrow_toint(J, base);
|
||||
if (!tref_isk(base) || IR(tref_ref(base))->i != 10)
|
||||
recff_nyiu(J);
|
||||
}
|
||||
if (tref_isnumber_str(tr)) {
|
||||
if (tref_isstr(tr)) {
|
||||
TValue tmp;
|
||||
if (!lj_strscan_num(strV(&rd->argv[0]), &tmp))
|
||||
recff_nyiu(J); /* Would need an inverted STRTO for this case. */
|
||||
tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0);
|
||||
}
|
||||
#if LJ_HASFFI
|
||||
} else if (tref_iscdata(tr)) {
|
||||
lj_crecord_tonumber(J, rd);
|
||||
return;
|
||||
#endif
|
||||
} else {
|
||||
tr = TREF_NIL;
|
||||
}
|
||||
J->base[0] = tr;
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
static TValue *recff_metacall_cp(lua_State *L, lua_CFunction dummy, void *ud)
|
||||
{
|
||||
jit_State *J = (jit_State *)ud;
|
||||
lj_record_tailcall(J, 0, 1);
|
||||
UNUSED(L); UNUSED(dummy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int recff_metacall(jit_State *J, RecordFFData *rd, MMS mm)
|
||||
{
|
||||
RecordIndex ix;
|
||||
ix.tab = J->base[0];
|
||||
copyTV(J->L, &ix.tabv, &rd->argv[0]);
|
||||
if (lj_record_mm_lookup(J, &ix, mm)) { /* Has metamethod? */
|
||||
int errcode;
|
||||
TValue argv0;
|
||||
/* Temporarily insert metamethod below object. */
|
||||
J->base[1] = J->base[0];
|
||||
J->base[0] = ix.mobj;
|
||||
copyTV(J->L, &argv0, &rd->argv[0]);
|
||||
copyTV(J->L, &rd->argv[1], &rd->argv[0]);
|
||||
copyTV(J->L, &rd->argv[0], &ix.mobjv);
|
||||
/* Need to protect lj_record_tailcall because it may throw. */
|
||||
errcode = lj_vm_cpcall(J->L, NULL, J, recff_metacall_cp);
|
||||
/* Always undo Lua stack changes to avoid confusing the interpreter. */
|
||||
copyTV(J->L, &rd->argv[0], &argv0);
|
||||
if (errcode)
|
||||
lj_err_throw(J->L, errcode); /* Propagate errors. */
|
||||
rd->nres = -1; /* Pending call. */
|
||||
return 1; /* Tailcalled to metamethod. */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_tostring(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = J->base[0];
|
||||
if (tref_isstr(tr)) {
|
||||
/* Ignore __tostring in the string base metatable. */
|
||||
/* Pass on result in J->base[0]. */
|
||||
} else if (!recff_metacall(J, rd, MM_tostring)) {
|
||||
if (tref_isnumber(tr)) {
|
||||
J->base[0] = emitir(IRT(IR_TOSTR, IRT_STR), tr, 0);
|
||||
} else if (tref_ispri(tr)) {
|
||||
J->base[0] = lj_ir_kstr(J, strV(&J->fn->c.upvalue[tref_type(tr)]));
|
||||
} else {
|
||||
recff_nyiu(J);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_ipairs_aux(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
RecordIndex ix;
|
||||
ix.tab = J->base[0];
|
||||
if (tref_istab(ix.tab)) {
|
||||
if (!tvisnumber(&rd->argv[1])) /* No support for string coercion. */
|
||||
lj_trace_err(J, LJ_TRERR_BADTYPE);
|
||||
setintV(&ix.keyv, numberVint(&rd->argv[1])+1);
|
||||
settabV(J->L, &ix.tabv, tabV(&rd->argv[0]));
|
||||
ix.val = 0; ix.idxchain = 0;
|
||||
ix.key = lj_opt_narrow_toint(J, J->base[1]);
|
||||
J->base[0] = ix.key = emitir(IRTI(IR_ADD), ix.key, lj_ir_kint(J, 1));
|
||||
J->base[1] = lj_record_idx(J, &ix);
|
||||
rd->nres = tref_isnil(J->base[1]) ? 0 : 2;
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_ipairs(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
if (!(LJ_52 && recff_metacall(J, rd, MM_ipairs))) {
|
||||
TRef tab = J->base[0];
|
||||
if (tref_istab(tab)) {
|
||||
J->base[0] = lj_ir_kfunc(J, funcV(&J->fn->c.upvalue[0]));
|
||||
J->base[1] = tab;
|
||||
J->base[2] = lj_ir_kint(J, 0);
|
||||
rd->nres = 3;
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_pcall(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
if (J->maxslot >= 1) {
|
||||
lj_record_call(J, 0, J->maxslot - 1);
|
||||
rd->nres = -1; /* Pending call. */
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static TValue *recff_xpcall_cp(lua_State *L, lua_CFunction dummy, void *ud)
|
||||
{
|
||||
jit_State *J = (jit_State *)ud;
|
||||
lj_record_call(J, 1, J->maxslot - 2);
|
||||
UNUSED(L); UNUSED(dummy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_xpcall(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
if (J->maxslot >= 2) {
|
||||
TValue argv0, argv1;
|
||||
TRef tmp;
|
||||
int errcode;
|
||||
/* Swap function and traceback. */
|
||||
tmp = J->base[0]; J->base[0] = J->base[1]; J->base[1] = tmp;
|
||||
copyTV(J->L, &argv0, &rd->argv[0]);
|
||||
copyTV(J->L, &argv1, &rd->argv[1]);
|
||||
copyTV(J->L, &rd->argv[0], &argv1);
|
||||
copyTV(J->L, &rd->argv[1], &argv0);
|
||||
/* Need to protect lj_record_call because it may throw. */
|
||||
errcode = lj_vm_cpcall(J->L, NULL, J, recff_xpcall_cp);
|
||||
/* Always undo Lua stack swap to avoid confusing the interpreter. */
|
||||
copyTV(J->L, &rd->argv[0], &argv0);
|
||||
copyTV(J->L, &rd->argv[1], &argv1);
|
||||
if (errcode)
|
||||
lj_err_throw(J->L, errcode); /* Propagate errors. */
|
||||
rd->nres = -1; /* Pending call. */
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
/* -- Math library fast functions ----------------------------------------- */
|
||||
|
||||
static void LJ_FASTCALL recff_math_abs(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
J->base[0] = emitir(IRTN(IR_ABS), tr, lj_ir_knum_abs(J));
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* Record rounding functions math.floor and math.ceil. */
|
||||
static void LJ_FASTCALL recff_math_round(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = J->base[0];
|
||||
if (!tref_isinteger(tr)) { /* Pass through integers unmodified. */
|
||||
tr = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, tr), rd->data);
|
||||
/* Result is integral (or NaN/Inf), but may not fit an int32_t. */
|
||||
if (LJ_DUALNUM) { /* Try to narrow using a guarded conversion to int. */
|
||||
lua_Number n = lj_vm_foldfpm(numberVnum(&rd->argv[0]), rd->data);
|
||||
if (n == (lua_Number)lj_num2int(n))
|
||||
tr = emitir(IRTGI(IR_CONV), tr, IRCONV_INT_NUM|IRCONV_CHECK);
|
||||
}
|
||||
J->base[0] = tr;
|
||||
}
|
||||
}
|
||||
|
||||
/* Record unary math.* functions, mapped to IR_FPMATH opcode. */
|
||||
static void LJ_FASTCALL recff_math_unary(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
J->base[0] = emitir(IRTN(IR_FPMATH), lj_ir_tonum(J, J->base[0]), rd->data);
|
||||
}
|
||||
|
||||
/* Record math.log. */
|
||||
static void LJ_FASTCALL recff_math_log(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
if (J->base[1]) {
|
||||
#ifdef LUAJIT_NO_LOG2
|
||||
uint32_t fpm = IRFPM_LOG;
|
||||
#else
|
||||
uint32_t fpm = IRFPM_LOG2;
|
||||
#endif
|
||||
TRef trb = lj_ir_tonum(J, J->base[1]);
|
||||
tr = emitir(IRTN(IR_FPMATH), tr, fpm);
|
||||
trb = emitir(IRTN(IR_FPMATH), trb, fpm);
|
||||
trb = emitir(IRTN(IR_DIV), lj_ir_knum_one(J), trb);
|
||||
tr = emitir(IRTN(IR_MUL), tr, trb);
|
||||
} else {
|
||||
tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_LOG);
|
||||
}
|
||||
J->base[0] = tr;
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* Record math.atan2. */
|
||||
static void LJ_FASTCALL recff_math_atan2(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
TRef tr2 = lj_ir_tonum(J, J->base[1]);
|
||||
J->base[0] = emitir(IRTN(IR_ATAN2), tr, tr2);
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* Record math.ldexp. */
|
||||
static void LJ_FASTCALL recff_math_ldexp(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
#if LJ_TARGET_X86ORX64
|
||||
TRef tr2 = lj_ir_tonum(J, J->base[1]);
|
||||
#else
|
||||
TRef tr2 = lj_opt_narrow_toint(J, J->base[1]);
|
||||
#endif
|
||||
J->base[0] = emitir(IRTN(IR_LDEXP), tr, tr2);
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* Record math.asin, math.acos, math.atan. */
|
||||
static void LJ_FASTCALL recff_math_atrig(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef y = lj_ir_tonum(J, J->base[0]);
|
||||
TRef x = lj_ir_knum_one(J);
|
||||
uint32_t ffid = rd->data;
|
||||
if (ffid != FF_math_atan) {
|
||||
TRef tmp = emitir(IRTN(IR_MUL), y, y);
|
||||
tmp = emitir(IRTN(IR_SUB), x, tmp);
|
||||
tmp = emitir(IRTN(IR_FPMATH), tmp, IRFPM_SQRT);
|
||||
if (ffid == FF_math_asin) { x = tmp; } else { x = y; y = tmp; }
|
||||
}
|
||||
J->base[0] = emitir(IRTN(IR_ATAN2), y, x);
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_math_htrig(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
J->base[0] = emitir(IRTN(IR_CALLN), tr, rd->data);
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_math_modf(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = J->base[0];
|
||||
if (tref_isinteger(tr)) {
|
||||
J->base[0] = tr;
|
||||
J->base[1] = lj_ir_kint(J, 0);
|
||||
} else {
|
||||
TRef trt;
|
||||
tr = lj_ir_tonum(J, tr);
|
||||
trt = emitir(IRTN(IR_FPMATH), tr, IRFPM_TRUNC);
|
||||
J->base[0] = trt;
|
||||
J->base[1] = emitir(IRTN(IR_SUB), tr, trt);
|
||||
}
|
||||
rd->nres = 2;
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_math_degrad(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
TRef trm = lj_ir_knum(J, numV(&J->fn->c.upvalue[0]));
|
||||
J->base[0] = emitir(IRTN(IR_MUL), tr, trm);
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
if (!tref_isnumber_str(J->base[1]))
|
||||
lj_trace_err(J, LJ_TRERR_BADTYPE);
|
||||
J->base[0] = lj_opt_narrow_pow(J, tr, J->base[1], &rd->argv[1]);
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_math_minmax(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonumber(J, J->base[0]);
|
||||
uint32_t op = rd->data;
|
||||
BCReg i;
|
||||
for (i = 1; J->base[i] != 0; i++) {
|
||||
TRef tr2 = lj_ir_tonumber(J, J->base[i]);
|
||||
IRType t = IRT_INT;
|
||||
if (!(tref_isinteger(tr) && tref_isinteger(tr2))) {
|
||||
if (tref_isinteger(tr)) tr = emitir(IRTN(IR_CONV), tr, IRCONV_NUM_INT);
|
||||
if (tref_isinteger(tr2)) tr2 = emitir(IRTN(IR_CONV), tr2, IRCONV_NUM_INT);
|
||||
t = IRT_NUM;
|
||||
}
|
||||
tr = emitir(IRT(op, t), tr, tr2);
|
||||
}
|
||||
J->base[0] = tr;
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_math_random(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
GCudata *ud = udataV(&J->fn->c.upvalue[0]);
|
||||
TRef tr, one;
|
||||
lj_ir_kgc(J, obj2gco(ud), IRT_UDATA); /* Prevent collection. */
|
||||
tr = lj_ir_call(J, IRCALL_lj_math_random_step, lj_ir_kptr(J, uddata(ud)));
|
||||
one = lj_ir_knum_one(J);
|
||||
tr = emitir(IRTN(IR_SUB), tr, one);
|
||||
if (J->base[0]) {
|
||||
TRef tr1 = lj_ir_tonum(J, J->base[0]);
|
||||
if (J->base[1]) { /* d = floor(d*(r2-r1+1.0)) + r1 */
|
||||
TRef tr2 = lj_ir_tonum(J, J->base[1]);
|
||||
tr2 = emitir(IRTN(IR_SUB), tr2, tr1);
|
||||
tr2 = emitir(IRTN(IR_ADD), tr2, one);
|
||||
tr = emitir(IRTN(IR_MUL), tr, tr2);
|
||||
tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR);
|
||||
tr = emitir(IRTN(IR_ADD), tr, tr1);
|
||||
} else { /* d = floor(d*r1) + 1.0 */
|
||||
tr = emitir(IRTN(IR_MUL), tr, tr1);
|
||||
tr = emitir(IRTN(IR_FPMATH), tr, IRFPM_FLOOR);
|
||||
tr = emitir(IRTN(IR_ADD), tr, one);
|
||||
}
|
||||
}
|
||||
J->base[0] = tr;
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* -- Bit library fast functions ------------------------------------------ */
|
||||
|
||||
/* Record unary bit.tobit, bit.bnot, bit.bswap. */
|
||||
static void LJ_FASTCALL recff_bit_unary(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_opt_narrow_tobit(J, J->base[0]);
|
||||
J->base[0] = (rd->data == IR_TOBIT) ? tr : emitir(IRTI(rd->data), tr, 0);
|
||||
}
|
||||
|
||||
/* Record N-ary bit.band, bit.bor, bit.bxor. */
|
||||
static void LJ_FASTCALL recff_bit_nary(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_opt_narrow_tobit(J, J->base[0]);
|
||||
uint32_t op = rd->data;
|
||||
BCReg i;
|
||||
for (i = 1; J->base[i] != 0; i++)
|
||||
tr = emitir(IRTI(op), tr, lj_opt_narrow_tobit(J, J->base[i]));
|
||||
J->base[0] = tr;
|
||||
}
|
||||
|
||||
/* Record bit shifts. */
|
||||
static void LJ_FASTCALL recff_bit_shift(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_opt_narrow_tobit(J, J->base[0]);
|
||||
TRef tsh = lj_opt_narrow_tobit(J, J->base[1]);
|
||||
IROp op = (IROp)rd->data;
|
||||
if (!(op < IR_BROL ? LJ_TARGET_MASKSHIFT : LJ_TARGET_MASKROT) &&
|
||||
!tref_isk(tsh))
|
||||
tsh = emitir(IRTI(IR_BAND), tsh, lj_ir_kint(J, 31));
|
||||
#ifdef LJ_TARGET_UNIFYROT
|
||||
if (op == (LJ_TARGET_UNIFYROT == 1 ? IR_BROR : IR_BROL)) {
|
||||
op = LJ_TARGET_UNIFYROT == 1 ? IR_BROL : IR_BROR;
|
||||
tsh = emitir(IRTI(IR_NEG), tsh, tsh);
|
||||
}
|
||||
#endif
|
||||
J->base[0] = emitir(IRTI(op), tr, tsh);
|
||||
}
|
||||
|
||||
/* -- String library fast functions --------------------------------------- */
|
||||
|
||||
static void LJ_FASTCALL recff_string_len(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
J->base[0] = emitir(IRTI(IR_FLOAD), lj_ir_tostr(J, J->base[0]), IRFL_STR_LEN);
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* Handle string.byte (rd->data = 0) and string.sub (rd->data = 1). */
|
||||
static void LJ_FASTCALL recff_string_range(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef trstr = lj_ir_tostr(J, J->base[0]);
|
||||
TRef trlen = emitir(IRTI(IR_FLOAD), trstr, IRFL_STR_LEN);
|
||||
TRef tr0 = lj_ir_kint(J, 0);
|
||||
TRef trstart, trend;
|
||||
GCstr *str = argv2str(J, &rd->argv[0]);
|
||||
int32_t start, end;
|
||||
if (rd->data) { /* string.sub(str, start [,end]) */
|
||||
start = argv2int(J, &rd->argv[1]);
|
||||
trstart = lj_opt_narrow_toint(J, J->base[1]);
|
||||
trend = J->base[2];
|
||||
if (tref_isnil(trend)) {
|
||||
trend = lj_ir_kint(J, -1);
|
||||
end = -1;
|
||||
} else {
|
||||
trend = lj_opt_narrow_toint(J, trend);
|
||||
end = argv2int(J, &rd->argv[2]);
|
||||
}
|
||||
} else { /* string.byte(str, [,start [,end]]) */
|
||||
if (J->base[1]) {
|
||||
start = argv2int(J, &rd->argv[1]);
|
||||
trstart = lj_opt_narrow_toint(J, J->base[1]);
|
||||
trend = J->base[2];
|
||||
if (tref_isnil(trend)) {
|
||||
trend = trstart;
|
||||
end = start;
|
||||
} else {
|
||||
trend = lj_opt_narrow_toint(J, trend);
|
||||
end = argv2int(J, &rd->argv[2]);
|
||||
}
|
||||
} else {
|
||||
trend = trstart = lj_ir_kint(J, 1);
|
||||
end = start = 1;
|
||||
}
|
||||
}
|
||||
if (end < 0) {
|
||||
emitir(IRTGI(IR_LT), trend, tr0);
|
||||
trend = emitir(IRTI(IR_ADD), emitir(IRTI(IR_ADD), trlen, trend),
|
||||
lj_ir_kint(J, 1));
|
||||
end = end+(int32_t)str->len+1;
|
||||
} else if ((MSize)end <= str->len) {
|
||||
emitir(IRTGI(IR_ULE), trend, trlen);
|
||||
} else {
|
||||
emitir(IRTGI(IR_GT), trend, trlen);
|
||||
end = (int32_t)str->len;
|
||||
trend = trlen;
|
||||
}
|
||||
if (start < 0) {
|
||||
emitir(IRTGI(IR_LT), trstart, tr0);
|
||||
trstart = emitir(IRTI(IR_ADD), trlen, trstart);
|
||||
start = start+(int32_t)str->len;
|
||||
emitir(start < 0 ? IRTGI(IR_LT) : IRTGI(IR_GE), trstart, tr0);
|
||||
if (start < 0) {
|
||||
trstart = tr0;
|
||||
start = 0;
|
||||
}
|
||||
} else {
|
||||
if (start == 0) {
|
||||
emitir(IRTGI(IR_EQ), trstart, tr0);
|
||||
trstart = tr0;
|
||||
} else {
|
||||
trstart = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, -1));
|
||||
emitir(IRTGI(IR_GE), trstart, tr0);
|
||||
start--;
|
||||
}
|
||||
}
|
||||
if (rd->data) { /* Return string.sub result. */
|
||||
if (end - start >= 0) {
|
||||
/* Also handle empty range here, to avoid extra traces. */
|
||||
TRef trptr, trslen = emitir(IRTI(IR_SUB), trend, trstart);
|
||||
emitir(IRTGI(IR_GE), trslen, tr0);
|
||||
trptr = emitir(IRT(IR_STRREF, IRT_P32), trstr, trstart);
|
||||
J->base[0] = emitir(IRT(IR_SNEW, IRT_STR), trptr, trslen);
|
||||
} else { /* Range underflow: return empty string. */
|
||||
emitir(IRTGI(IR_LT), trend, trstart);
|
||||
J->base[0] = lj_ir_kstr(J, lj_str_new(J->L, strdata(str), 0));
|
||||
}
|
||||
} else { /* Return string.byte result(s). */
|
||||
ptrdiff_t i, len = end - start;
|
||||
if (len > 0) {
|
||||
TRef trslen = emitir(IRTI(IR_SUB), trend, trstart);
|
||||
emitir(IRTGI(IR_EQ), trslen, lj_ir_kint(J, (int32_t)len));
|
||||
if (J->baseslot + len > LJ_MAX_JSLOTS)
|
||||
lj_trace_err_info(J, LJ_TRERR_STACKOV);
|
||||
rd->nres = len;
|
||||
for (i = 0; i < len; i++) {
|
||||
TRef tmp = emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, (int32_t)i));
|
||||
tmp = emitir(IRT(IR_STRREF, IRT_P32), trstr, tmp);
|
||||
J->base[i] = emitir(IRT(IR_XLOAD, IRT_U8), tmp, IRXLOAD_READONLY);
|
||||
}
|
||||
} else { /* Empty range or range underflow: return no results. */
|
||||
emitir(IRTGI(IR_LE), trend, trstart);
|
||||
rd->nres = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -- Table library fast functions ---------------------------------------- */
|
||||
|
||||
static void LJ_FASTCALL recff_table_getn(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
if (tref_istab(J->base[0]))
|
||||
J->base[0] = lj_ir_call(J, IRCALL_lj_tab_len, J->base[0]);
|
||||
/* else: Interpreter will throw. */
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_table_remove(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tab = J->base[0];
|
||||
rd->nres = 0;
|
||||
if (tref_istab(tab)) {
|
||||
if (!J->base[1] || tref_isnil(J->base[1])) { /* Simple pop: t[#t] = nil */
|
||||
TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, tab);
|
||||
GCtab *t = tabV(&rd->argv[0]);
|
||||
MSize len = lj_tab_len(t);
|
||||
emitir(IRTGI(len ? IR_NE : IR_EQ), trlen, lj_ir_kint(J, 0));
|
||||
if (len) {
|
||||
RecordIndex ix;
|
||||
ix.tab = tab;
|
||||
ix.key = trlen;
|
||||
settabV(J->L, &ix.tabv, t);
|
||||
setintV(&ix.keyv, len);
|
||||
ix.idxchain = 0;
|
||||
if (results_wanted(J) != 0) { /* Specialize load only if needed. */
|
||||
ix.val = 0;
|
||||
J->base[0] = lj_record_idx(J, &ix); /* Load previous value. */
|
||||
rd->nres = 1;
|
||||
/* Assumes ix.key/ix.tab is not modified for raw lj_record_idx(). */
|
||||
}
|
||||
ix.val = TREF_NIL;
|
||||
lj_record_idx(J, &ix); /* Remove value. */
|
||||
}
|
||||
} else { /* Complex case: remove in the middle. */
|
||||
recff_nyiu(J);
|
||||
}
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_table_insert(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
RecordIndex ix;
|
||||
ix.tab = J->base[0];
|
||||
ix.val = J->base[1];
|
||||
rd->nres = 0;
|
||||
if (tref_istab(ix.tab) && ix.val) {
|
||||
if (!J->base[2]) { /* Simple push: t[#t+1] = v */
|
||||
TRef trlen = lj_ir_call(J, IRCALL_lj_tab_len, ix.tab);
|
||||
GCtab *t = tabV(&rd->argv[0]);
|
||||
ix.key = emitir(IRTI(IR_ADD), trlen, lj_ir_kint(J, 1));
|
||||
settabV(J->L, &ix.tabv, t);
|
||||
setintV(&ix.keyv, lj_tab_len(t) + 1);
|
||||
ix.idxchain = 0;
|
||||
lj_record_idx(J, &ix); /* Set new value. */
|
||||
} else { /* Complex case: insert in the middle. */
|
||||
recff_nyiu(J);
|
||||
}
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
/* -- I/O library fast functions ------------------------------------------ */
|
||||
|
||||
/* Get FILE* for I/O function. Any I/O error aborts recording, so there's
|
||||
** no need to encode the alternate cases for any of the guards.
|
||||
*/
|
||||
static TRef recff_io_fp(jit_State *J, TRef *udp, int32_t id)
|
||||
{
|
||||
TRef tr, ud, fp;
|
||||
if (id) { /* io.func() */
|
||||
tr = lj_ir_kptr(J, &J2G(J)->gcroot[id]);
|
||||
ud = emitir(IRT(IR_XLOAD, IRT_UDATA), tr, 0);
|
||||
} else { /* fp:method() */
|
||||
ud = J->base[0];
|
||||
if (!tref_isudata(ud))
|
||||
lj_trace_err(J, LJ_TRERR_BADTYPE);
|
||||
tr = emitir(IRT(IR_FLOAD, IRT_U8), ud, IRFL_UDATA_UDTYPE);
|
||||
emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE));
|
||||
}
|
||||
*udp = ud;
|
||||
fp = emitir(IRT(IR_FLOAD, IRT_PTR), ud, IRFL_UDATA_FILE);
|
||||
emitir(IRTG(IR_NE, IRT_PTR), fp, lj_ir_knull(J, IRT_PTR));
|
||||
return fp;
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_io_write(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef ud, fp = recff_io_fp(J, &ud, rd->data);
|
||||
TRef zero = lj_ir_kint(J, 0);
|
||||
TRef one = lj_ir_kint(J, 1);
|
||||
ptrdiff_t i = rd->data == 0 ? 1 : 0;
|
||||
for (; J->base[i]; i++) {
|
||||
TRef str = lj_ir_tostr(J, J->base[i]);
|
||||
TRef buf = emitir(IRT(IR_STRREF, IRT_P32), str, zero);
|
||||
TRef len = emitir(IRTI(IR_FLOAD), str, IRFL_STR_LEN);
|
||||
if (tref_isk(len) && IR(tref_ref(len))->i == 1) {
|
||||
TRef tr = emitir(IRT(IR_XLOAD, IRT_U8), buf, IRXLOAD_READONLY);
|
||||
tr = lj_ir_call(J, IRCALL_fputc, tr, fp);
|
||||
if (results_wanted(J) != 0) /* Check result only if not ignored. */
|
||||
emitir(IRTGI(IR_NE), tr, lj_ir_kint(J, -1));
|
||||
} else {
|
||||
TRef tr = lj_ir_call(J, IRCALL_fwrite, buf, one, len, fp);
|
||||
if (results_wanted(J) != 0) /* Check result only if not ignored. */
|
||||
emitir(IRTGI(IR_EQ), tr, len);
|
||||
}
|
||||
}
|
||||
J->base[0] = LJ_52 ? ud : TREF_TRUE;
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_io_flush(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef ud, fp = recff_io_fp(J, &ud, rd->data);
|
||||
TRef tr = lj_ir_call(J, IRCALL_fflush, fp);
|
||||
if (results_wanted(J) != 0) /* Check result only if not ignored. */
|
||||
emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0));
|
||||
J->base[0] = TREF_TRUE;
|
||||
}
|
||||
|
||||
/* -- Record calls to fast functions -------------------------------------- */
|
||||
|
||||
#include "lj_recdef.h"
|
||||
|
||||
static uint32_t recdef_lookup(GCfunc *fn)
|
||||
{
|
||||
if (fn->c.ffid < sizeof(recff_idmap)/sizeof(recff_idmap[0]))
|
||||
return recff_idmap[fn->c.ffid];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Record entry to a fast function or C function. */
|
||||
void lj_ffrecord_func(jit_State *J)
|
||||
{
|
||||
RecordFFData rd;
|
||||
uint32_t m = recdef_lookup(J->fn);
|
||||
rd.data = m & 0xff;
|
||||
rd.nres = 1; /* Default is one result. */
|
||||
rd.argv = J->L->base;
|
||||
J->base[J->maxslot] = 0; /* Mark end of arguments. */
|
||||
(recff_func[m >> 8])(J, &rd); /* Call recff_* handler. */
|
||||
if (rd.nres >= 0) {
|
||||
if (J->postproc == LJ_POST_NONE) J->postproc = LJ_POST_FFRETRY;
|
||||
lj_record_ret(J, 0, rd.nres);
|
||||
}
|
||||
}
|
||||
|
||||
#undef IR
|
||||
#undef emitir
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
** Stack frames.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_FRAME_H
|
||||
#define _LJ_FRAME_H
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_bc.h"
|
||||
|
||||
/* -- Lua stack frame ----------------------------------------------------- */
|
||||
|
||||
/* Frame type markers in callee function slot (callee base-1). */
|
||||
enum {
|
||||
FRAME_LUA, FRAME_C, FRAME_CONT, FRAME_VARG,
|
||||
FRAME_LUAP, FRAME_CP, FRAME_PCALL, FRAME_PCALLH
|
||||
};
|
||||
#define FRAME_TYPE 3
|
||||
#define FRAME_P 4
|
||||
#define FRAME_TYPEP (FRAME_TYPE|FRAME_P)
|
||||
|
||||
/* Macros to access and modify Lua frames. */
|
||||
#define frame_gc(f) (gcref((f)->fr.func))
|
||||
#define frame_func(f) (&frame_gc(f)->fn)
|
||||
#define frame_ftsz(f) ((f)->fr.tp.ftsz)
|
||||
|
||||
#define frame_type(f) (frame_ftsz(f) & FRAME_TYPE)
|
||||
#define frame_typep(f) (frame_ftsz(f) & FRAME_TYPEP)
|
||||
#define frame_islua(f) (frame_type(f) == FRAME_LUA)
|
||||
#define frame_isc(f) (frame_type(f) == FRAME_C)
|
||||
#define frame_iscont(f) (frame_typep(f) == FRAME_CONT)
|
||||
#define frame_isvarg(f) (frame_typep(f) == FRAME_VARG)
|
||||
#define frame_ispcall(f) ((frame_ftsz(f) & 6) == FRAME_PCALL)
|
||||
|
||||
#define frame_pc(f) (mref((f)->fr.tp.pcr, const BCIns))
|
||||
#define frame_contpc(f) (frame_pc((f)-1))
|
||||
#if LJ_64
|
||||
#define frame_contf(f) \
|
||||
((ASMFunction)(void *)((intptr_t)lj_vm_asm_begin + \
|
||||
(intptr_t)(int32_t)((f)-1)->u32.lo))
|
||||
#else
|
||||
#define frame_contf(f) ((ASMFunction)gcrefp(((f)-1)->gcr, void))
|
||||
#endif
|
||||
#define frame_delta(f) (frame_ftsz(f) >> 3)
|
||||
#define frame_sized(f) (frame_ftsz(f) & ~FRAME_TYPEP)
|
||||
|
||||
#define frame_prevl(f) ((f) - (1+bc_a(frame_pc(f)[-1])))
|
||||
#define frame_prevd(f) ((TValue *)((char *)(f) - frame_sized(f)))
|
||||
#define frame_prev(f) (frame_islua(f)?frame_prevl(f):frame_prevd(f))
|
||||
/* Note: this macro does not skip over FRAME_VARG. */
|
||||
|
||||
#define setframe_pc(f, pc) (setmref((f)->fr.tp.pcr, (pc)))
|
||||
#define setframe_ftsz(f, sz) ((f)->fr.tp.ftsz = (sz))
|
||||
#define setframe_gc(f, p) (setgcref((f)->fr.func, (p)))
|
||||
|
||||
/* -- C stack frame ------------------------------------------------------- */
|
||||
|
||||
/* Macros to access and modify the C stack frame chain. */
|
||||
|
||||
/* These definitions must match with the arch-specific *.dasc files. */
|
||||
#if LJ_TARGET_X86
|
||||
#define CFRAME_OFS_ERRF (15*4)
|
||||
#define CFRAME_OFS_NRES (14*4)
|
||||
#define CFRAME_OFS_PREV (13*4)
|
||||
#define CFRAME_OFS_L (12*4)
|
||||
#define CFRAME_OFS_PC (6*4)
|
||||
#define CFRAME_OFS_MULTRES (5*4)
|
||||
#define CFRAME_SIZE (12*4)
|
||||
#define CFRAME_SHIFT_MULTRES 0
|
||||
#elif LJ_TARGET_X64
|
||||
#if LJ_ABI_WIN
|
||||
#define CFRAME_OFS_PREV (13*8)
|
||||
#define CFRAME_OFS_PC (25*4)
|
||||
#define CFRAME_OFS_L (24*4)
|
||||
#define CFRAME_OFS_ERRF (23*4)
|
||||
#define CFRAME_OFS_NRES (22*4)
|
||||
#define CFRAME_OFS_MULTRES (21*4)
|
||||
#define CFRAME_SIZE (10*8)
|
||||
#define CFRAME_SIZE_JIT (CFRAME_SIZE + 9*16 + 4*8)
|
||||
#define CFRAME_SHIFT_MULTRES 0
|
||||
#else
|
||||
#define CFRAME_OFS_PREV (4*8)
|
||||
#define CFRAME_OFS_PC (7*4)
|
||||
#define CFRAME_OFS_L (6*4)
|
||||
#define CFRAME_OFS_ERRF (5*4)
|
||||
#define CFRAME_OFS_NRES (4*4)
|
||||
#define CFRAME_OFS_MULTRES (1*4)
|
||||
#define CFRAME_SIZE (10*8)
|
||||
#define CFRAME_SIZE_JIT (CFRAME_SIZE + 16)
|
||||
#define CFRAME_SHIFT_MULTRES 0
|
||||
#endif
|
||||
#elif LJ_TARGET_ARM
|
||||
#define CFRAME_OFS_ERRF 24
|
||||
#define CFRAME_OFS_NRES 20
|
||||
#define CFRAME_OFS_PREV 16
|
||||
#define CFRAME_OFS_L 12
|
||||
#define CFRAME_OFS_PC 8
|
||||
#define CFRAME_OFS_MULTRES 4
|
||||
#if LJ_ARCH_HASFPU
|
||||
#define CFRAME_SIZE 128
|
||||
#else
|
||||
#define CFRAME_SIZE 64
|
||||
#endif
|
||||
#define CFRAME_SHIFT_MULTRES 3
|
||||
#elif LJ_TARGET_PPC
|
||||
#if LJ_TARGET_XBOX360
|
||||
#define CFRAME_OFS_ERRF 424
|
||||
#define CFRAME_OFS_NRES 420
|
||||
#define CFRAME_OFS_PREV 400
|
||||
#define CFRAME_OFS_L 416
|
||||
#define CFRAME_OFS_PC 412
|
||||
#define CFRAME_OFS_MULTRES 408
|
||||
#define CFRAME_SIZE 384
|
||||
#define CFRAME_SHIFT_MULTRES 3
|
||||
#elif LJ_ARCH_PPC64
|
||||
#define CFRAME_OFS_ERRF 472
|
||||
#define CFRAME_OFS_NRES 468
|
||||
#define CFRAME_OFS_PREV 448
|
||||
#define CFRAME_OFS_L 464
|
||||
#define CFRAME_OFS_PC 460
|
||||
#define CFRAME_OFS_MULTRES 456
|
||||
#define CFRAME_SIZE 400
|
||||
#define CFRAME_SHIFT_MULTRES 3
|
||||
#else
|
||||
#define CFRAME_OFS_ERRF 48
|
||||
#define CFRAME_OFS_NRES 44
|
||||
#define CFRAME_OFS_PREV 40
|
||||
#define CFRAME_OFS_L 36
|
||||
#define CFRAME_OFS_PC 32
|
||||
#define CFRAME_OFS_MULTRES 28
|
||||
#define CFRAME_SIZE 272
|
||||
#define CFRAME_SHIFT_MULTRES 3
|
||||
#endif
|
||||
#elif LJ_TARGET_PPCSPE
|
||||
#define CFRAME_OFS_ERRF 28
|
||||
#define CFRAME_OFS_NRES 24
|
||||
#define CFRAME_OFS_PREV 20
|
||||
#define CFRAME_OFS_L 16
|
||||
#define CFRAME_OFS_PC 12
|
||||
#define CFRAME_OFS_MULTRES 8
|
||||
#define CFRAME_SIZE 184
|
||||
#define CFRAME_SHIFT_MULTRES 3
|
||||
#elif LJ_TARGET_MIPS
|
||||
#define CFRAME_OFS_ERRF 124
|
||||
#define CFRAME_OFS_NRES 120
|
||||
#define CFRAME_OFS_PREV 116
|
||||
#define CFRAME_OFS_L 112
|
||||
#define CFRAME_OFS_PC 20
|
||||
#define CFRAME_OFS_MULTRES 16
|
||||
#define CFRAME_SIZE 112
|
||||
#define CFRAME_SHIFT_MULTRES 3
|
||||
#else
|
||||
#error "Missing CFRAME_* definitions for this architecture"
|
||||
#endif
|
||||
|
||||
#ifndef CFRAME_SIZE_JIT
|
||||
#define CFRAME_SIZE_JIT CFRAME_SIZE
|
||||
#endif
|
||||
|
||||
#define CFRAME_RESUME 1
|
||||
#define CFRAME_UNWIND_FF 2 /* Only used in unwinder. */
|
||||
#define CFRAME_RAWMASK (~(intptr_t)(CFRAME_RESUME|CFRAME_UNWIND_FF))
|
||||
|
||||
#define cframe_errfunc(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_ERRF))
|
||||
#define cframe_nres(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_NRES))
|
||||
#define cframe_prev(cf) (*(void **)(((char *)(cf))+CFRAME_OFS_PREV))
|
||||
#define cframe_multres(cf) (*(uint32_t *)(((char *)(cf))+CFRAME_OFS_MULTRES))
|
||||
#define cframe_multres_n(cf) (cframe_multres((cf)) >> CFRAME_SHIFT_MULTRES)
|
||||
#define cframe_L(cf) \
|
||||
(&gcref(*(GCRef *)(((char *)(cf))+CFRAME_OFS_L))->th)
|
||||
#define cframe_pc(cf) \
|
||||
(mref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), const BCIns))
|
||||
#define setcframe_L(cf, L) \
|
||||
(setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_L), (L)))
|
||||
#define setcframe_pc(cf, pc) \
|
||||
(setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), (pc)))
|
||||
#define cframe_canyield(cf) ((intptr_t)(cf) & CFRAME_RESUME)
|
||||
#define cframe_unwind_ff(cf) ((intptr_t)(cf) & CFRAME_UNWIND_FF)
|
||||
#define cframe_raw(cf) ((void *)((intptr_t)(cf) & CFRAME_RAWMASK))
|
||||
#define cframe_Lpc(L) cframe_pc(cframe_raw(L->cframe))
|
||||
|
||||
#endif
|
||||
@@ -1,271 +0,0 @@
|
||||
/*
|
||||
** IR CALL* instruction definitions.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_IRCALL_H
|
||||
#define _LJ_IRCALL_H
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_ir.h"
|
||||
#include "lj_jit.h"
|
||||
|
||||
/* C call info for CALL* instructions. */
|
||||
typedef struct CCallInfo {
|
||||
ASMFunction func; /* Function pointer. */
|
||||
uint32_t flags; /* Number of arguments and flags. */
|
||||
} CCallInfo;
|
||||
|
||||
#define CCI_NARGS(ci) ((ci)->flags & 0xff) /* Extract # of args. */
|
||||
#define CCI_NARGS_MAX 32 /* Max. # of args. */
|
||||
|
||||
#define CCI_OTSHIFT 16
|
||||
#define CCI_OPTYPE(ci) ((ci)->flags >> CCI_OTSHIFT) /* Get op/type. */
|
||||
#define CCI_OPSHIFT 24
|
||||
#define CCI_OP(ci) ((ci)->flags >> CCI_OPSHIFT) /* Get op. */
|
||||
|
||||
#define CCI_CALL_N (IR_CALLN << CCI_OPSHIFT)
|
||||
#define CCI_CALL_L (IR_CALLL << CCI_OPSHIFT)
|
||||
#define CCI_CALL_S (IR_CALLS << CCI_OPSHIFT)
|
||||
#define CCI_CALL_FN (CCI_CALL_N|CCI_CC_FASTCALL)
|
||||
#define CCI_CALL_FL (CCI_CALL_L|CCI_CC_FASTCALL)
|
||||
#define CCI_CALL_FS (CCI_CALL_S|CCI_CC_FASTCALL)
|
||||
|
||||
/* C call info flags. */
|
||||
#define CCI_L 0x0100 /* Implicit L arg. */
|
||||
#define CCI_CASTU64 0x0200 /* Cast u64 result to number. */
|
||||
#define CCI_NOFPRCLOBBER 0x0400 /* Does not clobber any FPRs. */
|
||||
#define CCI_VARARG 0x0800 /* Vararg function. */
|
||||
|
||||
#define CCI_CC_MASK 0x3000 /* Calling convention mask. */
|
||||
#define CCI_CC_SHIFT 12
|
||||
/* ORDER CC */
|
||||
#define CCI_CC_CDECL 0x0000 /* Default cdecl calling convention. */
|
||||
#define CCI_CC_THISCALL 0x1000 /* Thiscall calling convention. */
|
||||
#define CCI_CC_FASTCALL 0x2000 /* Fastcall calling convention. */
|
||||
#define CCI_CC_STDCALL 0x3000 /* Stdcall calling convention. */
|
||||
|
||||
/* Helpers for conditional function definitions. */
|
||||
#define IRCALLCOND_ANY(x) x
|
||||
|
||||
#if LJ_TARGET_X86ORX64
|
||||
#define IRCALLCOND_FPMATH(x) NULL
|
||||
#else
|
||||
#define IRCALLCOND_FPMATH(x) x
|
||||
#endif
|
||||
|
||||
#if LJ_SOFTFP
|
||||
#define IRCALLCOND_SOFTFP(x) x
|
||||
#if LJ_HASFFI
|
||||
#define IRCALLCOND_SOFTFP_FFI(x) x
|
||||
#else
|
||||
#define IRCALLCOND_SOFTFP_FFI(x) NULL
|
||||
#endif
|
||||
#else
|
||||
#define IRCALLCOND_SOFTFP(x) NULL
|
||||
#define IRCALLCOND_SOFTFP_FFI(x) NULL
|
||||
#endif
|
||||
|
||||
#define LJ_NEED_FP64 (LJ_TARGET_ARM || LJ_TARGET_PPC || LJ_TARGET_MIPS)
|
||||
|
||||
#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64)
|
||||
#define IRCALLCOND_FP64_FFI(x) x
|
||||
#else
|
||||
#define IRCALLCOND_FP64_FFI(x) NULL
|
||||
#endif
|
||||
|
||||
#if LJ_HASFFI
|
||||
#define IRCALLCOND_FFI(x) x
|
||||
#if LJ_32
|
||||
#define IRCALLCOND_FFI32(x) x
|
||||
#else
|
||||
#define IRCALLCOND_FFI32(x) NULL
|
||||
#endif
|
||||
#else
|
||||
#define IRCALLCOND_FFI(x) NULL
|
||||
#define IRCALLCOND_FFI32(x) NULL
|
||||
#endif
|
||||
|
||||
#if LJ_SOFTFP
|
||||
#define ARG1_FP 2 /* Treat as 2 32 bit arguments. */
|
||||
#else
|
||||
#define ARG1_FP 1
|
||||
#endif
|
||||
|
||||
#if LJ_32
|
||||
#define ARG2_64 4 /* Treat as 4 32 bit arguments. */
|
||||
#else
|
||||
#define ARG2_64 2
|
||||
#endif
|
||||
|
||||
/* Function definitions for CALL* instructions. */
|
||||
#define IRCALLDEF(_) \
|
||||
_(ANY, lj_str_cmp, 2, FN, INT, CCI_NOFPRCLOBBER) \
|
||||
_(ANY, lj_str_new, 3, S, STR, CCI_L) \
|
||||
_(ANY, lj_strscan_num, 2, FN, INT, 0) \
|
||||
_(ANY, lj_str_fromint, 2, FN, STR, CCI_L) \
|
||||
_(ANY, lj_str_fromnum, 2, FN, STR, CCI_L) \
|
||||
_(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \
|
||||
_(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \
|
||||
_(ANY, lj_tab_newkey, 3, S, P32, CCI_L) \
|
||||
_(ANY, lj_tab_len, 1, FL, INT, 0) \
|
||||
_(ANY, lj_gc_step_jit, 2, FS, NIL, CCI_L) \
|
||||
_(ANY, lj_gc_barrieruv, 2, FS, NIL, 0) \
|
||||
_(ANY, lj_mem_newgco, 2, FS, P32, CCI_L) \
|
||||
_(ANY, lj_math_random_step, 1, FS, NUM, CCI_CASTU64|CCI_NOFPRCLOBBER) \
|
||||
_(ANY, lj_vm_modi, 2, FN, INT, 0) \
|
||||
_(ANY, sinh, ARG1_FP, N, NUM, 0) \
|
||||
_(ANY, cosh, ARG1_FP, N, NUM, 0) \
|
||||
_(ANY, tanh, ARG1_FP, N, NUM, 0) \
|
||||
_(ANY, fputc, 2, S, INT, 0) \
|
||||
_(ANY, fwrite, 4, S, INT, 0) \
|
||||
_(ANY, fflush, 1, S, INT, 0) \
|
||||
/* ORDER FPM */ \
|
||||
_(FPMATH, lj_vm_floor, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, lj_vm_ceil, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, lj_vm_trunc, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, sqrt, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, exp, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, lj_vm_exp2, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, log, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, lj_vm_log2, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, log10, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, sin, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, cos, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, tan, ARG1_FP, N, NUM, 0) \
|
||||
_(FPMATH, lj_vm_powi, ARG1_FP+1, N, NUM, 0) \
|
||||
_(FPMATH, pow, ARG1_FP*2, N, NUM, 0) \
|
||||
_(FPMATH, atan2, ARG1_FP*2, N, NUM, 0) \
|
||||
_(FPMATH, ldexp, ARG1_FP+1, N, NUM, 0) \
|
||||
_(SOFTFP, lj_vm_tobit, 2, N, INT, 0) \
|
||||
_(SOFTFP, softfp_add, 4, N, NUM, 0) \
|
||||
_(SOFTFP, softfp_sub, 4, N, NUM, 0) \
|
||||
_(SOFTFP, softfp_mul, 4, N, NUM, 0) \
|
||||
_(SOFTFP, softfp_div, 4, N, NUM, 0) \
|
||||
_(SOFTFP, softfp_cmp, 4, N, NIL, 0) \
|
||||
_(SOFTFP, softfp_i2d, 1, N, NUM, 0) \
|
||||
_(SOFTFP, softfp_d2i, 2, N, INT, 0) \
|
||||
_(SOFTFP_FFI, softfp_ui2d, 1, N, NUM, 0) \
|
||||
_(SOFTFP_FFI, softfp_f2d, 1, N, NUM, 0) \
|
||||
_(SOFTFP_FFI, softfp_d2ui, 2, N, INT, 0) \
|
||||
_(SOFTFP_FFI, softfp_d2f, 2, N, FLOAT, 0) \
|
||||
_(SOFTFP_FFI, softfp_i2f, 1, N, FLOAT, 0) \
|
||||
_(SOFTFP_FFI, softfp_ui2f, 1, N, FLOAT, 0) \
|
||||
_(SOFTFP_FFI, softfp_f2i, 1, N, INT, 0) \
|
||||
_(SOFTFP_FFI, softfp_f2ui, 1, N, INT, 0) \
|
||||
_(FP64_FFI, fp64_l2d, 2, N, NUM, 0) \
|
||||
_(FP64_FFI, fp64_ul2d, 2, N, NUM, 0) \
|
||||
_(FP64_FFI, fp64_l2f, 2, N, FLOAT, 0) \
|
||||
_(FP64_FFI, fp64_ul2f, 2, N, FLOAT, 0) \
|
||||
_(FP64_FFI, fp64_d2l, ARG1_FP, N, I64, 0) \
|
||||
_(FP64_FFI, fp64_d2ul, ARG1_FP, N, U64, 0) \
|
||||
_(FP64_FFI, fp64_f2l, 1, N, I64, 0) \
|
||||
_(FP64_FFI, fp64_f2ul, 1, N, U64, 0) \
|
||||
_(FFI, lj_carith_divi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \
|
||||
_(FFI, lj_carith_divu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \
|
||||
_(FFI, lj_carith_modi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \
|
||||
_(FFI, lj_carith_modu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \
|
||||
_(FFI, lj_carith_powi64, ARG2_64, N, I64, CCI_NOFPRCLOBBER) \
|
||||
_(FFI, lj_carith_powu64, ARG2_64, N, U64, CCI_NOFPRCLOBBER) \
|
||||
_(FFI, lj_cdata_setfin, 2, FN, P32, CCI_L) \
|
||||
_(FFI, strlen, 1, L, INTP, 0) \
|
||||
_(FFI, memcpy, 3, S, PTR, 0) \
|
||||
_(FFI, memset, 3, S, PTR, 0) \
|
||||
_(FFI, lj_vm_errno, 0, S, INT, CCI_NOFPRCLOBBER) \
|
||||
_(FFI32, lj_carith_mul64, ARG2_64, N, I64, CCI_NOFPRCLOBBER)
|
||||
\
|
||||
/* End of list. */
|
||||
|
||||
typedef enum {
|
||||
#define IRCALLENUM(cond, name, nargs, kind, type, flags) IRCALL_##name,
|
||||
IRCALLDEF(IRCALLENUM)
|
||||
#undef IRCALLENUM
|
||||
IRCALL__MAX
|
||||
} IRCallID;
|
||||
|
||||
LJ_FUNC TRef lj_ir_call(jit_State *J, IRCallID id, ...);
|
||||
|
||||
LJ_DATA const CCallInfo lj_ir_callinfo[IRCALL__MAX+1];
|
||||
|
||||
/* Soft-float declarations. */
|
||||
#if LJ_SOFTFP
|
||||
#if LJ_TARGET_ARM
|
||||
#define softfp_add __aeabi_dadd
|
||||
#define softfp_sub __aeabi_dsub
|
||||
#define softfp_mul __aeabi_dmul
|
||||
#define softfp_div __aeabi_ddiv
|
||||
#define softfp_cmp __aeabi_cdcmple
|
||||
#define softfp_i2d __aeabi_i2d
|
||||
#define softfp_d2i __aeabi_d2iz
|
||||
#define softfp_ui2d __aeabi_ui2d
|
||||
#define softfp_f2d __aeabi_f2d
|
||||
#define softfp_d2ui __aeabi_d2uiz
|
||||
#define softfp_d2f __aeabi_d2f
|
||||
#define softfp_i2f __aeabi_i2f
|
||||
#define softfp_ui2f __aeabi_ui2f
|
||||
#define softfp_f2i __aeabi_f2iz
|
||||
#define softfp_f2ui __aeabi_f2uiz
|
||||
#define fp64_l2d __aeabi_l2d
|
||||
#define fp64_ul2d __aeabi_ul2d
|
||||
#define fp64_l2f __aeabi_l2f
|
||||
#define fp64_ul2f __aeabi_ul2f
|
||||
#if LJ_TARGET_IOS
|
||||
#define fp64_d2l __fixdfdi
|
||||
#define fp64_d2ul __fixunsdfdi
|
||||
#define fp64_f2l __fixsfdi
|
||||
#define fp64_f2ul __fixunssfdi
|
||||
#else
|
||||
#define fp64_d2l __aeabi_d2lz
|
||||
#define fp64_d2ul __aeabi_d2ulz
|
||||
#define fp64_f2l __aeabi_f2lz
|
||||
#define fp64_f2ul __aeabi_f2ulz
|
||||
#endif
|
||||
#else
|
||||
#error "Missing soft-float definitions for target architecture"
|
||||
#endif
|
||||
extern double softfp_add(double a, double b);
|
||||
extern double softfp_sub(double a, double b);
|
||||
extern double softfp_mul(double a, double b);
|
||||
extern double softfp_div(double a, double b);
|
||||
extern void softfp_cmp(double a, double b);
|
||||
extern double softfp_i2d(int32_t a);
|
||||
extern int32_t softfp_d2i(double a);
|
||||
#if LJ_HASFFI
|
||||
extern double softfp_ui2d(uint32_t a);
|
||||
extern double softfp_f2d(float a);
|
||||
extern uint32_t softfp_d2ui(double a);
|
||||
extern float softfp_d2f(double a);
|
||||
extern float softfp_i2f(int32_t a);
|
||||
extern float softfp_ui2f(uint32_t a);
|
||||
extern int32_t softfp_f2i(float a);
|
||||
extern uint32_t softfp_f2ui(float a);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LJ_HASFFI && LJ_NEED_FP64 && !(LJ_TARGET_ARM && LJ_SOFTFP)
|
||||
#ifdef __GNUC__
|
||||
#define fp64_l2d __floatdidf
|
||||
#define fp64_ul2d __floatundidf
|
||||
#define fp64_l2f __floatdisf
|
||||
#define fp64_ul2f __floatundisf
|
||||
#define fp64_d2l __fixdfdi
|
||||
#define fp64_d2ul __fixunsdfdi
|
||||
#define fp64_f2l __fixsfdi
|
||||
#define fp64_f2ul __fixunssfdi
|
||||
#else
|
||||
#error "Missing fp64 helper definitions for this compiler"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LJ_HASFFI && (LJ_SOFTFP || LJ_NEED_FP64)
|
||||
extern double fp64_l2d(int64_t a);
|
||||
extern double fp64_ul2d(uint64_t a);
|
||||
extern float fp64_l2f(int64_t a);
|
||||
extern float fp64_ul2f(uint64_t a);
|
||||
extern int64_t fp64_d2l(double a);
|
||||
extern uint64_t fp64_d2ul(double a);
|
||||
extern int64_t fp64_f2l(float a);
|
||||
extern uint64_t fp64_f2ul(float a);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,481 +0,0 @@
|
||||
/*
|
||||
** Lexical analyzer.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Major portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#define lj_lex_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_gc.h"
|
||||
#include "lj_err.h"
|
||||
#include "lj_str.h"
|
||||
#if LJ_HASFFI
|
||||
#include "lj_tab.h"
|
||||
#include "lj_ctype.h"
|
||||
#include "lj_cdata.h"
|
||||
#include "lualib.h"
|
||||
#endif
|
||||
#include "lj_state.h"
|
||||
#include "lj_lex.h"
|
||||
#include "lj_parse.h"
|
||||
#include "lj_char.h"
|
||||
#include "lj_strscan.h"
|
||||
|
||||
/* Lua lexer token names. */
|
||||
static const char *const tokennames[] = {
|
||||
#define TKSTR1(name) #name,
|
||||
#define TKSTR2(name, sym) #sym,
|
||||
TKDEF(TKSTR1, TKSTR2)
|
||||
#undef TKSTR1
|
||||
#undef TKSTR2
|
||||
NULL
|
||||
};
|
||||
|
||||
/* -- Buffer handling ----------------------------------------------------- */
|
||||
|
||||
#define char2int(c) ((int)(uint8_t)(c))
|
||||
#define next(ls) \
|
||||
(ls->current = (ls->n--) > 0 ? char2int(*ls->p++) : fillbuf(ls))
|
||||
#define save_and_next(ls) (save(ls, ls->current), next(ls))
|
||||
#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r')
|
||||
#define END_OF_STREAM (-1)
|
||||
|
||||
static int fillbuf(LexState *ls)
|
||||
{
|
||||
size_t sz;
|
||||
const char *buf = ls->rfunc(ls->L, ls->rdata, &sz);
|
||||
if (buf == NULL || sz == 0) return END_OF_STREAM;
|
||||
ls->n = (MSize)sz - 1;
|
||||
ls->p = buf;
|
||||
return char2int(*(ls->p++));
|
||||
}
|
||||
|
||||
static LJ_NOINLINE void save_grow(LexState *ls, int c)
|
||||
{
|
||||
MSize newsize;
|
||||
if (ls->sb.sz >= LJ_MAX_STR/2)
|
||||
lj_lex_error(ls, 0, LJ_ERR_XELEM);
|
||||
newsize = ls->sb.sz * 2;
|
||||
lj_str_resizebuf(ls->L, &ls->sb, newsize);
|
||||
ls->sb.buf[ls->sb.n++] = (char)c;
|
||||
}
|
||||
|
||||
static LJ_AINLINE void save(LexState *ls, int c)
|
||||
{
|
||||
if (LJ_UNLIKELY(ls->sb.n + 1 > ls->sb.sz))
|
||||
save_grow(ls, c);
|
||||
else
|
||||
ls->sb.buf[ls->sb.n++] = (char)c;
|
||||
}
|
||||
|
||||
static void inclinenumber(LexState *ls)
|
||||
{
|
||||
int old = ls->current;
|
||||
lua_assert(currIsNewline(ls));
|
||||
next(ls); /* skip `\n' or `\r' */
|
||||
if (currIsNewline(ls) && ls->current != old)
|
||||
next(ls); /* skip `\n\r' or `\r\n' */
|
||||
if (++ls->linenumber >= LJ_MAX_LINE)
|
||||
lj_lex_error(ls, ls->token, LJ_ERR_XLINES);
|
||||
}
|
||||
|
||||
/* -- Scanner for terminals ----------------------------------------------- */
|
||||
|
||||
/* Parse a number literal. */
|
||||
static void lex_number(LexState *ls, TValue *tv)
|
||||
{
|
||||
StrScanFmt fmt;
|
||||
int c, xp = 'e';
|
||||
lua_assert(lj_char_isdigit(ls->current));
|
||||
if ((c = ls->current) == '0') {
|
||||
save_and_next(ls);
|
||||
if ((ls->current | 0x20) == 'x') xp = 'p';
|
||||
}
|
||||
while (lj_char_isident(ls->current) || ls->current == '.' ||
|
||||
((ls->current == '-' || ls->current == '+') && (c | 0x20) == xp)) {
|
||||
c = ls->current;
|
||||
save_and_next(ls);
|
||||
}
|
||||
save(ls, '\0');
|
||||
fmt = lj_strscan_scan((const uint8_t *)ls->sb.buf, tv,
|
||||
(LJ_DUALNUM ? STRSCAN_OPT_TOINT : STRSCAN_OPT_TONUM) |
|
||||
(LJ_HASFFI ? (STRSCAN_OPT_LL|STRSCAN_OPT_IMAG) : 0));
|
||||
if (LJ_DUALNUM && fmt == STRSCAN_INT) {
|
||||
setitype(tv, LJ_TISNUM);
|
||||
} else if (fmt == STRSCAN_NUM) {
|
||||
/* Already in correct format. */
|
||||
#if LJ_HASFFI
|
||||
} else if (fmt != STRSCAN_ERROR) {
|
||||
lua_State *L = ls->L;
|
||||
GCcdata *cd;
|
||||
lua_assert(fmt == STRSCAN_I64 || fmt == STRSCAN_U64 || fmt == STRSCAN_IMAG);
|
||||
if (!ctype_ctsG(G(L))) {
|
||||
ptrdiff_t oldtop = savestack(L, L->top);
|
||||
luaopen_ffi(L); /* Load FFI library on-demand. */
|
||||
L->top = restorestack(L, oldtop);
|
||||
}
|
||||
if (fmt == STRSCAN_IMAG) {
|
||||
cd = lj_cdata_new_(L, CTID_COMPLEX_DOUBLE, 2*sizeof(double));
|
||||
((double *)cdataptr(cd))[0] = 0;
|
||||
((double *)cdataptr(cd))[1] = numV(tv);
|
||||
} else {
|
||||
cd = lj_cdata_new_(L, fmt==STRSCAN_I64 ? CTID_INT64 : CTID_UINT64, 8);
|
||||
*(uint64_t *)cdataptr(cd) = tv->u64;
|
||||
}
|
||||
lj_parse_keepcdata(ls, tv, cd);
|
||||
#endif
|
||||
} else {
|
||||
lua_assert(fmt == STRSCAN_ERROR);
|
||||
lj_lex_error(ls, TK_number, LJ_ERR_XNUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
static int skip_sep(LexState *ls)
|
||||
{
|
||||
int count = 0;
|
||||
int s = ls->current;
|
||||
lua_assert(s == '[' || s == ']');
|
||||
save_and_next(ls);
|
||||
while (ls->current == '=') {
|
||||
save_and_next(ls);
|
||||
count++;
|
||||
}
|
||||
return (ls->current == s) ? count : (-count) - 1;
|
||||
}
|
||||
|
||||
static void read_long_string(LexState *ls, TValue *tv, int sep)
|
||||
{
|
||||
save_and_next(ls); /* skip 2nd `[' */
|
||||
if (currIsNewline(ls)) /* string starts with a newline? */
|
||||
inclinenumber(ls); /* skip it */
|
||||
for (;;) {
|
||||
switch (ls->current) {
|
||||
case END_OF_STREAM:
|
||||
lj_lex_error(ls, TK_eof, tv ? LJ_ERR_XLSTR : LJ_ERR_XLCOM);
|
||||
break;
|
||||
case ']':
|
||||
if (skip_sep(ls) == sep) {
|
||||
save_and_next(ls); /* skip 2nd `]' */
|
||||
goto endloop;
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
case '\r':
|
||||
save(ls, '\n');
|
||||
inclinenumber(ls);
|
||||
if (!tv) lj_str_resetbuf(&ls->sb); /* avoid wasting space */
|
||||
break;
|
||||
default:
|
||||
if (tv) save_and_next(ls);
|
||||
else next(ls);
|
||||
break;
|
||||
}
|
||||
} endloop:
|
||||
if (tv) {
|
||||
GCstr *str = lj_parse_keepstr(ls, ls->sb.buf + (2 + (MSize)sep),
|
||||
ls->sb.n - 2*(2 + (MSize)sep));
|
||||
setstrV(ls->L, tv, str);
|
||||
}
|
||||
}
|
||||
|
||||
static void read_string(LexState *ls, int delim, TValue *tv)
|
||||
{
|
||||
save_and_next(ls);
|
||||
while (ls->current != delim) {
|
||||
switch (ls->current) {
|
||||
case END_OF_STREAM:
|
||||
lj_lex_error(ls, TK_eof, LJ_ERR_XSTR);
|
||||
continue;
|
||||
case '\n':
|
||||
case '\r':
|
||||
lj_lex_error(ls, TK_string, LJ_ERR_XSTR);
|
||||
continue;
|
||||
case '\\': {
|
||||
int c = next(ls); /* Skip the '\\'. */
|
||||
switch (c) {
|
||||
case 'a': c = '\a'; break;
|
||||
case 'b': c = '\b'; break;
|
||||
case 'f': c = '\f'; break;
|
||||
case 'n': c = '\n'; break;
|
||||
case 'r': c = '\r'; break;
|
||||
case 't': c = '\t'; break;
|
||||
case 'v': c = '\v'; break;
|
||||
case 'x': /* Hexadecimal escape '\xXX'. */
|
||||
c = (next(ls) & 15u) << 4;
|
||||
if (!lj_char_isdigit(ls->current)) {
|
||||
if (!lj_char_isxdigit(ls->current)) goto err_xesc;
|
||||
c += 9 << 4;
|
||||
}
|
||||
c += (next(ls) & 15u);
|
||||
if (!lj_char_isdigit(ls->current)) {
|
||||
if (!lj_char_isxdigit(ls->current)) goto err_xesc;
|
||||
c += 9;
|
||||
}
|
||||
break;
|
||||
case 'z': /* Skip whitespace. */
|
||||
next(ls);
|
||||
while (lj_char_isspace(ls->current))
|
||||
if (currIsNewline(ls)) inclinenumber(ls); else next(ls);
|
||||
continue;
|
||||
case '\n': case '\r': save(ls, '\n'); inclinenumber(ls); continue;
|
||||
case '\\': case '\"': case '\'': break;
|
||||
case END_OF_STREAM: continue;
|
||||
default:
|
||||
if (!lj_char_isdigit(c))
|
||||
goto err_xesc;
|
||||
c -= '0'; /* Decimal escape '\ddd'. */
|
||||
if (lj_char_isdigit(next(ls))) {
|
||||
c = c*10 + (ls->current - '0');
|
||||
if (lj_char_isdigit(next(ls))) {
|
||||
c = c*10 + (ls->current - '0');
|
||||
if (c > 255) {
|
||||
err_xesc:
|
||||
lj_lex_error(ls, TK_string, LJ_ERR_XESC);
|
||||
}
|
||||
next(ls);
|
||||
}
|
||||
}
|
||||
save(ls, c);
|
||||
continue;
|
||||
}
|
||||
save(ls, c);
|
||||
next(ls);
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
save_and_next(ls);
|
||||
break;
|
||||
}
|
||||
}
|
||||
save_and_next(ls); /* skip delimiter */
|
||||
setstrV(ls->L, tv, lj_parse_keepstr(ls, ls->sb.buf + 1, ls->sb.n - 2));
|
||||
}
|
||||
|
||||
/* -- Main lexical scanner ------------------------------------------------ */
|
||||
|
||||
static int llex(LexState *ls, TValue *tv)
|
||||
{
|
||||
lj_str_resetbuf(&ls->sb);
|
||||
for (;;) {
|
||||
if (lj_char_isident(ls->current)) {
|
||||
GCstr *s;
|
||||
if (lj_char_isdigit(ls->current)) { /* Numeric literal. */
|
||||
lex_number(ls, tv);
|
||||
return TK_number;
|
||||
}
|
||||
/* Identifier or reserved word. */
|
||||
do {
|
||||
save_and_next(ls);
|
||||
} while (lj_char_isident(ls->current));
|
||||
s = lj_parse_keepstr(ls, ls->sb.buf, ls->sb.n);
|
||||
setstrV(ls->L, tv, s);
|
||||
if (s->reserved > 0) /* Reserved word? */
|
||||
return TK_OFS + s->reserved;
|
||||
return TK_name;
|
||||
}
|
||||
switch (ls->current) {
|
||||
case '\n':
|
||||
case '\r':
|
||||
inclinenumber(ls);
|
||||
continue;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\v':
|
||||
case '\f':
|
||||
next(ls);
|
||||
continue;
|
||||
case '-':
|
||||
next(ls);
|
||||
if (ls->current != '-') return '-';
|
||||
/* else is a comment */
|
||||
next(ls);
|
||||
if (ls->current == '[') {
|
||||
int sep = skip_sep(ls);
|
||||
lj_str_resetbuf(&ls->sb); /* `skip_sep' may dirty the buffer */
|
||||
if (sep >= 0) {
|
||||
read_long_string(ls, NULL, sep); /* long comment */
|
||||
lj_str_resetbuf(&ls->sb);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* else short comment */
|
||||
while (!currIsNewline(ls) && ls->current != END_OF_STREAM)
|
||||
next(ls);
|
||||
continue;
|
||||
case '[': {
|
||||
int sep = skip_sep(ls);
|
||||
if (sep >= 0) {
|
||||
read_long_string(ls, tv, sep);
|
||||
return TK_string;
|
||||
} else if (sep == -1) {
|
||||
return '[';
|
||||
} else {
|
||||
lj_lex_error(ls, TK_string, LJ_ERR_XLDELIM);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
case '=':
|
||||
next(ls);
|
||||
if (ls->current != '=') return '='; else { next(ls); return TK_eq; }
|
||||
case '<':
|
||||
next(ls);
|
||||
if (ls->current != '=') return '<'; else { next(ls); return TK_le; }
|
||||
case '>':
|
||||
next(ls);
|
||||
if (ls->current != '=') return '>'; else { next(ls); return TK_ge; }
|
||||
case '~':
|
||||
next(ls);
|
||||
if (ls->current != '=') return '~'; else { next(ls); return TK_ne; }
|
||||
case ':':
|
||||
next(ls);
|
||||
if (ls->current != ':') return ':'; else { next(ls); return TK_label; }
|
||||
case '"':
|
||||
case '\'':
|
||||
read_string(ls, ls->current, tv);
|
||||
return TK_string;
|
||||
case '.':
|
||||
save_and_next(ls);
|
||||
if (ls->current == '.') {
|
||||
next(ls);
|
||||
if (ls->current == '.') {
|
||||
next(ls);
|
||||
return TK_dots; /* ... */
|
||||
}
|
||||
return TK_concat; /* .. */
|
||||
} else if (!lj_char_isdigit(ls->current)) {
|
||||
return '.';
|
||||
} else {
|
||||
lex_number(ls, tv);
|
||||
return TK_number;
|
||||
}
|
||||
case END_OF_STREAM:
|
||||
return TK_eof;
|
||||
default: {
|
||||
int c = ls->current;
|
||||
next(ls);
|
||||
return c; /* Single-char tokens (+ - / ...). */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -- Lexer API ----------------------------------------------------------- */
|
||||
|
||||
/* Setup lexer state. */
|
||||
int lj_lex_setup(lua_State *L, LexState *ls)
|
||||
{
|
||||
int header = 0;
|
||||
ls->L = L;
|
||||
ls->fs = NULL;
|
||||
ls->n = 0;
|
||||
ls->p = NULL;
|
||||
ls->vstack = NULL;
|
||||
ls->sizevstack = 0;
|
||||
ls->vtop = 0;
|
||||
ls->bcstack = NULL;
|
||||
ls->sizebcstack = 0;
|
||||
ls->lookahead = TK_eof; /* No look-ahead token. */
|
||||
ls->linenumber = 1;
|
||||
ls->lastline = 1;
|
||||
lj_str_resizebuf(ls->L, &ls->sb, LJ_MIN_SBUF);
|
||||
next(ls); /* Read-ahead first char. */
|
||||
if (ls->current == 0xef && ls->n >= 2 && char2int(ls->p[0]) == 0xbb &&
|
||||
char2int(ls->p[1]) == 0xbf) { /* Skip UTF-8 BOM (if buffered). */
|
||||
ls->n -= 2;
|
||||
ls->p += 2;
|
||||
next(ls);
|
||||
header = 1;
|
||||
}
|
||||
if (ls->current == '#') { /* Skip POSIX #! header line. */
|
||||
do {
|
||||
next(ls);
|
||||
if (ls->current == END_OF_STREAM) return 0;
|
||||
} while (!currIsNewline(ls));
|
||||
inclinenumber(ls);
|
||||
header = 1;
|
||||
}
|
||||
if (ls->current == LUA_SIGNATURE[0]) { /* Bytecode dump. */
|
||||
if (header) {
|
||||
/*
|
||||
** Loading bytecode with an extra header is disabled for security
|
||||
** reasons. This may circumvent the usual check for bytecode vs.
|
||||
** Lua code by looking at the first char. Since this is a potential
|
||||
** security violation no attempt is made to echo the chunkname either.
|
||||
*/
|
||||
setstrV(L, L->top++, lj_err_str(L, LJ_ERR_BCBAD));
|
||||
lj_err_throw(L, LUA_ERRSYNTAX);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Cleanup lexer state. */
|
||||
void lj_lex_cleanup(lua_State *L, LexState *ls)
|
||||
{
|
||||
global_State *g = G(L);
|
||||
lj_mem_freevec(g, ls->bcstack, ls->sizebcstack, BCInsLine);
|
||||
lj_mem_freevec(g, ls->vstack, ls->sizevstack, VarInfo);
|
||||
lj_str_freebuf(g, &ls->sb);
|
||||
}
|
||||
|
||||
void lj_lex_next(LexState *ls)
|
||||
{
|
||||
ls->lastline = ls->linenumber;
|
||||
if (LJ_LIKELY(ls->lookahead == TK_eof)) { /* No lookahead token? */
|
||||
ls->token = llex(ls, &ls->tokenval); /* Get next token. */
|
||||
} else { /* Otherwise return lookahead token. */
|
||||
ls->token = ls->lookahead;
|
||||
ls->lookahead = TK_eof;
|
||||
ls->tokenval = ls->lookaheadval;
|
||||
}
|
||||
}
|
||||
|
||||
LexToken lj_lex_lookahead(LexState *ls)
|
||||
{
|
||||
lua_assert(ls->lookahead == TK_eof);
|
||||
ls->lookahead = llex(ls, &ls->lookaheadval);
|
||||
return ls->lookahead;
|
||||
}
|
||||
|
||||
const char *lj_lex_token2str(LexState *ls, LexToken token)
|
||||
{
|
||||
if (token > TK_OFS)
|
||||
return tokennames[token-TK_OFS-1];
|
||||
else if (!lj_char_iscntrl(token))
|
||||
return lj_str_pushf(ls->L, "%c", token);
|
||||
else
|
||||
return lj_str_pushf(ls->L, "char(%d)", token);
|
||||
}
|
||||
|
||||
void lj_lex_error(LexState *ls, LexToken token, ErrMsg em, ...)
|
||||
{
|
||||
const char *tok;
|
||||
va_list argp;
|
||||
if (token == 0) {
|
||||
tok = NULL;
|
||||
} else if (token == TK_name || token == TK_string || token == TK_number) {
|
||||
save(ls, '\0');
|
||||
tok = ls->sb.buf;
|
||||
} else {
|
||||
tok = lj_lex_token2str(ls, token);
|
||||
}
|
||||
va_start(argp, em);
|
||||
lj_err_lex(ls->L, ls->chunkname, tok, ls->linenumber, em, argp);
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
void lj_lex_init(lua_State *L)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < TK_RESERVED; i++) {
|
||||
GCstr *s = lj_str_newz(L, tokennames[i]);
|
||||
fixstring(s); /* Reserved words are never collected. */
|
||||
s->reserved = (uint8_t)(i+1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,393 +0,0 @@
|
||||
/* This is a generated file. DO NOT EDIT! */
|
||||
|
||||
#ifdef LJLIB_MODULE_base
|
||||
#undef LJLIB_MODULE_base
|
||||
static const lua_CFunction lj_lib_cf_base[] = {
|
||||
lj_ffh_assert,
|
||||
lj_ffh_next,
|
||||
lj_ffh_pairs,
|
||||
lj_ffh_ipairs_aux,
|
||||
lj_ffh_ipairs,
|
||||
lj_ffh_setmetatable,
|
||||
lj_cf_getfenv,
|
||||
lj_cf_setfenv,
|
||||
lj_ffh_rawget,
|
||||
lj_cf_rawset,
|
||||
lj_cf_rawequal,
|
||||
lj_cf_unpack,
|
||||
lj_cf_select,
|
||||
lj_ffh_tonumber,
|
||||
lj_ffh_tostring,
|
||||
lj_cf_error,
|
||||
lj_ffh_pcall,
|
||||
lj_cf_loadfile,
|
||||
lj_cf_load,
|
||||
lj_cf_loadstring,
|
||||
lj_cf_dofile,
|
||||
lj_cf_gcinfo,
|
||||
lj_cf_collectgarbage,
|
||||
lj_cf_newproxy,
|
||||
lj_cf_print
|
||||
};
|
||||
static const uint8_t lj_lib_init_base[] = {
|
||||
2,0,28,70,97,115,115,101,114,116,195,110,105,108,199,98,111,111,108,101,97,
|
||||
110,252,1,200,117,115,101,114,100,97,116,97,198,115,116,114,105,110,103,197,
|
||||
117,112,118,97,108,198,116,104,114,101,97,100,197,112,114,111,116,111,200,102,
|
||||
117,110,99,116,105,111,110,197,116,114,97,99,101,197,99,100,97,116,97,197,116,
|
||||
97,98,108,101,252,9,198,110,117,109,98,101,114,132,116,121,112,101,68,110,101,
|
||||
120,116,253,69,112,97,105,114,115,64,253,70,105,112,97,105,114,115,140,103,
|
||||
101,116,109,101,116,97,116,97,98,108,101,76,115,101,116,109,101,116,97,116,
|
||||
97,98,108,101,7,103,101,116,102,101,110,118,7,115,101,116,102,101,110,118,70,
|
||||
114,97,119,103,101,116,6,114,97,119,115,101,116,8,114,97,119,101,113,117,97,
|
||||
108,6,117,110,112,97,99,107,6,115,101,108,101,99,116,72,116,111,110,117,109,
|
||||
98,101,114,195,110,105,108,197,102,97,108,115,101,196,116,114,117,101,72,116,
|
||||
111,115,116,114,105,110,103,5,101,114,114,111,114,69,112,99,97,108,108,134,
|
||||
120,112,99,97,108,108,8,108,111,97,100,102,105,108,101,4,108,111,97,100,10,
|
||||
108,111,97,100,115,116,114,105,110,103,6,100,111,102,105,108,101,6,103,99,105,
|
||||
110,102,111,14,99,111,108,108,101,99,116,103,97,114,98,97,103,101,252,2,8,110,
|
||||
101,119,112,114,111,120,121,200,116,111,115,116,114,105,110,103,5,112,114,105,
|
||||
110,116,252,3,200,95,86,69,82,83,73,79,78,250,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_coroutine
|
||||
#undef LJLIB_MODULE_coroutine
|
||||
static const lua_CFunction lj_lib_cf_coroutine[] = {
|
||||
lj_cf_coroutine_status,
|
||||
lj_cf_coroutine_running,
|
||||
lj_cf_coroutine_create,
|
||||
lj_ffh_coroutine_yield,
|
||||
lj_ffh_coroutine_resume,
|
||||
lj_cf_coroutine_wrap
|
||||
};
|
||||
static const uint8_t lj_lib_init_coroutine[] = {
|
||||
30,13,6,6,115,116,97,116,117,115,7,114,117,110,110,105,110,103,6,99,114,101,
|
||||
97,116,101,69,121,105,101,108,100,70,114,101,115,117,109,101,254,4,119,114,
|
||||
97,112,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_math
|
||||
#undef LJLIB_MODULE_math
|
||||
static const lua_CFunction lj_lib_cf_math[] = {
|
||||
lj_ffh_math_abs,
|
||||
lj_ffh_math_sqrt,
|
||||
lj_ffh_math_log,
|
||||
lj_ffh_math_atan2,
|
||||
lj_ffh_math_ldexp,
|
||||
lj_ffh_math_min,
|
||||
lj_cf_math_random,
|
||||
lj_cf_math_randomseed
|
||||
};
|
||||
static const uint8_t lj_lib_init_math[] = {
|
||||
37,16,30,67,97,98,115,133,102,108,111,111,114,132,99,101,105,108,68,115,113,
|
||||
114,116,133,108,111,103,49,48,131,101,120,112,131,115,105,110,131,99,111,115,
|
||||
131,116,97,110,132,97,115,105,110,132,97,99,111,115,132,97,116,97,110,132,115,
|
||||
105,110,104,132,99,111,115,104,132,116,97,110,104,133,102,114,101,120,112,132,
|
||||
109,111,100,102,67,108,111,103,251,248,193,99,26,220,165,76,64,131,100,101,
|
||||
103,251,57,157,82,162,70,223,145,63,131,114,97,100,69,97,116,97,110,50,131,
|
||||
112,111,119,132,102,109,111,100,69,108,100,101,120,112,67,109,105,110,131,109,
|
||||
97,120,251,24,45,68,84,251,33,9,64,194,112,105,250,251,0,0,0,0,0,0,240,127,
|
||||
196,104,117,103,101,250,252,2,6,114,97,110,100,111,109,252,2,10,114,97,110,
|
||||
100,111,109,115,101,101,100,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_bit
|
||||
#undef LJLIB_MODULE_bit
|
||||
static const lua_CFunction lj_lib_cf_bit[] = {
|
||||
lj_ffh_bit_tobit,
|
||||
lj_ffh_bit_lshift,
|
||||
lj_ffh_bit_band,
|
||||
lj_cf_bit_tohex
|
||||
};
|
||||
static const uint8_t lj_lib_init_bit[] = {
|
||||
65,42,12,69,116,111,98,105,116,132,98,110,111,116,133,98,115,119,97,112,70,
|
||||
108,115,104,105,102,116,134,114,115,104,105,102,116,135,97,114,115,104,105,
|
||||
102,116,131,114,111,108,131,114,111,114,68,98,97,110,100,131,98,111,114,132,
|
||||
98,120,111,114,5,116,111,104,101,120,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_string
|
||||
#undef LJLIB_MODULE_string
|
||||
static const lua_CFunction lj_lib_cf_string[] = {
|
||||
lj_ffh_string_len,
|
||||
lj_ffh_string_byte,
|
||||
lj_ffh_string_char,
|
||||
lj_ffh_string_sub,
|
||||
lj_ffh_string_rep,
|
||||
lj_ffh_string_reverse,
|
||||
lj_cf_string_dump,
|
||||
lj_cf_string_find,
|
||||
lj_cf_string_match,
|
||||
lj_cf_string_gmatch,
|
||||
lj_cf_string_gsub,
|
||||
lj_cf_string_format
|
||||
};
|
||||
static const uint8_t lj_lib_init_string[] = {
|
||||
77,53,14,67,108,101,110,68,98,121,116,101,68,99,104,97,114,67,115,117,98,67,
|
||||
114,101,112,71,114,101,118,101,114,115,101,133,108,111,119,101,114,133,117,
|
||||
112,112,101,114,4,100,117,109,112,4,102,105,110,100,5,109,97,116,99,104,254,
|
||||
6,103,109,97,116,99,104,4,103,115,117,98,6,102,111,114,109,97,116,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_table
|
||||
#undef LJLIB_MODULE_table
|
||||
static const lua_CFunction lj_lib_cf_table[] = {
|
||||
lj_cf_table_foreachi,
|
||||
lj_cf_table_foreach,
|
||||
lj_ffh_table_getn,
|
||||
lj_cf_table_maxn,
|
||||
lj_cf_table_insert,
|
||||
lj_cf_table_remove,
|
||||
lj_cf_table_concat,
|
||||
lj_cf_table_sort
|
||||
};
|
||||
static const uint8_t lj_lib_init_table[] = {
|
||||
92,61,8,8,102,111,114,101,97,99,104,105,7,102,111,114,101,97,99,104,68,103,
|
||||
101,116,110,4,109,97,120,110,6,105,110,115,101,114,116,6,114,101,109,111,118,
|
||||
101,6,99,111,110,99,97,116,4,115,111,114,116,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_io_method
|
||||
#undef LJLIB_MODULE_io_method
|
||||
static const lua_CFunction lj_lib_cf_io_method[] = {
|
||||
lj_cf_io_method_close,
|
||||
lj_cf_io_method_read,
|
||||
lj_cf_io_method_write,
|
||||
lj_cf_io_method_flush,
|
||||
lj_cf_io_method_seek,
|
||||
lj_cf_io_method_setvbuf,
|
||||
lj_cf_io_method_lines,
|
||||
lj_cf_io_method___gc,
|
||||
lj_cf_io_method___tostring
|
||||
};
|
||||
static const uint8_t lj_lib_init_io_method[] = {
|
||||
100,62,10,5,99,108,111,115,101,4,114,101,97,100,5,119,114,105,116,101,5,102,
|
||||
108,117,115,104,4,115,101,101,107,7,115,101,116,118,98,117,102,5,108,105,110,
|
||||
101,115,4,95,95,103,99,10,95,95,116,111,115,116,114,105,110,103,252,1,199,95,
|
||||
95,105,110,100,101,120,250,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_io
|
||||
#undef LJLIB_MODULE_io
|
||||
static const lua_CFunction lj_lib_cf_io[] = {
|
||||
lj_cf_io_open,
|
||||
lj_cf_io_popen,
|
||||
lj_cf_io_tmpfile,
|
||||
lj_cf_io_close,
|
||||
lj_cf_io_read,
|
||||
lj_cf_io_write,
|
||||
lj_cf_io_flush,
|
||||
lj_cf_io_input,
|
||||
lj_cf_io_output,
|
||||
lj_cf_io_lines,
|
||||
lj_cf_io_type
|
||||
};
|
||||
static const uint8_t lj_lib_init_io[] = {
|
||||
109,62,12,252,2,192,250,4,111,112,101,110,5,112,111,112,101,110,7,116,109,112,
|
||||
102,105,108,101,5,99,108,111,115,101,4,114,101,97,100,5,119,114,105,116,101,
|
||||
5,102,108,117,115,104,5,105,110,112,117,116,6,111,117,116,112,117,116,5,108,
|
||||
105,110,101,115,4,116,121,112,101,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_os
|
||||
#undef LJLIB_MODULE_os
|
||||
static const lua_CFunction lj_lib_cf_os[] = {
|
||||
lj_cf_os_execute,
|
||||
lj_cf_os_remove,
|
||||
lj_cf_os_rename,
|
||||
lj_cf_os_tmpname,
|
||||
lj_cf_os_getenv,
|
||||
lj_cf_os_exit,
|
||||
lj_cf_os_clock,
|
||||
lj_cf_os_date,
|
||||
lj_cf_os_time,
|
||||
lj_cf_os_difftime,
|
||||
lj_cf_os_setlocale
|
||||
};
|
||||
static const uint8_t lj_lib_init_os[] = {
|
||||
120,62,11,7,101,120,101,99,117,116,101,6,114,101,109,111,118,101,6,114,101,
|
||||
110,97,109,101,7,116,109,112,110,97,109,101,6,103,101,116,101,110,118,4,101,
|
||||
120,105,116,5,99,108,111,99,107,4,100,97,116,101,4,116,105,109,101,8,100,105,
|
||||
102,102,116,105,109,101,9,115,101,116,108,111,99,97,108,101,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_debug
|
||||
#undef LJLIB_MODULE_debug
|
||||
static const lua_CFunction lj_lib_cf_debug[] = {
|
||||
lj_cf_debug_getregistry,
|
||||
lj_cf_debug_getmetatable,
|
||||
lj_cf_debug_setmetatable,
|
||||
lj_cf_debug_getfenv,
|
||||
lj_cf_debug_setfenv,
|
||||
lj_cf_debug_getinfo,
|
||||
lj_cf_debug_getlocal,
|
||||
lj_cf_debug_setlocal,
|
||||
lj_cf_debug_getupvalue,
|
||||
lj_cf_debug_setupvalue,
|
||||
lj_cf_debug_upvalueid,
|
||||
lj_cf_debug_upvaluejoin,
|
||||
lj_cf_debug_sethook,
|
||||
lj_cf_debug_gethook,
|
||||
lj_cf_debug_debug,
|
||||
lj_cf_debug_traceback
|
||||
};
|
||||
static const uint8_t lj_lib_init_debug[] = {
|
||||
131,62,16,11,103,101,116,114,101,103,105,115,116,114,121,12,103,101,116,109,
|
||||
101,116,97,116,97,98,108,101,12,115,101,116,109,101,116,97,116,97,98,108,101,
|
||||
7,103,101,116,102,101,110,118,7,115,101,116,102,101,110,118,7,103,101,116,105,
|
||||
110,102,111,8,103,101,116,108,111,99,97,108,8,115,101,116,108,111,99,97,108,
|
||||
10,103,101,116,117,112,118,97,108,117,101,10,115,101,116,117,112,118,97,108,
|
||||
117,101,9,117,112,118,97,108,117,101,105,100,11,117,112,118,97,108,117,101,
|
||||
106,111,105,110,7,115,101,116,104,111,111,107,7,103,101,116,104,111,111,107,
|
||||
5,100,101,98,117,103,9,116,114,97,99,101,98,97,99,107,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_jit
|
||||
#undef LJLIB_MODULE_jit
|
||||
static const lua_CFunction lj_lib_cf_jit[] = {
|
||||
lj_cf_jit_on,
|
||||
lj_cf_jit_off,
|
||||
lj_cf_jit_flush,
|
||||
lj_cf_jit_status,
|
||||
lj_cf_jit_attach
|
||||
};
|
||||
static const uint8_t lj_lib_init_jit[] = {
|
||||
147,62,9,2,111,110,3,111,102,102,5,102,108,117,115,104,6,115,116,97,116,117,
|
||||
115,6,97,116,116,97,99,104,252,5,194,111,115,250,252,4,196,97,114,99,104,250,
|
||||
252,3,203,118,101,114,115,105,111,110,95,110,117,109,250,252,2,199,118,101,
|
||||
114,115,105,111,110,250,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_jit_util
|
||||
#undef LJLIB_MODULE_jit_util
|
||||
static const lua_CFunction lj_lib_cf_jit_util[] = {
|
||||
lj_cf_jit_util_funcinfo,
|
||||
lj_cf_jit_util_funcbc,
|
||||
lj_cf_jit_util_funck,
|
||||
lj_cf_jit_util_funcuvname,
|
||||
lj_cf_jit_util_traceinfo,
|
||||
lj_cf_jit_util_traceir,
|
||||
lj_cf_jit_util_tracek,
|
||||
lj_cf_jit_util_tracesnap,
|
||||
lj_cf_jit_util_tracemc,
|
||||
lj_cf_jit_util_traceexitstub,
|
||||
lj_cf_jit_util_ircalladdr
|
||||
};
|
||||
static const uint8_t lj_lib_init_jit_util[] = {
|
||||
152,62,11,8,102,117,110,99,105,110,102,111,6,102,117,110,99,98,99,5,102,117,
|
||||
110,99,107,10,102,117,110,99,117,118,110,97,109,101,9,116,114,97,99,101,105,
|
||||
110,102,111,7,116,114,97,99,101,105,114,6,116,114,97,99,101,107,9,116,114,97,
|
||||
99,101,115,110,97,112,7,116,114,97,99,101,109,99,13,116,114,97,99,101,101,120,
|
||||
105,116,115,116,117,98,10,105,114,99,97,108,108,97,100,100,114,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_jit_opt
|
||||
#undef LJLIB_MODULE_jit_opt
|
||||
static const lua_CFunction lj_lib_cf_jit_opt[] = {
|
||||
lj_cf_jit_opt_start
|
||||
};
|
||||
static const uint8_t lj_lib_init_jit_opt[] = {
|
||||
163,62,1,5,115,116,97,114,116,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_ffi_meta
|
||||
#undef LJLIB_MODULE_ffi_meta
|
||||
static const lua_CFunction lj_lib_cf_ffi_meta[] = {
|
||||
lj_cf_ffi_meta___index,
|
||||
lj_cf_ffi_meta___newindex,
|
||||
lj_cf_ffi_meta___eq,
|
||||
lj_cf_ffi_meta___len,
|
||||
lj_cf_ffi_meta___lt,
|
||||
lj_cf_ffi_meta___le,
|
||||
lj_cf_ffi_meta___concat,
|
||||
lj_cf_ffi_meta___call,
|
||||
lj_cf_ffi_meta___add,
|
||||
lj_cf_ffi_meta___sub,
|
||||
lj_cf_ffi_meta___mul,
|
||||
lj_cf_ffi_meta___div,
|
||||
lj_cf_ffi_meta___mod,
|
||||
lj_cf_ffi_meta___pow,
|
||||
lj_cf_ffi_meta___unm,
|
||||
lj_cf_ffi_meta___tostring,
|
||||
lj_cf_ffi_meta___pairs,
|
||||
lj_cf_ffi_meta___ipairs
|
||||
};
|
||||
static const uint8_t lj_lib_init_ffi_meta[] = {
|
||||
164,62,19,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101,
|
||||
120,4,95,95,101,113,5,95,95,108,101,110,4,95,95,108,116,4,95,95,108,101,8,95,
|
||||
95,99,111,110,99,97,116,6,95,95,99,97,108,108,5,95,95,97,100,100,5,95,95,115,
|
||||
117,98,5,95,95,109,117,108,5,95,95,100,105,118,5,95,95,109,111,100,5,95,95,
|
||||
112,111,119,5,95,95,117,110,109,10,95,95,116,111,115,116,114,105,110,103,7,
|
||||
95,95,112,97,105,114,115,8,95,95,105,112,97,105,114,115,195,102,102,105,203,
|
||||
95,95,109,101,116,97,116,97,98,108,101,250,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_ffi_clib
|
||||
#undef LJLIB_MODULE_ffi_clib
|
||||
static const lua_CFunction lj_lib_cf_ffi_clib[] = {
|
||||
lj_cf_ffi_clib___index,
|
||||
lj_cf_ffi_clib___newindex,
|
||||
lj_cf_ffi_clib___gc
|
||||
};
|
||||
static const uint8_t lj_lib_init_ffi_clib[] = {
|
||||
182,62,3,7,95,95,105,110,100,101,120,10,95,95,110,101,119,105,110,100,101,120,
|
||||
4,95,95,103,99,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_ffi_callback
|
||||
#undef LJLIB_MODULE_ffi_callback
|
||||
static const lua_CFunction lj_lib_cf_ffi_callback[] = {
|
||||
lj_cf_ffi_callback_free,
|
||||
lj_cf_ffi_callback_set
|
||||
};
|
||||
static const uint8_t lj_lib_init_ffi_callback[] = {
|
||||
185,62,3,4,102,114,101,101,3,115,101,116,252,1,199,95,95,105,110,100,101,120,
|
||||
250,255
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LJLIB_MODULE_ffi
|
||||
#undef LJLIB_MODULE_ffi
|
||||
static const lua_CFunction lj_lib_cf_ffi[] = {
|
||||
lj_cf_ffi_cdef,
|
||||
lj_cf_ffi_new,
|
||||
lj_cf_ffi_cast,
|
||||
lj_cf_ffi_typeof,
|
||||
lj_cf_ffi_istype,
|
||||
lj_cf_ffi_sizeof,
|
||||
lj_cf_ffi_alignof,
|
||||
lj_cf_ffi_offsetof,
|
||||
lj_cf_ffi_errno,
|
||||
lj_cf_ffi_string,
|
||||
lj_cf_ffi_copy,
|
||||
lj_cf_ffi_fill,
|
||||
lj_cf_ffi_abi,
|
||||
lj_cf_ffi_metatype,
|
||||
lj_cf_ffi_gc,
|
||||
lj_cf_ffi_load
|
||||
};
|
||||
static const uint8_t lj_lib_init_ffi[] = {
|
||||
187,62,22,4,99,100,101,102,3,110,101,119,4,99,97,115,116,6,116,121,112,101,
|
||||
111,102,6,105,115,116,121,112,101,6,115,105,122,101,111,102,7,97,108,105,103,
|
||||
110,111,102,8,111,102,102,115,101,116,111,102,5,101,114,114,110,111,6,115,116,
|
||||
114,105,110,103,4,99,111,112,121,4,102,105,108,108,3,97,98,105,252,8,192,250,
|
||||
8,109,101,116,97,116,121,112,101,252,7,192,250,2,103,99,252,5,192,250,4,108,
|
||||
111,97,100,252,4,193,67,250,252,3,194,111,115,250,252,2,196,97,114,99,104,250,
|
||||
255
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
** Miscellaneous object handling.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_obj_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "lj_obj.h"
|
||||
|
||||
/* Object type names. */
|
||||
LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */
|
||||
"no value", "nil", "boolean", "userdata", "number", "string",
|
||||
"table", "function", "userdata", "thread", "proto", "cdata"
|
||||
};
|
||||
|
||||
LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */
|
||||
"nil", "boolean", "boolean", "userdata", "string", "upval", "thread",
|
||||
"proto", "function", "trace", "cdata", "table", "userdata", "number"
|
||||
};
|
||||
|
||||
/* Compare two objects without calling metamethods. */
|
||||
int lj_obj_equal(cTValue *o1, cTValue *o2)
|
||||
{
|
||||
if (itype(o1) == itype(o2)) {
|
||||
if (tvispri(o1))
|
||||
return 1;
|
||||
if (!tvisnum(o1))
|
||||
return gcrefeq(o1->gcr, o2->gcr);
|
||||
} else if (!tvisnumber(o1) || !tvisnumber(o2)) {
|
||||
return 0;
|
||||
}
|
||||
return numberVnum(o1) == numberVnum(o2);
|
||||
}
|
||||
|
||||
@@ -1,263 +0,0 @@
|
||||
/* This is a generated file. DO NOT EDIT! */
|
||||
|
||||
static const uint16_t recff_idmap[] = {
|
||||
0,
|
||||
0x0100,
|
||||
0x0200,
|
||||
0x0300,
|
||||
0,
|
||||
0,
|
||||
0x0400,
|
||||
0x0500,
|
||||
0x0600,
|
||||
0x0700,
|
||||
0,
|
||||
0,
|
||||
0x0800,
|
||||
0x0900,
|
||||
0x0a00,
|
||||
0,
|
||||
0x0b00,
|
||||
0x0c00,
|
||||
0x0d00,
|
||||
0,
|
||||
0x0e00,
|
||||
0x0f00,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0x1000,
|
||||
0x1100+(IRFPM_FLOOR),
|
||||
0x1100+(IRFPM_CEIL),
|
||||
0x1200+(IRFPM_SQRT),
|
||||
0x1200+(IRFPM_LOG10),
|
||||
0x1200+(IRFPM_EXP),
|
||||
0x1200+(IRFPM_SIN),
|
||||
0x1200+(IRFPM_COS),
|
||||
0x1200+(IRFPM_TAN),
|
||||
0x1300+(FF_math_asin),
|
||||
0x1300+(FF_math_acos),
|
||||
0x1300+(FF_math_atan),
|
||||
0x1400+(IRCALL_sinh),
|
||||
0x1400+(IRCALL_cosh),
|
||||
0x1400+(IRCALL_tanh),
|
||||
0,
|
||||
0x1500,
|
||||
0x1600,
|
||||
0x1700,
|
||||
0x1700,
|
||||
0x1800,
|
||||
0x1900,
|
||||
0,
|
||||
0x1a00,
|
||||
0x1b00+(IR_MIN),
|
||||
0x1b00+(IR_MAX),
|
||||
0x1c00,
|
||||
0,
|
||||
0x1d00+(IR_TOBIT),
|
||||
0x1d00+(IR_BNOT),
|
||||
0x1d00+(IR_BSWAP),
|
||||
0x1e00+(IR_BSHL),
|
||||
0x1e00+(IR_BSHR),
|
||||
0x1e00+(IR_BSAR),
|
||||
0x1e00+(IR_BROL),
|
||||
0x1e00+(IR_BROR),
|
||||
0x1f00+(IR_BAND),
|
||||
0x1f00+(IR_BOR),
|
||||
0x1f00+(IR_BXOR),
|
||||
0,
|
||||
0x2000,
|
||||
0x2100+(0),
|
||||
0,
|
||||
0x2100+(1),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0x2200,
|
||||
0,
|
||||
0x2300,
|
||||
0x2400,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0x2500+(0),
|
||||
0x2600+(0),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0x2500+(GCROOT_IO_OUTPUT),
|
||||
0x2600+(GCROOT_IO_OUTPUT),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0x2700+(0),
|
||||
0x2700+(1),
|
||||
0x2800+(MM_eq),
|
||||
0x2800+(MM_len),
|
||||
0x2800+(MM_lt),
|
||||
0x2800+(MM_le),
|
||||
0x2800+(MM_concat),
|
||||
0x2900,
|
||||
0x2800+(MM_add),
|
||||
0x2800+(MM_sub),
|
||||
0x2800+(MM_mul),
|
||||
0x2800+(MM_div),
|
||||
0x2800+(MM_mod),
|
||||
0x2800+(MM_pow),
|
||||
0x2800+(MM_unm),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0x2a00+(1),
|
||||
0x2a00+(0),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0x2b00,
|
||||
0x2b00,
|
||||
0x2c00,
|
||||
0x2d00,
|
||||
0x2e00+(FF_ffi_sizeof),
|
||||
0x2e00+(FF_ffi_alignof),
|
||||
0x2e00+(FF_ffi_offsetof),
|
||||
0x2f00,
|
||||
0x3000,
|
||||
0x3100,
|
||||
0x3200,
|
||||
0x3300,
|
||||
0,
|
||||
0x3400
|
||||
};
|
||||
|
||||
static const RecordFunc recff_func[] = {
|
||||
recff_nyi,
|
||||
recff_c,
|
||||
recff_assert,
|
||||
recff_type,
|
||||
recff_ipairs_aux,
|
||||
recff_ipairs,
|
||||
recff_getmetatable,
|
||||
recff_setmetatable,
|
||||
recff_rawget,
|
||||
recff_rawset,
|
||||
recff_rawequal,
|
||||
recff_select,
|
||||
recff_tonumber,
|
||||
recff_tostring,
|
||||
recff_pcall,
|
||||
recff_xpcall,
|
||||
recff_math_abs,
|
||||
recff_math_round,
|
||||
recff_math_unary,
|
||||
recff_math_atrig,
|
||||
recff_math_htrig,
|
||||
recff_math_modf,
|
||||
recff_math_log,
|
||||
recff_math_degrad,
|
||||
recff_math_atan2,
|
||||
recff_math_pow,
|
||||
recff_math_ldexp,
|
||||
recff_math_minmax,
|
||||
recff_math_random,
|
||||
recff_bit_unary,
|
||||
recff_bit_shift,
|
||||
recff_bit_nary,
|
||||
recff_string_len,
|
||||
recff_string_range,
|
||||
recff_table_getn,
|
||||
recff_table_insert,
|
||||
recff_table_remove,
|
||||
recff_io_write,
|
||||
recff_io_flush,
|
||||
recff_cdata_index,
|
||||
recff_cdata_arith,
|
||||
recff_cdata_call,
|
||||
recff_clib_index,
|
||||
recff_ffi_new,
|
||||
recff_ffi_typeof,
|
||||
recff_ffi_istype,
|
||||
recff_ffi_xof,
|
||||
recff_ffi_errno,
|
||||
recff_ffi_string,
|
||||
recff_ffi_copy,
|
||||
recff_ffi_fill,
|
||||
recff_ffi_abi,
|
||||
recff_ffi_gc
|
||||
};
|
||||
|
||||
@@ -1,339 +0,0 @@
|
||||
/*
|
||||
** String handling.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
**
|
||||
** Portions taken verbatim or adapted from the Lua interpreter.
|
||||
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define lj_str_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_gc.h"
|
||||
#include "lj_err.h"
|
||||
#include "lj_str.h"
|
||||
#include "lj_state.h"
|
||||
#include "lj_char.h"
|
||||
|
||||
/* -- String interning ---------------------------------------------------- */
|
||||
|
||||
/* Ordered compare of strings. Assumes string data is 4-byte aligned. */
|
||||
int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b)
|
||||
{
|
||||
MSize i, n = a->len > b->len ? b->len : a->len;
|
||||
for (i = 0; i < n; i += 4) {
|
||||
/* Note: innocuous access up to end of string + 3. */
|
||||
uint32_t va = *(const uint32_t *)(strdata(a)+i);
|
||||
uint32_t vb = *(const uint32_t *)(strdata(b)+i);
|
||||
if (va != vb) {
|
||||
#if LJ_LE
|
||||
va = lj_bswap(va); vb = lj_bswap(vb);
|
||||
#endif
|
||||
i -= n;
|
||||
if ((int32_t)i >= -3) {
|
||||
va >>= 32+(i<<3); vb >>= 32+(i<<3);
|
||||
if (va == vb) break;
|
||||
}
|
||||
return va < vb ? -1 : 1;
|
||||
}
|
||||
}
|
||||
return (int32_t)(a->len - b->len);
|
||||
}
|
||||
|
||||
/* Fast string data comparison. Caveat: unaligned access to 1st string! */
|
||||
static LJ_AINLINE int str_fastcmp(const char *a, const char *b, MSize len)
|
||||
{
|
||||
MSize i = 0;
|
||||
lua_assert(len > 0);
|
||||
lua_assert((((uintptr_t)a + len) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4);
|
||||
do { /* Note: innocuous access up to end of string + 3. */
|
||||
uint32_t v = lj_getu32(a+i) ^ *(const uint32_t *)(b+i);
|
||||
if (v) {
|
||||
i -= len;
|
||||
#if LJ_LE
|
||||
return (int32_t)i >= -3 ? (v << (32+(i<<3))) : 1;
|
||||
#else
|
||||
return (int32_t)i >= -3 ? (v >> (32+(i<<3))) : 1;
|
||||
#endif
|
||||
}
|
||||
i += 4;
|
||||
} while (i < len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Resize the string hash table (grow and shrink). */
|
||||
void lj_str_resize(lua_State *L, MSize newmask)
|
||||
{
|
||||
global_State *g = G(L);
|
||||
GCRef *newhash;
|
||||
MSize i;
|
||||
if (g->gc.state == GCSsweepstring || newmask >= LJ_MAX_STRTAB-1)
|
||||
return; /* No resizing during GC traversal or if already too big. */
|
||||
newhash = lj_mem_newvec(L, newmask+1, GCRef);
|
||||
memset(newhash, 0, (newmask+1)*sizeof(GCRef));
|
||||
for (i = g->strmask; i != ~(MSize)0; i--) { /* Rehash old table. */
|
||||
GCobj *p = gcref(g->strhash[i]);
|
||||
while (p) { /* Follow each hash chain and reinsert all strings. */
|
||||
MSize h = gco2str(p)->hash & newmask;
|
||||
GCobj *next = gcnext(p);
|
||||
/* NOBARRIER: The string table is a GC root. */
|
||||
setgcrefr(p->gch.nextgc, newhash[h]);
|
||||
setgcref(newhash[h], p);
|
||||
p = next;
|
||||
}
|
||||
}
|
||||
lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
|
||||
g->strmask = newmask;
|
||||
g->strhash = newhash;
|
||||
}
|
||||
|
||||
/* Intern a string and return string object. */
|
||||
GCstr *lj_str_new(lua_State *L, const char *str, size_t lenx)
|
||||
{
|
||||
global_State *g;
|
||||
GCstr *s;
|
||||
GCobj *o;
|
||||
MSize len = (MSize)lenx;
|
||||
MSize a, b, h = len;
|
||||
if (lenx >= LJ_MAX_STR)
|
||||
lj_err_msg(L, LJ_ERR_STROV);
|
||||
g = G(L);
|
||||
/* Compute string hash. Constants taken from lookup3 hash by Bob Jenkins. */
|
||||
if (len >= 4) { /* Caveat: unaligned access! */
|
||||
a = lj_getu32(str);
|
||||
h ^= lj_getu32(str+len-4);
|
||||
b = lj_getu32(str+(len>>1)-2);
|
||||
h ^= b; h -= lj_rol(b, 14);
|
||||
b += lj_getu32(str+(len>>2)-1);
|
||||
} else if (len > 0) {
|
||||
a = *(const uint8_t *)str;
|
||||
h ^= *(const uint8_t *)(str+len-1);
|
||||
b = *(const uint8_t *)(str+(len>>1));
|
||||
h ^= b; h -= lj_rol(b, 14);
|
||||
} else {
|
||||
return &g->strempty;
|
||||
}
|
||||
a ^= h; a -= lj_rol(h, 11);
|
||||
b ^= a; b -= lj_rol(a, 25);
|
||||
h ^= b; h -= lj_rol(b, 16);
|
||||
/* Check if the string has already been interned. */
|
||||
o = gcref(g->strhash[h & g->strmask]);
|
||||
if (LJ_LIKELY((((uintptr_t)str + len) & (LJ_PAGESIZE-1)) <= LJ_PAGESIZE-4)) {
|
||||
while (o != NULL) {
|
||||
GCstr *sx = gco2str(o);
|
||||
if (sx->len == len && str_fastcmp(str, strdata(sx), len) == 0) {
|
||||
/* Resurrect if dead. Can only happen with fixstring() (keywords). */
|
||||
if (isdead(g, o)) flipwhite(o);
|
||||
return sx; /* Return existing string. */
|
||||
}
|
||||
o = gcnext(o);
|
||||
}
|
||||
} else { /* Slow path: end of string is too close to a page boundary. */
|
||||
while (o != NULL) {
|
||||
GCstr *sx = gco2str(o);
|
||||
if (sx->len == len && memcmp(str, strdata(sx), len) == 0) {
|
||||
/* Resurrect if dead. Can only happen with fixstring() (keywords). */
|
||||
if (isdead(g, o)) flipwhite(o);
|
||||
return sx; /* Return existing string. */
|
||||
}
|
||||
o = gcnext(o);
|
||||
}
|
||||
}
|
||||
/* Nope, create a new string. */
|
||||
s = lj_mem_newt(L, sizeof(GCstr)+len+1, GCstr);
|
||||
newwhite(g, s);
|
||||
s->gct = ~LJ_TSTR;
|
||||
s->len = len;
|
||||
s->hash = h;
|
||||
s->reserved = 0;
|
||||
memcpy(strdatawr(s), str, len);
|
||||
strdatawr(s)[len] = '\0'; /* Zero-terminate string. */
|
||||
/* Add it to string hash table. */
|
||||
h &= g->strmask;
|
||||
s->nextgc = g->strhash[h];
|
||||
/* NOBARRIER: The string table is a GC root. */
|
||||
setgcref(g->strhash[h], obj2gco(s));
|
||||
if (g->strnum++ > g->strmask) /* Allow a 100% load factor. */
|
||||
lj_str_resize(L, (g->strmask<<1)+1); /* Grow string table. */
|
||||
return s; /* Return newly interned string. */
|
||||
}
|
||||
|
||||
void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s)
|
||||
{
|
||||
g->strnum--;
|
||||
lj_mem_free(g, s, sizestring(s));
|
||||
}
|
||||
|
||||
/* -- Type conversions ---------------------------------------------------- */
|
||||
|
||||
/* Print number to buffer. Canonicalizes non-finite values. */
|
||||
size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o)
|
||||
{
|
||||
if (LJ_LIKELY((o->u32.hi << 1) < 0xffe00000)) { /* Finite? */
|
||||
lua_Number n = o->n;
|
||||
#if __BIONIC__
|
||||
if (tvismzero(o)) { s[0] = '-'; s[1] = '0'; return 2; }
|
||||
#endif
|
||||
return (size_t)lua_number2str(s, n);
|
||||
} else if (((o->u32.hi & 0x000fffff) | o->u32.lo) != 0) {
|
||||
s[0] = 'n'; s[1] = 'a'; s[2] = 'n'; return 3;
|
||||
} else if ((o->u32.hi & 0x80000000) == 0) {
|
||||
s[0] = 'i'; s[1] = 'n'; s[2] = 'f'; return 3;
|
||||
} else {
|
||||
s[0] = '-'; s[1] = 'i'; s[2] = 'n'; s[3] = 'f'; return 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Print integer to buffer. Returns pointer to start. */
|
||||
char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k)
|
||||
{
|
||||
uint32_t u = (uint32_t)(k < 0 ? -k : k);
|
||||
p += 1+10;
|
||||
do { *--p = (char)('0' + u % 10); } while (u /= 10);
|
||||
if (k < 0) *--p = '-';
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Convert number to string. */
|
||||
GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np)
|
||||
{
|
||||
char buf[LJ_STR_NUMBUF];
|
||||
size_t len = lj_str_bufnum(buf, (TValue *)np);
|
||||
return lj_str_new(L, buf, len);
|
||||
}
|
||||
|
||||
/* Convert integer to string. */
|
||||
GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k)
|
||||
{
|
||||
char s[1+10];
|
||||
char *p = lj_str_bufint(s, k);
|
||||
return lj_str_new(L, p, (size_t)(s+sizeof(s)-p));
|
||||
}
|
||||
|
||||
GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o)
|
||||
{
|
||||
return tvisint(o) ? lj_str_fromint(L, intV(o)) : lj_str_fromnum(L, &o->n);
|
||||
}
|
||||
|
||||
/* -- String formatting --------------------------------------------------- */
|
||||
|
||||
static void addstr(lua_State *L, SBuf *sb, const char *str, MSize len)
|
||||
{
|
||||
char *p;
|
||||
MSize i;
|
||||
if (sb->n + len > sb->sz) {
|
||||
MSize sz = sb->sz * 2;
|
||||
while (sb->n + len > sz) sz = sz * 2;
|
||||
lj_str_resizebuf(L, sb, sz);
|
||||
}
|
||||
p = sb->buf + sb->n;
|
||||
sb->n += len;
|
||||
for (i = 0; i < len; i++) p[i] = str[i];
|
||||
}
|
||||
|
||||
static void addchar(lua_State *L, SBuf *sb, int c)
|
||||
{
|
||||
if (sb->n + 1 > sb->sz) {
|
||||
MSize sz = sb->sz * 2;
|
||||
lj_str_resizebuf(L, sb, sz);
|
||||
}
|
||||
sb->buf[sb->n++] = (char)c;
|
||||
}
|
||||
|
||||
/* Push formatted message as a string object to Lua stack. va_list variant. */
|
||||
const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp)
|
||||
{
|
||||
SBuf *sb = &G(L)->tmpbuf;
|
||||
lj_str_needbuf(L, sb, (MSize)strlen(fmt));
|
||||
lj_str_resetbuf(sb);
|
||||
for (;;) {
|
||||
const char *e = strchr(fmt, '%');
|
||||
if (e == NULL) break;
|
||||
addstr(L, sb, fmt, (MSize)(e-fmt));
|
||||
/* This function only handles %s, %c, %d, %f and %p formats. */
|
||||
switch (e[1]) {
|
||||
case 's': {
|
||||
const char *s = va_arg(argp, char *);
|
||||
if (s == NULL) s = "(null)";
|
||||
addstr(L, sb, s, (MSize)strlen(s));
|
||||
break;
|
||||
}
|
||||
case 'c':
|
||||
addchar(L, sb, va_arg(argp, int));
|
||||
break;
|
||||
case 'd': {
|
||||
char buf[LJ_STR_INTBUF];
|
||||
char *p = lj_str_bufint(buf, va_arg(argp, int32_t));
|
||||
addstr(L, sb, p, (MSize)(buf+LJ_STR_INTBUF-p));
|
||||
break;
|
||||
}
|
||||
case 'f': {
|
||||
char buf[LJ_STR_NUMBUF];
|
||||
TValue tv;
|
||||
MSize len;
|
||||
tv.n = (lua_Number)(va_arg(argp, LUAI_UACNUMBER));
|
||||
len = (MSize)lj_str_bufnum(buf, &tv);
|
||||
addstr(L, sb, buf, len);
|
||||
break;
|
||||
}
|
||||
case 'p': {
|
||||
#define FMTP_CHARS (2*sizeof(ptrdiff_t))
|
||||
char buf[2+FMTP_CHARS];
|
||||
ptrdiff_t p = (ptrdiff_t)(va_arg(argp, void *));
|
||||
ptrdiff_t i, lasti = 2+FMTP_CHARS;
|
||||
if (p == 0) {
|
||||
addstr(L, sb, "NULL", 4);
|
||||
break;
|
||||
}
|
||||
#if LJ_64
|
||||
/* Shorten output for 64 bit pointers. */
|
||||
lasti = 2+2*4+((p >> 32) ? 2+2*(lj_fls((uint32_t)(p >> 32))>>3) : 0);
|
||||
#endif
|
||||
buf[0] = '0';
|
||||
buf[1] = 'x';
|
||||
for (i = lasti-1; i >= 2; i--, p >>= 4)
|
||||
buf[i] = "0123456789abcdef"[(p & 15)];
|
||||
addstr(L, sb, buf, (MSize)lasti);
|
||||
break;
|
||||
}
|
||||
case '%':
|
||||
addchar(L, sb, '%');
|
||||
break;
|
||||
default:
|
||||
addchar(L, sb, '%');
|
||||
addchar(L, sb, e[1]);
|
||||
break;
|
||||
}
|
||||
fmt = e+2;
|
||||
}
|
||||
addstr(L, sb, fmt, (MSize)strlen(fmt));
|
||||
setstrV(L, L->top, lj_str_new(L, sb->buf, sb->n));
|
||||
incr_top(L);
|
||||
return strVdata(L->top - 1);
|
||||
}
|
||||
|
||||
/* Push formatted message as a string object to Lua stack. Vararg variant. */
|
||||
const char *lj_str_pushf(lua_State *L, const char *fmt, ...)
|
||||
{
|
||||
const char *msg;
|
||||
va_list argp;
|
||||
va_start(argp, fmt);
|
||||
msg = lj_str_pushvf(L, fmt, argp);
|
||||
va_end(argp);
|
||||
return msg;
|
||||
}
|
||||
|
||||
/* -- Buffer handling ----------------------------------------------------- */
|
||||
|
||||
char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz)
|
||||
{
|
||||
if (sz > sb->sz) {
|
||||
if (sz < LJ_MIN_SBUF) sz = LJ_MIN_SBUF;
|
||||
lj_str_resizebuf(L, sb, sz);
|
||||
}
|
||||
return sb->buf;
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
** String handling.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#ifndef _LJ_STR_H
|
||||
#define _LJ_STR_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "lj_obj.h"
|
||||
|
||||
/* String interning. */
|
||||
LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b);
|
||||
LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask);
|
||||
LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len);
|
||||
LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s);
|
||||
|
||||
#define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s)))
|
||||
#define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1))
|
||||
|
||||
/* Type conversions. */
|
||||
LJ_FUNC size_t LJ_FASTCALL lj_str_bufnum(char *s, cTValue *o);
|
||||
LJ_FUNC char * LJ_FASTCALL lj_str_bufint(char *p, int32_t k);
|
||||
LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnum(lua_State *L, const lua_Number *np);
|
||||
LJ_FUNC GCstr * LJ_FASTCALL lj_str_fromint(lua_State *L, int32_t k);
|
||||
LJ_FUNCA GCstr * LJ_FASTCALL lj_str_fromnumber(lua_State *L, cTValue *o);
|
||||
|
||||
#define LJ_STR_INTBUF (1+10)
|
||||
#define LJ_STR_NUMBUF LUAI_MAXNUMBER2STR
|
||||
|
||||
/* String formatting. */
|
||||
LJ_FUNC const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp);
|
||||
LJ_FUNC const char *lj_str_pushf(lua_State *L, const char *fmt, ...)
|
||||
#if defined(__GNUC__)
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/* Resizable string buffers. Struct definition in lj_obj.h. */
|
||||
LJ_FUNC char *lj_str_needbuf(lua_State *L, SBuf *sb, MSize sz);
|
||||
|
||||
#define lj_str_initbuf(sb) ((sb)->buf = NULL, (sb)->sz = 0)
|
||||
#define lj_str_resetbuf(sb) ((sb)->n = 0)
|
||||
#define lj_str_resizebuf(L, sb, size) \
|
||||
((sb)->buf = (char *)lj_mem_realloc(L, (sb)->buf, (sb)->sz, (size)), \
|
||||
(sb)->sz = (size))
|
||||
#define lj_str_freebuf(g, sb) lj_mem_free(g, (void *)(sb)->buf, (sb)->sz)
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
** Math helper functions for assembler VM.
|
||||
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
|
||||
*/
|
||||
|
||||
#define lj_vmmath_c
|
||||
#define LUA_CORE
|
||||
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "lj_obj.h"
|
||||
#include "lj_ir.h"
|
||||
#include "lj_vm.h"
|
||||
|
||||
/* -- Helper functions for generated machine code ------------------------- */
|
||||
|
||||
#if LJ_TARGET_X86ORX64
|
||||
/* Wrapper functions to avoid linker issues on OSX. */
|
||||
LJ_FUNCA double lj_vm_sinh(double x) { return sinh(x); }
|
||||
LJ_FUNCA double lj_vm_cosh(double x) { return cosh(x); }
|
||||
LJ_FUNCA double lj_vm_tanh(double x) { return tanh(x); }
|
||||
#endif
|
||||
|
||||
#if !LJ_TARGET_X86ORX64
|
||||
double lj_vm_foldarith(double x, double y, int op)
|
||||
{
|
||||
switch (op) {
|
||||
case IR_ADD - IR_ADD: return x+y; break;
|
||||
case IR_SUB - IR_ADD: return x-y; break;
|
||||
case IR_MUL - IR_ADD: return x*y; break;
|
||||
case IR_DIV - IR_ADD: return x/y; break;
|
||||
case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break;
|
||||
case IR_POW - IR_ADD: return pow(x, y); break;
|
||||
case IR_NEG - IR_ADD: return -x; break;
|
||||
case IR_ABS - IR_ADD: return fabs(x); break;
|
||||
#if LJ_HASJIT
|
||||
case IR_ATAN2 - IR_ADD: return atan2(x, y); break;
|
||||
case IR_LDEXP - IR_ADD: return ldexp(x, (int)y); break;
|
||||
case IR_MIN - IR_ADD: return x > y ? y : x; break;
|
||||
case IR_MAX - IR_ADD: return x < y ? y : x; break;
|
||||
#endif
|
||||
default: return x;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LJ_HASJIT
|
||||
|
||||
#ifdef LUAJIT_NO_LOG2
|
||||
double lj_vm_log2(double a)
|
||||
{
|
||||
return log(a) * 1.4426950408889634074;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LUAJIT_NO_EXP2
|
||||
double lj_vm_exp2(double a)
|
||||
{
|
||||
return exp(a * 0.6931471805599453);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(LJ_TARGET_ARM || LJ_TARGET_PPC)
|
||||
int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b)
|
||||
{
|
||||
uint32_t y, ua, ub;
|
||||
lua_assert(b != 0); /* This must be checked before using this function. */
|
||||
ua = a < 0 ? (uint32_t)-a : (uint32_t)a;
|
||||
ub = b < 0 ? (uint32_t)-b : (uint32_t)b;
|
||||
y = ua % ub;
|
||||
if (y != 0 && (a^b) < 0) y = y - ub;
|
||||
if (((int32_t)y^b) < 0) y = (uint32_t)-(int32_t)y;
|
||||
return (int32_t)y;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !LJ_TARGET_X86ORX64
|
||||
/* Unsigned x^k. */
|
||||
static double lj_vm_powui(double x, uint32_t k)
|
||||
{
|
||||
double y;
|
||||
lua_assert(k != 0);
|
||||
for (; (k & 1) == 0; k >>= 1) x *= x;
|
||||
y = x;
|
||||
if ((k >>= 1) != 0) {
|
||||
for (;;) {
|
||||
x *= x;
|
||||
if (k == 1) break;
|
||||
if (k & 1) y *= x;
|
||||
k >>= 1;
|
||||
}
|
||||
y *= x;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
/* Signed x^k. */
|
||||
double lj_vm_powi(double x, int32_t k)
|
||||
{
|
||||
if (k > 1)
|
||||
return lj_vm_powui(x, (uint32_t)k);
|
||||
else if (k == 1)
|
||||
return x;
|
||||
else if (k == 0)
|
||||
return 1.0;
|
||||
else
|
||||
return 1.0 / lj_vm_powui(x, (uint32_t)-k);
|
||||
}
|
||||
|
||||
/* Computes fpm(x) for extended math functions. */
|
||||
double lj_vm_foldfpm(double x, int fpm)
|
||||
{
|
||||
switch (fpm) {
|
||||
case IRFPM_FLOOR: return lj_vm_floor(x);
|
||||
case IRFPM_CEIL: return lj_vm_ceil(x);
|
||||
case IRFPM_TRUNC: return lj_vm_trunc(x);
|
||||
case IRFPM_SQRT: return sqrt(x);
|
||||
case IRFPM_EXP: return exp(x);
|
||||
case IRFPM_EXP2: return lj_vm_exp2(x);
|
||||
case IRFPM_LOG: return log(x);
|
||||
case IRFPM_LOG2: return lj_vm_log2(x);
|
||||
case IRFPM_LOG10: return log10(x);
|
||||
case IRFPM_SIN: return sin(x);
|
||||
case IRFPM_COS: return cos(x);
|
||||
case IRFPM_TAN: return tan(x);
|
||||
default: lua_assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LJ_HASFFI
|
||||
int lj_vm_errno(void)
|
||||
{
|
||||
return errno;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,393 +0,0 @@
|
||||
/*
|
||||
** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
|
||||
** Lua - An Extensible Extension Language
|
||||
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
|
||||
** See Copyright Notice at the end of this file
|
||||
*/
|
||||
|
||||
|
||||
#ifndef lua_h
|
||||
#define lua_h
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
#include "luaconf.h"
|
||||
|
||||
|
||||
#define LUA_VERSION "Lua 5.1"
|
||||
#define LUA_RELEASE "Lua 5.1.4"
|
||||
#define LUA_VERSION_NUM 501
|
||||
#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
|
||||
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
|
||||
|
||||
|
||||
/* mark for precompiled code (`<esc>Lua') */
|
||||
#define LUA_SIGNATURE "\033Lua"
|
||||
|
||||
/* option for multiple returns in `lua_pcall' and `lua_call' */
|
||||
#define LUA_MULTRET (-1)
|
||||
|
||||
|
||||
/*
|
||||
** pseudo-indices
|
||||
*/
|
||||
#define LUA_REGISTRYINDEX (-10000)
|
||||
#define LUA_ENVIRONINDEX (-10001)
|
||||
#define LUA_GLOBALSINDEX (-10002)
|
||||
#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
|
||||
|
||||
|
||||
/* thread status; 0 is OK */
|
||||
#define LUA_YIELD 1
|
||||
#define LUA_ERRRUN 2
|
||||
#define LUA_ERRSYNTAX 3
|
||||
#define LUA_ERRMEM 4
|
||||
#define LUA_ERRERR 5
|
||||
|
||||
|
||||
typedef struct lua_State lua_State;
|
||||
|
||||
typedef int (*lua_CFunction) (lua_State *L);
|
||||
|
||||
|
||||
/*
|
||||
** functions that read/write blocks when loading/dumping Lua chunks
|
||||
*/
|
||||
typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
|
||||
|
||||
typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
|
||||
|
||||
|
||||
/*
|
||||
** prototype for memory-allocation functions
|
||||
*/
|
||||
typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
|
||||
|
||||
|
||||
/*
|
||||
** basic types
|
||||
*/
|
||||
#define LUA_TNONE (-1)
|
||||
|
||||
#define LUA_TNIL 0
|
||||
#define LUA_TBOOLEAN 1
|
||||
#define LUA_TLIGHTUSERDATA 2
|
||||
#define LUA_TNUMBER 3
|
||||
#define LUA_TSTRING 4
|
||||
#define LUA_TTABLE 5
|
||||
#define LUA_TFUNCTION 6
|
||||
#define LUA_TUSERDATA 7
|
||||
#define LUA_TTHREAD 8
|
||||
|
||||
|
||||
|
||||
/* minimum Lua stack available to a C function */
|
||||
#define LUA_MINSTACK 20
|
||||
|
||||
|
||||
/*
|
||||
** generic extra include file
|
||||
*/
|
||||
#if defined(LUA_USER_H)
|
||||
#include LUA_USER_H
|
||||
#endif
|
||||
|
||||
|
||||
/* type of numbers in Lua */
|
||||
typedef LUA_NUMBER lua_Number;
|
||||
|
||||
|
||||
/* type for integer functions */
|
||||
typedef LUA_INTEGER lua_Integer;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** state manipulation
|
||||
*/
|
||||
LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
|
||||
LUA_API void (lua_close) (lua_State *L);
|
||||
LUA_API lua_State *(lua_newthread) (lua_State *L);
|
||||
|
||||
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
|
||||
|
||||
|
||||
/*
|
||||
** basic stack manipulation
|
||||
*/
|
||||
LUA_API int (lua_gettop) (lua_State *L);
|
||||
LUA_API void (lua_settop) (lua_State *L, int idx);
|
||||
LUA_API void (lua_pushvalue) (lua_State *L, int idx);
|
||||
LUA_API void (lua_remove) (lua_State *L, int idx);
|
||||
LUA_API void (lua_insert) (lua_State *L, int idx);
|
||||
LUA_API void (lua_replace) (lua_State *L, int idx);
|
||||
LUA_API int (lua_checkstack) (lua_State *L, int sz);
|
||||
|
||||
LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
|
||||
|
||||
|
||||
/*
|
||||
** access functions (stack -> C)
|
||||
*/
|
||||
|
||||
LUA_API int (lua_isnumber) (lua_State *L, int idx);
|
||||
LUA_API int (lua_isstring) (lua_State *L, int idx);
|
||||
LUA_API int (lua_iscfunction) (lua_State *L, int idx);
|
||||
LUA_API int (lua_isuserdata) (lua_State *L, int idx);
|
||||
LUA_API int (lua_type) (lua_State *L, int idx);
|
||||
LUA_API const char *(lua_typename) (lua_State *L, int tp);
|
||||
|
||||
LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
|
||||
LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
|
||||
LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
|
||||
|
||||
LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
|
||||
LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
|
||||
LUA_API int (lua_toboolean) (lua_State *L, int idx);
|
||||
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
|
||||
LUA_API size_t (lua_objlen) (lua_State *L, int idx);
|
||||
LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
|
||||
LUA_API void *(lua_touserdata) (lua_State *L, int idx);
|
||||
LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
|
||||
LUA_API const void *(lua_topointer) (lua_State *L, int idx);
|
||||
|
||||
|
||||
/*
|
||||
** push functions (C -> stack)
|
||||
*/
|
||||
LUA_API void (lua_pushnil) (lua_State *L);
|
||||
LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
|
||||
LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
|
||||
LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l);
|
||||
LUA_API void (lua_pushstring) (lua_State *L, const char *s);
|
||||
LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
|
||||
va_list argp);
|
||||
LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
|
||||
LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
|
||||
LUA_API void (lua_pushboolean) (lua_State *L, int b);
|
||||
LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
|
||||
LUA_API int (lua_pushthread) (lua_State *L);
|
||||
|
||||
|
||||
/*
|
||||
** get functions (Lua -> stack)
|
||||
*/
|
||||
LUA_API void (lua_gettable) (lua_State *L, int idx);
|
||||
LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
|
||||
LUA_API void (lua_rawget) (lua_State *L, int idx);
|
||||
LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
|
||||
LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
|
||||
LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
|
||||
LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
|
||||
LUA_API void (lua_getfenv) (lua_State *L, int idx);
|
||||
|
||||
|
||||
/*
|
||||
** set functions (stack -> Lua)
|
||||
*/
|
||||
LUA_API void (lua_settable) (lua_State *L, int idx);
|
||||
LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
|
||||
LUA_API void (lua_rawset) (lua_State *L, int idx);
|
||||
LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
|
||||
LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
|
||||
LUA_API int (lua_setfenv) (lua_State *L, int idx);
|
||||
|
||||
|
||||
/*
|
||||
** `load' and `call' functions (load and run Lua code)
|
||||
*/
|
||||
LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
|
||||
LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
|
||||
LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
|
||||
LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
|
||||
const char *chunkname);
|
||||
|
||||
LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
|
||||
|
||||
|
||||
/*
|
||||
** coroutine functions
|
||||
*/
|
||||
LUA_API int (lua_yield) (lua_State *L, int nresults);
|
||||
LUA_API int (lua_resume) (lua_State *L, int narg);
|
||||
LUA_API int (lua_status) (lua_State *L);
|
||||
|
||||
/*
|
||||
** garbage-collection function and options
|
||||
*/
|
||||
|
||||
#define LUA_GCSTOP 0
|
||||
#define LUA_GCRESTART 1
|
||||
#define LUA_GCCOLLECT 2
|
||||
#define LUA_GCCOUNT 3
|
||||
#define LUA_GCCOUNTB 4
|
||||
#define LUA_GCSTEP 5
|
||||
#define LUA_GCSETPAUSE 6
|
||||
#define LUA_GCSETSTEPMUL 7
|
||||
|
||||
LUA_API int (lua_gc) (lua_State *L, int what, int data);
|
||||
|
||||
|
||||
/*
|
||||
** miscellaneous functions
|
||||
*/
|
||||
|
||||
LUA_API int (lua_error) (lua_State *L);
|
||||
|
||||
LUA_API int (lua_next) (lua_State *L, int idx);
|
||||
|
||||
LUA_API void (lua_concat) (lua_State *L, int n);
|
||||
|
||||
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
|
||||
LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** ===============================================================
|
||||
** some useful macros
|
||||
** ===============================================================
|
||||
*/
|
||||
|
||||
#define lua_pop(L,n) lua_settop(L, -(n)-1)
|
||||
|
||||
#define lua_newtable(L) lua_createtable(L, 0, 0)
|
||||
|
||||
#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
|
||||
|
||||
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
|
||||
|
||||
#define lua_strlen(L,i) lua_objlen(L, (i))
|
||||
|
||||
#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
|
||||
#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
|
||||
#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
|
||||
#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
|
||||
#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
|
||||
#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
|
||||
#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
|
||||
#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
|
||||
|
||||
#define lua_pushliteral(L, s) \
|
||||
lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
|
||||
|
||||
#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
|
||||
#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
|
||||
|
||||
#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** compatibility macros and functions
|
||||
*/
|
||||
|
||||
#define lua_open() luaL_newstate()
|
||||
|
||||
#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
|
||||
|
||||
#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
|
||||
|
||||
#define lua_Chunkreader lua_Reader
|
||||
#define lua_Chunkwriter lua_Writer
|
||||
|
||||
|
||||
/* hack */
|
||||
LUA_API void lua_setlevel (lua_State *from, lua_State *to);
|
||||
|
||||
|
||||
/*
|
||||
** {======================================================================
|
||||
** Debug API
|
||||
** =======================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
** Event codes
|
||||
*/
|
||||
#define LUA_HOOKCALL 0
|
||||
#define LUA_HOOKRET 1
|
||||
#define LUA_HOOKLINE 2
|
||||
#define LUA_HOOKCOUNT 3
|
||||
#define LUA_HOOKTAILRET 4
|
||||
|
||||
|
||||
/*
|
||||
** Event masks
|
||||
*/
|
||||
#define LUA_MASKCALL (1 << LUA_HOOKCALL)
|
||||
#define LUA_MASKRET (1 << LUA_HOOKRET)
|
||||
#define LUA_MASKLINE (1 << LUA_HOOKLINE)
|
||||
#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
|
||||
|
||||
typedef struct lua_Debug lua_Debug; /* activation record */
|
||||
|
||||
|
||||
/* Functions to be called by the debuger in specific events */
|
||||
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
|
||||
|
||||
|
||||
LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
|
||||
LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
|
||||
LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
|
||||
LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
|
||||
LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
|
||||
LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
|
||||
LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
|
||||
LUA_API lua_Hook lua_gethook (lua_State *L);
|
||||
LUA_API int lua_gethookmask (lua_State *L);
|
||||
LUA_API int lua_gethookcount (lua_State *L);
|
||||
|
||||
/* From Lua 5.2. */
|
||||
LUA_API void *lua_upvalueid (lua_State *L, int idx, int n);
|
||||
LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2);
|
||||
LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt,
|
||||
const char *chunkname, const char *mode);
|
||||
|
||||
|
||||
struct lua_Debug {
|
||||
int event;
|
||||
const char *name; /* (n) */
|
||||
const char *namewhat; /* (n) `global', `local', `field', `method' */
|
||||
const char *what; /* (S) `Lua', `C', `main', `tail' */
|
||||
const char *source; /* (S) */
|
||||
int currentline; /* (l) */
|
||||
int nups; /* (u) number of upvalues */
|
||||
int linedefined; /* (S) */
|
||||
int lastlinedefined; /* (S) */
|
||||
char short_src[LUA_IDSIZE]; /* (S) */
|
||||
/* private part */
|
||||
int i_ci; /* active function */
|
||||
};
|
||||
|
||||
/* }====================================================================== */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@@ -1,68 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
###########################
|
||||
#
|
||||
# SDL shared library
|
||||
#
|
||||
###########################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := SDL2
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(subst $(LOCAL_PATH)/,, \
|
||||
$(wildcard $(LOCAL_PATH)/src/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
|
||||
$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
|
||||
$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
|
||||
$(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/dynapi/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/events/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/file/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/filesystem/dummy/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/render/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/video/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/video/android/*.c))
|
||||
|
||||
LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
|
||||
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
###########################
|
||||
#
|
||||
# SDL static library
|
||||
#
|
||||
###########################
|
||||
|
||||
LOCAL_MODULE := SDL2_static
|
||||
|
||||
LOCAL_MODULE_FILENAME := libSDL2
|
||||
|
||||
LOCAL_SRC_FILES += $(LOCAL_PATH)/src/main/android/SDL_android_main.c
|
||||
|
||||
LOCAL_LDLIBS :=
|
||||
LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
Bugs are now managed in the SDL bug tracker, here:
|
||||
|
||||
http://bugzilla.libsdl.org/
|
||||
|
||||
You may report bugs there, and search to see if a given issue has already
|
||||
been reported, discussed, and maybe even fixed.
|
||||
|
||||
|
||||
You may also find help on the SDL mailing list. Subscription information:
|
||||
|
||||
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
|
||||
|
||||
Bug reports are welcome here, but we really appreciate if you use Bugzilla, as
|
||||
bugs discussed on the mailing list may be forgotten or missed.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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:
|
||||
|
||||
1. 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.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
|
||||
To compile and install SDL:
|
||||
|
||||
1. Windows with Visual Studio:
|
||||
* Read VisualC.html
|
||||
|
||||
Windows with gcc, either native or cross-compiling:
|
||||
* Read the FAQ at http://wiki.libsdl.org/moin.fcg/FAQWindows
|
||||
* Run './configure; make; make install'
|
||||
|
||||
Mac OS X with Xcode:
|
||||
* Read README-macosx.txt
|
||||
|
||||
Mac OS X from the command line:
|
||||
* Run './configure; make; make install'
|
||||
|
||||
Linux and other UNIX systems:
|
||||
* Run './configure; make; make install'
|
||||
|
||||
Android:
|
||||
* Read README-android.txt
|
||||
|
||||
iOS:
|
||||
* Read README-ios.txt
|
||||
|
||||
Using Cmake:
|
||||
* Read README-cmake.txt
|
||||
|
||||
2. Look at the example programs in ./test, and check out the online
|
||||
documentation at http://wiki.libsdl.org/
|
||||
|
||||
3. Join the SDL developer mailing list by sending E-mail to
|
||||
sdl-request@libsdl.org
|
||||
and put "subscribe" in the subject of the message.
|
||||
|
||||
Or alternatively you can use the web interface:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
That's it!
|
||||
Sam Lantinga <slouken@libsdl.org>
|
||||
@@ -1,219 +0,0 @@
|
||||
# Makefile to build and install the SDL library
|
||||
|
||||
top_builddir = .
|
||||
srcdir = @srcdir@
|
||||
objects = build
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
includedir = @includedir@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
auxdir = @ac_aux_dir@
|
||||
distpath = $(srcdir)/..
|
||||
distdir = SDL2-@SDL_VERSION@
|
||||
distfile = $(distdir).tar.gz
|
||||
|
||||
@SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
CC = @CC@
|
||||
INCLUDE = @INCLUDE@
|
||||
CFLAGS = @BUILD_CFLAGS@
|
||||
EXTRA_CFLAGS = @EXTRA_CFLAGS@
|
||||
LDFLAGS = @BUILD_LDFLAGS@
|
||||
EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
INSTALL = @INSTALL@
|
||||
AR = @AR@
|
||||
RANLIB = @RANLIB@
|
||||
WINDRES = @WINDRES@
|
||||
|
||||
TARGET = libSDL2.la
|
||||
OBJECTS = @OBJECTS@
|
||||
VERSION_OBJECTS = @VERSION_OBJECTS@
|
||||
|
||||
SDLMAIN_TARGET = libSDL2main.a
|
||||
SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
|
||||
|
||||
SDLTEST_TARGET = libSDL2_test.a
|
||||
SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
|
||||
|
||||
SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake configure configure.in debian include Makefile.* sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in src test VisualC.html VisualC Xcode Xcode-iOS
|
||||
GEN_DIST = SDL2.spec
|
||||
|
||||
HDRS = \
|
||||
SDL.h \
|
||||
SDL_assert.h \
|
||||
SDL_atomic.h \
|
||||
SDL_audio.h \
|
||||
SDL_bits.h \
|
||||
SDL_blendmode.h \
|
||||
SDL_clipboard.h \
|
||||
SDL_cpuinfo.h \
|
||||
SDL_endian.h \
|
||||
SDL_error.h \
|
||||
SDL_events.h \
|
||||
SDL_filesystem.h \
|
||||
SDL_gamecontroller.h \
|
||||
SDL_gesture.h \
|
||||
SDL_haptic.h \
|
||||
SDL_hints.h \
|
||||
SDL_joystick.h \
|
||||
SDL_keyboard.h \
|
||||
SDL_keycode.h \
|
||||
SDL_loadso.h \
|
||||
SDL_log.h \
|
||||
SDL_main.h \
|
||||
SDL_messagebox.h \
|
||||
SDL_mouse.h \
|
||||
SDL_mutex.h \
|
||||
SDL_name.h \
|
||||
SDL_opengl.h \
|
||||
SDL_opengles.h \
|
||||
SDL_opengles2.h \
|
||||
SDL_pixels.h \
|
||||
SDL_platform.h \
|
||||
SDL_power.h \
|
||||
SDL_quit.h \
|
||||
SDL_rect.h \
|
||||
SDL_render.h \
|
||||
SDL_rwops.h \
|
||||
SDL_scancode.h \
|
||||
SDL_shape.h \
|
||||
SDL_stdinc.h \
|
||||
SDL_surface.h \
|
||||
SDL_system.h \
|
||||
SDL_syswm.h \
|
||||
SDL_thread.h \
|
||||
SDL_timer.h \
|
||||
SDL_touch.h \
|
||||
SDL_types.h \
|
||||
SDL_version.h \
|
||||
SDL_video.h \
|
||||
begin_code.h \
|
||||
close_code.h
|
||||
|
||||
SDLTEST_HDRS = $(shell ls $(srcdir)/include | fgrep SDL_test)
|
||||
|
||||
LT_AGE = @LT_AGE@
|
||||
LT_CURRENT = @LT_CURRENT@
|
||||
LT_RELEASE = @LT_RELEASE@
|
||||
LT_REVISION = @LT_REVISION@
|
||||
LT_LDFLAGS = -no-undefined -rpath $(DESTDIR)$(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
|
||||
|
||||
all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
|
||||
|
||||
$(srcdir)/configure: $(srcdir)/configure.in
|
||||
@echo "Warning, configure.in is out of date"
|
||||
#(cd $(srcdir) && sh autogen.sh && sh configure)
|
||||
@sleep 3
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in
|
||||
$(SHELL) config.status $@
|
||||
|
||||
Makefile.in:;
|
||||
|
||||
$(objects):
|
||||
$(SHELL) $(auxdir)/mkinstalldirs $@
|
||||
|
||||
update-revision:
|
||||
$(SHELL) $(auxdir)/updaterev.sh
|
||||
|
||||
.PHONY: all update-revision install install-bin install-hdrs install-lib install-data uninstall uninstall-bin uninstall-hdrs uninstall-lib uninstall-data clean distclean dist $(OBJECTS:.lo=.d)
|
||||
|
||||
$(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS)
|
||||
$(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS)
|
||||
|
||||
$(objects)/$(SDLMAIN_TARGET): $(SDLMAIN_OBJECTS)
|
||||
$(AR) cru $@ $(SDLMAIN_OBJECTS)
|
||||
$(RANLIB) $@
|
||||
|
||||
$(objects)/$(SDLTEST_TARGET): $(SDLTEST_OBJECTS)
|
||||
$(AR) cru $@ $(SDLTEST_OBJECTS)
|
||||
$(RANLIB) $@
|
||||
|
||||
install: all install-bin install-hdrs install-lib install-data
|
||||
install-bin:
|
||||
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 755 sdl2-config $(DESTDIR)$(bindir)/sdl2-config
|
||||
install-hdrs: update-revision
|
||||
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(includedir)/SDL2
|
||||
for file in $(HDRS) $(SDLTEST_HDRS); do \
|
||||
$(INSTALL) -m 644 $(srcdir)/include/$$file $(DESTDIR)$(includedir)/SDL2/$$file; \
|
||||
done
|
||||
$(INSTALL) -m 644 include/SDL_config.h $(DESTDIR)$(includedir)/SDL2/SDL_config.h
|
||||
if test -f include/SDL_revision.h; then \
|
||||
$(INSTALL) -m 644 include/SDL_revision.h $(DESTDIR)$(includedir)/SDL2/SDL_revision.h; \
|
||||
else \
|
||||
$(INSTALL) -m 644 $(srcdir)/include/SDL_revision.h $(DESTDIR)$(includedir)/SDL2/SDL_revision.h; \
|
||||
fi
|
||||
|
||||
install-lib: $(objects) $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)
|
||||
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)
|
||||
$(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(DESTDIR)$(libdir)/$(TARGET)
|
||||
$(INSTALL) -m 644 $(objects)/$(SDLMAIN_TARGET) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
|
||||
$(INSTALL) -m 644 $(objects)/$(SDLTEST_TARGET) $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
|
||||
install-data:
|
||||
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(datadir)/aclocal
|
||||
$(INSTALL) -m 644 $(srcdir)/sdl2.m4 $(DESTDIR)$(datadir)/aclocal/sdl2.m4
|
||||
$(SHELL) $(auxdir)/mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig
|
||||
$(INSTALL) -m 644 sdl2.pc $(DESTDIR)$(libdir)/pkgconfig
|
||||
|
||||
uninstall: uninstall-bin uninstall-hdrs uninstall-lib uninstall-data
|
||||
uninstall-bin:
|
||||
rm -f $(DESTDIR)$(bindir)/sdl2-config
|
||||
uninstall-hdrs:
|
||||
for file in $(HDRS) $(SDLTEST_HDRS); do \
|
||||
rm -f $(DESTDIR)$(includedir)/SDL2/$$file; \
|
||||
done
|
||||
rm -f $(DESTDIR)$(includedir)/SDL2/SDL_config.h
|
||||
rm -f $(DESTDIR)$(includedir)/SDL2/SDL_revision.h
|
||||
-rmdir $(DESTDIR)$(includedir)/SDL2
|
||||
uninstall-lib:
|
||||
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(TARGET)
|
||||
rm -f $(DESTDIR)$(libdir)/$(SDLMAIN_TARGET)
|
||||
rm -f $(DESTDIR)$(libdir)/$(SDLTEST_TARGET)
|
||||
uninstall-data:
|
||||
rm -f $(DESTDIR)$(datadir)/aclocal/sdl2.m4
|
||||
rm -f $(DESTDIR)$(libdir)/pkgconfig/sdl2.pc
|
||||
|
||||
clean:
|
||||
rm -rf $(objects)
|
||||
if test -f test/Makefile; then (cd test; $(MAKE) $@); fi
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile Makefile.rules sdl2-config
|
||||
rm -f config.status config.cache config.log libtool
|
||||
rm -rf $(srcdir)/autom4te*
|
||||
find $(srcdir) \( \
|
||||
-name '*~' -o \
|
||||
-name '*.bak' -o \
|
||||
-name '*.old' -o \
|
||||
-name '*.rej' -o \
|
||||
-name '*.orig' -o \
|
||||
-name '.#*' \) \
|
||||
-exec rm -f {} \;
|
||||
if test -f test/Makefile; then (cd test; $(MAKE) $@); fi
|
||||
|
||||
dist $(distfile):
|
||||
$(SHELL) $(auxdir)/mkinstalldirs $(distdir)
|
||||
(cd $(srcdir); tar cf - $(SRC_DIST)) | (cd $(distdir); tar xf -)
|
||||
tar cf - $(GEN_DIST) | (cd $(distdir); tar xf -)
|
||||
find $(distdir) \( \
|
||||
-name '*~' -o \
|
||||
-name '*.bak' -o \
|
||||
-name '*.old' -o \
|
||||
-name '*.rej' -o \
|
||||
-name '*.orig' -o \
|
||||
-name '.#*' \) \
|
||||
-exec rm -f {} \;
|
||||
if test -f $(distdir)/test/Makefile; then (cd $(distdir)/test && make distclean); fi
|
||||
(cd $(distdir); build-scripts/updaterev.sh)
|
||||
tar cvf - $(distdir) | gzip --best >$(distfile)
|
||||
rm -rf $(distdir)
|
||||
|
||||
rpm: $(distfile)
|
||||
rpmbuild -ta $?
|
||||
@@ -1,37 +0,0 @@
|
||||
# Makefile to build the pandora SDL library
|
||||
|
||||
AR = arm-none-linux-gnueabi-ar
|
||||
RANLIB = arm-none-linux-gnueabi-ranlib
|
||||
CC = arm-none-linux-gnueabi-gcc
|
||||
CXX = arm-none-linux-gnueabi-g++
|
||||
STRIP = arm-none-linux-gnueabi-strip
|
||||
|
||||
CFLAGS = -O3 -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=softfp \
|
||||
-mfpu=neon -ftree-vectorize -ffast-math -fomit-frame-pointer -fno-strict-aliasing -fsingle-precision-constant \
|
||||
-I./include -I$(PNDSDK)/usr/include -DSDL_REVISION=0
|
||||
|
||||
TARGET = libSDL.a
|
||||
|
||||
SOURCES = ./src/*.c ./src/audio/*.c ./src/cpuinfo/*.c ./src/events/*.c \
|
||||
./src/file/*.c ./src/stdlib/*.c ./src/thread/*.c ./src/timer/*.c ./src/video/*.c \
|
||||
./src/joystick/*.c ./src/haptic/*.c ./src/power/*.c ./src/video/dummy/*.c ./src/audio/disk/*.c \
|
||||
./src/audio/dummy/*.c ./src/loadso/dlopen/*.c ./src/audio/dsp/*.c \
|
||||
./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \
|
||||
./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \
|
||||
./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c \
|
||||
./src/atomic/linux/*.c ./src/filesystem/unix/*.c \
|
||||
./src/video/pandora/SDL_pandora.o ./src/video/pandora/SDL_pandora_events.o ./src/video/x11/*.c
|
||||
|
||||
|
||||
OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')
|
||||
|
||||
CONFIG_H = $(shell cp include/SDL_config_pandora.h include/SDL_config.h && touch include/SDL_revision.h)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(CONFIG_H) $(OBJECTS)
|
||||
$(AR) crv $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
||||
@@ -1,61 +0,0 @@
|
||||
# Makefile to build the pandora SDL library
|
||||
WIZSDK = /mythtv/media/devel/toolchains/openwiz/arm-openwiz-linux-gnu
|
||||
|
||||
AR = $(WIZSDK)/bin/arm-openwiz-linux-gnu-ar
|
||||
RANLIB = $(WIZSDK)/bin/arm-openwiz-linux-gnu-ranlib
|
||||
CC = $(WIZSDK)/bin/arm-openwiz-linux-gnu-gcc
|
||||
CXX = $(WIZSDK)/bin/arm-openwiz-linux-gnu-g++
|
||||
STRIP = $(WIZSDK)/bin/arm-openwiz-linux-gnu-strip
|
||||
|
||||
CFLAGS = -Wall -fPIC -I./include -I$(WIZSDK)/include -DWIZ_GLES_LITE
|
||||
|
||||
TARGET_STATIC = libSDL13.a
|
||||
TARGET_SHARED = libSDL13.so
|
||||
|
||||
SOURCES = ./src/*.c ./src/audio/*.c ./src/cdrom/*.c ./src/cpuinfo/*.c ./src/events/*.c \
|
||||
./src/file/*.c ./src/stdlib/*.c ./src/thread/*.c ./src/timer/*.c ./src/video/*.c \
|
||||
./src/joystick/*.c ./src/haptic/*.c ./src/video/dummy/*.c ./src/audio/disk/*.c \
|
||||
./src/audio/dummy/*.c ./src/loadso/dlopen/*.c ./src/audio/dsp/*.c \
|
||||
./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \
|
||||
./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \
|
||||
./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c ./src/cdrom/dummy/*.c \
|
||||
./src/video/pandora/SDL_pandora.o ./src/video/pandora/SDL_pandora_events.o
|
||||
|
||||
|
||||
OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')
|
||||
|
||||
all: config_copy $(TARGET_STATIC) $(TARGET_SHARED)
|
||||
|
||||
$(TARGET_STATIC): $(OBJECTS)
|
||||
$(AR) crv $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
$(TARGET_SHARED):
|
||||
$(CC) -shared -Wl,-soname,$(TARGET_SHARED).0 -o $(TARGET_SHARED).0.0.1 $(OBJECTS)
|
||||
ln -s $(TARGET_SHARED).0.0.1 $(TARGET_SHARED).0
|
||||
ln -s $(TARGET_SHARED).0 $(TARGET_SHARED)
|
||||
|
||||
config_copy:
|
||||
cp include/SDL_config_wiz.h include/SDL_config.h
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET_STATIC) $(TARGET_SHARED)* $(OBJECTS)
|
||||
|
||||
install:
|
||||
mkdir -p $(WIZSDK)/lib
|
||||
mkdir -p $(WIZSDK)/include/SDL13
|
||||
cp -f $(TARGET_STATIC) $(WIZSDK)/lib
|
||||
cp -f $(TARGET_SHARED).0.0.1 $(WIZSDK)/lib
|
||||
rm -f $(WIZSDK)/lib/$(TARGET_SHARED).0 $(WIZSDK)/lib/$(TARGET_SHARED)
|
||||
ln -s $(WIZSDK)/lib/$(TARGET_SHARED).0.0.1 $(WIZSDK)/lib/$(TARGET_SHARED).0
|
||||
ln -s $(WIZSDK)/lib/$(TARGET_SHARED).0 $(WIZSDK)/lib/$(TARGET_SHARED)
|
||||
|
||||
cp $(TARGET_STATIC) ../../toolchain/libs
|
||||
cp $(TARGET_SHARED).0.0.1 ../../toolchain/libs
|
||||
rm -f ../../toolchain/libs/$(TARGET_SHARED).0 ../../toolchain/libs/$(TARGET_SHARED)
|
||||
ln -s ../../toolchain/libs/$(TARGET_SHARED).0.0.1 ../../toolchain/libs/$(TARGET_SHARED).0
|
||||
ln -s ../../toolchain/libs/$(TARGET_SHARED).0 ../../toolchain/libs/$(TARGET_SHARED)
|
||||
|
||||
cp $(TARGET_SHARED).0.0.1 ../nehe_demos/build/$(TARGET_SHARED).0
|
||||
cp -f include/*.h $(WIZSDK)/include/SDL13/
|
||||
cp -f include/*.h ../../toolchain/include/SDL13/
|
||||
@@ -1,438 +0,0 @@
|
||||
================================================================================
|
||||
Simple DirectMedia Layer for Android
|
||||
================================================================================
|
||||
|
||||
Requirements:
|
||||
|
||||
Android SDK (version 12 or later)
|
||||
http://developer.android.com/sdk/index.html
|
||||
|
||||
Android NDK r7 or later
|
||||
http://developer.android.com/tools/sdk/ndk/index.html
|
||||
|
||||
Minimum API level supported by SDL: 10 (Android 2.3.3)
|
||||
Joystick support is available for API level >=12 devices.
|
||||
|
||||
================================================================================
|
||||
How the port works
|
||||
================================================================================
|
||||
|
||||
- Android applications are Java-based, optionally with parts written in C
|
||||
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
||||
the SDL library
|
||||
- This means that your application C code must be placed inside an Android
|
||||
Java project, along with some C support code that communicates with Java
|
||||
- This eventually produces a standard Android .apk package
|
||||
|
||||
The Android Java code implements an "Activity" and can be found in:
|
||||
android-project/src/org/libsdl/app/SDLActivity.java
|
||||
|
||||
The Java code loads your game code, the SDL shared library, and
|
||||
dispatches to native functions implemented in the SDL library:
|
||||
src/core/android/SDL_android.c
|
||||
|
||||
Your project must include some glue code that starts your main() routine:
|
||||
src/main/android/SDL_android_main.c
|
||||
|
||||
|
||||
================================================================================
|
||||
Building an app
|
||||
================================================================================
|
||||
|
||||
For simple projects you can use the script located at build-scripts/androidbuild.sh
|
||||
|
||||
There's two ways of using it:
|
||||
|
||||
androidbuild.sh com.yourcompany.yourapp < sources.list
|
||||
androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
|
||||
|
||||
sources.list should be a text file with a source file name in each line
|
||||
Filenames should be specified relative to the current directory, for example if
|
||||
you are in the build-scripts directory and want to create the testgles.c test, you'll
|
||||
run:
|
||||
|
||||
./androidbuild.sh org.libsdl.testgles ../test/testgles.c
|
||||
|
||||
One limitation of this script is that all sources provided will be aggregated into
|
||||
a single directory, thus all your source files should have a unique name.
|
||||
|
||||
Once the project is complete the script will tell you where the debug APK is located.
|
||||
If you want to create a signed release APK, you can use the project created by this
|
||||
utility to generate it.
|
||||
|
||||
Finally, a word of caution: re running androidbuild.sh wipes any changes you may have
|
||||
done in the build directory for the app!
|
||||
|
||||
|
||||
For more complex projects, follow these instructions:
|
||||
|
||||
1. Copy the android-project directory wherever you want to keep your projects
|
||||
and rename it to the name of your project.
|
||||
2. Move or symlink this SDL directory into the <project>/jni directory
|
||||
3. Edit <project>/jni/src/Android.mk to include your source files
|
||||
4. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
|
||||
|
||||
If you want to use the Eclipse IDE, skip to the Eclipse section below.
|
||||
|
||||
5. Create <project>/local.properties and use that to point to the Android SDK directory, by writing a line with the following form:
|
||||
sdk.dir=PATH_TO_ANDROID_SDK
|
||||
6. Run 'ant debug' in android/project. This compiles the .java and eventually
|
||||
creates a .apk with the native code embedded
|
||||
7. 'ant debug install' will push the apk to the device or emulator (if connected)
|
||||
|
||||
Here's an explanation of the files in the Android project, so you can customize them:
|
||||
|
||||
android-project/
|
||||
AndroidManifest.xml - package manifest. Among others, it contains the class name
|
||||
of the main Activity and the package name of the application.
|
||||
build.properties - empty
|
||||
build.xml - build description file, used by ant. The actual application name
|
||||
is specified here.
|
||||
default.properties - holds the target ABI for the application, android-10 and up
|
||||
project.properties - holds the target ABI for the application, android-10 and up
|
||||
local.properties - holds the SDK path, you should change this to the path to your SDK
|
||||
jni/ - directory holding native code
|
||||
jni/Android.mk - Android makefile that can call recursively the Android.mk files
|
||||
in all subdirectories
|
||||
jni/SDL/ - (symlink to) directory holding the SDL library files
|
||||
jni/SDL/Android.mk - Android makefile for creating the SDL shared library
|
||||
jni/src/ - directory holding your C/C++ source
|
||||
jni/src/Android.mk - Android makefile that you should customize to include your
|
||||
source code and any library references
|
||||
res/ - directory holding resources for your application
|
||||
res/drawable-* - directories holding icons for different phone hardware. Could be
|
||||
one dir called "drawable".
|
||||
res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout.
|
||||
We don't need it because we use the SDL video output.
|
||||
res/values/strings.xml - strings used in your application, including the application name
|
||||
shown on the phone.
|
||||
src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding
|
||||
to SDL. Be very careful changing this, as the SDL library relies
|
||||
on this implementation.
|
||||
|
||||
|
||||
================================================================================
|
||||
Build an app with static linking of libSDL
|
||||
================================================================================
|
||||
|
||||
This build uses the Android NDK module system.
|
||||
|
||||
Instructions:
|
||||
1. Copy the android-project directory wherever you want to keep your projects
|
||||
and rename it to the name of your project.
|
||||
2. Rename <project>/jni/src/Android_static.mk to <project>/jni/src/Android.mk
|
||||
(overwrite the existing one)
|
||||
3. Edit <project>/jni/src/Android.mk to include your source files
|
||||
4. create and export an environment variable named NDK_MODULE_PATH that points
|
||||
to the parent directory of this SDL directory. e.g.:
|
||||
|
||||
export NDK_MODULE_PATH="$PWD"/..
|
||||
|
||||
5. Edit <project>/src/org/libsdl/app/SDLActivity.java and remove the call to
|
||||
System.loadLibrary("SDL2") line 42.
|
||||
6. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
|
||||
|
||||
|
||||
================================================================================
|
||||
Customizing your application name
|
||||
================================================================================
|
||||
|
||||
To customize your application name, edit AndroidManifest.xml and replace
|
||||
"org.libsdl.app" with an identifier for your product package.
|
||||
|
||||
Then create a Java class extending SDLActivity and place it in a directory
|
||||
under src matching your package, e.g.
|
||||
src/com/gamemaker/game/MyGame.java
|
||||
|
||||
Here's an example of a minimal class file:
|
||||
--- MyGame.java --------------------------
|
||||
package com.gamemaker.game;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
/*
|
||||
* A sample wrapper class that just calls SDLActivity
|
||||
*/
|
||||
|
||||
public class MyGame extends SDLActivity { }
|
||||
|
||||
------------------------------------------
|
||||
|
||||
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
||||
class, .e.g. "MyGame"
|
||||
|
||||
================================================================================
|
||||
Customizing your application icon
|
||||
================================================================================
|
||||
|
||||
Conceptually changing your icon is just replacing the "ic_launcher.png" files in
|
||||
the drawable directories under the res directory. There are four directories for
|
||||
different screen sizes. These can be replaced with one dir called "drawable",
|
||||
containing an icon file "ic_launcher.png" with dimensions 48x48 or 72x72.
|
||||
|
||||
You may need to change the name of your icon in AndroidManifest.xml to match
|
||||
this icon filename.
|
||||
|
||||
================================================================================
|
||||
Loading assets
|
||||
================================================================================
|
||||
|
||||
Any files you put in the "assets" directory of your android-project directory
|
||||
will get bundled into the application package and you can load them using the
|
||||
standard functions in SDL_rwops.h.
|
||||
|
||||
There are also a few Android specific functions that allow you to get other
|
||||
useful paths for saving and loading data:
|
||||
SDL_AndroidGetInternalStoragePath()
|
||||
SDL_AndroidGetExternalStorageState()
|
||||
SDL_AndroidGetExternalStoragePath()
|
||||
|
||||
See SDL_system.h for more details on these functions.
|
||||
|
||||
The asset packaging system will, by default, compress certain file extensions.
|
||||
SDL includes two asset file access mechanisms, the preferred one is the so
|
||||
called "File Descriptor" method, which is faster and doesn't involve the Dalvik
|
||||
GC, but given this method does not work on compressed assets, there is also the
|
||||
"Input Stream" method, which is automatically used as a fall back by SDL. You
|
||||
may want to keep this fact in mind when building your APK, specially when large
|
||||
files are involved.
|
||||
For more information on which extensions get compressed by default and how to
|
||||
disable this behaviour, see for example:
|
||||
|
||||
http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
|
||||
|
||||
================================================================================
|
||||
Pause / Resume behaviour
|
||||
================================================================================
|
||||
|
||||
If SDL is compiled with SDL_ANDROID_BLOCK_ON_PAUSE defined (the default),
|
||||
the event loop will block itself when the app is paused (ie, when the user
|
||||
returns to the main Android dashboard). Blocking is better in terms of battery
|
||||
use, and it allows your app to spring back to life instantaneously after resume
|
||||
(versus polling for a resume message).
|
||||
|
||||
Upon resume, SDL will attempt to restore the GL context automatically.
|
||||
In modern devices (Android 3.0 and up) this will most likely succeed and your
|
||||
app can continue to operate as it was.
|
||||
|
||||
However, there's a chance (on older hardware, or on systems under heavy load),
|
||||
where the GL context can not be restored. In that case you have to listen for
|
||||
a specific message, (which is not yet implemented!) and restore your textures
|
||||
manually or quit the app (which is actually the kind of behaviour you'll see
|
||||
under iOS, if the OS can not restore your GL context it will just kill your app)
|
||||
|
||||
================================================================================
|
||||
Threads and the Java VM
|
||||
================================================================================
|
||||
|
||||
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
||||
a look here: http://developer.android.com/guide/practices/jni.html
|
||||
If you want to use threads in your SDL app, it's strongly recommended that you
|
||||
do so by creating them using SDL functions. This way, the required attach/detach
|
||||
handling is managed by SDL automagically. If you have threads created by other
|
||||
means and they make calls to SDL functions, make sure that you call
|
||||
Android_JNI_SetupThread before doing anything else otherwise SDL will attach
|
||||
your thread automatically anyway (when you make an SDL call), but it'll never
|
||||
detach it.
|
||||
|
||||
================================================================================
|
||||
Using STL
|
||||
================================================================================
|
||||
|
||||
You can use STL in your project by creating an Application.mk file in the jni
|
||||
folder and adding the following line:
|
||||
APP_STL := stlport_static
|
||||
|
||||
For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation.
|
||||
|
||||
================================================================================
|
||||
Additional documentation
|
||||
================================================================================
|
||||
|
||||
The documentation in the NDK docs directory is very helpful in understanding the
|
||||
build process and how to work with native code on the Android platform.
|
||||
|
||||
The best place to start is with docs/OVERVIEW.TXT
|
||||
|
||||
|
||||
================================================================================
|
||||
Using Eclipse
|
||||
================================================================================
|
||||
|
||||
First make sure that you've installed Eclipse and the Android extensions as described here:
|
||||
http://developer.android.com/tools/sdk/eclipse-adt.html
|
||||
|
||||
Once you've copied the SDL android project and customized it, you can create an Eclipse project from it:
|
||||
* File -> New -> Other
|
||||
* Select the Android -> Android Project wizard and click Next
|
||||
* Enter the name you'd like your project to have
|
||||
* Select "Create project from existing source" and browse for your project directory
|
||||
* Make sure the Build Target is set to Android 2.0
|
||||
* Click Finish
|
||||
|
||||
|
||||
================================================================================
|
||||
Using the emulator
|
||||
================================================================================
|
||||
|
||||
There are some good tips and tricks for getting the most out of the
|
||||
emulator here: http://developer.android.com/tools/devices/emulator.html
|
||||
|
||||
Especially useful is the info on setting up OpenGL ES 2.0 emulation.
|
||||
|
||||
Notice that this software emulator is incredibly slow and needs a lot of disk space.
|
||||
Using a real device works better.
|
||||
|
||||
================================================================================
|
||||
Troubleshooting
|
||||
================================================================================
|
||||
|
||||
You can create and run an emulator from the Eclipse IDE:
|
||||
* Window -> Android SDK and AVD Manager
|
||||
|
||||
You can see if adb can see any devices with the following command:
|
||||
adb devices
|
||||
|
||||
You can see the output of log messages on the default device with:
|
||||
adb logcat
|
||||
|
||||
You can push files to the device with:
|
||||
adb push local_file remote_path_and_file
|
||||
|
||||
You can push files to the SD Card at /sdcard, for example:
|
||||
adb push moose.dat /sdcard/moose.dat
|
||||
|
||||
You can see the files on the SD card with a shell command:
|
||||
adb shell ls /sdcard/
|
||||
|
||||
You can start a command shell on the default device with:
|
||||
adb shell
|
||||
|
||||
You can remove the library files of your project (and not the SDL lib files) with:
|
||||
ndk-build clean
|
||||
|
||||
You can do a build with the following command:
|
||||
ndk-build
|
||||
|
||||
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
||||
ndk-build V=1
|
||||
|
||||
If your application crashes in native code, you can use addr2line to convert the
|
||||
addresses in the stack trace to lines in your code.
|
||||
|
||||
For example, if your crash looks like this:
|
||||
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
||||
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
||||
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
||||
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
||||
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
||||
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
||||
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
||||
|
||||
You can see that there's a crash in the C library being called from the main code.
|
||||
I run addr2line with the debug version of my code:
|
||||
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
||||
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
||||
000014bc
|
||||
|
||||
I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23.
|
||||
|
||||
You can add logging to your code to help show what's happening:
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
|
||||
|
||||
If you need to build without optimization turned on, you can create a file called
|
||||
"Application.mk" in the jni directory, with the following line in it:
|
||||
APP_OPTIM := debug
|
||||
|
||||
|
||||
================================================================================
|
||||
Memory debugging
|
||||
================================================================================
|
||||
|
||||
The best (and slowest) way to debug memory issues on Android is valgrind.
|
||||
Valgrind has support for Android out of the box, just grab code using:
|
||||
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
|
||||
... and follow the instructions in the file README.android to build it.
|
||||
|
||||
One thing I needed to do on Mac OS X was change the path to the toolchain,
|
||||
and add ranlib to the environment variables:
|
||||
export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib
|
||||
|
||||
Once valgrind is built, you can create a wrapper script to launch your
|
||||
application with it, changing org.libsdl.app to your package identifier:
|
||||
--- start_valgrind_app -------------------
|
||||
#!/system/bin/sh
|
||||
export TMPDIR=/data/data/org.libsdl.app
|
||||
exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
|
||||
------------------------------------------
|
||||
|
||||
Then push it to the device:
|
||||
adb push start_valgrind_app /data/local
|
||||
|
||||
and make it executable:
|
||||
adb shell chmod 755 /data/local/start_valgrind_app
|
||||
|
||||
and tell Android to use the script to launch your application:
|
||||
adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
|
||||
|
||||
If the setprop command says "could not set property", it's likely that
|
||||
your package name is too long and you should make it shorter by changing
|
||||
AndroidManifest.xml and the path to your class file in android-project/src
|
||||
|
||||
You can then launch your application normally and waaaaaaaiiittt for it.
|
||||
You can monitor the startup process with the logcat command above, and
|
||||
when it's done (or even while it's running) you can grab the valgrind
|
||||
output file:
|
||||
adb pull /sdcard/valgrind.log
|
||||
|
||||
When you're done instrumenting with valgrind, you can disable the wrapper:
|
||||
adb shell setprop wrap.org.libsdl.app ""
|
||||
|
||||
================================================================================
|
||||
Why is API level 10 the minimum required?
|
||||
================================================================================
|
||||
|
||||
API level 10 is the minimum required level at runtime (that is, on the device)
|
||||
because SDL requires some functionality for running not
|
||||
available on older devices. Since the incorporation of joystick support into SDL,
|
||||
the minimum SDK required to *build* SDL is version 12. Devices running API levels
|
||||
10-11 are still supported, only with the joystick functionality disabled.
|
||||
|
||||
Support for native OpenGL ES and ES2 applications was introduced in the NDK for
|
||||
API level 4 and 8. EGL was made a stable API in the NDK for API level 9, which
|
||||
has since then been obsoleted, with the recommendation to developers to bump the
|
||||
required API level to 10.
|
||||
As of this writing, according to http://developer.android.com/about/dashboards/index.html
|
||||
about 90% of the Android devices accessing Google Play support API level 10 or
|
||||
higher (March 2013).
|
||||
|
||||
================================================================================
|
||||
A note regarding the use of the "dirty rectangles" rendering technique
|
||||
================================================================================
|
||||
|
||||
If your app uses a variation of the "dirty rectangles" rendering technique,
|
||||
where you only update a portion of the screen on each frame, you may notice a
|
||||
variety of visual glitches on Android, that are not present on other platforms.
|
||||
This is caused by SDL's use of EGL as the support system to handle OpenGL ES/ES2
|
||||
contexts, in particular the use of the eglSwapBuffers function. As stated in the
|
||||
documentation for the function "The contents of ancillary buffers are always
|
||||
undefined after calling eglSwapBuffers".
|
||||
Setting the EGL_SWAP_BEHAVIOR attribute of the surface to EGL_BUFFER_PRESERVED
|
||||
is not possible for SDL as it requires EGL 1.4, available only on the API level
|
||||
17+, so the only workaround available on this platform is to redraw the entire
|
||||
screen each frame.
|
||||
|
||||
Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
|
||||
|
||||
================================================================================
|
||||
Known issues
|
||||
================================================================================
|
||||
|
||||
- The number of buttons reported for each joystick is hardcoded to be 36, which
|
||||
is the current maximum number of buttons Android can report.
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
================================================================================
|
||||
CMake build system for SDL (www.cmake.org)
|
||||
================================================================================
|
||||
|
||||
SDL's build system was traditionally based on autotools. Over time, this
|
||||
approach has suffered from several issues across the different supported
|
||||
platforms.
|
||||
To solve these problems, a new build system based on CMake is under development.
|
||||
It works in parallel to the legacy system, so users can experiment with it
|
||||
without complication.
|
||||
While still experimental, the build system should be usable on the following
|
||||
platforms:
|
||||
|
||||
* FreeBSD
|
||||
* Linux
|
||||
* VS.NET 2010
|
||||
* MinGW and Msys
|
||||
* OS X with support for XCode
|
||||
|
||||
================================================================================
|
||||
Usage
|
||||
================================================================================
|
||||
|
||||
Assuming the source for SDL is located at ~/sdl
|
||||
|
||||
cd ~
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ../sdl
|
||||
|
||||
This will build the static and dynamic versions of SDL in the ~/build directory.
|
||||
@@ -1,106 +0,0 @@
|
||||
SDL on DirectFB
|
||||
|
||||
Supports:
|
||||
|
||||
- Hardware YUV overlays
|
||||
- OpenGL - software only
|
||||
- 2D/3D accelerations (depends on directfb driver)
|
||||
- multiple displays
|
||||
- windows
|
||||
|
||||
What you need:
|
||||
|
||||
DirectFB 1.0.1, 1.2.x, 1.3.0
|
||||
Kernel-Framebuffer support: required: vesafb, radeonfb ....
|
||||
Mesa 7.0.x - optional for OpenGL
|
||||
|
||||
/etc/directfbrc
|
||||
|
||||
This file should contain the following lines to make
|
||||
your joystick work and avoid crashes:
|
||||
------------------------
|
||||
disable-module=joystick
|
||||
disable-module=cle266
|
||||
disable-module=cyber5k
|
||||
no-linux-input-grab
|
||||
------------------------
|
||||
|
||||
To disable to use x11 backend when DISPLAY variable is found use
|
||||
|
||||
export SDL_DIRECTFB_X11_CHECK=0
|
||||
|
||||
To disable the use of linux input devices, i.e. multimice/multikeyboard support,
|
||||
use
|
||||
|
||||
export SDL_DIRECTFB_LINUX_INPUT=0
|
||||
|
||||
To use hardware accelerated YUV-overlays for YUV-textures, use:
|
||||
|
||||
export SDL_DIRECTFB_YUV_DIRECT=1
|
||||
|
||||
This is disabled by default. It will only support one
|
||||
YUV texture, namely the first. Every other YUV texture will be
|
||||
rendered in software.
|
||||
|
||||
In addition, you may use (directfb-1.2.x)
|
||||
|
||||
export SDL_DIRECTFB_YUV_UNDERLAY=1
|
||||
|
||||
to make the YUV texture an underlay. This will make the cursor to
|
||||
be shown.
|
||||
|
||||
Simple Window Manager
|
||||
=====================
|
||||
|
||||
The driver has support for a very, very basic window manager you may
|
||||
want to use when running with "wm=default". Use
|
||||
|
||||
export SDL_DIRECTFB_WM=1
|
||||
|
||||
to enable basic window borders. In order to have the window title rendered,
|
||||
you need to have the following font installed:
|
||||
|
||||
/usr/share/fonts/truetype/freefont/FreeSans.ttf
|
||||
|
||||
OpenGL Support
|
||||
==============
|
||||
|
||||
The following instructions will give you *software* OpenGL. However this
|
||||
works at least on all directfb supported platforms.
|
||||
|
||||
As of this writing 20100802 you need to pull Mesa from git and do the following:
|
||||
|
||||
------------------------
|
||||
git clone git://anongit.freedesktop.org/git/mesa/mesa
|
||||
cd mesa
|
||||
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
|
||||
------------------------
|
||||
|
||||
Edit configs/linux-directfb so that the Directories-section looks like
|
||||
------------------------
|
||||
# Directories
|
||||
SRC_DIRS = mesa glu
|
||||
GLU_DIRS = sgi
|
||||
DRIVER_DIRS = directfb
|
||||
PROGRAM_DIRS =
|
||||
------------------------
|
||||
|
||||
make linux-directfb
|
||||
make
|
||||
|
||||
echo Installing - please enter sudo pw.
|
||||
|
||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||
cd src/mesa/drivers/directfb
|
||||
make
|
||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||
------------------------
|
||||
|
||||
To run the SDL - testprograms:
|
||||
|
||||
export SDL_VIDEODRIVER=directfb
|
||||
export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib
|
||||
export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7
|
||||
|
||||
./testgl
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
===========================================================================
|
||||
Dollar Gestures
|
||||
===========================================================================
|
||||
SDL Provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
||||
|
||||
Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up.
|
||||
|
||||
Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID.
|
||||
|
||||
Recording:
|
||||
----------
|
||||
To begin recording on a touch device call:
|
||||
SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices.
|
||||
|
||||
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
||||
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
||||
|
||||
event.dgesture.touchId - the Id of the touch used to record the gesture.
|
||||
event.dgesture.gestureId - the unique id of the recorded gesture.
|
||||
|
||||
|
||||
Performing:
|
||||
-----------
|
||||
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
||||
|
||||
event.dgesture.touchId - the Id of the touch which performed the gesture.
|
||||
event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
||||
event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
||||
event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
||||
|
||||
Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
||||
|
||||
|
||||
|
||||
Saving:
|
||||
-------
|
||||
To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
Both functions return the number of gestures successfully saved.
|
||||
|
||||
|
||||
Loading:
|
||||
--------
|
||||
To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file.
|
||||
|
||||
SDL_LoadDollarTemplates returns the number of templates successfully loaded.
|
||||
|
||||
|
||||
|
||||
===========================================================================
|
||||
Multi Gestures
|
||||
===========================================================================
|
||||
SDL provides simple support for pinch/rotate/swipe gestures.
|
||||
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
||||
|
||||
event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
||||
event.mgesture.x - the normalized x coordinate of the gesture. (0..1)
|
||||
event.mgesture.y - the normalized y coordinate of the gesture. (0..1)
|
||||
event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
||||
event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
||||
event.mgesture.numFingers - the number of fingers used in the gesture.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
@@ -1,23 +0,0 @@
|
||||
The latest development version of SDL is available via Mercurial.
|
||||
Mercurial allows you to get up-to-the-minute fixes and enhancements;
|
||||
as a developer works on a source tree, you can use "hg" to mirror that
|
||||
source tree instead of waiting for an official release. Please look
|
||||
at the Mercurial website ( http://mercurial.selenic.com/ ) for more
|
||||
information on using hg, where you can also download software for
|
||||
Mac OS X, Windows, and Unix systems.
|
||||
|
||||
hg clone http://hg.libsdl.org/SDL
|
||||
|
||||
If you are building SDL with an IDE, you will need to copy the file
|
||||
include/SDL_config.h.default to include/SDL_config.h before building.
|
||||
|
||||
If you are building SDL via configure, you will need to run autogen.sh
|
||||
before running configure.
|
||||
|
||||
There is a web interface to the subversion repository at:
|
||||
|
||||
http://hg.libsdl.org/SDL/
|
||||
|
||||
There is an RSS feed available at that URL, for those that want to
|
||||
track commits in real time.
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
==============================================================================
|
||||
Building the Simple DirectMedia Layer for iPhone OS 2.0
|
||||
==============================================================================
|
||||
|
||||
Requirements: Mac OS X v10.5 or later and the iPhone SDK.
|
||||
|
||||
Instructions:
|
||||
1. Open SDL.xcodeproj (located in Xcode-iOS/SDL) in XCode.
|
||||
2. Select your desired target, and hit build.
|
||||
|
||||
There are three build targets:
|
||||
- libSDL.a:
|
||||
Build SDL as a statically linked library
|
||||
- testsdl
|
||||
Build a test program (there are known test failures which are fine)
|
||||
- Template:
|
||||
Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers. The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen.
|
||||
|
||||
==============================================================================
|
||||
Build SDL for iOS from the command line
|
||||
==============================================================================
|
||||
|
||||
1. cd (PATH WHERE THE SDL CODE IS)/build-scripts
|
||||
2. ./iosbuild.sh
|
||||
|
||||
If everything goes fine, you should see a build/ios directory, inside there's
|
||||
two directories "lib" and "include".
|
||||
"include" contains a copy of the SDL headers that you'll need for your project,
|
||||
make sure to configure XCode to look for headers there.
|
||||
"lib" contains find two files, libSDL2.a and libSDL2main.a, you have to add both
|
||||
to your XCode project. These libraries contain three architectures in them,
|
||||
armv6 for legacy devices, armv7, and i386 (for the simulator).
|
||||
By default, iosbuild.sh will autodetect the SDK version you have installed using
|
||||
xcodebuild -showsdks, and build for iOS >= 3.0, you can override this behaviour
|
||||
by setting the MIN_OS_VERSION variable, ie:
|
||||
|
||||
MIN_OS_VERSION=4.2 ./iosbuild.sh
|
||||
|
||||
==============================================================================
|
||||
Using the Simple DirectMedia Layer for iOS
|
||||
==============================================================================
|
||||
|
||||
FIXME: This needs to be updated for the latest methods
|
||||
|
||||
Here is the easiest method:
|
||||
1. Build the SDL libraries (libSDL.a and libSDLSimulator.a) and the iPhone SDL Application template.
|
||||
1. Install the iPhone SDL Application template by copying it to one of XCode's template directories. I recommend creating a directory called "SDL" in "/Developer/Platforms/iOS.platform/Developer/Library/XCode/Project Templates/" and placing it there.
|
||||
2. Start a new project using the template. The project should be immediately ready for use with SDL.
|
||||
|
||||
Here is a more manual method:
|
||||
1. Create a new iPhone view based application.
|
||||
2. Build the SDL static libraries (libSDL.a and libSDLSimulator.a) for iPhone and include them in your project. XCode will ignore the library that is not currently of the correct architecture, hence your app will work both on iPhone and in the iPhone Simulator.
|
||||
3. Include the SDL header files in your project.
|
||||
4. Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iPhone provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iPhone produces its user interface programmatically.
|
||||
5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell XCode not to use the project prefix file, as it includes Objective-C code.
|
||||
|
||||
==============================================================================
|
||||
Notes -- Application events
|
||||
==============================================================================
|
||||
|
||||
On iOS the application goes through a fixed life cycle and you will get
|
||||
notifications of state changes via application events. When these events
|
||||
are delivered you must handle them in an event callback because the OS may
|
||||
not give you any processing time after the events are delivered.
|
||||
|
||||
e.g.
|
||||
|
||||
int HandleAppEvents(void *userdata, SDL_Event *event)
|
||||
{
|
||||
switch (event->type)
|
||||
{
|
||||
case SDL_APP_TERMINATING:
|
||||
/* Terminate the app.
|
||||
Shut everything down before returning from this function.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_LOWMEMORY:
|
||||
/* You will get this when your app is paused and iOS wants more memory.
|
||||
Release as much memory as possible.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_WILLENTERBACKGROUND:
|
||||
/* Prepare your app to go into the background. Stop loops, etc.
|
||||
This gets called when the user hits the home button, or gets a call.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_DIDENTERBACKGROUND:
|
||||
/* This will get called if the user accepted whatever sent your app to the background.
|
||||
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
|
||||
When you get this, you have 5 seconds to save all your state or the app will be terminated.
|
||||
Your app is NOT active at this point.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_WILLENTERFOREGROUND:
|
||||
/* This call happens when your app is coming back to the foreground.
|
||||
Restore all your state here.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_DIDENTERFOREGROUND:
|
||||
/* Restart your loops here.
|
||||
Your app is interactive and getting CPU again.
|
||||
*/
|
||||
return 0;
|
||||
default:
|
||||
/* No special processing, add it to the event queue */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_SetEventFilter(HandleAppEvents, NULL);
|
||||
|
||||
... run your main loop
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
==============================================================================
|
||||
Notes -- Accelerometer as Joystick
|
||||
==============================================================================
|
||||
|
||||
SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory.
|
||||
|
||||
The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
|
||||
|
||||
==============================================================================
|
||||
Notes -- OpenGL ES
|
||||
==============================================================================
|
||||
|
||||
Your SDL application for iPhone uses OpenGL ES for video by default.
|
||||
|
||||
OpenGL ES for iPhone supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute.
|
||||
|
||||
If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0.
|
||||
|
||||
Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 1.
|
||||
|
||||
==============================================================================
|
||||
Notes -- Keyboard
|
||||
==============================================================================
|
||||
|
||||
The SDL keyboard API has been extended to support on-screen keyboards:
|
||||
|
||||
void SDL_StartTextInput()
|
||||
-- enables text events and reveals the onscreen keyboard.
|
||||
void SDL_StopTextInput()
|
||||
-- disables text events and hides the onscreen keyboard.
|
||||
SDL_bool SDL_IsTextInputActive()
|
||||
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
||||
|
||||
==============================================================================
|
||||
Notes -- Reading and Writing files
|
||||
==============================================================================
|
||||
|
||||
Each application installed on iPhone resides in a sandbox which includes its own Application Home directory. Your application may not access files outside this directory.
|
||||
|
||||
Once your application is installed its directory tree looks like:
|
||||
|
||||
MySDLApp Home/
|
||||
MySDLApp.app
|
||||
Documents/
|
||||
Library/
|
||||
Preferences/
|
||||
tmp/
|
||||
|
||||
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".
|
||||
|
||||
More information on this subject is available here:
|
||||
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
|
||||
|
||||
==============================================================================
|
||||
Notes -- iPhone SDL limitations
|
||||
==============================================================================
|
||||
|
||||
Windows:
|
||||
Full-size, single window applications only. You cannot create multi-window SDL applications for iPhone OS. The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow the flag SDL_WINDOW_BORDERLESS).
|
||||
|
||||
Textures:
|
||||
The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, and SDL_PIXELFORMAT_RGB24 pixel formats.
|
||||
|
||||
Loading Shared Objects:
|
||||
This is disabled by default since it seems to break the terms of the iPhone SDK agreement. It can be re-enabled in SDL_config_iphoneos.h.
|
||||
|
||||
==============================================================================
|
||||
Game Center
|
||||
==============================================================================
|
||||
|
||||
Game Center integration requires that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
||||
|
||||
int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
||||
|
||||
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
||||
|
||||
e.g.
|
||||
|
||||
extern "C"
|
||||
void ShowFrame(void*)
|
||||
{
|
||||
... do event handling, frame logic and rendering
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
... initialize game ...
|
||||
|
||||
#if __IPHONEOS__
|
||||
// Initialize the Game Center for scoring and matchmaking
|
||||
InitGameCenter();
|
||||
|
||||
// Set up the game to run in the window animation callback on iOS
|
||||
// so that Game Center and so forth works correctly.
|
||||
SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
|
||||
#else
|
||||
while ( running ) {
|
||||
ShowFrame(0);
|
||||
DelayFrame();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
==============================================================================
|
||||
Using the Simple DirectMedia Layer with Mac OS X
|
||||
==============================================================================
|
||||
|
||||
These instructions are for people using Apple's Mac OS X (pronounced
|
||||
"ten").
|
||||
|
||||
From the developer's point of view, OS X is a sort of hybrid Mac and
|
||||
Unix system, and you have the option of using either traditional
|
||||
command line tools or Apple's IDE Xcode.
|
||||
|
||||
To build SDL using the command line, use the standard configure and make
|
||||
process:
|
||||
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
You can also build SDL as a Universal library (a single binary for both
|
||||
PowerPC and Intel architectures), on Mac OS X 10.4 and newer, by using
|
||||
the fatbuild.sh script in build-scripts:
|
||||
sh build-scripts/fatbuild.sh
|
||||
sudo build-scripts/fatbuild.sh install
|
||||
This script builds SDL with 10.2 ABI compatibility on PowerPC and 10.4
|
||||
ABI compatibility on Intel architectures. For best compatibility you
|
||||
should compile your application the same way. A script which wraps
|
||||
gcc to make this easy is provided in test/gcc-fat.sh
|
||||
|
||||
To use the library once it's built, you essential have two possibilities:
|
||||
use the traditional autoconf/automake/make method, or use Xcode.
|
||||
|
||||
==============================================================================
|
||||
Caveats for using SDL with Mac OS X
|
||||
==============================================================================
|
||||
|
||||
Some things you have to be aware of when using SDL on Mac OS X:
|
||||
|
||||
- If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
|
||||
SDL will not register its own. This means that SDL will not terminate using
|
||||
SDL_Quit if it receives a termination request, it will terminate like a
|
||||
normal app, and it will not send a SDL_DROPFILE when you request to open a
|
||||
file with the app. To solve these issues, put the following code in your
|
||||
NSApplicationDelegate implementation:
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_DROPFILE;
|
||||
event.drop.file = SDL_strdup([filename UTF8String]);
|
||||
return (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
==============================================================================
|
||||
Using the Simple DirectMedia Layer with a traditional Makefile
|
||||
==============================================================================
|
||||
|
||||
An existing autoconf/automake build system for your SDL app has good chances
|
||||
to work almost unchanged on OS X. However, to produce a "real" Mac OS X binary
|
||||
that you can distribute to users, you need to put the generated binary into a
|
||||
so called "bundle", which basically is a fancy folder with a name like
|
||||
"MyCoolGame.app".
|
||||
|
||||
To get this build automatically, add something like the following rule to
|
||||
your Makefile.am:
|
||||
|
||||
bundle_contents = APP_NAME.app/Contents
|
||||
APP_NAME_bundle: EXE_NAME
|
||||
mkdir -p $(bundle_contents)/MacOS
|
||||
mkdir -p $(bundle_contents)/Resources
|
||||
echo "APPL????" > $(bundle_contents)/PkgInfo
|
||||
$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
|
||||
|
||||
You should replace EXE_NAME with the name of the executable. APP_NAME is what
|
||||
will be visible to the user in the Finder. Usually it will be the same
|
||||
as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME
|
||||
usually is "TestGame". You might also want to use @PACKAGE@ to use the package
|
||||
name as specified in your configure.in file.
|
||||
|
||||
If your project builds more than one application, you will have to do a bit
|
||||
more. For each of your target applications, you need a separate rule.
|
||||
|
||||
If you want the created bundles to be installed, you may want to add this
|
||||
rule to your Makefile.am:
|
||||
|
||||
install-exec-hook: APP_NAME_bundle
|
||||
rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
|
||||
mkdir -p $(DESTDIR)$(prefix)/Applications/
|
||||
cp -r $< /$(DESTDIR)$(prefix)Applications/
|
||||
|
||||
This rule takes the Bundle created by the rule from step 3 and installs them
|
||||
into $(DESTDIR)$(prefix)/Applications/.
|
||||
|
||||
Again, if you want to install multiple applications, you will have to augment
|
||||
the make rule accordingly.
|
||||
|
||||
|
||||
But beware! That is only part of the story! With the above, you end up with
|
||||
a bare bone .app bundle, which is double clickable from the Finder. But
|
||||
there are some more things you should do before shipping your product...
|
||||
|
||||
1) The bundle right now probably is dynamically linked against SDL. That
|
||||
means that when you copy it to another computer, *it will not run*,
|
||||
unless you also install SDL on that other computer. A good solution
|
||||
for this dilemma is to static link against SDL. On OS X, you can
|
||||
achieve that by linking against the libraries listed by
|
||||
sdl-config --static-libs
|
||||
instead of those listed by
|
||||
sdl-config --libs
|
||||
Depending on how exactly SDL is integrated into your build systems, the
|
||||
way to achieve that varies, so I won't describe it here in detail
|
||||
2) Add an 'Info.plist' to your application. That is a special XML file which
|
||||
contains some meta-information about your application (like some copyright
|
||||
information, the version of your app, the name of an optional icon file,
|
||||
and other things). Part of that information is displayed by the Finder
|
||||
when you click on the .app, or if you look at the "Get Info" window.
|
||||
More information about Info.plist files can be found on Apple's homepage.
|
||||
|
||||
|
||||
As a final remark, let me add that I use some of the techniques (and some
|
||||
variations of them) in Exult and ScummVM; both are available in source on
|
||||
the net, so feel free to take a peek at them for inspiration!
|
||||
|
||||
|
||||
==============================================================================
|
||||
Using the Simple DirectMedia Layer with Xcode
|
||||
==============================================================================
|
||||
|
||||
These instructions are for using Apple's Xcode IDE to build SDL applications.
|
||||
|
||||
- First steps
|
||||
|
||||
The first thing to do is to unpack the Xcode.tar.gz archive in the
|
||||
top level SDL directory (where the Xcode.tar.gz archive resides).
|
||||
Because Stuffit Expander will unpack the archive into a subdirectory,
|
||||
you should unpack the archive manually from the command line:
|
||||
cd [path_to_SDL_source]
|
||||
tar zxf Xcode.tar.gz
|
||||
This will create a new folder called Xcode, which you can browse
|
||||
normally from the Finder.
|
||||
|
||||
- Building the Framework
|
||||
|
||||
The SDL Library is packaged as a framework bundle, an organized
|
||||
relocatable folder hierarchy of executable code, interface headers,
|
||||
and additional resources. For practical purposes, you can think of a
|
||||
framework as a more user and system-friendly shared library, whose library
|
||||
file behaves more or less like a standard UNIX shared library.
|
||||
|
||||
To build the framework, simply open the framework project and build it.
|
||||
By default, the framework bundle "SDL.framework" is installed in
|
||||
/Library/Frameworks. Therefore, the testers and project stationary expect
|
||||
it to be located there. However, it will function the same in any of the
|
||||
following locations:
|
||||
|
||||
~/Library/Frameworks
|
||||
/Local/Library/Frameworks
|
||||
/System/Library/Frameworks
|
||||
|
||||
- Build Options
|
||||
There are two "Build Styles" (See the "Targets" tab) for SDL.
|
||||
"Deployment" should be used if you aren't tweaking the SDL library.
|
||||
"Development" should be used to debug SDL apps or the library itself.
|
||||
|
||||
- Building the Testers
|
||||
Open the SDLTest project and build away!
|
||||
|
||||
- Using the Project Stationary
|
||||
Copy the stationary to the indicated folders to access it from
|
||||
the "New Project" and "Add target" menus. What could be easier?
|
||||
|
||||
- Setting up a new project by hand
|
||||
Some of you won't want to use the Stationary so I'll give some tips:
|
||||
* Create a new "Cocoa Application"
|
||||
* Add src/main/macosx/SDLMain.m , .h and .nib to your project
|
||||
* Remove "main.c" from your project
|
||||
* Remove "MainMenu.nib" from your project
|
||||
* Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
|
||||
* Add "$(HOME)/Library/Frameworks" to the frameworks search path
|
||||
* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
|
||||
* Set the "Main Nib File" under "Application Settings" to "SDLMain.nib"
|
||||
* Add your files
|
||||
* Clean and build
|
||||
|
||||
- Building from command line
|
||||
Use pbxbuild in the same directory as your .pbproj file
|
||||
|
||||
- Running your app
|
||||
You can send command line args to your app by either invoking it from
|
||||
the command line (in *.app/Contents/MacOS) or by entering them in the
|
||||
"Executables" panel of the target settings.
|
||||
|
||||
- Implementation Notes
|
||||
Some things that may be of interest about how it all works...
|
||||
* Working directory
|
||||
As defined in the SDL_main.m file, the working directory of your SDL app
|
||||
is by default set to its parent. You may wish to change this to better
|
||||
suit your needs.
|
||||
* You have a Cocoa App!
|
||||
Your SDL app is essentially a Cocoa application. When your app
|
||||
starts up and the libraries finish loading, a Cocoa procedure is called,
|
||||
which sets up the working directory and calls your main() method.
|
||||
You are free to modify your Cocoa app with generally no consequence
|
||||
to SDL. You cannot, however, easily change the SDL window itself.
|
||||
Functionality may be added in the future to help this.
|
||||
|
||||
|
||||
Known bugs are listed in the file "BUGS"
|
||||
@@ -1,16 +0,0 @@
|
||||
SDL 2.0 with open pandora console support ( http://openpandora.org/ )
|
||||
=====================================================================
|
||||
|
||||
- A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES
|
||||
support to work on the pandora under the framebuffer. This driver do not have
|
||||
input support for now, so if you use it you will have to add your own control code.
|
||||
The video driver name is "pandora" so if you have problem running it from
|
||||
the framebuffer, try to set the following variable before starting your application :
|
||||
"export SDL_VIDEODRIVER=pandora"
|
||||
|
||||
- OpenGL ES support was added to the x11 driver, so it's working like the normal
|
||||
x11 driver one with OpenGLX support, with SDL input event's etc..
|
||||
|
||||
|
||||
David Carré (Cpasjuste)
|
||||
cpasjuste@gmail.com
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
This is a list of the platforms SDL supports, and who maintains them.
|
||||
|
||||
Officially supported platforms
|
||||
==============================
|
||||
(code compiles, and thoroughly tested for release)
|
||||
==============================
|
||||
Windows XP/Vista/7/8
|
||||
Mac OS X 10.5+
|
||||
Linux 2.6+
|
||||
iOS 5.1.1+
|
||||
Android 2.3.3+
|
||||
|
||||
Unofficially supported platforms
|
||||
================================
|
||||
(code compiles, but not thoroughly tested)
|
||||
================================
|
||||
FreeBSD
|
||||
NetBSD
|
||||
OpenBSD
|
||||
Solaris
|
||||
|
||||
Platforms supported by volunteers
|
||||
=================================
|
||||
Haiku - maintained by Axel Dörfler <axeld@pinc-software.de>
|
||||
PSP - maintained by 527721088@qq.com
|
||||
Pandora - maintained by Scott Smith <pickle136@sbcglobal.net>
|
||||
|
||||
Platforms that need maintainers
|
||||
===============================
|
||||
@@ -1,61 +0,0 @@
|
||||
|
||||
* Porting To A New Platform
|
||||
|
||||
The first thing you have to do when porting to a new platform, is look at
|
||||
include/SDL_platform.h and create an entry there for your operating system.
|
||||
The standard format is __PLATFORM__, where PLATFORM is the name of the OS.
|
||||
Ideally SDL_platform.h will be able to auto-detect the system it's building
|
||||
on based on C preprocessor symbols.
|
||||
|
||||
There are two basic ways of building SDL at the moment:
|
||||
|
||||
1. The "UNIX" way: ./configure; make; make install
|
||||
|
||||
If you have a GNUish system, then you might try this. Edit configure.in,
|
||||
take a look at the large section labelled:
|
||||
"Set up the configuration based on the target platform!"
|
||||
Add a section for your platform, and then re-run autogen.sh and build!
|
||||
|
||||
2. Using an IDE:
|
||||
|
||||
If you're using an IDE or other non-configure build system, you'll probably
|
||||
want to create a custom SDL_config.h for your platform. Edit SDL_config.h,
|
||||
add a section for your platform, and create a custom SDL_config_{platform}.h,
|
||||
based on SDL_config.h.minimal and SDL_config.h.in
|
||||
|
||||
Add the top level include directory to the header search path, and then add
|
||||
the following sources to the project:
|
||||
src/*.c
|
||||
src/atomic/*.c
|
||||
src/audio/*.c
|
||||
src/cpuinfo/*.c
|
||||
src/events/*.c
|
||||
src/file/*.c
|
||||
src/haptic/*.c
|
||||
src/joystick/*.c
|
||||
src/power/*.c
|
||||
src/render/*.c
|
||||
src/stdlib/*.c
|
||||
src/thread/*.c
|
||||
src/timer/*.c
|
||||
src/video/*.c
|
||||
src/audio/disk/*.c
|
||||
src/audio/dummy/*.c
|
||||
src/video/dummy/*.c
|
||||
src/haptic/dummy/*.c
|
||||
src/joystick/dummy/*.c
|
||||
src/main/dummy/*.c
|
||||
src/thread/generic/*.c
|
||||
src/timer/dummy/*.c
|
||||
src/loadso/dummy/*.c
|
||||
|
||||
|
||||
Once you have a working library without any drivers, you can go back to each
|
||||
of the major subsystems and start implementing drivers for your platform.
|
||||
|
||||
If you have any questions, don't hesitate to ask on the SDL mailing list:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
Enjoy!
|
||||
Sam Lantinga (slouken@libsdl.org)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
SDL port for the Sony PSP contributed by
|
||||
Captian Lex
|
||||
|
||||
Credit to
|
||||
Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP
|
||||
Geecko for his PSP GU lib "Glib2d"
|
||||
|
||||
Building
|
||||
--------
|
||||
To build for the PSP, make sure psp-config is in the path and run:
|
||||
make -f Makefile.psp
|
||||
|
||||
|
||||
|
||||
To Do
|
||||
------
|
||||
PSP Screen Keyboard
|
||||
@@ -1,161 +0,0 @@
|
||||
================================================================================
|
||||
SDL2 for Raspberry Pi
|
||||
================================================================================
|
||||
|
||||
Requirements:
|
||||
|
||||
Raspbian (other Linux distros may work as well).
|
||||
|
||||
================================================================================
|
||||
Features
|
||||
================================================================================
|
||||
|
||||
* Works without X11
|
||||
* Hardware accelerated OpenGL ES 2.x
|
||||
* Sound via ALSA
|
||||
* Input (mouse/keyboard/joystick) via EVDEV
|
||||
* Hotplugging of input devices via UDEV
|
||||
|
||||
================================================================================
|
||||
Raspbian Build Dependencies
|
||||
================================================================================
|
||||
|
||||
sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
|
||||
|
||||
You also need the VideoCore binary stuff that ships in /opt/vc for EGL and
|
||||
OpenGL ES 2.x, it usually comes pre installed, but in any case:
|
||||
|
||||
sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
|
||||
|
||||
================================================================================
|
||||
Cross compiling from x86 Linux
|
||||
================================================================================
|
||||
|
||||
To cross compile SDL for Raspbian from your desktop machine, you'll need a
|
||||
Raspbian system root and the cross compilation tools. We'll assume these tools
|
||||
will be placed in /opt/rpi-tools
|
||||
|
||||
sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
|
||||
|
||||
You'll also need a Rasbian binary image.
|
||||
Get it from: http://downloads.raspberrypi.org/raspbian_latest
|
||||
After unzipping, you'll get file with a name like: <date>-wheezy-raspbian.img
|
||||
Let's assume the sysroot will be built in /opt/rpi-sysroot.
|
||||
|
||||
export SYSROOT=/opt/rpi-sysroot
|
||||
sudo kpartx -a -v <path_to_raspbian_image>.img
|
||||
sudo mount -o loop /dev/mapper/loop0p2 /mnt
|
||||
sudo cp -r /mnt $SYSROOT
|
||||
sudo apt-get install qemu binfmt-support qemu-user-static
|
||||
sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
|
||||
sudo mount --bind /dev $SYSROOT/dev
|
||||
sudo mount --bind /proc $SYSROOT/proc
|
||||
sudo mount --bind /sys $SYSROOT/sys
|
||||
|
||||
Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
|
||||
edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
|
||||
|
||||
sudo chroot $SYSROOT
|
||||
apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev
|
||||
exit
|
||||
sudo umount $SYSROOT/dev
|
||||
sudo umount $SYSROOT/proc
|
||||
sudo umount $SYSROOT/sys
|
||||
sudo umount /mnt
|
||||
|
||||
There's one more fix required, as the libdl.so symlink uses an absolute path
|
||||
which doesn't quite work in our setup.
|
||||
|
||||
sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||
sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||
|
||||
The final step is compiling SDL itself.
|
||||
|
||||
export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux"
|
||||
cd <SDL SOURCE>
|
||||
mkdir -p build;cd build
|
||||
../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
|
||||
make
|
||||
make install
|
||||
|
||||
To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
|
||||
|
||||
perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
|
||||
|
||||
================================================================================
|
||||
Apps don't work or poor video/audio performance
|
||||
================================================================================
|
||||
|
||||
If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to
|
||||
update the RPi's firmware. Note that doing so will fix these problems, but it
|
||||
will also render the CMA - Dynamic Memory Split functionality useless.
|
||||
|
||||
Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
|
||||
low in general, specially if a 1080p TV is hooked up.
|
||||
|
||||
See here how to configure this setting: http://elinux.org/RPiconfig
|
||||
|
||||
Using a fixed gpu_mem=128 is the best option (specially if you updated the
|
||||
firmware, using CMA probably won't work, at least it's the current case).
|
||||
|
||||
================================================================================
|
||||
No input
|
||||
================================================================================
|
||||
|
||||
Make sure you belong to the "input" group.
|
||||
|
||||
sudo usermod -aG input `whoami`
|
||||
|
||||
================================================================================
|
||||
No HDMI Audio
|
||||
================================================================================
|
||||
|
||||
If you notice that ALSA works but there's no audio over HDMI, try adding:
|
||||
|
||||
hdmi_drive=2
|
||||
|
||||
to your config.txt file and reboot.
|
||||
|
||||
Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
|
||||
|
||||
================================================================================
|
||||
Text Input API support
|
||||
================================================================================
|
||||
|
||||
The Text Input API is supported, with translation of scan codes done via the
|
||||
kernel symbol tables. For this to work, SDL needs access to a valid console.
|
||||
If you notice there's no SDL_TEXTINPUT message being emmited, double check that
|
||||
your app has read access to one of the following:
|
||||
|
||||
* /proc/self/fd/0
|
||||
* /dev/tty
|
||||
* /dev/tty[0...6]
|
||||
* /dev/vc/0
|
||||
* /dev/console
|
||||
|
||||
This is usually not a problem if you run from the physical terminal (as opposed
|
||||
to running from a pseudo terminal, such as via SSH). If running from a PTS, a
|
||||
quick workaround is to run your app as root or add yourself to the tty group,
|
||||
then re login to the system.
|
||||
|
||||
sudo usermod -aG tty `whoami`
|
||||
|
||||
The keyboard layout used by SDL is the same as the one the kernel uses.
|
||||
To configure the layout on Raspbian:
|
||||
|
||||
sudo dpkg-reconfigure keyboard-configuration
|
||||
|
||||
To configure the locale, which controls which keys are interpreted as letters,
|
||||
this determining the CAPS LOCK behavior:
|
||||
|
||||
sudo dpkg-reconfigure locales
|
||||
|
||||
================================================================================
|
||||
Notes
|
||||
================================================================================
|
||||
|
||||
* When launching apps remotely (via SSH), SDL can prevent local keystrokes from
|
||||
leaking into the console only if it has root privileges. Launching apps locally
|
||||
does not suffer from this issue.
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
===========================================================================
|
||||
System Specific Notes
|
||||
===========================================================================
|
||||
Linux:
|
||||
The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it.
|
||||
|
||||
Mac:
|
||||
The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
|
||||
|
||||
iPhone:
|
||||
Works out of box.
|
||||
|
||||
Windows:
|
||||
Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com
|
||||
|
||||
===========================================================================
|
||||
Events
|
||||
===========================================================================
|
||||
SDL_FINGERDOWN:
|
||||
Sent when a finger (or stylus) is placed on a touch device.
|
||||
Fields:
|
||||
event.tfinger.touchId - the Id of the touch device.
|
||||
event.tfinger.fingerId - the Id of the finger which just went down.
|
||||
event.tfinger.x - the x coordinate of the touch (0..1)
|
||||
event.tfinger.y - the y coordinate of the touch (0..1)
|
||||
event.tfinger.pressure - the pressure of the touch (0..1)
|
||||
|
||||
SDL_FINGERMOTION:
|
||||
Sent when a finger (or stylus) is moved on the touch device.
|
||||
Fields:
|
||||
Same as SDL_FINGERDOWN but with additional:
|
||||
event.tfinger.dx - change in x coordinate during this motion event.
|
||||
event.tfinger.dy - change in y coordinate during this motion event.
|
||||
|
||||
SDL_FINGERUP:
|
||||
Sent when a finger (or stylus) is lifted from the touch device.
|
||||
Fields:
|
||||
Same as SDL_FINGERDOWN.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Functions
|
||||
===========================================================================
|
||||
SDL provides the ability to access the underlying Finger structures.
|
||||
These structures should _never_ be modified.
|
||||
|
||||
The following functions are included from SDL_touch.h
|
||||
|
||||
To get a SDL_TouchID call SDL_GetTouchDevice(index).
|
||||
This returns a SDL_TouchID.
|
||||
IMPORTANT: If the touch has been removed, or there is no touch with the given ID, SDL_GetTouchID will return 0. Be sure to check for this!
|
||||
|
||||
The number of touch devices can be queried with SDL_GetNumTouchDevices().
|
||||
|
||||
A SDL_TouchID may be used to get pointers to SDL_Finger.
|
||||
|
||||
SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device.
|
||||
|
||||
The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following:
|
||||
|
||||
float x = event.tfinger.x;
|
||||
float y = event.tfinger.y;
|
||||
|
||||
|
||||
|
||||
To get a SDL_Finger, call SDL_GetTouchFinger(touchID,index), where touchID is a SDL_TouchID, and index is the requested finger.
|
||||
This returns a SDL_Finger*, or NULL if the finger does not exist, or has been removed.
|
||||
A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the SDL_FINGERUP event is polled.
|
||||
As a result, be very careful to check for NULL return values.
|
||||
|
||||
A SDL_Finger has the following fields:
|
||||
>x,y,pressure:
|
||||
The current coordinates of the touch.
|
||||
>pressure:
|
||||
The pressure of the touch.
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
(original author, API was changed since)
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
Windows CE is no longer supported by SDL.
|
||||
|
||||
We have left the CE support in SDL 1.2 for those that must have it, and we
|
||||
will accept patches that support more modern Windows Mobile platforms for
|
||||
SDL 2.0.
|
||||
|
||||
--ryan.
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
|
||||
Simple DirectMedia Layer
|
||||
|
||||
(SDL)
|
||||
|
||||
Version 2.0
|
||||
|
||||
---
|
||||
http://www.libsdl.org/
|
||||
|
||||
Simple DirectMedia Layer is a cross-platform development library designed
|
||||
to provide low level access to audio, keyboard, mouse, joystick, and graphics
|
||||
hardware via OpenGL and Direct3D. It is used by video playback software,
|
||||
emulators, and popular games including Valve's award winning catalog
|
||||
and many Humble Bundle games.
|
||||
|
||||
SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.
|
||||
Support for other platforms may be found in the source code.
|
||||
|
||||
SDL is written in C, works natively with C++, and there are bindings
|
||||
available for several other languages, including C# and Python.
|
||||
|
||||
This library is distributed under the zlib license, which can be found
|
||||
in the file "COPYING.txt".
|
||||
|
||||
The best way to learn how to use SDL is to check out the header files in
|
||||
the "include" subdirectory and the programs in the "test" subdirectory.
|
||||
The header files and test programs are well commented and always up to date.
|
||||
More documentation and FAQs are available online at:
|
||||
http://wiki.libsdl.org/
|
||||
|
||||
If you need help with the library, or just want to discuss SDL related
|
||||
issues, you can join the developers mailing list:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
If you want to report bugs or contribute patches, please submit them to
|
||||
bugzilla:
|
||||
http://bugzilla.libsdl.org/
|
||||
|
||||
Enjoy!
|
||||
Sam Lantinga (slouken@libsdl.org)
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
|
||||
This is a list of major changes in SDL's version history.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2.0.2:
|
||||
---------------------------------------------------------------------------
|
||||
General:
|
||||
* Added an API to load a database of Game Controller mappings from a file:
|
||||
SDL_GameControllerAddMappingsFromFile
|
||||
* EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share
|
||||
them using SDL_GL_SHARE_WITH_CURRENT_CONTEXT
|
||||
* Added testgles2. testgl2 does not need to link with libGL anymore.
|
||||
|
||||
Windows:
|
||||
* Support for OpenGL ES 2.x contexts using either WGL or EGL (natively via
|
||||
the driver or emulated through ANGLE)
|
||||
|
||||
Android:
|
||||
* Joystick support (minimum SDK version required to build SDL is now 12,
|
||||
the required runtime version remains at 10, but on such devices joystick
|
||||
support won't be available).
|
||||
* Hotplugging support for joysticks
|
||||
|
||||
Linux:
|
||||
* Fixed fullscreen and focused behavior when receiving NotifyGrab events
|
||||
* Wayland support
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
2.0.1:
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
General:
|
||||
* Added an API to get common filesystem paths in SDL_filesystem.h:
|
||||
SDL_GetBasePath(), SDL_GetPrefPath()
|
||||
* Added an API to do optimized YV12 and IYUV texture updates:
|
||||
SDL_UpdateYUVTexture()
|
||||
* Added an API to get the amount of RAM on the system:
|
||||
SDL_GetSystemRAM()
|
||||
* Added a macro to perform timestamp comparisons with SDL_GetTicks():
|
||||
SDL_TICKS_PASSED()
|
||||
* Dramatically improved OpenGL ES 2.0 rendering performance
|
||||
* Added OpenGL attribute SDL_GL_FRAMEBUFFER_SRGB_CAPABLE
|
||||
|
||||
Windows:
|
||||
* Created a static library configuration for the Visual Studio 2010 project
|
||||
* Added a hint to create the Direct3D device with support for multi-threading:
|
||||
SDL_HINT_RENDER_DIRECT3D_THREADSAFE
|
||||
* Added a function to get the D3D9 adapter index for a display:
|
||||
SDL_Direct3D9GetAdapterIndex()
|
||||
* Added a function to get the D3D9 device for a D3D9 renderer:
|
||||
SDL_RenderGetD3D9Device()
|
||||
* Fixed building SDL with the mingw32 toolchain (mingw-w64 is preferred)
|
||||
* Fixed crash when using two XInput controllers at the same time
|
||||
* Fixed detecting a mixture of XInput and DirectInput controllers
|
||||
* Fixed clearing a D3D render target larger than the window
|
||||
* Improved support for format specifiers in SDL_snprintf()
|
||||
|
||||
Mac OS X:
|
||||
* Added support for retina displays:
|
||||
Create your window with the SDL_WINDOW_ALLOW_HIGHDPI flag, and then use SDL_GL_GetDrawableSize() to find the actual drawable size. You are responsible for scaling mouse and drawing coordinates appropriately.
|
||||
* Fixed mouse warping in fullscreen mode
|
||||
* Right mouse click is emulated by holding the Ctrl key while left clicking
|
||||
|
||||
Linux:
|
||||
* Fixed float audio support with the PulseAudio driver
|
||||
* Fixed missing line endpoints in the OpenGL renderer on some drivers
|
||||
* X11 symbols are no longer defined to avoid collisions when linking statically
|
||||
|
||||
iOS:
|
||||
* Fixed status bar visibility on iOS 7
|
||||
* Flipped the accelerometer Y axis to match expected values
|
||||
|
||||
Android:
|
||||
IMPORTANT: You MUST get the updated SDLActivity.java to match C code
|
||||
* Moved EGL initialization to native code
|
||||
* Fixed the accelerometer axis rotation relative to the device rotation
|
||||
* Fixed race conditions when handling the EGL context on pause/resume
|
||||
* Touch devices are available for enumeration immediately after init
|
||||
|
||||
Raspberry Pi:
|
||||
* Added support for the Raspberry Pi, see README-raspberrypi.txt for details
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string></string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,43 +0,0 @@
|
||||
==============================================================================
|
||||
About the iPhone OS Demo Applications
|
||||
==============================================================================
|
||||
|
||||
Demos.xcodeproj contains several targets for iPhone oriented SDL demos. These demos are written strictly using SDL 1.3 calls. All the demos except for Fireworks (which requires OpenGL ES) should work on platforms other than iPhone OS, though you'll need to write your own compile script. To run them on your favorite platform, you may wish to set the macros SCREEN_WIDTH and SCREEN_HEIGHT, located in common.h.
|
||||
|
||||
Common files:
|
||||
|
||||
common.c and common.h contain code common to all demo applications. This includes macros about the screen dimensions (in pixels), simple error handling, and functions for generating random numbers.
|
||||
|
||||
Rectangles (rectangles.c):
|
||||
|
||||
Draws randomly sized and colored rectangles all over the screen by using SDL_RenderFill. This is the simplest of all the demos.
|
||||
|
||||
Happy (happy.c):
|
||||
|
||||
Loads the classic happy-face bitmap and draws a large number of happy faces bouncing around the screen. Shows how you can load a bitmap into an SDL_Texture.
|
||||
|
||||
Accelerometer (accelerometer.c):
|
||||
|
||||
Uses the iPhone's accelerometer as a joystick device to move a spaceship around the screen. Note the use of the macro SDL_IPHONE_MAX_GFORCE (normally defined in SDL_config_iphoneos.h) which converts between the Sint16 number returned by SDL_JoystickGetAxis, and the floating point units of g-force reported natively by the iPhone.
|
||||
|
||||
Touch (touch.c):
|
||||
|
||||
Acts as a finger-paint type program. Demonstrates how you can use SDL mouse input to accept touch input from the iPhone. If SDL for iPhone is compiled with multitouch as multiple mouse emulation (SDL_IPHONE_MULTIPLE_MICE in SDL_config_iphoneos.h) then the program will accept multiple finger inputs simultaneously.
|
||||
|
||||
Mixer (mixer.c):
|
||||
|
||||
Displays several rectangular buttons which can be used as a virtual drumkit. Demonstrates how you can play .wav sounds in SDL and how you can use SDL_MixAudioFormat to build a software mixer that can play multiple sounds at once.
|
||||
|
||||
Keyboard (keyboard.c):
|
||||
|
||||
Loads a bitmap font and let's the user type words, numbers, and symbols using the iPhone's virtual keyboard. The iPhone's onscreen keyboard visibility is toggled when the user taps the screen. If the user types ':)' a happy face is displayed. Demonstrates how to use functions added to the iPhone implementation of SDL to toggle keyboard onscreen visibility.
|
||||
|
||||
Fireworks (fireworks.c):
|
||||
|
||||
Displays a fireworks show. When you tap the iPhone's screen, fireworks fly from the bottom of the screen and explode at the point that you tapped. Demonstrates how you can use SDL on iPhone to build an OpenGL ES based application. Shows you how you can use SDL_LoadBMP to load a bmp image and convert it to an OpenGL ES texture. Of lesser importance, shows how you can use OpenGL ES point sprites to build an efficient particle system.
|
||||
|
||||
==============================================================================
|
||||
Building and Running the demos
|
||||
==============================================================================
|
||||
|
||||
Before building the demos you must first build SDL as a static library for BOTH the iPhone Simulator and the iPhone itself. See the iPhone SDL main README file for directions on how to do this. Once this is done, simply launch XCode, select the target you'd like to build, select the active SDK (simulator or device), and then build and go.
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* common.c
|
||||
* written by Holmes Futrell
|
||||
* use however you want
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "SDL.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
Produces a random int x, min <= x <= max
|
||||
following a uniform distribution
|
||||
*/
|
||||
int
|
||||
randomInt(int min, int max)
|
||||
{
|
||||
return min + rand() % (max - min + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
Produces a random float x, min <= x <= max
|
||||
following a uniform distribution
|
||||
*/
|
||||
float
|
||||
randomFloat(float min, float max)
|
||||
{
|
||||
return rand() / (float) RAND_MAX *(max - min) + min;
|
||||
}
|
||||
|
||||
void
|
||||
fatalError(const char *string)
|
||||
{
|
||||
printf("%s: %s\n", string, SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* happy.c
|
||||
* written by Holmes Futrell
|
||||
* use however you want
|
||||
*/
|
||||
|
||||
#include "SDL.h"
|
||||
#include "common.h"
|
||||
|
||||
#define NUM_HAPPY_FACES 100 /* number of faces to draw */
|
||||
#define MILLESECONDS_PER_FRAME 16 /* about 60 frames per second */
|
||||
#define HAPPY_FACE_SIZE 32 /* width and height of happyface (pixels) */
|
||||
|
||||
static SDL_Texture *texture = 0; /* reference to texture holding happyface */
|
||||
|
||||
static struct
|
||||
{
|
||||
float x, y; /* position of happyface */
|
||||
float xvel, yvel; /* velocity of happyface */
|
||||
} faces[NUM_HAPPY_FACES];
|
||||
|
||||
/*
|
||||
Sets initial positions and velocities of happyfaces
|
||||
units of velocity are pixels per millesecond
|
||||
*/
|
||||
void
|
||||
initializeHappyFaces()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < NUM_HAPPY_FACES; i++) {
|
||||
faces[i].x = randomFloat(0.0f, SCREEN_WIDTH - HAPPY_FACE_SIZE);
|
||||
faces[i].y = randomFloat(0.0f, SCREEN_HEIGHT - HAPPY_FACE_SIZE);
|
||||
faces[i].xvel = randomFloat(-0.1f, 0.1f);
|
||||
faces[i].yvel = randomFloat(-0.1f, 0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
render(SDL_Renderer *renderer)
|
||||
{
|
||||
|
||||
int i;
|
||||
SDL_Rect srcRect;
|
||||
SDL_Rect dstRect;
|
||||
|
||||
/* setup boundaries for happyface bouncing */
|
||||
Uint16 maxx = SCREEN_WIDTH - HAPPY_FACE_SIZE;
|
||||
Uint16 maxy = SCREEN_HEIGHT - HAPPY_FACE_SIZE;
|
||||
Uint16 minx = 0;
|
||||
Uint16 miny = 0;
|
||||
|
||||
/* setup rects for drawing */
|
||||
srcRect.x = 0;
|
||||
srcRect.y = 0;
|
||||
srcRect.w = HAPPY_FACE_SIZE;
|
||||
srcRect.h = HAPPY_FACE_SIZE;
|
||||
dstRect.w = HAPPY_FACE_SIZE;
|
||||
dstRect.h = HAPPY_FACE_SIZE;
|
||||
|
||||
/* fill background in with black */
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
/*
|
||||
loop through all the happy faces:
|
||||
- update position
|
||||
- update velocity (if boundary is hit)
|
||||
- draw
|
||||
*/
|
||||
for (i = 0; i < NUM_HAPPY_FACES; i++) {
|
||||
faces[i].x += faces[i].xvel * MILLESECONDS_PER_FRAME;
|
||||
faces[i].y += faces[i].yvel * MILLESECONDS_PER_FRAME;
|
||||
if (faces[i].x > maxx) {
|
||||
faces[i].x = maxx;
|
||||
faces[i].xvel = -faces[i].xvel;
|
||||
} else if (faces[i].y > maxy) {
|
||||
faces[i].y = maxy;
|
||||
faces[i].yvel = -faces[i].yvel;
|
||||
}
|
||||
if (faces[i].x < minx) {
|
||||
faces[i].x = minx;
|
||||
faces[i].xvel = -faces[i].xvel;
|
||||
} else if (faces[i].y < miny) {
|
||||
faces[i].y = miny;
|
||||
faces[i].yvel = -faces[i].yvel;
|
||||
}
|
||||
dstRect.x = faces[i].x;
|
||||
dstRect.y = faces[i].y;
|
||||
SDL_RenderCopy(renderer, texture, &srcRect, &dstRect);
|
||||
}
|
||||
/* update screen */
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
loads the happyface graphic into a texture
|
||||
*/
|
||||
void
|
||||
initializeTexture(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Surface *bmp_surface;
|
||||
/* load the bmp */
|
||||
bmp_surface = SDL_LoadBMP("icon.bmp");
|
||||
if (bmp_surface == NULL) {
|
||||
fatalError("could not load bmp");
|
||||
}
|
||||
/* set white to transparent on the happyface */
|
||||
SDL_SetColorKey(bmp_surface, 1,
|
||||
SDL_MapRGB(bmp_surface->format, 255, 255, 255));
|
||||
|
||||
/* convert RGBA surface to texture */
|
||||
texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
||||
if (texture == 0) {
|
||||
fatalError("could not create texture");
|
||||
}
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
|
||||
/* free up allocated memory */
|
||||
SDL_FreeSurface(bmp_surface);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
Uint32 startFrame;
|
||||
Uint32 endFrame;
|
||||
Uint32 delay;
|
||||
int done;
|
||||
|
||||
/* initialize SDL */
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
fatalError("Could not initialize SDL");
|
||||
}
|
||||
window = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
SDL_WINDOW_OPENGL |
|
||||
SDL_WINDOW_BORDERLESS);
|
||||
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
|
||||
initializeTexture(renderer);
|
||||
initializeHappyFaces();
|
||||
|
||||
/* main loop */
|
||||
done = 0;
|
||||
while (!done) {
|
||||
startFrame = SDL_GetTicks();
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_QUIT) {
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
render(renderer);
|
||||
endFrame = SDL_GetTicks();
|
||||
|
||||
/* figure out how much time we have left, and then sleep */
|
||||
delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame);
|
||||
if (delay < 0) {
|
||||
delay = 0;
|
||||
} else if (delay > MILLESECONDS_PER_FRAME) {
|
||||
delay = MILLESECONDS_PER_FRAME;
|
||||
}
|
||||
SDL_Delay(delay);
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
SDL_DestroyTexture(texture);
|
||||
/* shutdown SDL */
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
/*
|
||||
* keyboard.c
|
||||
* written by Holmes Futrell
|
||||
* use however you want
|
||||
*/
|
||||
|
||||
#import "SDL.h"
|
||||
#import "common.h"
|
||||
|
||||
#define GLYPH_SIZE_IMAGE 16 /* size of glyphs (characters) in the bitmap font file */
|
||||
#define GLYPH_SIZE_SCREEN 32 /* size of glyphs (characters) as shown on the screen */
|
||||
|
||||
static SDL_Texture *texture; /* texture where we'll hold our font */
|
||||
|
||||
/* function declarations */
|
||||
void cleanup(void);
|
||||
void drawBlank(int x, int y);
|
||||
|
||||
static SDL_Renderer *renderer;
|
||||
static int numChars = 0; /* number of characters we've typed so far */
|
||||
static SDL_bool lastCharWasColon = 0; /* we use this to detect sequences such as :) */
|
||||
static SDL_Color bg_color = { 50, 50, 100, 255 }; /* color of background */
|
||||
|
||||
/* this structure maps a scancode to an index in our bitmap font.
|
||||
it also contains data about under which modifiers the mapping is valid
|
||||
(for example, we don't want shift + 1 to produce the character '1',
|
||||
but rather the character '!')
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
SDL_Scancode scancode; /* scancode of the key we want to map */
|
||||
int allow_no_mod; /* is the map valid if the key has no modifiers? */
|
||||
SDL_Keymod mod; /* what modifiers are allowed for the mapping */
|
||||
int index; /* what index in the font does the scancode map to */
|
||||
} fontMapping;
|
||||
|
||||
#define TABLE_SIZE 51 /* size of our table which maps keys and modifiers to font indices */
|
||||
|
||||
/* Below is the table that defines the mapping between scancodes and modifiers to indices in the
|
||||
bitmap font. As an example, then line '{ SDL_SCANCODE_A, 1, KMOD_SHIFT, 33 }' means, map
|
||||
the key A (which has scancode SDL_SCANCODE_A) to index 33 in the font (which is a picture of an A),
|
||||
The '1' means that the mapping is valid even if there are no modifiers, and KMOD_SHIFT means the
|
||||
mapping is also valid if the user is holding shift.
|
||||
*/
|
||||
fontMapping map[TABLE_SIZE] = {
|
||||
|
||||
{SDL_SCANCODE_A, 1, KMOD_SHIFT, 33}, /* A */
|
||||
{SDL_SCANCODE_B, 1, KMOD_SHIFT, 34}, /* B */
|
||||
{SDL_SCANCODE_C, 1, KMOD_SHIFT, 35}, /* C */
|
||||
{SDL_SCANCODE_D, 1, KMOD_SHIFT, 36}, /* D */
|
||||
{SDL_SCANCODE_E, 1, KMOD_SHIFT, 37}, /* E */
|
||||
{SDL_SCANCODE_F, 1, KMOD_SHIFT, 38}, /* F */
|
||||
{SDL_SCANCODE_G, 1, KMOD_SHIFT, 39}, /* G */
|
||||
{SDL_SCANCODE_H, 1, KMOD_SHIFT, 40}, /* H */
|
||||
{SDL_SCANCODE_I, 1, KMOD_SHIFT, 41}, /* I */
|
||||
{SDL_SCANCODE_J, 1, KMOD_SHIFT, 42}, /* J */
|
||||
{SDL_SCANCODE_K, 1, KMOD_SHIFT, 43}, /* K */
|
||||
{SDL_SCANCODE_L, 1, KMOD_SHIFT, 44}, /* L */
|
||||
{SDL_SCANCODE_M, 1, KMOD_SHIFT, 45}, /* M */
|
||||
{SDL_SCANCODE_N, 1, KMOD_SHIFT, 46}, /* N */
|
||||
{SDL_SCANCODE_O, 1, KMOD_SHIFT, 47}, /* O */
|
||||
{SDL_SCANCODE_P, 1, KMOD_SHIFT, 48}, /* P */
|
||||
{SDL_SCANCODE_Q, 1, KMOD_SHIFT, 49}, /* Q */
|
||||
{SDL_SCANCODE_R, 1, KMOD_SHIFT, 50}, /* R */
|
||||
{SDL_SCANCODE_S, 1, KMOD_SHIFT, 51}, /* S */
|
||||
{SDL_SCANCODE_T, 1, KMOD_SHIFT, 52}, /* T */
|
||||
{SDL_SCANCODE_U, 1, KMOD_SHIFT, 53}, /* U */
|
||||
{SDL_SCANCODE_V, 1, KMOD_SHIFT, 54}, /* V */
|
||||
{SDL_SCANCODE_W, 1, KMOD_SHIFT, 55}, /* W */
|
||||
{SDL_SCANCODE_X, 1, KMOD_SHIFT, 56}, /* X */
|
||||
{SDL_SCANCODE_Y, 1, KMOD_SHIFT, 57}, /* Y */
|
||||
{SDL_SCANCODE_Z, 1, KMOD_SHIFT, 58}, /* Z */
|
||||
{SDL_SCANCODE_0, 1, 0, 16}, /* 0 */
|
||||
{SDL_SCANCODE_1, 1, 0, 17}, /* 1 */
|
||||
{SDL_SCANCODE_2, 1, 0, 18}, /* 2 */
|
||||
{SDL_SCANCODE_3, 1, 0, 19}, /* 3 */
|
||||
{SDL_SCANCODE_4, 1, 0, 20}, /* 4 */
|
||||
{SDL_SCANCODE_5, 1, 0, 21}, /* 5 */
|
||||
{SDL_SCANCODE_6, 1, 0, 22}, /* 6 */
|
||||
{SDL_SCANCODE_7, 1, 0, 23}, /* 7 */
|
||||
{SDL_SCANCODE_8, 1, 0, 24}, /* 8 */
|
||||
{SDL_SCANCODE_9, 1, 0, 25}, /* 9 */
|
||||
{SDL_SCANCODE_SPACE, 1, 0, 0}, /* ' ' */
|
||||
{SDL_SCANCODE_1, 0, KMOD_SHIFT, 1}, /* ! */
|
||||
{SDL_SCANCODE_SLASH, 0, KMOD_SHIFT, 31}, /* ? */
|
||||
{SDL_SCANCODE_SLASH, 1, 0, 15}, /* / */
|
||||
{SDL_SCANCODE_COMMA, 1, 0, 12}, /* , */
|
||||
{SDL_SCANCODE_SEMICOLON, 1, 0, 27}, /* ; */
|
||||
{SDL_SCANCODE_SEMICOLON, 0, KMOD_SHIFT, 26}, /* : */
|
||||
{SDL_SCANCODE_PERIOD, 1, 0, 14}, /* . */
|
||||
{SDL_SCANCODE_MINUS, 1, 0, 13}, /* - */
|
||||
{SDL_SCANCODE_EQUALS, 0, KMOD_SHIFT, 11}, /* = */
|
||||
{SDL_SCANCODE_APOSTROPHE, 1, 0, 7}, /* ' */
|
||||
{SDL_SCANCODE_APOSTROPHE, 0, KMOD_SHIFT, 2}, /* " */
|
||||
{SDL_SCANCODE_5, 0, KMOD_SHIFT, 5}, /* % */
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
This function maps an SDL_KeySym to an index in the bitmap font.
|
||||
It does so by scanning through the font mapping table one entry
|
||||
at a time.
|
||||
|
||||
If a match is found (scancode and allowed modifiers), the proper
|
||||
index is returned.
|
||||
|
||||
If there is no entry for the key, -1 is returned
|
||||
*/
|
||||
int
|
||||
keyToIndex(SDL_Keysym key)
|
||||
{
|
||||
int i, index = -1;
|
||||
for (i = 0; i < TABLE_SIZE; i++) {
|
||||
fontMapping compare = map[i];
|
||||
if (key.scancode == compare.scancode) {
|
||||
/* if this entry is valid with no key mod and we have no keymod, or if
|
||||
the key's modifiers are allowed modifiers for that mapping */
|
||||
if ((compare.allow_no_mod && key.mod == 0)
|
||||
|| (key.mod & compare.mod)) {
|
||||
index = compare.index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/*
|
||||
This function returns and x,y position for a given character number.
|
||||
It is used for positioning each character of text
|
||||
*/
|
||||
void
|
||||
getPositionForCharNumber(int n, int *x, int *y)
|
||||
{
|
||||
int x_padding = 16; /* padding space on left and right side of screen */
|
||||
int y_padding = 32; /* padding space at top of screen */
|
||||
/* figure out the number of characters that can fit horizontally across the screen */
|
||||
int max_x_chars = (SCREEN_WIDTH - 2 * x_padding) / GLYPH_SIZE_SCREEN;
|
||||
int line_separation = 5; /* pixels between each line */
|
||||
*x = (n % max_x_chars) * GLYPH_SIZE_SCREEN + x_padding;
|
||||
*y = (n / max_x_chars) * (GLYPH_SIZE_SCREEN + line_separation) +
|
||||
y_padding;
|
||||
}
|
||||
|
||||
void
|
||||
drawIndex(int index)
|
||||
{
|
||||
int x, y;
|
||||
getPositionForCharNumber(numChars, &x, &y);
|
||||
SDL_Rect srcRect =
|
||||
{ GLYPH_SIZE_IMAGE * index, 0, GLYPH_SIZE_IMAGE, GLYPH_SIZE_IMAGE };
|
||||
SDL_Rect dstRect = { x, y, GLYPH_SIZE_SCREEN, GLYPH_SIZE_SCREEN };
|
||||
drawBlank(x, y);
|
||||
SDL_RenderCopy(renderer, texture, &srcRect, &dstRect);
|
||||
}
|
||||
|
||||
/* draws the cursor icon at the current end position of the text */
|
||||
void
|
||||
drawCursor(void)
|
||||
{
|
||||
drawIndex(29); /* cursor is at index 29 in the bitmap font */
|
||||
}
|
||||
|
||||
/* paints over a glyph sized region with the background color
|
||||
in effect it erases the area
|
||||
*/
|
||||
void
|
||||
drawBlank(int x, int y)
|
||||
{
|
||||
SDL_Rect rect = { x, y, GLYPH_SIZE_SCREEN, GLYPH_SIZE_SCREEN };
|
||||
SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b, bg_color.a);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
/* moves backwards one character, erasing the last one put down */
|
||||
void
|
||||
backspace(void)
|
||||
{
|
||||
int x, y;
|
||||
if (numChars > 0) {
|
||||
getPositionForCharNumber(numChars, &x, &y);
|
||||
drawBlank(x, y);
|
||||
numChars--;
|
||||
getPositionForCharNumber(numChars, &x, &y);
|
||||
drawBlank(x, y);
|
||||
drawCursor();
|
||||
}
|
||||
}
|
||||
|
||||
/* this function loads our font into an SDL_Texture and returns the SDL_Texture */
|
||||
SDL_Texture*
|
||||
loadFont(void)
|
||||
{
|
||||
|
||||
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
|
||||
|
||||
if (!surface) {
|
||||
printf("Error loading bitmap: %s\n", SDL_GetError());
|
||||
return 0;
|
||||
} else {
|
||||
/* set the transparent color for the bitmap font (hot pink) */
|
||||
SDL_SetColorKey(surface, 1, SDL_MapRGB(surface->format, 238, 0, 252));
|
||||
/* now we convert the surface to our desired pixel format */
|
||||
int format = SDL_PIXELFORMAT_ABGR8888; /* desired texture format */
|
||||
Uint32 Rmask, Gmask, Bmask, Amask; /* masks for desired format */
|
||||
int bpp; /* bits per pixel for desired format */
|
||||
SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask,
|
||||
&Amask);
|
||||
SDL_Surface *converted =
|
||||
SDL_CreateRGBSurface(0, surface->w, surface->h, bpp, Rmask, Gmask,
|
||||
Bmask, Amask);
|
||||
SDL_BlitSurface(surface, NULL, converted, NULL);
|
||||
/* create our texture */
|
||||
texture =
|
||||
SDL_CreateTextureFromSurface(renderer, converted);
|
||||
if (texture == 0) {
|
||||
printf("texture creation failed: %s\n", SDL_GetError());
|
||||
} else {
|
||||
/* set blend mode for our texture */
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_FreeSurface(converted);
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int index; /* index of last key we pushed in the bitmap font */
|
||||
SDL_Window *window;
|
||||
SDL_Event event; /* last event received */
|
||||
SDL_Keymod mod; /* key modifiers of last key we pushed */
|
||||
SDL_Scancode scancode; /* scancode of last key we pushed */
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
printf("Error initializing SDL: %s", SDL_GetError());
|
||||
}
|
||||
/* create window */
|
||||
window = SDL_CreateWindow("iPhone keyboard test", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
|
||||
/* create renderer */
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
|
||||
/* load up our font */
|
||||
loadFont();
|
||||
|
||||
/* draw the background, we'll just paint over it */
|
||||
SDL_SetRenderDrawColor(renderer, bg_color.r, bg_color.g, bg_color.b, bg_color.a);
|
||||
SDL_RenderFillRect(renderer, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
int done = 0;
|
||||
/* loop till we get SDL_Quit */
|
||||
while (SDL_WaitEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_QUIT:
|
||||
done = 1;
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
index = keyToIndex(event.key.keysym);
|
||||
scancode = event.key.keysym.scancode;
|
||||
mod = event.key.keysym.mod;
|
||||
if (scancode == SDL_SCANCODE_DELETE) {
|
||||
/* if user hit delete, delete the last character */
|
||||
backspace();
|
||||
lastCharWasColon = 0;
|
||||
} else if (lastCharWasColon && scancode == SDL_SCANCODE_0
|
||||
&& (mod & KMOD_SHIFT)) {
|
||||
/* if our last key was a colon and this one is a close paren, the make a hoppy face */
|
||||
backspace();
|
||||
drawIndex(32); /* index for happy face */
|
||||
numChars++;
|
||||
drawCursor();
|
||||
lastCharWasColon = 0;
|
||||
} else if (index != -1) {
|
||||
/* if we aren't doing a happy face, then just draw the normal character */
|
||||
drawIndex(index);
|
||||
numChars++;
|
||||
drawCursor();
|
||||
lastCharWasColon =
|
||||
(event.key.keysym.scancode == SDL_SCANCODE_SEMICOLON
|
||||
&& (event.key.keysym.mod & KMOD_SHIFT));
|
||||
}
|
||||
/* check if the key was a colon */
|
||||
/* draw our updates to the screen */
|
||||
SDL_RenderPresent(renderer);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
/* mouse up toggles onscreen keyboard visibility */
|
||||
if (SDL_IsTextInputActive()) {
|
||||
SDL_StopTextInput();
|
||||
} else {
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* clean up after ourselves like a good kiddy */
|
||||
void
|
||||
cleanup(void)
|
||||
{
|
||||
SDL_DestroyTexture(texture);
|
||||
SDL_Quit();
|
||||
}
|
||||
@@ -1,353 +0,0 @@
|
||||
/*
|
||||
* mixer.c
|
||||
* written by Holmes Futrell
|
||||
* use however you want
|
||||
*/
|
||||
|
||||
#import "SDL.h"
|
||||
#import "common.h"
|
||||
|
||||
#define NUM_CHANNELS 8 /* max number of sounds we can play at once */
|
||||
#define NUM_DRUMS 4 /* number of drums in our set */
|
||||
#define MILLESECONDS_PER_FRAME 16 /* about 60 frames per second */
|
||||
|
||||
static struct
|
||||
{
|
||||
SDL_Rect rect; /* where the button is drawn */
|
||||
SDL_Color upColor; /* color when button is not active */
|
||||
SDL_Color downColor; /* color when button is active */
|
||||
int isPressed; /* is the button being pressed ? */
|
||||
int touchIndex; /* what mouse (touch) index pressed the button ? */
|
||||
} buttons[NUM_DRUMS];
|
||||
|
||||
struct sound
|
||||
{
|
||||
Uint8 *buffer; /* audio buffer for sound file */
|
||||
Uint32 length; /* length of the buffer (in bytes) */
|
||||
};
|
||||
|
||||
/* this array holds the audio for the drum noises */
|
||||
static struct sound drums[NUM_DRUMS];
|
||||
|
||||
/* function declarations */
|
||||
void handleMouseButtonDown(SDL_Event * event);
|
||||
void handleMouseButtonUp(SDL_Event * event);
|
||||
int playSound(struct sound *);
|
||||
void initializeButtons();
|
||||
void audioCallback(void *userdata, Uint8 * stream, int len);
|
||||
void loadSound(const char *file, struct sound *s);
|
||||
|
||||
struct
|
||||
{
|
||||
/* channel array holds information about currently playing sounds */
|
||||
struct
|
||||
{
|
||||
Uint8 *position; /* what is the current position in the buffer of this sound ? */
|
||||
Uint32 remaining; /* how many bytes remaining before we're done playing the sound ? */
|
||||
Uint32 timestamp; /* when did this sound start playing ? */
|
||||
} channels[NUM_CHANNELS];
|
||||
SDL_AudioSpec outputSpec; /* what audio format are we using for output? */
|
||||
int numSoundsPlaying; /* how many sounds are currently playing */
|
||||
} mixer;
|
||||
|
||||
/* sets up the buttons (color, position, state) */
|
||||
void
|
||||
initializeButtons()
|
||||
{
|
||||
|
||||
int i;
|
||||
int spacing = 10; /* gap between drum buttons */
|
||||
SDL_Rect buttonRect; /* keeps track of where to position drum */
|
||||
SDL_Color upColor = { 86, 86, 140, 255 }; /* color of drum when not pressed */
|
||||
SDL_Color downColor = { 191, 191, 221, 255 }; /* color of drum when pressed */
|
||||
|
||||
buttonRect.x = spacing;
|
||||
buttonRect.y = spacing;
|
||||
buttonRect.w = SCREEN_WIDTH - 2 * spacing;
|
||||
buttonRect.h = (SCREEN_HEIGHT - (NUM_DRUMS + 1) * spacing) / NUM_DRUMS;
|
||||
|
||||
/* setup each button */
|
||||
for (i = 0; i < NUM_DRUMS; i++) {
|
||||
|
||||
buttons[i].rect = buttonRect;
|
||||
buttons[i].isPressed = 0;
|
||||
buttons[i].upColor = upColor;
|
||||
buttons[i].downColor = downColor;
|
||||
|
||||
buttonRect.y += spacing + buttonRect.h; /* setup y coordinate for next drum */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
loads a wav file (stored in 'file'), converts it to the mixer's output format,
|
||||
and stores the resulting buffer and length in the sound structure
|
||||
*/
|
||||
void
|
||||
loadSound(const char *file, struct sound *s)
|
||||
{
|
||||
SDL_AudioSpec spec; /* the audio format of the .wav file */
|
||||
SDL_AudioCVT cvt; /* used to convert .wav to output format when formats differ */
|
||||
int result;
|
||||
if (SDL_LoadWAV(file, &spec, &s->buffer, &s->length) == NULL) {
|
||||
fatalError("could not load .wav");
|
||||
}
|
||||
/* build the audio converter */
|
||||
result = SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
|
||||
mixer.outputSpec.format,
|
||||
mixer.outputSpec.channels,
|
||||
mixer.outputSpec.freq);
|
||||
if (result == -1) {
|
||||
fatalError("could not build audio CVT");
|
||||
} else if (result != 0) {
|
||||
/*
|
||||
this happens when the .wav format differs from the output format.
|
||||
we convert the .wav buffer here
|
||||
*/
|
||||
cvt.buf = (Uint8 *) SDL_malloc(s->length * cvt.len_mult); /* allocate conversion buffer */
|
||||
cvt.len = s->length; /* set conversion buffer length */
|
||||
SDL_memcpy(cvt.buf, s->buffer, s->length); /* copy sound to conversion buffer */
|
||||
if (SDL_ConvertAudio(&cvt) == -1) { /* convert the sound */
|
||||
fatalError("could not convert .wav");
|
||||
}
|
||||
SDL_free(s->buffer); /* free the original (unconverted) buffer */
|
||||
s->buffer = cvt.buf; /* point sound buffer to converted buffer */
|
||||
s->length = cvt.len_cvt; /* set sound buffer's new length */
|
||||
}
|
||||
}
|
||||
|
||||
/* called from main event loop */
|
||||
void
|
||||
handleMouseButtonDown(SDL_Event * event)
|
||||
{
|
||||
|
||||
int x, y, mouseIndex, i, drumIndex;
|
||||
|
||||
mouseIndex = 0;
|
||||
drumIndex = -1;
|
||||
|
||||
SDL_GetMouseState(&x, &y);
|
||||
/* check if we hit any of the drum buttons */
|
||||
for (i = 0; i < NUM_DRUMS; i++) {
|
||||
if (x >= buttons[i].rect.x
|
||||
&& x < buttons[i].rect.x + buttons[i].rect.w
|
||||
&& y >= buttons[i].rect.y
|
||||
&& y < buttons[i].rect.y + buttons[i].rect.h) {
|
||||
drumIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (drumIndex != -1) {
|
||||
/* if we hit a button */
|
||||
buttons[drumIndex].touchIndex = mouseIndex;
|
||||
buttons[drumIndex].isPressed = 1;
|
||||
playSound(&drums[drumIndex]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* called from main event loop */
|
||||
void
|
||||
handleMouseButtonUp(SDL_Event * event)
|
||||
{
|
||||
int i;
|
||||
int mouseIndex = 0;
|
||||
/* check if this should cause any of the buttons to become unpressed */
|
||||
for (i = 0; i < NUM_DRUMS; i++) {
|
||||
if (buttons[i].touchIndex == mouseIndex) {
|
||||
buttons[i].isPressed = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* draws buttons to screen */
|
||||
void
|
||||
render(SDL_Renderer *renderer)
|
||||
{
|
||||
int i;
|
||||
SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255);
|
||||
SDL_RenderClear(renderer); /* draw background (gray) */
|
||||
/* draw the drum buttons */
|
||||
for (i = 0; i < NUM_DRUMS; i++) {
|
||||
SDL_Color color =
|
||||
buttons[i].isPressed ? buttons[i].downColor : buttons[i].upColor;
|
||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a);
|
||||
SDL_RenderFillRect(renderer, &buttons[i].rect);
|
||||
}
|
||||
/* update the screen */
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
/*
|
||||
finds a sound channel in the mixer for a sound
|
||||
and sets it up to start playing
|
||||
*/
|
||||
int
|
||||
playSound(struct sound *s)
|
||||
{
|
||||
/*
|
||||
find an empty channel to play on.
|
||||
if no channel is available, use oldest channel
|
||||
*/
|
||||
int i;
|
||||
int selected_channel = -1;
|
||||
int oldest_channel = 0;
|
||||
|
||||
if (mixer.numSoundsPlaying == 0) {
|
||||
/* we're playing a sound now, so start audio callback back up */
|
||||
SDL_PauseAudio(0);
|
||||
}
|
||||
|
||||
/* find a sound channel to play the sound on */
|
||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||
if (mixer.channels[i].position == NULL) {
|
||||
/* if no sound on this channel, select it */
|
||||
selected_channel = i;
|
||||
break;
|
||||
}
|
||||
/* if this channel's sound is older than the oldest so far, set it to oldest */
|
||||
if (mixer.channels[i].timestamp <
|
||||
mixer.channels[oldest_channel].timestamp)
|
||||
oldest_channel = i;
|
||||
}
|
||||
|
||||
/* no empty channels, take the oldest one */
|
||||
if (selected_channel == -1)
|
||||
selected_channel = oldest_channel;
|
||||
else
|
||||
mixer.numSoundsPlaying++;
|
||||
|
||||
/* point channel data to wav data */
|
||||
mixer.channels[selected_channel].position = s->buffer;
|
||||
mixer.channels[selected_channel].remaining = s->length;
|
||||
mixer.channels[selected_channel].timestamp = SDL_GetTicks();
|
||||
|
||||
return selected_channel;
|
||||
}
|
||||
|
||||
/*
|
||||
Called from SDL's audio system. Supplies sound input with data by mixing together all
|
||||
currently playing sound effects.
|
||||
*/
|
||||
void
|
||||
audioCallback(void *userdata, Uint8 * stream, int len)
|
||||
{
|
||||
int i;
|
||||
int copy_amt;
|
||||
SDL_memset(stream, mixer.outputSpec.silence, len); /* initialize buffer to silence */
|
||||
/* for each channel, mix in whatever is playing on that channel */
|
||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||
if (mixer.channels[i].position == NULL) {
|
||||
/* if no sound is playing on this channel */
|
||||
continue; /* nothing to do for this channel */
|
||||
}
|
||||
|
||||
/* copy len bytes to the buffer, unless we have fewer than len bytes remaining */
|
||||
copy_amt =
|
||||
mixer.channels[i].remaining <
|
||||
len ? mixer.channels[i].remaining : len;
|
||||
|
||||
/* mix this sound effect with the output */
|
||||
SDL_MixAudioFormat(stream, mixer.channels[i].position,
|
||||
mixer.outputSpec.format, copy_amt, 150);
|
||||
|
||||
/* update buffer position in sound effect and the number of bytes left */
|
||||
mixer.channels[i].position += copy_amt;
|
||||
mixer.channels[i].remaining -= copy_amt;
|
||||
|
||||
/* did we finish playing the sound effect ? */
|
||||
if (mixer.channels[i].remaining == 0) {
|
||||
mixer.channels[i].position = NULL; /* indicates no sound playing on channel anymore */
|
||||
mixer.numSoundsPlaying--;
|
||||
if (mixer.numSoundsPlaying == 0) {
|
||||
/* if no sounds left playing, pause audio callback */
|
||||
SDL_PauseAudio(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int done; /* has user tried to quit ? */
|
||||
SDL_Window *window; /* main window */
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Event event;
|
||||
Uint32 startFrame; /* holds when frame started processing */
|
||||
Uint32 endFrame; /* holds when frame ended processing */
|
||||
Uint32 delay; /* calculated delay, how long should we wait before next frame? */
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
|
||||
fatalError("could not initialize SDL");
|
||||
}
|
||||
window =
|
||||
SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS);
|
||||
renderer = SDL_CreateRenderer(window, 0, 0);
|
||||
|
||||
/* initialize the mixer */
|
||||
SDL_memset(&mixer, 0, sizeof(mixer));
|
||||
/* setup output format */
|
||||
mixer.outputSpec.freq = 44100;
|
||||
mixer.outputSpec.format = AUDIO_S16LSB;
|
||||
mixer.outputSpec.channels = 2;
|
||||
mixer.outputSpec.samples = 256;
|
||||
mixer.outputSpec.callback = audioCallback;
|
||||
mixer.outputSpec.userdata = NULL;
|
||||
|
||||
/* open audio for output */
|
||||
if (SDL_OpenAudio(&mixer.outputSpec, NULL) != 0) {
|
||||
fatalError("Opening audio failed");
|
||||
}
|
||||
|
||||
/* load our drum noises */
|
||||
loadSound("ds_kick_big_amb.wav", &drums[3]);
|
||||
loadSound("ds_brush_snare.wav", &drums[2]);
|
||||
loadSound("ds_loose_skin_mute.wav", &drums[1]);
|
||||
loadSound("ds_china.wav", &drums[0]);
|
||||
|
||||
/* setup positions, colors, and state of buttons */
|
||||
initializeButtons();
|
||||
|
||||
/* enter main loop */
|
||||
done = 0;
|
||||
while (!done) {
|
||||
startFrame = SDL_GetTicks();
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
handleMouseButtonDown(&event);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
handleMouseButtonUp(&event);
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
render(renderer); /* draw buttons */
|
||||
endFrame = SDL_GetTicks();
|
||||
|
||||
/* figure out how much time we have left, and then sleep */
|
||||
delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame);
|
||||
if (delay < 0) {
|
||||
delay = 0;
|
||||
} else if (delay > MILLESECONDS_PER_FRAME) {
|
||||
delay = MILLESECONDS_PER_FRAME;
|
||||
}
|
||||
SDL_Delay(delay);
|
||||
}
|
||||
|
||||
/* cleanup code, let's free up those sound buffers */
|
||||
int i;
|
||||
for (i = 0; i < NUM_DRUMS; i++) {
|
||||
SDL_free(drums[i].buffer);
|
||||
}
|
||||
/* let SDL do its exit code */
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user