Difference between revisions of "Symbol entries/fr"

From Lazarus wiki
Jump to navigationJump to search
 
(6 intermediate revisions by the same user not shown)
Line 148: Line 148:
 
=== Symbole Type (TTypeSym) ===
 
=== Symbole Type (TTypeSym) ===
  
The type symbol is created each time a new type declaration is done, the current symbol table stack is then inserted with this symbol. Furthermore, each time the compiler compiles a module, the default base types are initialized and added into the symbol table (psystem.pas) The type symbol contains the name of a type, as well as a pointer to its type definition.
+
Le symbole de Type est créé chaque fois qu'une nouvelle déclaration de type est faite, il est alors insérée dans la pile courante de la table symbole. De plus, chaque fois que le compilateur compile un module, les types de base par défaut sont initialisés et ajoutés dans la table des symboles (''psystem.pas''). Le symbole de Type contient le nom  d'un type, ainsi qu'un pointeur vers sa définition de type.
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
Line 161: Line 161:
 
=== Symbole Variable (TVarSym) ===
 
=== Symbole Variable (TVarSym) ===
  
Variable declarations, as well as parameters which are passed onto routines are declared as variable symbol types. Access information, as well as type information and optimization information are stored in this symbol type.
+
Déclaration de variables, aussi bien les paramètres qui sont passés aux routines que les types de symboles Variable. L'accès à l'information, aussi bien que l'information de type et l'information d'optimisation sont enregistrés dans ce type de symbole.
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
Line 188: Line 188:
 
! TVarOptions !! Description
 
! TVarOptions !! Description
 
|-
 
|-
| vo_regable || The variable can be put into a hardware general purpose register
+
| vo_regable || La variable peut être placée dans un registre matériel générique
 
|-
 
|-
| vo_is_c_var || The variable is imported from a C module
+
| vo_is_c_var || La variable est importée depuis un module C
 
|-
 
|-
| vo_is_external || The variable is declared external
+
| vo_is_external || La variable est déclarée ''external''
 
|-
 
|-
| vo_is_Dll_var || The variable is a shared library variable
+
| vo_is_Dll_var || La variable est une variable de bibliothèque partagée
 
|-
 
|-
| vo_is_thread_var || The variable is declared as being thread safe
+
| vo_is_thread_var || La variable est déclarée comme étant thread safe
 
|-
 
|-
| vo_fpuregable || The variable can be put into a hardware floating point register
+
| vo_fpuregable || La variable peut être placée dans un registre matériel en virgule flottante
 
|-
 
|-
 
| vo_is_local_copy || &nbsp;
 
| vo_is_local_copy || &nbsp;
 
|-
 
|-
| vo_is_const || unused and useless
+
| vo_is_const || inutilisé et inutile
 
|-
 
|-
| vo_is_exported || The variable is declared as exported in a dynamic link library
+
| vo_is_exported || La variable est is déclarée comme exportée dans une bibliothèque à liaison dynamique
 
|}
 
|}
  
Line 211: Line 211:
 
! TVarSpez !! Description
 
! TVarSpez !! Description
 
|-
 
|-
| vs_value || This is a value parameter
+
| vs_value || C'est un paramètre valeur
 
|-
 
|-
| vs_const || This is a constant parameter, property or array
+
| vs_const || C'est un paramètre constant, une propriété ou un tableau
 
|-
 
|-
| vs_var || This is a variable parameter
+
| vs_var || C'est un paramètre variable
 
|}
 
|}
  
Line 242: Line 242:
 
=== Symbole déclaré Absolute (TAbsoluteSym) ===
 
=== Symbole déclaré Absolute (TAbsoluteSym) ===
  
This symbol represents a variable declared with the <tt>absolute</tt> keyword. The address of the <tt>TVarSym</tt> object holds the address of the variable in the case of an absolute address variable.
+
Ce symbole représente une variable déclarée avec le mot-clé <tt>absolu</tt>. L'adresse de l'objet <tt>TVarSym</tt> contient l'adresse de la variable dans le cas d'une variable d'adresse absolue.
  
The possible types of absolute symbols, are from an external object reference, an absolute
+
Les types possibles de symboles ''absolute'' proviennent d'une référence d'objet externe, d'une adresse absolue (pour certaines cibles uniquement) ou au-dessus d'une autre variable déclarée.
address (for certain targets only), or on top of another declared variable.
 
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
Line 264: Line 263:
 
! TAbsoluteTyp !! Description
 
! TAbsoluteTyp !! Description
 
|-
 
|-
| toVar || The symbol will be declared on top of another symbol (variable or typed constant)
+
| toVar || Le symbole sera déclaré au-dessus d'un autre symbole ((variable ou constante typée)
 
|-
 
|-
| toAsm || The variable is imported from an external module
+
| toAsm || La variable est importée depuis un module externe
 
|-
 
|-
| toAddr || The variable is declared as being at an absolute address
+
| toAddr || La variable est déclarée comme étant à un adresse absolue
 
|}
 
|}
+
 
 
=== Symbole constante typée ===
 
=== Symbole constante typée ===
  
Line 277: Line 276:
 
=== Symbole Constante (TConstSym) ===
 
=== Symbole Constante (TConstSym) ===
  
This symbol type will contain all constants defined and encountered during the parsing. The
+
Ce type de symbole contiendra toutes les constantes définies et rencontrées lors de l'analyse. Les valeurs des constantes sont également définies dans cette entrée de type de symbole.
values of the constants are also set in this symbol type entry.
 
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
Line 299: Line 297:
 
=== Symbole Programme ===
 
=== Symbole Programme ===
  
The program symbol type (<tt>TProgramSym</tt>) is used to store the name of the program, which is declared using <tt>program</tt> in the pascal source. This symbol type is currently unused in FreePascal.
+
Le type de symbole de Programme (<tt>TProgramSym</tt>) est utilisé pour stocker le nom du programme, qui est déclaré en utilisant <tt>program</tt> dans le code source pascal. Ce type de symbole n'est actuellement pas utilisé dans FreePascal.
  
 
=== Symbole Sys ===
 
=== Symbole Sys ===
  
The <tt>TSysSym</tt> symbol type is used to load indexes into the symbol table of the internal routines which are inlined directly by the compiler. It has a single field, which is the index of the inline routine.
+
Le type de symbole <tt>TSysSym</tt> est utilisé pour charger les index dans la table des symboles des routines internes qui sont directement inline-ées par le compilateur. Il a un seul champ, qui est l'index de la routine en ligne.
  
 
== Symbole Interface ==
 
== Symbole Interface ==
  
 
Prochain chapitre: [[Type information/fr|Information de type]]
 
Prochain chapitre: [[Type information/fr|Information de type]]

Latest revision as of 12:39, 28 December 2020

English (en) français (fr)

Retour au contenu FPC internals

Entrées de symbole

Architecture

Warning-icon.png

Avertissement: Dernière mise à jour pour FPC version 1.0.x

Il y a différents types de symbole possibles, chacun ayant différents champs des autres. Chaque symbole a une signature spécifique pour indiquer quel type d'entrée il s'agit. Chaque entrée dans la table de symboles est effectivement une des entrées de symbole décrite dans les sections suivantes. La relation entre une entrée de symbole, une définition de type, et l'entrée de symbole du nom de type est montrée dans la figure suivante:

http://www.pjh2.de/fpc/CompilerInternalsFigure06.png

Types d'entrée de symbole

Warning-icon.png

Avertissement: Dernière mise à jour pour FPC version 1.0.x

Type de base de symbole (TSym)

Tous les types d'entrée dans la table de symboles sont dérivés de la classe de base qui contient l'information sur le type du symbole aussi bien que sur le propriétaire de l'entrée de symbole.

type
  PSym = ^TSym;
  TSym = object(TSymTableEntry)
    SymOptions: TSymOptions;  // Indicate the access scope of the symbol
    FileInfo: TFilePosInfo;
    Refs: Longint;            // Indicates how many times this label is refered in the
                              // parsed code (is only used with variable and assembler
                              // label symbols).
    LastRef: PRef;
    DefRef: PRef;
    LastWritten: PRef;
    RefCount: Longint;        // Browser information indicating the reference count
    Typ: TSymTyp;             // Indicates the symbol type
    IsStabWritten: Boolean;   // Set to TRUE if the stabs debugging information has
                              // been written for this symbol.
  end;
