Beispiel #1
0
        public Scope CreateChildScope(IEntityDeclaration entity)
        {
            //TODO: Constant SELF
            var builder = DeclaredIdentifiers.ToBuilder();

            //TODO: renaming
            foreach (var attribute in GetAttributesWithInherited(entity))
            {
                builder[attribute.Name] = attribute;
            }


            return(new Scope(builder.ToImmutable(), DeclaredDataTypes));
        }
Beispiel #2
0
        public Scope CreateChildScope(ITypeDeclaration type)
        {
            var builder = DeclaredIdentifiers.ToBuilder();

            if (TryGetDeclaredEnumerationItems(type, out var enumerationDeclarations))
            {
                foreach (var item in enumerationDeclarations)
                {
                    builder[item.Name] = item;
                }
            }

            //TODO: Constant SELF

            return(new Scope(builder.ToImmutable(), DeclaredDataTypes));
        }
Beispiel #3
0
        public Scope CreateChildScope(IRuleDeclaration rule)
        {
            var builder = DeclaredIdentifiers.ToBuilder();

            //TODO: declarations
            //TODO: type labels (?)

            foreach (var population in rule.Populations)
            {
                builder[population.Name] = population;
            }

            foreach (var variable in rule.LocalVariables)
            {
                builder[variable.Name] = variable;
            }

            return(new Scope(builder.ToImmutable(), DeclaredDataTypes));
        }
Beispiel #4
0
        public Scope CreateChildScope(IFunctionDeclaration function)
        {
            var builder = DeclaredIdentifiers.ToBuilder();

            //TODO: declarations
            //TODO: type labels

            foreach (var parameter in function.Parameters)
            {
                builder[parameter.Name] = parameter;
            }

            foreach (var variable in function.LocalVariables)
            {
                builder[variable.Name] = variable;
            }

            return(new Scope(builder.ToImmutable(), DeclaredDataTypes));
        }
Beispiel #5
0
        public Scope CreateChildScope(ISchemaDeclaration schema)
        {
            var identifers = DeclaredIdentifiers.ToBuilder();
            var dataTypes  = DeclaredDataTypes.ToBuilder();

            var importedEnumerationItems = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            //TODO: duplicate identifiers
            foreach (var declaration in schema.Declarations)
            {
                identifers[declaration.Name] = declaration;

                if (IsNamedDataType(declaration))
                {
                    dataTypes[declaration.Name] = declaration;
                }

                if (declaration is ITypeDeclaration typeDeclaration)
                {
                    if (TryGetDeclaredEnumerationItems(typeDeclaration, out var enumerationDeclarations))
                    {
                        foreach (var enumerationDeclaration in enumerationDeclarations)
                        {
                            if (importedEnumerationItems.Add(enumerationDeclaration.Name))
                            {
                                identifers[enumerationDeclaration.Name] = enumerationDeclaration;
                            }
                            else
                            {
                                identifers.Remove(enumerationDeclaration.Name);
                            }
                        }
                    }
                }
            }

            return(new Scope(identifers.ToImmutable(), dataTypes.ToImmutable()));
        }