Skip to content

Commit

Permalink
Prepare for 5.2 AST bump
Browse files Browse the repository at this point in the history
  • Loading branch information
patricoferris committed Oct 26, 2024
1 parent 5739f28 commit 873e1c3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
50 changes: 27 additions & 23 deletions src/trace_atd.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
// Generated by atdts from type definitions in 'trace.atd'.
//
// Type-safe translations from/to JSON
//
// For each type 'Foo', there is a pair of functions:
// - 'writeFoo': convert a 'Foo' value into a JSON-compatible value.
// - 'readFoo': convert a JSON-compatible value into a TypeScript value
// of type 'Foo'.
/*
Generated by atdts from type definitions in 'trace.atd'.
Type-safe translations from/to JSON
For each type 'Foo', there is a pair of functions:
- 'writeFoo': convert a 'Foo' value into a JSON-compatible value.
- 'readFoo': convert a JSON-compatible value into a TypeScript value
of type 'Foo'.
*/

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
/* tslint:disable */
/* eslint-disable */

export type Item = {
kind: Kind[];
goal_id: Int;
runtime_id: Int;
step: Int;
goal_id: number /*int*/;
runtime_id: number /*int*/;
step: number /*int*/;
name: string;
payload: string[];
}
Expand Down Expand Up @@ -89,9 +95,9 @@ export type Location =

export type FileLocation = {
filename: string;
line: Int;
column: Int;
character: Int;
line: number /*int*/;
column: number /*int*/;
character: number /*int*/;
}

export type Event =
Expand Down Expand Up @@ -124,11 +130,11 @@ export type Frame = {
runtime_id: RuntimeId;
}

export type GoalId = Int
export type GoalId = number /*int*/

export type StepId = Int
export type StepId = number /*int*/

export type RuntimeId = Int
export type RuntimeId = number /*int*/

export type GoalText = string

Expand Down Expand Up @@ -786,8 +792,6 @@ export function readChrText(x: any, context: any = x): ChrText {
// Runtime library
/////////////////////////////////////////////////////////////////////

export type Int = number

export type Option<T> = null | { value: T }

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

function _atd_check_json_tuple(len: Int, x: any, context: any) {
function _atd_check_json_tuple(len: number /*int*/, x: any, context: any) {
if (! Array.isArray(x) || x.length !== len)
_atd_bad_json('tuple of length ' + len, x, context);
}
Expand All @@ -843,7 +847,7 @@ function _atd_read_bool(x: any, context: any): boolean {
}
}

function _atd_read_int(x: any, context: any): Int {
function _atd_read_int(x: any, context: any): number /*int*/ {
if (Number.isInteger(x))
return x
else {
Expand Down Expand Up @@ -1024,7 +1028,7 @@ function _atd_write_bool(x: any, context: any): boolean {
}
}

function _atd_write_int(x: any, context: any): Int {
function _atd_write_int(x: any, context: any): number /*int*/ {
if (Number.isInteger(x))
return x
else {
Expand Down Expand Up @@ -1133,7 +1137,7 @@ function _atd_write_required_field<T>(type_name: string,
}

function _atd_write_optional_field<T>(write_elt: (x: T, context: any) => any,
x: T,
x: T | undefined,
context: any): any {
if (x === undefined || x === null)
return x
Expand Down
14 changes: 11 additions & 3 deletions trace/ppx/trace_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,17 @@ let map_trace = object(self)
let args = List.map (fun (x,y) -> x, self#expression y) args in
if args = [] then hd
else { e with pexp_desc = Pexp_apply (hd,args)}
| Pexp_fun(_,_,pat,rest) when not !enabled ->
let has_iftrace { ppat_attributes = l; _ } = has_iftrace_attribute l in
if has_iftrace pat then self#expression rest
| Pexp_function (param :: params, constraint_, rest) when not !enabled ->
let has_iftrace_pat { ppat_attributes = l; _ } = has_iftrace_attribute l in
let has_iftrace_param = function
| { pparam_desc = Pparam_val (_, _, pat); _ } -> has_iftrace_pat pat
| _ -> false
in
if has_iftrace_param param then begin
match params, rest with
| [], Pfunction_body exp -> self#expression exp
| _ -> self#expression { e with pexp_desc = Pexp_function (params, constraint_, rest) }
end
else e
| Pexp_let(_,[{pvb_pat = { ppat_attributes = l; _}; _}],rest) when not !enabled ->
if has_iftrace_attribute l then self#expression rest
Expand Down

0 comments on commit 873e1c3

Please sign in to comment.