Skip to content

Commit df1a633

Browse files
committed
remove lazy keyword
1 parent ae871c5 commit df1a633

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+234
-791
lines changed

jscomp/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(dirs bsb bsb_exe bsb_helper bsb_helper_exe bsc cmij common core depends ext
2-
frontend gentype jsoo js_parser ml napkin ounit_tests syntax)
2+
frontend gentype jsoo js_parser ml ounit_tests syntax)
33

44
(env
55
(dev

jscomp/runtime/caml_module.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ let init_mod = (loc: (string, int, int), shape: shape) => {
5353
let rec loop = (shape: shape, struct_: Obj.t, idx) =>
5454
switch shape {
5555
| Function => set_field(struct_, idx, Obj.magic(undef_module))
56-
| Lazy => set_field(struct_, idx, Obj.magic(lazy undef_module))
56+
| Lazy => set_field(struct_, idx, Obj.magic(undef_module))
5757
| Class =>
5858
set_field(
5959
struct_,

jscomp/stdlib-406/camlinternalLazy.res

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type t<'a> = {
3535
%%private(external fnToVal: ((. unit) => 'a) => 'a = "%identity")
3636
%%private(external valToFn: 'a => (. unit) => 'a = "%identity")
3737
%%private(external castToConcrete: lazy_t<'a> => t<'a> = "%identity")
38+
%%private(external castFromConcrete: t<'a> => lazy_t<'a> = "%identity")
3839

3940
let is_val = (type a, l: lazy_t<a>): bool => castToConcrete(l).tag
4041

@@ -90,3 +91,19 @@ let force_val = (type a, lzv: lazy_t<a>): a => {
9091
force_val_lazy_block(lzv)
9192
}
9293
}
94+
95+
let from_fun = (type a, closure: (. unit) => a): lazy_t<a> => {
96+
let blk = {
97+
tag: false,
98+
value: fnToVal(closure),
99+
}
100+
castFromConcrete(blk)
101+
}
102+
103+
let from_val = (type a, value: a): lazy_t<a> => {
104+
let blk = {
105+
tag: true,
106+
value: value,
107+
}
108+
castFromConcrete(blk)
109+
}

jscomp/stdlib-406/camlinternalLazy.resi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ let force: lazy_t<'a> => 'a
2525
let force_val: lazy_t<'a> => 'a
2626

2727
let is_val: lazy_t<'a> => bool
28+
29+
let from_fun: ((. unit) => 'a) => lazy_t<'a>
30+
31+
let from_val: 'a => lazy_t<'a>

jscomp/stdlib-406/hashtbl.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let randomized = ref(randomized_default)
5656
let randomize = () => randomized := true
5757
let is_randomized = () => randomized.contents
5858

59-
let prng = lazy Random.State.make_self_init()
59+
let prng = Lazy.from_fun(() => Random.State.make_self_init())
6060

6161
/* Creating a fresh, empty table */
6262

jscomp/stdlib-406/lazy.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ external force: t<'a> => 'a = "%lazy_force"
5555

5656
let force_val = CamlinternalLazy.force_val
5757

58-
let from_fun = f => lazy f()
58+
let from_fun = f => CamlinternalLazy.from_fun((. ) => f())
5959

60-
let from_val = v => lazy v
60+
let from_val = v => CamlinternalLazy.from_val(v)
6161

6262
let is_val = CamlinternalLazy.is_val
6363

jscomp/stdlib-406/stream.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ let iapp = (i, s) => Some({count: 0, data: Sapp(data(i), data(s))})
218218
let icons = (i, s) => Some({count: 0, data: Scons(i, data(s))})
219219
let ising = i => Some({count: 0, data: Scons(i, Sempty)})
220220

221-
let lapp = (f, s) => Some({count: 0, data: Slazy(lazy Sapp(data(f()), data(s)))})
221+
let lapp = (f, s) => Some({count: 0, data: Slazy(Lazy.from_fun(() => Sapp(data(f()), data(s))))})
222222

223-
let lcons = (f, s) => Some({count: 0, data: Slazy(lazy Scons(f(), data(s)))})
224-
let lsing = f => Some({count: 0, data: Slazy(lazy Scons(f(), Sempty))})
223+
let lcons = (f, s) => Some({count: 0, data: Slazy(Lazy.from_fun(() => Scons(f(), data(s))))})
224+
let lsing = f => Some({count: 0, data: Slazy(Lazy.from_fun(() => Scons(f(), Sempty)))})
225225

226226
let sempty = None
227-
let slazy = f => Some({count: 0, data: Slazy(lazy data(f()))})
227+
let slazy = f => Some({count: 0, data: Slazy(Lazy.from_fun(() => data(f())))})
228228

229229
/* For debugging use */
230230

jscomp/syntax/src/res_core.ml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,11 +1108,6 @@ let rec parsePattern ?(alias = true) ?(or_ = true) p =
11081108
let pat = parsePattern ~alias:false ~or_:false p in
11091109
let loc = mkLoc startPos p.prevEndPos in
11101110
Ast_helper.Pat.exception_ ~loc ~attrs pat
1111-
| Lazy ->
1112-
Parser.next p;
1113-
let pat = parsePattern ~alias:false ~or_:false p in
1114-
let loc = mkLoc startPos p.prevEndPos in
1115-
Ast_helper.Pat.lazy_ ~loc ~attrs pat
11161111
| List ->
11171112
Parser.next p;
11181113
parseListPattern ~startPos ~attrs p
@@ -2128,11 +2123,6 @@ and parseOperandExpr ~context p =
21282123
let () = attrs := [] in
21292124
parseAsyncArrowExpression ~arrowAttrs p
21302125
| Await -> parseAwaitExpression p
2131-
| Lazy ->
2132-
Parser.next p;
2133-
let expr = parseUnaryExpr p in
2134-
let loc = mkLoc startPos p.prevEndPos in
2135-
Ast_helper.Exp.lazy_ ~loc expr
21362126
| Try -> parseTryExpression p
21372127
| If -> parseIfOrIfLetExpression p
21382128
| For -> parseForExpression p

jscomp/syntax/src/res_grammar.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ let isSignatureItemStart = function
129129

130130
let isAtomicPatternStart = function
131131
| Token.Int _ | String _ | Codepoint _ | Backtick | Lparen | Lbracket | Lbrace
132-
| Underscore | Lident _ | Uident _ | List | Exception | Lazy | Percent ->
132+
| Underscore | Lident _ | Uident _ | List | Exception | Percent ->
133133
true
134134
| _ -> false
135135

@@ -148,9 +148,9 @@ let isAtomicTypExprStart = function
148148

149149
let isExprStart = function
150150
| Token.Assert | At | Await | Backtick | Bang | Codepoint _ | False | Float _
151-
| For | Hash | If | Int _ | Lazy | Lbrace | Lbracket | LessThan | Lident _
152-
| List | Lparen | Minus | MinusDot | Module | Percent | Plus | PlusDot
153-
| String _ | Switch | True | Try | Uident _ | Underscore (* _ => doThings() *)
151+
| For | Hash | If | Int _ | Lbrace | Lbracket | LessThan | Lident _ | List
152+
| Lparen | Minus | MinusDot | Module | Percent | Plus | PlusDot | String _
153+
| Switch | True | Try | Uident _ | Underscore (* _ => doThings() *)
154154
| While ->
155155
true
156156
| _ -> false
@@ -169,7 +169,7 @@ let isStructureItemStart = function
169169
let isPatternStart = function
170170
| Token.Int _ | Float _ | String _ | Codepoint _ | Backtick | True | False
171171
| Minus | Plus | Lparen | Lbracket | Lbrace | List | Underscore | Lident _
172-
| Uident _ | Hash | Exception | Lazy | Percent | Module | At ->
172+
| Uident _ | Hash | Exception | Percent | Module | At ->
173173
true
174174
| _ -> false
175175

@@ -257,10 +257,10 @@ let isJsxChildStart = isAtomicExprStart
257257

258258
let isBlockExprStart = function
259259
| Token.Assert | At | Await | Backtick | Bang | Codepoint _ | Exception
260-
| False | Float _ | For | Forwardslash | Hash | If | Int _ | Lazy | Lbrace
261-
| Lbracket | LessThan | Let | Lident _ | List | Lparen | Minus | MinusDot
262-
| Module | Open | Percent | Plus | PlusDot | String _ | Switch | True | Try
263-
| Uident _ | Underscore | While ->
260+
| False | Float _ | For | Forwardslash | Hash | If | Int _ | Lbrace | Lbracket
261+
| LessThan | Let | Lident _ | List | Lparen | Minus | MinusDot | Module | Open
262+
| Percent | Plus | PlusDot | String _ | Switch | True | Try | Uident _
263+
| Underscore | While ->
264264
true
265265
| _ -> false
266266

jscomp/syntax/src/res_token.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ type t =
5555
| Hash
5656
| HashEqual
5757
| Assert
58-
| Lazy
5958
| Tilde
6059
| Question
6160
| If
@@ -166,7 +165,6 @@ let toString = function
166165
| AsteriskDot -> "*."
167166
| Exponentiation -> "**"
168167
| Assert -> "assert"
169-
| Lazy -> "lazy"
170168
| Tilde -> "tilde"
171169
| Question -> "?"
172170
| If -> "if"
@@ -222,7 +220,6 @@ let keywordTable = function
222220
| "if" -> If
223221
| "in" -> In
224222
| "include" -> Include
225-
| "lazy" -> Lazy
226223
| "let" -> Let
227224
| "list{" -> List
228225
| "module" -> Module
@@ -242,8 +239,8 @@ let keywordTable = function
242239

243240
let isKeyword = function
244241
| Await | And | As | Assert | Constraint | Else | Exception | External | False
245-
| For | If | In | Include | Land | Lazy | Let | List | Lor | Module | Mutable
246-
| Of | Open | Private | Rec | Switch | True | Try | Typ | When | While ->
242+
| For | If | In | Include | Land | Let | List | Lor | Module | Mutable | Of
243+
| Open | Private | Rec | Switch | True | Try | Typ | When | While ->
247244
true
248245
| _ -> false
249246

0 commit comments

Comments
 (0)