mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Get Fabrice Bellard's JavaScript engine to build
$ m=tiny $ make -j12 MODE=$m o/$m/third_party/quickjs/qjs.com $ o/$m/third_party/quickjs/qjs.com -e 'console.log(2 + 2)' 4 $ ls -hal o/$m/third_party/quickjs/qjs.com 631.5K See #97
This commit is contained in:
parent
1fbfbb3192
commit
8f52c0d773
73 changed files with 954 additions and 1299 deletions
69
third_party/quickjs/quickjs.h
vendored
69
third_party/quickjs/quickjs.h
vendored
|
@ -1,42 +1,16 @@
|
|||
/*
|
||||
* QuickJS Javascript Engine
|
||||
*
|
||||
* Copyright (c) 2017-2021 Fabrice Bellard
|
||||
* Copyright (c) 2017-2021 Charlie Gordon
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifndef QUICKJS_H
|
||||
#define QUICKJS_H
|
||||
#ifndef COSMOPOLITAN_THIRD_PARTY_QUICKJS_QUICKJS_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_QUICKJS_QUICKJS_H_
|
||||
#include "libc/math.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__STRICT_ANSI__)
|
||||
#define js_likely(x) __builtin_expect(!!(x), 1)
|
||||
#define js_unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#define js_force_inline inline __attribute__((always_inline))
|
||||
#define __js_printf_like(f, a) __attribute__((format(printf, f, a)))
|
||||
#define js_force_inline forceinline
|
||||
#define __js_printf_like(f, a) __attribute__((__format__(__printf__, f, a)))
|
||||
#else
|
||||
#define js_likely(x) (x)
|
||||
#define js_unlikely(x) (x)
|
||||
|
@ -502,22 +476,22 @@ int JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id);
|
|||
|
||||
/* value handling */
|
||||
|
||||
static js_force_inline JSValue JS_NewBool(JSContext *ctx, JS_BOOL val)
|
||||
js_force_inline JSValue JS_NewBool(JSContext *ctx, JS_BOOL val)
|
||||
{
|
||||
return JS_MKVAL(JS_TAG_BOOL, (val != 0));
|
||||
}
|
||||
|
||||
static js_force_inline JSValue JS_NewInt32(JSContext *ctx, int32_t val)
|
||||
js_force_inline JSValue JS_NewInt32(JSContext *ctx, int32_t val)
|
||||
{
|
||||
return JS_MKVAL(JS_TAG_INT, val);
|
||||
}
|
||||
|
||||
static js_force_inline JSValue JS_NewCatchOffset(JSContext *ctx, int32_t val)
|
||||
js_force_inline JSValue JS_NewCatchOffset(JSContext *ctx, int32_t val)
|
||||
{
|
||||
return JS_MKVAL(JS_TAG_CATCH_OFFSET, val);
|
||||
}
|
||||
|
||||
static js_force_inline JSValue JS_NewInt64(JSContext *ctx, int64_t val)
|
||||
js_force_inline JSValue JS_NewInt64(JSContext *ctx, int64_t val)
|
||||
{
|
||||
JSValue v;
|
||||
if (val == (int32_t)val) {
|
||||
|
@ -528,7 +502,7 @@ static js_force_inline JSValue JS_NewInt64(JSContext *ctx, int64_t val)
|
|||
return v;
|
||||
}
|
||||
|
||||
static js_force_inline JSValue JS_NewUint32(JSContext *ctx, uint32_t val)
|
||||
js_force_inline JSValue JS_NewUint32(JSContext *ctx, uint32_t val)
|
||||
{
|
||||
JSValue v;
|
||||
if (val <= 0x7fffffff) {
|
||||
|
@ -542,7 +516,7 @@ static js_force_inline JSValue JS_NewUint32(JSContext *ctx, uint32_t val)
|
|||
JSValue JS_NewBigInt64(JSContext *ctx, int64_t v);
|
||||
JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v);
|
||||
|
||||
static js_force_inline JSValue JS_NewFloat64(JSContext *ctx, double d)
|
||||
js_force_inline JSValue JS_NewFloat64(JSContext *ctx, double d)
|
||||
{
|
||||
JSValue v;
|
||||
int32_t val;
|
||||
|
@ -723,7 +697,7 @@ int JS_IsArray(JSContext *ctx, JSValueConst val);
|
|||
JSValue JS_GetPropertyInternal(JSContext *ctx, JSValueConst obj,
|
||||
JSAtom prop, JSValueConst receiver,
|
||||
JS_BOOL throw_ref_error);
|
||||
static js_force_inline JSValue JS_GetProperty(JSContext *ctx, JSValueConst this_obj,
|
||||
js_force_inline JSValue JS_GetProperty(JSContext *ctx, JSValueConst this_obj,
|
||||
JSAtom prop)
|
||||
{
|
||||
return JS_GetPropertyInternal(ctx, this_obj, prop, this_obj, 0);
|
||||
|
@ -1042,8 +1016,7 @@ int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,
|
|||
#undef js_unlikely
|
||||
#undef js_force_inline
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* QUICKJS_H */
|
||||
/* clang-format on */
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_QUICKJS_QUICKJS_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue