From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- files/ar/mozilla/projects/index.html | 15 + files/ar/mozilla/projects/spidermonkey/index.html | 115 +++++++ .../index.html | 373 +++++++++++++++++++++ 3 files changed, 503 insertions(+) create mode 100644 files/ar/mozilla/projects/index.html create mode 100644 files/ar/mozilla/projects/spidermonkey/index.html create mode 100644 files/ar/mozilla/projects/spidermonkey/introduction_to_the_javascript_shell/index.html (limited to 'files/ar/mozilla/projects') diff --git a/files/ar/mozilla/projects/index.html b/files/ar/mozilla/projects/index.html new file mode 100644 index 0000000000..d7e62c6882 --- /dev/null +++ b/files/ar/mozilla/projects/index.html @@ -0,0 +1,15 @@ +--- +title: Projects +slug: Mozilla/Projects +tags: + - Landing + - Mozilla + - NeedsContent + - NeedsTranslation + - Projects + - TopicStub +translation_of: Mozilla/Projects +--- +

Here you'll find links to documentation about various Mozilla projects; these are often parts of Firefox or other products, but may also be used in other projects as well.

+ +

{{ LandingPageListSubpages() }}

diff --git a/files/ar/mozilla/projects/spidermonkey/index.html b/files/ar/mozilla/projects/spidermonkey/index.html new file mode 100644 index 0000000000..f39621af26 --- /dev/null +++ b/files/ar/mozilla/projects/spidermonkey/index.html @@ -0,0 +1,115 @@ +--- +title: 'SpiderMonkey: The Mozilla JavaScript runtime' +slug: Mozilla/Projects/SpiderMonkey +tags: + - NeedsTranslation + - SpiderMonkey + - TopicStub +translation_of: Mozilla/Projects/SpiderMonkey +--- +
{{SpiderMonkeySidebar}}
+ +
+

SpiderMonkey is Mozilla's JavaScript engine written in C and C++. It is used in various Mozilla products, including Firefox, and is available under the MPL2.

+
+ +

Standalone source code releases can be found on the Releases page.

+ +
+
+

Guides

+ +

Building

+ +
+
SpiderMonkey Build Documentation
+
How to get SpiderMonkey source code, build it, and run the test suite.
+
+ +

Using SpiderMonkey

+ +
+
Introduction to the JavaScript shell
+
Documentation of the command-line JavaScript shell, js.
+
JSAPI User Guide
+
This guide provides an overview of SpiderMonkey and describes how you can embed engine calls in your applications to make them JavaScript-aware.
+
JSAPI cookbook
+
Shows the JSAPI translation of some commonly used JavaScript expressions and statements.
+
GC Rooting Guide
+
Guide on how to write code compatible with the Generational GC in SpiderMonkey.
+
How to embed the JavaScript engine
+
An older tutorial about embedding SpiderMonkey.
+
+ +

Hacking on SpiderMonkey

+ +
+
New to SpiderMonkey
+
A guide to hacking on SpiderMonkey.
+
Setting up CDT to work on SpiderMonkey
+
How to configure Eclipse to work on the SpiderMonkey code.
+
+ +
+
Running Automated JavaScript Tests
+
How to run the JavaScript test suites.
+
Creating JavaScript tests
+
How to add tests to the JavaScript test suites.
+
+
+ +
+

Reference

+ +
+
JSAPI Reference
+
SpiderMonkey API reference.
+
JS Debugger API Reference
+
API reference for the Debugger object introduced in SpiderMonkey 1.8.6, which corresponds to Gecko 8.0 {{ geckoRelease("8.0") }}.
+
Bytecode descriptions
+
Listing of SpiderMonkey's bytecodes.
+
Parser API
+
Reflection of the SpiderMonkey parser, made available as a JavaScript API.
+
+ +

Tips, tricks and philosophy

+ +
+
Future Directions
+
Future directions for functionality, design, and coding practices.
+
SpiderMonkey Internals
+
A design overview and a file-by-file walkthrough of the implementation.
+
Bytecode Reference
+
SpiderMonkey bytecode reference.
+
SpiderMonkey Internals: GC
+
Separate internals article on the GC
+
SpiderMonkey Internals: Hacking Tips
+
Collection of helpful tips & tools for hacking on the engine
+
+ + + + + +

Releases

+ +
+
SpiderMonkey release notes
+
Current and past versions: 5245, 38, 31, 24, 17
+
+ +

