public ChangeNotificationSubscription(Guid iid, string name, ClassKind classKind, ChangeNotificationSubscriptionType changeNotificationSubscriptionType)
 {
     this.Iid       = iid;
     this.Name      = name;
     this.ClassKind = classKind;
     this.ChangeNotificationSubscriptionType = changeNotificationSubscriptionType;
 }
Пример #2
0
        /// <summary>
        /// Returns an instance of <see cref="Image"/> based on the provided <see cref="ClassKind"/>
        /// </summary>
        /// <param name="classKind">
        /// the subject <see cref="ClassKind"/>
        /// </param>
        /// <param name="getsmallicon">
        /// Indicates whether a small or large icon should be returned.
        /// </param>
        /// <returns>
        /// An of <see cref="Image"/> that corresponds to the subject <see cref="ClassKind"/>
        /// </returns>
        public Image GetImage(ClassKind classKind, bool getsmallicon = true)
        {
            Uri imageUri;

            if (IconUtilities.ImageUri(classKind, getsmallicon) is string convertedstring)
            {
                imageUri = new Uri(convertedstring);
                var image  = new BitmapImage(imageUri);
                var bitmap = IconUtilities.BitmapImage2Bitmap(image);
                return(bitmap);
            }

            if (IconUtilities.ImageUri(classKind, getsmallicon) is DXImageExtension convertedDXImageExtension)
            {
                var image = new BitmapImage();
                image.BeginInit();
                image.UriSource = convertedDXImageExtension.Image.MakeUri();
                image.EndInit();

                var bitmap = IconUtilities.BitmapImage2Bitmap(image);
                return(bitmap);
            }

            return(null);
        }
 private string GetImmBldConversion(MetaModel mmodel, MetaType type, ClassKind kind)
 {
     if (kind == ClassKind.BuilderOperation)
     {
         if (type is MetaClass)
         {
             return(".ToMutable()");
         }
         else if (type is MetaCollectionType mct)
         {
             if (mct.InnerType is MetaClass)
             {
                 return(".Select(obj => obj.ToMutable()).ToList()");
             }
         }
     }
     if (kind == ClassKind.ImmutableOperation)
     {
         if (type is MetaClass)
         {
             return(".ToImmutable()");
         }
         else if (type is MetaCollectionType mct)
         {
             if (mct.InnerType is MetaClass)
             {
                 return(".Select(obj => obj.ToImmutable()).ToList()");
             }
         }
     }
     return(string.Empty);
 }
Пример #4
0
        /// <summary>
        /// Resolve the properties of the current <see cref="ParticipantPermission"/> from its <see cref="DTO.Thing"/> counter-part
        /// </summary>
        /// <param name="dtoThing">The source <see cref="DTO.Thing"/></param>
        internal override void ResolveProperties(DTO.Thing dtoThing)
        {
            if (dtoThing == null)
            {
                throw new ArgumentNullException("dtoThing");
            }

            var dto = dtoThing as DTO.ParticipantPermission;

            if (dto == null)
            {
                throw new InvalidOperationException(string.Format("The DTO type {0} does not match the type of the current ParticipantPermission POCO.", dtoThing.GetType()));
            }

            this.AccessRight = dto.AccessRight;
            this.ExcludedDomain.ResolveList(dto.ExcludedDomain, dto.IterationContainerId, this.Cache);
            this.ExcludedPerson.ResolveList(dto.ExcludedPerson, dto.IterationContainerId, this.Cache);
            this.IsDeprecated    = dto.IsDeprecated;
            this.ModifiedOn      = dto.ModifiedOn;
            this.ObjectClass     = dto.ObjectClass;
            this.RevisionNumber  = dto.RevisionNumber;
            this.ThingPreference = dto.ThingPreference;

            this.ResolveExtraProperties();
        }
 public string CSharpName(MetaType mtype, MetaModel mmodel, ClassKind kind = ClassKind.None, bool fullName = false)
 {
     if (mtype == null)
     {
         return(string.Empty);
     }
     if (mtype is MetaPrimitiveType)
     {
         return(this.CSharpName((MetaPrimitiveType)mtype, mmodel, kind, fullName));
     }
     if (mtype is MetaCollectionType)
     {
         return(this.CSharpName((MetaCollectionType)mtype, mmodel, kind, fullName));
     }
     if (mtype is MetaNullableType)
     {
         return(this.CSharpName((MetaNullableType)mtype, mmodel, kind, fullName));
     }
     if (mtype is MetaEnum)
     {
         return(this.CSharpName((MetaEnum)mtype, mmodel, kind, fullName));
     }
     if (mtype is MetaClass)
     {
         return(this.CSharpName((MetaClass)mtype, mmodel, kind, fullName));
     }
     if (mtype is MetaConstant)
     {
         return(this.CSharpName((MetaConstant)mtype, mmodel, kind, fullName));
     }
     return(string.Empty);
 }
        /// <summary>
        /// Assert that the new added container is consistent with the container previously added
        /// </summary>
        /// <param name="lastRoute">container previously added</param>
        /// <param name="newRoute">new container</param>
        /// <returns>true if the new route is consistent with the existing one</returns>
        private bool IsAuthorizedRoute(ClassKind lastRoute, ClassKind newRoute)
        {
            var lastRouteContainerClass = ContainerPropertyHelper.ContainerClassName(lastRoute);

            if (newRoute.ToString() == lastRouteContainerClass)
            {
                return(true);
            }

            // the newRoute may not correspond to the container class because the container class is abstract.
            // Check if the parent of the added container is that abstract class
            var type = Type.GetType("CDP4Common.DTO." + newRoute);

            if (type != null)
            {
                var parent = type.QueryBaseType();
                while (parent != null)
                {
                    if (parent.Name == lastRouteContainerClass)
                    {
                        return(true);
                    }

                    parent = parent.QueryBaseType();
                }
            }

            return(false);
        }
        /// <summary>
        /// Adds a container to the current <see cref="Thing"/>. The containers should be added following the containment
        /// hierarchy starting at the current <see cref="Thing"/>. The last addition shall be either a <see cref="EngineeringModel"/>
        /// or a <see cref="SiteDirectory"/>
        /// </summary>
        /// <param name="classKind">
        /// A <see cref="ClassKind"/> specifying the type of the container that is being added
        /// </param>
        /// <param name="iid">
        /// the unique id of the container that is being added
        /// </param>
        public virtual void AddContainer(ClassKind classKind, Guid iid)
        {
            var lastRouteClassKind = this.partialClassKindRoute.Any()
                ? this.partialClassKindRoute.Last()
                : this.ClassKind;

            switch (lastRouteClassKind)
            {
            case ClassKind.SiteDirectory:
                throw new InvalidOperationException("Cannot add another container, SiteDirectory is a top container");

            case ClassKind.EngineeringModel:
                throw new InvalidOperationException("Cannot add another container, EngineeringModel is a top container");

            default:
            {
                if (this.IsAuthorizedRoute(lastRouteClassKind, classKind))
                {
                    var containerPropertyName = ContainerPropertyHelper.ContainerPropertyName(classKind);
                    var partialRoute          = string.Format("{0}/{1}", containerPropertyName, iid);
                    this.PartialRoutes.Add(partialRoute);
                    this.partialClassKindRoute.Add(classKind);
                    break;
                }

                throw new InvalidOperationException(string.Format("the added container of classKind: {0} is not consistent with the existing route", classKind));
            }
            }
        }
Пример #8
0
        /// <summary>
        /// Returns the <see cref="Uri"/> of the resource in grayscale
        /// </summary>
        /// <param name="classKind">
        /// The <see cref="ClassKind"/> for which in icon needs to be provided
        /// </param>
        /// <param name="getsmallicon">
        /// Indicates whether a small or large icon should be returned.
        /// </param>
        /// <returns>
        /// A <see cref="Uri"/> that points to a resource
        /// </returns>
        private object GrayScaleImageUri(ClassKind classKind, bool getsmallicon = true)
        {
            var    compositionroot = "pack://application:,,,/CDP4Composition;component/Resources/Images/Thing/";
            var    imagesize       = getsmallicon ? "_16x16" : "_32x32";
            string imagename;
            var    imageextension = ".png";

            switch (classKind)
            {
            case ClassKind.Participant:
                imagename = "grayscaleParticipant";
                return($"{compositionroot}{imagename}{imagesize}{imageextension}");

            case ClassKind.Person:
                imagename = "grayscalePerson";
                return($"{compositionroot}{imagename}{imagesize}{imageextension}");

            case ClassKind.IterationSetup:
                imagename = "grayscaleIterationSetup";
                return($"{compositionroot}{imagename}{imagesize}{imageextension}");

            default:
                // Iteration Setup for now used as default
                imagename = "grayscaleIterationSetup";
                return($"{compositionroot}{imagename}{imagesize}{imageextension}");
            }
        }
Пример #9
0
        /// <summary>
        /// Resolves whether the write operation can be performed on a <see cref="Thing"/> of <see cref="Type"/>
        /// <paramref name="thingType"/> based on the superclass of <paramref name="thingType"/>
        /// </summary>
        /// <param name="containerThing">The container of the <see cref="Thing"/> that the write operation
        /// needs to be performed on.</param>
        /// <param name="thingType">The <see cref="Type"/> of the <see cref="Thing"/> that will be write to.</param>
        /// <returns>True if the permissions of the superclass allow it.</returns>
        private bool CanWriteBasedOnSuperclassClassKind(Thing containerThing, ClassKind thingType)
        {
            var baseType = StaticMetadataProvider.BaseType(thingType.ToString());

            if (string.IsNullOrWhiteSpace(baseType))
            {
                return(false);
            }

            return(Enum.TryParse(baseType, out ClassKind superClassKind) && this.CanWrite(superClassKind, containerThing));
        }
Пример #10
0
        /// <summary>
        /// Resolves the <see cref="Type"/> of the view-model associated to the provided <see cref="ClassKind"/>
        /// </summary>
        /// <param name="classKind">
        /// the <see cref="ClassKind"/> for which the view-model <see cref="Type"/> needs to be resolved
        /// </param>
        /// <returns>
        /// an instance of <see cref="Type"/>
        /// </returns>
        private Type ResolveViewModelType(ClassKind classKind)
        {
            Type returnedViewModelType;
            var  viewModelTypeFound = this.viewModelDictionary.TryGetValue(classKind, out returnedViewModelType);

            if (!viewModelTypeFound)
            {
                throw new Exception($"A IThingDialogViewModel for {classKind} has not been registered with the Application");
            }

            return(returnedViewModelType);
        }
