-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
ArgumentsVariable.js
50 lines (43 loc) · 1.61 KB
/
ArgumentsVariable.js
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
import LocalVariable from './LocalVariable';
import { UNDEFINED_ASSIGNMENT, UNKNOWN_ASSIGNMENT } from '../values';
const getParameterVariable = ( path, options ) =>
(path[ 0 ] < options.getArgumentsVariables().length && options.getArgumentsVariables()[ path[ 0 ] ] )
|| UNDEFINED_ASSIGNMENT;
export default class ArgumentsVariable extends LocalVariable {
constructor ( parameters ) {
super( 'arguments', null, UNKNOWN_ASSIGNMENT );
this._parameters = parameters;
}
bindAssignmentAtPath ( path, expression, options ) {
if ( path.length > 0 ) {
if ( path[ 0 ] >= 0 && this._parameters[ path[ 0 ] ] ) {
this._parameters[ path[ 0 ] ].bindAssignmentAtPath( path.slice( 1 ), expression, options );
}
}
}
hasEffectsWhenAccessedAtPath ( path, options ) {
return path.length > 1
&& getParameterVariable( path, options )
.hasEffectsWhenAccessedAtPath( path.slice( 1 ), options );
}
hasEffectsWhenAssignedAtPath ( path, options ) {
return path.length === 0
|| this.included
|| getParameterVariable( path, options )
.hasEffectsWhenAssignedAtPath( path.slice( 1 ), options );
}
hasEffectsWhenCalledAtPath ( path, callOptions, options ) {
if ( path.length === 0 ) {
return true;
}
return getParameterVariable( path, options )
.hasEffectsWhenCalledAtPath( path.slice( 1 ), callOptions, options );
}
someReturnExpressionWhenCalledAtPath ( path, callOptions, predicateFunction, options ) {
if ( path.length === 0 ) {
return true;
}
return getParameterVariable( path, options )
.someReturnExpressionWhenCalledAtPath( path.slice( 1 ), callOptions, predicateFunction, options );
}
}