public void Freeze() { _frozen = true; DirectlyUsedVariables = new ReadOnlySet <IVariable>(DirectlyUsedVariables); DirectlyDeclaredVariables = new ReadOnlySet <IVariable>(DirectlyDeclaredVariables); NestedFunctions = NestedFunctions.AsReadOnly(); }
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); }
public Function ToFunction() { return (new Function( _name, _lineNo, _parameterNames.ToList(), _directives, DeclaredVariables.ToList(), NestedFunctions.ToList(), FunctionBody, _isDeclaration)); }
public void Free() { foreach (var scope in NestedScopes) { scope.Free(); } NestedScopes.Free(); foreach (var function in NestedFunctions) { function.Free(); } NestedFunctions.Free(); }