Community

+ + + +
+
+
+
diff --git a/files/ar/mozilla/projects/spidermonkey/introduction_to_the_javascript_shell/index.html b/files/ar/mozilla/projects/spidermonkey/introduction_to_the_javascript_shell/index.html new file mode 100644 index 0000000000..80998587aa --- /dev/null +++ b/files/ar/mozilla/projects/spidermonkey/introduction_to_the_javascript_shell/index.html @@ -0,0 +1,373 @@ +--- +title: Introduction to the JavaScript shell +slug: Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell +translation_of: Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell +--- +
{{SpiderMonkeySidebar ("عام")}}
+ +
+

و جافا سكريبت قذيفة ( js) هو برنامج سطر الأوامر المدرجة في سبايدر مونكي توزيع المصدر. إنه مكافئ جافا سكريبت لموجه Python التفاعلي ، أو حلقة Lisp للقراءة والتقييم والطباعة ، أو Ruby's irb. تشرح هذه المقالة كيفية استخدام الصدفة لتجربة كود JavaScript وتشغيل برامج JavaScript.

+
+ +

للحصول على SpiderMonkey JavaScript shell ، راجع  SpiderMonkey Build Documentation  أو قم بتنزيل ملف ثنائي مترجم لمنصتك من Nightly Builds .

+ +

للحصول على قائمة بأغلفة JavaScript الأخرى ، راجع قذائف JavaScript .

+ +
+

ملاحظة: بدءًا من SpiderMonkey 44 {{geckoRelease (44)}} ، يتم استخدام إصدار JavaScript القياسي المتوافق مع الويب افتراضيًا (وليس JS1.7 + بعد الآن). و version()قذيفة المضمن لا يزال هناك لاختبار الميزات القديمة.

+
+ +

تشغيل قشرة JavaScript

+ +

تقدم القذيفة وضعين للتشغيل. يمكنك استخدامه كصدفة تفاعلية ، حيث تكتب رمز JavaScript في الحال وتحصل على إشباع فوري ، وهو مفيد لتجربة الميزات الجديدة أو اختبارها. يمكنك أيضًا تمرير ملف برنامج JavaScript في سطر الأوامر ليتم تشغيله ، وفي هذه الحالة يتم تشغيل البرنامج تلقائيًا.

+ +

بعد اتباع وثائق الإنشاء وتثبيت الغلاف المدمج باستخدام إجراء التثبيت ، يمكنك تشغيل الصدفة في الوضع التفاعلي باستخدام الأمر:

+ +
شبيبة
+
+ +

