Beispiel #1
0
        public static FunctionObject FunctionInitialize(FunctionObject f, FunctionCreateKind kind, FormalParameters parameters, FunctionStatementList body, LexicalEnvironment scope)
        {
            var len = parameters.ExpectedArgumentCount();

            f.DefinePropertyOrThrow("length", new PropertyDescriptor(new NumberValue(len), false, false, true));
            f.Environment      = scope;
            f.FormalParameters = parameters;
            f.Code             = body;
            if (kind == FunctionCreateKind.Arrow)
            {
                f.ThisMode = ThisMode.Lexical;
            }
            else if (f.Strict)
            {
                f.ThisMode = ThisMode.Strict;
            }
            else
            {
                f.ThisMode = ThisMode.Global;
            }
            return(f);
        }