All files frame.js

100% Statements 16/16
100% Branches 3/3
100% Functions 7/7
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53    1x 1x         144796x 144796x       38657x 37652x   1005x 1005x 1005x 1005x       1005x             76445x       1x               37652x       37652x         1x  
'use strict';
 
const { ArgumentState } = require( './argumentState.js' );
const { error, normalError } = require( '../function-schemata/javascript/src/error.js' );
 
class BaseFrame {
 
	constructor( lastFrame = null ) {
		this.lastFrame_ = lastFrame;
		this.names_ = new Map();
	}
 
	mergedCopy( otherFrame ) {
		if ( this.isEmpty() ) {
			return otherFrame.copy();
		}
		const lastFrame = this.lastFrame_.mergedCopy( otherFrame );
		const myCopy = this.copy( lastFrame );
		myCopy.lastFrame_ = lastFrame;
		return myCopy;
	}
 
	isEmpty() {
		return false;
	}
 
}
 
class EmptyFrame extends BaseFrame {
	constructor() {
		super();
	}
 
	async retrieveArgument( argumentName ) {
		return ArgumentState.ERROR(
			normalError(
				// TODO (T287919): Reconsider error type.
				[ error.invalid_key ],
				[ 'No argument called ' + argumentName + ' in scope.' ] ) );
	}
 
	copy() {
		return new EmptyFrame();
	}
 
	isEmpty() {
		return true;
	}
 
}
 
module.exports = { BaseFrame, EmptyFrame };