ChannelFrame::ChannelFrame(const QString& name, ChannelConnection *channel, QWidget *parent) : QFrame(parent) { channelName = name; channelConnection = channel; setupUI(); assignSlots(); }
void compileScripts(uint32_t max, Node *table, symtab_t *symbols, symtab_t *block) { uint32_t start = 0; firstNode *fn; while(start < max) { fn = (firstNode *)(table + start); start += fn->moduleSize; hoistSymbols(fn->begin, table, symbols, block); } start = 0; while(start < max) { fn = (firstNode *)(table + start); assignSlots(fn->begin, table, symbols, block); start += fn->moduleSize; } }
void assignSlots(uint32_t slot, Node *table, symtab_t *symbols, symtab_t *block) { while (slot) switch (table[slot].type) { case node_fcndef: case node_fcnexpr: { fcnDeclNode *fd = (fcnDeclNode *)(table + slot); fd->symbols.depth = symbols->depth + 1; assignSlots(fd->body, table, &fd->symbols, block); return; } case node_endlist: case node_list: { listNode *ln; do { ln = (listNode *)(table + slot); assignSlots(ln->elem, table, symbols, block); slot -= sizeof(listNode) / sizeof(Node); } while (ln->hdr->type == node_list); return; } case node_neg: case node_enum: case node_incr: case node_typeof: case node_return: { exprNode *en = (exprNode *)(table + slot); slot = en->expr; continue; } case node_ternary: { ternaryNode *tn = (ternaryNode *)(table + slot); assignSlots(tn->condexpr, table, symbols, block); assignSlots(tn->trueexpr, table, symbols, block); slot = tn->falseexpr; continue; } case node_lor: case node_land: case node_math: case node_access: case node_opassign: case node_assign: { binaryNode *bn = (binaryNode *)(table + slot); assignSlots(bn->left, table, symbols, block); slot = bn->right; continue; } case node_ifthen: { ifThenNode *iftn = (ifThenNode *)(table + slot); assignSlots(iftn->condexpr, table, symbols, block); assignSlots(iftn->thenstmt, table, symbols, block); slot = iftn->elsestmt; continue; } case node_elem: { binaryNode *bn = (binaryNode *)(table + slot); slot = bn->right; continue; } case node_array: { arrayNode *an = (arrayNode *)(table + slot); slot = an->exprlist; continue; } case node_obj: { objNode *on = (objNode *)(table + slot); slot = on->elemlist; continue; } case node_while: case node_dowhile: { whileNode *wn = (whileNode *)(table + slot); assignSlots(wn->cond, table, symbols, block); slot = wn->stmt; continue; } case node_forin: { forInNode *forn = (forInNode*)(table + slot); block = &forn->symbols; // set our baseIdx after parent's frameIdx if (block->parent) block->baseIdx = block->parent->baseIdx + block->parent->frameIdx; else block->baseIdx = symbols->frameIdx; assignSlots(forn->var, table, symbols, block); assignSlots(forn->expr, table, symbols, block); slot = forn->stmt; continue; } case node_for: { forNode *forn = (forNode*)(table + slot); block = &forn->symbols; // set our baseIdx after parent's frameIdx if (block->parent) block->baseIdx = block->parent->baseIdx + block->parent->frameIdx; else block->baseIdx = symbols->frameIdx; assignSlots(forn->init, table, symbols, block); assignSlots(forn->cond, table, symbols, block); assignSlots(forn->incr, table, symbols, block); slot = forn->stmt; continue; } case node_var: { symNode *sym = (symNode *)(table + slot); stringNode *sn = (stringNode *)(table + sym->name); symbol_t *symbol = lookupSymbol(&sn->str, symbols, block); if (!symbol) { firstNode *fn = findFirstNode(table, slot); fprintf(stderr, "%s: Symbol not found: %s line = %d node = %d\n", fn->script, sn->str.val, (int)sym->hdr->lineNo, slot); exit(1); } if (symbol->scoped) sym->hdr->flag |= flag_scope; sym->level = symbols->depth - symbol->depth; sym->frameIdx = symbol->frameIdx; return; } case node_block: { blkEntryNode *be = (blkEntryNode *)(table + slot); // prepare for nested stmt block scope block = &be->symbols; // set our baseIdx after parent's frameIdx if (block->parent) block->baseIdx = block->parent->baseIdx + block->parent->frameIdx; else block->baseIdx = symbols->frameIdx; slot = be->body; continue; } case node_pipe: case node_fcncall: { fcnCallNode *fc = (fcnCallNode *)(table + slot); assignSlots(fc->args, table, symbols, block); symNode *sym = (symNode *)(table + fc->name); if (sym->hdr->type != node_var) { assignSlots(fc->name, table, symbols, block); return; } stringNode *sn = (stringNode *)(table + sym->name); symbol_t *symbol = lookupSymbol(&sn->str, symbols, block); if (symbol) { sym->level = symbols->depth - symbol->depth; sym->frameIdx = symbol->frameIdx; return; } firstNode *fn = findFirstNode(table, slot); fprintf(stderr, "%s: Function not found: %s line = %d node = %d\n", fn->script, sn->str.val, (int)sym->hdr->lineNo, slot); exit(1); } default: if (hoistDebug) fprintf(stderr, "node %d type %d assignment skipped\n", slot, (int)table[slot].type); return; } }