Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ under the licensing terms detailed in LICENSE:
* Adrien Zinger <zinger.ad@gmail.com>
* Ruixiang Chen <xiang19890319@gmail.com>
* Daniel Salvadori <danaugrs@gmail.com>
* Jairus Tanaka <jairus.v.tanaka@outlook.com>
* Jairus Tanaka <me@jairus.dev>
* CountBleck <Mr.YouKnowWhoIAm@protonmail.com>
* Abdul Rauf <abdulraufmujahid@gmail.com>
* Bach Le <bach@bullno1.com>
Expand Down
2 changes: 1 addition & 1 deletion cli/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
" threads Threading and atomic operations.",
" simd SIMD types and operations.",
" reference-types Reference types and operations.",
" multi-value Multi value types.",
" gc Garbage collection (WIP).",
" stringref String reference types.",
" relaxed-simd Relaxed SIMD operations.",
Expand All @@ -227,7 +228,6 @@
"TODO_doesNothingYet": [
" exception-handling Exception handling.",
" tail-calls Tail call operations.",
" multi-value Multi value types.",
" memory64 Memory64 operations.",
" extended-const Extended const expressions."
],
Expand Down
29 changes: 29 additions & 0 deletions src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const enum NodeKind {
// types
NamedType,
FunctionType,
TupleType,
TypeName,
TypeParameter,
Parameter,
Expand Down Expand Up @@ -161,6 +162,14 @@ export abstract class Node {
return new FunctionTypeNode(parameters, returnType, explicitThisType, isNullable, range);
}

static createTupleType(
elements: TypeNode[],
isNullable: bool,
range: Range
): TupleTypeNode {
return new TupleTypeNode(elements, isNullable, range);
}

static createOmittedType(
range: Range
): NamedTypeNode {
Expand Down Expand Up @@ -862,6 +871,12 @@ export abstract class TypeNode extends Node {
if (functionTypeNode.returnType.hasGenericComponent(typeParameterNodes)) return true;
let explicitThisType = functionTypeNode.explicitThisType;
if (explicitThisType && explicitThisType.hasGenericComponent(typeParameterNodes)) return true;
} else if (this.kind == NodeKind.TupleType) {
let tupleTypeNode = <TupleTypeNode>changetype<TypeNode>(this);
let elements = tupleTypeNode.elements;
for (let i = 0, k = elements.length; i < k; ++i) {
if (elements[i].hasGenericComponent(typeParameterNodes)) return true;
}
} else {
assert(false);
}
Expand Down Expand Up @@ -928,6 +943,20 @@ export class FunctionTypeNode extends TypeNode {
}
}

/** Represents a tuple type. */
export class TupleTypeNode extends TypeNode {
constructor(
/** Tuple elements. */
public elements: TypeNode[],
/** Whether nullable or not. */
isNullable: bool,
/** Source range. */
range: Range
) {
super(NodeKind.TupleType, isNullable, range);
}
}

/** Represents a type parameter. */
export class TypeParameterNode extends Node {
constructor(
Expand Down
Loading