forked from nodejs/node-v8
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ohad Rau
committed
Jul 10, 2019
1 parent
c2ab560
commit 6d6f699
Showing
63 changed files
with
1,931 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright 2019 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef INCLUDE_V8_WASM_H_ | ||
#define INCLUDE_V8_WASM_H_ | ||
|
||
#include <cstdint> | ||
#include <cstddef> | ||
#include "v8.h" | ||
|
||
namespace v8 { | ||
namespace wasm { | ||
|
||
class V8_EXPORT Memory { | ||
public: | ||
Memory(size_t pages, uint8_t* data); | ||
size_t size(); | ||
size_t pages(); | ||
uint8_t* data(); | ||
}; | ||
|
||
class V8_EXPORT Context { | ||
public: | ||
explicit Context(Memory* memory); | ||
Context(Memory* memory, Isolate* isolate); | ||
Memory* memory; | ||
Isolate* isolate; | ||
}; | ||
|
||
enum V8_EXPORT ValKind : uint8_t { | ||
I32, | ||
I64, | ||
F32, | ||
F64, | ||
ANYREF = 128, | ||
FUNCREF | ||
}; | ||
|
||
class V8_EXPORT Val { | ||
public: | ||
Val(); | ||
Val(Val&&); | ||
explicit Val(int32_t i); | ||
explicit Val(int64_t i); | ||
explicit Val(float i); | ||
explicit Val(double i); | ||
explicit Val(void* r); | ||
|
||
Val& operator=(Val&&); | ||
|
||
ValKind kind() const; | ||
int32_t i32() const; | ||
int64_t i64() const; | ||
float f32() const; | ||
double f64() const; | ||
void* ref() const; | ||
}; | ||
|
||
class V8_EXPORT FuncType { | ||
public: | ||
FuncType(std::vector<ValKind> params, std::vector<ValKind> results); | ||
|
||
std::vector<ValKind> params() const; | ||
std::vector<ValKind> results() const; | ||
}; | ||
|
||
class V8_EXPORT Func { | ||
public: | ||
// TODO(ohadrau): Specify a better return value (Trap) | ||
using callbackType = void (*)(const Memory*, const Val[], Val[]); | ||
|
||
Func(const FuncType*, callbackType); | ||
|
||
const FuncType* type(); | ||
callbackType callback(); | ||
}; | ||
|
||
void PreloadNative(Isolate* isolate, | ||
const char* module_name, | ||
const char* name, | ||
Func* import); | ||
|
||
} // namespace wasm | ||
} // namespace v8 | ||
|
||
#endif // INCLUDE_V8_WASM_H_ |
Oops, something went wrong.