| 3 | import org.dynjs.exception.ThrowException; |
| 4 | |
| 5 | public abstract class AbstractFunction extends DynObject implements JSFunction { |
| 6 | |
| 7 | private String[] formalParameters; |
| 8 | private LexicalEnvironment scope; |
| 9 | private boolean strict; |
| 10 | |
| 11 | protected String debugContext; |
| 12 | |
| 13 | public AbstractFunction(final GlobalContext globalContext, final LexicalEnvironment scope, final boolean strict, final String... formalParameters) { |
| 14 | super(globalContext); |
| 15 | this.formalParameters = formalParameters; |
| 16 | this.scope = scope; |
| 17 | this.strict = strict; |
| 18 | setClassName("Function"); |
| 19 | // http://es5.github.com/#x15.3.3.2 |
| 20 | defineOwnProperty(null, "length", |
| 21 | PropertyDescriptor.newDataPropertyDescriptor((long) formalParameters.length, false, false, false), false); |
| 22 | |
| 23 | if (strict) { |
| 24 | final Object thrower = globalContext.getThrowTypeError(); |
| 25 | if (thrower != null) { |
| 26 | defineOwnProperty(null, "caller", |
| 27 | PropertyDescriptor.newAccessorPropertyDescriptor(thrower, thrower), false); |
| 28 | defineOwnProperty(null, "arguments", |
| 29 | PropertyDescriptor.newAccessorPropertyDescriptor(thrower, thrower), true); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | setPrototype(globalContext.getPrototypeFor("Function")); |
| 34 | } |
| 35 | |
| 36 | public LexicalEnvironment getScope() { |
| 37 | return this.scope; |
| 38 | } |
| 39 | |
| 40 | public void setScope(LexicalEnvironment scope) { |
| 41 | this.scope = scope; |
| 42 | } |
| 43 | |
| 44 | public boolean isStrict() { |
| 45 | return this.strict; |
| 46 | } |
| 47 | |
| 48 | public boolean isConstructor() { |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public String[] getFormalParameters() { |
| 54 | return this.formalParameters; |
| 55 | } |
| 56 | |
| 57 | protected void setFormalParamters(String[] formalParameters) { |
| 58 | this.formalParameters = formalParameters; |
| 59 | } |
| 60 | |
| 61 | // ------------------------------------------------------------------------ |
| 62 | // ------------------------------------------------------------------------ |
nothing calls this directly
no outgoing calls
no test coverage detected