~webapps/unity-js-scopes/node.js

« back to all changes in this revision

Viewing changes to deps/v8/src/runtime/runtime-proxy.cc

  • Committer: Marcus Tomlinson
  • Date: 2015-11-13 07:59:04 UTC
  • Revision ID: marcus.tomlinson@canonical.com-20151113075904-h0swczmoq1rvstfc
Node v4 (stable)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2014 the V8 project authors. All rights reserved.
 
2
// Use of this source code is governed by a BSD-style license that can be
 
3
// found in the LICENSE file.
 
4
 
 
5
#include "src/v8.h"
 
6
 
 
7
#include "src/arguments.h"
 
8
#include "src/runtime/runtime-utils.h"
 
9
 
 
10
namespace v8 {
 
11
namespace internal {
 
12
 
 
13
RUNTIME_FUNCTION(Runtime_CreateJSProxy) {
 
14
  HandleScope scope(isolate);
 
15
  DCHECK(args.length() == 2);
 
16
  CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0);
 
17
  CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1);
 
18
  if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
 
19
  return *isolate->factory()->NewJSProxy(handler, prototype);
 
20
}
 
21
 
 
22
 
 
23
RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) {
 
24
  HandleScope scope(isolate);
 
25
  DCHECK(args.length() == 4);
 
26
  CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0);
 
27
  CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1);
 
28
  RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
 
29
  CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2);
 
30
  CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3);
 
31
  if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
 
32
  return *isolate->factory()->NewJSFunctionProxy(handler, call_trap,
 
33
                                                 construct_trap, prototype);
 
34
}
 
35
 
 
36
 
 
37
RUNTIME_FUNCTION(Runtime_IsJSProxy) {
 
38
  SealHandleScope shs(isolate);
 
39
  DCHECK(args.length() == 1);
 
40
  CONVERT_ARG_CHECKED(Object, obj, 0);
 
41
  return isolate->heap()->ToBoolean(obj->IsJSProxy());
 
42
}
 
43
 
 
44
 
 
45
RUNTIME_FUNCTION(Runtime_IsJSFunctionProxy) {
 
46
  SealHandleScope shs(isolate);
 
47
  DCHECK(args.length() == 1);
 
48
  CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
 
49
  return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy());
 
50
}
 
51
 
 
52
 
 
53
RUNTIME_FUNCTION(Runtime_GetHandler) {
 
54
  SealHandleScope shs(isolate);
 
55
  DCHECK(args.length() == 1);
 
56
  CONVERT_ARG_CHECKED(JSProxy, proxy, 0);
 
57
  return proxy->handler();
 
58
}
 
59
 
 
60
 
 
61
RUNTIME_FUNCTION(Runtime_GetCallTrap) {
 
62
  SealHandleScope shs(isolate);
 
63
  DCHECK(args.length() == 1);
 
64
  CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
 
65
  return proxy->call_trap();
 
66
}
 
67
 
 
68
 
 
69
RUNTIME_FUNCTION(Runtime_GetConstructTrap) {
 
70
  SealHandleScope shs(isolate);
 
71
  DCHECK(args.length() == 1);
 
72
  CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
 
73
  return proxy->construct_trap();
 
74
}
 
75
 
 
76
 
 
77
RUNTIME_FUNCTION(Runtime_Fix) {
 
78
  HandleScope scope(isolate);
 
79
  DCHECK(args.length() == 1);
 
80
  CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0);
 
81
  JSProxy::Fix(proxy);
 
82
  return isolate->heap()->undefined_value();
 
83
}
 
84
}  // namespace internal
 
85
}  // namespace v8