Exemple #1
0
 internal void CheckCLSCompliance(bool classIsCLSCompliant)
 {
     if (this.customAttributes != null)
     {
         CustomAttribute clsAttr = this.customAttributes.GetAttribute(Typeob.CLSCompliantAttribute);
         if (clsAttr != null)
         {
             this.clsCompliance = clsAttr.GetCLSComplianceValue();
             this.customAttributes.Remove(clsAttr);
         }
     }
     if (classIsCLSCompliant)
     {
         if (this.clsCompliance != CLSComplianceSpec.NonCLSCompliant)
         {
             if (type != null && !type.IsCLSCompliant())
             {
                 this.clsCompliance = CLSComplianceSpec.NonCLSCompliant;
                 if (this.originalContext != null)
                 {
                     this.originalContext.HandleError(JSError.NonCLSCompliantMember);
                 }
             }
         }
     }
     else if (this.clsCompliance == CLSComplianceSpec.CLSCompliant)
     {
         this.originalContext.HandleError(JSError.MemberTypeCLSCompliantMismatch);
     }
 }
Exemple #2
0
 internal void CheckCLSCompliance(bool classIsCLSCompliant)
 {
     if (this.customAttributes != null)
     {
         Microsoft.JScript.CustomAttribute elem = this.customAttributes.GetAttribute(Typeob.CLSCompliantAttribute);
         if (elem != null)
         {
             this.clsCompliance = elem.GetCLSComplianceValue();
             this.customAttributes.Remove(elem);
         }
     }
     if (classIsCLSCompliant)
     {
         if (((this.clsCompliance != CLSComplianceSpec.NonCLSCompliant) && (this.type != null)) && !this.type.IsCLSCompliant())
         {
             this.clsCompliance = CLSComplianceSpec.NonCLSCompliant;
             if (this.originalContext != null)
             {
                 this.originalContext.HandleError(JSError.NonCLSCompliantMember);
             }
         }
     }
     else if (this.clsCompliance == CLSComplianceSpec.CLSCompliant)
     {
         this.originalContext.HandleError(JSError.MemberTypeCLSCompliantMismatch);
     }
 }
 internal FunctionObject(Type t, string name, string method_name, string[] formal_parameters, JSLocalField[] fields, bool must_save_stack_locals, bool hasArgumentsObject, string text, VsaEngine engine) : base(engine.Globals.globalObject.originalFunction.originalPrototype, name, formal_parameters.Length)
 {
     base.engine = engine;
     this.formal_parameters = formal_parameters;
     this.argumentsSlotNumber = 0;
     this.body = null;
     this.method = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(t)).GetMethod(method_name, BindingFlags.Public | BindingFlags.Static);
     this.parameterInfos = this.method.GetParameters();
     if (!Microsoft.JScript.CustomAttribute.IsDefined(this.method, typeof(JSFunctionAttribute), false))
     {
         this.isMethod = true;
     }
     else
     {
         JSFunctionAttributeEnum attributeValue = ((JSFunctionAttribute) Microsoft.JScript.CustomAttribute.GetCustomAttributes(this.method, typeof(JSFunctionAttribute), false)[0]).attributeValue;
         this.isExpandoMethod = (attributeValue & JSFunctionAttributeEnum.IsExpandoMethod) != JSFunctionAttributeEnum.None;
     }
     this.funcContext = null;
     this.own_scope = null;
     this.fields = fields;
     this.must_save_stack_locals = must_save_stack_locals;
     this.hasArgumentsObject = hasArgumentsObject;
     this.text = text;
     this.attributes = MethodAttributes.Public;
     this.globals = engine.Globals;
     this.superConstructor = null;
     this.superConstructorCall = null;
     this.enclosing_scope = this.globals.ScopeStack.Peek();
     base.noExpando = false;
     this.clsCompliance = CLSComplianceSpec.NotAttributed;
 }
 internal void CheckCLSCompliance(bool classIsCLSCompliant)
 {
     if (this.customAttributes != null)
     {
         Microsoft.JScript.CustomAttribute elem = this.customAttributes.GetAttribute(Typeob.CLSCompliantAttribute);
         if (elem != null)
         {
             this.clsCompliance = elem.GetCLSComplianceValue();
             this.customAttributes.Remove(elem);
         }
     }
     if (classIsCLSCompliant)
     {
         if (((this.clsCompliance != CLSComplianceSpec.NonCLSCompliant) && (this.type != null)) && !this.type.IsCLSCompliant())
         {
             this.clsCompliance = CLSComplianceSpec.NonCLSCompliant;
             if (this.originalContext != null)
             {
                 this.originalContext.HandleError(JSError.NonCLSCompliantMember);
             }
         }
     }
     else if (this.clsCompliance == CLSComplianceSpec.CLSCompliant)
     {
         this.originalContext.HandleError(JSError.MemberTypeCLSCompliantMismatch);
     }
 }
 internal JSVariableField(String name, ScriptObject obj, FieldAttributes attributeFlags){
   this.obj = obj;
   this.name = name;
   this.debuggerName = name;
   this.metaData = null;
   if ((attributeFlags & FieldAttributes.FieldAccessMask) == (FieldAttributes)0)
     attributeFlags |= FieldAttributes.Public; //Fields not marked otherwise, are public
   this.attributeFlags = attributeFlags;
   this.type = null;
   this.method = null;
   this.cons = null;
   this.value = null;
   this.originalContext = null;
   this.clsCompliance = CLSComplianceSpec.NotAttributed;
 }
