コード例 #1
0
ファイル: Function.cs プロジェクト: osmedile/TypeCobol
 /// <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;
 }
コード例 #2
0
 public ParameterDescriptionEntry CreateFunctionDataParameter(CodeElementsParser.FunctionDataParameterContext context)
 {
     var parameter = new ParameterDescriptionEntry();
     parameter.LevelNumber = new GeneratedIntegerValue(1);
     parameter.DataName = CobolWordsBuilder.CreateDataNameDefinition(context.dataNameDefinition());
     if (context.pictureClause() != null) {
     parameter.Picture = CobolWordsBuilder.CreateAlphanumericValue(context.pictureClause().pictureCharacterString);
     parameter.DataType = DataType.Create(parameter.Picture.Value);
     } else {
     parameter.CustomType = CobolWordsBuilder.CreateAlphanumericValue(context.cobol2002TypeClause());
     parameter.DataType = DataType.CreateCustom(parameter.CustomType.Value);
     }
     //TODO#245: subphrases
     return parameter;
 }
コード例 #3
0
 private ParameterDescriptionEntry CreateFunctionDataParameter(DataConditionEntry condition)
 {
     var data = new ParameterDescriptionEntry();
     data.LevelNumber = condition.LevelNumber;
     data.DataName    = condition.DataName;
     data.DataType    = DataType.Unknown;
     return data;
 }
コード例 #4
0
 /// <summary>Parent node: DECLARE FUNCTION</summary>
 /// <param name="context">PROCEDURE DIVISION</param>
 public override void EnterFunctionProcedureDivision(ProgramClassParser.FunctionProcedureDivisionContext context)
 {
     var header = (ProcedureDivisionHeader)context.ProcedureDivisionHeader().Symbol;
     if (header.UsingParameters != null && header.UsingParameters.Count > 0)
         DiagnosticUtils.AddError(header, "TCRFUN_DECLARATION_NO_USING");//TODO#249
     var declaration = (FunctionDeclarationHeader)CurrentNode.CodeElement;
     foreach(var parameter in declaration.Profile.InputParameters) {
         parameter.SymbolTable = CurrentNode.SymbolTable;
         CurrentNode.SymbolTable.AddVariable(parameter);
     }
     foreach(var parameter in declaration.Profile.OutputParameters) {
         parameter.SymbolTable = CurrentNode.SymbolTable;
         CurrentNode.SymbolTable.AddVariable(parameter);
     }
     foreach(var parameter in declaration.Profile.InoutParameters) {
         parameter.SymbolTable = CurrentNode.SymbolTable;
         CurrentNode.SymbolTable.AddVariable(parameter);
     }
     if (declaration.Profile.ReturningParameter != null) {
         declaration.Profile.ReturningParameter.SymbolTable = CurrentNode.SymbolTable;
         CurrentNode.SymbolTable.AddVariable(declaration.Profile.ReturningParameter);
     } else
     if (header.ReturningParameter != null) {
         // we might have a RETURNING parameter to convert, but only if there is neither
         // PICTURE nor TYPE clause for the returning parameter in the function declaration.
         // however, this is as syntax error.
         var pentry = new ParameterDescriptionEntry();
         var data = header.ReturningParameter.StorageArea as DataOrConditionStorageArea;
         if (data != null) pentry.DataName = new SymbolDefinition(data.SymbolReference.NameLiteral, data.SymbolReference.Type);
         // pentry.Picture will remain empty, we can't do anything about it
         pentry.DataType = DataType.Unknown;
         declaration.Profile.ReturningParameter = new ParameterDescription(pentry);
     }
     Enter(new ProcedureDivision(header), context);
 }
コード例 #5
0
 private static CallTargetParameter CreateCallTargetParameter(ParameterDescriptionEntry param)
 {
     var symbolReference = new SymbolReference(param.DataName);
     var storageArea = new DataOrConditionStorageArea(symbolReference);
     var callParameter = new CallTargetParameter { StorageArea = storageArea };
     return callParameter;
 }
コード例 #6
0
 private ParameterDescriptionEntry Validate(ParameterDescriptionEntry parameter, string name)
 {
     if (parameter != null && parameter.Name.Equals(name)) return parameter;
     return null;
 }
コード例 #7
0
 private ParameterEntry CreateParameterEntry(ParameterDescriptionEntry parameter, Compiler.CodeModel.SymbolTable table)
 {
     var generated = new ParameterEntry(parameter, table);
     if (parameter.DataConditions != null) {
     foreach (var child in parameter.DataConditions) generated.Add(new DataCondition(child));
     }
     return generated;
 }
コード例 #8
0
ファイル: Function.cs プロジェクト: osmedile/TypeCobol
 public ParameterDescription(ParameterDescriptionEntry entry)
     : base(entry)
 {
 }
コード例 #9
0
ファイル: Function.cs プロジェクト: osmedile/TypeCobol
 /// <summary>Creates function.</summary>
 public Function(QualifiedName name, IList<ParameterDescriptionEntry> inputs, ParameterDescriptionEntry returning, AccessModifier visibility = AccessModifier.Private)
     : this(name, inputs, null, null, returning, visibility)
 {
 }