Пример #11
0
        /// <summary>
        /// Returns whether a Write operation can be performed by the active user on the current <see cref="ClassKind"/>
        /// based on the supplied <see cref="Container"/>. The <see cref="ClassKind"/> ultimately determines the access. This method is primarily used for
        /// creation of a certain <see cref="SiteDirectory"/> contained <see cref="Thing"/>.
        /// </summary>
        /// <param name="classKind">The <see cref="ClassKind"/> that ultimately determines the permissions.</param>
        /// <param name="containerThing">The <see cref="Thing"/> to write to</param>
        /// <param name="thingType">The <see cref="ClassKind"/> that determine the permission</param>
        /// <returns>True if Write operation can be performed.</returns>
        private bool CanWriteSiteDirectoryContainedThing(ClassKind classKind, Thing containerThing, ClassKind thingType)
        {
            var person = this.Session.ActivePerson;

            if (person == null)
            {
                return(false);
            }

            var personRole = this.Session.ActivePerson.Role;

            if (personRole == null)
            {
                return(false);
            }

            var permission = personRole.PersonPermission.SingleOrDefault(p => p.ObjectClass == classKind);

            // if the permission is not found or superclass derivation is used then get the default one.
            var accessRightKind = permission?.AccessRight ?? StaticDefaultPermissionProvider.GetDefaultPersonPermission(thingType.ToString());

            switch (accessRightKind)
            {
            case PersonAccessRightKind.SAME_AS_CONTAINER:
                return(this.CanWrite(containerThing, containerThing.GetType()));

            case PersonAccessRightKind.SAME_AS_SUPERCLASS:
                return(this.CanWriteBasedOnSuperclassClassKind(containerThing, thingType));

            case PersonAccessRightKind.MODIFY:
                return(true);

            case PersonAccessRightKind.MODIFY_IF_PARTICIPANT:
                if (containerThing is EngineeringModelSetup setup)
                {
                    return(setup.Participant.Any(x => x.Person == this.Session.ActivePerson));
                }

                if (containerThing is SiteReferenceDataLibrary)
                {
                    var rdl =
                        this.Session.RetrieveSiteDirectory()
                        .Model.SelectMany(ems => this.Session.GetEngineeringModelSetupRdlChain(ems));
                    return(rdl.Contains(containerThing));
                }

                return(false);

            default:
                return(false);
            }
        }
Пример #12
0
        private Class ClassType(TK token, ClassKind kind)
        {
            Begin();
            Match(token);
            var name           = Identifier();
            var typeparameters = TryTypeParameters();
            var provides       = TryProvides();
            var doc            = TryString();
            var members        = ClassMembers();


            return(new Class(End(), kind, name, typeparameters, provides, doc, members));
        }
        private string CSharpName(MetaNullableType mtype, MetaModel mmodel, ClassKind kind = ClassKind.None, bool fullName = false)
        {
            string result = this.CSharpName(mtype.InnerType, mmodel, kind, fullName);

            if (mtype.InnerType is MetaPrimitiveType)
            {
                MetaPrimitiveType mpt = (MetaPrimitiveType)mtype.InnerType;
                if (mpt.Name != "object" || mpt.Name != "string" || mpt.Name != "ModelObject")
                {
                    result = result + "?";
                }
            }
            return(result);
        }
        private string CSharpName(MetaCollectionType mtype, MetaModel mmodel, ClassKind kind = ClassKind.None, bool fullName = false)
        {
            string result = this.CSharpName(mtype.InnerType, mmodel, kind, fullName);

            if (kind == ClassKind.BuilderOperation || kind == ClassKind.ImmutableOperation)
            {
                if (mtype.Kind == MetaCollectionKind.List || mtype.Kind == MetaCollectionKind.MultiList)
                {
                    return("global::System.Collections.Generic.IReadOnlyList<" + result + ">");
                }
                else
                {
                    return("global::System.Collections.Generic.IReadOnlyCollection<" + result + ">");
                }
            }
            string collectionName;

            switch (mtype.Kind)
            {
            case MetaCollectionKind.List:
            case MetaCollectionKind.MultiList:
                if (kind == ClassKind.Builder)
                {
                    collectionName = "MutableModelList";
                }
                else
                {
                    collectionName = "ImmutableModelList";
                }
                break;

            case MetaCollectionKind.Set:
            case MetaCollectionKind.MultiSet:
                if (kind == ClassKind.Builder)
                {
                    collectionName = "MutableModelSet";
                }
                else
                {
                    collectionName = "ImmutableModelSet";
                }
                break;

            default:
                collectionName = "";
                break;
            }
            result = _generator.Properties.CoreNs + "." + collectionName + "<" + result + ">";
            return(result);
        }
Пример #15
0
        public Class(TokenSpan span, ClassKind kind, Identifier name, TypeParameterList?typeParameters, IType?provides, String?doc, MemberList items)
        {
            Span           = span;
            Kind           = kind;
            Name           = name;
            TypeParameters = typeParameters;
            Provides       = provides;
            Doc            = doc;
            Items          = items;

            Members = new NamedList <INamedMember>();
            Fields  = new NamedList <Field>();
            Methods = new NamedList <Method>();
        }
Пример #16
0
        /// <summary>
        /// The populate participant permission.
        /// </summary>
        private void PopulateParticipantPermissions()
        {
            var provider      = new DefaultPermissionProvider();
            var classKindType = ClassKind.GetType();

            provider.GetDefaultTypeNameParticipantPermissions()
            .Where(x => x.Value.Equals(ParticipantAccessRightKind.NONE))
            .ToList()
            .ForEach(x => {
                var participantPermission         = new ParticipantPermission(Guid.NewGuid(), null, null);
                participantPermission.AccessRight = x.Value;
                participantPermission.ObjectClass = (ClassKind)Enum.Parse(classKindType, x.Key);
                this.ParticipantPermission.Add(participantPermission);
            });
        }
Пример #17
0
 internal ClassObject(BaseScripter scripter, int class_id, int owner_id, ClassKind ck)
     : base(scripter, class_id, owner_id)
 {
     this.PatternMethod = null;
     this.UnderlyingType = null;
     this.RType = null;
     this._namespaceNameIndex = -1;
     this.MinValueId = 0;
     this.MaxValueId = 0;
     this.RangeTypeId = 0;
     this.IndexTypeId = 0;
     this.ht = new Hashtable();
     this.AncestorIds = new IntegerList(false);
     this.ImportedType = null;
     this.Class_Kind = ck;
     this.PatternMethod = null;
 }
        public string CSharpName(MetaConstant mconst, MetaModel mmodel, ClassKind kind = ClassKind.None, bool fullName = false)
        {
            string result = mconst.Name;

            if (fullName)
            {
                string fullNamePrefix;
                switch (kind)
                {
                case ClassKind.BuilderInstance:
                    fullNamePrefix = this.CSharpName(mmodel, this.ToModelKind(kind), !this.ContainsDeclaration(mmodel, mconst));
                    result         = fullNamePrefix + ".instance." + result;
                    break;

                case ClassKind.ImmutableInstance:
                case ClassKind.FactoryMethod:
                case ClassKind.Implementation:
                    fullNamePrefix = this.CSharpName(mmodel, this.ToModelKind(kind), !this.ContainsDeclaration(mmodel, mconst));
                    result         = fullNamePrefix + "." + result;
                    break;

                case ClassKind.Immutable:
                case ClassKind.Builder:
                case ClassKind.ImmutableOperation:
                case ClassKind.BuilderOperation:
                    if (mconst.DotNetName != null)
                    {
                        result = mconst.DotNetName;
                    }
                    else
                    {
                        fullNamePrefix = this.CSharpName(mconst.Namespace, this.ToNamespaceKind(kind), fullName);
                        result         = "global::" + fullNamePrefix + "." + result;
                    }
                    break;

                default:
                    fullNamePrefix = this.CSharpName(mconst.Namespace, this.ToNamespaceKind(kind), fullName);
                    result         = "global::" + fullNamePrefix + "." + result;
                    break;
                }
            }
            return(result);
        }
        private string CSharpName(MetaEnum mtype, MetaModel mmodel, ClassKind kind = ClassKind.None, bool fullName = false)
        {
            string result = mtype.Name;

            if (fullName)
            {
                bool modelContainsType = this.ContainsType(mmodel, mtype);
                if (kind == ClassKind.Descriptor || kind == ClassKind.ImmutableInstance || kind == ClassKind.BuilderInstance || kind == ClassKind.FactoryMethod)
                {
                    string fullNamePrefix = this.CSharpName(mtype.MetaModel, this.ToModelKind(kind), !modelContainsType);
                    result = fullNamePrefix + "." + result;
                }
                else if (!modelContainsType)
                {
                    string fullNamePrefix = this.CSharpName(mtype.Namespace, this.ToNamespaceKind(kind), true);
                    result = "global::" + fullNamePrefix + "." + result;
                }
            }
            return(result);
        }
Пример #20
0
        /// <summary>
        /// Update the properties
        /// </summary>
        protected override void UpdateProperties()
        {
            base.UpdateProperties();

            this.PopulatePossibleClasskind();
            this.SelectedSource = this.Thing.Source;
            this.SelectedTarget = this.Thing.Target;
            this.SelectedOwner  = this.Thing.Owner;

            if (this.SelectedSource != null)
            {
                this.SelectedSourceClasskind = this.SelectedSource.ClassKind;
            }

            if (this.SelectedTarget != null)
            {
                this.SelectedTargetClasskind = this.SelectedTarget.ClassKind;
            }

            this.PopulateCategory();
        }
Пример #21
0
        /// <summary>
        /// Returns whether a Write operation can be performed by the active user on the current <see cref="ClassKind"/>
        /// based on the supplied <see cref="Container"/>. The <see cref="ClassKind"/> ultimately determines the access. This method is primarily used for
        /// creation of a certain <see cref="EngineeringModel"/> contained <see cref="Thing"/>.
        /// </summary>
        /// <param name="classKind">The <see cref="ClassKind"/> that ultimately determines the permissions.</param>
        /// <param name="containerThing">The <see cref="Thing"/> to write to</param>
        /// <param name="thingType">The <see cref="ClassKind"/> that ultimately determines the permissions.</param>
        /// <returns>True if Write operation can be performed.</returns>
        private bool CanWriteEngineeringModelContainedThing(ClassKind classKind, Thing containerThing, ClassKind thingType)
        {
            var engineeringModel = containerThing.TopContainer as EngineeringModel;

            var iteration = containerThing is Iteration it ? it : containerThing.GetContainerOfType <Iteration>();

            if (iteration?.IterationSetup.FrozenOn != null)
            {
                return(false);
            }

            var participant = this.Session.ActivePersonParticipants.FirstOrDefault(p => ((EngineeringModelSetup)p.Container).EngineeringModelIid == engineeringModel.Iid);

            if (participant?.Role == null)
            {
                return(false);
            }

            var permission = participant.Role.ParticipantPermission.SingleOrDefault(perm => perm.ObjectClass == classKind);

            // if the permission is not found then get the default one.
            var right = permission?.AccessRight ?? StaticDefaultPermissionProvider.GetDefaultParticipantPermission(thingType.ToString());

            switch (right)
            {
            case ParticipantAccessRightKind.SAME_AS_CONTAINER:
                return(this.CanWrite(containerThing, containerThing.GetType()));

            case ParticipantAccessRightKind.SAME_AS_SUPERCLASS:
                return(this.CanWriteBasedOnSuperclassClassKind(containerThing, thingType));

            case ParticipantAccessRightKind.MODIFY:
            case ParticipantAccessRightKind.MODIFY_IF_OWNER:
                return(true);

            default:
                return(false);
            }
        }
        private ModelKind ToModelKind(ClassKind kind)
        {
            switch (kind)
            {
            case ClassKind.Descriptor:
                return(ModelKind.Descriptor);

            case ClassKind.ImmutableInstance:
                return(ModelKind.ImmutableInstance);

            case ClassKind.BuilderInstance:
                return(ModelKind.BuilderInstance);

            case ClassKind.FactoryMethod:
                return(ModelKind.Factory);

            case ClassKind.Implementation:
                return(ModelKind.ImplementationProvider);

            default:
                return(ModelKind.None);
            }
        }
