mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 00:45:04 +01:00
Add assignments
This commit is contained in:
parent
6d2a2fe474
commit
0bf9aed35e
6 changed files with 113 additions and 32 deletions
19
src/ast.ts
19
src/ast.ts
|
|
@ -72,9 +72,18 @@ export type ExprLet = {
|
|||
type?: Type;
|
||||
rhs: Expr;
|
||||
// IMPORTANT: This is (sadly) shared with ExprBlock.
|
||||
// TODO: Stop this sharing and just store the stack of blocks in typeck.
|
||||
local?: LocalInfo;
|
||||
};
|
||||
|
||||
// A bit like ExprBinary except there are restrictions
|
||||
// on the LHS and precedence is unrestricted.
|
||||
export type ExprAssign = {
|
||||
kind: "assign";
|
||||
lhs: Expr;
|
||||
rhs: Expr;
|
||||
};
|
||||
|
||||
export type ExprBlock = {
|
||||
kind: "block";
|
||||
exprs: Expr[];
|
||||
|
|
@ -128,6 +137,7 @@ export type ExprBreak = {
|
|||
/**
|
||||
* The break target block.
|
||||
* May be any control flow block, labelled from inside out.
|
||||
* TODO: This is not a good solution at all and pretty broken.
|
||||
*/
|
||||
target?: number;
|
||||
};
|
||||
|
|
@ -141,6 +151,7 @@ export type ExprStructLiteral = {
|
|||
export type ExprKind =
|
||||
| ExprEmpty
|
||||
| ExprLet
|
||||
| ExprAssign
|
||||
| ExprBlock
|
||||
| ExprLiteral
|
||||
| ExprIdent
|
||||
|
|
@ -482,6 +493,14 @@ export function superFoldExpr(expr: Expr, folder: Folder): Expr {
|
|||
rhs: folder.expr(expr.rhs),
|
||||
};
|
||||
}
|
||||
case "assign": {
|
||||
return {
|
||||
...expr,
|
||||
kind: "assign",
|
||||
lhs: folder.expr(expr.lhs),
|
||||
rhs: folder.expr(expr.rhs),
|
||||
};
|
||||
}
|
||||
case "block": {
|
||||
return {
|
||||
...expr,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue