public static void InitFunction(Context cx, Scriptable scope, NativeFunction function, int type, bool fromEvalCode) { if (type == FunctionNode.FUNCTION_STATEMENT) { string name = function.GetFunctionName(); if (name != null && name.Length != 0) { if (!fromEvalCode) { // ECMA specifies that functions defined in global and // function scope outside eval should have DONTDELETE set. ScriptableObject.DefineProperty(scope, name, function, ScriptableObject.PERMANENT); } else { scope.Put(name, scope, function); } } } else { if (type == FunctionNode.FUNCTION_EXPRESSION_STATEMENT) { string name = function.GetFunctionName(); if (name != null && name.Length != 0) { // Always put function expression statements into initial // activation object ignoring the with statement to follow // SpiderMonkey while (scope is NativeWith) { scope = scope.GetParentScope(); } scope.Put(name, scope, function); } } else { throw Kit.CodeBug(); } } }