Пример #23
0
        public RppClass(ClassKind kind, HashSet<ObjectModifier> modifiers, [NotNull] string name, [NotNull] IList<RppField> classParams,
            [NotNull] IEnumerable<IRppNode> classBody, [NotNull] IList<RppVariantTypeParam> typeParams, RppBaseConstructorCall baseConstructorCall) : base(name)
        {
            Kind = kind;
            BaseConstructorCall = baseConstructorCall;
            _classParams = classParams;
            // TODO all of this can be simplified, we don't need to separate body of class. We can just walk rpp nodes with visitors
            IEnumerable<IRppNode> rppNodes = classBody as IList<IRppNode> ?? classBody.ToList();
            _funcs = rppNodes.OfType<RppFunc>().Where(f => !f.IsConstructor).ToList();
            _funcs.ForEach(DefineFunc);
            var constrExprs = rppNodes.OfType<IRppExpr>().Where(n => !(n is RppField)).ToList();
            // TODO for some reason RppField is also IRppExpr, I think it shouldn't be
            _typeParams = typeParams;
            Modifiers = modifiers;

            _constructors = rppNodes.OfType<RppFunc>().Where(f => f.IsConstructor).ToList();

            _fields = _classParams.Where(param => param.MutabilityFlag != MutabilityFlag.MfUnspecified || IsCase).ToList();

            rppNodes.OfType<RppField>().ForEach(_fields.Add);

            var primaryConstructor = CreatePrimaryConstructor(constrExprs);
            _constructors.Add(primaryConstructor);

            CreateProperties();

            if (kind == ClassKind.Object)
            {
                string objectName = SymbolTable.GetObjectName(Name);
                ResolvableType instanceFieldType = new ResolvableType(new RTypeName(objectName));
                InstanceField = new RppField(MutabilityFlag.MfVal, "_instance", Collections.NoModifiers, instanceFieldType,
                    new RppNew(instanceFieldType, Collections.NoExprs));
                _fields.Add(InstanceField);
            }

            _nested = rppNodes.OfType<RppClass>().ToList();
        }
        private string CSharpName(MetaDeclaration mdecl, MetaModel mmodel, ClassKind kind = ClassKind.None, bool fullName = false)
        {
            if (mdecl is MetaType)
            {
                return(this.CSharpName((MetaType)mdecl, mmodel, kind, fullName));
            }
            string result = mdecl.Name;

            if (fullName)
            {
                string fullNamePrefix;
                bool   modelContainsDecl = this.ContainsDeclaration(mmodel, mdecl);
                switch (kind)
                {
                case ClassKind.BuilderInstance:
                    fullNamePrefix = this.CSharpName(mdecl.MetaModel, this.ToModelKind(kind), !modelContainsDecl);
                    result         = fullNamePrefix + ".instance." + result;
                    break;

                case ClassKind.ImmutableInstance:
                case ClassKind.FactoryMethod:
                case ClassKind.Implementation:
                    fullNamePrefix = this.CSharpName(mdecl.MetaModel, this.ToModelKind(kind), !modelContainsDecl);
                    result         = fullNamePrefix + "." + result;
                    break;

                default:
                    if (!modelContainsDecl)
                    {
                        fullNamePrefix = this.CSharpName(mdecl.Namespace, this.ToNamespaceKind(kind), true);
                        result         = "global::" + fullNamePrefix + "." + result;
                    }
                    break;
                }
            }
            return(result);
        }
Пример #25
0
        /// <summary>
        /// Returns whether a Write operation can be performed by the active user on the current <see cref="ClassKind"/>
        /// based on the supplied <see cref="Container"/>. The <see cref="ClassKind"/> ultimately determines the access. This method is primarily used for
        /// creation of a certain <see cref="Thing"/>.
        /// </summary>
        /// <param name="classKind">The <see cref="ClassKind"/> that ultimately determines the permissions.</param>
        /// <param name="containerThing">The <see cref="Thing"/> to write to</param>
        /// <returns>True if Write operation can be performed.</returns>
        public bool CanWrite(ClassKind classKind, Thing containerThing)
        {
            logger.Trace("CanWrite invoked on ClassKind {0} and Container {1}", classKind, containerThing);

            if (this.Session.Dal.IsReadOnly)
            {
                return(false);
            }

            this.CheckOwnedThing(containerThing);

            var topContainerClassKind = containerThing.TopContainer.ClassKind;

            switch (topContainerClassKind)
            {
            case ClassKind.SiteDirectory:
                return(this.CanWriteSiteDirectoryContainedThing(classKind, containerThing, classKind));

            case ClassKind.EngineeringModel:
                return(this.CanWriteEngineeringModelContainedThing(classKind, containerThing, classKind));
            }

            return(false);
        }
Пример #26
0
 public ClassDefinition(string name, ClassKind kind,
                        TypedNodeList typeParameters,
                        TypedNodeList supertypes,
                        TypedNodeList subtypes,
                        Location location)
     : base(location)
 {
     this.name = name;
     this.kind = kind;
     this.typeParameters = typeParameters;
     this.supertypes = supertypes;
     this.subtypes = subtypes;
     typeBuilder = null;
     typeData = null;
     constructor = null;
     staticConstructor = null;
     staticConstructorIL = null;
     adapters = new ArrayList();
 }
