Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[core] fix data render bug (#1557)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianhan-he authored and cxfeng1 committed Sep 20, 2018
1 parent 8041950 commit 1c3a440
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ - (void)renderWithURL:(NSURL *)url options:(NSDictionary *)options data:(id)data

- (void)renderView:(id)source options:(NSDictionary *)options data:(id)data
{
WXLogDebug(@"Render source: %@, data:%@", self, [WXUtility JSONString:data]);
_options = options;
_jsData = data;

self.needValidate = [[WXHandlerFactory handlerForProtocol:@protocol(WXValidateProtocol)] needValidate:self.scriptURL];

if ([source isKindOfClass:[NSString class]]) {
WXLogDebug(@"Render source: %@, data:%@", self, [WXUtility JSONString:data]);
[self _renderWithMainBundleString:source];
} else if ([source isKindOfClass:[NSData class]]) {
[self _renderWithOpcode:source];
Expand Down
12 changes: 4 additions & 8 deletions weex_core/Source/core/data_render/code_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,7 @@ void CodeGenerator::Visit(JSXNodeExpression *node, void *data) {
if (!node->LowerIdentifier()) {
std::string name = node->Identifier()->AsIdentifier()->GetName();
int index = exec_state_->global()->IndexOf(name);
if (index < 0) {
bool exist = block_->FindVariable(name);
if (!exist) {
throw GeneratorError("can't find identifier:" + name);
break;
}
}
else {
if (index >= 0) {
node->SetClass(true);
}
}
Expand Down Expand Up @@ -1093,6 +1086,9 @@ void CodeGenerator::Visit(PrefixExpression *node, void *data) {
else if (operation == PrefixOperation::kDecrement) {
func_->func_state()->AddInstruction(CREATE_ABC(OP_PRE_DECR, reg, ret, 0));
}
else if (operation == PrefixOperation::kNot) {
func_->func_state()->AddInstruction(CREATE_ABx(OP_NOT, ret, reg));
}
else if (operation == PrefixOperation::kUnfold) {
func_->func_state()->AddInstruction(CREATE_ABC(OP_MOVE, ret, reg, 0));
}
Expand Down
14 changes: 4 additions & 10 deletions weex_core/Source/core/data_render/vm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void VM::RunFrame(ExecState *exec_state, Frame frame, Value *ret) {
break;
}
case OP_JMP: {
LOGTEMP("OP_JMP A:%ld\n", GET_ARG_A(instruction));
LOGTEMP("OP_JMP A:%ld B:%ld \n", GET_ARG_A(instruction), GET_ARG_Bx(instruction));
a = frame.reg + GET_ARG_A(instruction);
bool con = false;
if (!ToBool(a, con)) {
Expand Down Expand Up @@ -292,12 +292,9 @@ void VM::RunFrame(ExecState *exec_state, Frame frame, Value *ret) {
LOGTEMP("OP_NOT A:%ld B:%ld \n", GET_ARG_A(instruction), GET_ARG_B(instruction));
a = frame.reg + GET_ARG_A(instruction);
b = frame.reg + GET_ARG_B(instruction);
if (!IsBool(b)) {
// TODO error
throw VMExecError("Not Bool Type Error With OP_CODE [OP_NOT]");
}
a->type =Value::Type::BOOL;
a->b = !b->b;
a->type = Value::Type::BOOL;
ToBool(b, a->b);
a->b = !a->b;
break;
}
case OP_OR: {
Expand Down Expand Up @@ -700,8 +697,6 @@ void VM::RunFrame(ExecState *exec_state, Frame frame, Value *ret) {
}
*a = ref->value();
a->ref = &ref->value();
// int value_index = a - exec_state->stack()->base();
// Value *test = exec_state->stack()->base() + value_index;
break;
}
case OP_GETINDEXVAR:
Expand Down Expand Up @@ -802,7 +797,6 @@ void VM::RunFrame(ExecState *exec_state, Frame frame, Value *ret) {
}
if (IsString(b) || IsTable(b)) {
int ret = SetTableValue(reinterpret_cast<Table *>(a->gc), b, *c);
//LOGTEMP("[OP_SETTABLE]:%s\n", TableToString(ValueTo<Table>(a)).c_str());
if (!ret) {
// TODO set faile
throw VMExecError("Set Table Error With OP_CODE [OP_SETTABLE]");
Expand Down

0 comments on commit 1c3a440

Please sign in to comment.