مترجم+محلّل: سمة @تمثيل_سي لبنية C-متوافقة (FFI) — F2-أ للاستضافة الذاتيّة (RFC #53)#277
Merged
Conversation
…اتيّة (RFC #53) الحاجز ٣/F2 من خارطة الاستضافة الذاتيّة: بنى ص مُعلَّبة بترويسة صنف مخفيّة عند الإزاحة صفر فلا تطابق تخطيط C-ABI. F2-أ يفتح السمة التوجيهيّة @تمثيل_سي (نظير Rust #[repr(C)]) نحويًّا مع قبول المحرّكين، بلا أثر تخطيطيّ بعد (التخطيط في F2-ب). - declarations.h: راية bool isCRepr=false على StructDecl (بجوار isPacked). - parser_main.cpp: فرع @تمثيل_سي في tryParseDirective (نمط @رمز، بلا وسيط) — يُدرِّل إلى StructDecl ويضبط الراية، وإلّا يرفض بخطأ نحويّ موجِّه. - directives.yaml: مدخل SoT directive.c_repr (status: experimental). - docs_extractor.h: emitStruct يطبع بادئة @تمثيل_سي (جولة AST→مصدر سليمة). - اختباران gr.oop.struct: 052 قبول إيجابيّ (3/4 محرّكين) + 053 حارس سلبيّ. المفسّر والمترجم يتجاهلان الراية ⇒ قبول محرّكين بلا سلوك جديد (نطاق F2-أ). البرهان: rules_matrix 2458/2459 (الفاشل b2_recursion_accumulator سابقٌ حتميّ، مطابق على الأساس origin/dev). أميليا: آمن بلا حاجب. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
📚 تذكير مزامنة دليل المطوّرين هذا الـPR يلمس مصادر موثَّقة في دليل المطوّرين. راجع الفصول الآتية وحدّثها إن تغيّر سلوكها، ثم ثبّت البصمات هناك (
بندٌ في معيار الإنجاز. تذكيرٌ آليّ — لا يحجب الدمج. |
المولِّد gen_tmgrammar.py منفصل عن x.py gen؛ إضافة directive.c_repr لـdirectives.yaml تتطلّب إعادة توليد sad.tmLanguage.json (تلوين @تمثيل_سي). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
SalehKadah
added a commit
that referenced
this pull request
Jul 25, 2026
…سي ينجز الربط الخارجيّ (RFC #53 F2-ب) (#280) بنى ص تُمثَّل داخليًّا كأصناف SIR بترويسة مؤشّر vtable في الحقل 0 (`{ ptr, i64, i64 }`)، فتُزاح حقول المستخدم 8 بايت مقابل بنية C نظيرة — وهو الحاجب الحقيقيّ للـFFI البنيويّ: تمرير بنية ص إلى دالّة C يقرأ/يكتب إزاحات خاطئة. هذه اللبنة تُفعّل سمة @تمثيل_سي (المُقرّة والمقبولة في F2-أ، #277) لتُسقِط ترويسة vtable: النوع يصير `{ i64, i64 }`، فالحقل 0 عند الإزاحة 0 — مطابقٌ لـ`struct { long؛ long؛ }` في C. التغييرات: - SIRClass::isCRepr يُنقل من StructDecl::isCRepr (المُحلَّل في F2-أ). - context_info_.cReprClasses تُملأ في preprocessClasses. - preprocessClasses: تخطّي دفع مؤشّر الترويسة للحقل 0 لبنى C-repr (كبنى ADT سلفًا). - getFieldStructIndex: يُرجِع i (بلا إزاحة) لـC-repr، وi+1 لغيرها. مركزة كلّ إزاحات إنشاء الكائن المبرمَجة صلبًا (mem_alloca/objects_arrays_ops/oop_ops) عليه. - storeVtablePtr: حارس مبكّر يتخطّى C-repr (لئلّا يطمس بيانات الحقل 0). - buildClassVtables: بنية C-repr لا تُبنى لها vtable (تبقى غائبة عن classVtableLayout/ classVtableGlobals) ⇒ استدعاء طريقةٍ عليها إرسالٌ مباشر لا افتراضيّ (حارس أمان C-1 من مراجعة أميليا: منع قراءة الحقل 0 كمؤشّر vtable). الهدم محفوظ بالاسم. - حجم malloc يتقلّص آليًّا (24→16) عبر getTypeAllocSize. البراهين الحيّة: - سلوكيّ: memset خارجيّة تصفّر أوّل 8 بايتات ⇒ الحقل الأوّل يصير 0 (عند الإزاحة 0)؛ الضبط (بنية عاديّة) ⇒ يبقى 111 (الحقل عند 8). IR: `{ i64, i64 }`+malloc(16) مقابل `{ ptr, i64, i64 }`+malloc(24). - طريقة على بنية @تمثيل_سي ⇒ 42 بإرسال مباشر (لا انهيار C-1). اختبار: 052_c_repr_method_direct_dispatch (تكافؤ مزدوج). انحدار صفريّ: 2459/2460 (الفشل الوحيد b2_recursion_accumulator انهيار انحدار عميق مسبق في المفسّر، غير ذي صلة). مراجعة أميليا خصميّة (جولتان): SAFE؛ ديون مؤجَّلة موثَّقة (H-2 حقول غير عدديّة، تخمين الصنف). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
الحاجز ٣/F2 — الاستضافة الذاتيّة (RFC sadlang/rfcs#53)
بنى ص مُعلَّبة بترويسة صنف مخفيّة عند الإزاحة صفر فلا تطابق تخطيط C-ABI (تشخيص تجريبيّ بدليل IR في RFC #53). F2-أ يفتح السمة التوجيهيّة
@تمثيل_سي(نظير Rust#[repr(C)]) نحويًّا مع قبول المحرّكين، بلا أثر تخطيطيّ بعد (التخطيط في F2-ب).التغيير
declarations.h: رايةbool isCRepr=falseعلىStructDecl.parser_main.cpp: فرع@تمثيل_سيفيtryParseDirective(نمط@رمز، بلا وسيط) — يُدرِّل إلىStructDeclويضبط الراية، وإلّا يرفض بخطأ نحويّ موجِّه.directives.yaml: مدخل SoTdirective.c_repr(status: experimental).docs_extractor.h:emitStructيطبع بادئة@تمثيل_سي(جولة AST→مصدر سليمة).gr.oop.struct:052قبول إيجابيّ (3/4 محرّكين) +053حارس سلبيّ (@تمثيل_سيعلى دالّة ⇒ خطأ).البرهان
statement_executor_oop_struct) والمترجم (statement_types.cpp) يتجاهلان الراية ⇒ قبول محرّكين بلا سلوك جديد (= نطاق F2-أ بالضبط).rules_matrix: 2458/2459 — الفاشل الوحيد_interactions/_combos/b2_recursion_accumulatorسابقٌ حتميّ (انهيار عمق تعاود مفسّر rc=127، مطابق على الأساس origin/dev).التالي
F2-ب: تخطيط LLVM بلا-ترويسة + تمرير بالمؤشّر المؤنمَط + محاذاة C.
🤖 Generated with Claude Code