Exemple #6
0
 internal JSVariableField(string name, ScriptObject obj, FieldAttributes attributeFlags)
 {
     this.obj          = obj;
     this.name         = name;
     this.debuggerName = name;
     this.metaData     = null;
     if ((attributeFlags & FieldAttributes.FieldAccessMask) == FieldAttributes.PrivateScope)
     {
         attributeFlags |= FieldAttributes.Public;
     }
     this.attributeFlags  = attributeFlags;
     this.type            = null;
     this.method          = null;
     this.value           = null;
     this.originalContext = null;
     this.clsCompliance   = CLSComplianceSpec.NotAttributed;
 }
 internal JSVariableField(string name, ScriptObject obj, FieldAttributes attributeFlags)
 {
     this.obj = obj;
     this.name = name;
     this.debuggerName = name;
     this.metaData = null;
     if ((attributeFlags & FieldAttributes.FieldAccessMask) == FieldAttributes.PrivateScope)
     {
         attributeFlags |= FieldAttributes.Public;
     }
     this.attributeFlags = attributeFlags;
     this.type = null;
     this.method = null;
     this.value = null;
     this.originalContext = null;
     this.clsCompliance = CLSComplianceSpec.NotAttributed;
 }
Exemple #8
0
 internal JSVariableField(String name, ScriptObject obj, FieldAttributes attributeFlags)
 {
     this.obj          = obj;
     this.name         = name;
     this.debuggerName = name;
     this.metaData     = null;
     if ((attributeFlags & FieldAttributes.FieldAccessMask) == (FieldAttributes)0)
     {
         attributeFlags |= FieldAttributes.Public; //Fields not marked otherwise, are public
     }
     this.attributeFlags  = attributeFlags;
     this.type            = null;
     this.method          = null;
     this.cons            = null;
     this.value           = null;
     this.originalContext = null;
     this.clsCompliance   = CLSComplianceSpec.NotAttributed;
 }
 internal void CheckCLSCompliance(bool classIsCLSCompliant){
   if (this.customAttributes != null){
     CustomAttribute clsAttr = this.customAttributes.GetAttribute(Typeob.CLSCompliantAttribute);
     if (clsAttr != null){
       this.clsCompliance = clsAttr.GetCLSComplianceValue();
       this.customAttributes.Remove(clsAttr);
     }
   }
   if (classIsCLSCompliant){
     if (this.clsCompliance != CLSComplianceSpec.NonCLSCompliant)
       if (type != null && !type.IsCLSCompliant()){
         this.clsCompliance = CLSComplianceSpec.NonCLSCompliant;
         if (this.originalContext != null)
           this.originalContext.HandleError(JSError.NonCLSCompliantMember);
       }
   }else if (this.clsCompliance == CLSComplianceSpec.CLSCompliant)
     this.originalContext.HandleError(JSError.MemberTypeCLSCompliantMismatch);
 }
