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 4df4fa9b1..62021010c 100644 --- a/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/dist/jscomp/test/flow_parser_reg_test.js @@ -15632,42 +15632,6 @@ function parse(content, options) { } } }; - const variable_declarator = function (param) { - const declarator = param[1]; - return node("VariableDeclarator", param[0], [ - [ - "id", - pattern(declarator.id) - ], - [ - "init", - option(expression, declarator.init) - ] - ]); - }; - const identifier = function (param) { - const id = param[1]; - return node("Identifier", param[0], [ - [ - "name", - string(id.name) - ], - [ - "typeAnnotation", - option(type_annotation, id.typeAnnotation) - ], - [ - "optional", - bool(id.optional) - ] - ]); - }; - const block = function (param) { - return node("BlockStatement", param[0], [[ - "body", - array_of_list(statement, param[1].body) - ]]); - }; const expression = function (param) { const arr = param[1]; const loc = param[0]; @@ -16174,6 +16138,12 @@ function parse(content, options) { } }; + const block = function (param) { + return node("BlockStatement", param[0], [[ + "body", + array_of_list(statement, param[1].body) + ]]); + }; const pattern = function (param) { const obj = param[1]; const loc = param[0]; @@ -16223,109 +16193,122 @@ function parse(content, options) { } }; - const object_type_call_property = function (param) { - const callProperty = param[1]; - return node("ObjectTypeCallProperty", param[0], [ - [ - "value", - function_type(callProperty.value) - ], - [ - "static", - bool(callProperty.static) - ] - ]); - }; - const object_type_property = function (param) { - const prop = param[1]; - const lit = prop.key; - let 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 new Caml_js_exceptions.MelangeError("Failure", { - MEL_EXN_ID: "Failure", - _1: "There should not be computed object type property keys" - }); - + const object_pattern_property = function (param) { + if (param.TAG === /* Property */0) { + const match = param._0; + const prop = match[1]; + const lit = prop.key; + let 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("PropertyPattern", match[0], [ + [ + "key", + match$1[0] + ], + [ + "pattern", + pattern(prop.pattern) + ], + [ + "computed", + bool(match$1[1]) + ], + [ + "shorthand", + bool(prop.shorthand) + ] + ]); } - return node("ObjectTypeProperty", param[0], [ + const match$2 = param._0; + return node("SpreadPropertyPattern", match$2[0], [[ + "argument", + pattern(match$2[1].argument) + ]]); + }; + const identifier = function (param) { + const id = param[1]; + return node("Identifier", param[0], [ [ - "key", - key + "name", + string(id.name) ], [ - "value", - _type(prop.value) + "typeAnnotation", + option(type_annotation, id.typeAnnotation) ], [ "optional", - bool(prop.optional) - ], - [ - "static", - bool(prop.static) + bool(id.optional) ] ]); }; - const object_type_indexer = function (param) { - const indexer = param[1]; - return node("ObjectTypeIndexer", param[0], [ + const type_annotation = function (param) { + return node("TypeAnnotation", param[0], [[ + "typeAnnotation", + _type(param[1]) + ]]); + }; + const array_pattern_element = function (p) { + if (p.TAG === /* Element */0) { + return pattern(p._0); + } + const match = p._0; + return node("SpreadElementPattern", match[0], [[ + "argument", + pattern(match[1].argument) + ]]); + }; + const export_specifier = function (param) { + const specifier = param[1]; + return node("ExportSpecifier", param[0], [ [ "id", - identifier(indexer.id) - ], - [ - "key", - _type(indexer.key) - ], - [ - "value", - _type(indexer.value) + identifier(specifier.id) ], [ - "static", - bool(indexer.static) + "name", + option(identifier, specifier.name) ] ]); }; - const interface_extends = function (param) { - const g = param[1]; - const id = g.id; - let id$1; - id$1 = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); - return node("InterfaceExtends", param[0], [ + const class_implements = function (param) { + const $$implements = param[1]; + return node("ClassImplements", param[0], [ [ "id", - id$1 + identifier($$implements.id) ], [ "typeParameters", - option(type_parameter_instantiation, g.typeParameters) + option(type_parameter_instantiation, $$implements.typeParameters) ] ]); }; - const object_type = function (param) { - const 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) - ] - ]); + const class_body = function (param) { + return node("ClassBody", param[0], [[ + "body", + array_of_list(class_element, param[1].body) + ]]); }; const type_parameter_declaration = function (param) { return node("TypeParameterDeclaration", param[0], [[ @@ -16333,244 +16316,20 @@ function parse(content, options) { array_of_list(type_param, param[1].params) ]]); }; - const literal = function (param) { - const lit = param[1]; - const raw = lit.raw; - const value = lit.value; + const type_parameter_instantiation = function (param) { + return node("TypeParameterInstantiation", param[0], [[ + "params", + array_of_list(_type, param[1].params) + ]]); + }; + const statement = function (param) { + const b = param[1]; const loc = param[0]; - let 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 : - const match = value._0; - value_ = regexp$1(loc, match.pattern, match.flags); - break; - - } - } - let props; - let exit = 0; - if (typeof value === "number" || value.TAG !== /* RegExp */3) { - exit = 1; - } else { - const match$1 = value._0; - const 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); - }; - const type_parameter_instantiation = function (param) { - return node("TypeParameterInstantiation", param[0], [[ - "params", - array_of_list(_type, param[1].params) - ]]); - }; - const generic_type_qualified_identifier = function (param) { - const q = param[1]; - const id = q.qualification; - let 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) - ] - ]); - }; - const function_type = function (param) { - const 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) - ] - ]); - }; - const jsx_member_expression = function (param) { - const member_expression = param[1]; - const id = member_expression._object; - let _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) - ] - ]); - }; - const jsx_identifier = function (param) { - return node("JSXIdentifier", param[0], [[ - "name", - string(param[1].name) - ]]); - }; - const declare_variable = function (param) { - return node("DeclareVariable", param[0], [[ - "id", - identifier(param[1].id) - ]]); - }; - const let_assignment = function (assignment) { - return obj([ - [ - "id", - pattern(assignment.id) - ], - [ - "init", - option(expression, assignment.init) - ] - ]); - }; - const $$catch = function (param) { - const c = param[1]; - return node("CatchClause", param[0], [ - [ - "param", - pattern(c.param) - ], - [ - "guard", - option(expression, c.guard) - ], - [ - "body", - block(c.body) - ] - ]); - }; - const type_alias = function (param) { - const alias = param[1]; - return node("TypeAlias", param[0], [ - [ - "id", - identifier(alias.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, alias.typeParameters) - ], - [ - "right", - _type(alias.right) - ] - ]); - }; - const declare_class = function (param) { - const d = param[1]; - return node("DeclareClass", param[0], [ - [ - "id", - identifier(d.id) - ], - [ - "typeParameters", - option(type_parameter_declaration, d.typeParameters) - ], - [ - "body", - object_type(d.body) - ], - [ - "extends", - array_of_list(interface_extends, d.extends) - ] - ]); - }; - const interface_declaration = function (param) { - const 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) - ] - ]); - }; - const statement = function (param) { - const b = param[1]; - const loc = param[0]; - if (typeof b === "number") { - if (b === /* Empty */0) { - return node("EmptyStatement", loc, []); - } else { - return node("DebuggerStatement", loc, []); + if (typeof b === "number") { + if (b === /* Empty */0) { + return node("EmptyStatement", loc, []); + } else { + return node("DebuggerStatement", loc, []); } } switch (b.TAG | 0) { @@ -17083,190 +16842,228 @@ function parse(content, options) { } }; - const variable_declaration = function (param) { - const $$var = param[1]; - const match = $$var.kind; - let kind; - switch (match) { - case /* Var */0 : - kind = "var"; - break; - case /* Let */1 : - kind = "let"; - break; - case /* Const */2 : - kind = "const"; - break; - - } - return node("VariableDeclaration", param[0], [ + const generic_type_qualified_identifier = function (param) { + const q = param[1]; + const id = q.qualification; + let qualification; + qualification = id.TAG === /* Unqualified */0 ? identifier(id._0) : generic_type_qualified_identifier(id._0); + return node("QualifiedTypeIdentifier", param[0], [ [ - "declarations", - array_of_list(variable_declarator, $$var.declarations) + "qualification", + qualification ], [ - "kind", - string(kind) + "id", + identifier(q.id) ] ]); }; - const export_specifiers = function (param) { - if (param !== undefined) { - if (param.TAG === /* ExportSpecifiers */0) { - return array_of_list(export_specifier, param._0); - } else { - return array([node("ExportBatchSpecifier", param._0, [[ - "name", - option(identifier, param._1) - ]])]); - } + const literal = function (param) { + const lit = param[1]; + const raw = lit.raw; + const value = lit.value; + const loc = param[0]; + let value_; + if (typeof value === "number") { + value_ = $$null; } else { - return array([]); - } - }; - const declare_function = function (param) { - return node("DeclareFunction", param[0], [[ - "id", - identifier(param[1].id) - ]]); + 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 : + const match = value._0; + value_ = regexp$1(loc, match.pattern, match.flags); + break; + + } + } + let props; + let exit = 0; + if (typeof value === "number" || value.TAG !== /* RegExp */3) { + exit = 1; + } else { + const match$1 = value._0; + const 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); }; - const type_annotation = function (param) { - return node("TypeAnnotation", param[0], [[ - "typeAnnotation", - _type(param[1]) - ]]); + const 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 + ]); + } }; - const $$case = function (param) { - const c = param[1]; - return node("SwitchCase", param[0], [ + const jsx_namespaced_name = function (param) { + const namespaced_name = param[1]; + return node("JSXNamespacedName", param[0], [ [ - "test", - option(expression, c.test) + "namespace", + jsx_identifier(namespaced_name.namespace) ], [ - "consequent", - array_of_list(statement, c.consequent) + "name", + jsx_identifier(namespaced_name.name) ] ]); }; - const comment = function (param) { - const c = param[1]; - let match; - match = c.TAG === /* Block */0 ? [ - "Block", - c._0 - ] : [ - "Line", - c._0 - ]; - return node(match[0], param[0], [[ - "value", - string(match[1]) + const jsx_identifier = function (param) { + return node("JSXIdentifier", param[0], [[ + "name", + string(param[1].name) ]]); }; - const template_element = function (param) { - const element = param[1]; - const value = obj([ - [ - "raw", - string(element.value.raw) - ], - [ - "cooked", - string(element.value.cooked) - ] - ]); - return node("TemplateElement", param[0], [ - [ - "value", - value - ], - [ - "tail", - bool(element.tail) - ] - ]); - }; - const function_expression = function (param) { - const _function = param[1]; - const b = _function.body; - let body; - body = b.TAG === /* BodyBlock */0 ? block(b._0) : expression(b._0); - return node("FunctionExpression", param[0], [ - [ - "id", - option(identifier, _function.id) - ], + const function_type = function (param) { + const fn = param[1]; + return node("FunctionTypeAnnotation", param[0], [ [ "params", - array_of_list(pattern, _function.params) + array_of_list(function_type_param, fn.params) ], [ - "defaults", - array_of_list((function (param) { - return option(expression, param); - }), _function.defaults) + "returnType", + _type(fn.returnType) ], [ "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) + option(function_type_param, fn.rest) ], [ "typeParameters", - option(type_parameter_declaration, _function.typeParameters) + option(type_parameter_declaration, fn.typeParameters) ] ]); }; - const template_literal = function (param) { - const value = param[1]; - return node("TemplateLiteral", param[0], [ + const function_type_param = function (param) { + const param$1 = param[1]; + return node("FunctionTypeParam", param[0], [ [ - "quasis", - array_of_list(template_element, value.quasis) + "name", + identifier(param$1.name) ], [ - "expressions", - array_of_list(expression, value.expressions) + "typeAnnotation", + _type(param$1.typeAnnotation) + ], + [ + "optional", + bool(param$1.optional) ] ]); }; - const comprehension_block = function (param) { - const b = param[1]; - return node("ComprehensionBlock", param[0], [ + const jsx_child = function (param) { + const element = param[1]; + const 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 : + let param$1 = [ + loc, + element._0 + ]; + const text = param$1[1]; + return node("JSXText", param$1[0], [ + [ + "value", + string(text.value) + ], + [ + "raw", + string(text.raw) + ] + ]); + + } + }; + const jsx_closing = function (param) { + return node("JSXClosingElement", param[0], [[ + "name", + jsx_name(param[1].name) + ]]); + }; + const jsx_opening = function (param) { + const opening = param[1]; + return node("JSXOpeningElement", param[0], [ [ - "left", - pattern(b.left) + "name", + jsx_name(opening.name) ], [ - "right", - expression(b.right) + "attributes", + array_of_list(jsx_opening_attribute, opening.attributes) ], [ - "each", - bool(b.each) + "selfClosing", + bool(opening.selfClosing) ] ]); }; + const jsx_expression_container = function (param) { + const expr = param[1].expression; + let expression$1; + expression$1 = expr.TAG === /* Expression */0 ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); + return node("JSXExpressionContainer", param[0], [[ + "expression", + expression$1 + ]]); + }; const jsx_element = function (param) { const element = param[1]; return node("JSXElement", param[0], [ @@ -17284,16 +17081,6 @@ function parse(content, options) { ] ]); }; - const expression_or_spread = function (expr) { - if (expr.TAG === /* Expression */0) { - return expression(expr._0); - } - const match = expr._0; - return node("SpreadElement", match[0], [[ - "argument", - expression(match[1].argument) - ]]); - }; const object_property = function (param) { if (param.TAG === /* Property */0) { const match = param._0; @@ -17368,90 +17155,179 @@ function parse(content, options) { expression(match$3[1].argument) ]]); }; - const object_pattern_property = function (param) { - if (param.TAG === /* Property */0) { - const match = param._0; - const prop = match[1]; - const lit = prop.key; - let 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("PropertyPattern", match[0], [ - [ - "key", - match$1[0] - ], - [ - "pattern", - pattern(prop.pattern) - ], - [ - "computed", - bool(match$1[1]) - ], - [ - "shorthand", - bool(prop.shorthand) - ] - ]); + const template_literal = function (param) { + const value = param[1]; + return node("TemplateLiteral", param[0], [ + [ + "quasis", + array_of_list(template_element, value.quasis) + ], + [ + "expressions", + array_of_list(expression, value.expressions) + ] + ]); + }; + const expression_or_spread = function (expr) { + if (expr.TAG === /* Expression */0) { + return expression(expr._0); } - const match$2 = param._0; - return node("SpreadPropertyPattern", match$2[0], [[ + const match = expr._0; + return node("SpreadElement", match[0], [[ "argument", - pattern(match$2[1].argument) + expression(match[1].argument) ]]); }; - const array_pattern_element = function (p) { - if (p.TAG === /* Element */0) { - return pattern(p._0); - } - const match = p._0; - return node("SpreadElementPattern", match[0], [[ - "argument", - pattern(match[1].argument) - ]]); + const function_expression = function (param) { + const _function = param[1]; + const b = _function.body; + let 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) + ] + ]); + }; + const let_assignment = function (assignment) { + return obj([ + [ + "id", + pattern(assignment.id) + ], + [ + "init", + option(expression, assignment.init) + ] + ]); }; - const jsx_expression_container = function (param) { - const expr = param[1].expression; - let expression$1; - expression$1 = expr.TAG === /* Expression */0 ? expression(expr._0) : node("JSXEmptyExpression", expr._0, []); - return node("JSXExpressionContainer", param[0], [[ - "expression", - expression$1 - ]]); + const comprehension_block = function (param) { + const b = param[1]; + return node("ComprehensionBlock", param[0], [ + [ + "left", + pattern(b.left) + ], + [ + "right", + expression(b.right) + ], + [ + "each", + bool(b.each) + ] + ]); }; - const export_specifier = function (param) { - const specifier = param[1]; - return node("ExportSpecifier", param[0], [ + const variable_declarator = function (param) { + const declarator = param[1]; + return node("VariableDeclarator", param[0], [ [ "id", - identifier(specifier.id) + pattern(declarator.id) ], [ - "name", - option(identifier, specifier.name) + "init", + option(expression, declarator.init) ] ]); }; + const object_type = function (param) { + const 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) + ] + ]); + }; + const interface_extends = function (param) { + const g = param[1]; + const id = g.id; + let 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) + ] + ]); + }; + const jsx_opening_attribute = function (attribute) { + if (attribute.TAG === /* Attribute */0) { + let param = attribute._0; + const attribute$1 = param[1]; + const id = attribute$1.name; + let name; + name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); + return node("JSXAttribute", param[0], [ + [ + "name", + name + ], + [ + "value", + option(jsx_attribute_value, attribute$1.value) + ] + ]); + } else { + let param$1 = attribute._0; + return node("JSXSpreadAttribute", param$1[0], [[ + "argument", + expression(param$1[1].argument) + ]]); + } + }; const jsx_name = function (id) { switch (id.TAG | 0) { case /* Identifier */0 : @@ -17463,177 +17339,148 @@ function parse(content, options) { } }; - const jsx_namespaced_name = function (param) { - const namespaced_name = param[1]; - return node("JSXNamespacedName", param[0], [ + const export_specifiers = function (param) { + if (param !== undefined) { + if (param.TAG === /* ExportSpecifiers */0) { + return array_of_list(export_specifier, param._0); + } else { + return array([node("ExportBatchSpecifier", param._0, [[ + "name", + option(identifier, param._1) + ]])]); + } + } else { + return array([]); + } + }; + const $$case = function (param) { + const c = param[1]; + return node("SwitchCase", param[0], [ [ - "namespace", - jsx_identifier(namespaced_name.namespace) + "test", + option(expression, c.test) ], [ - "name", - jsx_identifier(namespaced_name.name) + "consequent", + array_of_list(statement, c.consequent) ] ]); }; - const jsx_child = function (param) { - const element = param[1]; - const 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 : - let param$1 = [ - loc, - element._0 - ]; - const text = param$1[1]; - return node("JSXText", param$1[0], [ - [ - "value", - string(text.value) - ], - [ - "raw", - string(text.raw) - ] - ]); - - } - }; - const jsx_opening = function (param) { - const opening = param[1]; - return node("JSXOpeningElement", param[0], [ + const $$catch = function (param) { + const c = param[1]; + return node("CatchClause", param[0], [ [ - "name", - jsx_name(opening.name) + "param", + pattern(c.param) ], [ - "attributes", - array_of_list(jsx_opening_attribute, opening.attributes) + "guard", + option(expression, c.guard) ], [ - "selfClosing", - bool(opening.selfClosing) + "body", + block(c.body) ] ]); }; - const jsx_closing = function (param) { - return node("JSXClosingElement", param[0], [[ - "name", - jsx_name(param[1].name) + const declare_variable = function (param) { + return node("DeclareVariable", param[0], [[ + "id", + identifier(param[1].id) ]]); }; - const 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 - ]); - } - }; - const function_type_param = function (param) { - const param$1 = param[1]; - return node("FunctionTypeParam", param[0], [ + const interface_declaration = function (param) { + const i = param[1]; + return node("InterfaceDeclaration", param[0], [ [ - "name", - identifier(param$1.name) + "id", + identifier(i.id) + ], + [ + "typeParameters", + option(type_parameter_declaration, i.typeParameters) + ], + [ + "body", + object_type(i.body) + ], + [ + "extends", + array_of_list(interface_extends, i.extends) + ] + ]); + }; + const declare_function = function (param) { + return node("DeclareFunction", param[0], [[ + "id", + identifier(param[1].id) + ]]); + }; + const type_alias = function (param) { + const alias = param[1]; + return node("TypeAlias", param[0], [ + [ + "id", + identifier(alias.id) ], [ - "typeAnnotation", - _type(param$1.typeAnnotation) + "typeParameters", + option(type_parameter_declaration, alias.typeParameters) ], [ - "optional", - bool(param$1.optional) + "right", + _type(alias.right) ] ]); }; - const type_param = function (param) { - const tp = param[1]; - const 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) - ], + const variable_declaration = function (param) { + const $$var = param[1]; + const match = $$var.kind; + let kind; + switch (match) { + case /* Var */0 : + kind = "var"; + break; + case /* Let */1 : + kind = "let"; + break; + case /* Const */2 : + kind = "const"; + break; + + } + return node("VariableDeclaration", param[0], [ [ - "variance", - option(variance, tp.variance) + "declarations", + array_of_list(variable_declarator, $$var.declarations) ], [ - "default", - option(_type, tp.default) + "kind", + string(kind) ] ]); }; - const class_implements = function (param) { - const $$implements = param[1]; - return node("ClassImplements", param[0], [ + const declare_class = function (param) { + const d = param[1]; + return node("DeclareClass", param[0], [ [ "id", - identifier($$implements.id) + identifier(d.id) ], [ "typeParameters", - option(type_parameter_instantiation, $$implements.typeParameters) + option(type_parameter_declaration, d.typeParameters) + ], + [ + "body", + object_type(d.body) + ], + [ + "extends", + array_of_list(interface_extends, d.extends) ] ]); }; - const class_body = function (param) { - return node("ClassBody", param[0], [[ - "body", - array_of_list(class_element, param[1].body) - ]]); - }; - const jsx_opening_attribute = function (attribute) { - if (attribute.TAG === /* Attribute */0) { - let param = attribute._0; - const attribute$1 = param[1]; - const id = attribute$1.name; - let name; - name = id.TAG === /* Identifier */0 ? jsx_identifier(id._0) : jsx_namespaced_name(id._0); - return node("JSXAttribute", param[0], [ - [ - "name", - name - ], - [ - "value", - option(jsx_attribute_value, attribute$1.value) - ] - ]); - } else { - let param$1 = attribute._0; - return node("JSXSpreadAttribute", param$1[0], [[ - "argument", - expression(param$1[1].argument) - ]]); - } - }; const class_element = function (m) { if (m.TAG === /* Method */0) { let param = m._0; @@ -17753,6 +17600,159 @@ function parse(content, options) { ]); } }; + const jsx_member_expression = function (param) { + const member_expression = param[1]; + const id = member_expression._object; + let _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) + ] + ]); + }; + const template_element = function (param) { + const element = param[1]; + const value = obj([ + [ + "raw", + string(element.value.raw) + ], + [ + "cooked", + string(element.value.cooked) + ] + ]); + return node("TemplateElement", param[0], [ + [ + "value", + value + ], + [ + "tail", + bool(element.tail) + ] + ]); + }; + const object_type_call_property = function (param) { + const callProperty = param[1]; + return node("ObjectTypeCallProperty", param[0], [ + [ + "value", + function_type(callProperty.value) + ], + [ + "static", + bool(callProperty.static) + ] + ]); + }; + const object_type_indexer = function (param) { + const indexer = param[1]; + return node("ObjectTypeIndexer", param[0], [ + [ + "id", + identifier(indexer.id) + ], + [ + "key", + _type(indexer.key) + ], + [ + "value", + _type(indexer.value) + ], + [ + "static", + bool(indexer.static) + ] + ]); + }; + const object_type_property = function (param) { + const prop = param[1]; + const lit = prop.key; + let 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 new Caml_js_exceptions.MelangeError("Failure", { + MEL_EXN_ID: "Failure", + _1: "There should not be computed object type property keys" + }); + + } + return node("ObjectTypeProperty", param[0], [ + [ + "key", + key + ], + [ + "value", + _type(prop.value) + ], + [ + "optional", + bool(prop.optional) + ], + [ + "static", + bool(prop.static) + ] + ]); + }; + const type_param = function (param) { + const tp = param[1]; + const 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) + ] + ]); + }; + const comment = function (param) { + const c = param[1]; + let match; + match = c.TAG === /* Block */0 ? [ + "Block", + c._0 + ] : [ + "Line", + c._0 + ]; + return node(match[0], param[0], [[ + "value", + string(match[1]) + ]]); + }; const 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 9a084edb9..886977bf7 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js @@ -11217,6 +11217,20 @@ function directive_parse(token_with_comments, lexbuf) { push(e); return v; }; + const parse_or_aux = function (calc, v) { + const e = token(undefined); + if (e === 8) { + const calc$1 = calc && !v; + const 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; + }; const parse_relation = function (calc) { const curr_token = token(undefined); const curr_loc = curr(lexbuf); @@ -11352,20 +11366,6 @@ function directive_parse(token_with_comments, lexbuf) { } } }; - const parse_or_aux = function (calc, v) { - const e = token(undefined); - if (e === 8) { - const calc$1 = calc && !v; - const 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; - }; const v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); const match = token(undefined); if (match === 88) { @@ -12706,6 +12706,66 @@ function token(lexbuf) { }; } +function string(lexbuf) { + lexbuf.lex_mem = Caml_array.make(2, -1); + let ___ocaml_lex_state = 164; + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __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 : + const 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); + } + const 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 new Caml_js_exceptions.MelangeError($$Error$2, { + MEL_EXN_ID: $$Error$2, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + }); + 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) { const __ocaml_lex_state = ___ocaml_lex_state; @@ -12922,66 +12982,6 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { }; } -function string(lexbuf) { - lexbuf.lex_mem = Caml_array.make(2, -1); - let ___ocaml_lex_state = 164; - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __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 : - const 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); - } - const 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 new Caml_js_exceptions.MelangeError($$Error$2, { - MEL_EXN_ID: $$Error$2, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents - }); - 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 at_bol(lexbuf) { const 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 937b886be..ae77c2314 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js @@ -23246,20 +23246,6 @@ function directive_parse(token_with_comments, lexbuf) { } }; - const parse_or_aux = function (calc, v) { - const e = token(undefined); - if (e === 8) { - const calc$1 = calc && !v; - const 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; - }; const parse_relation = function (calc) { const curr_token = token(undefined); const curr_loc = curr(lexbuf); @@ -23419,6 +23405,20 @@ function directive_parse(token_with_comments, lexbuf) { push(e); return v; }; + const parse_or_aux = function (calc, v) { + const e = token(undefined); + if (e === 8) { + const calc$1 = calc && !v; + const 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; + }; const v = parse_or_aux(true, parse_and_aux(true, parse_relation(true))); const match = token(undefined); if (match === 88) { @@ -24759,8 +24759,42 @@ function token(lexbuf) { }; } -function comment(lexbuf) { - return __ocaml_lex_comment_rec(lexbuf, 132); +function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { + while(true) { + const __ocaml_lex_state = ___ocaml_lex_state; + const __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 new Caml_js_exceptions.MelangeError($$Error$4, { + MEL_EXN_ID: $$Error$4, + _1: /* Unterminated_string */0, + _2: string_start_loc.contents + }); + case 2 : + const edelim = Stdlib__Lexing.lexeme(lexbuf); + const 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) { @@ -24819,6 +24853,10 @@ function string(lexbuf) { }; } +function comment(lexbuf) { + return __ocaml_lex_comment_rec(lexbuf, 132); +} + function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { while(true) { const __ocaml_lex_state = ___ocaml_lex_state; @@ -24997,44 +25035,6 @@ function __ocaml_lex_comment_rec(lexbuf, ___ocaml_lex_state) { }; } -function __ocaml_lex_quoted_string_rec(delim, lexbuf, ___ocaml_lex_state) { - while(true) { - const __ocaml_lex_state = ___ocaml_lex_state; - const __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 new Caml_js_exceptions.MelangeError($$Error$4, { - MEL_EXN_ID: $$Error$4, - _1: /* Unterminated_string */0, - _2: string_start_loc.contents - }); - case 2 : - const edelim = Stdlib__Lexing.lexeme(lexbuf); - const 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) { const pos = lexbuf.lex_start_p; return pos.pos_cnum === pos.pos_bol; @@ -25941,37 +25941,6 @@ function TypedtreeMap_MakeMap(funarg) { ctyp_attributes: ct$1.ctyp_attributes }); }; - const 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) - }; - } - }; - const map_package_type = function (pack) { - const pack$1 = Curry._1(funarg.enter_package_type, pack); - const 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 - }); - }; const map_module_type = function (mty) { const mty$1 = Curry._1(funarg.enter_module_type, mty); const sg = mty$1.mty_desc; @@ -26324,258 +26293,205 @@ function TypedtreeMap_MakeMap(funarg) { mod_attributes: mexpr$1.mod_attributes }); }; - const map_extension_constructor = function (ext) { - const ext$1 = Curry._1(funarg.enter_extension_constructor, ext); - const match = ext$1.ext_kind; - let ext_kind; - if (match.TAG === /* Text_decl */0) { - const args = Stdlib__List.map(map_core_type, match._0); - const ret = may_map(map_core_type, match._1); - ext_kind = { - TAG: /* Text_decl */0, - _0: args, - _1: ret - }; - } else { - 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 - }); - }; const map_type_parameter = function (param) { return [ map_core_type(param[0]), param[1] ]; }; - const 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) + const map_class_type = function (ct) { + const ct$1 = Curry._1(funarg.enter_class_type, ct); + const csg = ct$1.cltyp_desc; + let cltyp_desc; + switch (csg.TAG | 0) { + case /* Tcty_constr */0 : + cltyp_desc = { + TAG: /* Tcty_constr */0, + _0: csg._0, + _1: csg._1, + _2: Stdlib__List.map(map_core_type, csg._2) }; - }; - const map_type_extension = function (tyext) { - const tyext$1 = Curry._1(funarg.enter_type_extension, tyext); - const tyext_params = Stdlib__List.map(map_type_parameter, tyext$1.tyext_params); - const 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 + break; + 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 }); }; - const map_value_description = function (v) { - const v$1 = Curry._1(funarg.enter_value_description, v); - const 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 - }); + const map_with_constraint = function (cstr) { + const cstr$1 = Curry._1(funarg.enter_with_constraint, cstr); + let tmp; + switch (cstr$1.TAG | 0) { + case /* Twith_type */0 : + tmp = { + TAG: /* Twith_type */0, + _0: map_type_declaration(cstr$1._0) + }; + break; + case /* Twith_typesubst */2 : + tmp = { + TAG: /* Twith_typesubst */2, + _0: map_type_declaration(cstr$1._0) + }; + break; + case /* Twith_module */1 : + case /* Twith_modsubst */3 : + tmp = cstr$1; + break; + + } + return Curry._1(funarg.leave_with_constraint, tmp); }; - const map_module_type_declaration = function (mtd) { - const 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 + const map_signature = function (sg) { + const sg$1 = Curry._1(funarg.enter_signature, sg); + const 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 }); }; - const map_type_declaration = function (decl) { - const decl$1 = Curry._1(funarg.enter_type_declaration, decl); - const typ_params = Stdlib__List.map(map_type_parameter, decl$1.typ_params); - const typ_cstrs = Stdlib__List.map((function (param) { - return [ - map_core_type(param[0]), - map_core_type(param[1]), - param[2] - ]; - }), decl$1.typ_cstrs); - const list = decl$1.typ_kind; - let 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) { - const list$1 = Stdlib__List.map(map_constructor_declaration, list._0); - typ_kind = { - TAG: /* Ttype_variant */0, - _0: list$1 - }; + const 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 { - const 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: /* Tinherit */1, + _0: map_core_type(rf._0) + }; } - const 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 - }); }; - const map_class_type_declaration = function (cd) { - const cd$1 = Curry._1(funarg.enter_class_type_declaration, cd); - const ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - const 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 + const map_package_type = function (pack) { + const pack$1 = Curry._1(funarg.enter_package_type, pack); + const 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 }); }; - const map_class_description = function (cd) { - const cd$1 = Curry._1(funarg.enter_class_description, cd); - const ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - const 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 + const map_class_structure = function (cs) { + const cs$1 = Curry._1(funarg.enter_class_structure, cs); + const cstr_self = map_pattern(cs$1.cstr_self); + const 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 }); }; - const map_pattern = function (pat) { - const pat$1 = Curry._1(funarg.enter_pattern, pat); - const list = pat$1.pat_desc; - let pat_desc; - if (typeof list === "number") { - pat_desc = pat$1.pat_desc; - } else { - switch (list.TAG | 0) { - case /* Tpat_alias */1 : - const 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 : - const pato = list._1; - const 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; - } + const 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) + }; + }; + const 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 + }; + }; + const map_exp_extra = function (exp_extra) { + const attrs = exp_extra[2]; + const loc = exp_extra[1]; + const 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 : + const 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 : + const 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; + } - const 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 - }); + }; + const 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 + }; }; const map_class_field = function (cf) { const cf$1 = Curry._1(funarg.enter_class_field, cf); @@ -26651,236 +26567,108 @@ function TypedtreeMap_MakeMap(funarg) { }; 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; - - } - return Curry._1(funarg.leave_class_field, { - cf_desc: cf_desc, - cf_loc: cf$1.cf_loc, - cf_attributes: cf$1.cf_attributes - }); - }; - const map_class_expr = function (cexpr) { - const cexpr$1 = Curry._1(funarg.enter_class_expr, cexpr); - const clstr = cexpr$1.cl_desc; - let 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 /* Tcl_structure */1 : - cl_desc = { - TAG: /* Tcl_structure */1, - _0: map_class_structure(clstr._0) - }; - 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 - }; - 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) - }; - break; - case /* Tcl_let */4 : - const 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 /* Tcl_constraint */5 : - const clty = clstr._1; - const 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_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 - }); - }; - const map_exp_extra = function (exp_extra) { - const attrs = exp_extra[2]; - const loc = exp_extra[1]; - const 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 : - const 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 : - const 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; - - } - }; - const 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 - }; - }; - const map_class_structure = function (cs) { - const cs$1 = Curry._1(funarg.enter_class_structure, cs); - const cstr_self = map_pattern(cs$1.cstr_self); - const 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 - }); - }; - const 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 - }; - }; - const map_class_type = function (ct) { - const ct$1 = Curry._1(funarg.enter_class_type, ct); - const csg = ct$1.cltyp_desc; - let cltyp_desc; - switch (csg.TAG | 0) { - case /* Tcty_constr */0 : - cltyp_desc = { - TAG: /* Tcty_constr */0, - _0: csg._0, - _1: csg._1, - _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) + cf_desc = { + TAG: /* Tcf_initializer */4, + _0: map_expression(exp._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) - }; + case /* Tcf_attribute */5 : + cf_desc = exp; 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_class_field, { + cf_desc: cf_desc, + cf_loc: cf$1.cf_loc, + cf_attributes: cf$1.cf_attributes + }); + }; + const map_pattern = function (pat) { + const pat$1 = Curry._1(funarg.enter_pattern, pat); + const list = pat$1.pat_desc; + let pat_desc; + if (typeof list === "number") { + pat_desc = pat$1.pat_desc; + } else { + switch (list.TAG | 0) { + case /* Tpat_alias */1 : + const 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 : + const pato = list._1; + const 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; + } + } + const 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 }); }; const map_signature_item = function (item) { @@ -26983,93 +26771,97 @@ function TypedtreeMap_MakeMap(funarg) { sig_loc: item$1.sig_loc }); }; - const map_signature = function (sg) { - const sg$1 = Curry._1(funarg.enter_signature, sg); - const 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 - }); - }; - const map_with_constraint = function (cstr) { - const cstr$1 = Curry._1(funarg.enter_with_constraint, cstr); - let tmp; - switch (cstr$1.TAG | 0) { - case /* Twith_type */0 : - tmp = { - TAG: /* Twith_type */0, - _0: map_type_declaration(cstr$1._0) - }; - break; - case /* Twith_typesubst */2 : - tmp = { - TAG: /* Twith_typesubst */2, - _0: map_type_declaration(cstr$1._0) + const map_class_expr = function (cexpr) { + const cexpr$1 = Curry._1(funarg.enter_class_expr, cexpr); + const clstr = cexpr$1.cl_desc; + let 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 /* Twith_module */1 : - case /* Twith_modsubst */3 : - tmp = cstr$1; - break; - - } - return Curry._1(funarg.leave_with_constraint, tmp); - }; - const map_class_type_field = function (ctf) { - const ctf$1 = Curry._1(funarg.enter_class_type_field, ctf); - const ct = ctf$1.ctf_desc; - let ctf_desc; - switch (ct.TAG | 0) { - case /* Tctf_inherit */0 : - ctf_desc = { - TAG: /* Tctf_inherit */0, - _0: map_class_type(ct._0) + case /* Tcl_structure */1 : + cl_desc = { + TAG: /* Tcl_structure */1, + _0: map_class_structure(clstr._0) }; break; - case /* Tctf_val */1 : - const match = ct._0; - ctf_desc = { - TAG: /* Tctf_val */1, - _0: [ - match[0], - match[1], - match[2], - map_core_type(match[3]) - ] + 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 /* Tctf_method */2 : - const match$1 = ct._0; - ctf_desc = { - TAG: /* Tctf_method */2, - _0: [ - match$1[0], - match$1[1], - match$1[2], - map_core_type(match$1[3]) - ] + 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 /* Tctf_constraint */3 : - const match$2 = ct._0; - ctf_desc = { - TAG: /* Tctf_constraint */3, - _0: [ - map_core_type(match$2[0]), - map_core_type(match$2[1]) - ] + case /* Tcl_let */4 : + const 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 /* Tctf_attribute */4 : - ctf_desc = ct; + case /* Tcl_constraint */5 : + const clty = clstr._1; + const 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_type_field, { - ctf_desc: ctf_desc, - ctf_loc: ctf$1.ctf_loc, - ctf_attributes: ctf$1.ctf_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 }); }; const map_pat_extra = function (pat_extra) { @@ -27087,30 +26879,134 @@ function TypedtreeMap_MakeMap(funarg) { ]; } }; - const map_class_signature = function (cs) { - const cs$1 = Curry._1(funarg.enter_class_signature, cs); - const csig_self = map_core_type(cs$1.csig_self); - const 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 + const map_extension_constructor = function (ext) { + const ext$1 = Curry._1(funarg.enter_extension_constructor, ext); + const match = ext$1.ext_kind; + let ext_kind; + if (match.TAG === /* Text_decl */0) { + const args = Stdlib__List.map(map_core_type, match._0); + const ret = may_map(map_core_type, match._1); + ext_kind = { + TAG: /* Text_decl */0, + _0: args, + _1: ret + }; + } else { + 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 }); }; - const 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 - }; + const map_type_declaration = function (decl) { + const decl$1 = Curry._1(funarg.enter_type_declaration, decl); + const typ_params = Stdlib__List.map(map_type_parameter, decl$1.typ_params); + const typ_cstrs = Stdlib__List.map((function (param) { + return [ + map_core_type(param[0]), + map_core_type(param[1]), + param[2] + ]; + }), decl$1.typ_cstrs); + const list = decl$1.typ_kind; + let 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) { + const list$1 = Stdlib__List.map(map_constructor_declaration, list._0); + typ_kind = { + TAG: /* Ttype_variant */0, + _0: list$1 + }; + } else { + const 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 + }; + } + const 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 + }); }; - const map_class_declaration = function (cd) { - const cd$1 = Curry._1(funarg.enter_class_declaration, cd); + const map_value_description = function (v) { + const v$1 = Curry._1(funarg.enter_value_description, v); + const 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 + }); + }; + const map_class_description = function (cd) { + const cd$1 = Curry._1(funarg.enter_class_description, cd); const ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); - const ci_expr = map_class_expr(cd$1.ci_expr); - return Curry._1(funarg.leave_class_declaration, { + const 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 + }); + }; + const map_type_extension = function (tyext) { + const tyext$1 = Curry._1(funarg.enter_type_extension, tyext); + const tyext_params = Stdlib__List.map(map_type_parameter, tyext$1.tyext_params); + const 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 + }); + }; + const map_class_type_declaration = function (cd) { + const cd$1 = Curry._1(funarg.enter_class_type_declaration, cd); + const ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); + const 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, @@ -27125,6 +27021,16 @@ function TypedtreeMap_MakeMap(funarg) { ci_attributes: cd$1.ci_attributes }); }; + const map_module_type_declaration = function (mtd) { + const 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 + }); + }; const map_structure_item = function (item) { const item$1 = Curry._1(funarg.enter_structure_item, item); const vd = item$1.str_desc; @@ -27207,43 +27113,137 @@ function TypedtreeMap_MakeMap(funarg) { _0: list$1 }; break; - case /* Tstr_class_type */11 : - const 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 : + const 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 : + const 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 + }); + }; + const map_class_declaration = function (cd) { + const cd$1 = Curry._1(funarg.enter_class_declaration, cd); + const ci_params = Stdlib__List.map(map_type_parameter, cd$1.ci_params); + const 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 + }); + }; + const 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 + }; + }; + const map_class_signature = function (cs) { + const cs$1 = Curry._1(funarg.enter_class_signature, cs); + const csig_self = map_core_type(cs$1.csig_self); + const 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 + }); + }; + const map_class_type_field = function (ctf) { + const ctf$1 = Curry._1(funarg.enter_class_type_field, ctf); + const ct = ctf$1.ctf_desc; + let ctf_desc; + switch (ct.TAG | 0) { + case /* Tctf_inherit */0 : + ctf_desc = { + TAG: /* Tctf_inherit */0, + _0: map_class_type(ct._0) + }; + break; + case /* Tctf_val */1 : + const match = ct._0; + ctf_desc = { + TAG: /* Tctf_val */1, + _0: [ + match[0], + match[1], + match[2], + map_core_type(match[3]) + ] + }; + break; + case /* Tctf_method */2 : + const match$1 = ct._0; + ctf_desc = { + TAG: /* Tctf_method */2, + _0: [ + match$1[0], + match$1[1], + match$1[2], + map_core_type(match$1[3]) + ] }; break; - case /* Tstr_include */12 : - const 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 - } + case /* Tctf_constraint */3 : + const match$2 = ct._0; + ctf_desc = { + TAG: /* Tctf_constraint */3, + _0: [ + map_core_type(match$2[0]), + map_core_type(match$2[1]) + ] }; break; - case /* Tstr_attribute */13 : - str_desc = { - TAG: /* Tstr_attribute */13, - _0: vd._0 - }; + case /* Tctf_attribute */4 : + ctf_desc = ct; break; } - return Curry._1(funarg.leave_structure_item, { - str_desc: str_desc, - str_loc: item$1.str_loc, - str_env: item$1.str_env + return Curry._1(funarg.leave_class_type_field, { + ctf_desc: ctf_desc, + ctf_loc: ctf$1.ctf_loc, + ctf_attributes: ctf$1.ctf_attributes }); }; return { @@ -32794,6 +32794,90 @@ function unify(env, t1, t2) { } } +function unify_fields(env, ty1, ty2) { + const match = flatten_fields(ty1); + const rest1 = match[1]; + const match$1 = flatten_fields(ty2); + const rest2 = match$1[1]; + const match$2 = associate_fields(match[0], match$1[0]); + const miss2 = match$2[2]; + const miss1 = match$2[1]; + const l1 = repr(ty1).level; + const l2 = repr(ty2).level; + const va = make_rowvar(l1 < l2 ? l1 : l2, Caml_obj.caml_equal(miss2, /* [] */0), rest1, Caml_obj.caml_equal(miss1, /* [] */0), rest2); + const d1 = rest1.desc; + const d2 = rest2.desc; + try { + unify(env, build_fields(l1)(miss1, va), rest2); + unify(env, rest1, build_fields(l2)(miss2, va)); + return Stdlib__List.iter((function (param) { + const t2 = param[4]; + const k2 = param[3]; + const t1 = param[2]; + const k1 = param[1]; + const n = param[0]; + unify_kind(k1, k2); + try { + if (trace_gadt_instances.contents) { + update_level(env.contents, va.level, t1); + } + return unify(env, t1, t2); + } + catch (raw_trace){ + const trace = Caml_js_exceptions.internalToOCamlException(raw_trace); + if (trace.MEL_EXN_ID === Unify) { + const desc_3 = newty2(current_level.contents, /* Tnil */0); + const desc = { + TAG: /* Tfield */5, + _0: n, + _1: k1, + _2: t1, + _3: desc_3 + }; + const desc_3$1 = newty2(current_level.contents, /* Tnil */0); + const desc$1 = { + TAG: /* Tfield */5, + _0: n, + _1: k2, + _2: t2, + _3: desc_3$1 + }; + throw new Caml_js_exceptions.MelangeError(Unify, { + MEL_EXN_ID: Unify, + _1: { + hd: [ + newty2(current_level.contents, desc), + newty2(current_level.contents, desc$1) + ], + tl: trace._1 + } + }); + } + throw new Caml_js_exceptions.MelangeError(trace.MEL_EXN_ID, trace); + } + }), match$2[0]); + } + catch (exn){ + log_type(rest1); + rest1.desc = d1; + log_type(rest2); + rest2.desc = d2; + throw new Caml_js_exceptions.MelangeError(exn.MEL_EXN_ID, exn); + } +} + +function unify_list(env, tl1, tl2) { + if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { + throw new Caml_js_exceptions.MelangeError(Unify, { + MEL_EXN_ID: Unify, + _1: /* [] */0 + }); + } + Stdlib__List.iter2((function (param, param$1) { + return unify(env, param, param$1); + }), tl1, tl2); +} + function unify_row(env, row1, row2) { const row1$1 = row_repr_aux(/* [] */0, row1); const row2$1 = row_repr_aux(/* [] */0, row2); @@ -33254,90 +33338,6 @@ function unify_row(env, row1, row2) { } } -function unify_list(env, tl1, tl2) { - if (Stdlib__List.length(tl1) !== Stdlib__List.length(tl2)) { - throw new Caml_js_exceptions.MelangeError(Unify, { - MEL_EXN_ID: Unify, - _1: /* [] */0 - }); - } - Stdlib__List.iter2((function (param, param$1) { - return unify(env, param, param$1); - }), tl1, tl2); -} - -function unify_fields(env, ty1, ty2) { - const match = flatten_fields(ty1); - const rest1 = match[1]; - const match$1 = flatten_fields(ty2); - const rest2 = match$1[1]; - const match$2 = associate_fields(match[0], match$1[0]); - const miss2 = match$2[2]; - const miss1 = match$2[1]; - const l1 = repr(ty1).level; - const l2 = repr(ty2).level; - const va = make_rowvar(l1 < l2 ? l1 : l2, Caml_obj.caml_equal(miss2, /* [] */0), rest1, Caml_obj.caml_equal(miss1, /* [] */0), rest2); - const d1 = rest1.desc; - const d2 = rest2.desc; - try { - unify(env, build_fields(l1)(miss1, va), rest2); - unify(env, rest1, build_fields(l2)(miss2, va)); - return Stdlib__List.iter((function (param) { - const t2 = param[4]; - const k2 = param[3]; - const t1 = param[2]; - const k1 = param[1]; - const n = param[0]; - unify_kind(k1, k2); - try { - if (trace_gadt_instances.contents) { - update_level(env.contents, va.level, t1); - } - return unify(env, t1, t2); - } - catch (raw_trace){ - const trace = Caml_js_exceptions.internalToOCamlException(raw_trace); - if (trace.MEL_EXN_ID === Unify) { - const desc_3 = newty2(current_level.contents, /* Tnil */0); - const desc = { - TAG: /* Tfield */5, - _0: n, - _1: k1, - _2: t1, - _3: desc_3 - }; - const desc_3$1 = newty2(current_level.contents, /* Tnil */0); - const desc$1 = { - TAG: /* Tfield */5, - _0: n, - _1: k2, - _2: t2, - _3: desc_3$1 - }; - throw new Caml_js_exceptions.MelangeError(Unify, { - MEL_EXN_ID: Unify, - _1: { - hd: [ - newty2(current_level.contents, desc), - newty2(current_level.contents, desc$1) - ], - tl: trace._1 - } - }); - } - throw new Caml_js_exceptions.MelangeError(trace.MEL_EXN_ID, trace); - } - }), match$2[0]); - } - catch (exn){ - log_type(rest1); - rest1.desc = d1; - log_type(rest2); - rest2.desc = d2; - throw new Caml_js_exceptions.MelangeError(exn.MEL_EXN_ID, exn); - } -} - function unify2(env, t1, t2) { const expand_both = function (_t1$p$p, _t2$p$p) { while(true) { @@ -34046,44 +34046,7 @@ function unify3(env, t1, t1$p, t2, t2$p) { throw new Caml_js_exceptions.MelangeError(trace.MEL_EXN_ID, trace); } } - -} - -function unify_kind(k1, k2) { - const k1$1 = field_kind_repr(k1); - const 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 { - const 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 new Caml_js_exceptions.MelangeError("Assert_failure", { - MEL_EXN_ID: "Assert_failure", - _1: [ - "jscomp/test/ocaml_typedtree_test.ml", - 32636, - 37 - ] - }); + } function make_rowvar(level, use1, rest1, use2, rest2) { @@ -34158,6 +34121,43 @@ function make_rowvar(level, use1, rest1, use2, rest2) { } } +function unify_kind(k1, k2) { + const k1$1 = field_kind_repr(k1); + const 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 { + const 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 new Caml_js_exceptions.MelangeError("Assert_failure", { + MEL_EXN_ID: "Assert_failure", + _1: [ + "jscomp/test/ocaml_typedtree_test.ml", + 32636, + 37 + ] + }); +} + function unify$1(env, ty1, ty2) { try { return unify(env, ty1, ty2); @@ -41199,6 +41199,111 @@ 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 ; + } + const item = param.hd; + if (!param.tl) { + return Curry._2(out_sig_item.contents, ppf, item); + } + if (item.TAG === /* Osig_typext */2 && !item._1) { + const ext = item._0; + const gather_extensions = function (_acc, _items) { + while(true) { + const items = _items; + const acc = _acc; + if (!items) { + return [ + Stdlib__List.rev(acc), + items + ]; + } + const 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 + ]; + } + const ext = match._0; + _items = items.tl; + _acc = { + hd: [ + ext.oext_name, + ext.oext_args, + ext.oext_ret_type + ], + tl: acc + }; + continue ; + }; + }; + const match = gather_extensions({ + hd: [ + ext.oext_name, + ext.oext_args, + ext.oext_ret_type + ], + tl: /* [] */0 + }, param.tl); + const te_otyext_name = ext.oext_type_name; + const te_otyext_params = ext.oext_type_params; + const te_otyext_constructors = match[0]; + const te_otyext_private = ext.oext_private; + const 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 ; @@ -41323,111 +41428,6 @@ function print_out_module_type(ppf, t) { } } -function print_out_signature(ppf, param) { - if (!param) { - return ; - } - const item = param.hd; - if (!param.tl) { - return Curry._2(out_sig_item.contents, ppf, item); - } - if (item.TAG === /* Osig_typext */2 && !item._1) { - const ext = item._0; - const gather_extensions = function (_acc, _items) { - while(true) { - const items = _items; - const acc = _acc; - if (!items) { - return [ - Stdlib__List.rev(acc), - items - ]; - } - const 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 - ]; - } - const ext = match._0; - _items = items.tl; - _acc = { - hd: [ - ext.oext_name, - ext.oext_args, - ext.oext_ret_type - ], - tl: acc - }; - continue ; - }; - }; - const match = gather_extensions({ - hd: [ - ext.oext_name, - ext.oext_args, - ext.oext_ret_type - ], - tl: /* [] */0 - }, param.tl); - const te_otyext_name = ext.oext_type_name; - const te_otyext_params = ext.oext_type_params; - const te_otyext_constructors = match[0]; - const te_otyext_private = ext.oext_private; - const 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_sig_item(ppf, param) { switch (param.TAG | 0) { case /* Osig_class */0 :