Skip to content
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

Revert "[TIMOB-10837] use return with the last statement for blocks" #6026

Merged
merged 1 commit into from
Sep 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import java.util.Stack;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollEventCallback;
Expand Down Expand Up @@ -148,18 +146,8 @@ synchronized public String getJSValue(String expression)
{
// Don't try to evaluate js code again if the binding has already been destroyed
if (!destroyed) {
// see if this is an expression or a statement block
// Match ; followed by 0 or even quotes
Pattern pattern = Pattern.compile(";(?=([^\"]*\"[^\"]*\")*[^\"]*$)");
Matcher matcher = pattern.matcher(expression);
if (matcher.find()) {
String lastStmt = expression.substring(matcher.end(matcher.groupCount() - 1));
String stmtBlock = expression.substring(0, matcher.end(matcher.groupCount() - 1));
expression = stmtBlock + " return " + lastStmt;
} else {
expression = " return " + expression;
}
String code = "_TiReturn.setValue((function(){try{" + expression + "+\"\";}catch(ti_eval_err){return '';}})());";
String code = "_TiReturn.setValue((function(){try{return " + expression
+ "+\"\";}catch(ti_eval_err){return '';}})());";
Log.d(TAG, "getJSValue:" + code, Log.DEBUG_MODE);
returnSemaphore.drainPermits();
synchronized (codeSnippets) {
Expand Down