Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
316 changes: 283 additions & 33 deletions documents/إرشادات إستعمال ألف.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions documents/ما الجديد.md
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,11 @@
# ['السلام', ' عليكم', ' ورحمة, الله']
```

15- إضافة دالة اقسم() للنص حيث تقوم بتقسيم النص إلى ثلاث اجزاء بالنسبة للمعامل الممرر.
15- إضافة دالة قسم() للنص حيث تقوم بتقسيم النص إلى ثلاث اجزاء بالنسبة للمعامل الممرر.
مثال:
```
نص = "ملف.لاحقة"
اطبع(نص.اقسم("."))
اطبع(نص.قسم("."))
# ('ملف', '.', 'لاحقة')
```

Expand Down
2 changes: 1 addition & 1 deletion examples/شريط_التقدم.alif
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
الوقت.غفوة(0.07)
اطبع()

اطبع("جاري تحميل الملف ...")
اطبع("جاري تحميل الملف ...")
شريط_التقدم(السابقة="التقدم:", اللاحقة="اكتمل", الطول=51)
اطبع("إكتمل التحميل بنجاح.")
1 change: 1 addition & 0 deletions source/AlifCore/Include/Core/AlifCore_SymTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class SymTableEntry { // 89
unsigned compInlined : 1;
unsigned compIterTarget : 1;
unsigned canSeeClassScope : 1;
unsigned hasDocstring : 1;

AlifIntT compIterExpr{};
AlifSourceLocation loc{};
Expand Down
3 changes: 2 additions & 1 deletion source/AlifCore/Include/Main/Code.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ class AlifCodeObject ALIFCODE_DEF(1); // 140

#define CO_NO_MONITORING_EVENTS 0x2000000

#define CO_HAS_DOCSTRING 0x4000000 // 180


#define MAXBLOCKS 21

extern AlifTypeObject _alifCodeType_; // 179
extern AlifTypeObject _alifCodeType_; // 189
#define ALIFCODE_CHECK(_op) ALIF_IS_TYPE((_op), &_alifCodeType_)


Expand Down
44 changes: 22 additions & 22 deletions source/AlifCore/Include/Main/FrozenModules/GetPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,32 +241,32 @@ const unsigned char _ALIF_M__GetPath[] = {
99,1,0,0,0,0,0,0,0,1,0,0,0,4,0,0,
0,7,0,0,0,115,108,0,0,0,92,0,92,1,149,0,
80,0,37,0,0,0,0,0,0,0,95,42,0,0,87,1,
0,0,0,0,0,0,0,0,81,1,81,0,48,2,79,1,
0,0,0,0,0,0,0,0,81,1,81,0,48,2,79,0,
23,0,103,8,81,2,16,0,49,0,0,0,0,0,0,0,
49,1,0,0,0,0,0,0,37,0,0,0,0,0,0,0,
95,2,0,0,80,0,33,0,87,3,0,0,0,0,0,0,
0,0,80,0,49,1,0,0,0,0,0,0,106,0,72,49,
0,0,79,0,33,0,40,2,0,0,0,78,99,1,0,0,
0,0,0,0,0,0,0,0,0,7,0,0,0,51,0,0,
0,115,74,0,0,0,58,2,32,0,29,0,149,0,81,0,
16,0,67,23,0,0,107,1,80,2,31,0,87,1,0,0,
0,0,0,0,0,0,80,3,81,1,49,2,0,0,0,0,
0,0,49,1,0,0,0,0,0,0,115,0,149,5,29,0,
72,25,0,0,9,0,29,0,79,0,33,0,51,3,100,1,
40,1,0,0,0,78,40,1,0,0,0,117,17,0,0,0,
216,182,217,133,95,216,167,217,132,217,133,216,179,216,167,216,
177,40,4,0,0,0,117,2,0,0,0,46,48,117,2,0,
0,0,216,182,117,10,0,0,0,216,167,216,174,216,170,216,
168,216,177,117,10,0,0,0,216,179,216,167,216,168,217,130,
216,169,115,4,0,0,0,32,32,128,128,117,16,0,0,0,
60,216,172,216,177,216,175,32,71,101,116,80,97,116,104,62,
117,9,0,0,0,60,103,101,110,101,120,112,114,62,117,38,
0,0,0,216,168,216,173,216,171,95,216,170,216,181,216,167,
216,185,216,175,217,138,46,60,108,111,99,97,108,115,62,46,
60,103,101,110,101,120,112,114,62,34,0,0,0,115,35,0,
0,0,248,233,0,128,0,208,22,95,210,84,94,200,66,145,
122,212,34,51,176,74,192,2,211,34,67,215,23,68,208,23,
68,211,84,94,249,115,4,0,0,0,131,32,35,1,40,2,
0,0,79,1,33,0,40,2,0,0,0,99,1,0,0,0,
0,0,0,0,0,0,0,0,7,0,0,0,51,0,0,0,
115,74,0,0,0,58,2,32,0,29,0,149,0,81,0,16,
0,67,23,0,0,107,1,80,2,31,0,87,1,0,0,0,
0,0,0,0,0,80,3,81,1,49,2,0,0,0,0,0,
0,49,1,0,0,0,0,0,0,115,0,149,5,29,0,72,
25,0,0,9,0,29,0,79,0,33,0,51,3,100,1,40,
1,0,0,0,78,40,1,0,0,0,117,17,0,0,0,216,
182,217,133,95,216,167,217,132,217,133,216,179,216,167,216,177,
40,4,0,0,0,117,2,0,0,0,46,48,117,2,0,0,
0,216,182,117,10,0,0,0,216,167,216,174,216,170,216,168,
216,177,117,10,0,0,0,216,179,216,167,216,168,217,130,216,
169,115,4,0,0,0,32,32,128,128,117,16,0,0,0,60,
216,172,216,177,216,175,32,71,101,116,80,97,116,104,62,117,
9,0,0,0,60,103,101,110,101,120,112,114,62,117,38,0,
0,0,216,168,216,173,216,171,95,216,170,216,181,216,167,216,
185,216,175,217,138,46,60,108,111,99,97,108,115,62,46,60,
103,101,110,101,120,112,114,62,34,0,0,0,115,35,0,0,
0,248,233,0,128,0,208,22,95,210,84,94,200,66,145,122,
212,34,51,176,74,192,2,211,34,67,215,23,68,208,23,68,
211,84,94,249,115,4,0,0,0,131,32,35,1,78,40,2,
0,0,0,117,13,0,0,0,216,170,216,173,217,130,217,130,
95,216,167,217,138,117,19,0,0,0,216,167,216,179,217,133,
95,216,167,217,132,217,133,216,172,217,132,216,175,40,3,0,
Expand Down
6 changes: 6 additions & 0 deletions source/AlifCore/Objects/ActionHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,9 @@ ExprTy alifParserEngine_collectCallSeqs(AlifParser* _p, ASDLExprSeq* _a, ASDLSeq
if (stars) totalLen += ASDL_SEQ_LEN(stars);

ASDLExprSeq* args = alifNew_exprSeq(totalLen, _astMem);
if (args == nullptr) {
return nullptr;
}

AlifSizeT i = 0;
for (i = 0; i < argsLen; i++) {
Expand Down Expand Up @@ -895,6 +898,9 @@ static ASDLExprSeq* unpackTopLevel_joinedStrs(AlifParser* _p, ASDLExprSeq* _rawE
}

ASDLExprSeq* expressions = alifNew_exprSeq(reqSize, _p->astMem);
if (expressions == nullptr) {
return nullptr;
}

AlifSizeT rawIndex{}, reqIndex = 0;
for (rawIndex = 0; rawIndex < rawSize; rawIndex++) {
Expand Down
2 changes: 2 additions & 0 deletions source/AlifCore/Objects/AlifCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,8 @@ static AlifIntT compute_codeFlags(AlifCompiler* _c) {
flags |= CO_VARARGS;
if (ste->varKeywords)
flags |= CO_VARKEYWORDS;
if (ste->hasDocstring)
flags |= CO_HAS_DOCSTRING;
}

if (ste->coroutine and !ste->generator) {
Expand Down
19 changes: 9 additions & 10 deletions source/AlifCore/Objects/Codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,37 +1229,36 @@ static AlifIntT codegen_functionBody(AlifCompiler* _c, StmtTy _s,
RETURN_IF_ERROR(
codegen_enterScope(_c, name, scopeType, (void*)_s, _firstLineNo, nullptr, &umd));

AlifSizeT first_instr = 0;
AlifSizeT firstInstr = 0;
AlifObject* docstring = alifAST_getDocString(body);
if (docstring) {
first_instr = 1;
firstInstr = 1;
/* add docstring */
//docstring = _alifCompile_cleanDoc(docstring);
//if (docstring == nullptr) {
// compiler_exitScope(_c);
// return ERROR;
//}
AlifSizeT idx = _alifCompiler_addConst(_c, docstring);
ALIF_DECREF(docstring);
RETURN_IF_ERROR_IN_SCOPE(_c, idx < 0 ? ERROR : SUCCESS);
}

AlifSizeT idx = _alifCompiler_addConst(_c, docstring ? docstring : ALIF_NONE);
ALIF_XDECREF(docstring);
RETURN_IF_ERROR_IN_SCOPE(_c, idx < 0 ? ERROR : SUCCESS);

NEW_JUMP_TARGET_LABEL(_c, start);
USE_LABEL(_c, start);
SymTableEntry* ste = SYMTABLE_ENTRY(_c);
bool add_stopiteration_handler = ste->coroutine or ste->generator;
if (add_stopiteration_handler) {
bool addStopIterationHandler = ste->coroutine or ste->generator;
if (addStopIterationHandler) {
RETURN_IF_ERROR(
_alifCompiler_pushFBlock(_c, _noLocation_,
AlifCompileFBlockType::Compiler_FBlock_Stop_Iteration,
start, NO_LABEL, nullptr));
}

for (AlifSizeT i = first_instr; i < ASDL_SEQ_LEN(body); i++) {
for (AlifSizeT i = firstInstr; i < ASDL_SEQ_LEN(body); i++) {
VISIT_IN_SCOPE(_c, Stmt, (StmtTy)ASDL_SEQ_GET(body, i));
}
if (add_stopiteration_handler) {
if (addStopIterationHandler) {
RETURN_IF_ERROR_IN_SCOPE(_c, codegen_wrapInStopIterationHandler(_c));
_alifCompiler_popFBlock(_c, AlifCompileFBlockType::Compiler_FBlock_Stop_Iteration, start);
}
Expand Down
2 changes: 1 addition & 1 deletion source/AlifCore/Objects/FuncObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ AlifObject* alifFunction_newWithQualName(AlifObject* _code,

AlifObject* consts = codeObj->consts;
AlifObject* doc{};
if (alifTuple_size(consts) >= 1) {
if (codeObj->flags & CO_HAS_DOCSTRING) {
doc = alifTuple_getItem(consts, 0);
if (!ALIFUSTR_CHECK(doc)) {
doc = ALIF_NONE;
Expand Down
3 changes: 3 additions & 0 deletions source/AlifCore/Objects/LongObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2810,6 +2810,9 @@ static AlifLongObject* long_add(AlifLongObject* _a, AlifLongObject* _b) { // 376
return z;
}

AlifObject* _alifLong_add(AlifLongObject* _a, AlifLongObject* _b) { // 3782
return (AlifObject*)long_add(_a, _b);
}

static AlifObject* long_addMethod(AlifObject* _a, AlifObject* _b) { // 3795
CHECK_BINOP(_a, _b);
Expand Down
2 changes: 2 additions & 0 deletions source/AlifCore/Objects/SymTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ static SymTableEntry* ste_new(AlifSymTable* _st, AlifObject* _name, BlockType_ _
ste_->needsClassDict = 0;
ste_->annotationBlock = nullptr;

ste_->hasDocstring = 0;

ste_->symbols = alifDict_new();
ste_->varNames = alifList_new(0);
ste_->children = alifList_new(0);
Expand Down
55 changes: 51 additions & 4 deletions source/AlifCore/Objects/clinic/MathModule.cpp.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,67 @@

#include "AlifCore_ModSupport.h"

// 19

#define MATH_GCD_METHODDEF \
{"قم_اكبر", ALIF_CPPFUNCTION_CAST(math_gcd), METHOD_FASTCALL},

static AlifObject* math_gcdImpl(AlifObject*, AlifSizeT, AlifObject* const*);

static AlifObject* math_gcd(AlifObject* _module,
AlifObject* const* _args, AlifSizeT _nArgs) { // 23
AlifObject* returnValue{};
AlifSizeT nvararg = _nArgs - 0;
AlifObject* const* __clinicArgs{};

if (!_ALIFARG_CHECKPOSITIONAL("قم_اكبر", _nArgs, 0, ALIF_SIZET_MAX)) {
goto exit;
}
__clinicArgs = _args + 0;
returnValue = math_gcdImpl(_module, nvararg, __clinicArgs);

exit:
return returnValue;
}

#define MATH_LCM_METHODDEF \
{"قم_اصغر", ALIF_CPPFUNCTION_CAST(math_lcm), METHOD_FASTCALL},

static AlifObject* math_lcmImpl(AlifObject*, AlifSizeT, AlifObject *const*);

static AlifObject* math_lcm(AlifObject* _module,
AlifObject* const* _args, AlifSizeT _nArgs) { // 52
AlifObject* returnValue{};
AlifSizeT nvararg = _nArgs - 0;
AlifObject* const* __clinicArgs{};

if (!_ALIFARG_CHECKPOSITIONAL("قم_اصغر", _nArgs, 0, ALIF_SIZET_MAX)) {
goto exit;
}
__clinicArgs = _args + 0;
returnValue = math_lcmImpl(_module, nvararg, __clinicArgs);

exit:
return returnValue;
}





// 77
#define MATH_CEIL_METHODDEF \
{"حد_اعلى", (AlifCPPFunction)math_ceil, METHOD_O},

// 30
// 88
#define MATH_FLOOR_METHODDEF \
{"حد_ادنى", (AlifCPPFunction)math_floor, METHOD_O},


// 61
// 119
#define MATH_FACTORIAL_METHODDEF \
{"المضروب", (AlifCPPFunction)math_factorial, METHOD_O},

// 330
// 388
#define MATH_DIST_METHODDEF \
{"مسافة", ALIF_CPPFUNCTION_CAST(math_dist), METHOD_FASTCALL},

Expand Down
14 changes: 7 additions & 7 deletions source/Modules/MathModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static double m_log(double _x) { // 641
}
}

static AlifObject* math_gcd(AlifObject* _module, AlifObject* const* _args, AlifSizeT _nArgs) { // 723
static AlifObject* math_gcdImpl(AlifObject* _module, AlifSizeT _nArgs, AlifObject* const* _args) { // 730
if (_nArgs == 2 and ALIFLONG_CHECKEXACT(_args[0]) and ALIFLONG_CHECKEXACT(_args[1]))
{
return alifLong_gcd(_args[0], _args[1]);
Expand Down Expand Up @@ -141,8 +141,8 @@ static AlifObject* long_lcm(AlifObject* _a, AlifObject* _b) { // 774
return ab;
}

static AlifObject* math_lcm(AlifObject* _module,
AlifObject* const* _args, AlifSizeT _nArgs) { // 802
static AlifObject* math_lcmImpl(AlifObject* _module,
AlifSizeT _nArgs, AlifObject* const* _args) { // 802
AlifObject* res{}, * x{};
AlifSizeT i{};

Expand Down Expand Up @@ -560,8 +560,8 @@ static AlifObject* math_distImpl(AlifObject* _module, AlifObject* _p, AlifObject
m = ALIFTUPLE_GET_SIZE(_p);
n = ALIFTUPLE_GET_SIZE(_q);
if (m != n) {
//alifErr_setString(_alifExcValueError_,
//"both points must have the same number of dimensions");
alifErr_setString(_alifExcValueError_,
"كلا النقطتين يجب أن تمتلك نفس عدد الأبعاد");
goto errorExit;
}
if (n > NUM_STACK_ELEMS) {
Expand Down Expand Up @@ -630,8 +630,8 @@ static AlifMethodDef _alifMathMethods_[] = { // 4087
MATH_DIST_METHODDEF
{"قيمة_مطلقة", math_fabs, METHOD_O},
MATH_FACTORIAL_METHODDEF
{"قم_اكبر", ALIF_CPPFUNCTION_CAST(math_gcd), METHOD_FASTCALL},
{"قم_اصغر", ALIF_CPPFUNCTION_CAST(math_lcm), METHOD_FASTCALL},
MATH_GCD_METHODDEF
MATH_LCM_METHODDEF
{"لوغ", ALIF_CPPFUNCTION_CAST(math_log), METHOD_FASTCALL},
MATH_RADIANS_METHODDEF
{nullptr, nullptr} /* sentinel */
Expand Down
Loading