Пример #1
0
void WhileFunc::execute() {
    static int body_symid = symbol_add("body");
    static int until_symid = symbol_add("until");
    static int nilchk_symid = symbol_add("nilchk");
    ComValue untilflag(stack_key_post_eval(until_symid));
    ComValue nilchkflag(stack_key_post_eval(nilchk_symid));
    ComValue* bodyexpr = nil;
    while (1) {
        if (untilflag.is_false()) {
            ComValue doneexpr(stack_arg_post_eval(0));
            if (nilchkflag.is_false() ? doneexpr.is_false() : doneexpr.is_unknown()) break;
        }
        delete bodyexpr;
        ComValue keybody(stack_key_post_eval(body_symid, false, ComValue::unkval(), true));
        if (keybody.is_unknown() && nargsfixed()>= 2)
            bodyexpr = new ComValue(stack_arg_post_eval(1));
        else
            bodyexpr = new ComValue(keybody);
        if (untilflag.is_true()) {
            ComValue doneexpr(stack_arg_post_eval(0));
            if (nilchkflag.is_false() ? doneexpr.is_true() : doneexpr.is_unknown()) break;
        }
    }
    reset_stack();
    if (bodyexpr) {
        push_stack(*bodyexpr);
        delete bodyexpr;
    } else
        push_stack(ComValue::nullval());
}
Пример #2
0
void IfThenElseFunc::execute() {
    ComValue booltest(stack_arg_post_eval(0));
    static int then_symid = symbol_add("then");
    static int else_symid = symbol_add("else");
    ComValue retval(booltest.is_true()
                    ? stack_key_post_eval(then_symid)
                    : stack_key_post_eval(else_symid));
    reset_stack();
    push_stack(retval);
}
Пример #3
0
void ForFunc::execute() {
    static int body_symid = symbol_add("body");
    ComValue initexpr(stack_arg_post_eval(0));
    ComValue* bodyexpr = nil;
    while (1) {
        ComValue whileexpr(stack_arg_post_eval(1));
        if (whileexpr.is_false()) break;
        delete bodyexpr;
        ComValue keybody(stack_key_post_eval(body_symid, false, ComValue::unkval(), true));
        if (keybody.is_unknown() && nargsfixed()>= 4)
            bodyexpr = new ComValue(stack_arg_post_eval(3));
        else
            bodyexpr = new ComValue(keybody);
        ComValue nextexpr(stack_arg_post_eval(2));
    }
    reset_stack();
    if (bodyexpr) {
        push_stack(*bodyexpr);
        delete bodyexpr;
    } else
        push_stack(ComValue::nullval());
}
Пример #4
0
void GrStreamFunc::execute() {
  ComValue convertv(stack_arg_post_eval(0));
  
  if (convertv.object_compview()) {
    reset_stack();
    
    static StreamNextFunc* snfunc = nil;
    if (!snfunc) {
      snfunc = new StreamNextFunc(comterp());
      snfunc->funcid(symbol_add("stream"));
    }

    AttributeValueList* avl = new AttributeValueList();
    Component* comp = ((ComponentView*)convertv.obj_val())->GetSubject();
    if (!comp->IsA(OVERLAYS_COMP)) {
      push_stack(ComValue::nullval());
      return;
    }
    OverlaysComp* ovcomps = (OverlaysComp*)comp;
    Iterator it;
    for(ovcomps->First(it); !ovcomps->Done(it); ovcomps->Next(it)) {
      OverlayComp* subcomp = (OverlayComp*) ovcomps->GetComp(it);
      AttributeValue* av = 
        new AttributeValue(new OverlayViewRef(subcomp), subcomp->classid());
      avl->Append(av);
    }
    ComValue stream(snfunc, avl);
    stream.stream_mode(-1); // for internal use (use by this func)
    push_stack(stream);
    
  } else {
    
    StreamFunc strmfunc(comterp());
    strmfunc.exec(funcstate()->nargs(), funcstate()->nkeys(), pedepth());
    return;
    
  }
  
}
Пример #5
0
void PostEvalFunc::execute() {
    // evaluate every fixed argument on the stack and return in array
    int numargs = nargstotal();
    if (numargs) {
        AttributeValueList* avl = nil;
        for (int i=0; i<numargs; i++) {
            ComValue* val = new ComValue(stack_arg_post_eval(i));
            if (val->is_nil()) {
                delete val;
                break;
            }
            if (!avl) avl = new AttributeValueList();
            avl->Append(val);
        }
        reset_stack();
        if (avl) {
            ComValue retval(avl);
            push_stack(retval);
        }
    } else
        reset_stack();
}
Пример #6
0
void SeqFunc::execute() {
    ComValue arg1(stack_arg_post_eval(0, true));
    ComValue arg2(stack_arg_post_eval(1, true));
    reset_stack();
    push_stack(arg2);
}