-
Notifications
You must be signed in to change notification settings - Fork 683
Implemention of eval (by Andrey Shitov and Ruben Ayrapetyan) #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
101b78b
to
7c49630
Compare
assert (typeof (y) === 'string'); | ||
|
||
delete y; | ||
assert (typeof (y) === 'string'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be "undefined" instead of "string"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, as y
is variable, declared through 'var' in global code (10.4.1), and so configurableBindings
for the variable is false
(10.5).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah.. okay I see.
7c49630
to
283b718
Compare
Pull request is updated: added two more test cases for 'eval'. |
Please, review. |
if (this_arg_p != NULL | ||
&& !operand_is_empty (*this_arg_p)) | ||
{ | ||
call_flags = (opcode_call_flags_t) (call_flags | OPCODE_CALL_FLAGS_HAVE_THIS_ARG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think call_flags |= OPCODE_CALL_FLAGS_HAVE_THIS_ARG
would be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it seems to be more readable, but current compiler options do not permit the version:
error: invalid conversion from ‘int’ to ‘opcode_call_flags_t’ [-fpermissive]
.
Strange name of pull request. I feel myself excluded ^_^ |
{ | ||
is_strict = true; | ||
} | ||
if ((scope_flags & OPCODE_SCOPE_CODE_FLAGS_NOT_REF_ARGUMENTS_IDENTIFIER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing empty line.
283b718
to
5e3e5f3
Compare
@egavrin, I've updated pull request according to your note. |
JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta); | ||
JERRY_ASSERT (next_opcode.data.meta.type == OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER); | ||
|
||
lit_cpointer_t catch_exc_val_var_name_lit_cp = serializer_get_literal_cp_by_uid ( | ||
next_opcode.data.meta.data_1, | ||
int_data->pos); | ||
int_data->opcodes_p, int_data->pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO: the last argument should be on a new line if the other parameters are already separated by a newline character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
5e3e5f3
to
f180f04
Compare
|
||
#ifdef MEM_STATS | ||
const opcode_counter_t opcode_pos = int_data_p->pos; | ||
|
||
interp_mem_stats_opcode_enter (opcode_pos, | ||
interp_mem_stats_opcode_enter (int_data_p->opcodes_p, opcode_pos, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameters should each be on it's own line in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
f180f04
to
f025fac
Compare
@egavrin, fix some notes and you'll be included ;)) |
@galpeter, I've updated pull request according to your notes, except about missing comments to arguments (as I'm waiting for your answer). |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got a test case which fails with this PR:
var r = function() { return eval('return 1;'); };
try {
r();
print("fail");
assert(false);
} catch (e) {
print(e);
assert(e instanceof SyntaxError);
}
It prints out the fail
message, but a SyntaxError should be thrown. Other engines reports the error with the "return not in function" message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the case.
Correct syntax errors handling would be implemented in context of #54.
Could you, please, add the test case to the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
#include "ecma-conversion.h" | ||
#include "ecma-exceptions.h" | ||
#include "ecma-try-catch-macro.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other files, these are lexically ordered. This rule was true here before the change.
I don't mind if we discard this rule, just we should say it explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is an issue. Will fix.
I've got no other comments, lgtm |
6d76992
to
adf7262
Compare
@zherczeg, thank you for your notes. The pull request is updated. |
b539076
to
70e2fe9
Compare
JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
…h 'code' argument represented as array of characters instead of ecma-string. Updating jerry_api_eval to use ecma_op_eval_chars_buffer, so removing redundant conversion of character array to ecma-string. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
70e2fe9
to
db99cde
Compare
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
…nal information' meta opcode with flags describing the call site features, and, optionally, 'this' argument. Introducing opcode_call_flags_t for argument of the new meta opcode, currently with two flags: 'have this argument' and '"direct call to eval" form'. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
…'Direct call to eval' form in process, and interfaces for accessing the flag and 'strict mode' flag. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
db99cde
to
5d5e75f
Compare
Related issue: #48