Skip to content

Commit 873e1c3

Browse files
committed
Prepare for 5.2 AST bump
1 parent 5739f28 commit 873e1c3

File tree

2 files changed

+38
-26
lines changed

2 files changed

+38
-26
lines changed

src/trace_atd.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
// Generated by atdts from type definitions in 'trace.atd'.
2-
//
3-
// Type-safe translations from/to JSON
4-
//
5-
// For each type 'Foo', there is a pair of functions:
6-
// - 'writeFoo': convert a 'Foo' value into a JSON-compatible value.
7-
// - 'readFoo': convert a JSON-compatible value into a TypeScript value
8-
// of type 'Foo'.
1+
/*
2+
Generated by atdts from type definitions in 'trace.atd'.
93
4+
Type-safe translations from/to JSON
5+
6+
For each type 'Foo', there is a pair of functions:
7+
- 'writeFoo': convert a 'Foo' value into a JSON-compatible value.
8+
- 'readFoo': convert a JSON-compatible value into a TypeScript value
9+
of type 'Foo'.
10+
*/
11+
12+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
13+
// @ts-nocheck
14+
/* tslint:disable */
15+
/* eslint-disable */
1016

1117
export type Item = {
1218
kind: Kind[];
13-
goal_id: Int;
14-
runtime_id: Int;
15-
step: Int;
19+
goal_id: number /*int*/;
20+
runtime_id: number /*int*/;
21+
step: number /*int*/;
1622
name: string;
1723
payload: string[];
1824
}
@@ -89,9 +95,9 @@ export type Location =
8995

9096
export type FileLocation = {
9197
filename: string;
92-
line: Int;
93-
column: Int;
94-
character: Int;
98+
line: number /*int*/;
99+
column: number /*int*/;
100+
character: number /*int*/;
95101
}
96102

97103
export type Event =
@@ -124,11 +130,11 @@ export type Frame = {
124130
runtime_id: RuntimeId;
125131
}
126132

127-
export type GoalId = Int
133+
export type GoalId = number /*int*/
128134

129-
export type StepId = Int
135+
export type StepId = number /*int*/
130136

131-
export type RuntimeId = Int
137+
export type RuntimeId = number /*int*/
132138

133139
export type GoalText = string
134140

@@ -786,8 +792,6 @@ export function readChrText(x: any, context: any = x): ChrText {
786792
// Runtime library
787793
/////////////////////////////////////////////////////////////////////
788794

789-
export type Int = number
790-
791795
export type Option<T> = null | { value: T }
792796

793797
function _atd_missing_json_field(type_name: string, json_field_name: string) {
@@ -820,7 +824,7 @@ function _atd_bad_ts(expected_type: string, ts_value: any, context: any) {
820824
` Occurs in '${JSON.stringify(context)}'.`)
821825
}
822826

823-
function _atd_check_json_tuple(len: Int, x: any, context: any) {
827+
function _atd_check_json_tuple(len: number /*int*/, x: any, context: any) {
824828
if (! Array.isArray(x) || x.length !== len)
825829
_atd_bad_json('tuple of length ' + len, x, context);
826830
}
@@ -843,7 +847,7 @@ function _atd_read_bool(x: any, context: any): boolean {
843847
}
844848
}
845849

846-
function _atd_read_int(x: any, context: any): Int {
850+
function _atd_read_int(x: any, context: any): number /*int*/ {
847851
if (Number.isInteger(x))
848852
return x
849853
else {
@@ -1024,7 +1028,7 @@ function _atd_write_bool(x: any, context: any): boolean {
10241028
}
10251029
}
10261030

1027-
function _atd_write_int(x: any, context: any): Int {
1031+
function _atd_write_int(x: any, context: any): number /*int*/ {
10281032
if (Number.isInteger(x))
10291033
return x
10301034
else {
@@ -1133,7 +1137,7 @@ function _atd_write_required_field<T>(type_name: string,
11331137
}
11341138

11351139
function _atd_write_optional_field<T>(write_elt: (x: T, context: any) => any,
1136-
x: T,
1140+
x: T | undefined,
11371141
context: any): any {
11381142
if (x === undefined || x === null)
11391143
return x

trace/ppx/trace_ppx.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,17 @@ let map_trace = object(self)
173173
let args = List.map (fun (x,y) -> x, self#expression y) args in
174174
if args = [] then hd
175175
else { e with pexp_desc = Pexp_apply (hd,args)}
176-
| Pexp_fun(_,_,pat,rest) when not !enabled ->
177-
let has_iftrace { ppat_attributes = l; _ } = has_iftrace_attribute l in
178-
if has_iftrace pat then self#expression rest
176+
| Pexp_function (param :: params, constraint_, rest) when not !enabled ->
177+
let has_iftrace_pat { ppat_attributes = l; _ } = has_iftrace_attribute l in
178+
let has_iftrace_param = function
179+
| { pparam_desc = Pparam_val (_, _, pat); _ } -> has_iftrace_pat pat
180+
| _ -> false
181+
in
182+
if has_iftrace_param param then begin
183+
match params, rest with
184+
| [], Pfunction_body exp -> self#expression exp
185+
| _ -> self#expression { e with pexp_desc = Pexp_function (params, constraint_, rest) }
186+
end
179187
else e
180188
| Pexp_let(_,[{pvb_pat = { ppat_attributes = l; _}; _}],rest) when not !enabled ->
181189
if has_iftrace_attribute l then self#expression rest

0 commit comments

Comments
 (0)