コード例 #1
0
        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;
            }
        }
コード例 #2
0
	// 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;
				}
			}
コード例 #3
0
        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;
            }
        }
コード例 #4
0
ファイル: BuiltinFunction.cs プロジェクト: ForNeVeR/pnet
 // 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;
     }
 }
コード例 #5
0
ファイル: ast.cs プロジェクト: raj581/Marvin
 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;
     }
 }
コード例 #6
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);
        }
コード例 #7
0
ファイル: LateBinding.cs プロジェクト: retahc/old-code
        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;
                }
            }
        }
コード例 #8
0
        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;
        }
コード例 #9
0
        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;
 }
コード例 #12
0
 public JSFunctionAttribute(JSFunctionAttributeEnum value, JSBuiltin builtinFunction)
 {
 }
コード例 #13
0
 // Constructors
 public JSFunctionAttribute(JSFunctionAttributeEnum value)
 {
 }
コード例 #14
0
ファイル: jsfunctionattribute.cs プロジェクト: ydunk/masters
 public JSFunctionAttribute(JSFunctionAttributeEnum value, JSBuiltin builtinFunction)
 {
     this.attributeValue  = value;
     this.builtinFunction = builtinFunction;
 }
コード例 #15
0
ファイル: jsfunctionattribute.cs プロジェクト: ydunk/masters
 public JSFunctionAttribute(JSFunctionAttributeEnum value)
 {
     this.attributeValue  = value;
     this.builtinFunction = (JSBuiltin)0;
 }
コード例 #16
0
ファイル: JSFunctionAttribute.cs プロジェクト: nickchal/pash
		public JSFunctionAttribute (JSFunctionAttributeEnum value)
		{
			this.value = value;
			this.built_in_function = (JSBuiltin) 0;
		}
コード例 #17
0
	public JSFunctionAttribute(JSFunctionAttributeEnum value, JSBuiltin builtinFunction) {}
コード例 #18
0
ファイル: ast.cs プロジェクト: nickchal/pash
		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;
		}
コード例 #19
0
	// Constructors
	public JSFunctionAttribute(JSFunctionAttributeEnum value) {}
コード例 #20
0
 public JSFunctionAttribute(JSFunctionAttributeEnum value)
 {
     this.value             = value;
     this.built_in_function = (JSBuiltin)0;
 }
コード例 #21
0
ファイル: SemanticAnalizer.cs プロジェクト: nickchal/pash
		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;
		}