Пример #27
0
 private void Parse_ClassMemberDeclaration(int class_id, ModifierList owner_modifiers, bool IsModule, ClassKind ck)
 {
     this.Parse_Attributes();
     ModifierList ml = this.Parse_Modifiers();
     if (owner_modifiers.HasModifier(Modifier.Public) && !ml.HasModifier(Modifier.Private))
     {
         ml.Add(Modifier.Public);
     }
     if (base.IsCurrText("Enum"))
     {
         this.Parse_NonModuleDeclaration(ml);
     }
     else if (base.IsCurrText("Structure"))
     {
         this.Parse_NonModuleDeclaration(ml);
     }
     else if (base.IsCurrText("Interface"))
     {
         this.Parse_NonModuleDeclaration(ml);
     }
     else if (base.IsCurrText("Class"))
     {
         this.Parse_NonModuleDeclaration(ml);
     }
     else if (base.IsCurrText("Delegate"))
     {
         this.Parse_NonModuleDeclaration(ml);
     }
     else if (base.IsCurrText("Event"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_EventMemberDeclaration(class_id, ml, owner_modifiers);
     }
     else if (base.IsCurrText("Dim"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_VariableMemberDeclaration(class_id, ml, owner_modifiers);
     }
     else if (base.IsCurrText("Const"))
     {
         ml.Add(Modifier.Static);
         this.Parse_ConstantMemberDeclaration(class_id, ml, owner_modifiers);
     }
     else if (base.IsCurrText("Property"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_PropertyMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else if (base.IsCurrText("Declare"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else if (base.IsCurrText("Sub"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else if (base.IsCurrText("Function"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_VariableMemberDeclaration(class_id, ml, owner_modifiers);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ThingDialogViewExportAttribute"/> class.
 /// </summary>
 /// <param name="classKind">
 /// The <see cref="ClassKind"/> of the <see cref="Thing"/> that is represented by the decorated <see cref="IDialogView"/>
 /// </param>
 public ThingDialogViewExportAttribute(ClassKind classKind)
     : base(typeof(IThingDialogView))
 {
     this.ClassKind = classKind;
 }
Пример #29
0
 /// <summary>
 /// Checks whether the <see cref="ClassKind" /> of the <see cref="Thing" /> matches criteria for a rebuild of the matrix.
 /// </summary>
 /// <param name="thingClassKind">The <see cref="ClassKind" /> of the relevant <see cref="Thing" /></param>
 /// <param name="expectedClassKind">The <see cref="ClassKind" /> selected in the configuration.</param>
 /// <returns>True if the <see cref="ClassKind" /> matches the criteria.</returns>
 private bool IsClassKindValidForRebuild(ClassKind thingClassKind, ClassKind expectedClassKind)
 {
     // class kind should match, or in case of ElementUsage, ElementDefinition should be taken into account.
     return(thingClassKind == expectedClassKind || expectedClassKind == ClassKind.ElementUsage &&
            thingClassKind == ClassKind.ElementDefinition);
 }
Пример #30
0
        /// <summary>
        /// Gets the <see cref="ShapeDescription"/> for a <see cref="ClassKind"/>
        /// </summary>
        /// <param name="classKind">The <see cref="ClassKind"/></param>
        /// <returns>The <see cref="ShapeDescription"/></returns>
        /// <remarks>Default is <see cref="BasicShapes.Rectangle"/></remarks>
        public static ShapeDescription GetShape(ClassKind classKind)
        {
            ShapeDescription shape;

            return(ShapeMapper.TryGetValue(classKind, out shape) ? shape : BasicShapes.Rectangle);
        }
Пример #31
0
 private void Parse_MethodMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     base.DECLARE_SWITCH = true;
     if (base.IsCurrText("Sub"))
     {
         this.Parse_SubDeclaration(class_id, ml, owner_ml, ck);
     }
     else if (base.IsCurrText("Function"))
     {
         this.Parse_FunctionDeclaration(class_id, ml, owner_ml, ck);
     }
     else if (base.IsCurrText("Declare"))
     {
         this.Parse_ExternalMethodDeclaration(class_id, ml, owner_ml);
     }
     else
     {
         this.Match("Sub");
     }
 }
Пример #32
0
 private void Parse_FunctionDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     this.Match("function");
     int num = 0x10;
     this.valid_this_context = true;
     int num2 = this.BeginMethod(this.Parse_Ident(), MemberKind.Method, ml, num);
     if (base.IsCurrText('('))
     {
         this.Match('(');
         if (!base.IsCurrText(')'))
         {
             this.Parse_ParameterList(num2, false);
         }
         this.Match(')');
     }
     this.Match(":");
     this.Parse_Attributes();
     num = this.Parse_Type();
     this.Match(";");
     if (!this.Parse_ForwardMethodDeclaration(num2))
     {
         base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, num2, -1, -1);
         base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, base.CurrResultId, -1, -1);
         this.Gen(base.code.OP_ASSIGN_TYPE, num2, num, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, base.CurrResultId, num, 0);
         if (this.Parse_DirectiveList().IndexOf(1) >= 0)
         {
             base.SetForward(num2, true);
             this.EndMethod(num2);
         }
         else
         {
             base.SetName(base.CurrResultId, "result");
             this.Gen(base.code.OP_DECLARE_LOCAL_VARIABLE, base.CurrResultId, base.CurrSubId, 0);
             if (ml.HasModifier(Modifier.Extern))
             {
                 base.RaiseErrorEx(false, "CS0179. '{0}' cannot be extern and declare a body.", new object[] { base.GetName(num2) });
             }
             if (ck != ClassKind.Interface)
             {
                 this.InitMethod(num2);
                 this.Parse_LocalDeclarationPart();
                 if (ml.HasModifier(Modifier.Abstract))
                 {
                     string name = base.GetName(num2);
                     base.RaiseErrorEx(false, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { name });
                 }
                 if (base.GetName(num2) == "Main")
                 {
                     this.Gen(base.code.OP_CHECKED, base.TRUE_id, 0, 0);
                 }
                 base.DECLARE_SWITCH = false;
                 this.Parse_CompoundStatement();
                 this.Match(";");
                 if (base.GetName(num2) == "Main")
                 {
                     this.Gen(base.code.OP_RESTORE_CHECKED_STATE, 0, 0, 0);
                 }
             }
             this.EndMethod(num2);
             this.valid_this_context = false;
             base.DECLARE_SWITCH = true;
         }
     }
 }
Пример #33
0
 public ClassDefinition(string name, ClassKind kind,
                        TypedNodeList typeParameters,
                        TypedNodeList supertypes,
                        Location location)
     : this(name, kind, typeParameters, supertypes, null, location)
 {
 }
 public string GetImmBldReturn(MetaModel mmodel, MetaOperation operation, ClassKind kind)
 {
     return(this.GetImmBldConversion(mmodel, operation.ReturnType, kind));
 }
Пример #35
0
 private void Parse_MemberDeclaration(int class_id, ClassKind ck, ModifierList owner_ml)
 {
     int num27;
     int num28;
     string name = base.GetName(class_id);
     base.DECLARE_SWITCH = true;
     if (base.IsCurrText('['))
     {
         this.Parse_Attributes();
     }
     ModifierList ml = this.Parse_Modifiers();
     bool flag = ml.HasModifier(Modifier.Static);
     int k = base.ReadToken();
     string text = base.curr_token.Text;
     k += base.ReadToken();
     string str3 = base.curr_token.Text;
     base.Backup_SCANNER(k);
     if ((((base.IsCurrText("enum") | base.IsCurrText("class")) | base.IsCurrText("struct")) | base.IsCurrText("interface")) | base.IsCurrText("delegate"))
     {
         this.Parse_TypeDeclaration(ml);
     }
     else if (!base.IsCurrText("const"))
     {
         ModifierList list2;
         if (!base.IsCurrText("event"))
         {
             if (base.IsCurrText("implicit"))
             {
                 base.CheckModifiers(ml, this.operator_modifiers);
                 this.Match("implicit");
                 this.Match("operator");
                 if (!ml.HasModifier(Modifier.Public) || !ml.HasModifier(Modifier.Static))
                 {
                     base.RaiseErrorEx(false, "CS0558. User-defined operator 'operator' must be declared static and public.", new object[] { "op_Implicit" });
                 }
                 int num11 = this.Parse_Type();
                 int num12 = base.NewVar();
                 base.SetName(num12, "op_Implicit");
                 this.BeginMethod(num12, MemberKind.Method, ml, num11);
                 this.Match('(');
                 if (this.Parse_FormalParameterList(num12, false) != 1)
                 {
                     base.RaiseErrorEx(false, "CS1535. Overloaded unary operator '{0}' only takes one parameter.", new object[] { "implicit" });
                 }
                 this.Match(')');
                 if (base.IsCurrText(';'))
                 {
                     this.Match(';');
                 }
                 else
                 {
                     this.InitMethod(num12);
                     this.Parse_MethodBlock();
                 }
                 this.EndMethod(num12);
                 goto Label_1519;
             }
             if (base.IsCurrText("explicit"))
             {
                 base.CheckModifiers(ml, this.operator_modifiers);
                 this.Match("explicit");
                 this.Match("operator");
                 if (!ml.HasModifier(Modifier.Public) || !ml.HasModifier(Modifier.Static))
                 {
                     base.RaiseErrorEx(false, "CS0558. User-defined operator 'operator' must be declared static and public.", new object[] { "op_Explicit" });
                 }
                 int num14 = this.Parse_Type();
                 int num15 = base.NewVar();
                 base.SetName(num15, "op_Explicit");
                 this.BeginMethod(num15, MemberKind.Method, ml, num14);
                 this.Match('(');
                 if (this.Parse_FormalParameterList(num15, false) != 1)
                 {
                     base.RaiseErrorEx(false, "CS1535. Overloaded unary operator '{0}' only takes one parameter.", new object[] { "explicit" });
                 }
                 this.Match(')');
                 string str6 = base.GetName(num14);
                 string str7 = base.GetName(this.param_type_ids[0]);
                 if ((str6 == name) && (str7 == name))
                 {
                     base.RaiseError(false, "CS0556. User-defined conversion must convert to or from the enclosing type.");
                 }
                 if ((str6 != name) && (str7 != name))
                 {
                     base.RaiseError(false, "CS0556. User-defined conversion must convert to or from the enclosing type.");
                 }
                 if (base.IsCurrText(';'))
                 {
                     this.Match(';');
                 }
                 else
                 {
                     this.InitMethod(num15);
                     this.Parse_MethodBlock();
                 }
                 this.EndMethod(num15);
                 goto Label_1519;
             }
             if (base.IsCurrText("~"))
             {
                 if (ck == ClassKind.Struct)
                 {
                     base.RaiseError(false, "CS0575. Only class types can contain destructors.");
                 }
                 base.CheckModifiers(ml, this.destructor_modifiers);
                 this.Match("~");
                 int num17 = this.Parse_Ident();
                 if (base.GetName(class_id) != base.GetName(num17))
                 {
                     base.RaiseError(false, "CS0574. Name of destructor must match name of class.");
                 }
                 this.BeginMethod(num17, MemberKind.Method, ml, 1);
                 this.Match('(');
                 if (!base.IsCurrText(')'))
                 {
                     this.Parse_FormalParameterList(num17, false);
                 }
                 this.Match(')');
                 if (base.IsCurrText(';'))
                 {
                     this.Match(';');
                 }
                 else
                 {
                     this.InitMethod(num17);
                     this.Parse_MethodBlock();
                 }
                 this.EndMethod(num17);
                 goto Label_1519;
             }
             if ((base.GetName(class_id) == base.curr_token.Text) && (text == "("))
             {
                 IntegerList list3;
                 base.CheckModifiers(ml, this.constructor_modifiers);
                 if (flag && this.HasAccessModifier(ml))
                 {
                     base.RaiseErrorEx(false, "CS0515. '{0}' : access modifiers are not allowed on static constructors.", new object[] { base.GetName(class_id) });
                 }
                 int num18 = this.Parse_Ident();
                 this.valid_this_context = true;
                 this.BeginMethod(num18, MemberKind.Constructor, ml, 1);
                 this.Match('(');
                 if (!base.IsCurrText(')'))
                 {
                     if (flag)
                     {
                         base.RaiseErrorEx(false, "CS0132. '{0}' : a static constructor must be parameterless.", new object[] { base.GetName(class_id) });
                     }
                     this.Parse_FormalParameterList(num18, false);
                 }
                 else if (ck == ClassKind.Struct)
                 {
                     base.RaiseError(false, "CS0568. Structs cannot contain explicit parameterless constructors.");
                 }
                 this.Match(')');
                 this.InitMethod(num18);
                 if (flag)
                 {
                     list3 = this.static_variable_initializers;
                 }
                 else
                 {
                     list3 = this.variable_initializers;
                 }
                 for (int i = 0; i < list3.Count; i++)
                 {
                     int num20 = list3[i];
                     this.Gen(base.code.OP_BEGIN_CALL, num20, 0, 0);
                     this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
                     this.Gen(base.code.OP_CALL, num20, 0, 0);
                 }
                 if (base.IsCurrText(':'))
                 {
                     this.Match(':');
                     if (flag)
                     {
                         base.RaiseErrorEx(false, "CS0514. '{0}' : static constructor cannot have an explicit this or base constructor call.", new object[] { base.GetName(class_id) });
                     }
                     if (base.IsCurrText("base"))
                     {
                         if (ck == ClassKind.Struct)
                         {
                             base.RaiseErrorEx(false, "CS0522. '{0}' : structs cannot call base class constructors.", new object[] { base.GetName(class_id) });
                         }
                         this.Match("base");
                         int num21 = base.NewVar();
                         int num22 = base.NewVar();
                         this.Gen(base.code.OP_EVAL_BASE_TYPE, class_id, 0, num22);
                         this.Gen(base.code.OP_ASSIGN_NAME, num21, num22, num21);
                         int num23 = base.NewVar();
                         this.Gen(base.code.OP_CAST, num22, base.CurrThisID, num23);
                         this.Gen(base.code.OP_CREATE_REFERENCE, num23, 0, num21);
                         base.DECLARE_SWITCH = false;
                         this.Match('(');
                         this.Gen(base.code.OP_CALL_BASE, num21, this.Parse_ArgumentList(")", num21, num23), 0);
                         base.DECLARE_SWITCH = true;
                         this.Match(')');
                     }
                     else if (base.IsCurrText("this"))
                     {
                         this.Match("this");
                         base.DECLARE_SWITCH = false;
                         this.Match('(');
                         this.Gen(base.code.OP_CALL, num18, this.Parse_ArgumentList(")", num18, base.CurrThisID), 0);
                         base.DECLARE_SWITCH = true;
                         this.Match(')');
                     }
                     else
                     {
                         base.RaiseError(true, "CS1018. Keyword this or base expected.");
                     }
                 }
                 else if (!flag)
                 {
                     int num24 = base.NewVar();
                     int num25 = base.NewVar();
                     this.Gen(base.code.OP_EVAL_BASE_TYPE, class_id, 0, num25);
                     this.Gen(base.code.OP_ASSIGN_NAME, num24, num25, num24);
                     int num26 = base.NewVar();
                     this.Gen(base.code.OP_CAST, num25, base.CurrThisID, num26);
                     this.Gen(base.code.OP_CREATE_REFERENCE, num26, 0, num24);
                     this.Gen(base.code.OP_BEGIN_CALL, num24, 0, 0);
                     this.Gen(base.code.OP_PUSH, num26, 0, 0);
                     this.Gen(base.code.OP_CALL, num24, 0, 0);
                 }
                 if (base.IsCurrText(';'))
                 {
                     this.Match(';');
                 }
                 else
                 {
                     this.Parse_Block();
                 }
                 this.EndMethod(num18);
                 this.valid_this_context = false;
                 if (flag)
                 {
                     this.static_variable_initializers.Clear();
                 }
                 else
                 {
                     this.has_constructor = true;
                 }
                 goto Label_1519;
             }
             num27 = this.Parse_Type();
             num28 = 0;
             if (!(str3 == "."))
             {
                 goto Label_0CD9;
             }
             if (ml.HasModifier(Modifier.Public))
             {
                 base.RaiseErrorEx(false, "CS0106. The modifier '{0}' is not valid for this item.", new object[] { "public" });
             }
             ml.Add(Modifier.Public);
             num28 = this.Parse_Ident();
             this.Gen(base.code.OP_EVAL_TYPE, 0, 0, num28);
             while (true)
             {
                 base.REF_SWITCH = true;
                 if (!base.CondMatch('.'))
                 {
                     goto Label_0CD2;
                 }
                 int num29 = base.ReadToken();
                 string str8 = base.curr_token.Text;
                 base.Backup_SCANNER(num29);
                 if (str8 != ".")
                 {
                     goto Label_0CD2;
                 }
                 int num30 = num28;
                 num28 = this.Parse_Ident();
                 this.Gen(base.code.OP_CREATE_TYPE_REFERENCE, num30, 0, num28);
             }
         }
         this.Match("event");
         base.CheckModifiers(ml, this.method_modifiers);
         int num4 = this.Parse_Type();
         int id = this.Parse_Ident();
         if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
         {
             string str4 = base.GetName(id);
             base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { str4, name });
         }
         if (base.IsCurrText('{'))
         {
             base.BeginEvent(id, ml, num4, 0);
             this.Gen(base.code.OP_ADD_MODIFIER, id, 1, 0);
             this.param_ids.Clear();
             this.param_type_ids.Clear();
             this.param_mods.Clear();
             this.Parse_EventAccessorDeclarations(id, num4, ml);
             base.EndEvent(id);
             goto Label_1519;
         }
     Label_0249:
         list2 = ml.Clone();
         list2.Delete(Modifier.Public);
         base.BeginField(id, list2, num4);
         string str5 = base.GetName(id);
         base.SetName(id, "__" + str5);
         if (base.IsCurrText('='))
         {
             this.Parse_InstanceVariableInitializer(id, num4, ml);
         }
         base.EndField(id);
         int num10 = base.NewVar();
         base.SetName(num10, str5);
         base.BeginEvent(num10, ml, num4, 0);
         this.Gen(base.code.OP_ADD_EVENT_FIELD, num10, id, 0);
         int num6 = base.NewVar();
         base.SetName(num6, "add_" + str5);
         this.BeginMethod(num6, MemberKind.Method, list2, 1);
         int num7 = base.NewVar();
         base.SetName(num7, "value");
         this.Gen(base.code.OP_ADD_PARAM, num6, num7, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num7, num4, 0);
         this.InitMethod(num6);
         int num8 = base.NewVar();
         base.SetName(num8, base.GetName(id));
         int res = base.NewVar();
         this.Gen(base.code.OP_EVAL, 0, 0, num8);
         this.Gen(base.code.OP_PLUS, num8, num7, res);
         this.Gen(base.code.OP_ASSIGN, num8, res, num8);
         this.EndMethod(num6);
         this.Gen(base.code.OP_ADD_ADD_ACCESSOR, num10, num6, 0);
         num6 = base.NewVar();
         base.SetName(num6, "remove_" + str5);
         this.BeginMethod(num6, MemberKind.Method, list2, 1);
         num7 = base.NewVar();
         base.SetName(num7, "value");
         this.Gen(base.code.OP_ADD_PARAM, num6, num7, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num7, num4, 0);
         this.InitMethod(num6);
         num8 = base.NewVar();
         base.SetName(num8, base.GetName(id));
         res = base.NewVar();
         this.Gen(base.code.OP_EVAL, 0, 0, num8);
         this.Gen(base.code.OP_MINUS, num8, num7, res);
         this.Gen(base.code.OP_ASSIGN, num8, res, num8);
         this.EndMethod(num6);
         this.Gen(base.code.OP_ADD_REMOVE_ACCESSOR, num10, num6, 0);
         base.EndEvent(num10);
         if (base.IsCurrText(','))
         {
             this.Call_SCANNER();
             id = this.Parse_Ident();
             goto Label_0249;
         }
         this.Match(';');
     }
     else
     {
         this.Match("const");
         base.CheckModifiers(ml, this.constant_modifiers);
         ml.Add(Modifier.Static);
         int num2 = this.Parse_Type();
         do
         {
             int num3 = this.Parse_Ident();
             if (flag)
             {
                 base.RaiseErrorEx(false, "CS0504. The constant '{0}' cannot be marked static.", new object[] { base.GetName(num3) });
             }
             if (!base.IsCurrText('='))
             {
                 base.RaiseError(true, "CS0145. A const field requires a value to be provided.");
             }
             base.BeginField(num3, ml, num2);
             base.DECLARE_SWITCH = false;
             this.Parse_InstanceVariableInitializer(num3, num2, ml);
             base.EndField(num3);
             base.DECLARE_SWITCH = true;
         }
         while (base.CondMatch(','));
         this.Match(';');
     }
     goto Label_1519;
     Label_0CD2:
     base.REF_SWITCH = false;
     Label_0CD9:
     if (base.IsCurrText("this"))
     {
         base.CheckModifiers(ml, this.method_modifiers);
         this.Match("this");
         int num31 = base.NewVar();
         base.SetName(num31, "Item");
         if (num27 == 1)
         {
             base.RaiseError(false, "CS0620. Indexers can't have void type.");
         }
         if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
         {
             string str9 = base.GetName(num31);
             base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { str9, name });
         }
         this.Match('[');
         int num32 = this.Parse_FormalParameterList(num31, true);
         this.Match(']');
         this.valid_this_context = true;
         base.BeginProperty(num31, ml, num27, num32);
         this.Parse_PropertyAccessorDeclarations(num31, num27, ml);
         base.EndProperty(num31);
         this.valid_this_context = false;
     }
     else if (!base.IsCurrText("operator"))
     {
         int num39;
         if (base.IsCurrText('('))
         {
             base.RaiseError(true, "CS1520. Class, struct, or interface method must have a return type.");
         }
     Label_0F95:
         num39 = this.Parse_Ident();
         if (base.IsCurrText(';'))
         {
             if (num27 == 1)
             {
                 base.RaiseError(false, "CS0670. Field cannot have void type.");
             }
             base.CheckModifiers(ml, this.field_modifiers);
             base.BeginField(num39, ml, num27);
             this.Add_InstanceVariableInitializer(num39, num27, ml);
             base.EndField(num39);
             this.Match(';');
         }
         else if (base.IsCurrText(','))
         {
             base.CheckModifiers(ml, this.field_modifiers);
             base.BeginField(num39, ml, num27);
             base.EndField(num39);
             this.Match(',');
             do
             {
                 num39 = this.Parse_Ident();
                 base.BeginField(num39, ml, num27);
                 if (base.IsCurrText('='))
                 {
                     if (!ml.HasModifier(Modifier.Static) && (ck == ClassKind.Struct))
                     {
                         base.RaiseErrorEx(false, "CS0573. '{0}' : cannot have instance field initializers in structs.", new object[] { base.GetName(num39) });
                     }
                     this.Parse_InstanceVariableInitializer(num39, num27, ml);
                 }
                 else
                 {
                     this.Add_InstanceVariableInitializer(num39, num27, ml);
                 }
                 base.EndField(num39);
             }
             while (base.CondMatch(','));
             this.Match(';');
         }
         else if (base.IsCurrText('='))
         {
             if (num27 == 1)
             {
                 base.RaiseError(false, "CS0670. Field cannot have void type.");
             }
             if (!ml.HasModifier(Modifier.Static) && (ck == ClassKind.Struct))
             {
                 base.RaiseErrorEx(false, "CS0573. '{0}' : cannot have instance field initializers in structs.", new object[] { base.GetName(num39) });
             }
             base.CheckModifiers(ml, this.field_modifiers);
             base.BeginField(num39, ml, num27);
             this.Parse_InstanceVariableInitializer(num39, num27, ml);
             base.EndField(num39);
             if (base.IsCurrText(','))
             {
                 this.Match(',');
                 goto Label_0F95;
             }
             this.Match(';');
         }
         else if (base.IsCurrText('('))
         {
             base.CheckModifiers(ml, this.method_modifiers);
             if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
             {
                 string str12 = base.GetName(num39);
                 base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { str12, name });
             }
             if (flag && ((ml.HasModifier(Modifier.Abstract) || ml.HasModifier(Modifier.Virtual)) || ml.HasModifier(Modifier.Override)))
             {
                 base.RaiseErrorEx(false, "CS0112. A static member '{0}' cannot be marked as override, virtual or abstract.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Override) && (ml.HasModifier(Modifier.Virtual) || ml.HasModifier(Modifier.New)))
             {
                 base.RaiseErrorEx(false, "CS0113. A member '{0}' marked as override cannot be marked as new or virtual.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Extern) && ml.HasModifier(Modifier.Abstract))
             {
                 base.RaiseErrorEx(false, "CS0180. '{0}' cannot be both extern and abstract.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Sealed) && !ml.HasModifier(Modifier.Override))
             {
                 base.RaiseErrorEx(false, "CS0238. '{0}' cannot be sealed because it is not an override.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Abstract) && ml.HasModifier(Modifier.Virtual))
             {
                 base.RaiseErrorEx(false, "CS0503. The abstract method '{0}' cannot be marked virtual.", new object[] { base.GetName(num39) });
             }
             if (ml.HasModifier(Modifier.Virtual) && owner_ml.HasModifier(Modifier.Sealed))
             {
                 base.RaiseErrorEx(false, "CS0549. '{0}' is a new virtual member in sealed class '{1}'.", new object[] { base.GetName(num39) });
             }
             int num40 = num39;
             this.valid_this_context = true;
             this.BeginMethod(num40, MemberKind.Method, ml, num27);
             if (num28 > 0)
             {
                 this.Gen(base.code.OP_ADD_EXPLICIT_INTERFACE, num40, num28, 0);
             }
             this.Match('(');
             if (!base.IsCurrText(')'))
             {
                 this.Parse_FormalParameterList(num40, false);
             }
             this.Match(')');
             if (base.IsCurrText(';'))
             {
                 if (!ml.HasModifier(Modifier.Extern) && !ml.HasModifier(Modifier.Abstract))
                 {
                     base.RaiseErrorEx(false, "CS0501. '{0}' must declare a body because it is not marked abstract or extern.", new object[] { base.GetName(num40) });
                 }
                 this.Match(';');
             }
             else
             {
                 if (ml.HasModifier(Modifier.Extern))
                 {
                     base.RaiseErrorEx(false, "CS0179. '{0}' cannot be extern and declare a body.", new object[] { base.GetName(num40) });
                 }
                 this.InitMethod(num40);
                 if (ml.HasModifier(Modifier.Abstract))
                 {
                     string str13 = base.GetName(num40);
                     base.RaiseErrorEx(false, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { str13 });
                 }
                 if (base.GetName(num39) == "Main")
                 {
                     this.Gen(base.code.OP_CHECKED, base.TRUE_id, 0, 0);
                 }
                 this.Parse_MethodBlock();
                 if (base.GetName(num39) == "Main")
                 {
                     this.Gen(base.code.OP_RESTORE_CHECKED_STATE, 0, 0, 0);
                 }
             }
             this.EndMethod(num40);
             this.valid_this_context = false;
         }
         else if (base.IsCurrText('{'))
         {
             base.CheckModifiers(ml, this.method_modifiers);
             if (ml.HasModifier(Modifier.Abstract) && !owner_ml.HasModifier(Modifier.Abstract))
             {
                 string str14 = base.GetName(num39);
                 base.RaiseErrorEx(false, "CS0513. '{0}' is abstract but it is contained in nonabstract class '{1}'", new object[] { str14, name });
             }
             this.valid_this_context = true;
             base.BeginProperty(num39, ml, num27, 0);
             this.param_ids.Clear();
             this.param_type_ids.Clear();
             this.param_mods.Clear();
             this.Parse_PropertyAccessorDeclarations(num39, num27, ml);
             base.EndProperty(num39);
             this.valid_this_context = false;
         }
         else
         {
             this.Parse_TypeDeclaration(ml);
         }
     }
     else
     {
         base.CheckModifiers(ml, this.operator_modifiers);
         this.Match("operator");
         if (num27 == 1)
         {
             base.RaiseError(false, "CS0590. User-defined operators cannot return void.");
         }
         if (!ml.HasModifier(Modifier.Public) || !ml.HasModifier(Modifier.Static))
         {
             base.RaiseErrorEx(false, "CS0558. User-defined operator 'operator' must be declared static and public.", new object[] { base.curr_token.Text });
         }
         string s = base.curr_token.Text;
         this.Call_SCANNER();
         int num33 = base.NewVar();
         this.BeginMethod(num33, MemberKind.Method, ml, num27);
         this.Match('(');
         int num34 = this.Parse_FormalParameterList(num33, false);
         string str11 = "";
         switch (num34)
         {
             case 1:
             {
                 int index = this.overloadable_unary_operators.IndexOf(s);
                 if (index == -1)
                 {
                     base.RaiseError(true, "CS1019. Overloadable unary operator expected.");
                 }
                 int num36 = (int) this.overloadable_unary_operators.Objects[index];
                 str11 = (string) base.code.overloadable_unary_operators_str[num36];
                 break;
             }
             case 2:
             {
                 int num37 = this.overloadable_binary_operators.IndexOf(s);
                 if (num37 == -1)
                 {
                     base.RaiseError(true, "CS1020. Overloadable binary operator expected.");
                 }
                 int num38 = (int) this.overloadable_binary_operators.Objects[num37];
                 str11 = (string) base.code.overloadable_binary_operators_str[num38];
                 break;
             }
             default:
                 base.RaiseErrorEx(true, "CS1534. Overloaded binary operator '{0}' only takes two parameters.", new object[] { s });
                 break;
         }
         base.SetName(num33, str11);
         this.Match(')');
         if (base.IsCurrText(';'))
         {
             this.Match(';');
         }
         else
         {
             this.InitMethod(num33);
             this.Parse_MethodBlock();
         }
         this.EndMethod(num33);
     }
     Label_1519:
     base.DECLARE_SWITCH = false;
 }
Пример #36
0
 private void Parse_ConstructorDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     this.Match("constructor");
     this.valid_this_context = true;
     bool flag = ml.HasModifier(Modifier.Static);
     int num2 = this.BeginMethod(this.Parse_Ident(), MemberKind.Constructor, ml, 1);
     if (base.IsCurrText('('))
     {
         this.Match('(');
         if (!base.IsCurrText(')'))
         {
             if (flag)
             {
                 base.RaiseErrorEx(false, "CS0132. '{0}' : a static constructor must be parameterless.", new object[] { base.GetName(class_id) });
             }
             this.Parse_ParameterList(num2, false);
         }
         this.Match(')');
     }
     this.Match(";");
     if (!this.Parse_ForwardMethodDeclaration(num2))
     {
         IntegerList list;
         this.InitMethod(num2);
         this.Parse_LocalDeclarationPart();
         if (flag)
         {
             list = this.static_variable_initializers;
         }
         else
         {
             list = this.variable_initializers;
         }
         for (int i = 0; i < list.Count; i++)
         {
             int num4 = list[i];
             this.Gen(base.code.OP_BEGIN_CALL, num4, 0, 0);
             this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
             this.Gen(base.code.OP_CALL, num4, 0, 0);
         }
         base.DECLARE_SWITCH = false;
         this.Parse_CompoundStatement();
         this.Match(";");
         this.EndMethod(num2);
         this.valid_this_context = false;
         if (flag)
         {
             this.static_variable_initializers.Clear();
         }
         else
         {
             this.has_constructor = true;
         }
         base.DECLARE_SWITCH = true;
     }
 }
Пример #37
0
 private void Parse_SubDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     int num;
     this.Match("Sub");
     this.PushExitKind(ExitKind.Sub);
     int num2 = 1;
     this.valid_this_context = true;
     if (base.IsCurrText("New"))
     {
         IntegerList list;
         bool flag = ml.HasModifier(Modifier.Static);
         base.CheckModifiers(ml, this.constructor_modifiers);
         if (flag && this.HasAccessModifier(ml))
         {
             base.RaiseErrorEx(false, "CS0515. '{0}' : access modifiers are not allowed on static constructors.", new object[] { base.GetName(class_id) });
         }
         num = base.NewVar();
         this.Call_SCANNER();
         this.BeginMethod(num, MemberKind.Constructor, ml, 1);
         if (base.IsCurrText('('))
         {
             this.Match('(');
             if (!base.IsCurrText(')'))
             {
                 if (flag)
                 {
                     base.RaiseErrorEx(false, "CS0132. '{0}' : a static constructor must be parameterless.", new object[] { base.GetName(class_id) });
                 }
                 this.Parse_ParameterList(num, false);
             }
             this.Match(')');
         }
         this.InitMethod(num);
         if (flag)
         {
             list = this.static_variable_initializers;
         }
         else
         {
             list = this.variable_initializers;
         }
         for (int i = 0; i < list.Count; i++)
         {
             int num4 = list[i];
             this.Gen(base.code.OP_BEGIN_CALL, num4, 0, 0);
             this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
             this.Gen(base.code.OP_CALL, num4, 0, 0);
         }
         base.DECLARE_SWITCH = false;
         this.MatchLineTerminator();
         this.Parse_Block();
         this.EndMethod(num);
         this.valid_this_context = false;
         if (flag)
         {
             this.static_variable_initializers.Clear();
         }
         else
         {
             this.has_constructor = true;
         }
         base.DECLARE_SWITCH = true;
         this.Match("End");
         this.Match("Sub");
         this.PopExitKind();
         this.MatchLineTerminator();
     }
     else
     {
         num = this.Parse_Ident();
         this.CheckMethodModifiers(num, class_id, ml, owner_ml);
         this.BeginMethod(num, MemberKind.Method, ml, num2);
         if (this.explicit_intf_id > 0)
         {
             this.Gen(base.code.OP_ADD_EXPLICIT_INTERFACE, num, this.explicit_intf_id, 0);
         }
         if (base.IsCurrText('('))
         {
             this.Match('(');
             if (!base.IsCurrText(')'))
             {
                 this.Parse_ParameterList(num, false);
             }
             this.Match(')');
         }
         if (ml.HasModifier(Modifier.Extern))
         {
             base.RaiseErrorEx(false, "CS0179. '{0}' cannot be extern and declare a body.", new object[] { base.GetName(num) });
         }
         if (ck != ClassKind.Interface)
         {
             this.InitMethod(num);
             if (ml.HasModifier(Modifier.Abstract))
             {
                 string name = base.GetName(num);
                 base.RaiseErrorEx(false, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { name });
             }
             if (base.GetName(num) == "Main")
             {
                 this.Gen(base.code.OP_CHECKED, base.TRUE_id, 0, 0);
             }
             if (base.IsCurrText("Handles"))
             {
                 this.Parse_HandlesClause();
             }
             else if (base.IsCurrText("Implements"))
             {
                 this.Parse_ImplementsClause(num);
             }
             base.DECLARE_SWITCH = false;
             this.MatchLineTerminator();
             this.Parse_Block();
             if (base.GetName(num) == "Main")
             {
                 this.Gen(base.code.OP_RESTORE_CHECKED_STATE, 0, 0, 0);
             }
             this.Match("End");
             this.Match("Sub");
         }
         this.EndMethod(num);
         this.valid_this_context = false;
         base.DECLARE_SWITCH = true;
         this.PopExitKind();
         this.MatchLineTerminator();
     }
 }
Пример #38
0
 private void Parse_FunctionHeading(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     this.Match("function");
     int num = 0x10;
     int num2 = this.BeginMethod(this.Parse_Ident(), MemberKind.Method, ml, num);
     if (base.IsCurrText('('))
     {
         this.Match('(');
         if (!base.IsCurrText(')'))
         {
             this.Parse_ParameterList(num2, false);
         }
         this.Match(')');
     }
     this.Match(":");
     this.Parse_Attributes();
     num = this.Parse_Type();
     this.Match(";");
     base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, num2, -1, -1);
     base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, base.CurrResultId, -1, -1);
     this.Gen(base.code.OP_ASSIGN_TYPE, num2, num, 0);
     this.Gen(base.code.OP_ASSIGN_TYPE, base.CurrResultId, num, 0);
     this.Parse_DirectiveList();
     base.SetForward(num2, true);
     this.EndMethod(num2);
     base.DECLARE_SWITCH = true;
 }
Пример #39
0
 private void Parse_DestructorDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     this.Match("destructor");
     int num = 1;
     this.valid_this_context = true;
     int num2 = this.BeginMethod(this.Parse_Ident(), MemberKind.Method, ml, num);
     this.Match(";");
     if (!this.Parse_ForwardMethodDeclaration(num2))
     {
         if (ck != ClassKind.Interface)
         {
             this.InitMethod(num2);
             this.Parse_LocalDeclarationPart();
             if (ml.HasModifier(Modifier.Abstract))
             {
                 string name = base.GetName(num2);
                 base.RaiseErrorEx(false, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { name });
             }
             base.DECLARE_SWITCH = false;
             this.Parse_CompoundStatement();
             this.Match(";");
         }
         this.EndMethod(num2);
         this.valid_this_context = false;
         base.DECLARE_SWITCH = true;
     }
 }
Пример #40
0
 private void Parse_FunctionDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     this.Match("Function");
     this.PushExitKind(ExitKind.Function);
     int id = this.Parse_Ident();
     this.CheckMethodModifiers(id, class_id, ml, owner_ml);
     int num2 = 0x10;
     this.valid_this_context = true;
     this.BeginMethod(id, MemberKind.Method, ml, num2);
     if (this.explicit_intf_id > 0)
     {
         this.Gen(base.code.OP_ADD_EXPLICIT_INTERFACE, id, this.explicit_intf_id, 0);
     }
     if (base.IsCurrText('('))
     {
         this.Match('(');
         if (!base.IsCurrText(')'))
         {
             this.Parse_ParameterList(id, false);
         }
         this.Match(')');
     }
     if (base.IsCurrText("As"))
     {
         this.Match("As");
         this.Parse_Attributes();
         num2 = this.Parse_Type();
         if (base.IsCurrText('('))
         {
             string str = this.Parse_TypeNameModifier();
             string str2 = base.GetName(num2) + str;
             num2 = base.NewVar();
             base.SetName(num2, str2);
             this.Gen(base.code.OP_EVAL_TYPE, 0, 0, num2);
         }
         base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, id, -1, -1);
         base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, base.CurrResultId, -1, -1);
         this.Gen(base.code.OP_ASSIGN_TYPE, id, num2, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, base.CurrResultId, num2, 0);
     }
     if (ml.HasModifier(Modifier.Extern))
     {
         base.RaiseErrorEx(false, "CS0179. '{0}' cannot be extern and declare a body.", new object[] { base.GetName(id) });
     }
     if (ck != ClassKind.Interface)
     {
         this.InitMethod(id);
         if (ml.HasModifier(Modifier.Abstract))
         {
             string name = base.GetName(id);
             base.RaiseErrorEx(false, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { name });
         }
         if (base.GetName(id) == "Main")
         {
             this.Gen(base.code.OP_CHECKED, base.TRUE_id, 0, 0);
         }
         if (base.IsCurrText("Handles"))
         {
             this.Parse_HandlesClause();
         }
         else if (base.IsCurrText("Implements"))
         {
             this.Parse_ImplementsClause(id);
         }
         base.DECLARE_SWITCH = false;
         this.MatchLineTerminator();
         this.Parse_Block();
         if (base.GetName(id) == "Main")
         {
             this.Gen(base.code.OP_RESTORE_CHECKED_STATE, 0, 0, 0);
         }
         this.Match("End");
         this.Match("Function");
     }
     this.EndMethod(id);
     this.valid_this_context = false;
     base.DECLARE_SWITCH = true;
     this.PopExitKind();
     this.MatchLineTerminator();
 }
Пример #41
0
 private void Parse_MethodMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     base.DECLARE_SWITCH = true;
     if (base.IsCurrText("procedure"))
     {
         this.Parse_ProcedureDeclaration(class_id, ml, owner_ml, ck);
     }
     else if (base.IsCurrText("function"))
     {
         this.Parse_FunctionDeclaration(class_id, ml, owner_ml, ck);
     }
     else if (base.IsCurrText("constructor"))
     {
         this.Parse_ConstructorDeclaration(class_id, ml, owner_ml, ck);
     }
     else if (base.IsCurrText("destructor"))
     {
         this.Parse_DestructorDeclaration(class_id, ml, owner_ml, ck);
     }
 }
Пример #42
0
 private void Parse_PropertyMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_modifiers, ClassKind ck)
 {
     this.Match("Property");
     int num = this.Parse_Ident();
     this.param_ids.Clear();
     this.param_type_ids.Clear();
     this.param_mods.Clear();
     if (base.IsCurrText('('))
     {
         this.Match('(');
         if (!base.IsCurrText(')'))
         {
             this.Parse_ParameterList(num, false);
         }
         this.Match(')');
     }
     int num2 = 0x10;
     if (base.IsCurrText("As"))
     {
         this.Match("As");
         this.Parse_Attributes();
         num2 = this.Parse_TypeEx();
         base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, num, -1, -1);
         this.Gen(base.code.OP_ASSIGN_TYPE, num, num2, 0);
     }
     base.BeginProperty(num, ml, num2, 0);
     if (ml.HasModifier(Modifier.Default))
     {
         if (this.param_ids.Count == 0)
         {
             base.RaiseError(false, "VB00004. Properties with no required parameters cannot be declared 'Default'.");
         }
         else
         {
             this.Gen(base.code.OP_SET_DEFAULT, num, 0, 0);
         }
     }
     if (base.IsCurrText("Implements"))
     {
         this.Parse_ImplementsClause(num);
     }
     int num3 = 0;
     int num4 = 0;
     Label_0110:
     this.MatchLineTerminator();
     this.Parse_Attributes();
     if (base.IsCurrText("Get"))
     {
         this.curr_prop_id = num;
         this.Match("Get");
         base.DECLARE_SWITCH = false;
         this.valid_this_context = true;
         this.MatchLineTerminator();
         int id = base.NewVar();
         base.SetName(id, "get_" + base.GetName(num));
         this.BeginMethod(id, MemberKind.Method, ml, num2);
         num3++;
         if (num3 > 1)
         {
             base.RaiseError(true, "CS1008. Type byte, sbyte, short, ushort, int, uint, long, or ulong expected.");
         }
         for (int i = 0; i < this.param_ids.Count; i++)
         {
             base.DiscardInstruction(base.code.OP_ADD_PARAM, num, -1, -1);
             int num7 = base.NewVar();
             base.SetName(num7, base.GetName(this.param_ids[i]));
             this.Gen(base.code.OP_ASSIGN_TYPE, num7, this.param_type_ids[i], 0);
             this.Gen(base.code.OP_ADD_PARAM, id, num7, 0);
         }
         this.InitMethod(id);
         this.Parse_Block();
         this.EndMethod(id);
         this.Gen(base.code.OP_ADD_READ_ACCESSOR, num, id, 0);
         base.DECLARE_SWITCH = true;
         this.valid_this_context = false;
         this.Match("End");
         this.Match("Get");
         this.curr_prop_id = 0;
         goto Label_0110;
     }
     if (base.IsCurrText("Set"))
     {
         this.valid_this_context = true;
         this.Match("Set");
         int num8 = base.NewVar();
         base.SetName(num8, "set_" + base.GetName(num));
         this.BeginMethod(num8, MemberKind.Method, ml, num2);
         num4++;
         if (num4 > 1)
         {
             base.RaiseError(true, "CS1008. Type byte, sbyte, short, ushort, int, uint, long, or ulong expected.");
         }
         if (this.IsLineTerminator())
         {
             int num9;
             for (int j = 0; j < this.param_ids.Count; j++)
             {
                 num9 = base.NewVar();
                 base.SetName(num9, base.GetName(this.param_ids[j]));
                 this.Gen(base.code.OP_ASSIGN_TYPE, num9, this.param_type_ids[j], 0);
                 this.Gen(base.code.OP_ADD_PARAM, num8, num9, 0);
             }
             num9 = base.NewVar();
             base.SetName(num9, "value");
             this.Gen(base.code.OP_ADD_PARAM, num8, num9, 0);
             this.Gen(base.code.OP_ASSIGN_TYPE, num9, num2, 0);
             base.DECLARE_SWITCH = false;
             this.InitMethod(num8);
             this.MatchLineTerminator();
         }
         else
         {
             if (base.IsCurrText('('))
             {
                 for (int k = 0; k < this.param_ids.Count; k++)
                 {
                     int num12 = base.NewVar();
                     base.SetName(num12, base.GetName(this.param_ids[k]));
                     this.Gen(base.code.OP_ASSIGN_TYPE, num12, this.param_type_ids[k], 0);
                     this.Gen(base.code.OP_ADD_PARAM, num8, num12, 0);
                 }
                 this.Match('(');
                 if (!base.IsCurrText(')'))
                 {
                     this.Parse_ParameterList(num8, false);
                 }
                 this.Match(')');
             }
             base.DECLARE_SWITCH = false;
             this.InitMethod(num8);
             this.MatchLineTerminator();
         }
         this.Parse_Block();
         this.EndMethod(num8);
         this.Gen(base.code.OP_ADD_WRITE_ACCESSOR, num, num8, 0);
         base.DECLARE_SWITCH = true;
         this.valid_this_context = false;
         this.Match("End");
         this.Match("Set");
         goto Label_0110;
     }
     base.EndProperty(num);
     if ((num3 + num4) == 0)
     {
         if (ml.HasModifier(Modifier.Abstract))
         {
             return;
         }
         base.RaiseErrorEx(true, "CS0548. '{0}' : property or indexer must have at least one accessor.", new object[] { base.GetName(num) });
     }
     this.Match("End");
     this.Match("Property");
     this.MatchLineTerminator();
 }
Пример #43
0
 private void Parse_ProcedureDeclaration(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     this.Match("procedure");
     int num2 = 1;
     this.valid_this_context = true;
     int num = this.BeginMethod(this.Parse_Ident(), MemberKind.Method, ml, num2);
     if (base.IsCurrText('('))
     {
         this.Match('(');
         if (!base.IsCurrText(')'))
         {
             this.Parse_ParameterList(num, false);
         }
         this.Match(')');
     }
     this.Match(";");
     if (!this.Parse_ForwardMethodDeclaration(num))
     {
         if (ck != ClassKind.Interface)
         {
             this.InitMethod(num);
             this.Parse_LocalDeclarationPart();
             if (ml.HasModifier(Modifier.Abstract))
             {
                 string name = base.GetName(num);
                 base.RaiseErrorEx(false, "CS0500. '{0}' cannot declare a body because it is marked abstract.", new object[] { name });
             }
             if (base.GetName(num) == "Main")
             {
                 this.Gen(base.code.OP_CHECKED, base.TRUE_id, 0, 0);
             }
             base.DECLARE_SWITCH = false;
             this.Parse_CompoundStatement();
             this.Match(";");
             if (base.GetName(num) == "Main")
             {
                 this.Gen(base.code.OP_RESTORE_CHECKED_STATE, 0, 0, 0);
             }
         }
         this.EndMethod(num);
         this.valid_this_context = false;
         base.DECLARE_SWITCH = true;
     }
 }
Пример #44
0
        /// <summary>
        /// Sets the readonly ClassKind property of an object using reflection
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of the object</typeparam>
        /// <param name="obj">The object</param>
        /// <param name="classKind">The <see cref="ClassKind"/></param>
        private void SetClassKind <T>(T obj, ClassKind classKind)
        {
            var field = typeof(RelationalExpression).GetField("<ClassKind>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);

            field?.SetValue(obj, classKind);
        }
Пример #45
0
 private void Parse_ProcedureHeading(int class_id, ModifierList ml, ModifierList owner_ml, ClassKind ck)
 {
     this.Match("procedure");
     int num2 = 1;
     int num = this.BeginMethod(this.Parse_Ident(), MemberKind.Method, ml, num2);
     if (base.IsCurrText('('))
     {
         this.Match('(');
         if (!base.IsCurrText(')'))
         {
             this.Parse_ParameterList(num, false);
         }
         this.Match(')');
     }
     this.Match(";");
     this.Parse_DirectiveList();
     base.SetForward(num, true);
     this.EndMethod(num);
     base.DECLARE_SWITCH = true;
 }
Пример #46
0
        /// <summary>
        /// Returns the <see cref="Uri"/> of the resource
        /// </summary>
        /// <param name="classKind">
        /// The <see cref="ClassKind"/> for which in icon needs to be provided
        /// </param>
        /// <param name="getsmallicon">
        /// Indicates whether a small or large icon should be returned.
        /// </param>
        /// <returns>
        /// A <see cref="Uri"/> that points to a resource
        /// </returns>
        public static object ImageUri(ClassKind classKind, bool getsmallicon = true)
        {
            DXImageInfo imageInfo;

            var compositionroot = "pack://application:,,,/CDP4Composition;component/Resources/Images/Thing/";
            var imagesize       = getsmallicon ? "_16x16" : "_32x32";
            var imagename       = string.Empty;
            var imageextension  = ".png";

            switch (classKind)
            {
            case ClassKind.BinaryRelationship:
                imagename = "LineItem";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.MultiRelationship:
                imagename = "Line2";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.PossibleFiniteState:
            case ClassKind.PossibleFiniteStateList:
                return("pack://application:,,,/CDP4Composition;component/Resources/Images/Thing/PossibleFiniteState_48x48.png");

            case ClassKind.ActualFiniteState:
            case ClassKind.ActualFiniteStateList:
                return("pack://application:,,,/CDP4Composition;component/Resources/Images/Thing/ActualFiniteState_48x48.png");

            case ClassKind.NaturalLanguage:
                return("pack://application:,,,/CDP4Composition;component/Resources/Images/Thing/naturallanguage.png");

            case ClassKind.Requirement:
                return("pack://application:,,,/CDP4Composition;component/Resources/Images/Thing/requirement.png");

            case ClassKind.Book:
                return("pack://application:,,,/CDP4Composition;component/Resources/Images/Thing/Book.png");

            case ClassKind.Page:
                imagename = "ListBox";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Section:
                imagename = "Reading";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.BinaryNote:
            case ClassKind.TextualNote:
                imagename = "Notes";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.DiagramCanvas:
                imagename = "LabelsRight";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.SimpleUnit:
            case ClassKind.PrefixedUnit:
            case ClassKind.LinearConversionUnit:
            case ClassKind.DerivedUnit:
            case ClassKind.MeasurementUnit:
                imagename = "measurementunit";

                return($"{compositionroot}{imagename}{imagesize}{imageextension}");

            case ClassKind.UnitPrefix:
                imagename = "VerticalAxisThousands";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.RequirementsContainer:
            case ClassKind.RequirementsGroup:
                imagename = "ListBox";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.RequirementsSpecification:
                imagename = "BOReport";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.IntervalScale:
            case ClassKind.LogarithmicScale:
            case ClassKind.OrdinalScale:
            case ClassKind.RatioScale:
            case ClassKind.CyclicRatioScale:
            case ClassKind.MeasurementScale:
                imagename = "ChartYAxisSettings";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Constant:
                imagename = "RecentlyUse";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.BinaryRelationshipRule:
                imagename = "LineItem";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Organization:
                imagename = "Organization";

                return($"{compositionroot}{imagename}{imagesize}{imageextension}");

            case ClassKind.Rule:
                imagename = "TreeView";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.DecompositionRule:
                imagename = "TreeView";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.MultiRelationshipRule:
                imagename = "DocumentMap";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ParameterizedCategoryRule:
                imagename = "FixedWidth";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ReferencerRule:
                imagename = "Tag";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.SiteDirectory:
                imagename = "Database";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.EngineeringModelSetup:
            case ClassKind.EngineeringModel:
                imagename = "Technology";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ParametricConstraint:
                imagename = "ShowFormulas";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.NotExpression:
            case ClassKind.AndExpression:
            case ClassKind.OrExpression:
            case ClassKind.ExclusiveOrExpression:
            case ClassKind.RelationalExpression:
            case ClassKind.BooleanExpression:
                imagename = "UseInFormula";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.File:
                imagename = "BOFileAttachment";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.FileRevision:
                imagename = "Version";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Folder:
            case ClassKind.NotThing:
                imagename = "BOFolder";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Participant:
                imagename = "Employee";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Iteration:
            case ClassKind.IterationSetup:
                imagename = "GroupFieldCollection";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ElementDefinition:
                imagename = "Product";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ElementUsage:
                imagename = "Version";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ParameterGroup:
                imagename = "BOFolder";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Parameter:
            case ClassKind.SimpleParameterValue:
                imagename = "Stepline";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ParameterValueSet:
            case ClassKind.ParameterOverrideValueSet:
            case ClassKind.ParameterSubscriptionValueSet:
            case ClassKind.ParameterValueSetBase:
                imagename = "DocumentMap";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ParameterSubscription:
                imagename = "LabelsCenter";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ParameterOverride:
                imagename = "LabelsBelow";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Category:
                imagename = "category";

                return($"{compositionroot}{imagename}{imagesize}{imageextension}");

            case ClassKind.PersonRole:
            case ClassKind.ParticipantRole:
                imagename = "BOUser";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Person:
                imagename = "Customer";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.PersonPermission:
            case ClassKind.ParticipantPermission:
                imagename = "BOPermission";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ReferenceSource:
                imagename = "Information";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.EmailAddress:
                imagename = "Mail";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.TelephoneNumber:
                imagename = "BOContact";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.UserPreference:
                imagename = "Technology";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.DomainOfExpertise:
                imagename = "domainofexpertise";

                return($"{compositionroot}{imagename}{imagesize}{imageextension}");

            case ClassKind.ModelReferenceDataLibrary:
            case ClassKind.SiteReferenceDataLibrary:
                imagename = "siteRdl";

                return($"{compositionroot}{imagename}{imagesize}{imageextension}");

            case ClassKind.SimpleQuantityKind:
            case ClassKind.DerivedQuantityKind:
            case ClassKind.SpecializedQuantityKind:
            case ClassKind.ArrayParameterType:
            case ClassKind.BooleanParameterType:
            case ClassKind.CompoundParameterType:
            case ClassKind.DateParameterType:
            case ClassKind.DateTimeParameterType:
            case ClassKind.EnumerationParameterType:
            case ClassKind.ScalarParameterType:
            case ClassKind.TextParameterType:
            case ClassKind.TimeOfDayParameterType:
            case ClassKind.SampledFunctionParameterType:
            case ClassKind.ParameterType:
                imagename = "NameManager";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ParameterTypeComponent:
                imagename = "Between";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Definition:
                imagename = "SendBehindText";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Option:
                imagename = "Properties";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Term:
                imagename = "TextBox";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Glossary:
                imagename = "Text";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.FileType:
                imagename = "TextBox2";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.Publication:
                imagename = "CreateModelDifferences";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.CommonFileStore:
                imagename = "Project";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.DomainFileStore:
                imagename = "Project";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ChangeRequest:
            case ClassKind.RequestForDeviation:
            case ClassKind.RequestForWaiver:
                imagename = "EditComment";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ActionItem:
                imagename = "GroupByResource";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ChangeProposal:
                imagename = "PreviousComment";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            case ClassKind.ReviewItemDiscrepancy:
                imagename = "InsertComment";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());

            default:
                // TODO: create default Thing icon to be used accross the app after the branding change. Default for now uses Iteration setup icon.
                imagename = "Technology";
                imageInfo = new DXImageConverter().ConvertFrom($"{imagename}{imagesize}{imageextension}") as DXImageInfo;

                return(imageInfo.MakeUri().ToString());
            }
        }
Пример #47
0
 private void Parse_PropertyMemberDeclaration(int class_id, ModifierList ml, ModifierList owner_modifiers, ClassKind ck)
 {
     base.DECLARE_SWITCH = true;
     this.Match("property");
     int num = this.Parse_Ident();
     this.param_ids.Clear();
     this.param_type_ids.Clear();
     this.param_mods.Clear();
     IntegerList list = new IntegerList(true);
     if (base.IsCurrText('['))
     {
         this.Match('[');
         if (!base.IsCurrText(']'))
         {
             this.Parse_ParameterList(num, false);
         }
         this.Match(']');
     }
     base.DECLARE_SWITCH = false;
     this.Match(":");
     int num2 = this.Parse_Type();
     base.DiscardInstruction(base.code.OP_ASSIGN_TYPE, num, -1, -1);
     this.Gen(base.code.OP_ASSIGN_TYPE, num, num2, 0);
     int id = 0;
     int iD = 0;
     if (base.IsCurrText("read"))
     {
         this.Call_SCANNER();
         id = this.Parse_Ident();
         string name = base.GetName(id);
         base.DiscardInstruction(base.code.OP_EVAL, 0, 0, id);
         base.SetName(id, "");
         id = base.LookupID(name);
         if (id == 0)
         {
             base.RaiseErrorEx(true, "Undeclared identifier '{0}'", new object[] { name });
         }
     }
     if (base.IsCurrText("write"))
     {
         this.Call_SCANNER();
         iD = this.Parse_Ident();
         string s = base.GetName(iD);
         base.DiscardInstruction(base.code.OP_EVAL, 0, 0, iD);
         base.SetName(iD, "");
         iD = base.LookupID(s);
         if (iD == 0)
         {
             base.RaiseErrorEx(true, "Undeclared identifier '{0}'", new object[] { s });
         }
     }
     base.BeginProperty(num, ml, num2, 0);
     if (id > 0)
     {
         this.valid_this_context = true;
         int num5 = base.NewVar();
         base.SetName(num5, "get_" + base.GetName(num));
         this.BeginMethod(num5, MemberKind.Method, ml, num2);
         list.Clear();
         for (int i = 0; i < this.param_ids.Count; i++)
         {
             base.DiscardInstruction(base.code.OP_ADD_PARAM, num, -1, -1);
             int num7 = base.NewVar();
             base.SetName(num7, base.GetName(this.param_ids[i]));
             this.Gen(base.code.OP_ASSIGN_TYPE, num7, this.param_type_ids[i], 0);
             this.Gen(base.code.OP_ADD_PARAM, num5, num7, 0);
             list.Add(num7);
         }
         this.InitMethod(num5);
         if (base.GetKind(id) == MemberKind.Method)
         {
             int res = base.NewRef(base.GetName(id));
             this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, res);
             this.Gen(base.code.OP_BEGIN_CALL, res, 0, 0);
             for (int j = 0; j < this.param_ids.Count; j++)
             {
                 this.Gen(base.code.OP_PUSH, list[j], 0, res);
             }
             this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
             this.Gen(base.code.OP_CALL, res, this.param_ids.Count, base.CurrResultId);
         }
         else if (base.GetKind(id) == MemberKind.Field)
         {
             if (this.param_ids.Count > 0)
             {
                 base.RaiseError(false, "PAS0002. Incompatible types");
             }
             int num10 = base.NewRef(base.GetName(id));
             this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num10);
             this.Gen(base.code.OP_ASSIGN, base.CurrResultId, num10, base.CurrResultId);
         }
         else
         {
             base.RaiseError(false, "PAS0001. Field or method identifier expected");
         }
         this.EndMethod(num5);
         this.Gen(base.code.OP_ADD_READ_ACCESSOR, num, num5, 0);
         this.valid_this_context = false;
     }
     if (iD > 0)
     {
         int num12;
         this.valid_this_context = true;
         int num11 = base.NewVar();
         base.SetName(num11, "set_" + base.GetName(num));
         this.BeginMethod(num11, MemberKind.Method, ml, num2);
         list.Clear();
         for (int k = 0; k < this.param_ids.Count; k++)
         {
             base.DiscardInstruction(base.code.OP_ADD_PARAM, num, -1, -1);
             num12 = base.NewVar();
             base.SetName(num12, base.GetName(this.param_ids[k]));
             this.Gen(base.code.OP_ASSIGN_TYPE, num12, this.param_type_ids[k], 0);
             this.Gen(base.code.OP_ADD_PARAM, num11, num12, 0);
             list.Add(num12);
         }
         num12 = base.NewVar();
         base.SetName(num12, "value");
         this.Gen(base.code.OP_ADD_PARAM, num11, num12, 0);
         this.Gen(base.code.OP_ASSIGN_TYPE, num12, num2, 0);
         list.Add(num12);
         this.InitMethod(num11);
         if (base.GetKind(iD) == MemberKind.Method)
         {
             int num14 = base.NewRef(base.GetName(iD));
             this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num14);
             this.Gen(base.code.OP_BEGIN_CALL, num14, 0, 0);
             for (int m = 0; m < list.Count; m++)
             {
                 this.Gen(base.code.OP_PUSH, list[m], 0, num14);
             }
             this.Gen(base.code.OP_PUSH, base.CurrThisID, 0, 0);
             this.Gen(base.code.OP_CALL, num14, list.Count, base.CurrResultId);
         }
         else if (base.GetKind(iD) == MemberKind.Field)
         {
             if (this.param_ids.Count > 0)
             {
                 base.RaiseError(false, "PAS0002. Incompatible types");
             }
             int num16 = base.NewRef(base.GetName(iD));
             this.Gen(base.code.OP_CREATE_REFERENCE, base.CurrThisID, 0, num16);
             this.Gen(base.code.OP_ASSIGN, num16, num12, num16);
         }
         else
         {
             base.RaiseError(false, "PAS0001. Field or method identifier expected");
         }
         this.EndMethod(num11);
         this.Gen(base.code.OP_ADD_WRITE_ACCESSOR, num, num11, 0);
         this.valid_this_context = false;
     }
     this.Match(";");
     if (base.IsCurrText("default"))
     {
         this.Call_SCANNER();
         if (this.param_ids.Count == 0)
         {
             base.RaiseError(false, "VB00004. Properties with no required parameters cannot be declared 'Default'.");
         }
         else
         {
             this.Gen(base.code.OP_SET_DEFAULT, num, 0, 0);
         }
         this.Match(";");
     }
     base.EndProperty(num);
     base.DECLARE_SWITCH = true;
 }
