public void Freeze()
 {
     _frozen = true;
     DirectlyUsedVariables     = new ReadOnlySet <IVariable>(DirectlyUsedVariables);
     DirectlyDeclaredVariables = new ReadOnlySet <IVariable>(DirectlyDeclaredVariables);
     NestedFunctions           = NestedFunctions.AsReadOnly();
 }
Exemplo n.º 2
0
        public override void Validate(ComputationContext ctx)
        {
            base.Validate(ctx);

            {   // detecting function duplicates
                var functions = NestedFunctions.StoreReadOnlyList();
                for (int a = 0; a < functions.Count; ++a)
                {
                    for (int b = a + 1; b < functions.Count; ++b)
                    {
                        FunctionDefinition func_a = functions[a];
                        FunctionDefinition func_b = functions[b];

                        if (FunctionDefinitionExtension.IsOverloadedDuplicate(func_a, func_b))
                        {
                            ctx.ErrorManager.AddError(ErrorCode.OverloadingDuplicateFunctionDefinition, func_b, func_a);
                        }
                    }
                }
            }

            // detecting entity duplicates
            foreach (IEntity entity in this.NestedFields.Select(it => it.Cast <IEntity>())
                     .Concat(this.NestedTypes().Where(it => !it.IsTrait))
                     .Concat(this.NestedProperties.Where(it => !it.IsIndexer))
                     .GroupBy(it => it.Name, EntityNameArityComparer.Instance)
                     .Select(group => group.Skip(1).FirstOrDefault())
                     .Where(it => it != null))
            {
                ctx.ErrorManager.AddError(ErrorCode.NameAlreadyExists, entity);
            }

            IEntityScopeExtension.Validate(this, ctx);
        }
Exemplo n.º 3
0
 public Function ToFunction()
 {
     return
         (new Function(
              _name,
              _lineNo,
              _parameterNames.ToList(),
              _directives,
              DeclaredVariables.ToList(),
              NestedFunctions.ToList(),
              FunctionBody,
              _isDeclaration));
 }
Exemplo n.º 4
0
                public void Free()
                {
                    foreach (var scope in NestedScopes)
                    {
                        scope.Free();
                    }
                    NestedScopes.Free();

                    foreach (var function in NestedFunctions)
                    {
                        function.Free();
                    }
                    NestedFunctions.Free();
                }