Difference between revisions of "Symbol entries/fr"

From Lazarus wiki
Jump to navigationJump to search
Line 19: Line 19:
 
=== Type de base de symbole (TSym) ===
 
=== Type de base de symbole (TSym) ===
  
All entries in the symbol table are derived from this base object which contains information on
+
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.
the symbol type as well as information on the owner of this symbol entry.
 
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
Line 44: Line 43:
 
! TSymTyp !! Description
 
! TSymTyp !! Description
 
|-
 
|-
| AbstractSym || This is a special abstract symbol (this should never occur)
+
| AbstractSym || C'(est un symbole abstrait spécial (ne devrait jamais être rencontré)
 
|-
 
|-
| VarSym || This symbol is a variable declaration in the var section, or a var parameter.
+
| VarSym || Ce symbole est une déclaration de variable dans la section ''var'', ou un paramètre ''var''
 
|-
 
|-
| TypeSym || This symbol is a type name
+
| TypeSym || Ce symbole est un nom de type
 
|-
 
|-
| ProcSym || This symbol is a routine or method name
+
| ProcSym || Ce symbole est un nom de routine ou de méthode
 
|-
 
|-
| UnitSym || This symbol is a unit name
+
| UnitSym || Ce symbole est un nom d'unité
 
|-
 
|-
| ProgramSym || This symbol is the main program name
+
| ProgramSym || Ce symbole est un nom de programme principal
 
|-
 
|-
| ConstSym || This symbol is a constant
+
| ConstSym || Ce symbole est une constante
 
|-
 
|-
| EnumSym || This symbol is an enumeration symbol (an element in an enumeration)
+
| EnumSym || Ce symbole est un symbole d'énumération (un élément dans une énumeration)
 
|-
 
|-
| TypedConstSym || This symbol is pre-initialized variable (pascal typed constant)
+
| TypedConstSym || Ce symbole est une variable pré-initialisée (constante typée Pascal)
 
|-
 
|-
| ErrorSym || This symbol is created for error generation
+
| ErrorSym || Ce symbole est créé pour une génération d'erreur
 
|-
 
|-
| SysSym || This symbol represents an inlined system unit routine
+
| SysSym || Ce symbole représenté une routine d'unité ''system'' inline-ée
 
|-
 
|-
| LabelSym || This symbol represents a label in a label pascal declaration
+
| LabelSym || Ce symbole représente une étiquette dans une déclaration Pascal d'étiquette
 
|-
 
|-
| AbsoluteSym || This symbol represents an the symbol following an absolute variable declaration
+
| AbsoluteSym || Ce symbole représente un symbole suivant une déclaration de variable ''absolute''
 
|-
 
|-
| PropertySym || This symbol is a property name
+
| PropertySym || Ce symbole est un nom de propriété
 
|-
 
|-
| FuncRetSym || This symbol is the name of the return value for functions
+
| FuncRetSym || Ce symbole est le nom de la valeur de retour pour les fonctions
 
|-
 
|-
| MacroSym || This symbol is a macro symbol (just like #define in C)
+
| MacroSym || Ce symbole est un symbole de macro (tout comme un ''#define'' en C)
 
|}
 
|}
  
=== Symbole Etiquette (TLabelSym) ===
+
=== Symbole d'Etiquette (TLabelSym) ===
  
The label symbol table entry is only created when a pascal label is declared via the label keyword. The object has the following fields which are available for use publicly:
+
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:
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
Line 95: Line 94:
  
  
=== Symbole Unité (TUnitSym) ===
+
=== Symbole d'Unité (TUnitSym) ===
  
The unit symbol is created and added to the symbol table each time that the uses clause is parsed and a unit name is found, it is also used when compiling a unit, with the first entry in that symbol table being the unit name being compiled. The unit symbol entry is actual part of a linked list which is used in the unit symbol table.
+
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é.
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
Line 112: Line 111:
 
=== Symbole Macro (TMacroSym) ===
 
=== Symbole Macro (TMacroSym) ===
  
The macro synbols are used in the preprocessor for conditional compilation statements. There is one such entry created for each $define directive, it contains the value of the define (stored as a string).
+
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).
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>
Line 131: Line 130:
 
=== Symbole Erreur (TErrorSym) ===
 
=== Symbole Erreur (TErrorSym) ===
  
This symbol is actually an empty symbol table entry. When the parser encounters an error when parsing a symbol, instead of putting nothing in the symbol table, it puts this symbol entry. This avoids illegal memory accesses later in parsing.
+
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) ===
 
=== Symbole Procédure (TProcSym) ===
  
The procedure symbol is created each time a routine is defined in the code. This can be either a forward definition or the actual implementation of the routine. After creation, the symbol is added into the appropriate symbol table stack.
+
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.
  
 
<syntaxhighlight lang=pascal>
 
<syntaxhighlight lang=pascal>

Revision as of 12:19, 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)

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.

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

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.

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 The variable can be put into a hardware general purpose register
vo_is_c_var The variable is imported from a C module
vo_is_external The variable is declared external
vo_is_Dll_var The variable is a shared library variable
vo_is_thread_var The variable is declared as being thread safe
vo_fpuregable The variable can be put into a hardware floating point register
vo_is_local_copy  
vo_is_const unused and useless
vo_is_exported The variable is declared as exported in a dynamic link library


TVarSpez Description
vs_value This is a value parameter
vs_const This is a constant parameter, property or array
vs_var This is a variable parameter

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)

This symbol represents a variable declared with the absolute keyword. The address of the TVarSym object holds the address of the variable in the case of an absolute address variable.

The possible types of absolute symbols, are from an external object reference, an absolute address (for certain targets only), or on top of another declared variable.

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 The symbol will be declared on top of another symbol (variable or typed constant)
toAsm The variable is imported from an external module
toAddr The variable is declared as being at an absolute address

Symbole constante typée

...

Symbole Constante (TConstSym)

This symbol type will contain all constants defined and encountered during the parsing. The values of the constants are also set in this symbol type entry.

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

The program symbol type (TProgramSym) is used to store the name of the program, which is declared using program in the pascal source. This symbol type is currently unused in FreePascal.

Symbole Sys

The TSysSym 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.

Symbole Interface

Prochain chapitre: Information de type