forked from swc-project/swc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
privateNamesUnique-3_es5.1.normal.js
82 lines (82 loc) · 2.6 KB
/
privateNamesUnique-3_es5.1.normal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function _checkPrivateRedeclaration(obj, privateCollection) {
if (privateCollection.has(obj)) {
throw new TypeError("Cannot initialize the same private elements twice on an object");
}
}
function _classApplyDescriptorGet(receiver, descriptor) {
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
if (descriptor === undefined) {
throw new TypeError("attempted to " + action + " private static field before its declaration");
}
}
function _classPrivateFieldInit(obj, privateMap, value) {
_checkPrivateRedeclaration(obj, privateMap);
privateMap.set(obj, value);
}
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
_classCheckPrivateStaticAccess(receiver, classConstructor);
_classCheckPrivateStaticFieldDescriptor(descriptor, "get");
return _classApplyDescriptorGet(receiver, descriptor);
}
function _defineProperties(target, props) {
for(var i = 0; i < props.length; i++){
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _classCheckPrivateStaticAccess(receiver, classConstructor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
}
var _foo = new WeakMap();
var A = function A() {
"use strict";
_classCallCheck(this, A);
_classPrivateFieldInit(this, _foo, {
writable: true,
value: 1
});
};
var _foo = {
writable: true,
value: true
}// error (duplicate)
;
var B = /*#__PURE__*/ function() {
"use strict";
function B() {
_classCallCheck(this, B);
}
_createClass(B, [
{
key: "test",
value: function test(x) {
_classStaticPrivateFieldSpecGet(x, B, _foo1); // error (#foo is a static property on B, not an instance property)
}
}
]);
return B;
}();
var _foo1 = {
writable: true,
value: true
};