Exemple #10
0
 internal Class(Context context, AST id, TypeExpression superTypeExpression, TypeExpression[] interfaces, Block body, 
   FieldAttributes attributes, bool isAbstract, bool isFinal, bool isStatic, bool isInterface, CustomAttributeList customAttributes)
   : base(context) {
   this.name = id.ToString();
   this.superTypeExpression = superTypeExpression;
   this.interfaces = interfaces;
   this.body = body;
   this.enclosingScope = (ScriptObject)Globals.ScopeStack.Peek(1);
   this.attributes = TypeAttributes.Class|TypeAttributes.Serializable;
   this.SetAccessibility(attributes);
   if (isAbstract)
     this.attributes |= TypeAttributes.Abstract;
   this.isAbstract = isAbstract || isInterface;
   this.isAlreadyPartiallyEvaluated = false;
   if (isFinal)
     this.attributes |= TypeAttributes.Sealed;
   if (isInterface)
     this.attributes |= TypeAttributes.Interface | TypeAttributes.Abstract;
   this.isCooked = false;
   this.cookedType = null;
   this.isExpando = false;
   this.isInterface = isInterface;
   this.isStatic = isStatic;
   this.needsEngine = !isInterface;
   this.validOn = (AttributeTargets)0;
   this.allowMultiple = true;
   this.classob = (ClassScope)Globals.ScopeStack.Peek();
   this.classob.name = this.name;
   this.classob.owner = this;
   this.implicitDefaultConstructor = null;
   if (!isInterface && !(this is EnumDeclaration))
     this.SetupConstructors();
   this.EnterNameIntoEnclosingScopeAndGetOwnField(id, isStatic);
   this.fields = this.classob.GetMemberFields();
   this.superClass = null;
   this.superIR = null;
   this.superMembers = null;
   this.firstIndex = null;
   this.fieldInitializer = null;
   this.customAttributes = customAttributes;
   this.clsCompliance = CLSComplianceSpec.NotAttributed;
   this.generateCodeForExpando = false;
   this.expandoItemProp = null;
   this.getHashTableMethod = null;
   this.getItem = null;
   this.setItem = null;
 }
