-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
|
||
export type TirExpr | ||
= | ||
| TirBinaryExpr | ||
Check failure on line 5 in src/compiler/tir/expressions/TirExpr.ts
|
||
; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { HasSourceRange } from "../../../ast/nodes/HasSourceRange"; | ||
import { SourceRange } from "../../../ast/Source/SourceRange"; | ||
import { TirExpr } from "../expressions/TirExpr"; | ||
import { TirStmt, TirVarDecl } from "./TirStmt"; | ||
|
||
/** | ||
* for( `elemDeclaration` of iterable ) body | ||
*/ | ||
export class TirForOfStmt | ||
implements HasSourceRange | ||
{ | ||
constructor( | ||
readonly elemDeclaration: TirForOfElemDecl, | ||
readonly iterable: TirExpr, | ||
readonly body: TirStmt, | ||
readonly range: SourceRange, | ||
) {} | ||
} | ||
|
||
/** | ||
* just like function parameters | ||
* destructured elements are moved in the `for...of` body | ||
* | ||
* unlike funciton parameters | ||
* `for...of` element type is inferred from the iterable | ||
*/ | ||
export class TirForOfElemDecl | ||
implements HasSourceRange | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly range: SourceRange, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { HasSourceRange } from "../../../ast/nodes/HasSourceRange"; | ||
import { SourceRange } from "../../../ast/Source/SourceRange"; | ||
import { TirExpr } from "../expressions/TirExpr"; | ||
import { TirStmt, TirVarDecl } from "./TirStmt"; | ||
|
||
/** | ||
* ***NOT*** for...of loop | ||
* | ||
* for( init; condition; update ) body | ||
*/ | ||
export class TirForStmt | ||
implements HasSourceRange | ||
{ | ||
constructor( | ||
readonly init: TirVarDecl[], | ||
readonly condition: TirExpr | undefined, | ||
readonly update: TirExpr | undefined, | ||
readonly body: TirStmt, | ||
readonly range: SourceRange, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { HasSourceRange } from "../../../ast/nodes/HasSourceRange"; | ||
import { SourceRange } from "../../../ast/Source/SourceRange"; | ||
import { TirExpr } from "../expressions/TirExpr"; | ||
import { TirConcreteType } from "../types/TirConcreteType"; | ||
|
||
|
||
export class TirFuncDecl | ||
implements HasSourceRange | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly params: TirSimpleFuncParam[], | ||
readonly returnType: TirConcreteType, | ||
readonly body: TirBlockStmt, | ||
Check failure on line 14 in src/compiler/tir/statements/TirFuncDecl.ts
|
||
readonly range: SourceRange, | ||
) {} | ||
} | ||
|
||
export class TirSimpleFuncParam | ||
implements HasSourceRange | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly type: TirConcreteType, // params MUST have a type, even with initExpr | ||
readonly initExpr: TirExpr | undefined, // optional initializer for params | ||
readonly range: SourceRange, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HasSourceRange } from "../../../ast/nodes/HasSourceRange"; | ||
import { SourceRange } from "../../../ast/Source/SourceRange"; | ||
import { TirExpr } from "../expressions/TirExpr"; | ||
import { TirStmt } from "./TirStmt"; | ||
|
||
export class TirIfStmt | ||
implements HasSourceRange | ||
{ | ||
constructor( | ||
readonly condition: TirExpr, | ||
readonly thenBranch: TirStmt, | ||
readonly elseBranch: TirStmt | undefined, | ||
readonly range: SourceRange, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HasSourceRange } from "../../../../ast/nodes/HasSourceRange"; | ||
import { SourceRange } from "../../../../ast/Source/SourceRange"; | ||
import { TirExpr } from "../../expressions/TirExpr"; | ||
import { TirConcreteType } from "../../types/TirConcreteType"; | ||
|
||
export class TirNamedDeconstructVarDecl | ||
implements HasSourceRange | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly type: TirConcreteType, | ||
readonly initExpr: TirExpr, | ||
readonly range: SourceRange, | ||
) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HasSourceRange } from "../../../../ast/nodes/HasSourceRange"; | ||
import { SourceRange } from "../../../../ast/Source/SourceRange"; | ||
import { TirExpr } from "../../expressions/TirExpr"; | ||
import { TirConcreteType } from "../../types/TirConcreteType"; | ||
|
||
export class TirSimpleVarDecl | ||
implements HasSourceRange | ||
{ | ||
constructor( | ||
readonly name: string, | ||
readonly type: TirConcreteType, | ||
readonly initExpr: TirExpr, | ||
readonly range: SourceRange, | ||
) {} | ||
} |