示例#1
0
 /// <summary>
 /// Checks and handles any procedure call resolution.
 /// </summary>
 /// <param name="items">The items to check if they correspond to the procedure qualified name</param>
 /// <returns>true if it was a Procedure style call, false otherwise.</returns>
 private bool IsProcedureStyleCallItems(IList <SymbolReference> items, out string hashFunction)
 {
     hashFunction = null;
     if (CurrentNode is TypeCobol.Compiler.Nodes.ProcedureStyleCall)
     {
         TypeCobol.Compiler.Nodes.ProcedureStyleCall procStyleCall = CurrentNode as TypeCobol.Compiler.Nodes.ProcedureStyleCall;
         if (procStyleCall.CodeElement is TypeCobol.Compiler.CodeElements.ProcedureStyleCallStatement)
         {
             TypeCobol.Compiler.CodeElements.ProcedureStyleCallStatement procStyleCallStmt =
                 procStyleCall.CodeElement as TypeCobol.Compiler.CodeElements.ProcedureStyleCallStatement;
             if (procStyleCallStmt.ProgramOrProgramEntryOrProcedureOrFunctionOrTCProcedureFunction is
                 TypeCobol.Compiler.CodeElements.TypeCobolQualifiedSymbolReference)
             {
                 TypeCobol.Compiler.CodeElements.TypeCobolQualifiedSymbolReference tcqsr = procStyleCallStmt.ProgramOrProgramEntryOrProcedureOrFunctionOrTCProcedureFunction as
                                                                                           TypeCobol.Compiler.CodeElements.TypeCobolQualifiedSymbolReference;
                 IList <SymbolReference> names_items = tcqsr.AsList();
                 if (names_items.Count != items.Count)
                 {
                     return(false);
                 }
                 if (EqualItems(items, names_items))
                 {//This is a reference to a Function Call.
                     hashFunction = procStyleCall.FunctionDeclaration.Hash;
                     if (ProgramStack != null && ProgramStack.Count > 0)
                     {   //Memoïze the (hash,ProcedureStyleCall) In the Program procedure style call dictionary.
                         var program = ProgramStack.Peek();
                         if (!program.ProcStyleCalls.ContainsKey(hashFunction))
                         {
                             program.ProcStyleCalls[hashFunction] = new Tuple <IList <SymbolReference>, TypeCobol.Compiler.Nodes.ProcedureStyleCall>(items, procStyleCall);
                         }
                     }
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 ////////////////////
 // PROCEDURE CALL //
 ////////////////////
 public override void EnterTcCallStatement(CodeElementsParser.TcCallStatementContext context)
 {
     var name = CobolWordsBuilder.CreateFunctionNameReference(context.functionNameReference());
     var inputs = new List<CallSiteParameter>();
     SyntaxProperty<ParameterSharingMode> mode = null;
     foreach(var p in context.callInputParameter()) {
     CreateSharingMode(p, ref mode); // TCRFUN_INPUT_BY
     inputs.Add(new CallSiteParameter {
             SharingMode = mode,
             StorageAreaOrValue = CobolExpressionsBuilder.CreateSharedVariableOrFileName(p.sharedVariableOrFileName()),
         });
     }
     var inouts = new List<CallSiteParameter>();
     foreach(var p in context.callInoutParameter()) {
     inouts.Add(new CallSiteParameter { // TCRFUN_CALL_INOUT_AND_OUTPUT_BY_REFERENCE
             SharingMode = new SyntaxProperty<ParameterSharingMode>(ParameterSharingMode.ByReference, null),
             StorageAreaOrValue = new Variable(CobolExpressionsBuilder.CreateSharedStorageArea(p.sharedStorageArea1())),
         });
     }
     var outputs = new List<CallSiteParameter>();
     foreach(var p in context.callOutputParameter()) {
     outputs.Add(new CallSiteParameter { // TCRFUN_CALL_INOUT_AND_OUTPUT_BY_REFERENCE
             SharingMode = new SyntaxProperty<ParameterSharingMode>(ParameterSharingMode.ByReference, null),
             StorageAreaOrValue = new Variable(CobolExpressionsBuilder.CreateSharedStorageArea(p.sharedStorageArea1())),
         });
     }
     Context = context;
     CodeElement = new ProcedureStyleCallStatement(new ProcedureCall(name, inputs,inouts,outputs));
 }