Esempio n. 1
0
        private DOM.Antlr.AliasDefinition LookupAliasDef(DOM.Antlr.Alias alias)
        {
            if (alias.AliasDefinition != null)
            {
                return(alias.AliasDefinition == AliasDefinition.Undefined ? null : alias.AliasDefinition);
            }

            var result = _context.NamespaceResolver.GetAliasDefinition(alias.Name);

            alias.AliasDefinition = result ?? AliasDefinition.Undefined;
            return(result);
        }
Esempio n. 2
0
        private int CalcNumOfRootElements(DOM.Antlr.Alias alias, List <DOM.AliasDefinition> aliasList)
        {
            int result   = 0;
            var aliasDef = LookupAliasDef(alias);

            if (aliasDef == null)
            {
                return(0);
            }

            //Checking if there is circular reference to prevent infinite loop.
            if (aliasList == null)
            {
                aliasList = new List <DOM.AliasDefinition>();
            }

            if (aliasList.Any(n => n == aliasDef))
            {
                return(0);
            }

            aliasList.Add(aliasDef);

            foreach (var entity in aliasDef.Entities)
            {
                if (entity is DOM.Element)
                {
                    result++;
                }
                var aliasEntity = entity as DOM.Antlr.Alias;
                if (aliasEntity != null)
                {
                    result += CalcNumOfRootElements(aliasEntity, aliasList);
                }
            }

            return(result);
        }
Esempio n. 3
0
        private NsInfo ResolveAliasInModuleMember(DOM.Antlr.Alias alias, NsInfo memberNsInfo)
        {
            //Finding AliasDef
            var aliasDef = LookupAliasDef(alias);

            if (aliasDef == null)
            {
                //Report Error if alias is not defined
                _context.AddError(CompilerErrorFactory.AliasIsNotDefined(alias, memberNsInfo.ModuleMember.Module.FileName));
                return(null);
            }

            if (aliasDef.IsValueNode != alias.IsValueNode)
            {
                _context.AddError(aliasDef.IsValueNode
                    ? CompilerErrorFactory.CantUseValueAliasInTheBlock(alias, memberNsInfo.ModuleMember.Module.FileName)
                    : CompilerErrorFactory.CantUseBlockAliasAsValue(alias, memberNsInfo.ModuleMember.Module.FileName));
            }


            CheckAliasArguments(alias, aliasDef, memberNsInfo);

            return(ResolveAliasesInAliasDefinition(aliasDef));
        }
Esempio n. 4
0
        private void CheckDuplicateArguments(DOM.Antlr.Alias alias)
        {
            var dups = alias.Arguments.GroupBy(a => a.Name).Where(g => g.Count() > 1).SelectMany(g => g).ToList();

            dups.ForEach(a => _context.AddError(CompilerErrorFactory.DuplicateArgumentName(a, _currentModule.FileName)));
        }
Esempio n. 5
0
 /// <summary>
 /// Adds Alias to the Namespace Info of the current Module Member.
 /// </summary>
 /// <param name="node"></param>
 public void AddAlias(DOM.Antlr.Alias node)
 {
     CurrentModuleMemberNsInfo.Aliases.Add(node);
 }
Esempio n. 6
0
 public void ProcessAlias(DOM.Antlr.Alias node)
 {
     CheckDuplicateArguments(node);
 }