Пример #1
0
        private void ConvertStructDecl(Grammar.ASTNodeDeclStruct structNode, Core.Name curNamespace, List <Core.UseDirective> useDirectives)
        {
            var name = curNamespace.Concatenate(NameResolver.Resolve(structNode.name));

            if (!ValidateName(name, structNode.name.GetSpan()))
            {
                return;
            }

            var structIndex = this.session.CreateStruct(name, structNode);

            foreach (var structUseNode in structNode.useDirectives)
            {
                useDirectives.Add(UseDirectiveResolver.Resolve(structUseNode));
            }

            this.structWorkData.Add(new StructWorkData
            {
                name          = name,
                declNode      = structNode,
                declIndex     = structIndex,
                useDirectives = useDirectives.ToArray()
            });

            foreach (var structUseNode in structNode.useDirectives)
            {
                useDirectives.RemoveAt(useDirectives.Count - 1);
            }
        }
Пример #2
0
        private void ConvertDeclGroup(Grammar.ASTNodeDeclGroup declGroup, Core.Name curNamespace, List <Core.UseDirective> useDirectives)
        {
            var useDirectiveCountBefore = useDirectives.Count;

            foreach (var useNode in declGroup.useDirectives)
            {
                useDirectives.Add(UseDirectiveResolver.Resolve(useNode));
            }

            foreach (var structNode in declGroup.structDecls)
            {
                this.ConvertStructDecl(structNode, curNamespace, useDirectives);
            }

            foreach (var functNode in declGroup.functDecls)
            {
                this.ConvertFunctDecl(functNode, curNamespace, useDirectives);
            }

            foreach (var namespaceNode in declGroup.namespaceDecls)
            {
                this.ConvertNamespaceDecl(namespaceNode, curNamespace, useDirectives);
            }

            while (useDirectives.Count > useDirectiveCountBefore)
            {
                useDirectives.RemoveAt(useDirectives.Count - 1);
            }
        }