Beispiel #1
0
 /// <summary>Creates functions or procedure</summary>
 public Function(QualifiedName name, IList<ParameterDescriptionEntry> inputs, IList<ParameterDescriptionEntry> outputs, IList<ParameterDescriptionEntry> inouts, ParameterDescriptionEntry returning, AccessModifier visibility = AccessModifier.Private)
 {
     QualifiedName = name;
     Profile = new ParametersProfile();
     Profile.InputParameters  = inputs  ?? new List<ParameterDescriptionEntry>();
     Profile.OutputParameters = outputs ?? new List<ParameterDescriptionEntry>();
     Profile.InoutParameters  = inouts  ?? new List<ParameterDescriptionEntry>();
     Profile.ReturningParameter = returning;
     Visibility = visibility;
 }
 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);
     }
     }
 }
Beispiel #3
0
 public virtual bool Visit(ParametersProfile parametersProfile)
 {
     return(true);
 }
Beispiel #4
0
 /// <summary>TCRFUN_DECLARATION_NO_DUPLICATE_NAME</summary>
 /// <param name="node">LINKAGE SECTION node</param>
 /// <param name="profile">Parameters for original function</param>
 private void CheckNoLinkageItemIsAParameter(LinkageSection node, ParametersProfile profile)
 {
     if (node == null) return; // no LINKAGE SECTION
     var linkage = new List<DataDefinition>();
     AddEntries(linkage, node);
     foreach(var description in linkage) {
     var used = Validate(profile.ReturningParameter, description.Name);
     if (used != null) { AddErrorAlreadyParameter(description, description.QualifiedName); continue; }
     used = GetParameter(profile.InputParameters,  description.Name);
     if (used != null) { AddErrorAlreadyParameter(description, description.QualifiedName); continue; }
     used = GetParameter(profile.OutputParameters, description.Name);
     if (used != null) { AddErrorAlreadyParameter(description, description.QualifiedName); continue; }
     used = GetParameter(profile.InoutParameters,  description.Name);
     if (used != null) { AddErrorAlreadyParameter(description, description.QualifiedName); continue; }
     }
 }