Exemple #11
0
 protected bool NeedsToBeCheckedForCLSCompliance(){
   bool result = false;
   this.clsCompliance = CLSComplianceSpec.NotAttributed;
   if (this.customAttributes != null){
     CustomAttribute clsAttr = this.customAttributes.GetAttribute(Typeob.CLSCompliantAttribute);
     if (clsAttr != null){
       this.clsCompliance = clsAttr.GetCLSComplianceValue();
       result = this.clsCompliance == CLSComplianceSpec.CLSCompliant;
       this.customAttributes.Remove(clsAttr);
     }
   }
   if (this.clsCompliance == CLSComplianceSpec.CLSCompliant && !this.Engine.isCLSCompliant)
     this.context.HandleError(JSError.TypeAssemblyCLSCompliantMismatch);
   if (this.clsCompliance == CLSComplianceSpec.NotAttributed && (this.attributes & TypeAttributes.Public) != 0)
     result = Engine.isCLSCompliant;
   return result;
 }
 internal FunctionObject(string name, ParameterDeclaration[] parameter_declarations, TypeExpression return_type_expr, Block body, FunctionScope own_scope, ScriptObject enclosing_scope, Context funcContext, MethodAttributes attributes, CustomAttributeList customAttributes, bool isMethod) : base(body.Globals.globalObject.originalFunction.originalPrototype, name, parameter_declarations.Length)
 {
     this.parameter_declarations = parameter_declarations;
     int length = parameter_declarations.Length;
     this.formal_parameters = new string[length];
     for (int i = 0; i < length; i++)
     {
         this.formal_parameters[i] = parameter_declarations[i].identifier;
     }
     this.argumentsSlotNumber = 0;
     this.return_type_expr = return_type_expr;
     if (this.return_type_expr != null)
     {
         own_scope.AddReturnValueField();
     }
     this.body = body;
     this.method = null;
     this.parameterInfos = null;
     this.funcContext = funcContext;
     this.own_scope = own_scope;
     this.own_scope.owner = this;
     if ((!(enclosing_scope is ActivationObject) || !((ActivationObject) enclosing_scope).fast) && !isMethod)
     {
         this.argumentsSlotNumber = this.own_scope.GetNextSlotNumber();
         JSLocalField field = (JSLocalField) this.own_scope.AddNewField("arguments", null, FieldAttributes.PrivateScope);
         field.type = new TypeExpression(new ConstantWrapper(Typeob.Object, funcContext));
         field.isDefined = true;
         this.hasArgumentsObject = true;
     }
     else
     {
         this.hasArgumentsObject = false;
     }
     this.implementedIface = null;
     this.implementedIfaceMethod = null;
     this.isMethod = isMethod;
     this.isExpandoMethod = (customAttributes != null) && customAttributes.ContainsExpandoAttribute();
     this.isStatic = this.own_scope.isStatic = (attributes & MethodAttributes.Static) != MethodAttributes.PrivateScope;
     this.suppressIL = false;
     this.noVersionSafeAttributeSpecified = true;
     this.fields = this.own_scope.GetLocalFields();
     this.enclosing_scope = enclosing_scope;
     this.must_save_stack_locals = false;
     this.text = null;
     this.mb = null;
     this.cb = null;
     this.attributes = attributes;
     if (!this.isStatic)
     {
         this.attributes |= MethodAttributes.HideBySig;
     }
     this.globals = body.Globals;
     this.superConstructor = null;
     this.superConstructorCall = null;
     this.customAttributes = customAttributes;
     base.noExpando = false;
     this.clsCompliance = CLSComplianceSpec.NotAttributed;
     this.engineLocal = null;
     this.partiallyEvaluated = false;
 }
 internal void PartiallyEvaluate()
 {
     if (!this.partiallyEvaluated)
     {
         ClassScope scope = this.enclosing_scope as ClassScope;
         if (scope != null)
         {
             scope.owner.PartiallyEvaluate();
         }
         if (!this.partiallyEvaluated)
         {
             this.partiallyEvaluated = true;
             this.clsCompliance = CLSComplianceSpec.NotAttributed;
             if (this.customAttributes != null)
             {
                 this.customAttributes.PartiallyEvaluate();
                 Microsoft.JScript.CustomAttribute elem = this.customAttributes.GetAttribute(Typeob.CLSCompliantAttribute);
                 if (elem != null)
                 {
                     this.clsCompliance = elem.GetCLSComplianceValue();
                     this.customAttributes.Remove(elem);
                 }
                 elem = this.customAttributes.GetAttribute(Typeob.Override);
                 if (elem != null)
                 {
                     if (this.isStatic)
                     {
                         elem.context.HandleError(JSError.StaticMethodsCannotOverride);
                     }
                     else
                     {
                         this.attributes &= ~MethodAttributes.NewSlot;
                     }
                     this.noVersionSafeAttributeSpecified = false;
                     this.customAttributes.Remove(elem);
                 }
                 elem = this.customAttributes.GetAttribute(Typeob.Hide);
                 if (elem != null)
                 {
                     if (!this.noVersionSafeAttributeSpecified)
                     {
                         elem.context.HandleError(JSError.OverrideAndHideUsedTogether);
                         this.attributes |= MethodAttributes.NewSlot;
                         this.noVersionSafeAttributeSpecified = true;
                     }
                     else
                     {
                         if (this.isStatic)
                         {
                             elem.context.HandleError(JSError.StaticMethodsCannotHide);
                         }
                         this.noVersionSafeAttributeSpecified = false;
                     }
                     this.customAttributes.Remove(elem);
                 }
                 Microsoft.JScript.CustomAttribute attribute = this.customAttributes.GetAttribute(Typeob.Expando);
                 if (attribute != null)
                 {
                     if (!this.noVersionSafeAttributeSpecified && ((this.attributes & MethodAttributes.NewSlot) == MethodAttributes.PrivateScope))
                     {
                         attribute.context.HandleError(JSError.ExpandoPrecludesOverride);
                         this.attributes |= MethodAttributes.NewSlot;
                         this.noVersionSafeAttributeSpecified = true;
                     }
                     if (this.isConstructor)
                     {
                         attribute.context.HandleError(JSError.NotValidForConstructor);
                     }
                     else if ((this.attributes & MethodAttributes.Abstract) != MethodAttributes.PrivateScope)
                     {
                         attribute.context.HandleError(JSError.ExpandoPrecludesAbstract);
                     }
                     else if ((this.attributes & MethodAttributes.Static) != MethodAttributes.PrivateScope)
                     {
                         attribute.context.HandleError(JSError.ExpandoPrecludesStatic);
                     }
                     else if ((this.attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public)
                     {
                         attribute.context.HandleError(JSError.ExpandoMustBePublic);
                     }
                     else
                     {
                         this.own_scope.isMethod = false;
                         this.isMethod = false;
                         this.isExpandoMethod = true;
                         this.isStatic = true;
                         this.attributes &= ~MethodAttributes.Virtual;
                         this.attributes &= ~MethodAttributes.NewSlot;
                         this.attributes |= MethodAttributes.Static;
                     }
                 }
             }
             int index = 0;
             int length = this.parameter_declarations.Length;
             while (index < length)
             {
                 this.parameter_declarations[index].PartiallyEvaluate();
                 JSLocalField field = (JSLocalField) this.own_scope.name_table[this.formal_parameters[index]];
                 field.type = this.parameter_declarations[index].type;
                 if (field.type == null)
                 {
                     field.type = new TypeExpression(new ConstantWrapper(Typeob.Object, this.parameter_declarations[index].context));
                 }
                 field.isDefined = true;
                 index++;
             }
             if (this.return_type_expr != null)
             {
                 this.return_type_expr.PartiallyEvaluate();
                 this.own_scope.returnVar.type = this.return_type_expr;
                 if (this.own_scope.returnVar.type.ToIReflect() == Typeob.Void)
                 {
                     this.own_scope.returnVar.type = null;
                     this.own_scope.returnVar = null;
                 }
             }
             this.globals.ScopeStack.Push(this.own_scope);
             if (!this.own_scope.isKnownAtCompileTime)
             {
                 int num3 = 0;
                 int num4 = this.fields.Length;
                 while (num3 < num4)
                 {
                     this.fields[num3].SetInferredType(Typeob.Object, null);
                     num3++;
                 }
             }
             if (!this.isConstructor)
             {
                 this.body.PartiallyEvaluate();
             }
             else
             {
                 this.body.MarkSuperOKIfIsFirstStatement();
                 this.body.PartiallyEvaluate();
                 ClassScope scope2 = (ClassScope) this.enclosing_scope;
                 int num5 = (this.superConstructorCall == null) ? 0 : this.superConstructorCall.arguments.count;
                 if (num5 == 0)
                 {
                     Type[] emptyTypes = Type.EmptyTypes;
                 }
                 IReflect[] argIRs = new IReflect[num5];
                 for (int i = 0; i < num5; i++)
                 {
                     argIRs[i] = this.superConstructorCall.arguments[i].InferType(null);
                 }
                 Context context = (this.superConstructorCall == null) ? this.funcContext : this.superConstructorCall.context;
                 try
                 {
                     if ((this.superConstructorCall != null) && !this.superConstructorCall.isSuperConstructorCall)
                     {
                         this.superConstructor = JSBinder.SelectConstructor(scope2.constructors, argIRs);
                     }
                     else
                     {
                         this.superConstructor = scope2.owner.GetSuperConstructor(argIRs);
                     }
                     if (this.superConstructor == null)
                     {
                         context.HandleError(JSError.SuperClassConstructorNotAccessible);
                     }
                     else
                     {
                         ConstructorInfo superConstructor = this.superConstructor;
                         if (((!superConstructor.IsPublic && !superConstructor.IsFamily) && !superConstructor.IsFamilyOrAssembly) && (!(this.superConstructor is JSConstructor) || !((JSConstructor) this.superConstructor).IsAccessibleFrom(this.enclosing_scope)))
                         {
                             context.HandleError(JSError.SuperClassConstructorNotAccessible);
                             this.superConstructor = null;
                         }
                         else if ((num5 > 0) && !Binding.CheckParameters(superConstructor.GetParameters(), argIRs, this.superConstructorCall.arguments, this.superConstructorCall.context))
                         {
                             this.superConstructor = null;
                         }
                     }
                 }
                 catch (AmbiguousMatchException)
                 {
                     context.HandleError(JSError.AmbiguousConstructorCall);
                 }
             }
             this.own_scope.HandleUnitializedVariables();
             this.globals.ScopeStack.Pop();
             this.must_save_stack_locals = this.own_scope.mustSaveStackLocals;
             this.fields = this.own_scope.GetLocalFields();
         }
     }
 }
 internal void CheckCLSCompliance(bool classIsCLSCompliant)
 {
     if (classIsCLSCompliant)
     {
         if (this.clsCompliance != CLSComplianceSpec.NonCLSCompliant)
         {
             int index = 0;
             int length = this.parameter_declarations.Length;
             while (index < length)
             {
                 IReflect parameterIReflect = this.parameter_declarations[index].ParameterIReflect;
                 if ((parameterIReflect != null) && !TypeExpression.TypeIsCLSCompliant(parameterIReflect))
                 {
                     this.clsCompliance = CLSComplianceSpec.NonCLSCompliant;
                     this.funcContext.HandleError(JSError.NonCLSCompliantMember);
                     return;
                 }
                 index++;
             }
             if ((this.return_type_expr != null) && !this.return_type_expr.IsCLSCompliant())
             {
                 this.clsCompliance = CLSComplianceSpec.NonCLSCompliant;
                 this.funcContext.HandleError(JSError.NonCLSCompliantMember);
             }
         }
     }
     else if (this.clsCompliance == CLSComplianceSpec.CLSCompliant)
     {
         this.funcContext.HandleError(JSError.MemberTypeCLSCompliantMismatch);
     }
 }
Exemple #15
0
 internal void PartiallyEvaluate(){
   if (this.partiallyEvaluated)
     return;
   this.partiallyEvaluated = true;
   // deal with custom attributes
   this.clsCompliance = CLSComplianceSpec.NotAttributed;
   if (this.customAttributes != null){
     this.customAttributes.PartiallyEvaluate();
     CustomAttribute clsAttr = this.customAttributes.GetAttribute(Typeob.CLSCompliantAttribute);
     if (clsAttr != null){
       this.clsCompliance = clsAttr.GetCLSComplianceValue();
       this.customAttributes.Remove(clsAttr);
     }
     clsAttr = this.customAttributes.GetAttribute(typeof(Override));
     if (clsAttr != null){
       if (this.isStatic)
         clsAttr.context.HandleError(JSError.StaticMethodsCannotOverride);
       else
         this.attributes &= ~MethodAttributes.NewSlot;
       this.noVersionSafeAttributeSpecified = false;
       this.customAttributes.Remove(clsAttr);
     }
     clsAttr = this.customAttributes.GetAttribute(typeof(Hide));
     if (clsAttr != null){
       if (!this.noVersionSafeAttributeSpecified){
         clsAttr.context.HandleError(JSError.OverrideAndHideUsedTogether);
         this.attributes |= MethodAttributes.NewSlot;
         this.noVersionSafeAttributeSpecified = true;
       }else{
         if (this.isStatic)
           clsAttr.context.HandleError(JSError.StaticMethodsCannotHide);
         this.noVersionSafeAttributeSpecified = false;
       }
       this.customAttributes.Remove(clsAttr);
     }
     CustomAttribute expAttr = this.customAttributes.GetAttribute(typeof(Expando));
     if (expAttr != null){
       if (!this.noVersionSafeAttributeSpecified && (this.attributes & MethodAttributes.NewSlot) == 0){
         expAttr.context.HandleError(JSError.ExpandoPrecludesOverride);
         this.attributes |= MethodAttributes.NewSlot;
         this.noVersionSafeAttributeSpecified = true;
       }
       if (this.isConstructor)
         expAttr.context.HandleError(JSError.NotValidForConstructor);
       else if ((this.attributes & MethodAttributes.Abstract) != 0)
         expAttr.context.HandleError(JSError.ExpandoPrecludesAbstract);
       else if ((this.attributes & MethodAttributes.Static) != 0)
         expAttr.context.HandleError(JSError.ExpandoPrecludesStatic);
       else if ((this.attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public)
         expAttr.context.HandleError(JSError.ExpandoMustBePublic);
       else{
         this.own_scope.isMethod = false;
         this.isMethod = false;
         this.isExpandoMethod = true;
         this.isStatic = true;
         this.attributes &= ~MethodAttributes.Virtual;
         this.attributes &= ~MethodAttributes.NewSlot;
         this.attributes |= MethodAttributes.Static;
       }
     }
   }
   for (int i = 0, n = this.parameter_declarations.Length; i < n; i++){
     this.parameter_declarations[i].PartiallyEvaluate();
     JSLocalField pfield = (JSLocalField)this.own_scope.name_table[this.formal_parameters[i]];
     pfield.type = this.parameter_declarations[i].type;
     if (pfield.type == null)
       pfield.type = new TypeExpression(new ConstantWrapper(Typeob.Object, this.parameter_declarations[i].context));
     pfield.isDefined = true;
   }
   if (this.return_type_expr != null){
     this.return_type_expr.PartiallyEvaluate();
     this.own_scope.returnVar.type = this.return_type_expr;
     if (this.own_scope.returnVar.type.ToIReflect() == Typeob.Void){
       this.own_scope.returnVar.type = null;
       this.own_scope.returnVar = null; //This does not completely get rid of the returnVar value, but acts as flag, hence the above.
     }
   }
   globals.ScopeStack.Push(this.own_scope);
   if (!this.own_scope.isKnownAtCompileTime) //Function contains an eval. Type inference is impossible for local vars
     for (int i = 0, n = this.fields.Length; i < n; i++)
       this.fields[i].SetInferredType(Typeob.Object, null);
   if (!this.isConstructor)
     this.body.PartiallyEvaluate();
   else{
     this.body.MarkSuperOKIfIsFirstStatement();
     this.body.PartiallyEvaluate(); //super constructor calls that have not been marked OK will generate errors
     ClassScope cscope = (ClassScope)this.enclosing_scope;
     int n = this.superConstructorCall == null ? 0 : this.superConstructorCall.arguments.count;
     Type[] argTypes = n == 0 ? Type.EmptyTypes : new Type[n];
     IReflect[] argIRs = new IReflect[n];
     for (int i = 0; i < n; i++)
       argIRs[i] = this.superConstructorCall.arguments[i].InferType(null);
     Context errorContext = this.superConstructorCall == null ? this.funcContext : this.superConstructorCall.context;
     try{
       if (this.superConstructorCall != null && !this.superConstructorCall.isSuperConstructorCall)
         this.superConstructor = JSBinder.SelectConstructor(cscope.constructors, argIRs);
       else
         this.superConstructor = cscope.owner.GetSuperConstructor(argIRs);
       if (this.superConstructor == null)
         errorContext.HandleError(JSError.SuperClassConstructorNotAccessible);
       else{
         ConstructorInfo cons = (ConstructorInfo)this.superConstructor;
         if (!cons.IsPublic && !cons.IsFamily && 
           !(this.superConstructor is JSConstructor && ((JSConstructor)this.superConstructor).IsAccessibleFrom(this.enclosing_scope))){
           errorContext.HandleError(JSError.SuperClassConstructorNotAccessible);
             this.superConstructor = null;
         }else if (n > 0)
           if (!Binding.CheckParameters(cons.GetParameters(), argIRs, this.superConstructorCall.arguments, this.superConstructorCall.context))
             this.superConstructor = null;
       }
     }catch(AmbiguousMatchException){
       errorContext.HandleError(JSError.AmbiguousConstructorCall);
     }  
   }
   this.own_scope.HandleUnitializedVariables();
   globals.ScopeStack.Pop();
   this.must_save_stack_locals = this.own_scope.mustSaveStackLocals;
   this.fields = this.own_scope.GetLocalFields();
 }      
Exemple #16
0
      //assume this code is called after PartiallyEvaluate
      internal void CheckCLSCompliance(bool classIsCLSCompliant){
        if (classIsCLSCompliant){
          if (this.clsCompliance != CLSComplianceSpec.NonCLSCompliant){
            for (int i = 0, length = this.parameter_declarations.Length; i < length; i++){
              IReflect ir  = this.parameter_declarations[i].ParameterIReflect;
              if (ir != null && !TypeExpression.TypeIsCLSCompliant(ir)){
                this.clsCompliance = CLSComplianceSpec.NonCLSCompliant;
                this.funcContext.HandleError(JSError.NonCLSCompliantMember);
                return;
              }
            }
            if (this.return_type_expr != null && !this.return_type_expr.IsCLSCompliant()){
              this.clsCompliance = CLSComplianceSpec.NonCLSCompliant;
              this.funcContext.HandleError(JSError.NonCLSCompliantMember);
            }
          }
        }else if (this.clsCompliance == CLSComplianceSpec.CLSCompliant)
          this.funcContext.HandleError(JSError.MemberTypeCLSCompliantMismatch);

      }