mirror of
https://git.sfja.dk/Mikkel/slige.git
synced 2025-01-18 10:36:31 +00:00
add sourcemaps
This commit is contained in:
parent
da1dbb92cd
commit
3032f0867c
@ -8,28 +8,6 @@ export type File = {
|
||||
stmts: Stmt[];
|
||||
};
|
||||
|
||||
export type UnaryType = "not";
|
||||
export type BinaryType =
|
||||
| "+"
|
||||
| "*"
|
||||
| "=="
|
||||
| "-"
|
||||
| "/"
|
||||
| "!="
|
||||
| "<"
|
||||
| ">"
|
||||
| "<="
|
||||
| ">="
|
||||
| "or"
|
||||
| "and";
|
||||
|
||||
export type Param = {
|
||||
ident: string;
|
||||
etype?: EType;
|
||||
pos: Pos;
|
||||
vtype?: VType;
|
||||
};
|
||||
|
||||
export type Stmt = {
|
||||
kind: StmtKind;
|
||||
pos: Pos;
|
||||
@ -83,6 +61,28 @@ export type ExprKind =
|
||||
sym: Sym;
|
||||
};
|
||||
|
||||
export type UnaryType = "not";
|
||||
export type BinaryType =
|
||||
| "+"
|
||||
| "*"
|
||||
| "=="
|
||||
| "-"
|
||||
| "/"
|
||||
| "!="
|
||||
| "<"
|
||||
| ">"
|
||||
| "<="
|
||||
| ">="
|
||||
| "or"
|
||||
| "and";
|
||||
|
||||
export type Param = {
|
||||
ident: string;
|
||||
etype?: EType;
|
||||
pos: Pos;
|
||||
vtype?: VType;
|
||||
};
|
||||
|
||||
export type Sym = {
|
||||
ident: string;
|
||||
pos?: Pos;
|
||||
@ -108,6 +108,12 @@ export type ETypeKind =
|
||||
| { type: "array"; inner: EType }
|
||||
| { type: "struct"; fields: Param[] };
|
||||
|
||||
export type ETypeParam = {
|
||||
ident: string;
|
||||
pos: Pos;
|
||||
vtype?: VType;
|
||||
};
|
||||
|
||||
export type Anno = {
|
||||
ident: string;
|
||||
values: Expr[];
|
||||
|
@ -136,6 +136,7 @@ export class Lowerer {
|
||||
? "main"
|
||||
: `${stmt.kind.ident}_${stmt.id}`;
|
||||
this.program.setLabel({ label });
|
||||
this.addSourceMap(stmt.pos);
|
||||
|
||||
const outerLocals = this.locals;
|
||||
const fnRoot = new LocalsFnRoot(outerLocals);
|
||||
@ -377,6 +378,7 @@ export class Lowerer {
|
||||
this.program.add(Ops.PushPtr, falseLabel);
|
||||
this.program.add(Ops.JumpIfTrue);
|
||||
|
||||
this.addSourceMap(expr.kind.truthy.pos);
|
||||
this.lowerExpr(expr.kind.truthy);
|
||||
|
||||
this.program.add(Ops.PushPtr, doneLabel);
|
||||
@ -385,6 +387,7 @@ export class Lowerer {
|
||||
this.program.setLabel(falseLabel);
|
||||
|
||||
if (expr.kind.falsy) {
|
||||
this.addSourceMap(expr.kind.truthy.pos);
|
||||
this.lowerExpr(expr.kind.falsy!);
|
||||
} else {
|
||||
this.program.add(Ops.PushNull);
|
||||
@ -403,6 +406,7 @@ export class Lowerer {
|
||||
this.breakStack.push(breakLabel);
|
||||
|
||||
this.program.setLabel(contineLabel);
|
||||
this.addSourceMap(expr.kind.body.pos);
|
||||
this.lowerExpr(expr.kind.body);
|
||||
this.program.add(Ops.Pop);
|
||||
this.program.add(Ops.PushPtr, contineLabel);
|
||||
|
Loading…
Reference in New Issue
Block a user