[إذا حصلت على "خطأ في البحث عن الرمز: ./js: رمز غير محدد: PR_SetCurrentThreadName" على سبيل المثال من وحدة تحكم Bash عند استخدام برنامج ثنائي تم تجميعه مسبقًا ، جرب <path to your Firefox's run-mozilla.sh> /run-mozilla.sh. / js - لقد نجحت معي]

+ +

إذا كنت ترغب في تشغيل كود JavaScript في الملف foo.js، يمكنك استخدام هذا الأمر:

+ +
js foo.js
+
+ +

للتشغيل foo.jsثم الإسقاط في الغلاف التفاعلي ، قم بما يلي:

+ +
js -f foo.js -i
+
+ +

مرجع

+ +
ملاحظة: نظرًا لاستخدام JavaScript shell كبيئة اختبار لمحرك JavaScript ، يمكن أن تتغير الخيارات المتاحة والوظائف المضمنة بمرور الوقت.
+ +

خيارات سطر الأوامر

+ +

هناك عدد من خيارات سطر الأوامر التي يمكنك تحديدها للتحكم في الغلاف. هذه ملخصة أدناه. تأكد من استخدام -h مع jsshell الخاص بك لمعرفة ما إذا كان هناك أي شيء غير موثق.

+ +
+
-c, --compileonly
+
يخبر الغلاف بتجميع البرنامج ولكن لا يقوم بتشغيله. هذه طريقة مناسبة للتحقق بسرعة من أخطاء بناء الجملة في برنامجك دون تشغيله فعليًا.
+
-e script
+
يقوم بتشغيل البرنامج النصي المحدد ، وهو سلسلة حرفية تحتوي على الكود المطلوب تنفيذه.
+
-f filename
+
يقوم بتشغيل برنامج JavaScript المحدد بواسطة اسم الملف .
+
-i
+
تمكن الوضع التفاعلي. (افتراضي إذا لم يتم توفير اسم ملف.)
+
--no-ion
+
تعطيل برنامج التحويل البرمجي الأمثل JIT.
+
--no-baseline
+
تعطيل مترجم JIT الأساسي.
+
-P
+
إذا كان السطر الأول من الملف هو "/ usr / bin / env js -P" ، فسيتم تفسير محتوى الملف بواسطة محرك JavaScript.
+
يمكّنك هذا من إنشاء ملف JavaScript قابل للتنفيذ على أجهزة unix و OS X.
+
-s
+
لتمكين وضع التحذير الصارم.
+
-w, --warnings
+
تمكن رسائل التحذير.
+
-W، - المعلومات
+
تعطيل رسائل التحذير.
+
+ +

خيارات البيئة

+ +

هناك بعض متغيرات البيئة التي يمكن ضبطها لتغيير سلوك js shell.

+ +
+
JS_STDOUT=file
+
إعادة توجيه stdout إلى ملف .
+
JS_STDERR=file
+
إعادة توجيه stderr إلى ملف .
+
+ +

وظائف مدمجة

+ +

لجعل JavaScript shell أكثر فائدة ، هناك عدد من الوظائف المضمنة بشرط أن يمكنك استخدامها إما من برامج JavaScript أو في الوضع التفاعلي.

+ +
+

ملاحظة : هذه القائمة غير مكتملة وتتداخل مع كائنات شل العامة . راجع {{Source ("js / src / shell / js.cpp")}} (حول shell_functions) للمزيد.

+
+ +

build()

+ +

لعرض التاريخ والوقت اللذين تم فيهما إنشاء غلاف JavaScript.

+ +
ملاحظة: clear() بدون أي معلمات يزيل كل شيء حقًا. وهذا يشمل كل هذه الوظائف المدمجة.
+ +

clone(function, [scope])

+ +

استنساخ كائن الوظيفة المحدد . إذا لم يتم تحديد النطاق ، فسيكون الكائن الرئيسي الجديد هو نفسه الكائن الأصلي. خلاف ذلك ، يتم وضع الكائن الجديد في نطاق الكائن المحدد بواسطة النطاق .

+ +

countHeap([start[, kind]])

+ +

{{jsapi_minversion_inline ("1.8")}} احسب عدد أشياء GC الحية في الكومة ، أو الأشياء التي يمكن الوصول إليها من البداية عندما يتم تقديمها وليست فارغة. النوع هو إما 'all'(افتراضي) لعد كل الأشياء أو واحد من 'object'، 'double'، 'string'، 'function'، 'qname'، 'namespace'، 'xml'لحساب الأشياء من هذا النوع فقط.

+ +

dumpHeap([fileName[, start[, toFind[, maxDepth[, toIgnore]]]]])

+ +

{{jsapi_minversion_inline ("1.8")}} تفريغ الرسم البياني لجميع الكائنات الموجودة (أو رسم فرعي محدد مثير للاهتمام) إلى ملف. لمزيد من المعلومات ، راجع إصدار C / C ++ من هذه الوظيفة ، JS_DumpHeap.

+ +

evalcx(string[, object])

+ +

يقيم كود JavaScript في السلسلة . إذا تم تحديد الكائن ، فسيتم تنفيذ الكود في هذا الكائن ، ومعاملته كصندوق حماية.

+ +

إذا كانت السلسلة فارغة ولم يتم تحديد الكائن ، يتم evalcx()إرجاع كائن جديد بفئات قياسية متلهفة.

+ +

إذا كانت السلسلة "lazy" ولم يتم تحديد الكائن ، يتم evalcx()إرجاع كائن جديد بفئات قياسية كسولة.

+ +
ملاحظة: evalcx() هذا مفيد فقط للأشخاص الذين يقومون بعمل داخلي عميق على محرك JavaScript ، evalInSandboxلبيئات تشبه الاختبار في الغلاف.
+ +

gc()

+ +

يدير جامع القمامة لتحرير الذاكرة.

+ +

gcparam(name[, value])

+ +

{{jsapi_minversion_inline ("1.8")}} قراءة أو تهيئة معلمات أداة تجميع البيانات المهملة.

+ +

و اسم يجب أن يكون واحدا من مفاتيح المعلمة (مثل 'maxBytes'، 'maxMallocBytes'أو ' gcNumber') حددها FOR_EACH_GC_PARAMفي https://searchfox.org/mozilla-central/source/js/src/builtin/TestingFunctions.cpp#464 .

+ +

إذا لم يتم تحديد القيمة ، يتم gcparam()إرجاع القيمة الحالية المرتبطة بمعلمة GC المسماة بالاسم .

+ +

إذا تم تحديد القيمة ، يجب أن تكون قابلة للتحويل إلى uint32 موجب ؛ gcparam()يحدد اسم معلمة GC إلى قيمة .

+ +

لمزيد من المعلومات ، راجع دالات C / C ++  JS_GetGCParameterو JS_SetGCParameter.

+ +

gczeal(level)

+ +

{{jsapi_minversion_inline ("1.8")}} DEBUGفقط. اضبط مستوى حماسة GC ، ميزة تصحيح الأخطاء. يمكن أن يكون هذا 0 لجمع القمامة الدورية العادية ، أو 1 لـ GC المتكرر للغاية ، أو 2 لـ GC المتكرر للغاية . أي شيء بخلاف 0 سيجعل JavaScript يعمل ببطء شديد ولكنه قد يساعد في الكشف عن الأخطاء المتعلقة بـ GC أو إعادة إنتاجها. لمزيد من المعلومات ، راجع إصدار C / C ++ من هذه الوظيفة ، JS_SetGCZeal.

+ +

getpda(object)

+ +

إرجاع واصفات الخصائص للكائن المحدد .

+ +

getslx(object)

+ +

Returns the script line extent, which is the number of lines of code comprising the specified object.

+ +

help([command ...])

+ +

Displays brief help information about the specified commands, or about all available functions if none are specified.

+ +

intern(string)

+ +

Internalizes the specified string into the atom table. Every string has a unique identifier, called an atom. This system makes it easier to do comparisons between strings.

+ +
Note: This function is intended only for use when testing the JavaScript engine.
+ +

line2pc([function, ] line)

+ +

Returns the program counter value corresponding to the specified line of code. If function is specified, line is an offset into the specified function.

+ +

load(filename1 [filename])

+ +

Loads the JavaScript files with the specified names.

+ +
Note: For loading non-JavaScript files, use read().
+ +

options([option ...])

+ +

Lets you set or get options. If you specified options on the command line, the results of calling options will indicate which options you requested. You can also pass in new options to set.

+ +

The available options are:

+ + + + + + + + + + + + + + + + + + + + +
Option NameDescription
strictStrict mode is enabled.
werrorWarnings should be treated as errors.
atlineWhen atline is enabled, comments of the form //@line num set the number of the following line to num.
+ +

pc2line(function, [pc])

+ +

Returns the line number of the JavaScript code that corresponds to the first line of the specified function. If you specify a program counter offset into the function, the line number of the line of code containing that offset is returned.

+ +

print([expression ...])

+ +

Evaluates the expression(s) and displays the result(s) on stdout, separated by spaces (" ") and terminated by a newline ("\n").

+ +

putstr(expression)

+ +

Evaluates the expression and displays the result on stdout.

+ +

quit([status])

+ +

Exits the shell. status defaults to 0 if omitted.

+ +

read(filename[, type])

+ +

Reads and returns the contents of file. If type is "binary" returns an Uint8Array, otherwise returns an UTF-8 decoded string.

+ +

readline()

+ +

Reads a single line of input from stdin, returning it to the caller. You can use this to create interactive shell programs in JavaScript.

+ +

Reflect.parse()

+ +

See Parser API.

+ +
Note: This function is intended only for use when testing the JavaScript engine.
+ +

seal(object[, deep])

+ +

Seals the specified object, or an object graph if deep is true. By sealing an object or object graph, you disable modification of those objects.

+ +

sleep(dt)

+ +

{{ jsapi_minversion_inline("1.8") }} Only in JS_THREADSAFE builds. Sleep for dt seconds. Fractions of a second are supported. Returns true on success, false if the sleep was interrupted.

+ +

stackQuota([number]) {{obsolete_inline}}

+ +

Get or set the script stack quota.

+ +

throwError()

+ +

Throws an error from the JS_ReportError() function.

+ +
Note: This function is intended only for use when testing the JavaScript engine.
+ +

trap([function, [pc,]] expression)

+ +

Sets a trap at the specific point in the JavaScript code. When the bytecode at the offset specified by pc in the function function is about to be executed, the expression is evaluated.

+ +

This is a powerful debugging mechanism when used in concert with line2pc(). For example, if you want to display a message when line 6 of a function, doSomething() is executed, you can enter the following:

+ +
trap(doSomething, line2pc(doSomething, 6), "print('line 6!\n')");
+
+ +
Note: When a trap is set, the corresponding bytecode in the program is replaced with a trap bytecode until you use untrap() to remove the trap.
+ +

untrap(function [, pc])

+ +

Removes a trap from the specified function at the offset pc. If pc isn't specified, the trap is removed from the function's entry point.

+ +

This function has no effect if there is no trap at the specified location.

+ +

version([number])

+ +

The version() function lets you get or set the JavaScript version number. This may be useful for gaining access to syntax only available in certain versions of JavaScript (for example, see Using JavaScript 1.7).

+ +

Debug functions

+ +

These built-in functions are only available in DEBUG builds.

+ +

dis([function])

+ +

Disassembles the JavaScript bytecode for the entire program, or for the specified function.

+ +

For example, if you enter the JavaScript function below:

+ +
function test() {
+  var i = 3;
+  print(i+2);
+}
+
+ +

Then run the command dis(test);, you get this output:

+ +
main:
+00000:  uint16 3
+00003:  setvar 0
+00006:  pop
+00007:  name "print"
+00010:  pushobj
+00011:  getvar 0
+00014:  uint16 2
+00017:  add
+00018:  call 1
+00021:  pop
+00022:  stop
+
+Source notes:
+  0:     0 [   0] newline
+  1:     3 [   3] decl     offset 0
+  2:     7 [   4] newline
+  3:    18 [  11] xdelta
+  4:    18 [   0] pcbase   offset 11
+
+ +

dissrc([function])

+ +

Disassembles the JavaScript bytecode for the entire program, or for the specified function, showing the source lines. This function only works with programs loaded from files, either using the -f flag on launching the shell, or by using the load() function.

+ +

If your program includes a function, doStuff(), like this:

+ +
function doStuff(input) {
+	print("Enter a number: ");
+	var n1 = readline();
+	print("Enter another one: ");
+	var n2 = readline();
+
+	print("You entered " + n1 + " and " + n2 + "\n");
+}
+
+ +

Calling dissrc(doStuff) function would give this output:

+ +
;-------------------------  10:         print("Enter a number: ");
+00000:  10  name "print"
+00003:  10  pushobj
+00004:  10  string "Enter a number: "
+00007:  10  call 1
+00010:  10  pop
+;-------------------------  11:         var n1 = readline();
+00011:  11  name "readline"
+00014:  11  pushobj
+00015:  11  call 0
+00018:  11  setvar 0
+00021:  11  pop
+;-------------------------  12:         print("Enter another one: ");
+00022:  12  name "print"
+00025:  12  pushobj
+00026:  12  string "Enter another one: "
+00029:  12  call 1
+00032:  12  pop
+;-------------------------  13:         var n2 = readline();
+00033:  13  name "readline"
+00036:  13  pushobj
+00037:  13  call 0
+00040:  13  setvar 1
+00043:  13  pop
+;-------------------------  14:
+;-------------------------  15:         print("You entered " + n1 + " and " + n2 + "\n");
+00044:  15  name "print"
+00047:  15  pushobj
+00048:  15  string "You entered "
+00051:  15  getvar 0
+00054:  15  add
+00055:  15  string " and "
+00058:  15  add
+00059:  15  getvar 1
+00062:  15  add
+00063:  15  string "\\n"
+00066:  15  add
+00067:  15  call 1
+00070:  15  pop
+00071:  15  stop
+
+ +

dumpheap(([fileName[, start[, toFind[, maxDepth[, toIgnore]]]]])

+ +

Dump GC information. This is a thin wrapper for JS_DumpHeap.

+ +

gczeal(zeal)

+ +

قم بتمكين GC المتكرر للمساعدة في العثور على مخاطر GC. الحماسة عدد صحيح. المعنى هو نفسه بالنسبة للمعلمة JS_SetGCZeal.

+ +

notes([function])

+ +

يظهر ملاحظات المصدر للوظيفة المحددة. تحتوي ملاحظات المصدر على معلومات تقوم بتعيين الرمز الثانوي إلى الكود المصدري ، والذي يتم استخدامه عند فك الشفرة ، مثل عند استخدام dissrc()الوظيفة.

-- cgit v1.2.3-54-g00ecf