Skip to content

Commit

Permalink
Merge branch 'main' of ssh://github.com/CS4215-OOGA/ooga-lang
Browse files Browse the repository at this point in the history
  • Loading branch information
arnav-ag committed Apr 9, 2024
2 parents 330b34f + e1d38c4 commit 5236900
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/vm/oogavm-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export class HeapDeadError extends OogaError {
}
}

export class RuntimeError extends OogaError {
constructor(msg: string) {
super(msg);
}
}

export class CompilerError extends OogaError {
constructor(msg: string) {
super(msg);
Expand Down
5 changes: 3 additions & 2 deletions src/vm/oogavm-scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RuntimeError } from './oogavm-errors.js';

export type ThreadId = number;

export interface Scheduler {
Expand Down Expand Up @@ -65,9 +67,8 @@ export class RoundRobinScheduler implements Scheduler {
}

runThread(): [ThreadId, number] | null {
// Arnav: When will this be 0? This will cause a crash because the callee assumes the tuple result
if (this._idleThreads.length === 0) {
return null;
throw new RuntimeError("Expected a thread but nothing.");
} else {
// The ! is a non-null assertion operator
const nextThread = this._idleThreads.shift()!;
Expand Down
3 changes: 0 additions & 3 deletions src/vm/oogavm-typechecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,6 @@ const type_comp = {
log('AssignmentExpression');
log(unparse(comp));
const id_type = type(comp.left, te, struct_te);
if (id_type.is_const) {
throw new TypecheckError('cannot redeclare variable as it is constant');
}
const expr_type = type(comp.right, te, struct_te);
if (!equal_type(id_type, expr_type)) {
throw new TypecheckError(
Expand Down

0 comments on commit 5236900

Please sign in to comment.