Пример #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ContextMenuItemViewModel"/> class
 /// </summary>
 /// <param name="header">The header for this menu item</param>
 /// <param name="inputGestureText">The Input Gesture text can shows a keyboard combination</param>
 /// <param name="command">The <see cref="ICommand"/> bound to this command</param>
 /// <param name="menuItemKind">The <see cref="MenuItemKind"/> of this <see cref="ContextMenuItemViewModel"/></param>
 /// <param name="thingKind">The <see cref="ClassKind"/> this menu-item operates on</param>
 public ContextMenuItemViewModel(string header, string inputGestureText, ICommand command, MenuItemKind menuItemKind = MenuItemKind.None, ClassKind thingKind = ClassKind.Thing)
 {
     this.Header           = header;
     this.InputGestureText = inputGestureText;
     this.MenuCommand      = command;
     this.MenuItemKind     = menuItemKind;
     this.thingKind        = thingKind;
     this.SubMenu          = new List <ContextMenuItemViewModel>();
 }
Пример #49
0
 private void Parse_ClassMemberDeclaration(int class_id, ModifierList owner_modifiers, bool IsModule, ClassKind ck)
 {
     this.Parse_Attributes();
     ModifierList ml = new ModifierList();
     ml.Add(Modifier.Public);
     if (base.IsCurrText("private"))
     {
         this.Call_SCANNER();
     }
     else if (base.IsCurrText("protected"))
     {
         this.Call_SCANNER();
     }
     if (base.IsCurrText("public"))
     {
         this.Call_SCANNER();
     }
     if (owner_modifiers.HasModifier(Modifier.Public) && !ml.HasModifier(Modifier.Private))
     {
         ml.Add(Modifier.Public);
     }
     if (base.IsCurrText("type"))
     {
         this.Parse_TypeDeclaration(class_id, owner_modifiers);
     }
     else if (base.IsCurrText("var"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_VariableMemberDeclaration(class_id, ml, owner_modifiers, IsModule);
     }
     else if (base.IsCurrText("const"))
     {
         ml.Add(Modifier.Static);
         this.Parse_ConstantMemberDeclaration(class_id, ml, owner_modifiers, IsModule);
     }
     else if (base.IsCurrText("constructor"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else if (base.IsCurrText("destructor"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else if (base.IsCurrText("procedure"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else if (base.IsCurrText("function"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_MethodMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else if (base.IsCurrText("property"))
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_PropertyMemberDeclaration(class_id, ml, owner_modifiers, ck);
     }
     else
     {
         if (IsModule)
         {
             ml.Add(Modifier.Static);
         }
         this.Parse_VariableMemberDeclaration(class_id, ml, owner_modifiers, IsModule);
     }
 }