Microsoft.JScript.Class.EnterNameIntoEnclosingScopeAndGetOwnField C# (CSharp) Method

EnterNameIntoEnclosingScopeAndGetOwnField() private method

private EnterNameIntoEnclosingScopeAndGetOwnField ( AST id, bool isStatic ) : void
id AST
isStatic bool
return void
      private void EnterNameIntoEnclosingScopeAndGetOwnField(AST id, bool isStatic){
        if (((IActivationObject)this.enclosingScope).GetLocalField(this.name) != null){
          id.context.HandleError(JSError.DuplicateName, true);
          this.name = this.name + " class";
        }
        FieldAttributes fieldAttrs = FieldAttributes.Literal;
        switch (this.attributes & TypeAttributes.VisibilityMask){
          case TypeAttributes.NestedAssembly : fieldAttrs |= FieldAttributes.Assembly; break;
          case TypeAttributes.NestedFamANDAssem : fieldAttrs |= FieldAttributes.FamANDAssem; break;
          case TypeAttributes.NestedFamily : fieldAttrs |= FieldAttributes.Family; break;
          case TypeAttributes.NestedFamORAssem : fieldAttrs |= FieldAttributes.FamORAssem; break;
          case TypeAttributes.NestedPrivate : fieldAttrs |= FieldAttributes.Private; break;
          default: fieldAttrs |= FieldAttributes.Public; break;
        }
        ScriptObject enclScope = this.enclosingScope;
        while (enclScope is BlockScope) enclScope = enclScope.GetParent();
        if (!(enclScope is GlobalScope) && !(enclScope is PackageScope) && !(enclScope is ClassScope)){
          isStatic = false;
          if (this is EnumDeclaration)
            this.context.HandleError(JSError.EnumNotAllowed);
          else
            this.context.HandleError(JSError.ClassNotAllowed);
        }
        if (isStatic) fieldAttrs |= FieldAttributes.Static;
        if (this.enclosingScope is ActivationObject){
          if (this.enclosingScope is ClassScope){
            if (this.name == ((ClassScope)this.enclosingScope).name){
              context.HandleError(JSError.CannotUseNameOfClass);
              this.name = this.name + " nested class";
            }
          }
          this.ownField = ((ActivationObject)this.enclosingScope).AddNewField(this.name, this.classob, fieldAttrs);
          if (this.ownField is JSLocalField)
            ((JSLocalField)this.ownField).isDefined = true;
        }else
          this.ownField = ((StackFrame)this.enclosingScope).AddNewField(this.name, this.classob, fieldAttrs);
        this.ownField.originalContext = id.context;
      }