IMPLEMENTATION MODULE MetrGMethods;
FROM YaflMetImplementation IMPORT MethodImplementation;
FROM YaflGC IMPORT YaflGC;
FROM YaflType IMPORT Type;
FROM YaflClasses IMPORT ClassDeclaration, VirtualClassDecl;
FROM YaflModules IMPORT CompilationUnit;
FROM YaflPredefined IMPORT PredefItems;
FROM YaflCreator IMPORT Creators;
FROM YaflCfg IMPORT CurrentSpot, YaflCfg;
FROM Streams IMPORT StdOut;
FROM YaflDictionary IMPORT MethodReference;
FROM Conversions IMPORT IntConversions;
IMPORT SYSTEM;

------------------------------------------------------------   

  CLASS MetrMethImplCodeGenerator;
    INHERITS MethImplCodeGenerator(CGcContext);

    METHOD Output: YaflGC;
      BEGIN
      ASSERT Ctx.Output <> VOID;
      RESULT := Ctx.Output;
      END Output;
    
    METHOD LocGenerateMetrics (Key: ARRAY OF CHAR);
        METHOD Int (i: INTEGER): ARRAY OF CHAR;
          BEGIN
          RESULT := IntConversions.IntToString (i, 0);
          END Int;
    
        VAR
           SonNr: INTEGER;
          Sep, IsPublicCode: ARRAY OF CHAR;
        BEGIN
        Sep := SYSTEM.STRI(SYSTEM.Tab);
        IF Obj.Definition = VOID THEN
          IsPublicCode := "0";
         ELSE
          IsPublicCode := "1";
          END;
--        Output.WriteLine ("E" + Sep + 
--                          Key + Sep +
--                          Obj.Class.Id.Data + Sep + 
--                          Obj.Class.Module.Id.Data + Sep +
--                          IsPublicCode + Sep +
--                          Int(Obj.LastStatement - Obj.FirstStatement + 1) + Sep + 
--                          Int(Obj.Nesting) + Sep +
--                          Int(Obj.CyclomaticComplexity));
        FOR i := 0 TO Obj.Methods.Size - 1 DO
          WHAT Obj.Methods.Get(i).Gc OF
            IN MetrMethImplCodeGenerator:
               TAG.LocGenerateMetrics (Key + "." + Int (SonNr));
               END;
            END;
          SonNr := SonNr + 1;                                       
          END;                                  
        END LocGenerateMetrics;
                                         
    REDEFINE METHOD GenerateCode;
      BEGIN
      LocGenerateMetrics (Obj.Id.Data);
      END GenerateCode;
      
  END MetrMethImplCodeGenerator;
   
   
END MetrGMethods;




