From 166cdbacac99e84a41820dedebc935966bcc60e7 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Fri, 24 Nov 2023 21:54:40 -0800 Subject: [PATCH] feat: remove `Js.null_undefined` (#930) * feat: remove `Js.null_undefined` use Js.nullable instead * chore: add changelog entry --- Changes.md | 2 + jscomp/runtime/js.ml | 2 - .../dist/jscomp/test/flow_parser_reg_test.js | 3554 ++++++++--------- .../dist/jscomp/test/ocaml_parsetree_test.js | 78 +- .../dist/jscomp/test/ocaml_typedtree_test.js | 2992 +++++++------- ppx/ast_core_type_class_type.ml | 2 +- ppx/ast_literal.ml | 2 +- ppx/ast_literal.mli | 2 +- 8 files changed, 3317 insertions(+), 3317 deletions(-) diff --git a/Changes.md b/Changes.md index 1810e67c9a..bc52c13917 100644 --- a/Changes.md +++ b/Changes.md @@ -60,6 +60,8 @@ Unreleased [#928](https://github.com/melange-re/melange/pull/928)) - Fix a typo in `Node.node_module` (pa{r,}rent) [#929](https://github.com/melange-re/melange/pull/929) +- BREAKING(runtime): Remove `Js.null_undefined` in favor of `Js.nullable` + ([#930](https://github.com/melange-re/melange/pull/930)) 2.1.0 2023-10-22 --------------- diff --git a/jscomp/runtime/js.ml b/jscomp/runtime/js.ml index 8e8accc745..f9bae5f3da 100644 --- a/jscomp/runtime/js.ml +++ b/jscomp/runtime/js.ml @@ -61,8 +61,6 @@ type +'a nullable = 'a Js_nullable.t (** A value of this type can be [undefined], [null] or ['a]. This type is the same as type [t] n {!Nullable} *) -type +'a null_undefined = 'a nullable - module Exn = Js_exn (** Provide utilities for dealing with Js exceptions *) diff --git a/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js b/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js index 40fb8ec4b4..f83e020fe3 100644 --- a/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js @@ -15547,313 +15547,498 @@ function parse(content, options) { string(param[1].name) ]]); }; - var statement = function (param) { - var b = param[1]; + var jsx_expression_container = function (param) { + var expr = param[1].expression; + var expression$1; + expression$1 = expr.TAG === /* Expression */0 ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); + return node("JSXExpressionContainer", param[0], [[ + "expression", + expression$1 + ]]); + }; + var jsx_element = function (param) { + var element = param[1]; + return node("JSXElement", param[0], [ + [ + "openingElement", + jsx_opening(element.openingElement) + ], + [ + "closingElement", + option(jsx_closing, element.closingElement) + ], + [ + "children", + array_of_list(jsx_child, element.children) + ] + ]); + }; + var expression = function (param) { + var arr = param[1]; var loc = param[0]; - if (typeof b === "number") { - if (b === /* Empty */0) { - return node("EmptyStatement", loc, []); - } else { - return node("DebuggerStatement", loc, []); - } + if (typeof arr === "number") { + return node("ThisExpression", loc, []); } - switch (b.TAG | 0) { - case /* Block */0 : - return block([ + switch (arr.TAG | 0) { + case /* Array */0 : + return node("ArrayExpression", loc, [[ + "elements", + array_of_list((function (param) { + return option(expression_or_spread, param); + }), arr._0.elements) + ]]); + case /* Object */1 : + return node("ObjectExpression", loc, [[ + "properties", + array_of_list(object_property, arr._0.properties) + ]]); + case /* Function */2 : + return function_expression([ loc, - b._0 + arr._0 ]); - case /* Expression */1 : - return node("ExpressionStatement", loc, [[ - "expression", - expression(b._0.expression) - ]]); - case /* If */2 : - var _if = b._0; - return node("IfStatement", loc, [ + case /* ArrowFunction */3 : + var arrow = arr._0; + var b = arrow.body; + var body; + body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); + return node("ArrowFunctionExpression", loc, [ [ - "test", - expression(_if.test) + "id", + option(identifier, arrow.id) ], [ - "consequent", - statement(_if.consequent) + "params", + array_of_list(pattern, arrow.params) ], [ - "alternate", - option(statement, _if.alternate) - ] - ]); - case /* Labeled */3 : - var labeled = b._0; - return node("LabeledStatement", loc, [ - [ - "label", - identifier(labeled.label) + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), arrow.defaults) ], [ - "body", - statement(labeled.body) - ] - ]); - case /* Break */4 : - return node("BreakStatement", loc, [[ - "label", - option(identifier, b._0.label) - ]]); - case /* Continue */5 : - return node("ContinueStatement", loc, [[ - "label", - option(identifier, b._0.label) - ]]); - case /* With */6 : - var _with = b._0; - return node("WithStatement", loc, [ - [ - "object", - expression(_with._object) + "rest", + option(identifier, arrow.rest) ], [ "body", - statement(_with.body) - ] - ]); - case /* TypeAlias */7 : - return type_alias([ - loc, - b._0 - ]); - case /* Switch */8 : - var $$switch = b._0; - return node("SwitchStatement", loc, [ - [ - "discriminant", - expression($$switch.discriminant) + body ], [ - "cases", - array_of_list($$case, $$switch.cases) + "async", + bool(arrow.async) ], [ - "lexical", - bool($$switch.lexical) - ] - ]); - case /* Return */9 : - return node("ReturnStatement", loc, [[ - "argument", - option(expression, b._0.argument) - ]]); - case /* Throw */10 : - return node("ThrowStatement", loc, [[ - "argument", - expression(b._0.argument) - ]]); - case /* Try */11 : - var _try = b._0; - return node("TryStatement", loc, [ - [ - "block", - block(_try.block) + "generator", + bool(arrow.generator) ], [ - "handler", - option($$catch, _try.handler) + "expression", + bool(arrow.expression) ], [ - "guardedHandlers", - array_of_list($$catch, _try.guardedHandlers) + "returnType", + option(type_annotation, arrow.returnType) ], [ - "finalizer", - option(block, _try.finalizer) + "typeParameters", + option(type_parameter_declaration, arrow.typeParameters) ] ]); - case /* While */12 : - var _while = b._0; - return node("WhileStatement", loc, [ + case /* Sequence */4 : + return node("SequenceExpression", loc, [[ + "expressions", + array_of_list(expression, arr._0.expressions) + ]]); + case /* Unary */5 : + var unary = arr._0; + var match = unary.operator; + if (match >= 7) { + return node("AwaitExpression", loc, [[ + "argument", + expression(unary.argument) + ]]); + } + var match$1 = unary.operator; + var operator; + switch (match$1) { + case /* Minus */0 : + operator = "-"; + break; + case /* Plus */1 : + operator = "+"; + break; + case /* Not */2 : + operator = "!"; + break; + case /* BitNot */3 : + operator = "~"; + break; + case /* Typeof */4 : + operator = "typeof"; + break; + case /* Void */5 : + operator = "void"; + break; + case /* Delete */6 : + operator = "delete"; + break; + case /* Await */7 : + throw { + MEL_EXN_ID: "Failure", + _1: "matched above", + Error: new Error() + }; + + } + return node("UnaryExpression", loc, [ [ - "test", - expression(_while.test) + "operator", + string(operator) ], [ - "body", - statement(_while.body) - ] - ]); - case /* DoWhile */13 : - var dowhile = b._0; - return node("DoWhileStatement", loc, [ - [ - "body", - statement(dowhile.body) + "prefix", + bool(unary.prefix) ], [ - "test", - expression(dowhile.test) + "argument", + expression(unary.argument) ] ]); - case /* For */14 : - var _for = b._0; - var init = function (param) { - if (param.TAG === /* InitDeclaration */0) { - return variable_declaration(param._0); - } else { - return expression(param._0); - } - }; - return node("ForStatement", loc, [ - [ - "init", - option(init, _for.init) - ], - [ - "test", - option(expression, _for.test) + case /* Binary */6 : + var binary = arr._0; + var match$2 = binary.operator; + var operator$1; + switch (match$2) { + case /* Equal */0 : + operator$1 = "=="; + break; + case /* NotEqual */1 : + operator$1 = "!="; + break; + case /* StrictEqual */2 : + operator$1 = "==="; + break; + case /* StrictNotEqual */3 : + operator$1 = "!=="; + break; + case /* LessThan */4 : + operator$1 = "<"; + break; + case /* LessThanEqual */5 : + operator$1 = "<="; + break; + case /* GreaterThan */6 : + operator$1 = ">"; + break; + case /* GreaterThanEqual */7 : + operator$1 = ">="; + break; + case /* LShift */8 : + operator$1 = "<<"; + break; + case /* RShift */9 : + operator$1 = ">>"; + break; + case /* RShift3 */10 : + operator$1 = ">>>"; + break; + case /* Plus */11 : + operator$1 = "+"; + break; + case /* Minus */12 : + operator$1 = "-"; + break; + case /* Mult */13 : + operator$1 = "*"; + break; + case /* Exp */14 : + operator$1 = "**"; + break; + case /* Div */15 : + operator$1 = "/"; + break; + case /* Mod */16 : + operator$1 = "%"; + break; + case /* BitOr */17 : + operator$1 = "|"; + break; + case /* Xor */18 : + operator$1 = "^"; + break; + case /* BitAnd */19 : + operator$1 = "&"; + break; + case /* In */20 : + operator$1 = "in"; + break; + case /* Instanceof */21 : + operator$1 = "instanceof"; + break; + + } + return node("BinaryExpression", loc, [ + [ + "operator", + string(operator$1) ], [ - "update", - option(expression, _for.update) + "left", + expression(binary.left) ], [ - "body", - statement(_for.body) + "right", + expression(binary.right) ] ]); - case /* ForIn */15 : - var forin = b._0; - var left = forin.left; - var left$1; - left$1 = left.TAG === /* LeftDeclaration */0 ? variable_declaration(left._0) : expression(left._0); - return node("ForInStatement", loc, [ + case /* Assignment */7 : + var assignment = arr._0; + var match$3 = assignment.operator; + var operator$2; + switch (match$3) { + case /* Assign */0 : + operator$2 = "="; + break; + case /* PlusAssign */1 : + operator$2 = "+="; + break; + case /* MinusAssign */2 : + operator$2 = "-="; + break; + case /* MultAssign */3 : + operator$2 = "*="; + break; + case /* ExpAssign */4 : + operator$2 = "**="; + break; + case /* DivAssign */5 : + operator$2 = "/="; + break; + case /* ModAssign */6 : + operator$2 = "%="; + break; + case /* LShiftAssign */7 : + operator$2 = "<<="; + break; + case /* RShiftAssign */8 : + operator$2 = ">>="; + break; + case /* RShift3Assign */9 : + operator$2 = ">>>="; + break; + case /* BitOrAssign */10 : + operator$2 = "|="; + break; + case /* BitXorAssign */11 : + operator$2 = "^="; + break; + case /* BitAndAssign */12 : + operator$2 = "&="; + break; + + } + return node("AssignmentExpression", loc, [ + [ + "operator", + string(operator$2) + ], [ "left", - left$1 + pattern(assignment.left) ], [ "right", - expression(forin.right) + expression(assignment.right) + ] + ]); + case /* Update */8 : + var update = arr._0; + var match$4 = update.operator; + var operator$3 = match$4 ? "--" : "++"; + return node("UpdateExpression", loc, [ + [ + "operator", + string(operator$3) ], [ - "body", - statement(forin.body) + "argument", + expression(update.argument) ], [ - "each", - bool(forin.each) + "prefix", + bool(update.prefix) ] ]); - case /* ForOf */16 : - var forof = b._0; - var left$2 = forof.left; - var left$3; - left$3 = left$2.TAG === /* LeftDeclaration */0 ? variable_declaration(left$2._0) : expression(left$2._0); - return node("ForOfStatement", loc, [ + case /* Logical */9 : + var logical = arr._0; + var match$5 = logical.operator; + var operator$4 = match$5 ? "&&" : "||"; + return node("LogicalExpression", loc, [ + [ + "operator", + string(operator$4) + ], [ "left", - left$3 + expression(logical.left) ], [ "right", - expression(forof.right) + expression(logical.right) + ] + ]); + case /* Conditional */10 : + var conditional = arr._0; + return node("ConditionalExpression", loc, [ + [ + "test", + expression(conditional.test) ], [ - "body", - statement(forof.body) + "consequent", + expression(conditional.consequent) + ], + [ + "alternate", + expression(conditional.alternate) ] ]); - case /* Let */17 : - var _let = b._0; - return node("LetStatement", loc, [ + case /* New */11 : + var _new = arr._0; + return node("NewExpression", loc, [ [ - "head", - array_of_list(let_assignment, _let.head) + "callee", + expression(_new.callee) ], [ - "body", - statement(_let.body) + "arguments", + array_of_list(expression_or_spread, _new.arguments) ] ]); - case /* FunctionDeclaration */18 : - var fn = b._0; - var id = fn.id; - var match = id !== undefined ? [ - "FunctionDeclaration", - identifier(id) - ] : [ - "FunctionExpression", - $$null - ]; - var b$1 = fn.body; - var body; - body = b$1.TAG === /* BodyBlock */0 ? block(b$1._0) : expression(b$1._0); - return node(match[0], loc, [ + case /* Call */12 : + var call = arr._0; + return node("CallExpression", loc, [ [ - "id", - match[1] + "callee", + expression(call.callee) ], [ - "params", - array_of_list(pattern, fn.params) + "arguments", + array_of_list(expression_or_spread, call.arguments) + ] + ]); + case /* Member */13 : + var member = arr._0; + var id = member.property; + var property; + property = id.TAG === /* PropertyIdentifier */0 ? identifier(id._0) : expression(id._0); + return node("MemberExpression", loc, [ + [ + "object", + expression(member._object) ], [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), fn.defaults) + "property", + property ], [ - "rest", - option(identifier, fn.rest) - ], + "computed", + bool(member.computed) + ] + ]); + case /* Yield */14 : + var $$yield = arr._0; + return node("YieldExpression", loc, [ [ - "body", - body + "argument", + option(expression, $$yield.argument) ], [ - "async", - bool(fn.async) - ], + "delegate", + bool($$yield.delegate) + ] + ]); + case /* Comprehension */15 : + var comp = arr._0; + return node("ComprehensionExpression", loc, [ [ - "generator", - bool(fn.generator) + "blocks", + array_of_list(comprehension_block, comp.blocks) ], [ - "expression", - bool(fn.expression) + "filter", + option(expression, comp.filter) + ] + ]); + case /* Generator */16 : + var gen = arr._0; + return node("GeneratorExpression", loc, [ + [ + "blocks", + array_of_list(comprehension_block, gen.blocks) ], [ - "returnType", - option(type_annotation, fn.returnType) + "filter", + option(expression, gen.filter) + ] + ]); + case /* Let */17 : + var _let = arr._0; + return node("LetExpression", loc, [ + [ + "head", + array_of_list(let_assignment, _let.head) ], [ - "typeParameters", - option(type_parameter_declaration, fn.typeParameters) + "body", + expression(_let.body) ] ]); - case /* VariableDeclaration */19 : - return variable_declaration([ + case /* Identifier */18 : + return identifier(arr._0); + case /* Literal */19 : + return literal([ loc, - b._0 + arr._0 ]); - case /* ClassDeclaration */20 : + case /* TemplateLiteral */20 : + return template_literal([ + loc, + arr._0 + ]); + case /* TaggedTemplate */21 : var param$1 = [ loc, - b._0 + arr._0 ]; - var c = param$1[1]; - var id$1 = c.id; - var match$1 = id$1 !== undefined ? [ - "ClassDeclaration", - identifier(id$1) - ] : [ - "ClassExpression", - $$null - ]; - return node(match$1[0], param$1[0], [ + var tagged = param$1[1]; + return node("TaggedTemplateExpression", param$1[0], [ + [ + "tag", + expression(tagged.tag) + ], + [ + "quasi", + template_literal(tagged.quasi) + ] + ]); + case /* JSXElement */22 : + return jsx_element([ + loc, + arr._0 + ]); + case /* Class */23 : + var param$2 = [ + loc, + arr._0 + ]; + var c = param$2[1]; + return node("ClassExpression", param$2[0], [ [ "id", - match$1[1] + option(identifier, c.id) ], [ "body", @@ -15880,659 +16065,1026 @@ function parse(content, options) { array_of_list(expression, c.classDecorators) ] ]); - case /* InterfaceDeclaration */21 : - return interface_declaration([ - loc, - b._0 - ]); - case /* DeclareVariable */22 : - return declare_variable([ - loc, - b._0 - ]); - case /* DeclareFunction */23 : - return declare_function([ - loc, - b._0 - ]); - case /* DeclareClass */24 : - return declare_class([ - loc, - b._0 - ]); - case /* DeclareModule */25 : - var m = b._0; - var lit = m.id; - var id$2; - id$2 = lit.TAG === /* Identifier */0 ? identifier(lit._0) : literal(lit._0); - var match$2 = m.kind; - var tmp; - tmp = match$2.TAG === /* CommonJS */0 ? string("CommonJS") : string("ES"); - return node("DeclareModule", loc, [ - [ - "id", - id$2 - ], + case /* TypeCast */24 : + var typecast = arr._0; + return node("TypeCastExpression", loc, [ [ - "body", - block(m.body) + "expression", + expression(typecast.expression) ], [ - "kind", - tmp - ] - ]); - case /* DeclareModuleExports */26 : - return node("DeclareModuleExports", loc, [[ "typeAnnotation", - type_annotation(b._0) - ]]); - case /* DeclareExportDeclaration */27 : - var $$export = b._0; - var match$3 = $$export.declaration; - var declaration; - if (match$3 !== undefined) { - switch (match$3.TAG | 0) { - case /* Variable */0 : - declaration = declare_variable(match$3._0); - break; - case /* Function */1 : - declaration = declare_function(match$3._0); - break; - case /* Class */2 : - declaration = declare_class(match$3._0); - break; - case /* DefaultType */3 : - declaration = _type(match$3._0); - break; - case /* NamedType */4 : - declaration = type_alias(match$3._0); - break; - case /* Interface */5 : - declaration = interface_declaration(match$3._0); - break; - - } - } else { - declaration = $$null; - } - return node("DeclareExportDeclaration", loc, [ - [ - "default", - bool($$export.default) - ], - [ - "declaration", - declaration - ], - [ - "specifiers", - export_specifiers($$export.specifiers) - ], - [ - "source", - option(literal, $$export.source) - ] - ]); - case /* ExportDeclaration */28 : - var $$export$1 = b._0; - var match$4 = $$export$1.declaration; - var declaration$1 = match$4 !== undefined ? ( - match$4.TAG === /* Declaration */0 ? statement(match$4._0) : expression(match$4._0) - ) : $$null; - return node("ExportDeclaration", loc, [ - [ - "default", - bool($$export$1.default) - ], - [ - "declaration", - declaration$1 - ], - [ - "specifiers", - export_specifiers($$export$1.specifiers) - ], - [ - "source", - option(literal, $$export$1.source) - ], - [ - "exportKind", - string($$export$1.exportKind ? "value" : "type") - ] - ]); - case /* ImportDeclaration */29 : - var $$import = b._0; - var specifiers = Stdlib__List.map((function (param) { - switch (param.TAG | 0) { - case /* ImportNamedSpecifier */0 : - var match = param._0; - var local_id = match.local; - var remote_id = match.remote; - var span_loc = local_id !== undefined ? btwn(remote_id[0], local_id[0]) : remote_id[0]; - return node("ImportSpecifier", span_loc, [ - [ - "id", - identifier(remote_id) - ], - [ - "name", - option(identifier, local_id) - ] - ]); - case /* ImportDefaultSpecifier */1 : - var id = param._0; - return node("ImportDefaultSpecifier", id[0], [[ - "id", - identifier(id) - ]]); - case /* ImportNamespaceSpecifier */2 : - var param$1 = param._0; - return node("ImportNamespaceSpecifier", param$1[0], [[ - "id", - identifier(param$1[1]) - ]]); - - } - }), $$import.specifiers); - var match$5 = $$import.importKind; - var import_kind; - switch (match$5) { - case /* ImportType */0 : - import_kind = "type"; - break; - case /* ImportTypeof */1 : - import_kind = "typeof"; - break; - case /* ImportValue */2 : - import_kind = "value"; - break; - - } - return node("ImportDeclaration", loc, [ - [ - "specifiers", - array(Stdlib__Array.of_list(specifiers)) - ], - [ - "source", - literal($$import.source) - ], - [ - "importKind", - string(import_kind) + type_annotation(typecast.typeAnnotation) ] ]); } }; - var expression = function (param) { - var arr = param[1]; + var template_element = function (param) { + var element = param[1]; + var value = obj([ + [ + "raw", + string(element.value.raw) + ], + [ + "cooked", + string(element.value.cooked) + ] + ]); + return node("TemplateElement", param[0], [ + [ + "value", + value + ], + [ + "tail", + bool(element.tail) + ] + ]); + }; + var literal = function (param) { + var lit = param[1]; + var raw = lit.raw; + var value = lit.value; var loc = param[0]; - if (typeof arr === "number") { - return node("ThisExpression", loc, []); + var value_; + if (typeof value === "number") { + value_ = $$null; + } else { + switch (value.TAG | 0) { + case /* String */0 : + value_ = string(value._0); + break; + case /* Boolean */1 : + value_ = bool(value._0); + break; + case /* Number */2 : + value_ = number$1(value._0); + break; + case /* RegExp */3 : + var match = value._0; + value_ = regexp$1(loc, match.pattern, match.flags); + break; + + } } - switch (arr.TAG | 0) { - case /* Array */0 : - return node("ArrayExpression", loc, [[ - "elements", - array_of_list((function (param) { - return option(expression_or_spread, param); - }), arr._0.elements) - ]]); - case /* Object */1 : - return node("ObjectExpression", loc, [[ - "properties", - array_of_list(object_property, arr._0.properties) - ]]); - case /* Function */2 : - return function_expression([ - loc, - arr._0 - ]); - case /* ArrowFunction */3 : - var arrow = arr._0; - var b = arrow.body; - var body; - body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); - return node("ArrowFunctionExpression", loc, [ - [ - "id", - option(identifier, arrow.id) - ], - [ - "params", - array_of_list(pattern, arrow.params) - ], - [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), arrow.defaults) - ], - [ - "rest", - option(identifier, arrow.rest) - ], - [ - "body", - body - ], - [ - "async", - bool(arrow.async) - ], - [ - "generator", - bool(arrow.generator) - ], - [ - "expression", - bool(arrow.expression) - ], - [ - "returnType", - option(type_annotation, arrow.returnType) - ], - [ - "typeParameters", - option(type_parameter_declaration, arrow.typeParameters) - ] - ]); - case /* Sequence */4 : - return node("SequenceExpression", loc, [[ - "expressions", - array_of_list(expression, arr._0.expressions) - ]]); - case /* Unary */5 : - var unary = arr._0; - var match = unary.operator; - if (match >= 7) { - return node("AwaitExpression", loc, [[ - "argument", - expression(unary.argument) + var props; + var exit = 0; + if (typeof value === "number" || value.TAG !== /* RegExp */3) { + exit = 1; + } else { + var match$1 = value._0; + var regex = obj([ + [ + "pattern", + string(match$1.pattern) + ], + [ + "flags", + string(match$1.flags) + ] + ]); + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ], + [ + "regex", + regex + ] + ]; + } + if (exit === 1) { + props = [ + [ + "value", + value_ + ], + [ + "raw", + string(raw) + ] + ]; + } + return node("Literal", loc, props); + }; + var _type = function (param) { + var t = param[1]; + var loc = param[0]; + if (typeof t === "number") { + switch (t) { + case /* Any */0 : + return node("AnyTypeAnnotation", loc, []); + case /* Void */1 : + return node("VoidTypeAnnotation", loc, []); + case /* Null */2 : + return node("NullTypeAnnotation", loc, []); + case /* Number */3 : + return node("NumberTypeAnnotation", loc, []); + case /* String */4 : + return node("StringTypeAnnotation", loc, []); + case /* Boolean */5 : + return node("BooleanTypeAnnotation", loc, []); + case /* Exists */6 : + return node("ExistsTypeAnnotation", loc, []); + + } + } else { + switch (t.TAG | 0) { + case /* Nullable */0 : + var t$1 = t._0; + return node("NullableTypeAnnotation", loc, [[ + "typeAnnotation", + _type(t$1) ]]); - } - var match$1 = unary.operator; - var operator; - switch (match$1) { - case /* Minus */0 : - operator = "-"; - break; - case /* Plus */1 : - operator = "+"; - break; - case /* Not */2 : - operator = "!"; - break; - case /* BitNot */3 : - operator = "~"; - break; - case /* Typeof */4 : - operator = "typeof"; - break; - case /* Void */5 : - operator = "void"; - break; - case /* Delete */6 : - operator = "delete"; - break; - case /* Await */7 : - throw { - MEL_EXN_ID: "Failure", - _1: "matched above", - Error: new Error() - }; - - } - return node("UnaryExpression", loc, [ - [ - "operator", - string(operator) - ], + case /* Function */1 : + return function_type([ + loc, + t._0 + ]); + case /* Object */2 : + return object_type([ + loc, + t._0 + ]); + case /* Array */3 : + var t$2 = t._0; + return node("ArrayTypeAnnotation", loc, [[ + "elementType", + _type(t$2) + ]]); + case /* Generic */4 : + var param$1 = [ + loc, + t._0 + ]; + var g = param$1[1]; + var id = g.id; + var id$1; + id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("GenericTypeAnnotation", param$1[0], [ + [ + "id", + id$1 + ], + [ + "typeParameters", + option(type_parameter_instantiation, g.typeParameters) + ] + ]); + case /* Union */5 : + var param$2 = [ + loc, + t._0 + ]; + return node("UnionTypeAnnotation", param$2[0], [[ + "types", + array_of_list(_type, param$2[1]) + ]]); + case /* Intersection */6 : + var param$3 = [ + loc, + t._0 + ]; + return node("IntersectionTypeAnnotation", param$3[0], [[ + "types", + array_of_list(_type, param$3[1]) + ]]); + case /* Typeof */7 : + var param$4 = [ + loc, + t._0 + ]; + return node("TypeofTypeAnnotation", param$4[0], [[ + "argument", + _type(param$4[1]) + ]]); + case /* Tuple */8 : + var param$5 = [ + loc, + t._0 + ]; + return node("TupleTypeAnnotation", param$5[0], [[ + "types", + array_of_list(_type, param$5[1]) + ]]); + case /* StringLiteral */9 : + var param$6 = [ + loc, + t._0 + ]; + var s = param$6[1]; + return node("StringLiteralTypeAnnotation", param$6[0], [ + [ + "value", + string(s.value) + ], + [ + "raw", + string(s.raw) + ] + ]); + case /* NumberLiteral */10 : + var param$7 = [ + loc, + t._0 + ]; + var s$1 = param$7[1]; + return node("NumberLiteralTypeAnnotation", param$7[0], [ + [ + "value", + number$1(s$1.value) + ], + [ + "raw", + string(s$1.raw) + ] + ]); + case /* BooleanLiteral */11 : + var param$8 = [ + loc, + t._0 + ]; + var s$2 = param$8[1]; + return node("BooleanLiteralTypeAnnotation", param$8[0], [ + [ + "value", + bool(s$2.value) + ], + [ + "raw", + string(s$2.raw) + ] + ]); + + } + } + }; + var identifier = function (param) { + var id = param[1]; + return node("Identifier", param[0], [ + [ + "name", + string(id.name) + ], + [ + "typeAnnotation", + option(type_annotation, id.typeAnnotation) + ], + [ + "optional", + bool(id.optional) + ] + ]); + }; + var class_element = function (param) { + if (param.TAG === /* Method */0) { + var param$1 = param._0; + var method_ = param$1[1]; + var key = method_.key; + var match; + switch (key.TAG | 0) { + case /* Literal */0 : + match = [ + literal(key._0), + false + ]; + break; + case /* Identifier */1 : + match = [ + identifier(key._0), + false + ]; + break; + case /* Computed */2 : + match = [ + expression(key._0), + true + ]; + break; + + } + var kind; + switch (method_.kind) { + case /* Constructor */0 : + kind = "constructor"; + break; + case /* Method */1 : + kind = "method"; + break; + case /* Get */2 : + kind = "get"; + break; + case /* Set */3 : + kind = "set"; + break; + + } + return node("MethodDefinition", param$1[0], [ + [ + "key", + match[0] + ], + [ + "value", + function_expression(method_.value) + ], + [ + "kind", + string(kind) + ], + [ + "static", + bool(method_.static) + ], + [ + "computed", + bool(match[1]) + ], + [ + "decorators", + array_of_list(expression, method_.decorators) + ] + ]); + } else { + var param$2 = param._0; + var prop = param$2[1]; + var lit = prop.key; + var match$1; + switch (lit.TAG | 0) { + case /* Literal */0 : + match$1 = [ + literal(lit._0), + false + ]; + break; + case /* Identifier */1 : + match$1 = [ + identifier(lit._0), + false + ]; + break; + case /* Computed */2 : + match$1 = [ + expression(lit._0), + true + ]; + break; + + } + return node("ClassProperty", param$2[0], [ + [ + "key", + match$1[0] + ], + [ + "value", + option(expression, prop.value) + ], + [ + "typeAnnotation", + option(type_annotation, prop.typeAnnotation) + ], + [ + "computed", + bool(match$1[1]) + ], + [ + "static", + bool(prop.static) + ] + ]); + } + }; + var pattern = function (param) { + var obj = param[1]; + var loc = param[0]; + switch (obj.TAG | 0) { + case /* Object */0 : + var obj$1 = obj._0; + return node("ObjectPattern", loc, [ [ - "prefix", - bool(unary.prefix) + "properties", + array_of_list(object_pattern_property, obj$1.properties) ], [ - "argument", - expression(unary.argument) + "typeAnnotation", + option(type_annotation, obj$1.typeAnnotation) ] ]); - case /* Binary */6 : - var binary = arr._0; - var match$2 = binary.operator; - var operator$1; - switch (match$2) { - case /* Equal */0 : - operator$1 = "=="; - break; - case /* NotEqual */1 : - operator$1 = "!="; - break; - case /* StrictEqual */2 : - operator$1 = "==="; - break; - case /* StrictNotEqual */3 : - operator$1 = "!=="; - break; - case /* LessThan */4 : - operator$1 = "<"; - break; - case /* LessThanEqual */5 : - operator$1 = "<="; - break; - case /* GreaterThan */6 : - operator$1 = ">"; - break; - case /* GreaterThanEqual */7 : - operator$1 = ">="; - break; - case /* LShift */8 : - operator$1 = "<<"; - break; - case /* RShift */9 : - operator$1 = ">>"; - break; - case /* RShift3 */10 : - operator$1 = ">>>"; - break; - case /* Plus */11 : - operator$1 = "+"; - break; - case /* Minus */12 : - operator$1 = "-"; - break; - case /* Mult */13 : - operator$1 = "*"; - break; - case /* Exp */14 : - operator$1 = "**"; - break; - case /* Div */15 : - operator$1 = "/"; - break; - case /* Mod */16 : - operator$1 = "%"; - break; - case /* BitOr */17 : - operator$1 = "|"; - break; - case /* Xor */18 : - operator$1 = "^"; - break; - case /* BitAnd */19 : - operator$1 = "&"; - break; - case /* In */20 : - operator$1 = "in"; - break; - case /* Instanceof */21 : - operator$1 = "instanceof"; - break; - - } - return node("BinaryExpression", loc, [ + case /* Array */1 : + var arr = obj._0; + return node("ArrayPattern", loc, [ [ - "operator", - string(operator$1) + "elements", + array_of_list((function (param) { + return option(array_pattern_element, param); + }), arr.elements) ], + [ + "typeAnnotation", + option(type_annotation, arr.typeAnnotation) + ] + ]); + case /* Assignment */2 : + var match = obj._0; + return node("AssignmentPattern", loc, [ [ "left", - expression(binary.left) + pattern(match.left) ], [ "right", - expression(binary.right) + expression(match.right) ] ]); - case /* Assignment */7 : - var assignment = arr._0; - var match$3 = assignment.operator; - var operator$2; - switch (match$3) { - case /* Assign */0 : - operator$2 = "="; - break; - case /* PlusAssign */1 : - operator$2 = "+="; - break; - case /* MinusAssign */2 : - operator$2 = "-="; - break; - case /* MultAssign */3 : - operator$2 = "*="; - break; - case /* ExpAssign */4 : - operator$2 = "**="; - break; - case /* DivAssign */5 : - operator$2 = "/="; - break; - case /* ModAssign */6 : - operator$2 = "%="; - break; - case /* LShiftAssign */7 : - operator$2 = "<<="; - break; - case /* RShiftAssign */8 : - operator$2 = ">>="; - break; - case /* RShift3Assign */9 : - operator$2 = ">>>="; - break; - case /* BitOrAssign */10 : - operator$2 = "|="; - break; - case /* BitXorAssign */11 : - operator$2 = "^="; - break; - case /* BitAndAssign */12 : - operator$2 = "&="; - break; - - } - return node("AssignmentExpression", loc, [ + case /* Identifier */3 : + return identifier(obj._0); + case /* Expression */4 : + return expression(obj._0); + + } + }; + var block = function (param) { + return node("BlockStatement", param[0], [[ + "body", + array_of_list(statement, param[1].body) + ]]); + }; + var variable_declarator = function (param) { + var declarator = param[1]; + return node("VariableDeclarator", param[0], [ + [ + "id", + pattern(declarator.id) + ], + [ + "init", + option(expression, declarator.init) + ] + ]); + }; + var generic_type_qualified_identifier = function (param) { + var q = param[1]; + var id = q.qualification; + var qualification; + qualification = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("QualifiedTypeIdentifier", param[0], [ + [ + "qualification", + qualification + ], + [ + "id", + identifier(q.id) + ] + ]); + }; + var type_parameter_instantiation = function (param) { + return node("TypeParameterInstantiation", param[0], [[ + "params", + array_of_list(_type, param[1].params) + ]]); + }; + var jsx_name = function (param) { + switch (param.TAG | 0) { + case /* Identifier */0 : + return jsx_identifier(param._0); + case /* NamespacedName */1 : + return jsx_namespaced_name(param._0); + case /* MemberExpression */2 : + return jsx_member_expression(param._0); + + } + }; + var jsx_opening_attribute = function (param) { + if (param.TAG === /* Attribute */0) { + var param$1 = param._0; + var attribute = param$1[1]; + var id = attribute.name; + var name; + name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); + return node("JSXAttribute", param$1[0], [ + [ + "name", + name + ], + [ + "value", + option(jsx_attribute_value, attribute.value) + ] + ]); + } else { + var param$2 = param._0; + return node("JSXSpreadAttribute", param$2[0], [[ + "argument", + expression(param$2[1].argument) + ]]); + } + }; + var export_specifier = function (param) { + var specifier = param[1]; + return node("ExportSpecifier", param[0], [ + [ + "id", + identifier(specifier.id) + ], + [ + "name", + option(identifier, specifier.name) + ] + ]); + }; + var type_param = function (param) { + var tp = param[1]; + var variance = function (param) { + if (param) { + return string("minus"); + } else { + return string("plus"); + } + }; + return node("TypeParameter", param[0], [ + [ + "name", + string(tp.name) + ], + [ + "bound", + option(type_annotation, tp.bound) + ], + [ + "variance", + option(variance, tp.variance) + ], + [ + "default", + option(_type, tp.default) + ] + ]); + }; + var class_body = function (param) { + return node("ClassBody", param[0], [[ + "body", + array_of_list(class_element, param[1].body) + ]]); + }; + var type_parameter_declaration = function (param) { + return node("TypeParameterDeclaration", param[0], [[ + "params", + array_of_list(type_param, param[1].params) + ]]); + }; + var class_implements = function (param) { + var $$implements = param[1]; + return node("ClassImplements", param[0], [ + [ + "id", + identifier($$implements.id) + ], + [ + "typeParameters", + option(type_parameter_instantiation, $$implements.typeParameters) + ] + ]); + }; + var object_type = function (param) { + var o = param[1]; + return node("ObjectTypeAnnotation", param[0], [ + [ + "properties", + array_of_list(object_type_property, o.properties) + ], + [ + "indexers", + array_of_list(object_type_indexer, o.indexers) + ], + [ + "callProperties", + array_of_list(object_type_call_property, o.callProperties) + ] + ]); + }; + var interface_extends = function (param) { + var g = param[1]; + var id = g.id; + var id$1; + id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("InterfaceExtends", param[0], [ + [ + "id", + id$1 + ], + [ + "typeParameters", + option(type_parameter_instantiation, g.typeParameters) + ] + ]); + }; + var object_type_property = function (param) { + var prop = param[1]; + var lit = prop.key; + var key; + switch (lit.TAG | 0) { + case /* Literal */0 : + key = literal(lit._0); + break; + case /* Identifier */1 : + key = identifier(lit._0); + break; + case /* Computed */2 : + throw { + MEL_EXN_ID: "Failure", + _1: "There should not be computed object type property keys", + Error: new Error() + }; + + } + return node("ObjectTypeProperty", param[0], [ + [ + "key", + key + ], + [ + "value", + _type(prop.value) + ], + [ + "optional", + bool(prop.optional) + ], + [ + "static", + bool(prop.static) + ] + ]); + }; + var object_type_call_property = function (param) { + var callProperty = param[1]; + return node("ObjectTypeCallProperty", param[0], [ + [ + "value", + function_type(callProperty.value) + ], + [ + "static", + bool(callProperty.static) + ] + ]); + }; + var object_type_indexer = function (param) { + var indexer = param[1]; + return node("ObjectTypeIndexer", param[0], [ + [ + "id", + identifier(indexer.id) + ], + [ + "key", + _type(indexer.key) + ], + [ + "value", + _type(indexer.value) + ], + [ + "static", + bool(indexer.static) + ] + ]); + }; + var template_literal = function (param) { + var value = param[1]; + return node("TemplateLiteral", param[0], [ + [ + "quasis", + array_of_list(template_element, value.quasis) + ], + [ + "expressions", + array_of_list(expression, value.expressions) + ] + ]); + }; + var type_annotation = function (param) { + return node("TypeAnnotation", param[0], [[ + "typeAnnotation", + _type(param[1]) + ]]); + }; + var statement = function (param) { + var b = param[1]; + var loc = param[0]; + if (typeof b === "number") { + if (b === /* Empty */0) { + return node("EmptyStatement", loc, []); + } else { + return node("DebuggerStatement", loc, []); + } + } + switch (b.TAG | 0) { + case /* Block */0 : + return block([ + loc, + b._0 + ]); + case /* Expression */1 : + return node("ExpressionStatement", loc, [[ + "expression", + expression(b._0.expression) + ]]); + case /* If */2 : + var _if = b._0; + return node("IfStatement", loc, [ [ - "operator", - string(operator$2) + "test", + expression(_if.test) ], [ - "left", - pattern(assignment.left) + "consequent", + statement(_if.consequent) ], [ - "right", - expression(assignment.right) + "alternate", + option(statement, _if.alternate) ] ]); - case /* Update */8 : - var update = arr._0; - var match$4 = update.operator; - var operator$3 = match$4 ? "--" : "++"; - return node("UpdateExpression", loc, [ + case /* Labeled */3 : + var labeled = b._0; + return node("LabeledStatement", loc, [ [ - "operator", - string(operator$3) + "label", + identifier(labeled.label) ], [ - "argument", - expression(update.argument) + "body", + statement(labeled.body) + ] + ]); + case /* Break */4 : + return node("BreakStatement", loc, [[ + "label", + option(identifier, b._0.label) + ]]); + case /* Continue */5 : + return node("ContinueStatement", loc, [[ + "label", + option(identifier, b._0.label) + ]]); + case /* With */6 : + var _with = b._0; + return node("WithStatement", loc, [ + [ + "object", + expression(_with._object) ], [ - "prefix", - bool(update.prefix) + "body", + statement(_with.body) ] ]); - case /* Logical */9 : - var logical = arr._0; - var match$5 = logical.operator; - var operator$4 = match$5 ? "&&" : "||"; - return node("LogicalExpression", loc, [ + case /* TypeAlias */7 : + return type_alias([ + loc, + b._0 + ]); + case /* Switch */8 : + var $$switch = b._0; + return node("SwitchStatement", loc, [ [ - "operator", - string(operator$4) + "discriminant", + expression($$switch.discriminant) ], [ - "left", - expression(logical.left) + "cases", + array_of_list($$case, $$switch.cases) ], [ - "right", - expression(logical.right) + "lexical", + bool($$switch.lexical) ] ]); - case /* Conditional */10 : - var conditional = arr._0; - return node("ConditionalExpression", loc, [ + case /* Return */9 : + return node("ReturnStatement", loc, [[ + "argument", + option(expression, b._0.argument) + ]]); + case /* Throw */10 : + return node("ThrowStatement", loc, [[ + "argument", + expression(b._0.argument) + ]]); + case /* Try */11 : + var _try = b._0; + return node("TryStatement", loc, [ [ - "test", - expression(conditional.test) + "block", + block(_try.block) ], [ - "consequent", - expression(conditional.consequent) + "handler", + option($$catch, _try.handler) ], [ - "alternate", - expression(conditional.alternate) + "guardedHandlers", + array_of_list($$catch, _try.guardedHandlers) + ], + [ + "finalizer", + option(block, _try.finalizer) ] ]); - case /* New */11 : - var _new = arr._0; - return node("NewExpression", loc, [ + case /* While */12 : + var _while = b._0; + return node("WhileStatement", loc, [ [ - "callee", - expression(_new.callee) + "test", + expression(_while.test) ], [ - "arguments", - array_of_list(expression_or_spread, _new.arguments) + "body", + statement(_while.body) ] ]); - case /* Call */12 : - var call = arr._0; - return node("CallExpression", loc, [ + case /* DoWhile */13 : + var dowhile = b._0; + return node("DoWhileStatement", loc, [ [ - "callee", - expression(call.callee) + "body", + statement(dowhile.body) ], [ - "arguments", - array_of_list(expression_or_spread, call.arguments) + "test", + expression(dowhile.test) ] ]); - case /* Member */13 : - var member = arr._0; - var id = member.property; - var property; - property = id.TAG === /* PropertyIdentifier */0 ? identifier(id._0) : expression(id._0); - return node("MemberExpression", loc, [ + case /* For */14 : + var _for = b._0; + var init = function (param) { + if (param.TAG === /* InitDeclaration */0) { + return variable_declaration(param._0); + } else { + return expression(param._0); + } + }; + return node("ForStatement", loc, [ [ - "object", - expression(member._object) + "init", + option(init, _for.init) ], [ - "property", - property + "test", + option(expression, _for.test) ], [ - "computed", - bool(member.computed) + "update", + option(expression, _for.update) + ], + [ + "body", + statement(_for.body) ] ]); - case /* Yield */14 : - var $$yield = arr._0; - return node("YieldExpression", loc, [ + case /* ForIn */15 : + var forin = b._0; + var left = forin.left; + var left$1; + left$1 = left.TAG === /* LeftDeclaration */0 ? variable_declaration(left._0) : expression(left._0); + return node("ForInStatement", loc, [ [ - "argument", - option(expression, $$yield.argument) + "left", + left$1 ], [ - "delegate", - bool($$yield.delegate) + "right", + expression(forin.right) + ], + [ + "body", + statement(forin.body) + ], + [ + "each", + bool(forin.each) ] ]); - case /* Comprehension */15 : - var comp = arr._0; - return node("ComprehensionExpression", loc, [ + case /* ForOf */16 : + var forof = b._0; + var left$2 = forof.left; + var left$3; + left$3 = left$2.TAG === /* LeftDeclaration */0 ? variable_declaration(left$2._0) : expression(left$2._0); + return node("ForOfStatement", loc, [ [ - "blocks", - array_of_list(comprehension_block, comp.blocks) + "left", + left$3 ], [ - "filter", - option(expression, comp.filter) + "right", + expression(forof.right) + ], + [ + "body", + statement(forof.body) ] ]); - case /* Generator */16 : - var gen = arr._0; - return node("GeneratorExpression", loc, [ + case /* Let */17 : + var _let = b._0; + return node("LetStatement", loc, [ + [ + "head", + array_of_list(let_assignment, _let.head) + ], + [ + "body", + statement(_let.body) + ] + ]); + case /* FunctionDeclaration */18 : + var fn = b._0; + var id = fn.id; + var match = id !== undefined ? [ + "FunctionDeclaration", + identifier(id) + ] : [ + "FunctionExpression", + $$null + ]; + var b$1 = fn.body; + var body; + body = b$1.TAG === /* BodyBlock */0 ? block(b$1._0) : expression(b$1._0); + return node(match[0], loc, [ + [ + "id", + match[1] + ], + [ + "params", + array_of_list(pattern, fn.params) + ], + [ + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), fn.defaults) + ], + [ + "rest", + option(identifier, fn.rest) + ], [ - "blocks", - array_of_list(comprehension_block, gen.blocks) + "body", + body ], [ - "filter", - option(expression, gen.filter) - ] - ]); - case /* Let */17 : - var _let = arr._0; - return node("LetExpression", loc, [ + "async", + bool(fn.async) + ], [ - "head", - array_of_list(let_assignment, _let.head) + "generator", + bool(fn.generator) ], [ - "body", - expression(_let.body) - ] - ]); - case /* Identifier */18 : - return identifier(arr._0); - case /* Literal */19 : - return literal([ - loc, - arr._0 - ]); - case /* TemplateLiteral */20 : - return template_literal([ - loc, - arr._0 - ]); - case /* TaggedTemplate */21 : - var param$1 = [ - loc, - arr._0 - ]; - var tagged = param$1[1]; - return node("TaggedTemplateExpression", param$1[0], [ + "expression", + bool(fn.expression) + ], [ - "tag", - expression(tagged.tag) + "returnType", + option(type_annotation, fn.returnType) ], [ - "quasi", - template_literal(tagged.quasi) + "typeParameters", + option(type_parameter_declaration, fn.typeParameters) ] ]); - case /* JSXElement */22 : - return jsx_element([ + case /* VariableDeclaration */19 : + return variable_declaration([ loc, - arr._0 + b._0 ]); - case /* Class */23 : - var param$2 = [ + case /* ClassDeclaration */20 : + var param$1 = [ loc, - arr._0 + b._0 ]; - var c = param$2[1]; - return node("ClassExpression", param$2[0], [ + var c = param$1[1]; + var id$1 = c.id; + var match$1 = id$1 !== undefined ? [ + "ClassDeclaration", + identifier(id$1) + ] : [ + "ClassExpression", + $$null + ]; + return node(match$1[0], param$1[0], [ [ "id", - option(identifier, c.id) + match$1[1] ], [ "body", @@ -16541,404 +17093,232 @@ function parse(content, options) { [ "superClass", option(expression, c.superClass) - ], - [ - "typeParameters", - option(type_parameter_declaration, c.typeParameters) - ], - [ - "superTypeParameters", - option(type_parameter_instantiation, c.superTypeParameters) - ], - [ - "implements", - array_of_list(class_implements, c.implements) - ], - [ - "decorators", - array_of_list(expression, c.classDecorators) - ] - ]); - case /* TypeCast */24 : - var typecast = arr._0; - return node("TypeCastExpression", loc, [ - [ - "expression", - expression(typecast.expression) - ], - [ - "typeAnnotation", - type_annotation(typecast.typeAnnotation) - ] - ]); - - } - }; - var identifier = function (param) { - var id = param[1]; - return node("Identifier", param[0], [ - [ - "name", - string(id.name) - ], - [ - "typeAnnotation", - option(type_annotation, id.typeAnnotation) - ], - [ - "optional", - bool(id.optional) - ] - ]); - }; - var literal = function (param) { - var lit = param[1]; - var raw = lit.raw; - var value = lit.value; - var loc = param[0]; - var value_; - if (typeof value === "number") { - value_ = $$null; - } else { - switch (value.TAG | 0) { - case /* String */0 : - value_ = string(value._0); - break; - case /* Boolean */1 : - value_ = bool(value._0); - break; - case /* Number */2 : - value_ = number$1(value._0); - break; - case /* RegExp */3 : - var match = value._0; - value_ = regexp$1(loc, match.pattern, match.flags); - break; - - } - } - var props; - var exit = 0; - if (typeof value === "number" || value.TAG !== /* RegExp */3) { - exit = 1; - } else { - var match$1 = value._0; - var regex = obj([ - [ - "pattern", - string(match$1.pattern) - ], - [ - "flags", - string(match$1.flags) - ] - ]); - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ], - [ - "regex", - regex - ] - ]; - } - if (exit === 1) { - props = [ - [ - "value", - value_ - ], - [ - "raw", - string(raw) - ] - ]; - } - return node("Literal", loc, props); - }; - var function_expression = function (param) { - var _function = param[1]; - var b = _function.body; - var body; - body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); - return node("FunctionExpression", param[0], [ - [ - "id", - option(identifier, _function.id) - ], - [ - "params", - array_of_list(pattern, _function.params) - ], - [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), _function.defaults) - ], - [ - "rest", - option(identifier, _function.rest) - ], - [ - "body", - body - ], - [ - "async", - bool(_function.async) - ], - [ - "generator", - bool(_function.generator) - ], - [ - "expression", - bool(_function.expression) - ], - [ - "returnType", - option(type_annotation, _function.returnType) - ], - [ - "typeParameters", - option(type_parameter_declaration, _function.typeParameters) - ] - ]); - }; - var pattern = function (param) { - var obj = param[1]; - var loc = param[0]; - switch (obj.TAG | 0) { - case /* Object */0 : - var obj$1 = obj._0; - return node("ObjectPattern", loc, [ + ], [ - "properties", - array_of_list(object_pattern_property, obj$1.properties) + "typeParameters", + option(type_parameter_declaration, c.typeParameters) ], [ - "typeAnnotation", - option(type_annotation, obj$1.typeAnnotation) - ] - ]); - case /* Array */1 : - var arr = obj._0; - return node("ArrayPattern", loc, [ + "superTypeParameters", + option(type_parameter_instantiation, c.superTypeParameters) + ], [ - "elements", - array_of_list((function (param) { - return option(array_pattern_element, param); - }), arr.elements) + "implements", + array_of_list(class_implements, c.implements) ], [ - "typeAnnotation", - option(type_annotation, arr.typeAnnotation) + "decorators", + array_of_list(expression, c.classDecorators) ] ]); - case /* Assignment */2 : - var match = obj._0; - return node("AssignmentPattern", loc, [ + case /* InterfaceDeclaration */21 : + return interface_declaration([ + loc, + b._0 + ]); + case /* DeclareVariable */22 : + return declare_variable([ + loc, + b._0 + ]); + case /* DeclareFunction */23 : + return declare_function([ + loc, + b._0 + ]); + case /* DeclareClass */24 : + return declare_class([ + loc, + b._0 + ]); + case /* DeclareModule */25 : + var m = b._0; + var lit = m.id; + var id$2; + id$2 = lit.TAG === /* Identifier */0 ? identifier(lit._0) : literal(lit._0); + var match$2 = m.kind; + var tmp; + tmp = match$2.TAG === /* CommonJS */0 ? string("CommonJS") : string("ES"); + return node("DeclareModule", loc, [ [ - "left", - pattern(match.left) + "id", + id$2 ], [ - "right", - expression(match.right) + "body", + block(m.body) + ], + [ + "kind", + tmp ] ]); - case /* Identifier */3 : - return identifier(obj._0); - case /* Expression */4 : - return expression(obj._0); - - } - }; - var jsx_namespaced_name = function (param) { - var namespaced_name = param[1]; - return node("JSXNamespacedName", param[0], [ - [ - "namespace", - jsx_identifier(namespaced_name.namespace) - ], - [ - "name", - jsx_identifier(namespaced_name.name) - ] - ]); - }; - var jsx_attribute_value = function (param) { - if (param.TAG === /* Literal */0) { - return literal([ - param._0, - param._1 - ]); - } else { - return jsx_expression_container([ - param._0, - param._1 - ]); - } - }; - var _type = function (param) { - var t = param[1]; - var loc = param[0]; - if (typeof t === "number") { - switch (t) { - case /* Any */0 : - return node("AnyTypeAnnotation", loc, []); - case /* Void */1 : - return node("VoidTypeAnnotation", loc, []); - case /* Null */2 : - return node("NullTypeAnnotation", loc, []); - case /* Number */3 : - return node("NumberTypeAnnotation", loc, []); - case /* String */4 : - return node("StringTypeAnnotation", loc, []); - case /* Boolean */5 : - return node("BooleanTypeAnnotation", loc, []); - case /* Exists */6 : - return node("ExistsTypeAnnotation", loc, []); - - } - } else { - switch (t.TAG | 0) { - case /* Nullable */0 : - var t$1 = t._0; - return node("NullableTypeAnnotation", loc, [[ - "typeAnnotation", - _type(t$1) - ]]); - case /* Function */1 : - return function_type([ - loc, - t._0 - ]); - case /* Object */2 : - return object_type([ - loc, - t._0 - ]); - case /* Array */3 : - var t$2 = t._0; - return node("ArrayTypeAnnotation", loc, [[ - "elementType", - _type(t$2) - ]]); - case /* Generic */4 : - var param$1 = [ - loc, - t._0 - ]; - var g = param$1[1]; - var id = g.id; - var id$1; - id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("GenericTypeAnnotation", param$1[0], [ - [ - "id", - id$1 - ], - [ - "typeParameters", - option(type_parameter_instantiation, g.typeParameters) - ] - ]); - case /* Union */5 : - var param$2 = [ - loc, - t._0 - ]; - return node("UnionTypeAnnotation", param$2[0], [[ - "types", - array_of_list(_type, param$2[1]) - ]]); - case /* Intersection */6 : - var param$3 = [ - loc, - t._0 - ]; - return node("IntersectionTypeAnnotation", param$3[0], [[ - "types", - array_of_list(_type, param$3[1]) - ]]); - case /* Typeof */7 : - var param$4 = [ - loc, - t._0 - ]; - return node("TypeofTypeAnnotation", param$4[0], [[ - "argument", - _type(param$4[1]) - ]]); - case /* Tuple */8 : - var param$5 = [ - loc, - t._0 - ]; - return node("TupleTypeAnnotation", param$5[0], [[ - "types", - array_of_list(_type, param$5[1]) - ]]); - case /* StringLiteral */9 : - var param$6 = [ - loc, - t._0 - ]; - var s = param$6[1]; - return node("StringLiteralTypeAnnotation", param$6[0], [ - [ - "value", - string(s.value) - ], - [ - "raw", - string(s.raw) - ] - ]); - case /* NumberLiteral */10 : - var param$7 = [ - loc, - t._0 - ]; - var s$1 = param$7[1]; - return node("NumberLiteralTypeAnnotation", param$7[0], [ - [ - "value", - number$1(s$1.value) - ], - [ - "raw", - string(s$1.raw) - ] - ]); - case /* BooleanLiteral */11 : - var param$8 = [ - loc, - t._0 - ]; - var s$2 = param$8[1]; - return node("BooleanLiteralTypeAnnotation", param$8[0], [ - [ - "value", - bool(s$2.value) - ], - [ - "raw", - string(s$2.raw) - ] - ]); - - } + case /* DeclareModuleExports */26 : + return node("DeclareModuleExports", loc, [[ + "typeAnnotation", + type_annotation(b._0) + ]]); + case /* DeclareExportDeclaration */27 : + var $$export = b._0; + var match$3 = $$export.declaration; + var declaration; + if (match$3 !== undefined) { + switch (match$3.TAG | 0) { + case /* Variable */0 : + declaration = declare_variable(match$3._0); + break; + case /* Function */1 : + declaration = declare_function(match$3._0); + break; + case /* Class */2 : + declaration = declare_class(match$3._0); + break; + case /* DefaultType */3 : + declaration = _type(match$3._0); + break; + case /* NamedType */4 : + declaration = type_alias(match$3._0); + break; + case /* Interface */5 : + declaration = interface_declaration(match$3._0); + break; + + } + } else { + declaration = $$null; + } + return node("DeclareExportDeclaration", loc, [ + [ + "default", + bool($$export.default) + ], + [ + "declaration", + declaration + ], + [ + "specifiers", + export_specifiers($$export.specifiers) + ], + [ + "source", + option(literal, $$export.source) + ] + ]); + case /* ExportDeclaration */28 : + var $$export$1 = b._0; + var match$4 = $$export$1.declaration; + var declaration$1 = match$4 !== undefined ? ( + match$4.TAG === /* Declaration */0 ? statement(match$4._0) : expression(match$4._0) + ) : $$null; + return node("ExportDeclaration", loc, [ + [ + "default", + bool($$export$1.default) + ], + [ + "declaration", + declaration$1 + ], + [ + "specifiers", + export_specifiers($$export$1.specifiers) + ], + [ + "source", + option(literal, $$export$1.source) + ], + [ + "exportKind", + string($$export$1.exportKind ? "value" : "type") + ] + ]); + case /* ImportDeclaration */29 : + var $$import = b._0; + var specifiers = Stdlib__List.map((function (param) { + switch (param.TAG | 0) { + case /* ImportNamedSpecifier */0 : + var match = param._0; + var local_id = match.local; + var remote_id = match.remote; + var span_loc = local_id !== undefined ? btwn(remote_id[0], local_id[0]) : remote_id[0]; + return node("ImportSpecifier", span_loc, [ + [ + "id", + identifier(remote_id) + ], + [ + "name", + option(identifier, local_id) + ] + ]); + case /* ImportDefaultSpecifier */1 : + var id = param._0; + return node("ImportDefaultSpecifier", id[0], [[ + "id", + identifier(id) + ]]); + case /* ImportNamespaceSpecifier */2 : + var param$1 = param._0; + return node("ImportNamespaceSpecifier", param$1[0], [[ + "id", + identifier(param$1[1]) + ]]); + + } + }), $$import.specifiers); + var match$5 = $$import.importKind; + var import_kind; + switch (match$5) { + case /* ImportType */0 : + import_kind = "type"; + break; + case /* ImportTypeof */1 : + import_kind = "typeof"; + break; + case /* ImportValue */2 : + import_kind = "value"; + break; + + } + return node("ImportDeclaration", loc, [ + [ + "specifiers", + array(Stdlib__Array.of_list(specifiers)) + ], + [ + "source", + literal($$import.source) + ], + [ + "importKind", + string(import_kind) + ] + ]); + } }; + var function_type = function (param) { + var fn = param[1]; + return node("FunctionTypeAnnotation", param[0], [ + [ + "params", + array_of_list(function_type_param, fn.params) + ], + [ + "returnType", + _type(fn.returnType) + ], + [ + "rest", + option(function_type_param, fn.rest) + ], + [ + "typeParameters", + option(type_parameter_declaration, fn.typeParameters) + ] + ]); + }; var comment = function (param) { var c = param[1]; var match; @@ -16954,133 +17334,172 @@ function parse(content, options) { string(match[1]) ]]); }; - var type_parameter_instantiation = function (param) { - return node("TypeParameterInstantiation", param[0], [[ - "params", - array_of_list(_type, param[1].params) - ]]); + var jsx_attribute_value = function (param) { + if (param.TAG === /* Literal */0) { + return literal([ + param._0, + param._1 + ]); + } else { + return jsx_expression_container([ + param._0, + param._1 + ]); + } }; - var interface_extends = function (param) { - var g = param[1]; - var id = g.id; - var id$1; - id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("InterfaceExtends", param[0], [ + var jsx_namespaced_name = function (param) { + var namespaced_name = param[1]; + return node("JSXNamespacedName", param[0], [ [ - "id", - id$1 + "namespace", + jsx_identifier(namespaced_name.namespace) ], [ - "typeParameters", - option(type_parameter_instantiation, g.typeParameters) + "name", + jsx_identifier(namespaced_name.name) ] ]); }; - var type_parameter_declaration = function (param) { - return node("TypeParameterDeclaration", param[0], [[ - "params", - array_of_list(type_param, param[1].params) - ]]); - }; - var object_type = function (param) { - var o = param[1]; - return node("ObjectTypeAnnotation", param[0], [ + var function_type_param = function (param) { + var param$1 = param[1]; + return node("FunctionTypeParam", param[0], [ [ - "properties", - array_of_list(object_type_property, o.properties) + "name", + identifier(param$1.name) ], [ - "indexers", - array_of_list(object_type_indexer, o.indexers) + "typeAnnotation", + _type(param$1.typeAnnotation) ], [ - "callProperties", - array_of_list(object_type_call_property, o.callProperties) + "optional", + bool(param$1.optional) ] ]); }; - var jsx_element = function (param) { - var element = param[1]; - return node("JSXElement", param[0], [ + var function_expression = function (param) { + var _function = param[1]; + var b = _function.body; + var body; + body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); + return node("FunctionExpression", param[0], [ + [ + "id", + option(identifier, _function.id) + ], + [ + "params", + array_of_list(pattern, _function.params) + ], + [ + "defaults", + array_of_list((function (param) { + return option(expression, param); + }), _function.defaults) + ], + [ + "rest", + option(identifier, _function.rest) + ], + [ + "body", + body + ], + [ + "async", + bool(_function.async) + ], + [ + "generator", + bool(_function.generator) + ], [ - "openingElement", - jsx_opening(element.openingElement) + "expression", + bool(_function.expression) ], [ - "closingElement", - option(jsx_closing, element.closingElement) + "returnType", + option(type_annotation, _function.returnType) ], [ - "children", - array_of_list(jsx_child, element.children) + "typeParameters", + option(type_parameter_declaration, _function.typeParameters) ] ]); }; - var block = function (param) { - return node("BlockStatement", param[0], [[ - "body", - array_of_list(statement, param[1].body) - ]]); + var jsx_child = function (param) { + var element = param[1]; + var loc = param[0]; + switch (element.TAG | 0) { + case /* Element */0 : + return jsx_element([ + loc, + element._0 + ]); + case /* ExpressionContainer */1 : + return jsx_expression_container([ + loc, + element._0 + ]); + case /* Text */2 : + var param$1 = [ + loc, + element._0 + ]; + var text = param$1[1]; + return node("JSXText", param$1[0], [ + [ + "value", + string(text.value) + ], + [ + "raw", + string(text.raw) + ] + ]); + + } }; - var let_assignment = function (assignment) { - return obj([ + var jsx_opening = function (param) { + var opening = param[1]; + return node("JSXOpeningElement", param[0], [ [ - "id", - pattern(assignment.id) + "name", + jsx_name(opening.name) ], [ - "init", - option(expression, assignment.init) - ] - ]); - }; - var template_literal = function (param) { - var value = param[1]; - return node("TemplateLiteral", param[0], [ - [ - "quasis", - array_of_list(template_element, value.quasis) + "attributes", + array_of_list(jsx_opening_attribute, opening.attributes) ], [ - "expressions", - array_of_list(expression, value.expressions) + "selfClosing", + bool(opening.selfClosing) ] ]); }; - var expression_or_spread = function (param) { - if (param.TAG === /* Expression */0) { - return expression(param._0); - } - var match = param._0; - return node("SpreadElement", match[0], [[ - "argument", - expression(match[1].argument) + var jsx_closing = function (param) { + return node("JSXClosingElement", param[0], [[ + "name", + jsx_name(param[1].name) ]]); }; - var comprehension_block = function (param) { - var b = param[1]; - return node("ComprehensionBlock", param[0], [ - [ - "left", - pattern(b.left) - ], + var jsx_member_expression = function (param) { + var member_expression = param[1]; + var id = member_expression._object; + var _object; + _object = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_member_expression(id._0); + return node("JSXMemberExpression", param[0], [ [ - "right", - expression(b.right) + "object", + _object ], [ - "each", - bool(b.each) + "property", + jsx_identifier(member_expression.property) ] ]); }; - var type_annotation = function (param) { - return node("TypeAnnotation", param[0], [[ - "typeAnnotation", - _type(param[1]) - ]]); - }; - var object_property = function (param) { + var object_pattern_property = function (param) { if (param.TAG === /* Property */0) { var match = param._0; var prop = match[1]; @@ -17107,214 +17526,103 @@ function parse(content, options) { break; } - var match$2 = prop.kind; - var kind; - switch (match$2) { - case /* Init */0 : - kind = "init"; - break; - case /* Get */1 : - kind = "get"; - break; - case /* Set */2 : - kind = "set"; - break; - - } - return node("Property", match[0], [ + return node("PropertyPattern", match[0], [ [ "key", match$1[0] ], [ - "value", - expression(prop.value) - ], - [ - "kind", - string(kind) + "pattern", + pattern(prop.pattern) ], [ - "method", - bool(prop._method) + "computed", + bool(match$1[1]) ], [ "shorthand", bool(prop.shorthand) - ], - [ - "computed", - bool(match$1[1]) ] ]); } - var match$3 = param._0; - return node("SpreadProperty", match$3[0], [[ + var match$2 = param._0; + return node("SpreadPropertyPattern", match$2[0], [[ "argument", - expression(match$3[1].argument) + pattern(match$2[1].argument) ]]); }; - var object_type_property = function (param) { - var prop = param[1]; - var lit = prop.key; - var key; - switch (lit.TAG | 0) { - case /* Literal */0 : - key = literal(lit._0); - break; - case /* Identifier */1 : - key = identifier(lit._0); - break; - case /* Computed */2 : - throw { - MEL_EXN_ID: "Failure", - _1: "There should not be computed object type property keys", - Error: new Error() - }; - - } - return node("ObjectTypeProperty", param[0], [ - [ - "key", - key - ], - [ - "value", - _type(prop.value) - ], - [ - "optional", - bool(prop.optional) - ], - [ - "static", - bool(prop.static) - ] - ]); - }; - var object_type_call_property = function (param) { - var callProperty = param[1]; - return node("ObjectTypeCallProperty", param[0], [ - [ - "value", - function_type(callProperty.value) - ], - [ - "static", - bool(callProperty.static) - ] - ]); - }; - var object_type_indexer = function (param) { - var indexer = param[1]; - return node("ObjectTypeIndexer", param[0], [ - [ - "id", - identifier(indexer.id) - ], - [ - "key", - _type(indexer.key) - ], - [ - "value", - _type(indexer.value) - ], - [ - "static", - bool(indexer.static) - ] - ]); - }; - var jsx_name = function (param) { - switch (param.TAG | 0) { - case /* Identifier */0 : - return jsx_identifier(param._0); - case /* NamespacedName */1 : - return jsx_namespaced_name(param._0); - case /* MemberExpression */2 : - return jsx_member_expression(param._0); - + var array_pattern_element = function (param) { + if (param.TAG === /* Element */0) { + return pattern(param._0); } - }; - var function_type = function (param) { - var fn = param[1]; - return node("FunctionTypeAnnotation", param[0], [ - [ - "params", - array_of_list(function_type_param, fn.params) - ], - [ - "returnType", - _type(fn.returnType) - ], + var match = param._0; + return node("SpreadElementPattern", match[0], [[ + "argument", + pattern(match[1].argument) + ]]); + }; + var $$case = function (param) { + var c = param[1]; + return node("SwitchCase", param[0], [ [ - "rest", - option(function_type_param, fn.rest) + "test", + option(expression, c.test) ], [ - "typeParameters", - option(type_parameter_declaration, fn.typeParameters) + "consequent", + array_of_list(statement, c.consequent) ] ]); }; - var type_param = function (param) { - var tp = param[1]; - var variance = function (param) { - if (param) { - return string("minus"); - } else { - return string("plus"); - } - }; - return node("TypeParameter", param[0], [ - [ - "name", - string(tp.name) - ], - [ - "bound", - option(type_annotation, tp.bound) - ], + var let_assignment = function (assignment) { + return obj([ [ - "variance", - option(variance, tp.variance) + "id", + pattern(assignment.id) ], [ - "default", - option(_type, tp.default) + "init", + option(expression, assignment.init) ] ]); }; - var class_implements = function (param) { - var $$implements = param[1]; - return node("ClassImplements", param[0], [ + var type_alias = function (param) { + var alias = param[1]; + return node("TypeAlias", param[0], [ [ "id", - identifier($$implements.id) + identifier(alias.id) ], [ "typeParameters", - option(type_parameter_instantiation, $$implements.typeParameters) + option(type_parameter_declaration, alias.typeParameters) + ], + [ + "right", + _type(alias.right) ] ]); }; - var class_body = function (param) { - return node("ClassBody", param[0], [[ - "body", - array_of_list(class_element, param[1].body) + var declare_function = function (param) { + return node("DeclareFunction", param[0], [[ + "id", + identifier(param[1].id) ]]); }; - var $$case = function (param) { + var $$catch = function (param) { var c = param[1]; - return node("SwitchCase", param[0], [ + return node("CatchClause", param[0], [ [ - "test", - option(expression, c.test) + "param", + pattern(c.param) ], [ - "consequent", - array_of_list(statement, c.consequent) + "guard", + option(expression, c.guard) + ], + [ + "body", + block(c.body) ] ]); }; @@ -17345,22 +17653,11 @@ function parse(content, options) { ] ]); }; - var $$catch = function (param) { - var c = param[1]; - return node("CatchClause", param[0], [ - [ - "param", - pattern(c.param) - ], - [ - "guard", - option(expression, c.guard) - ], - [ - "body", - block(c.body) - ] - ]); + var declare_variable = function (param) { + return node("DeclareVariable", param[0], [[ + "id", + identifier(param[1].id) + ]]); }; var export_specifiers = function (param) { if (param !== undefined) { @@ -17376,56 +17673,6 @@ function parse(content, options) { return array([]); } }; - var type_alias = function (param) { - var alias = param[1]; - return node("TypeAlias", param[0], [ - [ - "id", - identifier(alias.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, alias.typeParameters) - ], - [ - "right", - _type(alias.right) - ] - ]); - }; - var declare_function = function (param) { - return node("DeclareFunction", param[0], [[ - "id", - identifier(param[1].id) - ]]); - }; - var declare_variable = function (param) { - return node("DeclareVariable", param[0], [[ - "id", - identifier(param[1].id) - ]]); - }; - var interface_declaration = function (param) { - var i = param[1]; - return node("InterfaceDeclaration", param[0], [ - [ - "id", - identifier(i.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, i.typeParameters) - ], - [ - "body", - object_type(i.body) - ], - [ - "extends", - array_of_list(interface_extends, i.extends) - ] - ]); - }; var declare_class = function (param) { var d = param[1]; return node("DeclareClass", param[0], [ @@ -17447,288 +17694,55 @@ function parse(content, options) { ] ]); }; - var jsx_member_expression = function (param) { - var member_expression = param[1]; - var id = member_expression._object; - var _object; - _object = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_member_expression(id._0); - return node("JSXMemberExpression", param[0], [ - [ - "object", - _object - ], - [ - "property", - jsx_identifier(member_expression.property) - ] - ]); - }; - var export_specifier = function (param) { - var specifier = param[1]; - return node("ExportSpecifier", param[0], [ + var interface_declaration = function (param) { + var i = param[1]; + return node("InterfaceDeclaration", param[0], [ [ "id", - identifier(specifier.id) - ], - [ - "name", - option(identifier, specifier.name) - ] - ]); - }; - var jsx_opening_attribute = function (param) { - if (param.TAG === /* Attribute */0) { - var param$1 = param._0; - var attribute = param$1[1]; - var id = attribute.name; - var name; - name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); - return node("JSXAttribute", param$1[0], [ - [ - "name", - name - ], - [ - "value", - option(jsx_attribute_value, attribute.value) - ] - ]); - } else { - var param$2 = param._0; - return node("JSXSpreadAttribute", param$2[0], [[ - "argument", - expression(param$2[1].argument) - ]]); - } - }; - var generic_type_qualified_identifier = function (param) { - var q = param[1]; - var id = q.qualification; - var qualification; - qualification = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("QualifiedTypeIdentifier", param[0], [ - [ - "qualification", - qualification + identifier(i.id) ], [ - "id", - identifier(q.id) - ] - ]); - }; - var jsx_child = function (param) { - var element = param[1]; - var loc = param[0]; - switch (element.TAG | 0) { - case /* Element */0 : - return jsx_element([ - loc, - element._0 - ]); - case /* ExpressionContainer */1 : - return jsx_expression_container([ - loc, - element._0 - ]); - case /* Text */2 : - var param$1 = [ - loc, - element._0 - ]; - var text = param$1[1]; - return node("JSXText", param$1[0], [ - [ - "value", - string(text.value) - ], - [ - "raw", - string(text.raw) - ] - ]); - - } - }; - var jsx_opening = function (param) { - var opening = param[1]; - return node("JSXOpeningElement", param[0], [ - [ - "name", - jsx_name(opening.name) + "typeParameters", + option(type_parameter_declaration, i.typeParameters) ], [ - "attributes", - array_of_list(jsx_opening_attribute, opening.attributes) + "body", + object_type(i.body) ], [ - "selfClosing", - bool(opening.selfClosing) + "extends", + array_of_list(interface_extends, i.extends) ] ]); }; - var jsx_closing = function (param) { - return node("JSXClosingElement", param[0], [[ - "name", - jsx_name(param[1].name) - ]]); - }; - var template_element = function (param) { - var element = param[1]; - var value = obj([ - [ - "raw", - string(element.value.raw) - ], - [ - "cooked", - string(element.value.cooked) - ] - ]); - return node("TemplateElement", param[0], [ + var comprehension_block = function (param) { + var b = param[1]; + return node("ComprehensionBlock", param[0], [ [ - "value", - value + "left", + pattern(b.left) ], [ - "tail", - bool(element.tail) - ] - ]); - }; - var variable_declarator = function (param) { - var declarator = param[1]; - return node("VariableDeclarator", param[0], [ - [ - "id", - pattern(declarator.id) + "right", + expression(b.right) ], [ - "init", - option(expression, declarator.init) + "each", + bool(b.each) ] ]); }; - var class_element = function (param) { - if (param.TAG === /* Method */0) { - var param$1 = param._0; - var method_ = param$1[1]; - var key = method_.key; - var match; - switch (key.TAG | 0) { - case /* Literal */0 : - match = [ - literal(key._0), - false - ]; - break; - case /* Identifier */1 : - match = [ - identifier(key._0), - false - ]; - break; - case /* Computed */2 : - match = [ - expression(key._0), - true - ]; - break; - - } - var kind; - switch (method_.kind) { - case /* Constructor */0 : - kind = "constructor"; - break; - case /* Method */1 : - kind = "method"; - break; - case /* Get */2 : - kind = "get"; - break; - case /* Set */3 : - kind = "set"; - break; - - } - return node("MethodDefinition", param$1[0], [ - [ - "key", - match[0] - ], - [ - "value", - function_expression(method_.value) - ], - [ - "kind", - string(kind) - ], - [ - "static", - bool(method_.static) - ], - [ - "computed", - bool(match[1]) - ], - [ - "decorators", - array_of_list(expression, method_.decorators) - ] - ]); - } else { - var param$2 = param._0; - var prop = param$2[1]; - var lit = prop.key; - var match$1; - switch (lit.TAG | 0) { - case /* Literal */0 : - match$1 = [ - literal(lit._0), - false - ]; - break; - case /* Identifier */1 : - match$1 = [ - identifier(lit._0), - false - ]; - break; - case /* Computed */2 : - match$1 = [ - expression(lit._0), - true - ]; - break; - - } - return node("ClassProperty", param$2[0], [ - [ - "key", - match$1[0] - ], - [ - "value", - option(expression, prop.value) - ], - [ - "typeAnnotation", - option(type_annotation, prop.typeAnnotation) - ], - [ - "computed", - bool(match$1[1]) - ], - [ - "static", - bool(prop.static) - ] - ]); + var expression_or_spread = function (param) { + if (param.TAG === /* Expression */0) { + return expression(param._0); } + var match = param._0; + return node("SpreadElement", match[0], [[ + "argument", + expression(match[1].argument) + ]]); }; - var object_pattern_property = function (param) { + var object_property = function (param) { if (param.TAG === /* Property */0) { var match = param._0; var prop = match[1]; @@ -17755,67 +17769,53 @@ function parse(content, options) { break; } - return node("PropertyPattern", match[0], [ + var match$2 = prop.kind; + var kind; + switch (match$2) { + case /* Init */0 : + kind = "init"; + break; + case /* Get */1 : + kind = "get"; + break; + case /* Set */2 : + kind = "set"; + break; + + } + return node("Property", match[0], [ [ "key", match$1[0] ], [ - "pattern", - pattern(prop.pattern) + "value", + expression(prop.value) ], [ - "computed", - bool(match$1[1]) + "kind", + string(kind) + ], + [ + "method", + bool(prop._method) ], [ "shorthand", bool(prop.shorthand) + ], + [ + "computed", + bool(match$1[1]) ] ]); } - var match$2 = param._0; - return node("SpreadPropertyPattern", match$2[0], [[ - "argument", - pattern(match$2[1].argument) - ]]); - }; - var array_pattern_element = function (param) { - if (param.TAG === /* Element */0) { - return pattern(param._0); - } - var match = param._0; - return node("SpreadElementPattern", match[0], [[ + var match$3 = param._0; + return node("SpreadProperty", match$3[0], [[ "argument", - pattern(match[1].argument) - ]]); - }; - var jsx_expression_container = function (param) { - var expr = param[1].expression; - var expression$1; - expression$1 = expr.TAG === /* Expression */0 ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); - return node("JSXExpressionContainer", param[0], [[ - "expression", - expression$1 + expression(match$3[1].argument) ]]); }; - var function_type_param = function (param) { - var param$1 = param[1]; - return node("FunctionTypeParam", param[0], [ - [ - "name", - identifier(param$1.name) - ], - [ - "typeAnnotation", - _type(param$1.typeAnnotation) - ], - [ - "optional", - bool(param$1.optional) - ] - ]); - }; var program$2 = function (param) { return node("Program", param[0], [ [ diff --git a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js index a5e9e41c4f..b3359bfd15 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js @@ -12796,6 +12796,45 @@ function token(lexbuf) { }; } +function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + update_loc(lexbuf, undefined, 1, false, 0); + store_string(Stdlib__Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 183; + continue ; + case 1 : + is_in_string.contents = false; + throw { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents, + Error: new Error() + }; + case 2 : + var edelim = Stdlib__Lexing.lexeme(lexbuf); + var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); + if (delim === edelim$1) { + return ; + } + store_string(Stdlib__Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 183; + continue ; + case 3 : + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); + ___ocaml_lex_state = 183; + continue ; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + function string(lexbuf) { lexbuf.lex_mem = Caml_array.make(2, -1); var ___ocaml_lex_state = 164; @@ -13042,45 +13081,6 @@ function comment(lexbuf) { return __ocaml_lex_comment_rec(lexbuf, 132); } -function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - update_loc(lexbuf, undefined, 1, false, 0); - store_string(Stdlib__Lexing.lexeme(lexbuf)); - ___ocaml_lex_state = 183; - continue ; - case 1 : - is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; - case 2 : - var edelim = Stdlib__Lexing.lexeme(lexbuf); - var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); - if (delim === edelim$1) { - return ; - } - store_string(Stdlib__Lexing.lexeme(lexbuf)); - ___ocaml_lex_state = 183; - continue ; - case 3 : - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - ___ocaml_lex_state = 183; - continue ; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - function at_bol(lexbuf) { var pos = lexbuf.lex_start_p; return pos.pos_cnum === pos.pos_bol; diff --git a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js index 3dfd4c0231..fae44dd918 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js @@ -23428,20 +23428,6 @@ function directive_parse(token_with_comments, lexbuf) { } }; - var parse_or_aux = function (calc, v) { - var e = token(undefined); - if (e === 8) { - var calc$1 = calc && !v; - var b = parse_or_aux(calc$1, parse_and_aux(calc$1, parse_relation(calc$1))); - if (v) { - return true; - } else { - return b; - } - } - push(e); - return v; - }; var parse_and_aux = function (calc, v) { var e = token(undefined); if (typeof e === "number") { @@ -23611,6 +23597,20 @@ function directive_parse(token_with_comments, lexbuf) { } } }; + var parse_or_aux = function (calc, v) { + var e = token(undefined); + if (e === 8) { + var calc$1 = calc && !v; + var b = parse_or_aux(calc$1, parse_and_aux(calc$1, parse_relation(calc$1))); + if (v) { + return true; + } else { + return b; + } + } + push(e); + return v; + }; var v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); var match = token(undefined); if (match === 88) { @@ -24966,106 +24966,6 @@ function token(lexbuf) { }; } -function string(lexbuf) { - lexbuf.lex_mem = Caml_array.make(2, -1); - var ___ocaml_lex_state = 164; - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - return ; - case 1 : - var space = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); - update_loc(lexbuf, undefined, 1, false, space.length); - return string(lexbuf); - case 2 : - store_string_char(char_for_backslash(Stdlib__Lexing.lexeme_char(lexbuf, 1))); - return string(lexbuf); - case 3 : - store_string_char(char_for_decimal_code(lexbuf, 1)); - return string(lexbuf); - case 4 : - store_string_char(char_for_hexadecimal_code(lexbuf, 2)); - return string(lexbuf); - case 5 : - if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { - return string(lexbuf); - } - var loc = curr(lexbuf); - prerr_warning(loc, /* Illegal_backslash */7); - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 1)); - return string(lexbuf); - case 6 : - if (!Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { - prerr_warning(curr(lexbuf), /* Eol_in_string */14); - } - update_loc(lexbuf, undefined, 1, false, 0); - store_string(Stdlib__Lexing.lexeme(lexbuf)); - return string(lexbuf); - case 7 : - is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; - case 8 : - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - return string(lexbuf); - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - -function comment(lexbuf) { - return __ocaml_lex_comment_rec(lexbuf, 132); -} - -function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { - while(true) { - var __ocaml_lex_state = ___ocaml_lex_state; - var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); - switch (__ocaml_lex_state$1) { - case 0 : - update_loc(lexbuf, undefined, 1, false, 0); - store_string(Stdlib__Lexing.lexeme(lexbuf)); - ___ocaml_lex_state = 183; - continue ; - case 1 : - is_in_string.contents = false; - throw { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents, - Error: new Error() - }; - case 2 : - var edelim = Stdlib__Lexing.lexeme(lexbuf); - var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); - if (delim === edelim$1) { - return ; - } - store_string(Stdlib__Lexing.lexeme(lexbuf)); - ___ocaml_lex_state = 183; - continue ; - case 3 : - store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); - ___ocaml_lex_state = 183; - continue ; - default: - Curry._1(lexbuf.refill_buff, lexbuf); - ___ocaml_lex_state = __ocaml_lex_state$1; - continue ; - } - }; -} - function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { while(true) { var __ocaml_lex_state = ___ocaml_lex_state; @@ -25251,6 +25151,106 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { }; } +function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + update_loc(lexbuf, undefined, 1, false, 0); + store_string(Stdlib__Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 183; + continue ; + case 1 : + is_in_string.contents = false; + throw { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents, + Error: new Error() + }; + case 2 : + var edelim = Stdlib__Lexing.lexeme(lexbuf); + var edelim$1 = Stdlib__String.sub(edelim, 1, edelim.length - 2 | 0); + if (delim === edelim$1) { + return ; + } + store_string(Stdlib__Lexing.lexeme(lexbuf)); + ___ocaml_lex_state = 183; + continue ; + case 3 : + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); + ___ocaml_lex_state = 183; + continue ; + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + +function comment(lexbuf) { + return __ocaml_lex_comment_rec(lexbuf, 132); +} + +function string(lexbuf) { + lexbuf.lex_mem = Caml_array.make(2, -1); + var ___ocaml_lex_state = 164; + while(true) { + var __ocaml_lex_state = ___ocaml_lex_state; + var __ocaml_lex_state$1 = Stdlib__Lexing.new_engine(__ocaml_lex_tables, __ocaml_lex_state, lexbuf); + switch (__ocaml_lex_state$1) { + case 0 : + return ; + case 1 : + var space = Stdlib__Lexing.sub_lexeme(lexbuf, Caml_array.get(lexbuf.lex_mem, 0), lexbuf.lex_curr_pos); + update_loc(lexbuf, undefined, 1, false, space.length); + return string(lexbuf); + case 2 : + store_string_char(char_for_backslash(Stdlib__Lexing.lexeme_char(lexbuf, 1))); + return string(lexbuf); + case 3 : + store_string_char(char_for_decimal_code(lexbuf, 1)); + return string(lexbuf); + case 4 : + store_string_char(char_for_hexadecimal_code(lexbuf, 2)); + return string(lexbuf); + case 5 : + if (Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { + return string(lexbuf); + } + var loc = curr(lexbuf); + prerr_warning(loc, /* Illegal_backslash */7); + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 1)); + return string(lexbuf); + case 6 : + if (!Caml_obj.caml_notequal(comment_start_loc.contents, /* [] */0)) { + prerr_warning(curr(lexbuf), /* Eol_in_string */14); + } + update_loc(lexbuf, undefined, 1, false, 0); + store_string(Stdlib__Lexing.lexeme(lexbuf)); + return string(lexbuf); + case 7 : + is_in_string.contents = false; + throw { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents, + Error: new Error() + }; + case 8 : + store_string_char(Stdlib__Lexing.lexeme_char(lexbuf, 0)); + return string(lexbuf); + default: + Curry._1(lexbuf.refill_buff, lexbuf); + ___ocaml_lex_state = __ocaml_lex_state$1; + continue ; + } + }; +} + function at_bol(lexbuf) { var pos = lexbuf.lex_start_p; return pos.pos_cnum === pos.pos_bol; @@ -26077,198 +26077,142 @@ function TypedtreeMap_MakeMap(funarg) { str_final_env: str$1.str_final_env }); }; - var map_core_type = function (ct) { - var ct$1 = Curry._1(funarg.enter_core_type, ct); - var list = ct$1.ctyp_desc; - var ctyp_desc; - if (typeof list === "number") { - ctyp_desc = ct$1.ctyp_desc; + var map_extension_constructor = function (ext) { + var ext$1 = Curry._1(funarg.enter_extension_constructor, ext); + var match = ext$1.ext_kind; + var ext_kind; + if (match.TAG === /* Text_decl */0) { + var args = Stdlib__List.map(map_core_type, match._0); + var ret = may_map(map_core_type, match._1); + ext_kind = { + TAG: /* Text_decl */0, + _0: args, + _1: ret + }; } else { - switch (list.TAG | 0) { - case /* Ttyp_var */0 : - ctyp_desc = ct$1.ctyp_desc; - break; - case /* Ttyp_arrow */1 : - ctyp_desc = { - TAG: /* Ttyp_arrow */1, - _0: list._0, - _1: map_core_type(list._1), - _2: map_core_type(list._2) + ext_kind = { + TAG: /* Text_rebind */1, + _0: match._0, + _1: match._1 + }; + } + return Curry._1(funarg.leave_extension_constructor, { + ext_id: ext$1.ext_id, + ext_name: ext$1.ext_name, + ext_type: ext$1.ext_type, + ext_kind: ext_kind, + ext_loc: ext$1.ext_loc, + ext_attributes: ext$1.ext_attributes + }); + }; + var map_type_parameter = function (param) { + return [ + map_core_type(param[0]), + param[1] + ]; + }; + var map_pattern = function (pat) { + var pat$1 = Curry._1(funarg.enter_pattern, pat); + var list = pat$1.pat_desc; + var pat_desc; + if (typeof list === "number") { + pat_desc = pat$1.pat_desc; + } else { + switch (list.TAG | 0) { + case /* Tpat_alias */1 : + var pat1 = map_pattern(list._0); + pat_desc = { + TAG: /* Tpat_alias */1, + _0: pat1, + _1: list._1, + _2: list._2 }; break; - case /* Ttyp_tuple */2 : - ctyp_desc = { - TAG: /* Ttyp_tuple */2, - _0: Stdlib__List.map(map_core_type, list._0) + case /* Tpat_tuple */3 : + pat_desc = { + TAG: /* Tpat_tuple */3, + _0: Stdlib__List.map(map_pattern, list._0) }; break; - case /* Ttyp_constr */3 : - ctyp_desc = { - TAG: /* Ttyp_constr */3, + case /* Tpat_construct */4 : + pat_desc = { + TAG: /* Tpat_construct */4, _0: list._0, _1: list._1, - _2: Stdlib__List.map(map_core_type, list._2) + _2: Stdlib__List.map(map_pattern, list._2) }; break; - case /* Ttyp_object */4 : - ctyp_desc = { - TAG: /* Ttyp_object */4, + case /* Tpat_variant */5 : + var pato = list._1; + var pato$1 = pato !== undefined ? map_pattern(pato) : pato; + pat_desc = { + TAG: /* Tpat_variant */5, + _0: list._0, + _1: pato$1, + _2: list._2 + }; + break; + case /* Tpat_record */6 : + pat_desc = { + TAG: /* Tpat_record */6, _0: Stdlib__List.map((function (param) { return [ param[0], param[1], - map_core_type(param[2]) + map_pattern(param[2]) ]; }), list._0), _1: list._1 }; break; - case /* Ttyp_class */5 : - ctyp_desc = { - TAG: /* Ttyp_class */5, - _0: list._0, - _1: list._1, - _2: Stdlib__List.map(map_core_type, list._2) - }; - break; - case /* Ttyp_alias */6 : - ctyp_desc = { - TAG: /* Ttyp_alias */6, - _0: map_core_type(list._0), - _1: list._1 + case /* Tpat_array */7 : + pat_desc = { + TAG: /* Tpat_array */7, + _0: Stdlib__List.map(map_pattern, list._0) }; break; - case /* Ttyp_variant */7 : - ctyp_desc = { - TAG: /* Ttyp_variant */7, - _0: Stdlib__List.map(map_row_field, list._0), - _1: list._1, + case /* Tpat_or */8 : + pat_desc = { + TAG: /* Tpat_or */8, + _0: map_pattern(list._0), + _1: map_pattern(list._1), _2: list._2 }; break; - case /* Ttyp_poly */8 : - ctyp_desc = { - TAG: /* Ttyp_poly */8, - _0: list._0, - _1: map_core_type(list._1) - }; - break; - case /* Ttyp_package */9 : - ctyp_desc = { - TAG: /* Ttyp_package */9, - _0: map_package_type(list._0) + case /* Tpat_lazy */9 : + pat_desc = { + TAG: /* Tpat_lazy */9, + _0: map_pattern(list._0) }; break; - + default: + pat_desc = pat$1.pat_desc; } } - return Curry._1(funarg.leave_core_type, { - ctyp_desc: ctyp_desc, - ctyp_type: ct$1.ctyp_type, - ctyp_env: ct$1.ctyp_env, - ctyp_loc: ct$1.ctyp_loc, - ctyp_attributes: ct$1.ctyp_attributes + var pat_extra = Stdlib__List.map(map_pat_extra, pat$1.pat_extra); + return Curry._1(funarg.leave_pattern, { + pat_desc: pat_desc, + pat_loc: pat$1.pat_loc, + pat_extra: pat_extra, + pat_type: pat$1.pat_type, + pat_env: pat$1.pat_env, + pat_attributes: pat$1.pat_attributes }); }; - var map_type_declaration = function (decl) { - var decl$1 = Curry._1(funarg.enter_type_declaration, decl); - var typ_params = Stdlib__List.map(map_type_parameter, decl$1.typ_params); - var typ_cstrs = Stdlib__List.map((function (param) { - return [ - map_core_type(param[0]), - map_core_type(param[1]), - param[2] - ]; - }), decl$1.typ_cstrs); - var list = decl$1.typ_kind; - var typ_kind; - if (typeof list === "number") { - typ_kind = list === /* Ttype_abstract */0 ? /* Ttype_abstract */0 : /* Ttype_open */1; - } else if (list.TAG === /* Ttype_variant */0) { - var list$1 = Stdlib__List.map(map_constructor_declaration, list._0); - typ_kind = { - TAG: /* Ttype_variant */0, - _0: list$1 - }; + var map_pat_extra = function (pat_extra) { + var ct = pat_extra[0]; + if (typeof ct === "number" || ct.TAG !== /* Tpat_constraint */0) { + return pat_extra; } else { - var list$2 = Stdlib__List.map((function (ld) { - return { - ld_id: ld.ld_id, - ld_name: ld.ld_name, - ld_mutable: ld.ld_mutable, - ld_type: map_core_type(ld.ld_type), - ld_loc: ld.ld_loc, - ld_attributes: ld.ld_attributes - }; - }), list._0); - typ_kind = { - TAG: /* Ttype_record */1, - _0: list$2 - }; + return [ + { + TAG: /* Tpat_constraint */0, + _0: map_core_type(ct._0) + }, + pat_extra[1], + pat_extra[2] + ]; } - var typ_manifest = may_map(map_core_type, decl$1.typ_manifest); - return Curry._1(funarg.leave_type_declaration, { - typ_id: decl$1.typ_id, - typ_name: decl$1.typ_name, - typ_params: typ_params, - typ_type: decl$1.typ_type, - typ_cstrs: typ_cstrs, - typ_kind: typ_kind, - typ_private: decl$1.typ_private, - typ_manifest: typ_manifest, - typ_loc: decl$1.typ_loc, - typ_attributes: decl$1.typ_attributes - }); - }; - var map_type_extension = function (tyext) { - var tyext$1 = Curry._1(funarg.enter_type_extension, tyext); - var tyext_params = Stdlib__List.map(map_type_parameter, tyext$1.tyext_params); - var tyext_constructors = Stdlib__List.map(map_extension_constructor, tyext$1.tyext_constructors); - return Curry._1(funarg.leave_type_extension, { - tyext_path: tyext$1.tyext_path, - tyext_txt: tyext$1.tyext_txt, - tyext_params: tyext_params, - tyext_constructors: tyext_constructors, - tyext_private: tyext$1.tyext_private, - tyext_attributes: tyext$1.tyext_attributes - }); - }; - var map_binding = function (vb) { - return { - vb_pat: map_pattern(vb.vb_pat), - vb_expr: map_expression(vb.vb_expr), - vb_attributes: vb.vb_attributes, - vb_loc: vb.vb_loc - }; - }; - var map_class_type_declaration = function (cd) { - var cd$1 = Curry._1(funarg.enter_class_type_declaration, cd); - var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - var ci_expr = map_class_type(cd$1.ci_expr); - return Curry._1(funarg.leave_class_type_declaration, { - ci_virt: cd$1.ci_virt, - ci_params: ci_params, - ci_id_name: cd$1.ci_id_name, - ci_id_class: cd$1.ci_id_class, - ci_id_class_type: cd$1.ci_id_class_type, - ci_id_object: cd$1.ci_id_object, - ci_id_typesharp: cd$1.ci_id_typesharp, - ci_expr: ci_expr, - ci_decl: cd$1.ci_decl, - ci_type_decl: cd$1.ci_type_decl, - ci_loc: cd$1.ci_loc, - ci_attributes: cd$1.ci_attributes - }); - }; - var map_module_type_declaration = function (mtd) { - var mtd$1 = Curry._1(funarg.enter_module_type_declaration, mtd); - return Curry._1(funarg.leave_module_type_declaration, { - mtd_id: mtd$1.mtd_id, - mtd_name: mtd$1.mtd_name, - mtd_type: may_map(map_module_type, mtd$1.mtd_type), - mtd_attributes: mtd$1.mtd_attributes, - mtd_loc: mtd$1.mtd_loc - }); }; var map_module_expr = function (mexpr) { var mexpr$1 = Curry._1(funarg.enter_module_expr, mexpr); @@ -26338,304 +26282,128 @@ function TypedtreeMap_MakeMap(funarg) { mod_attributes: mexpr$1.mod_attributes }); }; - var map_module_binding = function (x) { - return { - mb_id: x.mb_id, - mb_name: x.mb_name, - mb_expr: map_module_expr(x.mb_expr), - mb_attributes: x.mb_attributes, - mb_loc: x.mb_loc - }; - }; - var map_expression = function (exp) { - var exp$1 = Curry._1(funarg.enter_expression, exp); - var list = exp$1.exp_desc; - var exp_desc; - switch (list.TAG | 0) { - case /* Texp_let */2 : - var rec_flag = list._0; - exp_desc = { - TAG: /* Texp_let */2, - _0: rec_flag, - _1: Stdlib__List.map(map_binding, list._1), - _2: map_expression(list._2) - }; - break; - case /* Texp_function */3 : - exp_desc = { - TAG: /* Texp_function */3, - _0: list._0, - _1: Stdlib__List.map(map_case, list._1), - _2: list._2 - }; - break; - case /* Texp_apply */4 : - exp_desc = { - TAG: /* Texp_apply */4, - _0: map_expression(list._0), - _1: Stdlib__List.map((function (param) { - var expo = param[1]; - var expo$1 = expo !== undefined ? map_expression(expo) : expo; - return [ - param[0], - expo$1, - param[2] - ]; - }), list._1) - }; - break; - case /* Texp_match */5 : - exp_desc = { - TAG: /* Texp_match */5, - _0: map_expression(list._0), - _1: Stdlib__List.map(map_case, list._1), - _2: Stdlib__List.map(map_case, list._2), - _3: list._3 - }; - break; - case /* Texp_try */6 : - exp_desc = { - TAG: /* Texp_try */6, - _0: map_expression(list._0), - _1: Stdlib__List.map(map_case, list._1) - }; - break; - case /* Texp_tuple */7 : - exp_desc = { - TAG: /* Texp_tuple */7, - _0: Stdlib__List.map(map_expression, list._0) - }; - break; - case /* Texp_construct */8 : - exp_desc = { - TAG: /* Texp_construct */8, - _0: list._0, - _1: list._1, - _2: Stdlib__List.map(map_expression, list._2) - }; - break; - case /* Texp_variant */9 : - var expo = list._1; - var expo$1 = expo !== undefined ? map_expression(expo) : expo; - exp_desc = { - TAG: /* Texp_variant */9, - _0: list._0, - _1: expo$1 - }; - break; - case /* Texp_record */10 : - var expo$2 = list._1; - var list$1 = Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_expression(param[2]) - ]; - }), list._0); - var expo$3 = expo$2 !== undefined ? map_expression(expo$2) : expo$2; - exp_desc = { - TAG: /* Texp_record */10, - _0: list$1, - _1: expo$3 - }; - break; - case /* Texp_field */11 : - exp_desc = { - TAG: /* Texp_field */11, - _0: map_expression(list._0), - _1: list._1, - _2: list._2 - }; - break; - case /* Texp_setfield */12 : - exp_desc = { - TAG: /* Texp_setfield */12, - _0: map_expression(list._0), - _1: list._1, - _2: list._2, - _3: map_expression(list._3) - }; - break; - case /* Texp_array */13 : - exp_desc = { - TAG: /* Texp_array */13, - _0: Stdlib__List.map(map_expression, list._0) - }; - break; - case /* Texp_ifthenelse */14 : - var expo$4 = list._2; - exp_desc = { - TAG: /* Texp_ifthenelse */14, - _0: map_expression(list._0), - _1: map_expression(list._1), - _2: expo$4 !== undefined ? map_expression(expo$4) : expo$4 - }; - break; - case /* Texp_sequence */15 : - exp_desc = { - TAG: /* Texp_sequence */15, - _0: map_expression(list._0), - _1: map_expression(list._1) - }; - break; - case /* Texp_while */16 : - exp_desc = { - TAG: /* Texp_while */16, - _0: map_expression(list._0), - _1: map_expression(list._1) - }; - break; - case /* Texp_for */17 : - exp_desc = { - TAG: /* Texp_for */17, - _0: list._0, - _1: list._1, - _2: map_expression(list._2), - _3: map_expression(list._3), - _4: list._4, - _5: map_expression(list._5) - }; - break; - case /* Texp_send */18 : - exp_desc = { - TAG: /* Texp_send */18, - _0: map_expression(list._0), - _1: list._1, - _2: may_map(map_expression, list._2) - }; - break; - case /* Texp_ident */0 : - case /* Texp_constant */1 : - case /* Texp_new */19 : - case /* Texp_instvar */20 : - exp_desc = exp$1.exp_desc; - break; - case /* Texp_setinstvar */21 : - exp_desc = { - TAG: /* Texp_setinstvar */21, - _0: list._0, - _1: list._1, - _2: list._2, - _3: map_expression(list._3) - }; - break; - case /* Texp_override */22 : - exp_desc = { - TAG: /* Texp_override */22, - _0: list._0, - _1: Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_expression(param[2]) - ]; - }), list._1) - }; - break; - case /* Texp_letmodule */23 : - exp_desc = { - TAG: /* Texp_letmodule */23, - _0: list._0, - _1: list._1, - _2: map_module_expr(list._2), - _3: map_expression(list._3) - }; - break; - case /* Texp_assert */24 : - exp_desc = { - TAG: /* Texp_assert */24, - _0: map_expression(list._0) - }; - break; - case /* Texp_lazy */25 : - exp_desc = { - TAG: /* Texp_lazy */25, - _0: map_expression(list._0) - }; - break; - case /* Texp_object */26 : - exp_desc = { - TAG: /* Texp_object */26, - _0: map_class_structure(list._0), - _1: list._1 - }; - break; - case /* Texp_pack */27 : - exp_desc = { - TAG: /* Texp_pack */27, - _0: map_module_expr(list._0) - }; - break; - + var map_row_field = function (rf) { + if (rf.TAG === /* Ttag */0) { + return { + TAG: /* Ttag */0, + _0: rf._0, + _1: rf._1, + _2: rf._2, + _3: Stdlib__List.map(map_core_type, rf._3) + }; + } else { + return { + TAG: /* Tinherit */1, + _0: map_core_type(rf._0) + }; } - var exp_extra = Stdlib__List.map(map_exp_extra, exp$1.exp_extra); - return Curry._1(funarg.leave_expression, { - exp_desc: exp_desc, - exp_loc: exp$1.exp_loc, - exp_extra: exp_extra, - exp_type: exp$1.exp_type, - exp_env: exp$1.exp_env, - exp_attributes: exp$1.exp_attributes - }); - }; - var map_class_declaration = function (cd) { - var cd$1 = Curry._1(funarg.enter_class_declaration, cd); - var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - var ci_expr = map_class_expr(cd$1.ci_expr); - return Curry._1(funarg.leave_class_declaration, { - ci_virt: cd$1.ci_virt, - ci_params: ci_params, - ci_id_name: cd$1.ci_id_name, - ci_id_class: cd$1.ci_id_class, - ci_id_class_type: cd$1.ci_id_class_type, - ci_id_object: cd$1.ci_id_object, - ci_id_typesharp: cd$1.ci_id_typesharp, - ci_expr: ci_expr, - ci_decl: cd$1.ci_decl, - ci_type_decl: cd$1.ci_type_decl, - ci_loc: cd$1.ci_loc, - ci_attributes: cd$1.ci_attributes - }); }; - var map_value_description = function (v) { - var v$1 = Curry._1(funarg.enter_value_description, v); - var val_desc = map_core_type(v$1.val_desc); - return Curry._1(funarg.leave_value_description, { - val_id: v$1.val_id, - val_name: v$1.val_name, - val_desc: val_desc, - val_val: v$1.val_val, - val_prim: v$1.val_prim, - val_loc: v$1.val_loc, - val_attributes: v$1.val_attributes + var map_package_type = function (pack) { + var pack$1 = Curry._1(funarg.enter_package_type, pack); + var pack_fields = Stdlib__List.map((function (param) { + return [ + param[0], + map_core_type(param[1]) + ]; + }), pack$1.pack_fields); + return Curry._1(funarg.leave_package_type, { + pack_path: pack$1.pack_path, + pack_fields: pack_fields, + pack_type: pack$1.pack_type, + pack_txt: pack$1.pack_txt }); }; - var map_extension_constructor = function (ext) { - var ext$1 = Curry._1(funarg.enter_extension_constructor, ext); - var match = ext$1.ext_kind; - var ext_kind; - if (match.TAG === /* Text_decl */0) { - var args = Stdlib__List.map(map_core_type, match._0); - var ret = may_map(map_core_type, match._1); - ext_kind = { - TAG: /* Text_decl */0, - _0: args, - _1: ret - }; + var map_core_type = function (ct) { + var ct$1 = Curry._1(funarg.enter_core_type, ct); + var list = ct$1.ctyp_desc; + var ctyp_desc; + if (typeof list === "number") { + ctyp_desc = ct$1.ctyp_desc; } else { - ext_kind = { - TAG: /* Text_rebind */1, - _0: match._0, - _1: match._1 - }; + switch (list.TAG | 0) { + case /* Ttyp_var */0 : + ctyp_desc = ct$1.ctyp_desc; + break; + case /* Ttyp_arrow */1 : + ctyp_desc = { + TAG: /* Ttyp_arrow */1, + _0: list._0, + _1: map_core_type(list._1), + _2: map_core_type(list._2) + }; + break; + case /* Ttyp_tuple */2 : + ctyp_desc = { + TAG: /* Ttyp_tuple */2, + _0: Stdlib__List.map(map_core_type, list._0) + }; + break; + case /* Ttyp_constr */3 : + ctyp_desc = { + TAG: /* Ttyp_constr */3, + _0: list._0, + _1: list._1, + _2: Stdlib__List.map(map_core_type, list._2) + }; + break; + case /* Ttyp_object */4 : + ctyp_desc = { + TAG: /* Ttyp_object */4, + _0: Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_core_type(param[2]) + ]; + }), list._0), + _1: list._1 + }; + break; + case /* Ttyp_class */5 : + ctyp_desc = { + TAG: /* Ttyp_class */5, + _0: list._0, + _1: list._1, + _2: Stdlib__List.map(map_core_type, list._2) + }; + break; + case /* Ttyp_alias */6 : + ctyp_desc = { + TAG: /* Ttyp_alias */6, + _0: map_core_type(list._0), + _1: list._1 + }; + break; + case /* Ttyp_variant */7 : + ctyp_desc = { + TAG: /* Ttyp_variant */7, + _0: Stdlib__List.map(map_row_field, list._0), + _1: list._1, + _2: list._2 + }; + break; + case /* Ttyp_poly */8 : + ctyp_desc = { + TAG: /* Ttyp_poly */8, + _0: list._0, + _1: map_core_type(list._1) + }; + break; + case /* Ttyp_package */9 : + ctyp_desc = { + TAG: /* Ttyp_package */9, + _0: map_package_type(list._0) + }; + break; + + } } - return Curry._1(funarg.leave_extension_constructor, { - ext_id: ext$1.ext_id, - ext_name: ext$1.ext_name, - ext_type: ext$1.ext_type, - ext_kind: ext_kind, - ext_loc: ext$1.ext_loc, - ext_attributes: ext$1.ext_attributes + return Curry._1(funarg.leave_core_type, { + ctyp_desc: ctyp_desc, + ctyp_type: ct$1.ctyp_type, + ctyp_env: ct$1.ctyp_env, + ctyp_loc: ct$1.ctyp_loc, + ctyp_attributes: ct$1.ctyp_attributes }); }; var map_class_type = function (ct) { @@ -26651,28 +26419,89 @@ function TypedtreeMap_MakeMap(funarg) { _2: Stdlib__List.map(map_core_type, csg._2) }; break; - case /* Tcty_signature */1 : - cltyp_desc = { - TAG: /* Tcty_signature */1, - _0: map_class_signature(csg._0) + case /* Tcty_signature */1 : + cltyp_desc = { + TAG: /* Tcty_signature */1, + _0: map_class_signature(csg._0) + }; + break; + case /* Tcty_arrow */2 : + cltyp_desc = { + TAG: /* Tcty_arrow */2, + _0: csg._0, + _1: map_core_type(csg._1), + _2: map_class_type(csg._2) + }; + break; + + } + return Curry._1(funarg.leave_class_type, { + cltyp_desc: cltyp_desc, + cltyp_type: ct$1.cltyp_type, + cltyp_env: ct$1.cltyp_env, + cltyp_loc: ct$1.cltyp_loc, + cltyp_attributes: ct$1.cltyp_attributes + }); + }; + var map_binding = function (vb) { + return { + vb_pat: map_pattern(vb.vb_pat), + vb_expr: map_expression(vb.vb_expr), + vb_attributes: vb.vb_attributes, + vb_loc: vb.vb_loc + }; + }; + var map_module_type = function (mty) { + var mty$1 = Curry._1(funarg.enter_module_type, mty); + var sg = mty$1.mty_desc; + var mty_desc; + switch (sg.TAG | 0) { + case /* Tmty_signature */1 : + mty_desc = { + TAG: /* Tmty_signature */1, + _0: map_signature(sg._0) + }; + break; + case /* Tmty_functor */2 : + mty_desc = { + TAG: /* Tmty_functor */2, + _0: sg._0, + _1: sg._1, + _2: may_map(map_module_type, sg._2), + _3: map_module_type(sg._3) }; break; - case /* Tcty_arrow */2 : - cltyp_desc = { - TAG: /* Tcty_arrow */2, - _0: csg._0, - _1: map_core_type(csg._1), - _2: map_class_type(csg._2) + case /* Tmty_with */3 : + mty_desc = { + TAG: /* Tmty_with */3, + _0: map_module_type(sg._0), + _1: Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_with_constraint(param[2]) + ]; + }), sg._1) + }; + break; + case /* Tmty_typeof */4 : + mty_desc = { + TAG: /* Tmty_typeof */4, + _0: map_module_expr(sg._0) }; break; + case /* Tmty_ident */0 : + case /* Tmty_alias */5 : + mty_desc = mty$1.mty_desc; + break; } - return Curry._1(funarg.leave_class_type, { - cltyp_desc: cltyp_desc, - cltyp_type: ct$1.cltyp_type, - cltyp_env: ct$1.cltyp_env, - cltyp_loc: ct$1.cltyp_loc, - cltyp_attributes: ct$1.cltyp_attributes + return Curry._1(funarg.leave_module_type, { + mty_desc: mty_desc, + mty_type: mty$1.mty_type, + mty_env: mty$1.mty_env, + mty_loc: mty$1.mty_loc, + mty_attributes: mty$1.mty_attributes }); }; var map_class_type_field = function (ctf) { @@ -26731,99 +26560,165 @@ function TypedtreeMap_MakeMap(funarg) { ctf_attributes: ctf$1.ctf_attributes }); }; - var map_pattern = function (pat) { - var pat$1 = Curry._1(funarg.enter_pattern, pat); - var list = pat$1.pat_desc; - var pat_desc; - if (typeof list === "number") { - pat_desc = pat$1.pat_desc; - } else { - switch (list.TAG | 0) { - case /* Tpat_alias */1 : - var pat1 = map_pattern(list._0); - pat_desc = { - TAG: /* Tpat_alias */1, - _0: pat1, - _1: list._1, - _2: list._2 - }; - break; - case /* Tpat_tuple */3 : - pat_desc = { - TAG: /* Tpat_tuple */3, - _0: Stdlib__List.map(map_pattern, list._0) - }; - break; - case /* Tpat_construct */4 : - pat_desc = { - TAG: /* Tpat_construct */4, - _0: list._0, - _1: list._1, - _2: Stdlib__List.map(map_pattern, list._2) - }; - break; - case /* Tpat_variant */5 : - var pato = list._1; - var pato$1 = pato !== undefined ? map_pattern(pato) : pato; - pat_desc = { - TAG: /* Tpat_variant */5, - _0: list._0, - _1: pato$1, - _2: list._2 - }; - break; - case /* Tpat_record */6 : - pat_desc = { - TAG: /* Tpat_record */6, - _0: Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_pattern(param[2]) - ]; - }), list._0), - _1: list._1 - }; - break; - case /* Tpat_array */7 : - pat_desc = { - TAG: /* Tpat_array */7, - _0: Stdlib__List.map(map_pattern, list._0) - }; - break; - case /* Tpat_or */8 : - pat_desc = { - TAG: /* Tpat_or */8, - _0: map_pattern(list._0), - _1: map_pattern(list._1), - _2: list._2 - }; - break; - case /* Tpat_lazy */9 : - pat_desc = { - TAG: /* Tpat_lazy */9, - _0: map_pattern(list._0) - }; - break; - default: - pat_desc = pat$1.pat_desc; - } + var map_class_field = function (cf) { + var cf$1 = Curry._1(funarg.enter_class_field, cf); + var exp = cf$1.cf_desc; + var cf_desc; + switch (exp.TAG | 0) { + case /* Tcf_inherit */0 : + cf_desc = { + TAG: /* Tcf_inherit */0, + _0: exp._0, + _1: map_class_expr(exp._1), + _2: exp._2, + _3: exp._3, + _4: exp._4 + }; + break; + case /* Tcf_val */1 : + var cty = exp._3; + var ident = exp._2; + var mut = exp._1; + var lab = exp._0; + cf_desc = cty.TAG === /* Tcfk_virtual */0 ? ({ + TAG: /* Tcf_val */1, + _0: lab, + _1: mut, + _2: ident, + _3: { + TAG: /* Tcfk_virtual */0, + _0: map_core_type(cty._0) + }, + _4: exp._4 + }) : ({ + TAG: /* Tcf_val */1, + _0: lab, + _1: mut, + _2: ident, + _3: { + TAG: /* Tcfk_concrete */1, + _0: cty._0, + _1: map_expression(cty._1) + }, + _4: exp._4 + }); + break; + case /* Tcf_method */2 : + var cty$1 = exp._2; + var priv = exp._1; + var lab$1 = exp._0; + cf_desc = cty$1.TAG === /* Tcfk_virtual */0 ? ({ + TAG: /* Tcf_method */2, + _0: lab$1, + _1: priv, + _2: { + TAG: /* Tcfk_virtual */0, + _0: map_core_type(cty$1._0) + } + }) : ({ + TAG: /* Tcf_method */2, + _0: lab$1, + _1: priv, + _2: { + TAG: /* Tcfk_concrete */1, + _0: cty$1._0, + _1: map_expression(cty$1._1) + } + }); + break; + case /* Tcf_constraint */3 : + cf_desc = { + TAG: /* Tcf_constraint */3, + _0: map_core_type(exp._0), + _1: map_core_type(exp._1) + }; + break; + case /* Tcf_initializer */4 : + cf_desc = { + TAG: /* Tcf_initializer */4, + _0: map_expression(exp._0) + }; + break; + case /* Tcf_attribute */5 : + cf_desc = exp; + break; + } - var pat_extra = Stdlib__List.map(map_pat_extra, pat$1.pat_extra); - return Curry._1(funarg.leave_pattern, { - pat_desc: pat_desc, - pat_loc: pat$1.pat_loc, - pat_extra: pat_extra, - pat_type: pat$1.pat_type, - pat_env: pat$1.pat_env, - pat_attributes: pat$1.pat_attributes + return Curry._1(funarg.leave_class_field, { + cf_desc: cf_desc, + cf_loc: cf$1.cf_loc, + cf_attributes: cf$1.cf_attributes + }); + }; + var map_module_binding = function (x) { + return { + mb_id: x.mb_id, + mb_name: x.mb_name, + mb_expr: map_module_expr(x.mb_expr), + mb_attributes: x.mb_attributes, + mb_loc: x.mb_loc + }; + }; + var map_value_description = function (v) { + var v$1 = Curry._1(funarg.enter_value_description, v); + var val_desc = map_core_type(v$1.val_desc); + return Curry._1(funarg.leave_value_description, { + val_id: v$1.val_id, + val_name: v$1.val_name, + val_desc: val_desc, + val_val: v$1.val_val, + val_prim: v$1.val_prim, + val_loc: v$1.val_loc, + val_attributes: v$1.val_attributes + }); + }; + var map_class_type_declaration = function (cd) { + var cd$1 = Curry._1(funarg.enter_class_type_declaration, cd); + var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); + var ci_expr = map_class_type(cd$1.ci_expr); + return Curry._1(funarg.leave_class_type_declaration, { + ci_virt: cd$1.ci_virt, + ci_params: ci_params, + ci_id_name: cd$1.ci_id_name, + ci_id_class: cd$1.ci_id_class, + ci_id_class_type: cd$1.ci_id_class_type, + ci_id_object: cd$1.ci_id_object, + ci_id_typesharp: cd$1.ci_id_typesharp, + ci_expr: ci_expr, + ci_decl: cd$1.ci_decl, + ci_type_decl: cd$1.ci_type_decl, + ci_loc: cd$1.ci_loc, + ci_attributes: cd$1.ci_attributes }); }; - var map_class_description = function (cd) { - var cd$1 = Curry._1(funarg.enter_class_description, cd); + var map_type_extension = function (tyext) { + var tyext$1 = Curry._1(funarg.enter_type_extension, tyext); + var tyext_params = Stdlib__List.map(map_type_parameter, tyext$1.tyext_params); + var tyext_constructors = Stdlib__List.map(map_extension_constructor, tyext$1.tyext_constructors); + return Curry._1(funarg.leave_type_extension, { + tyext_path: tyext$1.tyext_path, + tyext_txt: tyext$1.tyext_txt, + tyext_params: tyext_params, + tyext_constructors: tyext_constructors, + tyext_private: tyext$1.tyext_private, + tyext_attributes: tyext$1.tyext_attributes + }); + }; + var map_module_type_declaration = function (mtd) { + var mtd$1 = Curry._1(funarg.enter_module_type_declaration, mtd); + return Curry._1(funarg.leave_module_type_declaration, { + mtd_id: mtd$1.mtd_id, + mtd_name: mtd$1.mtd_name, + mtd_type: may_map(map_module_type, mtd$1.mtd_type), + mtd_attributes: mtd$1.mtd_attributes, + mtd_loc: mtd$1.mtd_loc + }); + }; + var map_class_declaration = function (cd) { + var cd$1 = Curry._1(funarg.enter_class_declaration, cd); var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - var ci_expr = map_class_type(cd$1.ci_expr); - return Curry._1(funarg.leave_class_description, { + var ci_expr = map_class_expr(cd$1.ci_expr); + return Curry._1(funarg.leave_class_declaration, { ci_virt: cd$1.ci_virt, ci_params: ci_params, ci_id_name: cd$1.ci_id_name, @@ -26838,397 +26733,344 @@ function TypedtreeMap_MakeMap(funarg) { ci_attributes: cd$1.ci_attributes }); }; - var map_module_type = function (mty) { - var mty$1 = Curry._1(funarg.enter_module_type, mty); - var sg = mty$1.mty_desc; - var mty_desc; - switch (sg.TAG | 0) { - case /* Tmty_signature */1 : - mty_desc = { - TAG: /* Tmty_signature */1, - _0: map_signature(sg._0) + var map_expression = function (exp) { + var exp$1 = Curry._1(funarg.enter_expression, exp); + var list = exp$1.exp_desc; + var exp_desc; + switch (list.TAG | 0) { + case /* Texp_let */2 : + var rec_flag = list._0; + exp_desc = { + TAG: /* Texp_let */2, + _0: rec_flag, + _1: Stdlib__List.map(map_binding, list._1), + _2: map_expression(list._2) }; break; - case /* Tmty_functor */2 : - mty_desc = { - TAG: /* Tmty_functor */2, - _0: sg._0, - _1: sg._1, - _2: may_map(map_module_type, sg._2), - _3: map_module_type(sg._3) + case /* Texp_function */3 : + exp_desc = { + TAG: /* Texp_function */3, + _0: list._0, + _1: Stdlib__List.map(map_case, list._1), + _2: list._2 }; break; - case /* Tmty_with */3 : - mty_desc = { - TAG: /* Tmty_with */3, - _0: map_module_type(sg._0), + case /* Texp_apply */4 : + exp_desc = { + TAG: /* Texp_apply */4, + _0: map_expression(list._0), _1: Stdlib__List.map((function (param) { + var expo = param[1]; + var expo$1 = expo !== undefined ? map_expression(expo) : expo; return [ param[0], - param[1], - map_with_constraint(param[2]) + expo$1, + param[2] ]; - }), sg._1) + }), list._1) }; break; - case /* Tmty_typeof */4 : - mty_desc = { - TAG: /* Tmty_typeof */4, - _0: map_module_expr(sg._0) + case /* Texp_match */5 : + exp_desc = { + TAG: /* Texp_match */5, + _0: map_expression(list._0), + _1: Stdlib__List.map(map_case, list._1), + _2: Stdlib__List.map(map_case, list._2), + _3: list._3 }; break; - case /* Tmty_ident */0 : - case /* Tmty_alias */5 : - mty_desc = mty$1.mty_desc; + case /* Texp_try */6 : + exp_desc = { + TAG: /* Texp_try */6, + _0: map_expression(list._0), + _1: Stdlib__List.map(map_case, list._1) + }; break; - - } - return Curry._1(funarg.leave_module_type, { - mty_desc: mty_desc, - mty_type: mty$1.mty_type, - mty_env: mty$1.mty_env, - mty_loc: mty$1.mty_loc, - mty_attributes: mty$1.mty_attributes - }); - }; - var map_class_signature = function (cs) { - var cs$1 = Curry._1(funarg.enter_class_signature, cs); - var csig_self = map_core_type(cs$1.csig_self); - var csig_fields = Stdlib__List.map(map_class_type_field, cs$1.csig_fields); - return Curry._1(funarg.leave_class_signature, { - csig_self: csig_self, - csig_fields: csig_fields, - csig_type: cs$1.csig_type - }); - }; - var map_row_field = function (rf) { - if (rf.TAG === /* Ttag */0) { - return { - TAG: /* Ttag */0, - _0: rf._0, - _1: rf._1, - _2: rf._2, - _3: Stdlib__List.map(map_core_type, rf._3) - }; - } else { - return { - TAG: /* Tinherit */1, - _0: map_core_type(rf._0) - }; - } - }; - var map_package_type = function (pack) { - var pack$1 = Curry._1(funarg.enter_package_type, pack); - var pack_fields = Stdlib__List.map((function (param) { - return [ - param[0], - map_core_type(param[1]) - ]; - }), pack$1.pack_fields); - return Curry._1(funarg.leave_package_type, { - pack_path: pack$1.pack_path, - pack_fields: pack_fields, - pack_type: pack$1.pack_type, - pack_txt: pack$1.pack_txt - }); - }; - var map_case = function (param) { - return { - c_lhs: map_pattern(param.c_lhs), - c_guard: may_map(map_expression, param.c_guard), - c_rhs: map_expression(param.c_rhs) + case /* Texp_tuple */7 : + exp_desc = { + TAG: /* Texp_tuple */7, + _0: Stdlib__List.map(map_expression, list._0) }; - }; - var map_class_expr = function (cexpr) { - var cexpr$1 = Curry._1(funarg.enter_class_expr, cexpr); - var clstr = cexpr$1.cl_desc; - var cl_desc; - switch (clstr.TAG | 0) { - case /* Tcl_ident */0 : - cl_desc = { - TAG: /* Tcl_ident */0, - _0: clstr._0, - _1: clstr._1, - _2: Stdlib__List.map(map_core_type, clstr._2) + break; + case /* Texp_construct */8 : + exp_desc = { + TAG: /* Texp_construct */8, + _0: list._0, + _1: list._1, + _2: Stdlib__List.map(map_expression, list._2) }; break; - case /* Tcl_structure */1 : - cl_desc = { - TAG: /* Tcl_structure */1, - _0: map_class_structure(clstr._0) + case /* Texp_variant */9 : + var expo = list._1; + var expo$1 = expo !== undefined ? map_expression(expo) : expo; + exp_desc = { + TAG: /* Texp_variant */9, + _0: list._0, + _1: expo$1 }; break; - case /* Tcl_fun */2 : - cl_desc = { - TAG: /* Tcl_fun */2, - _0: clstr._0, - _1: map_pattern(clstr._1), - _2: Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_expression(param[2]) - ]; - }), clstr._2), - _3: map_class_expr(clstr._3), - _4: clstr._4 + case /* Texp_record */10 : + var expo$2 = list._1; + var list$1 = Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_expression(param[2]) + ]; + }), list._0); + var expo$3 = expo$2 !== undefined ? map_expression(expo$2) : expo$2; + exp_desc = { + TAG: /* Texp_record */10, + _0: list$1, + _1: expo$3 }; break; - case /* Tcl_apply */3 : - cl_desc = { - TAG: /* Tcl_apply */3, - _0: map_class_expr(clstr._0), - _1: Stdlib__List.map((function (param) { - return [ - param[0], - may_map(map_expression, param[1]), - param[2] - ]; - }), clstr._1) + case /* Texp_field */11 : + exp_desc = { + TAG: /* Texp_field */11, + _0: map_expression(list._0), + _1: list._1, + _2: list._2 + }; + break; + case /* Texp_setfield */12 : + exp_desc = { + TAG: /* Texp_setfield */12, + _0: map_expression(list._0), + _1: list._1, + _2: list._2, + _3: map_expression(list._3) + }; + break; + case /* Texp_array */13 : + exp_desc = { + TAG: /* Texp_array */13, + _0: Stdlib__List.map(map_expression, list._0) }; break; - case /* Tcl_let */4 : - var rec_flat = clstr._0; - cl_desc = { - TAG: /* Tcl_let */4, - _0: rec_flat, - _1: Stdlib__List.map(map_binding, clstr._1), - _2: Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_expression(param[2]) - ]; - }), clstr._2), - _3: map_class_expr(clstr._3) + case /* Texp_ifthenelse */14 : + var expo$4 = list._2; + exp_desc = { + TAG: /* Texp_ifthenelse */14, + _0: map_expression(list._0), + _1: map_expression(list._1), + _2: expo$4 !== undefined ? map_expression(expo$4) : expo$4 }; break; - case /* Tcl_constraint */5 : - var clty = clstr._1; - var cl = clstr._0; - cl_desc = clty !== undefined ? ({ - TAG: /* Tcl_constraint */5, - _0: map_class_expr(cl), - _1: map_class_type(clty), - _2: clstr._2, - _3: clstr._3, - _4: clstr._4 - }) : ({ - TAG: /* Tcl_constraint */5, - _0: map_class_expr(cl), - _1: undefined, - _2: clstr._2, - _3: clstr._3, - _4: clstr._4 - }); + case /* Texp_sequence */15 : + exp_desc = { + TAG: /* Texp_sequence */15, + _0: map_expression(list._0), + _1: map_expression(list._1) + }; break; - - } - return Curry._1(funarg.leave_class_expr, { - cl_desc: cl_desc, - cl_loc: cexpr$1.cl_loc, - cl_type: cexpr$1.cl_type, - cl_env: cexpr$1.cl_env, - cl_attributes: cexpr$1.cl_attributes - }); - }; - var map_type_parameter = function (param) { - return [ - map_core_type(param[0]), - param[1] - ]; - }; - var map_constructor_declaration = function (cd) { - return { - cd_id: cd.cd_id, - cd_name: cd.cd_name, - cd_args: Stdlib__List.map(map_core_type, cd.cd_args), - cd_res: may_map(map_core_type, cd.cd_res), - cd_loc: cd.cd_loc, - cd_attributes: cd.cd_attributes + case /* Texp_while */16 : + exp_desc = { + TAG: /* Texp_while */16, + _0: map_expression(list._0), + _1: map_expression(list._1) }; - }; - var map_class_structure = function (cs) { - var cs$1 = Curry._1(funarg.enter_class_structure, cs); - var cstr_self = map_pattern(cs$1.cstr_self); - var cstr_fields = Stdlib__List.map(map_class_field, cs$1.cstr_fields); - return Curry._1(funarg.leave_class_structure, { - cstr_self: cstr_self, - cstr_fields: cstr_fields, - cstr_type: cs$1.cstr_type, - cstr_meths: cs$1.cstr_meths - }); - }; - var map_exp_extra = function (exp_extra) { - var attrs = exp_extra[2]; - var loc = exp_extra[1]; - var desc = exp_extra[0]; - switch (desc.TAG | 0) { - case /* Texp_constraint */0 : - return [ - { - TAG: /* Texp_constraint */0, - _0: map_core_type(desc._0) - }, - loc, - attrs - ]; - case /* Texp_coerce */1 : - var ct1 = desc._0; - if (ct1 !== undefined) { - return [ - { - TAG: /* Texp_coerce */1, - _0: map_core_type(ct1), - _1: map_core_type(desc._1) - }, - loc, - attrs - ]; - } else { - return [ - { - TAG: /* Texp_coerce */1, - _0: undefined, - _1: map_core_type(desc._1) - }, - loc, - attrs - ]; - } - case /* Texp_poly */3 : - var ct = desc._0; - if (ct !== undefined) { - return [ - { - TAG: /* Texp_poly */3, - _0: map_core_type(ct) - }, - loc, - attrs - ]; - } else { - return exp_extra; - } - case /* Texp_open */2 : - case /* Texp_newtype */4 : - return exp_extra; - - } - }; - var map_pat_extra = function (pat_extra) { - var ct = pat_extra[0]; - if (typeof ct === "number" || ct.TAG !== /* Tpat_constraint */0) { - return pat_extra; - } else { - return [ - { - TAG: /* Tpat_constraint */0, - _0: map_core_type(ct._0) - }, - pat_extra[1], - pat_extra[2] - ]; - } - }; - var map_signature_item = function (item) { - var item$1 = Curry._1(funarg.enter_signature_item, item); - var vd = item$1.sig_desc; - var sig_desc; - switch (vd.TAG | 0) { - case /* Tsig_value */0 : - sig_desc = { - TAG: /* Tsig_value */0, - _0: map_value_description(vd._0) + break; + case /* Texp_for */17 : + exp_desc = { + TAG: /* Texp_for */17, + _0: list._0, + _1: list._1, + _2: map_expression(list._2), + _3: map_expression(list._3), + _4: list._4, + _5: map_expression(list._5) }; break; - case /* Tsig_type */1 : - sig_desc = { - TAG: /* Tsig_type */1, - _0: Stdlib__List.map(map_type_declaration, vd._0) + case /* Texp_send */18 : + exp_desc = { + TAG: /* Texp_send */18, + _0: map_expression(list._0), + _1: list._1, + _2: may_map(map_expression, list._2) }; break; - case /* Tsig_typext */2 : - sig_desc = { - TAG: /* Tsig_typext */2, - _0: map_type_extension(vd._0) + case /* Texp_ident */0 : + case /* Texp_constant */1 : + case /* Texp_new */19 : + case /* Texp_instvar */20 : + exp_desc = exp$1.exp_desc; + break; + case /* Texp_setinstvar */21 : + exp_desc = { + TAG: /* Texp_setinstvar */21, + _0: list._0, + _1: list._1, + _2: list._2, + _3: map_expression(list._3) }; break; - case /* Tsig_exception */3 : - sig_desc = { - TAG: /* Tsig_exception */3, - _0: map_extension_constructor(vd._0) + case /* Texp_override */22 : + exp_desc = { + TAG: /* Texp_override */22, + _0: list._0, + _1: Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_expression(param[2]) + ]; + }), list._1) }; break; - case /* Tsig_module */4 : - var md = vd._0; - sig_desc = { - TAG: /* Tsig_module */4, - _0: { - md_id: md.md_id, - md_name: md.md_name, - md_type: map_module_type(md.md_type), - md_attributes: md.md_attributes, - md_loc: md.md_loc - } + case /* Texp_letmodule */23 : + exp_desc = { + TAG: /* Texp_letmodule */23, + _0: list._0, + _1: list._1, + _2: map_module_expr(list._2), + _3: map_expression(list._3) }; break; - case /* Tsig_recmodule */5 : - sig_desc = { - TAG: /* Tsig_recmodule */5, - _0: Stdlib__List.map((function (md) { - return { - md_id: md.md_id, - md_name: md.md_name, - md_type: map_module_type(md.md_type), - md_attributes: md.md_attributes, - md_loc: md.md_loc - }; - }), vd._0) + case /* Texp_assert */24 : + exp_desc = { + TAG: /* Texp_assert */24, + _0: map_expression(list._0) }; break; - case /* Tsig_modtype */6 : - sig_desc = { - TAG: /* Tsig_modtype */6, - _0: map_module_type_declaration(vd._0) + case /* Texp_lazy */25 : + exp_desc = { + TAG: /* Texp_lazy */25, + _0: map_expression(list._0) }; break; - case /* Tsig_open */7 : - sig_desc = item$1.sig_desc; + case /* Texp_object */26 : + exp_desc = { + TAG: /* Texp_object */26, + _0: map_class_structure(list._0), + _1: list._1 + }; break; - case /* Tsig_include */8 : - var incl = vd._0; - sig_desc = { - TAG: /* Tsig_include */8, - _0: { - incl_mod: map_module_type(incl.incl_mod), - incl_type: incl.incl_type, - incl_loc: incl.incl_loc, - incl_attributes: incl.incl_attributes - } + case /* Texp_pack */27 : + exp_desc = { + TAG: /* Texp_pack */27, + _0: map_module_expr(list._0) }; break; - case /* Tsig_class */9 : - sig_desc = { - TAG: /* Tsig_class */9, - _0: Stdlib__List.map(map_class_description, vd._0) + + } + var exp_extra = Stdlib__List.map(map_exp_extra, exp$1.exp_extra); + return Curry._1(funarg.leave_expression, { + exp_desc: exp_desc, + exp_loc: exp$1.exp_loc, + exp_extra: exp_extra, + exp_type: exp$1.exp_type, + exp_env: exp$1.exp_env, + exp_attributes: exp$1.exp_attributes + }); + }; + var map_type_declaration = function (decl) { + var decl$1 = Curry._1(funarg.enter_type_declaration, decl); + var typ_params = Stdlib__List.map(map_type_parameter, decl$1.typ_params); + var typ_cstrs = Stdlib__List.map((function (param) { + return [ + map_core_type(param[0]), + map_core_type(param[1]), + param[2] + ]; + }), decl$1.typ_cstrs); + var list = decl$1.typ_kind; + var typ_kind; + if (typeof list === "number") { + typ_kind = list === /* Ttype_abstract */0 ? /* Ttype_abstract */0 : /* Ttype_open */1; + } else if (list.TAG === /* Ttype_variant */0) { + var list$1 = Stdlib__List.map(map_constructor_declaration, list._0); + typ_kind = { + TAG: /* Ttype_variant */0, + _0: list$1 + }; + } else { + var list$2 = Stdlib__List.map((function (ld) { + return { + ld_id: ld.ld_id, + ld_name: ld.ld_name, + ld_mutable: ld.ld_mutable, + ld_type: map_core_type(ld.ld_type), + ld_loc: ld.ld_loc, + ld_attributes: ld.ld_attributes + }; + }), list._0); + typ_kind = { + TAG: /* Ttype_record */1, + _0: list$2 + }; + } + var typ_manifest = may_map(map_core_type, decl$1.typ_manifest); + return Curry._1(funarg.leave_type_declaration, { + typ_id: decl$1.typ_id, + typ_name: decl$1.typ_name, + typ_params: typ_params, + typ_type: decl$1.typ_type, + typ_cstrs: typ_cstrs, + typ_kind: typ_kind, + typ_private: decl$1.typ_private, + typ_manifest: typ_manifest, + typ_loc: decl$1.typ_loc, + typ_attributes: decl$1.typ_attributes + }); + }; + var map_case = function (param) { + return { + c_lhs: map_pattern(param.c_lhs), + c_guard: may_map(map_expression, param.c_guard), + c_rhs: map_expression(param.c_rhs) + }; + }; + var map_with_constraint = function (cstr) { + var cstr$1 = Curry._1(funarg.enter_with_constraint, cstr); + var tmp; + switch (cstr$1.TAG | 0) { + case /* Twith_type */0 : + tmp = { + TAG: /* Twith_type */0, + _0: map_type_declaration(cstr$1._0) }; break; - case /* Tsig_class_type */10 : - sig_desc = { - TAG: /* Tsig_class_type */10, - _0: Stdlib__List.map(map_class_type_declaration, vd._0) + case /* Twith_typesubst */2 : + tmp = { + TAG: /* Twith_typesubst */2, + _0: map_type_declaration(cstr$1._0) }; break; - case /* Tsig_attribute */11 : - sig_desc = vd; + case /* Twith_module */1 : + case /* Twith_modsubst */3 : + tmp = cstr$1; break; } - return Curry._1(funarg.leave_signature_item, { - sig_desc: sig_desc, - sig_env: item$1.sig_env, - sig_loc: item$1.sig_loc + return Curry._1(funarg.leave_with_constraint, tmp); + }; + var map_signature = function (sg) { + var sg$1 = Curry._1(funarg.enter_signature, sg); + var sig_items = Stdlib__List.map(map_signature_item, sg$1.sig_items); + return Curry._1(funarg.leave_signature, { + sig_items: sig_items, + sig_type: sg$1.sig_type, + sig_final_env: sg$1.sig_final_env + }); + }; + var map_class_description = function (cd) { + var cd$1 = Curry._1(funarg.enter_class_description, cd); + var ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); + var ci_expr = map_class_type(cd$1.ci_expr); + return Curry._1(funarg.leave_class_description, { + ci_virt: cd$1.ci_virt, + ci_params: ci_params, + ci_id_name: cd$1.ci_id_name, + ci_id_class: cd$1.ci_id_class, + ci_id_class_type: cd$1.ci_id_class_type, + ci_id_object: cd$1.ci_id_object, + ci_id_typesharp: cd$1.ci_id_typesharp, + ci_expr: ci_expr, + ci_decl: cd$1.ci_decl, + ci_type_decl: cd$1.ci_type_decl, + ci_loc: cd$1.ci_loc, + ci_attributes: cd$1.ci_attributes }); }; var map_structure_item = function (item) { @@ -27313,167 +27155,325 @@ function TypedtreeMap_MakeMap(funarg) { _0: list$1 }; break; - case /* Tstr_class_type */11 : - var list$2 = Stdlib__List.map((function (param) { - return [ - param[0], - param[1], - map_class_type_declaration(param[2]) - ]; - }), vd._0); - str_desc = { - TAG: /* Tstr_class_type */11, - _0: list$2 - }; + case /* Tstr_class_type */11 : + var list$2 = Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_class_type_declaration(param[2]) + ]; + }), vd._0); + str_desc = { + TAG: /* Tstr_class_type */11, + _0: list$2 + }; + break; + case /* Tstr_include */12 : + var incl = vd._0; + str_desc = { + TAG: /* Tstr_include */12, + _0: { + incl_mod: map_module_expr(incl.incl_mod), + incl_type: incl.incl_type, + incl_loc: incl.incl_loc, + incl_attributes: incl.incl_attributes + } + }; + break; + case /* Tstr_attribute */13 : + str_desc = { + TAG: /* Tstr_attribute */13, + _0: vd._0 + }; + break; + + } + return Curry._1(funarg.leave_structure_item, { + str_desc: str_desc, + str_loc: item$1.str_loc, + str_env: item$1.str_env + }); + }; + var map_signature_item = function (item) { + var item$1 = Curry._1(funarg.enter_signature_item, item); + var vd = item$1.sig_desc; + var sig_desc; + switch (vd.TAG | 0) { + case /* Tsig_value */0 : + sig_desc = { + TAG: /* Tsig_value */0, + _0: map_value_description(vd._0) + }; + break; + case /* Tsig_type */1 : + sig_desc = { + TAG: /* Tsig_type */1, + _0: Stdlib__List.map(map_type_declaration, vd._0) + }; + break; + case /* Tsig_typext */2 : + sig_desc = { + TAG: /* Tsig_typext */2, + _0: map_type_extension(vd._0) + }; + break; + case /* Tsig_exception */3 : + sig_desc = { + TAG: /* Tsig_exception */3, + _0: map_extension_constructor(vd._0) + }; + break; + case /* Tsig_module */4 : + var md = vd._0; + sig_desc = { + TAG: /* Tsig_module */4, + _0: { + md_id: md.md_id, + md_name: md.md_name, + md_type: map_module_type(md.md_type), + md_attributes: md.md_attributes, + md_loc: md.md_loc + } + }; + break; + case /* Tsig_recmodule */5 : + sig_desc = { + TAG: /* Tsig_recmodule */5, + _0: Stdlib__List.map((function (md) { + return { + md_id: md.md_id, + md_name: md.md_name, + md_type: map_module_type(md.md_type), + md_attributes: md.md_attributes, + md_loc: md.md_loc + }; + }), vd._0) + }; + break; + case /* Tsig_modtype */6 : + sig_desc = { + TAG: /* Tsig_modtype */6, + _0: map_module_type_declaration(vd._0) + }; + break; + case /* Tsig_open */7 : + sig_desc = item$1.sig_desc; break; - case /* Tstr_include */12 : + case /* Tsig_include */8 : var incl = vd._0; - str_desc = { - TAG: /* Tstr_include */12, + sig_desc = { + TAG: /* Tsig_include */8, _0: { - incl_mod: map_module_expr(incl.incl_mod), + incl_mod: map_module_type(incl.incl_mod), incl_type: incl.incl_type, incl_loc: incl.incl_loc, incl_attributes: incl.incl_attributes } }; break; - case /* Tstr_attribute */13 : - str_desc = { - TAG: /* Tstr_attribute */13, - _0: vd._0 - }; - break; - - } - return Curry._1(funarg.leave_structure_item, { - str_desc: str_desc, - str_loc: item$1.str_loc, - str_env: item$1.str_env - }); - }; - var map_with_constraint = function (cstr) { - var cstr$1 = Curry._1(funarg.enter_with_constraint, cstr); - var tmp; - switch (cstr$1.TAG | 0) { - case /* Twith_type */0 : - tmp = { - TAG: /* Twith_type */0, - _0: map_type_declaration(cstr$1._0) + case /* Tsig_class */9 : + sig_desc = { + TAG: /* Tsig_class */9, + _0: Stdlib__List.map(map_class_description, vd._0) }; break; - case /* Twith_typesubst */2 : - tmp = { - TAG: /* Twith_typesubst */2, - _0: map_type_declaration(cstr$1._0) + case /* Tsig_class_type */10 : + sig_desc = { + TAG: /* Tsig_class_type */10, + _0: Stdlib__List.map(map_class_type_declaration, vd._0) }; break; - case /* Twith_module */1 : - case /* Twith_modsubst */3 : - tmp = cstr$1; + case /* Tsig_attribute */11 : + sig_desc = vd; break; } - return Curry._1(funarg.leave_with_constraint, tmp); + return Curry._1(funarg.leave_signature_item, { + sig_desc: sig_desc, + sig_env: item$1.sig_env, + sig_loc: item$1.sig_loc + }); }; - var map_signature = function (sg) { - var sg$1 = Curry._1(funarg.enter_signature, sg); - var sig_items = Stdlib__List.map(map_signature_item, sg$1.sig_items); - return Curry._1(funarg.leave_signature, { - sig_items: sig_items, - sig_type: sg$1.sig_type, - sig_final_env: sg$1.sig_final_env + var map_class_signature = function (cs) { + var cs$1 = Curry._1(funarg.enter_class_signature, cs); + var csig_self = map_core_type(cs$1.csig_self); + var csig_fields = Stdlib__List.map(map_class_type_field, cs$1.csig_fields); + return Curry._1(funarg.leave_class_signature, { + csig_self: csig_self, + csig_fields: csig_fields, + csig_type: cs$1.csig_type }); }; - var map_class_field = function (cf) { - var cf$1 = Curry._1(funarg.enter_class_field, cf); - var exp = cf$1.cf_desc; - var cf_desc; - switch (exp.TAG | 0) { - case /* Tcf_inherit */0 : - cf_desc = { - TAG: /* Tcf_inherit */0, - _0: exp._0, - _1: map_class_expr(exp._1), - _2: exp._2, - _3: exp._3, - _4: exp._4 + var map_class_structure = function (cs) { + var cs$1 = Curry._1(funarg.enter_class_structure, cs); + var cstr_self = map_pattern(cs$1.cstr_self); + var cstr_fields = Stdlib__List.map(map_class_field, cs$1.cstr_fields); + return Curry._1(funarg.leave_class_structure, { + cstr_self: cstr_self, + cstr_fields: cstr_fields, + cstr_type: cs$1.cstr_type, + cstr_meths: cs$1.cstr_meths + }); + }; + var map_class_expr = function (cexpr) { + var cexpr$1 = Curry._1(funarg.enter_class_expr, cexpr); + var clstr = cexpr$1.cl_desc; + var cl_desc; + switch (clstr.TAG | 0) { + case /* Tcl_ident */0 : + cl_desc = { + TAG: /* Tcl_ident */0, + _0: clstr._0, + _1: clstr._1, + _2: Stdlib__List.map(map_core_type, clstr._2) }; break; - case /* Tcf_val */1 : - var cty = exp._3; - var ident = exp._2; - var mut = exp._1; - var lab = exp._0; - cf_desc = cty.TAG === /* Tcfk_virtual */0 ? ({ - TAG: /* Tcf_val */1, - _0: lab, - _1: mut, - _2: ident, - _3: { - TAG: /* Tcfk_virtual */0, - _0: map_core_type(cty._0) - }, - _4: exp._4 - }) : ({ - TAG: /* Tcf_val */1, - _0: lab, - _1: mut, - _2: ident, - _3: { - TAG: /* Tcfk_concrete */1, - _0: cty._0, - _1: map_expression(cty._1) - }, - _4: exp._4 - }); + case /* Tcl_structure */1 : + cl_desc = { + TAG: /* Tcl_structure */1, + _0: map_class_structure(clstr._0) + }; break; - case /* Tcf_method */2 : - var cty$1 = exp._2; - var priv = exp._1; - var lab$1 = exp._0; - cf_desc = cty$1.TAG === /* Tcfk_virtual */0 ? ({ - TAG: /* Tcf_method */2, - _0: lab$1, - _1: priv, - _2: { - TAG: /* Tcfk_virtual */0, - _0: map_core_type(cty$1._0) - } - }) : ({ - TAG: /* Tcf_method */2, - _0: lab$1, - _1: priv, - _2: { - TAG: /* Tcfk_concrete */1, - _0: cty$1._0, - _1: map_expression(cty$1._1) - } - }); + case /* Tcl_fun */2 : + cl_desc = { + TAG: /* Tcl_fun */2, + _0: clstr._0, + _1: map_pattern(clstr._1), + _2: Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_expression(param[2]) + ]; + }), clstr._2), + _3: map_class_expr(clstr._3), + _4: clstr._4 + }; break; - case /* Tcf_constraint */3 : - cf_desc = { - TAG: /* Tcf_constraint */3, - _0: map_core_type(exp._0), - _1: map_core_type(exp._1) + case /* Tcl_apply */3 : + cl_desc = { + TAG: /* Tcl_apply */3, + _0: map_class_expr(clstr._0), + _1: Stdlib__List.map((function (param) { + return [ + param[0], + may_map(map_expression, param[1]), + param[2] + ]; + }), clstr._1) }; break; - case /* Tcf_initializer */4 : - cf_desc = { - TAG: /* Tcf_initializer */4, - _0: map_expression(exp._0) + case /* Tcl_let */4 : + var rec_flat = clstr._0; + cl_desc = { + TAG: /* Tcl_let */4, + _0: rec_flat, + _1: Stdlib__List.map(map_binding, clstr._1), + _2: Stdlib__List.map((function (param) { + return [ + param[0], + param[1], + map_expression(param[2]) + ]; + }), clstr._2), + _3: map_class_expr(clstr._3) }; break; - case /* Tcf_attribute */5 : - cf_desc = exp; + case /* Tcl_constraint */5 : + var clty = clstr._1; + var cl = clstr._0; + cl_desc = clty !== undefined ? ({ + TAG: /* Tcl_constraint */5, + _0: map_class_expr(cl), + _1: map_class_type(clty), + _2: clstr._2, + _3: clstr._3, + _4: clstr._4 + }) : ({ + TAG: /* Tcl_constraint */5, + _0: map_class_expr(cl), + _1: undefined, + _2: clstr._2, + _3: clstr._3, + _4: clstr._4 + }); break; } - return Curry._1(funarg.leave_class_field, { - cf_desc: cf_desc, - cf_loc: cf$1.cf_loc, - cf_attributes: cf$1.cf_attributes - }); + return Curry._1(funarg.leave_class_expr, { + cl_desc: cl_desc, + cl_loc: cexpr$1.cl_loc, + cl_type: cexpr$1.cl_type, + cl_env: cexpr$1.cl_env, + cl_attributes: cexpr$1.cl_attributes + }); + }; + var map_exp_extra = function (exp_extra) { + var attrs = exp_extra[2]; + var loc = exp_extra[1]; + var desc = exp_extra[0]; + switch (desc.TAG | 0) { + case /* Texp_constraint */0 : + return [ + { + TAG: /* Texp_constraint */0, + _0: map_core_type(desc._0) + }, + loc, + attrs + ]; + case /* Texp_coerce */1 : + var ct1 = desc._0; + if (ct1 !== undefined) { + return [ + { + TAG: /* Texp_coerce */1, + _0: map_core_type(ct1), + _1: map_core_type(desc._1) + }, + loc, + attrs + ]; + } else { + return [ + { + TAG: /* Texp_coerce */1, + _0: undefined, + _1: map_core_type(desc._1) + }, + loc, + attrs + ]; + } + case /* Texp_poly */3 : + var ct = desc._0; + if (ct !== undefined) { + return [ + { + TAG: /* Texp_poly */3, + _0: map_core_type(ct) + }, + loc, + attrs + ]; + } else { + return exp_extra; + } + case /* Texp_open */2 : + case /* Texp_newtype */4 : + return exp_extra; + + } + }; + var map_constructor_declaration = function (cd) { + return { + cd_id: cd.cd_id, + cd_name: cd.cd_name, + cd_args: Stdlib__List.map(map_core_type, cd.cd_args), + cd_res: may_map(map_core_type, cd.cd_res), + cd_loc: cd.cd_loc, + cd_attributes: cd.cd_attributes + }; }; return { map_structure: map_structure, @@ -33169,6 +33169,116 @@ function unify(env, t1, t2) { } } +function make_rowvar(level, use1, rest1, use2, rest2) { + var set_name = function (ty, name) { + var match = ty.desc; + if (typeof match === "number" || !(match.TAG === /* Tvar */0 && match._0 === undefined)) { + return ; + } else { + log_type(ty); + ty.desc = { + TAG: /* Tvar */0, + _0: name + }; + return ; + } + }; + var match = rest1.desc; + var match$1 = rest2.desc; + var name; + var exit = 0; + if (typeof match === "number" || match.TAG !== /* Tvar */0) { + exit = 1; + } else { + var name1 = match._0; + if (name1 !== undefined) { + var exit$1 = 0; + if (typeof match$1 === "number" || match$1.TAG !== /* Tvar */0) { + exit$1 = 2; + } else { + var name2 = match$1._0; + if (name2 !== undefined) { + name = rest1.level <= rest2.level ? name1 : name2; + } else { + exit$1 = 2; + } + } + if (exit$1 === 2) { + if (use2) { + set_name(rest2, name1); + } + name = name1; + } + + } else { + exit = 1; + } + } + if (exit === 1) { + if (typeof match$1 === "number" || match$1.TAG !== /* Tvar */0) { + name = undefined; + } else { + var name$1 = match$1._0; + if (name$1 !== undefined) { + if (use1) { + set_name(rest2, name$1); + } + name = name$1; + } else { + name = undefined; + } + } + } + if (use1) { + return rest1; + } else if (use2) { + return rest2; + } else { + return newty2(level, { + TAG: /* Tvar */0, + _0: name + }); + } +} + +function unify_kind(k1, k2) { + var k1$1 = field_kind_repr(k1); + var k2$1 = field_kind_repr(k2); + if (k1$1 === k2$1) { + return ; + } + if (typeof k1$1 === "number") { + if (!k1$1) { + if (typeof k2$1 !== "number") { + return set_kind(k2$1._0, k1$1); + } + if (!k2$1) { + return ; + } + + } + + } else { + var r = k1$1._0; + if (typeof k2$1 !== "number") { + return set_kind(r, k2$1); + } + if (!k2$1) { + return set_kind(r, k2$1); + } + + } + throw { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32636, + 37 + ], + Error: new Error() + }; +} + function unify_list(env, tl1, tl2) { if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { throw { @@ -33724,137 +33834,118 @@ function unify_fields(env, ty1, ty2) { }; throw { MEL_EXN_ID: Unify, - _1: { - hd: [ - newty2(current_level.contents, desc), - newty2(current_level.contents, desc$1) - ], - tl: exn._1 - }, - Error: new Error() - }; - } - throw exn; - } - }), match$2[0]); - } - catch (exn){ - log_type(rest1); - rest1.desc = d1; - log_type(rest2); - rest2.desc = d2; - throw exn; - } -} - -function make_rowvar(level, use1, rest1, use2, rest2) { - var set_name = function (ty, name) { - var match = ty.desc; - if (typeof match === "number" || !(match.TAG === /* Tvar */0 && match._0 === undefined)) { - return ; - } else { - log_type(ty); - ty.desc = { - TAG: /* Tvar */0, - _0: name - }; - return ; - } - }; - var match = rest1.desc; - var match$1 = rest2.desc; - var name; - var exit = 0; - if (typeof match === "number" || match.TAG !== /* Tvar */0) { - exit = 1; - } else { - var name1 = match._0; - if (name1 !== undefined) { - var exit$1 = 0; - if (typeof match$1 === "number" || match$1.TAG !== /* Tvar */0) { - exit$1 = 2; - } else { - var name2 = match$1._0; - if (name2 !== undefined) { - name = rest1.level <= rest2.level ? name1 : name2; - } else { - exit$1 = 2; - } - } - if (exit$1 === 2) { - if (use2) { - set_name(rest2, name1); - } - name = name1; - } - - } else { - exit = 1; - } - } - if (exit === 1) { - if (typeof match$1 === "number" || match$1.TAG !== /* Tvar */0) { - name = undefined; - } else { - var name$1 = match$1._0; - if (name$1 !== undefined) { - if (use1) { - set_name(rest2, name$1); - } - name = name$1; - } else { - name = undefined; - } - } + _1: { + hd: [ + newty2(current_level.contents, desc), + newty2(current_level.contents, desc$1) + ], + tl: exn._1 + }, + Error: new Error() + }; + } + throw exn; + } + }), match$2[0]); } - if (use1) { - return rest1; - } else if (use2) { - return rest2; - } else { - return newty2(level, { - TAG: /* Tvar */0, - _0: name - }); + catch (exn){ + log_type(rest1); + rest1.desc = d1; + log_type(rest2); + rest2.desc = d2; + throw exn; } } -function unify_kind(k1, k2) { - var k1$1 = field_kind_repr(k1); - var k2$1 = field_kind_repr(k2); - if (k1$1 === k2$1) { +function unify2(env, t1, t2) { + var expand_both = function (_t1$p$p, _t2$p$p) { + while(true) { + var t2$p$p = _t2$p$p; + var t1$p$p = _t1$p$p; + var t1$p = expand_head_unif(env.contents, t1); + var t2$p = expand_head_unif(env.contents, t2); + if (unify_eq(env.contents, t1$p, t1$p$p) && unify_eq(env.contents, t2$p, t2$p$p)) { + return [ + t1$p, + t2$p + ]; + } + _t2$p$p = t2$p; + _t1$p$p = t1$p; + continue ; + }; + }; + var match = expand_both(t1, t2); + var t2$p = match[1]; + var t1$p = match[0]; + var lv = t1$p.level < t2$p.level ? t1$p.level : t2$p.level; + update_level(env.contents, lv, t2); + update_level(env.contents, lv, t1); + if (unify_eq(env.contents, t1$p, t2$p)) { return ; } - if (typeof k1$1 === "number") { - if (!k1$1) { - if (typeof k2$1 !== "number") { - return set_kind(k2$1._0, k1$1); - } - if (!k2$1) { - return ; + var t1$1 = repr(t1); + var t2$1 = repr(t2); + if (trace_gadt_instances.contents) { + var ilevel = function (t) { + var lv = gadt_instance_level(env.contents, t); + if (lv !== undefined) { + return lv; + } else { + return 0; } - + }; + var lv1 = ilevel(t1$1); + var lv2 = ilevel(t2$1); + if (lv1 > lv2) { + add_gadt_instance_chain(env.contents, lv1, t2$1); + } else if (lv2 > lv1) { + add_gadt_instance_chain(env.contents, lv2, t1$1); } + } + var match$1; + if (principal.contents && (find_lowest_level(t1$p) < lv || find_lowest_level(t2$p) < lv)) { + var match$2 = t1$1.desc; + var tmp; + tmp = typeof match$2 === "number" || !(match$2.TAG === /* Tconstr */3 && !match$2._1) ? t1$1 : t1$p; + var match$3 = t2$1.desc; + var tmp$1; + tmp$1 = typeof match$3 === "number" || !(match$3.TAG === /* Tconstr */3 && !match$3._1) ? t2$1 : t2$p; + match$1 = [ + tmp, + tmp$1 + ]; } else { - var r = k1$1._0; - if (typeof k2$1 !== "number") { - return set_kind(r, k2$1); - } - if (!k2$1) { - return set_kind(r, k2$1); + match$1 = [ + t1$1, + t2$1 + ]; + } + var t2$2 = match$1[1]; + var t1$2 = match$1[0]; + if (unify_eq(env.contents, t1$2, t1$p) || !unify_eq(env.contents, t2$2, t2$p)) { + return unify3(env, t1$2, t1$p, t2$2, t2$p); + } + try { + return unify3(env, t2$2, t2$p, t1$2, t1$p); + } + catch (raw_exn){ + var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + if (exn.MEL_EXN_ID === Unify) { + throw { + MEL_EXN_ID: Unify, + _1: Stdlib__List.map((function (param) { + return [ + param[1], + param[0] + ]; + }), exn._1), + Error: new Error() + }; } - + throw exn; } - throw { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32636, - 37 - ], - Error: new Error() - }; } function unify3(env, t1, t1$p, t2, t2$p) { @@ -34469,128 +34560,37 @@ function unify3(env, t1, t1$p, t2, t2$p) { } if (!create_recursion) { - return ; - } - var match$8 = t2.desc; - if (typeof match$8 === "number") { - return ; - } - if (match$8.TAG !== /* Tconstr */3) { - return ; - } - forget_abbrev(match$8._2, match$8._0); - var t2$p$p = expand_head_unif(env.contents, t2); - if (!closed_parameterized_type(match$8._1, t2$p$p)) { - return link_type(repr(t2), repr(t2$p)); - } else { - return ; - } - } - catch (raw_exn$3){ - var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); - if (exn$3.MEL_EXN_ID === Unify) { - t1$p.desc = d1; - throw { - MEL_EXN_ID: Unify, - _1: exn$3._1, - Error: new Error() - }; - } - throw exn$3; - } - } - -} - -function unify2(env, t1, t2) { - var expand_both = function (_t1$p$p, _t2$p$p) { - while(true) { - var t2$p$p = _t2$p$p; - var t1$p$p = _t1$p$p; - var t1$p = expand_head_unif(env.contents, t1); - var t2$p = expand_head_unif(env.contents, t2); - if (unify_eq(env.contents, t1$p, t1$p$p) && unify_eq(env.contents, t2$p, t2$p$p)) { - return [ - t1$p, - t2$p - ]; - } - _t2$p$p = t2$p; - _t1$p$p = t1$p; - continue ; - }; - }; - var match = expand_both(t1, t2); - var t2$p = match[1]; - var t1$p = match[0]; - var lv = t1$p.level < t2$p.level ? t1$p.level : t2$p.level; - update_level(env.contents, lv, t2); - update_level(env.contents, lv, t1); - if (unify_eq(env.contents, t1$p, t2$p)) { - return ; - } - var t1$1 = repr(t1); - var t2$1 = repr(t2); - if (trace_gadt_instances.contents) { - var ilevel = function (t) { - var lv = gadt_instance_level(env.contents, t); - if (lv !== undefined) { - return lv; - } else { - return 0; - } - }; - var lv1 = ilevel(t1$1); - var lv2 = ilevel(t2$1); - if (lv1 > lv2) { - add_gadt_instance_chain(env.contents, lv1, t2$1); - } else if (lv2 > lv1) { - add_gadt_instance_chain(env.contents, lv2, t1$1); - } - - } - var match$1; - if (principal.contents && (find_lowest_level(t1$p) < lv || find_lowest_level(t2$p) < lv)) { - var match$2 = t1$1.desc; - var tmp; - tmp = typeof match$2 === "number" || !(match$2.TAG === /* Tconstr */3 && !match$2._1) ? t1$1 : t1$p; - var match$3 = t2$1.desc; - var tmp$1; - tmp$1 = typeof match$3 === "number" || !(match$3.TAG === /* Tconstr */3 && !match$3._1) ? t2$1 : t2$p; - match$1 = [ - tmp, - tmp$1 - ]; - } else { - match$1 = [ - t1$1, - t2$1 - ]; - } - var t2$2 = match$1[1]; - var t1$2 = match$1[0]; - if (unify_eq(env.contents, t1$2, t1$p) || !unify_eq(env.contents, t2$2, t2$p)) { - return unify3(env, t1$2, t1$p, t2$2, t2$p); - } - try { - return unify3(env, t2$2, t2$p, t1$2, t1$p); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.MEL_EXN_ID === Unify) { - throw { - MEL_EXN_ID: Unify, - _1: Stdlib__List.map((function (param) { - return [ - param[1], - param[0] - ]; - }), exn._1), - Error: new Error() - }; + return ; + } + var match$8 = t2.desc; + if (typeof match$8 === "number") { + return ; + } + if (match$8.TAG !== /* Tconstr */3) { + return ; + } + forget_abbrev(match$8._2, match$8._0); + var t2$p$p = expand_head_unif(env.contents, t2); + if (!closed_parameterized_type(match$8._1, t2$p$p)) { + return link_type(repr(t2), repr(t2$p)); + } else { + return ; + } + } + catch (raw_exn$3){ + var exn$3 = Caml_js_exceptions.internalToOCamlException(raw_exn$3); + if (exn$3.MEL_EXN_ID === Unify) { + t1$p.desc = d1; + throw { + MEL_EXN_ID: Unify, + _1: exn$3._1, + Error: new Error() + }; + } + throw exn$3; } - throw exn; } + } function unify$1(env, ty1, ty2) { @@ -41667,6 +41667,111 @@ function print_out_functor(ppf, m) { }), print_out_module_type, m); } +function print_out_signature(ppf, param) { + if (!param) { + return ; + } + var item = param.hd; + if (!param.tl) { + return Curry._2(out_sig_item.contents, ppf, item); + } + if (item.TAG === /* Osig_typext */2 && !item._1) { + var ext = item._0; + var gather_extensions = function (_acc, _items) { + while(true) { + var items = _items; + var acc = _acc; + if (!items) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + var match = items.hd; + if (match.TAG !== /* Osig_typext */2) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + if (match._1 !== 1) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + var ext = match._0; + _items = items.tl; + _acc = { + hd: [ + ext.oext_name, + ext.oext_args, + ext.oext_ret_type + ], + tl: acc + }; + continue ; + }; + }; + var match = gather_extensions({ + hd: [ + ext.oext_name, + ext.oext_args, + ext.oext_ret_type + ], + tl: /* [] */0 + }, param.tl); + var te_otyext_name = ext.oext_type_name; + var te_otyext_params = ext.oext_type_params; + var te_otyext_constructors = match[0]; + var te_otyext_private = ext.oext_private; + var te = { + otyext_name: te_otyext_name, + otyext_params: te_otyext_params, + otyext_constructors: te_otyext_constructors, + otyext_private: te_otyext_private + }; + return Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ + _0: { + TAG: /* Alpha */15, + _0: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@ ", + _1: 1, + _2: 0 + }, + _1: { + TAG: /* Alpha */15, + _0: /* End_of_format */0 + } + } + }, + _1: "%a@ %a" + }), out_type_extension.contents, te, print_out_signature, match[1]); + } + Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ + _0: { + TAG: /* Alpha */15, + _0: { + TAG: /* Formatting_lit */17, + _0: { + TAG: /* Break */0, + _0: "@ ", + _1: 1, + _2: 0 + }, + _1: { + TAG: /* Alpha */15, + _0: /* End_of_format */0 + } + } + }, + _1: "%a@ %a" + }), out_sig_item.contents, item, print_out_signature, param.tl); +} + function print_out_constr(ppf, param) { var ret_type_opt = param[2]; var tyl = param[1]; @@ -41871,111 +41976,6 @@ function print_out_label(ppf, param) { }), param[1] ? "mutable " : "", param[0], out_type.contents, param[2]); } -function print_out_signature(ppf, param) { - if (!param) { - return ; - } - var item = param.hd; - if (!param.tl) { - return Curry._2(out_sig_item.contents, ppf, item); - } - if (item.TAG === /* Osig_typext */2 && !item._1) { - var ext = item._0; - var gather_extensions = function (_acc, _items) { - while(true) { - var items = _items; - var acc = _acc; - if (!items) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - var match = items.hd; - if (match.TAG !== /* Osig_typext */2) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - if (match._1 !== 1) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - var ext = match._0; - _items = items.tl; - _acc = { - hd: [ - ext.oext_name, - ext.oext_args, - ext.oext_ret_type - ], - tl: acc - }; - continue ; - }; - }; - var match = gather_extensions({ - hd: [ - ext.oext_name, - ext.oext_args, - ext.oext_ret_type - ], - tl: /* [] */0 - }, param.tl); - var te_otyext_name = ext.oext_type_name; - var te_otyext_params = ext.oext_type_params; - var te_otyext_constructors = match[0]; - var te_otyext_private = ext.oext_private; - var te = { - otyext_name: te_otyext_name, - otyext_params: te_otyext_params, - otyext_constructors: te_otyext_constructors, - otyext_private: te_otyext_private - }; - return Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ - _0: { - TAG: /* Alpha */15, - _0: { - TAG: /* Formatting_lit */17, - _0: { - TAG: /* Break */0, - _0: "@ ", - _1: 1, - _2: 0 - }, - _1: { - TAG: /* Alpha */15, - _0: /* End_of_format */0 - } - } - }, - _1: "%a@ %a" - }), out_type_extension.contents, te, print_out_signature, match[1]); - } - Curry._4(Stdlib__Format.fprintf(ppf)(/* Format */{ - _0: { - TAG: /* Alpha */15, - _0: { - TAG: /* Formatting_lit */17, - _0: { - TAG: /* Break */0, - _0: "@ ", - _1: 1, - _2: 0 - }, - _1: { - TAG: /* Alpha */15, - _0: /* End_of_format */0 - } - } - }, - _1: "%a@ %a" - }), out_sig_item.contents, item, print_out_signature, param.tl); -} - function print_out_module_type(ppf, t) { if (typeof t === "number") { return ; @@ -46547,14 +46547,6 @@ function filter_params(tyl) { }), /* [] */0, tyl)); } -function tree_of_label(l) { - return [ - l.ld_id.name, - l.ld_mutable === /* Mutable */1, - tree_of_typexp(false, l.ld_type) - ]; -} - function tree_of_constructor(cd) { var name = cd.cd_id.name; var res = cd.cd_res; @@ -46581,6 +46573,14 @@ function tree_of_constructor(cd) { ]; } +function tree_of_label(l) { + return [ + l.ld_id.name, + l.ld_mutable === /* Mutable */1, + tree_of_typexp(false, l.ld_type) + ]; +} + function tree_of_type_decl(id, decl) { reset(undefined); var params = filter_params(decl.type_params); diff --git a/ppx/ast_core_type_class_type.ml b/ppx/ast_core_type_class_type.ml index 568630c47e..d23b0815bf 100644 --- a/ppx/ast_core_type_class_type.ml +++ b/ppx/ast_core_type_class_type.ml @@ -49,7 +49,7 @@ let process_getter_setter ~not_getter_setter | false, false -> ty | true, false -> lift Ast_literal.js_null | false, true -> lift Ast_literal.js_undefined - | true, true -> lift Ast_literal.js_null_undefined + | true, true -> lift Ast_literal.js_nullable in get ty name pctf_attributes :: acc in diff --git a/ppx/ast_literal.ml b/ppx/ast_literal.ml index 3e5c709e1b..057672cb2f 100644 --- a/ppx/ast_literal.ml +++ b/ppx/ast_literal.ml @@ -33,7 +33,7 @@ let js_oo : t = Ldot (Ldot (js, "Private"), "Js_OO") let js_meth : t = Ldot (js_oo, "Meth") let js_meth_callback : t = Ldot (js_oo, "Callback") let js_null : t = Ldot (js, "null") -let js_null_undefined : t = Ldot (js, "null_undefined") +let js_nullable : t = Ldot (js, "nullable") let js_obj : t = Ldot (js, "t") let js_re_id : t = Ldot (Ldot (js, "Re"), "t") let js_undefined : t = Ldot (js, "undefined") diff --git a/ppx/ast_literal.mli b/ppx/ast_literal.mli index 16db03e2fd..913fc0d30f 100644 --- a/ppx/ast_literal.mli +++ b/ppx/ast_literal.mli @@ -31,7 +31,7 @@ val js_internal_full_apply : t val js_meth : t val js_meth_callback : t val js_null : t -val js_null_undefined : t +val js_nullable : t val js_obj : t val js_oo : t val js_re_id : t