mirror of
https://github.com/bendtherules/not-a-js-engine.git
synced 2026-08-18 22:01:53 +00:00
Implement string, number literal and completion record
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { LanguageType } from '../language-types/allTypes';
|
||||
|
||||
export const TypeString = '[[Type]]';
|
||||
export const ValueString = '[[Value]]';
|
||||
export const TargetString = '[[Target]]';
|
||||
|
||||
export type TType = 'normal' | 'break' | 'continue' | 'return' | 'throw';
|
||||
export type TValue = LanguageType | undefined;
|
||||
export type TTarget = string | undefined;
|
||||
|
||||
export interface TCompletionRecord {
|
||||
[TypeString]: TType;
|
||||
[ValueString]: TValue;
|
||||
[TargetString]: TTarget;
|
||||
}
|
||||
|
||||
export class CompletionRecord implements TCompletionRecord {
|
||||
[TypeString]: TType;
|
||||
[ValueString]: TValue;
|
||||
[TargetString]: TTarget;
|
||||
|
||||
constructor(type: TType, value?: TValue, target?: TTarget) {
|
||||
this[TypeString] = type;
|
||||
this[ValueString] = value;
|
||||
this[TargetString] = target;
|
||||
}
|
||||
}
|
||||
|
||||
export function NormalCompletion(value?: TValue) {
|
||||
return new CompletionRecord('normal', value);
|
||||
}
|
||||
Reference in New Issue
Block a user