@@ -6505,8 +6505,12 @@ main (void)
65056505
65066506Generate snapshot from the specified source code.
65076507
6508- *Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
6509- is no longer needed.
6508+ *Notes*:
6509+ - Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
6510+ is no longer needed.
6511+ - This API depends on a build option (`JERRY_SNAPSHOT_SAVE`) and can be checked in runtime with
6512+ the `JERRY_FEATURE_SNAPSHOT_SAVE` feature enum value, see [jerry_is_feature_enabled](#jerry_is_feature_enabled).
6513+ If the feature is not enabled the function will return an error.
65106514
65116515**Prototype**
65126516
@@ -6560,7 +6564,11 @@ main (void)
65606564 global_mode_snapshot_buffer,
65616565 sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
65626566
6563- size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
6567+ if (!jerry_value_is_error (generate_result))
6568+ {
6569+ size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
6570+ }
6571+
65646572 jerry_release_value (generate_result);
65656573
65666574 jerry_cleanup ();
@@ -6586,8 +6594,12 @@ with the given arguments.
65866594The function arguments and function body are
65876595passed as separated arguments.
65886596
6589- *Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
6590- is no longer needed.
6597+ *Notes*:
6598+ - Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
6599+ is no longer needed.
6600+ - This API depends on a build option (`JERRY_SNAPSHOT_SAVE`) and can be checked in runtime with
6601+ the `JERRY_FEATURE_SNAPSHOT_SAVE` feature enum value, see [jerry_is_feature_enabled](#jerry_is_feature_enabled).
6602+ If the feature is not enabled the function will return an error.
65916603
65926604**Prototype**
65936605
@@ -6648,7 +6660,11 @@ main (void)
66486660 func_snapshot_buffer,
66496661 sizeof (func_snapshot_buffer) / sizeof (uint32_t));
66506662
6651- size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
6663+ if (!jerry_value_is_error (generate_result))
6664+ {
6665+ size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
6666+ }
6667+
66526668 jerry_release_value (generate_result);
66536669
66546670 jerry_cleanup ();
@@ -6670,8 +6686,12 @@ main (void)
66706686
66716687Execute snapshot from the specified buffer.
66726688
6673- *Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
6674- is no longer needed.
6689+ *Notes*:
6690+ - Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
6691+ is no longer needed.
6692+ - This API depends on a build option (`JERRY_SNAPSHOT_EXEC`) and can be checked in runtime with
6693+ the `JERRY_FEATURE_SNAPSHOT_EXEC` feature enum value, see [jerry_is_feature_enabled](#jerry_is_feature_enabled).
6694+ If the feature is not enabled the function will return an error.
66756695
66766696**Prototype**
66776697
@@ -6683,13 +6703,13 @@ jerry_exec_snapshot (const uint32_t *snapshot_p,
66836703 uint32_t exec_snapshot_opts);
66846704```
66856705
6686- - `snapshot_p` - pointer to snapshot
6687- - `snapshot_size` - size of snapshot in bytes
6688- - `func_index` - index of executed function
6706+ - `snapshot_p` - pointer to snapshot.
6707+ - `snapshot_size` - size of snapshot in bytes.
6708+ - `func_index` - index of executed function.
66896709- `exec_snapshot_opts` - any combination of [jerry_exec_snapshot_opts_t](#jerry_exec_snapshot_opts_t) flags.
66906710- return value
6691- - result of bytecode, if run was successful
6692- - thrown error, otherwise
6711+ - result of bytecode, if run was successful.
6712+ - thrown error, otherwise (an error is reported if the snapshot execution feature is not enabled).
66936713
66946714*Changed in version 2.0*: Added `func_index` and `exec_snapshot_opts` arguments. Removed the `copy_bytecode` last argument.
66956715
@@ -6716,6 +6736,7 @@ main (void)
67166736 0,
67176737 global_mode_snapshot_buffer,
67186738 sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
6739+ // generate_result should be checked if it is an error or not
67196740
67206741 size_t global_mode_snapshot_size = (size_t) jerry_get_number_value (generate_result);
67216742 jerry_release_value (generate_result);
@@ -6728,6 +6749,9 @@ main (void)
67286749 global_mode_snapshot_size,
67296750 0,
67306751 0);
6752+
6753+ // check the `res` value for error and process the result.
6754+
67316755 jerry_release_value (res);
67326756
67336757 jerry_cleanup ();
@@ -6750,8 +6774,12 @@ Load the selected snapshot function from the specified buffer as a function obje
67506774
67516775The lexical environment of the loaded function is always the global lexical environment.
67526776
6753- *Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
6754- is no longer needed.
6777+ *Notes*:
6778+ - Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
6779+ is no longer needed.
6780+ - This API depends on a build option (`JERRY_SNAPSHOT_EXEC`) and can be checked in runtime with
6781+ the `JERRY_FEATURE_SNAPSHOT_EXEC` feature enum value, see [jerry_is_feature_enabled](#jerry_is_feature_enabled).
6782+ If the feature is not enabled the function will return an error.
67556783
67566784**Prototype**
67576785
@@ -6846,6 +6874,11 @@ main (void)
68466874Collect the used literals from the given snapshot and save them into a buffer in list or C format.
68476875None of these literals are magic strings. In C format only valid identifiers are collected.
68486876
6877+ *Note*:
6878+ - This API depends on a build option (`JERRY_SNAPSHOT_SAVE`) and can be checked in runtime with
6879+ the `JERRY_FEATURE_SNAPSHOT_SAVE` feature enum value, see [jerry_is_feature_enabled](#jerry_is_feature_enabled).
6880+ If the feature is not enabled the function will return zero.
6881+
68496882**Prototype**
68506883
68516884```c
0 commit comments