internal BuiltinFunction(string name, object obj, MethodInfo method, ScriptFunction parent) : base(parent, name) { base.noExpando = false; ParameterInfo[] parameters = method.GetParameters(); base.ilength = parameters.Length; object[] objArray = Microsoft.JScript.CustomAttribute.GetCustomAttributes(method, typeof(JSFunctionAttribute), false); JSFunctionAttribute attribute = (objArray.Length > 0) ? ((JSFunctionAttribute)objArray[0]) : new JSFunctionAttribute(JSFunctionAttributeEnum.None); JSFunctionAttributeEnum attributeValue = attribute.attributeValue; if ((attributeValue & JSFunctionAttributeEnum.HasThisObject) != JSFunctionAttributeEnum.None) { base.ilength--; } if ((attributeValue & JSFunctionAttributeEnum.HasEngine) != JSFunctionAttributeEnum.None) { base.ilength--; } if ((attributeValue & JSFunctionAttributeEnum.HasVarArgs) != JSFunctionAttributeEnum.None) { base.ilength--; } this.biFunc = attribute.builtinFunction; if (this.biFunc == JSBuiltin.None) { this.method = new JSNativeMethod(method, obj, base.engine); } else { this.method = null; } }
// Constructor. public BuiltinFunction(ScriptObject prototype, String name, MethodInfo method) : base(prototype, name) { this.method = method; Object[] attrs = method.GetCustomAttributes (typeof(JSFunctionAttribute), false); if(attrs == null || attrs.Length == 0) { this.flags = (JSFunctionAttributeEnum)0; } else { this.flags = ((JSFunctionAttribute)(attrs[0])) .GetAttributeValue(); } requiredParameters = method.GetParameters().Length; lengthValue = requiredParameters; if((flags & JSFunctionAttributeEnum.HasThisObject) != 0) { --lengthValue; } if((flags & JSFunctionAttributeEnum.HasEngine) != 0) { --lengthValue; } if((flags & JSFunctionAttributeEnum.HasVarArgs) != 0) { --lengthValue; } }
internal BuiltinFunction(String name, Object obj, MethodInfo method, ScriptFunction parent) : base(parent, name) { this.noExpando = false; ParameterInfo[] pars = method.GetParameters(); int n = this.ilength = pars.Length; Object[] attrs = CustomAttribute.GetCustomAttributes(method, typeof(JSFunctionAttribute), false); JSFunctionAttribute attr = attrs.Length > 0 ? (JSFunctionAttribute)attrs[0] : new JSFunctionAttribute((JSFunctionAttributeEnum)0); JSFunctionAttributeEnum attrVal = attr.attributeValue; if ((attrVal & JSFunctionAttributeEnum.HasThisObject) != 0) { this.ilength--; } if ((attrVal & JSFunctionAttributeEnum.HasEngine) != 0) { this.ilength--; } if ((attrVal & JSFunctionAttributeEnum.HasVarArgs) != 0) { this.ilength--; } this.biFunc = attr.builtinFunction; if (this.biFunc == 0) { this.method = new JSNativeMethod(method, obj, this.engine); } else { this.method = null; } }
// Constructor. public BuiltinFunction(ScriptObject prototype, String name, MethodInfo method) : base(prototype, name) { this.method = method; Object[] attrs = method.GetCustomAttributes (typeof(JSFunctionAttribute), false); if (attrs == null || attrs.Length == 0) { this.flags = (JSFunctionAttributeEnum)0; } else { this.flags = ((JSFunctionAttribute)(attrs[0])) .GetAttributeValue(); } requiredParameters = method.GetParameters().Length; lengthValue = requiredParameters; if ((flags & JSFunctionAttributeEnum.HasThisObject) != 0) { --lengthValue; } if ((flags & JSFunctionAttributeEnum.HasEngine) != 0) { --lengthValue; } if ((flags & JSFunctionAttributeEnum.HasVarArgs) != 0) { --lengthValue; } }
internal void set_function_type() { if (parent == null || parent.GetType() == typeof(ScriptBlock)) { func_type = JSFunctionAttributeEnum.ClassicFunction; } else if (parent is FunctionDeclaration) { func_type = JSFunctionAttributeEnum.NestedFunction; } }
internal static bool Needs(JSFunctionAttributeEnum targetAttr, MethodInfo method) { JSFunctionAttribute [] custom_attrs = (JSFunctionAttribute []) method.GetCustomAttributes(typeof(JSFunctionAttribute), true); foreach (JSFunctionAttribute attr in custom_attrs) { if ((attr.GetAttributeValue() & targetAttr) != 0) { return(true); } } return(false); }
internal static void GetMethodFlags(MethodInfo method, out bool has_engine, out bool has_var_args, out bool has_this) { // // Very hackish. It would be better if the // anonymous methods could be decorated with the right attributes. // if (method.DeclaringType.IsSubclassOf(typeof(GlobalScope))) { has_engine = true; has_var_args = false; has_this = true; return; } JSFunctionAttribute [] custom_attrs = (JSFunctionAttribute []) method.GetCustomAttributes(typeof(JSFunctionAttribute), true); // // We need to iterate through the JSFunctionAttributes to find out whether the function wants // to get passed the vsaEngine or not so we can pass the right arguments to it. // has_engine = false; has_var_args = false; has_this = false; foreach (JSFunctionAttribute attr in custom_attrs) { JSFunctionAttributeEnum flags = attr.GetAttributeValue(); if ((flags & JSFunctionAttributeEnum.HasEngine) != 0) { has_engine = true; } if ((flags & JSFunctionAttributeEnum.HasVarArgs) != 0) { has_var_args = true; } if ((flags & JSFunctionAttributeEnum.HasThisObject) != 0) { has_this = true; } } }
internal JSNativeMethod(MethodInfo method, object obj, VsaEngine engine) : base(obj) { this.method = method; this.formalParams = method.GetParameters(); object[] objArray = Microsoft.JScript.CustomAttribute.GetCustomAttributes(method, typeof(JSFunctionAttribute), false); JSFunctionAttribute attribute = (objArray.Length > 0) ? ((JSFunctionAttribute)objArray[0]) : new JSFunctionAttribute(JSFunctionAttributeEnum.None); JSFunctionAttributeEnum attributeValue = attribute.attributeValue; if ((attributeValue & JSFunctionAttributeEnum.HasThisObject) != JSFunctionAttributeEnum.None) { this.hasThis = true; } if ((attributeValue & JSFunctionAttributeEnum.HasEngine) != JSFunctionAttributeEnum.None) { this.hasEngine = true; } if ((attributeValue & JSFunctionAttributeEnum.HasVarArgs) != JSFunctionAttributeEnum.None) { this.hasVarargs = true; } this.engine = engine; }
internal JSNativeMethod(MethodInfo method, Object obj, VsaEngine engine) : base(obj) { this.method = method; this.formalParams = method.GetParameters(); Object[] attrs = CustomAttribute.GetCustomAttributes(method, typeof(JSFunctionAttribute), false); JSFunctionAttribute attr = attrs.Length > 0 ? (JSFunctionAttribute)attrs[0] : new JSFunctionAttribute((JSFunctionAttributeEnum)0); JSFunctionAttributeEnum attrVal = attr.attributeValue; if ((attrVal & JSFunctionAttributeEnum.HasThisObject) != 0) { this.hasThis = true; } if ((attrVal & JSFunctionAttributeEnum.HasEngine) != 0) { this.hasEngine = true; } if ((attrVal & JSFunctionAttributeEnum.HasVarArgs) != 0) { this.hasVarargs = true; } this.engine = engine; }
public JSFunctionAttribute(JSFunctionAttributeEnum value, JSBuiltin builtinFunction) { this.attributeValue = value; this.builtinFunction = builtinFunction; }
public JSFunctionAttribute(JSFunctionAttributeEnum value) { this.attributeValue = value; this.builtinFunction = JSBuiltin.None; }
public JSFunctionAttribute(JSFunctionAttributeEnum value, JSBuiltin builtinFunction) { }
// Constructors public JSFunctionAttribute(JSFunctionAttributeEnum value) { }
public JSFunctionAttribute(JSFunctionAttributeEnum value) { this.attributeValue = value; this.builtinFunction = (JSBuiltin)0; }
public JSFunctionAttribute (JSFunctionAttributeEnum value) { this.value = value; this.built_in_function = (JSBuiltin) 0; }
public JSFunctionAttribute(JSFunctionAttributeEnum value, JSBuiltin builtinFunction) {}
internal void set_function_type () { if (parent == null || parent.GetType () == typeof (ScriptBlock)) func_type = JSFunctionAttributeEnum.ClassicFunction; else if (parent is FunctionDeclaration) func_type = JSFunctionAttributeEnum.NestedFunction; }
// Constructors public JSFunctionAttribute(JSFunctionAttributeEnum value) {}
public JSFunctionAttribute(JSFunctionAttributeEnum value) { this.value = value; this.built_in_function = (JSBuiltin)0; }
internal static bool Needs (JSFunctionAttributeEnum targetAttr, MethodInfo method) { JSFunctionAttribute [] custom_attrs = (JSFunctionAttribute []) method.GetCustomAttributes (typeof (JSFunctionAttribute), true); foreach (JSFunctionAttribute attr in custom_attrs) if ((attr.GetAttributeValue () & targetAttr) != 0) return true; return false; }