TSymTyp Description
AbstractSym C'(est un symbole abstrait spécial (ne devrait jamais être rencontré)
VarSym Ce symbole est une déclaration de variable dans la section var, ou un paramètre var
TypeSym Ce symbole est un nom de type
ProcSym Ce symbole est un nom de routine ou de méthode
UnitSym Ce symbole est un nom d'unité
ProgramSym Ce symbole est un nom de programme principal
ConstSym Ce symbole est une constante
EnumSym Ce symbole est un symbole d'énumération (un élément dans une énumeration)
TypedConstSym Ce symbole est une variable pré-initialisée (constante typée Pascal)
ErrorSym Ce symbole est créé pour une génération d'erreur
SysSym Ce symbole représenté une routine d'unité system inline-ée
LabelSym Ce symbole représente une étiquette dans une déclaration Pascal d'étiquette
AbsoluteSym Ce symbole représente un symbole suivant une déclaration de variable absolute
PropertySym Ce symbole est un nom de propriété
FuncRetSym Ce symbole est le nom de la valeur de retour pour les fonctions
MacroSym Ce symbole est un symbole de macro (tout comme un #define en C)

Symbole d'Etiquette (TLabelSym)

L'entrée de table de symboles d'étiquette est seulement créé quand une étiquette Pascal est déclarée via le mot-clé label. L'objet expose publiquement les champs suivants:

type
  PLabelSym = ^TLabelSym;
  TLabelSym = object(TSym)
    Used: Boolean;                 // Set to TRUE if this pascal label is used using a goto
                                   // or in an assembler statement
    Defined: Boolean;              // Set to TRUE if this label has been declared
    Lab: PAsmLabel;                // Points to the actual assembler label structure which
                                   // will be emitted by the code generator
    Code: Pointer;
  end;


Symbole d'Unité (TUnitSym)

Le symbole d'unité est créé et ajouté à une table de symbole chaque fois que la clause uses est analysée et qu'un nom d'unité est trouvé, c'est aussi utilisé lors de la compilation d'une unité, avec la première entrée dans cette table de symbole devenant le nom d'unité se compilant. L'entrée de symbole d'unité fait partie d'une liste chaînée utilisée dans la table de symboles d'unité.

type
  PUnitSym = ^TUnitSym;
  TUnitSym = object(TSym)
    UnitSymTable: PUnitSymTable;  // Pointer to the global symbol table for that
                                  // unit, containing entries for each public?
                                  // symbol in that unit
    PrevSym: PUnitSym;            // Pointer to previous entry in the linked list
  end;

Symbole Macro (TMacroSym)

Les symboles de macro sont utilisés dans le préprocesseur pour des instructions de compilation conditionnelle. Il existe une telle entrée créée pour chaque directive $define, elle contient la valeur du define (stockée sous forme de chaîne).

type
  PMacroSym = ^TMacroSym;
  TMacroSym = object(TSym)
    Defined: Boolean;              // TRUE if the symbol has been defined with a 
                                   // $define directive, or false if it has been 
                                   // undefined with a $undef directive
    Defined_At_Startup: Boolean;   // TRUE if the symbol is a system wide define
    Is_Used: Boolean;              // TRUE if the define has been used such as in 
                                   // a $ifdef directive.
    BufText: PChar;                // The actual string text of the define
    BufLength: Longint;            // The actual string length of the define
  end;

Symbole Erreur (TErrorSym)

Ce symbole est en fait une entrée de table de symboles vide. Lorsque l'analyseur rencontre une erreur lors de l'analyse d'un symbole, au lieu de ne rien mettre dans la table des symboles, il place cette entrée de symbole. Cela évite les accès mémoire illégaux ultérieurement lors de l'analyse.

Symbole Procédure (TProcSym)

Le symbole de procédure est créé chaque fois qu'une routine est définie dans le code. Cela peut être soit une déclaration avancée (forward) ou l'implémentaiton réelle de la routine. Après la création, le symbole est ajouté dans la pile de table de symbole appropriée.

type
  PProcSym = ^TProcSym;
  TProcSym = object(TSym)
    Is_Global: Boolean;           // Set if the routine is exported by the unit
    Definition: PProcDef;         // Procedure definition, including parameter 
                                  // information and return values
  end;

Symbole Type (TTypeSym)

Le symbole de Type est créé chaque fois qu'une nouvelle déclaration de type est faite, il est alors insérée dans la pile courante de la table symbole. De plus, chaque fois que le compilateur compile un module, les types de base par défaut sont initialisés et ajoutés dans la table des symboles (psystem.pas). Le symbole de Type contient le nom d'un type, ainsi qu'un pointeur vers sa définition de type.

type
  PTypeSym = ^TTypeSym;
  TTypeSym = object(TSym)
    ResType: TType;               // Contains base type information as well as the type
                                  // definition
  end;

Symbole Variable (TVarSym)

Déclaration de variables, aussi bien les paramètres qui sont passés aux routines que les types de symboles Variable. L'accès à l'information, aussi bien que l'information de type et l'information d'optimisation sont enregistrés dans ce type de symbole.

type
  PVarSym = ^TVarSym;
  TVarSym = object(TSym)
    Reg: TRegister;              // If the value is a register variable, the reg field will
                                 // be different then R_NO
    VarSpez: TVarSpez;           // Indicates the variable type (parameters only) (Cf. 32).
    Address: Longint;            // In the case where the variable is a routine parameter,
                                 // this indicates the positive offset from theframe_pointer 
                                 // to access this variable. In the caseof a local variable,
                                 // this field indicates the negative offset from the 
                                 // frame_pointer. to access this variable.
    LocalVarSym: PVarSym;
    VarType: TType;              // Contains base type information as well as the type
                                 // definition
    VarOptions: TVarOptions;     // Flags for this variable (Cf. 31)
    VarState: TVarState;         // Indicates the state of the variable, if it’s used or
                                 // declared
  end;


TVarOptions Description
vo_regable La variable peut être placée dans un registre matériel générique
vo_is_c_var La variable est importée depuis un module C
vo_is_external La variable est déclarée external
vo_is_Dll_var La variable est une variable de bibliothèque partagée
vo_is_thread_var La variable est déclarée comme étant thread safe
vo_fpuregable La variable peut être placée dans un registre matériel en virgule flottante
vo_is_local_copy  
vo_is_const inutilisé et inutile
vo_is_exported La variable est is déclarée comme exportée dans une bibliothèque à liaison dynamique


TVarSpez Description
vs_value C'est un paramètre valeur
vs_const C'est un paramètre constant, une propriété ou un tableau
vs_var C'est un paramètre variable

Symbole Propriétét (TPropertySym)

type
  PPropertySym = ^TPropertySym;
  TPropertySym = object(TSym)
    PropOptions: TPropertyOptions;    // ???
    PropType: TType;                  // Indicates the type of the property
    PropOverriden: PPropertySym;      // ???
    IndexType: TType;
    Index: Longint;                   // ????
    Default: Longint;                 // ???
    ReadAccess: PSymList;             // ???
    WriteAccess: PSymList;            // ???
    StoredAccess: PSymList;           // ???
  end;

Symbole Valeur de retour de fonction

...

Symbole déclaré Absolute (TAbsoluteSym)

Ce symbole représente une variable déclarée avec le mot-clé absolu. L'adresse de l'objet TVarSym contient l'adresse de la variable dans le cas d'une variable d'adresse absolue.

Les types possibles de symboles absolute proviennent d'une référence d'objet externe, d'une adresse absolue (pour certaines cibles uniquement) ou au-dessus d'une autre variable déclarée.

type
  PAbsoluteSym = ^TAbsoluteSym;
  TAbsoluteSym = object(TVarSym)
    AbsTyp: TAbsoluteTyp;         // Indicates the type of absolute symbol it is 
    AbsSeg: Boolean;              // ???
    Ref: PSym;                    // In case abstyp is tovar, this field indicates the
                                  // symbol which is overlaid with this symbol. Otherwise
                                  // this field is unused.
    AsmName: PString;             // In case abstyp is toasm, this field indicates label
                                  // name for the variable.
  end;
TAbsoluteTyp Description
toVar Le symbole sera déclaré au-dessus d'un autre symbole ((variable ou constante typée)
toAsm La variable est importée depuis un module externe
toAddr La variable est déclarée comme étant à un adresse absolue

Symbole constante typée

...

Symbole Constante (TConstSym)

Ce type de symbole contiendra toutes les constantes définies et rencontrées lors de l'analyse. Les valeurs des constantes sont également définies dans cette entrée de type de symbole.

type
  PConstSym = ^TConstSym;
  TConstSym = object(TSym)
    ConstType: TType;       // Type information for this constant (?).
    ConstTyp: TConstTyp;    // Indicates the type of the constant
    ResStrIndex: Longint;   // If this is a resource string constant, it indicates the
                            // index in the resource table
    Value: Longint;         // In certain cases, contains the value of the constant
    Len: Longint;
  end;

Symbole Enumération

...

Symbole Programme

Le type de symbole de Programme (TProgramSym) est utilisé pour stocker le nom du programme, qui est déclaré en utilisant program dans le code source pascal. Ce type de symbole n'est actuellement pas utilisé dans FreePascal.

Symbole Sys

Le type de symbole TSysSym est utilisé pour charger les index dans la table des symboles des routines internes qui sont directement inline-ées par le compilateur. Il a un seul champ, qui est l'index de la routine en ligne.

Symbole Interface

Prochain chapitre: Information de type