J’ai créé ce langage pour le fun, car cela m’amuse de faire des choses complexes.
Et puis, je veux maîtriser l’API C++ de LLVM IR.
Très simplement :
On construit un AST → l’AST est converti en LLVM IR → puis on compile vers un fichier objet.
Le fichier objet est ensuite traduit en exécutable avec le linker disponible sur le système hôte.
Déjà :
Ensuite :
struct. Je ne veux pas tomber dans le délire qui consiste à
tout transformer en objet).La programmation orientée objet, c’est bien, mais seulement dans certains cas précis.
La plupart du temps, elle est utilisée par des gens qui ne connaissent pas grand-chose à la machine.
Par « moutonnisme », ils font de la programmation orientée objet sans véritable opinion personnelle.
JE NE SUIS PAS ANTI-PROGRAMMATION OBJET, JE SUIS SEULEMENT PRAGMATIQUE.
Premier parti pris :
Les variables sont définies avant les fonctions :
global uint32_t MB_OK = 0x00000000;
global uint64_t hwnd;
global wstring titre = L"éééé ください";
global wstring texte = L"WoW GaspardOS ééé Bonjour MIAM MIAM !!!!!";
global string ascii = "string ascii, GaspardOS prend en charge Unicode et ASCII nativement";En réalité, sous Windows, wstring correspond à :
global ptr uint16_t string_unicode_win .....| TYPE | Note | Exemple |
|---|---|---|
| uint8_t | Entier non signé sur 8 bits | global uint8_t d = cast uint8_t 4; |
| uint16_t | Entier non signé sur 16 bits | global uint16_t d = cast uint16_t 16; |
| uint32_t | Entier non signé sur 32 bits | global uint32_t d = cast uint32_t 32; |
| uint64_t | Entier non signé sur 64 bits | global uint64_t d = 32; NOTE : plus besoin de cast, car dans Gaspard LANG un entier est toujours codé sur 64 bits |
| int8_t | Entier signé sur 8 bits | global int8_t d = cast int8_t -4; |
| int16_t | Entier signé sur 16 bits | global int16_t d = cast int16_t -16; |
| int32_t | Entier signé sur 32 bits | global int32_t d = cast int32_t -32; |
| int64_t | Entier signé sur 64 bits | global int64_t d = -32; NOTE : plus besoin de cast, car dans Gaspard LANG un entier est toujours codé sur 64 bits |
| float | Flottant simple précision (32 bits) | global float d = cast float 32.4; |
| double | Flottant double précision (64 bits) | global double d = cast double 32.4; |
| string | Chaîne ASCII | global string str = “Bonjour ASCII”; |
| wstring | Chaîne Unicode | global wstring str = L”Bonjour Unicode WOW”; |
Comme vous pouvez le constater, les types s’inspirent du C. Vous
remarquerez également la nécessité d’effectuer un cast, sauf pour
int64_t et uint64_t.
Pour les professionnels de la sécurité système (ou de la « cybersécurité », en langage marketing), mon système de typage est tout à fait nécessaire et permet d’éviter les overflows silencieux (notamment sur x86, entre autres).
Sur GitHub, c’est open source :
https://github.com/gcourchinoux/GaspardOSLang
J’écrirai d’autres articles thématiques sur GaspardOS LANG.
Gaspard COURCHINOUX
11/06/2026
Voici du code GaspardOS LANG. En gros , il appelle une seule fonction de la STDLIB GASPARDOS
Pour créer une fenetre avec CreateWindowExW
on peut avoir la boucle EVENT WndProc qui est WindowHandler1.
Le résultat :
// on compile avec : -Lwin32 stdlib/Win32.o
global uint32_t width ;
global uint32_t height ;
global uint64_t ret_un = 0x1;
global uint64_t status2 = 0;
global string message2 = "addr glang func 0x%lx : \n";
global string message1 = "Gaspard CALL HWND : 0x%x \n";
// #define WM_DESTROY 0x0002
global uint32_t WM_DESTROY = cast uint32_t 0x0002;
global uint32_t ZERO = cast uint32_t 0;
global uint64_t addr_func = 0;
prototype procedure GaspardOSCreateWindow return uint32_t = begin
argument begin
argument uint64_t hInst;
argument uint32_t nCmdShow;
argument uint32_t width;
argument uint32_t height;
argument ptr uint64_t HandlerFunc;
end
end
prototype procedure DefWindowProcW return int64_t = begin
//DefWindowProc
argument begin
argument uint64_t hwnd;
argument uint32_t msg;
argument uint64_t wParam;
argument int64_t lParam;
end
end
prototype procedure PostQuitMessage = begin
argument begin
argument int32_t exit_code;
end
end
procedure WindowHandler1 return int64_t = begin
//typedef int (*GaspardOSH)(HWND hwnd,unsigned int msg,uint64_t wParam,uint64_t lParam);
argument begin
argument uint64_t hwnd;
argument uint32_t msg;
argument uint64_t wParam;
argument int64_t lParam;
end
if hwnd == 0 begin
return 0;
end
if msg == WM_DESTROY begin
call PostQuitMessage ZERO;
return 0;
end
call printf message1 hwnd;
call DefWindowProcW return status2 hwnd msg wParam lParam ;
return status2;
end
procedure WinMain = begin
argument begin
argument uint64_t hInst;
argument uint64_t hPrev;
argument ptr uint8_t cmd;
argument uint32_t show;
end
width = cast uint32_t 400;
height = cast uint32_t 800;
addr_func = WindowHandler1;
call printf message2 addr_func;
call printf message1;
call GaspardOSCreateWindow hInst show width height WindowHandler1;
end