forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlam_methname.js
161 lines (157 loc) · 5.17 KB
/
lam_methname.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// Generated CODE, PLEASE EDIT WITH CARE
'use strict';
var Caml_builtin_exceptions = require("../runtime/caml_builtin_exceptions");
var Caml_obj = require("../runtime/caml_obj");
var Caml_format = require("../runtime/caml_format");
var Ext_string = require("./ext_string");
var Ext_log = require("./ext_log");
var Lam_current_unit = require("./lam_current_unit");
var $$String = require("../stdlib/string");
var Caml_curry = require("../runtime/caml_curry");
var List = require("../stdlib/list");
function process(x) {
switch (x) {
case "index__" :
case "index__r" :
case "index__r_unsafe" :
case "index__unsafe_r" :
return /* tuple */[
/* Js_read_index */0,
"index"
];
case "index__w" :
case "index__w_js" :
case "index__w_js_unsafe" :
case "index__w_unsafe" :
return /* tuple */[
/* Js_write_index */1,
"index"
];
default:
var sub = "__";
var v = Ext_string.rfind(sub, x);
if (v < 0) {
return /* tuple */[
/* Unknown */{
0: /* None */0,
length: 1,
tag: 2
},
x
];
}
else {
var len_sub = sub.length;
var indicator = Ext_string.tail_from(x, v + len_sub | 0);
var normal_name = $$String.sub(x, 0, v);
switch (indicator) {
case "r" :
return /* tuple */[
/* Js_read */3,
normal_name
];
case "w" :
return /* tuple */[
/* Js_write */2,
normal_name
];
default:
var props = Ext_string.split(/* None */0, indicator, /* "_" */95);
var kind = [/* None */0];
var arity = [/* None */0];
var fail = function (l) {
var error = "invalid indicator" + (indicator + ("in method name " + (x + (":" + Lam_current_unit.get_file(/* () */0)))));
Caml_curry.app1(Ext_log.err(l, /* Format */{
0: /* String */{
0: /* No_padding */0,
1: /* End_of_format */0,
length: 2,
tag: 2
},
1: "%s",
length: 2,
tag: 0
}), error);
throw [
Caml_builtin_exceptions.failure,
error
];
};
var update_ref = function (r, k) {
var match = r[0];
if (match) {
if (Caml_obj.caml_notequal(match[0], k)) {
return fail('File "lam_methname.ml", line 98, characters 42-49');
}
else {
return 0;
}
}
else {
r[0] = /* Some */[k];
return /* () */0;
}
};
List.iter(function (x) {
switch (x) {
case "gen" :
return update_ref(kind, /* Unknown */785140586);
case "js" :
return update_ref(kind, /* Js */16617);
case "ml" :
return update_ref(kind, /* Ml */17279);
case "unsafe" :
return /* () */0;
default:
var exit = 0;
var v;
try {
v = Caml_format.caml_int_of_string(x);
exit = 1;
}
catch (exn){
return fail('File "lam_methname.ml", line 113, characters 34-41');
}
if (exit === 1) {
return update_ref(arity, v);
}
}
}, props);
var arity$1 = arity[0];
var match = kind[0];
var $js;
if (match) {
var match$1 = match[0];
$js = match$1 !== 17279 ? (
match$1 >= 785140586 ? /* Unknown */{
0: arity$1,
length: 1,
tag: 2
} : /* Js */{
0: arity$1,
length: 1,
tag: 0
}
) : /* Ml */{
0: arity$1,
length: 1,
tag: 1
};
}
else {
$js = /* Js */{
0: arity$1,
length: 1,
tag: 0
};
}
return /* tuple */[
$js,
normal_name
];
}
}
}
}
exports.process = process;
/* Ext_log Not a pure module */