-
Notifications
You must be signed in to change notification settings - Fork 620
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
Javascript: multiple prototype assignments #3770
Javascript: multiple prototype assignments #3770
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3770 +/- ##
==========================================
+ Coverage 83.03% 83.04% +0.01%
==========================================
Files 227 227
Lines 55135 55175 +40
==========================================
+ Hits 45779 45819 +40
Misses 9356 9356
☔ View full report in Codecov by Sentry. |
Instead of adjusting a parser to vString API, you can add a function to vString API. |
@masatake Thanks for all the feedback! I figured I was missing some useful stuff, e.g., ptrArray. |
f079297
to
cbb1cf3
Compare
I don't know JavaScript well but...
The error tells us This is very unlike variables in a shell script:
It is difficult to know whether X is a definition or reference (with left side role). However, you want to make a tag for B. You need it to make a scope for m5. The However, we must add some new code for handling Here is my proposal:
Comparing a given token with "prototype" twice is a quirk. However, making parsePrototype short is more important. Your code does strstr while iterating the tokens in the array.
|
cbb1cf3
to
aa6e8eb
Compare
Yes! Much better. However, I can't pass |
So you can pass it to |
aa6e8eb
to
d2b1619
Compare
Thank you for updating. After re-reading your change, I found we can reuse your original idea of the string manipulation earlier. if ( isType (method_body_token, TOKEN_EQUAL_SIGN) &&
! isType (identifier_token, TOKEN_UNDEFINED))
{
char *str = vStringValue (identifier_token->string);
char *needle = strstr(str, ".prototype.")
if (prototype_tokens == NULL)
prototype_tokens = ptrArrayNew (deleteTokenFn);
tokenInfo *const save_token = newToken ();
copyToken (save_token, identifier_token, true);
/* Keep \1 of #/(.*)\.prototype\.(.*)/. */
vStringTruncate (save_token->strng, needle - str);
vStringPut (save_token->strng, '.');
/* Append \2 of #/(.*)\.prototype\.(.*)/. */
vStringNCatS (save_token->strng, needle + 11);
ptrArrayAdd (prototype_tokens, save_token);
identifier_token->type = TOKEN_UNDEFINED;
} With this code, we no longer need the change for makeJsRefTagsForNameChain() I proposed. |
d2b1619
to
461905b
Compare
Definitely better to do the string processing in |
Thank you. |
No description provided.