1 / 60

ADA 9X

ADA 9X. OBJECTIFS. ADA 9X. HISTORIQUE ADA OBJET ADA TEMPS REEL DIVERS TYPES ENTREES SORTIES POINTEURS DIVERS GENERICITE EXCEPTIONS. HISTORIQUE. 1979 CHOIX DU LANGAGE ADA CII COMMANDE DoD 1983/1987 NORMALISATION ANSI/ISO 199X REVISION DU LANGAGE 1994 DRAFT 4 ASSEZ STABLE ALSYS

Download Presentation

ADA 9X

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ADA 9X .

  2. OBJECTIFS • .

  3. ADA 9X • HISTORIQUE • ADA OBJET • ADA TEMPS REEL • DIVERS • TYPES • ENTREES SORTIES • POINTEURS • DIVERS • GENERICITE • EXCEPTIONS

  4. HISTORIQUE • 1979 CHOIX DU LANGAGE ADA CII • COMMANDE DoD • 1983/1987 NORMALISATION ANSI/ISO • 199X REVISION DU LANGAGE • 1994 DRAFT 4 ASSEZ STABLE • ALSYS • GNU • 1995 NORMALISATION PREVUE ADA9X

  5. ADA9X = • ADA 83 • + ORIENTE OBJET • + TEMPS REEL OPTIMISE • + HIERARCHIE DES UNITES • + EXTENSIONS DIVERSES • + EXTENSION SPECIALISEES

  6. ADA ORIENTE OBJETSLES TYPES TAGGED Type Forme is tagged recordCentre : Point; Couleur : Tcouleur; end record; Centre : Point Couleur : Tcouleur

  7. ADA ORIENTE OBJETSTYPE TAGGED • LE TYPE EST IDENTIFIE • NOM • IDENTIFICATION INTERNE package Ada.Tags is type Tag is dépend du fournisseur; function Expanded_Name( T: Tag) return String; function External_Tag(T: Tag) return String; function Internal_Tag(External : string) return Tag; end Ada.Tags;

  8. ADA ORIENTE OBJETSPROCEDURES ET FONCTIONS procedure Affiche ( F: in Forme) ;procedure Deplace ( F: in Forme; Vers : Point) isbegin Centre := Vers; Affiche(F);end deplace;

  9. ADA OO / TYPES DERIVESHERITAGE DES CHAMPS Type Carre is new Forme with recordCote : Float;end record; Centre : Point Couleur : Tcouleur Cote : Float

  10. ADA OOHERITAGE DES FONCTIONS • HERITAGE • procedure Affiche ( F: in Forme) ; • procedure Deplace ( F: in Forme; Vers : Point); • VAR C : CARRE; • DEPLACE(C, DEST) => APPEL DE • SURCHARGE • procedure Affiche ( F: in Carre) ; • VAR C : CARRE • AFFICHE(C) => APPEL DE

  11. ADA ORIENTE OBJETSSELECTION STATIQUE • procedure Affiche ( F: in Forme) ; • procedure Deplace ( F: in Forme; Vers : Point) isbegin Centre := Vers; Affiche(F);end deplace; • procedure Affiche( C : Carre); • var CA : carre; • Deplace(CA,dest); appel de Deplace hérité oublie du type carre appel de la version forme d'affiche !!!!!

  12. ADA ORIENTE OBJETSSELECTION STATIQUE FORME DEPLACE AFFICHE CERCLE CARRE AFFICHE AFFICHE DEPLACE(CAR) DEPLACE(ROND)

  13. ADA OO / LES CLASSESSELECTION DYNAMIQUE procedure Deplace ( F: in Forme'CLASS; Vers : Point) isbegin Centre := Vers; Affiche(F);end deplace; Appel de la version d'affiche spécifique du type du paramètre F

  14. ADA ORIENTE OBJETSSELECTION DYNAMIQUE FORME DEPLACE AFFICHE CERCLE CARRE AFFICHE AFFICHE DEPLACE(CAR) DEPLACE(ROND)

  15. ADA ORIENTE OBJETSTYPE DERIVESANS NOUVEAU CHAMP Type Forme2 is new Forme with null record;

  16. ADA ORIENTE OBJETSTYPE DERIVE DE TYPE DERIVE Type Rectangle is new Carre with recordLargeur : Float;end record; FORME CARRE RECTANGLE

  17. ADA ORIENTE OBJETSTYPES ABSTRAITS Type Forme is abstract tagged null record; procedure Affiche ( F: in Forme) is abstract

  18. ADA ORIENTE OBJETSTYPES CONTROLES with System.Finalization_Implementation; -- version mai 94 use System; package Ada.Finalization is type Controlled is abstract new Finalization_Implementation.Root_Controlled with null record; procedure Initialize(Object : in out Controlled); procedure Adjust(Object : in out Controlled); procedure Finalize(Object : in out Controlled);

  19. ADA ORIENTE OBJETSTYPES CONTROLES • FONCTIONS PAR DEFAUT VIDES • INITIALISATION • AFFECTATION • DESTRUCTION • SURCHARGABLES

  20. ADA 9XORIENTE OBJETS • CLASSE = TAG • METHODES = PROCEDURES+FONCTIONS • HERITAGE SIMPLE • SELECTION DYNAMIQUE

  21. C++ -> ADA 9X • CLASSE • TYPES TAGS • PROCEDURE ET FONCTION AVEC TAGS EN PARAMETRES • FONCTION VIRTUELLE # 'CLASS • LIMITEE A HERITAGE SIMPLE

  22. ADA RAPPEL RENDEZ-VOUS SYNCHRONE TACHE CLIENTE SERVEUR.ENTREE N TACHE SERVEUR SELECT ACCEPT ENTREE 1 ACCEPT ENTREE 2 ACCEPT ENTREE 3 END SELECT

  23. ADA RAPPELREALISATION DE FILE TACHE RECEPTION LOOP ... QUEUE.LIRE TRAITEMENT END LOOP TACHE QUEUE SELECT ACCEPT LIRE WHEN NB>0 DEPILER END ACCEPT ACCEPT ECRIRE WHEN NB<MAX EMPILER END ACCEPT END SELECT TACHE CLIENTE QUEUE.ECRIRE

  24. ADA RAPPELCOMMUNICATION ASYNCHRONE • TACHE INTERMEDIAIRE • DEUX RENDEZ-VOUS

  25. TEMPS REELDISCRIMINANT DE TACHE task type Keyboad_Driver( ID : Keyboard_ID := New_ID) is entry Read(C : out Character); entry Write(C : in Character); end Keyboard_Driver; Teletype : Keyboard_Driver(TTY_ID);

  26. TEMPS REELVARIABLE PROTEGEE protected variable is function lire return item; procedure ecrire(valeur : item);privatedonnee : Item; end variable; variable.ecrire(4);i:= variable.lire();

  27. TEMPS REELTYPES PROTEGES protected type Tampon_tournant is entry Ecrire(X : in Item); entry Lire(X : out Item); private A: Item_Array(1..Max); I,J : Integer range 1..Max :=1; Count : Integer range 0..Max :=0; end Bounded_Buffer;

  28. TEMPS REELTYPES PROTEGES protected body Tampon_Tournant is entry Ecrire(X : in Item) when Count<Max is begin A(I) := X; I := I mod Max + 1; Count := Count +1; end Ecrire; entry Lire(X : out Item) when Count>0 is begin X := A(J); J := J mod Max + 1; Count := Count-1; end Lire; end Tampon_Tournant;

  29. TEMPS REELTYPES PROTEGES • SOUS-PROGRAMMES EXCLUSIF • PROCEDURE EN LECTURE/ECRITURE • FONCTION EN LECTURE SEULEMENT • ENTREE CONDITIONNEL EN LECTURE/ECRITURE

  30. TEMPS REELEXEMPLE FILE PROTECTED QUEUE ENTRY LIRE WHEN NB>0 DEPILER END LIRE ENTRY ECRIRE WHEN NB<MAX EMPILER END ECRIRE END QUEUE TACHE RECEPTION LOOP ... QUEUE.LIRE TRAITEMENT END LOOP TACHE CLIENTE QUEUE.ECRIRE

  31. TEMPS REELCOMMUNICATION ASYNCHRONE • PAS DE CHANGEMENT DE CONTEXTE • MISE EN ATTENTE SEULEMENT SI ACCES SIMULTANE

  32. TEMPS REELEXEMPLE SEMAPHORE protected type Semaphore( Nombre_de_ressources : Integer : 1) is entry Reserve; procedure Libere; function Ressources_Libre return Integer; private Compteur : Integer := Nombre_de_ressources; end Semaphore;

  33. TEMPS REELEXEMPLE SEMAPHORE protected body Semaphore is entry Reserve when Compteur >0 is begin Compteur := Compteur - 1; end Reserve; procedure Libere is begin Compteur := Compteur + 1; function Ressources_Libres is begin return Compteur; end Nombre; end Semaphore;

  34. TEMPS REELATTENTE HEURE ABSOLU delay until heure;

  35. TEMPS REELTRAITEMENT TEMPS LIMITE select delay 5.0; Put_line("Temps de calcul trop long"); then abort Inversion_de_matrice(X); end select;

  36. TEMPS REELTRAITEMENT ABORTABLE loop select Terminal.Wait_For_Interrupt; Put_line("Fin du terminal"); then abort Put_line("-> "); Get_Line(Command, Last); Process_Command(Command(1..Last)); end select; end loop

  37. TEMPS REELINTERRUPTIONS • PRAGMAS • Interrupt_handler • Attach_Handler • A VARIABLE PROTEGEE

  38. TEMPS REELPRIORITE • PAR PRAGMA • STATIQUES • DYNAMIQUES

  39. TEMPS REELREMISE EN FILE requeue entry_name [with abort];

  40. HIERARCHIEPAQUETAGE package Nombre_complexe is type Complexe is private; function "+" (X,Y : Complexe) return Complexe;private...end Nombre_complexe;

  41. HIERARCHIESOUS-PAQUETAGES package Nombre_complexe.Polaire is procedure Polaire_to_complexe (R,theta:Float) return Complexe;private...end Nombre_complexe;

  42. HIERARCHIEUTILISATION with Nombre_complexe.Polaire; use Nombre_complexe; C := Nombre_complexe.Polaire_to_complexe(4, 2)

  43. NOUVEAUX TYPES • CHARACTER (8 bits) / WIDE_CHARACTER (16) • STRING / WIDE_STRING • PAQUETAGE TAILLE FIXE • PAQUETAGE TAILLE DYNAMIQUE BORNEE • PAQUETAGE TAILLE DYNAMIQUE • ENTIER NON SIGNES • Type BYTE is MOD 256; -- 0..255 • PAQUETAGE GENERATION DE NOMBRES ALEATOIRES • REELS FIXES • TYPE Volt is delta 0..125 range 0.0..255.0; • TYPE Money is delta 0.01 digits 15; • REELS FLOTTANTS • PAQUETAGE GENERIC_ELEMENTARY_FUNCTIONS

  44. ENTREES SORTIESMEMOIRE with Ada.IO_EXCEPTIONS; with System.Storage_Elements; generic type Element_Type is private; package Ada.Storage_IO is Buffer_Size : constant System.Storage_Elements.Storage_Count := implementation-defined subtype Buffer_Type is System.Storage_Elements.Storage_Array[1..Buffer_Size]; procedure Read(Buffer : in Buffer_Type; Item : out Element-Type); procedure Write(Buffer : out Buffer_Type; Item : in Element_Type); Data_Error : exception renames IO_Exceptions.Data_Error; private end Ada.Direct_IO;

  45. ENTREES SORTIESSTREAMS with Ada.EXCEPTIONS; with System.Storage_Elements; with Ada.Tags package Ada.Stream is pragma Pure(Streams); type Root_Stream_Type is abstract tagged limited private; procedure Read( Stream : in out Root_Stream_type; Item : out System.Storage_Elements.Storage_Array; Last : out System.Storage_Elements.Storage_offset) is abstract; procedure Write( Stream : in out Root_Stream_type; Item : in System.Storage_Elements.Storage_Array; ) is abstract; private end Ada.Stream;

  46. ENTREES SORTIESSURCHARGE for matrice'readuse my_matrice_read; for matrice'writeuse my_matrice_write;

  47. POINTEURSPARAMETRES FONCTIONS Type Integree is access function(X:Float) return Float; Function Integrer( F : Integree; Debut,Fin : Float; precision : Float := 1.0e-7); Integrer( Log'Access, 1.0, 2.0); F.all(X);

  48. POINTEURSVARIABLES STATIQUES type Pointeur_entier is access all integer;Pointeur : Pointeur_entier;I : aliased Integer;...Pointeur := I'access;

  49. PARAMETRE OUT PROCEDURE COMPTAGE( RESULTAT OUT INTEGER) BEGIN RESULTAT :=0; LOOP IFcondition THEN RESULTAT := RESULTAT + 1; END IF; END LOOP; END COMPTAGE;

  50. GENERICITE type NOM isrange <>; -- type entier type NOM isdigits <>; -- type réel type NOM isprivate; -- type privé type NOM islimited private;-- type limité privé type NOM is (<>) ; type NOM isdelta <> -- type réel fixe type NOM isarray( ) of -- type tableau type NOM ismod <> -- type entier non signé type NOM isaccess <> -- type pointeur type NOM is [[abstract] [tagged]][limited] private

More Related