Пример #1
0
        private void CreateOrUpdateLinkageSection(Compiler.Nodes.FunctionDeclaration node, ParametersProfile profile)
        {
            var linkage    = node.Get <Compiler.Nodes.LinkageSection>("linkage");
            var parameters = profile.InputParameters.Count + profile.InoutParameters.Count + profile.OutputParameters.Count + (profile.ReturningParameter != null? 1:0);
            IReadOnlyList <DataDefinition> data = new List <DataDefinition>().AsReadOnly();

            if (linkage == null && parameters > 0)
            {
                var datadiv = node.Get <Compiler.Nodes.DataDivision>("data-division");
                if (datadiv == null)
                {
                    datadiv = new DataDivision();
                    children.Add(datadiv);
                }
                linkage = new LinkageSection();
                datadiv.Add(linkage);
            }
            if (linkage != null)
            {
                data = linkage.Children().ToList();
            }
            // TCRFUN_CODEGEN_PARAMETERS_ORDER
            var generated = new List <string>();

            foreach (var parameter in profile.InputParameters)
            {
                if (!generated.Contains(parameter.Name) && !Contains(data, parameter.Name))
                {
                    linkage.Add(CreateParameterEntry(parameter, node.SymbolTable));
                    generated.Add(parameter.Name);
                }
            }
            foreach (var parameter in profile.InoutParameters)
            {
                if (!generated.Contains(parameter.Name) && !Contains(data, parameter.Name))
                {
                    linkage.Add(CreateParameterEntry(parameter, node.SymbolTable));
                    generated.Add(parameter.Name);
                }
            }
            foreach (var parameter in profile.OutputParameters)
            {
                if (!generated.Contains(parameter.Name) && !Contains(data, parameter.Name))
                {
                    linkage.Add(CreateParameterEntry(parameter, node.SymbolTable));
                    generated.Add(parameter.Name);
                }
            }
            if (profile.ReturningParameter != null)
            {
                if (!generated.Contains(profile.ReturningParameter.Name) && !Contains(data, profile.ReturningParameter.Name))
                {
                    linkage.Add(CreateParameterEntry(profile.ReturningParameter, node.SymbolTable));
                    generated.Add(profile.ReturningParameter.Name);
                }
            }
        }
 private void CreateOrUpdateLinkageSection(Compiler.Nodes.FunctionDeclaration node, ParametersProfile profile)
 {
     var linkage = node.Get<Compiler.Nodes.LinkageSection>("linkage");
     var parameters = profile.InputParameters.Count + profile.InoutParameters.Count + profile.OutputParameters.Count + (profile.ReturningParameter != null? 1:0);
     IReadOnlyList<DataDefinition> data = new List<DataDefinition>().AsReadOnly();
     if (linkage == null && parameters > 0) {
         var datadiv = node.Get<Compiler.Nodes.DataDivision>("data-division");
         if (datadiv == null) {
             datadiv = new DataDivision();
             children.Add(datadiv);
         }
         linkage = new LinkageSection();
         datadiv.Add(linkage);
     }
     if (linkage != null) data = linkage.Children();
     // TCRFUN_CODEGEN_PARAMETERS_ORDER
     var generated = new List<string>();
     foreach(var parameter in profile.InputParameters) {
         if (!generated.Contains(parameter.Name) && !Contains(data, parameter.Name)) {
             linkage.Add(CreateParameterEntry(parameter, node.SymbolTable));
             generated.Add(parameter.Name);
         }
     }
     foreach(var parameter in profile.InoutParameters) {
         if (!generated.Contains(parameter.Name) && !Contains(data, parameter.Name)) {
             linkage.Add(CreateParameterEntry(parameter, node.SymbolTable));
             generated.Add(parameter.Name);
         }
     }
     foreach(var parameter in profile.OutputParameters) {
         if (!generated.Contains(parameter.Name) && !Contains(data, parameter.Name)) {
             linkage.Add(CreateParameterEntry(parameter, node.SymbolTable));
             generated.Add(parameter.Name);
         }
     }
     if (profile.ReturningParameter != null) {
         if (!generated.Contains(profile.ReturningParameter.Name) && !Contains(data, profile.ReturningParameter.Name)) {
             linkage.Add(CreateParameterEntry(profile.ReturningParameter, node.SymbolTable));
             generated.Add(profile.ReturningParameter.Name);
         }
     }
 }