Skip to content

Commit

Permalink
core, feat: support isFrozen function.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Aug 15, 2018
1 parent 7da2020 commit 62ae2a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions fibjs/include/v8_api.h
Expand Up @@ -27,6 +27,8 @@ void beginCoverage(v8::Isolate* isolate);
void pauseCoverage(v8::Isolate* isolate);
void WriteLcovData(v8::Isolate* isolate, FILE* file);

bool isFrozen(v8::Handle<v8::Object> object);

} /* namespace fibjs */

#endif /* _V8_API_H_ */
20 changes: 13 additions & 7 deletions fibjs/src/base/v8_api.cpp
Expand Up @@ -26,10 +26,11 @@ namespace fibjs {

bool path_isAbsolute(exlib::string path);

v8::Local<v8::BigInt> BigInt_New(v8::Isolate* isolate, uint64_t value) {
v8::internal::Isolate* internal_isolate = reinterpret_cast<v8::internal::Isolate*>(isolate);
v8::internal::Handle<v8::internal::BigInt> result = v8::internal::BigInt::FromUint64(internal_isolate, value);
return v8::Utils::ToLocal(result);
v8::Local<v8::BigInt> BigInt_New(v8::Isolate* isolate, uint64_t value)
{
v8::internal::Isolate* internal_isolate = reinterpret_cast<v8::internal::Isolate*>(isolate);
v8::internal::Handle<v8::internal::BigInt> result = v8::internal::BigInt::FromUint64(internal_isolate, value);
return v8::Utils::ToLocal(result);
}

void InvokeApiInterruptCallbacks(v8::Isolate* isolate)
Expand Down Expand Up @@ -118,9 +119,7 @@ exlib::string traceInfo(v8::Isolate* isolate, int32_t deep, void* entry_fp, void
exlib::string traceInfo(v8::Isolate* isolate, int32_t deep)
{
v8::internal::Isolate* v8_isolate = (v8::internal::Isolate*)isolate;
return traceInfo(isolate, deep
, (void*)*v8_isolate->c_entry_fp_address()
, (void*)*v8_isolate->handler_address());
return traceInfo(isolate, deep, (void*)*v8_isolate->c_entry_fp_address(), (void*)*v8_isolate->handler_address());
}

void beginCoverage(v8::Isolate* isolate)
Expand Down Expand Up @@ -227,4 +226,11 @@ void WriteLcovData(v8::Isolate* isolate, FILE* file)

fclose(file);
}

bool isFrozen(v8::Handle<v8::Object> object)
{
auto obj = v8::Utils::OpenHandle(*object);
v8::Maybe<bool> test = v8::internal::JSReceiver::TestIntegrityLevel(obj, v8::internal::FROZEN);
return test.ToChecked();
}
}

0 comments on commit 62ae2a1

Please sign in to comment.