void Tree::traverse(Visitor& visitor) { for (definitionIter = globalDefinitions.begin(); definitionIter != globalDefinitions.end(); definitionIter++) { auto definition = *definitionIter; unsigned int traverseMask = visitor.getTraverseMask(); switch (definition->getKind()) { case Definition::Class: if (traverseMask & Visitor::TraverseClasses) { definition->traverse(visitor); } break; case Definition::Member: if (traverseMask & Visitor::TraverseMethods) { definition->traverse(visitor); } break; default: break; } } }
void MtxLP::addStoich(stomap* sto, double lb, double ub, string name){ name = newColName(name); int len = sto->size(); int* ind = new int[len + 1]; double* val = new double[len + 1]; int j = addCol(name, lb, ub); int i = 1; for (stomap::iterator it = sto->begin(); it != sto->end(); ++it){ string row = it->first; int n = nrow(row); if (n == 0) n = addRow(row); ind[i] = n; val[i] = it->second; i++; } set_mat_col(j, len, ind, val); delete [] ind; delete [] val; if (getKind() == MILP) attachIntVar(name); }
ZVaa3dMarker ZDvidSynapse::toVaa3dMarker(double radius) const { ZVaa3dMarker marker; marker.setCenter( getPosition().getX(), getPosition().getY(), getPosition().getZ()); if (getKind() == EKind::KIND_PRE_SYN) { marker.setColor(255, 255, 0); marker.setType(1); } else { marker.setColor(128, 128, 128); marker.setType(2); } std::ostringstream commentStream; commentStream << getBodyId(); marker.setName(commentStream.str()); marker.setRadius(radius); return marker; }
PlanIter_t op_node_sort_distinct_base::codegen( CompilerCB* /*cb*/, static_context* sctx, const QueryLoc& loc, std::vector<PlanIter_t>& argv, expr& ann) const { const bool* myActions = action(); bool sort = (myActions[SORT_ASC] || myActions[SORT_DESC]); bool distinct = myActions[DISTINCT]; bool noa = myActions[NOA]; if (! sort) { if (distinct) { bool check = (getKind() == FunctionConsts::OP_CHECK_DISTINCT_NODES_1); return new NodeDistinctIterator(sctx, loc, argv[0], noa, check); } else if (noa) { return new EitherNodesOrAtomicsIterator(sctx, loc, argv); } else { return argv[0]; } } else { return new NodeSortIterator(sctx, loc, argv[0], myActions[SORT_ASC], distinct, noa); } }
MojErr MojDbKindEngine::find(const MojDbQuery& query, MojDbCursor& cursor, MojDbWatcher* watcher, MojDbReq& req, MojDbOp op) { MojAssert(isOpen()); MojLogTrace(s_log); MojErr err = query.validate(); MojErrCheck(err); // In order to find collate index, cursor needs kindEngine cursor.kindEngine(this); err = cursor.init(query); MojErrCheck(err); MojDbKind* kind = NULL; err = getKind(query.from().data(), kind); MojErrCheck(err); MojAssert(kind); err = kind->find(cursor, watcher, req, op); MojErrCheck(err); cursor.kindEngine(this); return MojErrNone; }
void CElement::dumpContent(string& strContent, CErrorContext& errorContext, const uint32_t uiDepth) const { string strIndent; // Level uint32_t uiNbIndents = uiDepth; while (uiNbIndents--) { strIndent += " "; } // Type strContent += strIndent + "- " + getKind(); // Name if (!_strName.empty()) { strContent += ": " + getName(); } // Value string strValue; logValue(strValue, errorContext); if (!strValue.empty()) { strContent += " = " + strValue; } strContent += "\n"; uint32_t uiIndex; for (uiIndex = 0; uiIndex < _childArray.size(); uiIndex++) { _childArray[uiIndex]->dumpContent(strContent, errorContext, uiDepth + 1); } }
void NodeValue::printAst(std::ostream& out, int ind) const { RefCountGuard guard(this); indent(out, ind); out << '('; out << getKind(); if(getMetaKind() == kind::metakind::VARIABLE) { out << ' ' << getId(); } else if(getMetaKind() == kind::metakind::CONSTANT) { out << ' '; kind::metakind::NodeValueConstPrinter::toStream(out, this); } else { if(nv_begin() != nv_end()) { for(const_nv_iterator child = nv_begin(); child != nv_end(); ++child) { out << std::endl; (*child)->printAst(out, ind + 1); } out << std::endl; indent(out, ind); } } out << ')'; }
void c_WaitableWaitHandle::enterContextImpl(context_idx_t ctx_idx) { switch (getKind()) { case Kind::Static: not_reached(); case Kind::AsyncFunction: return asAsyncFunction()->enterContextImpl(ctx_idx); case Kind::AsyncGenerator: return asAsyncGenerator()->enterContextImpl(ctx_idx); case Kind::GenArray: return asGenArray()->enterContextImpl(ctx_idx); case Kind::GenMap: return asGenMap()->enterContextImpl(ctx_idx); case Kind::GenVector: return asGenVector()->enterContextImpl(ctx_idx); case Kind::Reschedule: return asReschedule()->enterContextImpl(ctx_idx); case Kind::Sleep: return asSleep()->enterContextImpl(ctx_idx); case Kind::ExternalThreadEvent: return asExternalThreadEvent()->enterContextImpl(ctx_idx); } not_reached(); }
c_WaitableWaitHandle* c_WaitableWaitHandle::getChild() { assert(!isFinished()); switch (getKind()) { case Kind::Static: not_reached(); case Kind::AsyncFunction: return static_cast<c_AsyncFunctionWaitHandle*>(this)->getChild(); case Kind::GenArray: return static_cast<c_GenArrayWaitHandle*>(this)->getChild(); case Kind::GenMap: return static_cast<c_GenMapWaitHandle*>(this)->getChild(); case Kind::GenVector: return static_cast<c_GenVectorWaitHandle*>(this)->getChild(); case Kind::SetResultToRef: return static_cast<c_SetResultToRefWaitHandle*>(this)->getChild(); case Kind::Reschedule: case Kind::Sleep: case Kind::ExternalThreadEvent: return nullptr; } not_reached(); }
String c_WaitableWaitHandle::getName() { switch (getKind()) { case Kind::Static: not_reached(); case Kind::AsyncFunction: return static_cast<c_AsyncFunctionWaitHandle*>(this)->getName(); case Kind::GenArray: return static_cast<c_GenArrayWaitHandle*>(this)->getName(); case Kind::GenMap: return static_cast<c_GenMapWaitHandle*>(this)->getName(); case Kind::GenVector: return static_cast<c_GenVectorWaitHandle*>(this)->getName(); case Kind::SetResultToRef: return static_cast<c_SetResultToRefWaitHandle*>(this)->getName(); case Kind::Reschedule: return static_cast<c_RescheduleWaitHandle*>(this)->getName(); case Kind::Sleep: return static_cast<c_SleepWaitHandle*>(this)->getName(); case Kind::ExternalThreadEvent: return static_cast<c_ExternalThreadEventWaitHandle*>(this)->getName(); } not_reached(); }
bool FVisitor::VisitVarTemplateDecl(clang::VarTemplateDecl* Declaration) { for (auto Spec : Declaration->specializations()) { const auto& TemplateArguments = Spec->getTemplateArgs(); for (int32 Index = 0, Size = TemplateArguments.size(); Index < Size; ++Index) { auto Argument = TemplateArguments.get(Index); if (Argument.getKind() == clang::TemplateArgument::ArgKind::Type) { if (auto TypePtr = Argument.getAsType().getTypePtr()) { if (auto RecordDecl = TypePtr->getAsCXXRecordDecl()) { ParseUsageOfDecl(RecordDecl, Declaration->getLocStart()); } } } } } return true; }
bool Cursor::isTranslationUnit() const { return clang().isTranslationUnit(getKind()); }
bool Cursor::isInvalid() const { return clang().isInvalid(getKind()); }
bool Cursor::isAttribute() const { return clang().isAttribute(getKind()); }
bool Cursor::isStatement() const { return clang().isStatement(getKind()); }
bool Cursor::isExpression() const { return clang().isExpression(getKind()); }
static void findTag (tokenInfo *const token) { if (currentContext->kind != K_UNDEFINED) { /* Drop context, but only if an end token is found */ dropContext (token); } if (token->kind == K_CONSTANT && vStringItem (token->name, 0) == '`') { /* Bug #961001: Verilog compiler directives are line-based. */ int c = skipWhite (vGetc ()); readIdentifier (token, c); createTag (token); /* Skip the rest of the line. */ do { c = vGetc(); } while (c != EOF && c != '\n'); vUngetc (c); } else if (token->kind == K_BLOCK) { /* Process begin..end blocks */ processBlock (token); } else if (token->kind == K_FUNCTION || token->kind == K_TASK) { /* Functions are treated differently because they may also include the * type of the return value. * Tasks are treated in the same way, although not having a return * value.*/ processFunction (token); } else if (token->kind == K_ASSERTION) { if (vStringLength (currentContext->blockName) > 0) { vStringCopy (token->name, currentContext->blockName); createTag (token); skipToSemiColon (); } } else if (token->kind == K_TYPEDEF) { processTypedef (token); } else if (token->kind == K_CLASS) { processClass (token); } else if (token->kind == K_IGNORE && isSingleStatement (token)) { currentContext->singleStat = TRUE; } else if (isVariable (token)) { int c = skipWhite (vGetc ()); tagNameList (token, c); } else if (token->kind != K_UNDEFINED && token->kind != K_IGNORE) { int c = skipWhite (vGetc ()); if (isIdentifierCharacter (c)) { readIdentifier (token, c); while (getKind (token) == K_IGNORE) { c = skipWhite (vGetc ()); readIdentifier (token, c); } createTag (token); /* Get port list if required */ c = skipWhite (vGetc ()); if (c == '(' && hasSimplePortList (token)) { processPortList (c); } else { vUngetc (c); } } } }
/** * Style needed */ void FbEditor::onStyleNeeded(wxStyledTextEvent & event) { // startint position auto startPos = GetEndStyled(); auto startLine = LineFromPosition(startPos); startPos = PositionFromLine(startLine); // end position int lastPos = event.GetPosition(); int lastLine = std::max(LineFromPosition(lastPos), std::min(GetLineCount(), GetFirstVisibleLine() + LinesOnScreen())); lastPos = GetLineEndPosition(lastLine); // get token auto token = m_srcCtx->getLine(startLine, lastLine); // set stylling position StartStyling(startPos, INT_MAX); // clear indicatirs SetIndicatorCurrent(ErrorIndicator); IndicatorClearRange(startPos, lastPos - startPos); // no token? just colour to default if (!token) { style(lastPos - startPos, TokenStyle::Default); return; } // style the tokens int line = startLine; int col = 0; while (token && line <= lastLine) { // end of the line? if (token->getKind() == TokenKind::EndOfLine) { token = token->getNext(); continue; } // token line int tline = token->getLine(); // token started before current line if (line > tline) { int start = PositionFromLine(line); int end = PositionFromLine(token->getEndLine()) + token->getEndCol(); style(end - start, token); // end on line and column col = token->getEndCol(); line = token->getEndLine(); // get next token and continue token = token->getNext(); continue; } // empty lines before next token? if (line < tline) { int start = PositionFromLine(line) + col; int end = PositionFromLine(tline) + token->getCol(); style(end - start, TokenStyle::Default); // end on line and column line = token->getLine(); col = token->getCol(); continue; } // started on the current line if (line == tline) { // empty space ? if (token->getCol() > col) { style(token->getCol() - col, TokenStyle::Default); } // style the token style(token->getLength(), token); col = token->getEndCol(); line = token->getEndLine(); // advance to the next one token = token->getNext(); continue; } // some empty space till end of the line int length = GetLineLength(line); if (col < length) { style(length - col, TokenStyle::Default); } // incement line line++; col = 0; } }
GameObject *GameLevel::getHero() { auto hero = getObjectManager()->getObjectByID(0); CC_ASSERT(hero && hero->getKind() == KIND_HERO); return hero; }
CombatType_t MagicField::getCombatType() const { return getKind()->combatType; }
bool MagicField::isReplaceable() const {return getKind()->replaceable;}
bool Cursor::isPreprocessing() const { return clang().isPreprocessing(getKind()); }
bool Cursor::isUnexposed() const { return clang().isUnexposed(getKind()); }
static void updateKind (tokenInfo *const token) { token->kind = getKind (token); }
bool Cursor::isReference() const { return clang().isReference(getKind()); }
static void tagNameList (tokenInfo* token, int c) { verilogKind localKind; boolean repeat; /* Many keywords can have bit width. * reg [3:0] net_name; * inout [(`DBUSWIDTH-1):0] databus; */ if (c == '(') c = skipPastMatch ("()"); c = skipWhite (c); if (c == '[') c = skipPastMatch ("[]"); c = skipWhite (c); if (c == '#') { c = vGetc (); if (c == '(') c = skipPastMatch ("()"); } c = skipWhite (c); do { repeat = FALSE; while (c == '`' && c != EOF) { c = skipMacro (c); } if (isIdentifierCharacter (c)) { readIdentifier (token, c); localKind = getKind (token); /* Create tag in case name is not a known kind ... */ if (localKind == K_UNDEFINED) { createTag (token); } /* ... or else continue searching for names */ else { /* Update kind unless it's a port or an ignored keyword */ if (token->kind != K_PORT && localKind != K_IGNORE) { token->kind = localKind; } repeat = TRUE; } } else break; c = skipWhite (vGetc ()); if (c == '[') c = skipPastMatch ("[]"); c = skipWhite (c); if (c == '=') { c = skipWhite (vGetc ()); if (c == '{') skipPastMatch ("{}"); else { /* Skip until end of current name, kind or parameter list definition */ do c = vGetc (); while (c != EOF && c != ',' && c != ';' && c != ')'); } } if (c == ',') { c = skipWhite (vGetc ()); repeat = TRUE; } } while (repeat); vUngetc (c); }
void lsDir(const char* dirName, const char* preDir, int allSet, int inodeSet, int listSet, int recurSet){ //for dir and file list struct dirent** myfile; struct stat mystat; int i, n; int kind; char autho[10]; mode_t mode; struct passwd* pw; struct group* grp; time_t t; time_t t2; struct tm* tms; int inodeLen = 0; int linkLen = 0; int unameLen = 0; int gnameLen = 0; int sizeLen = 0; int filenameLen = 0; char lengBuf[100]; char dirBuf[100]; char cwd[100]; char previousDir[100]; char tempBuf[100]; int newlineCount = 0; getcwd(cwd, sizeof(cwd)); chdir(dirName); n = scandir(".", &myfile, 0, alphasort); if(recurSet){ printf("%s:\n", preDir); } //for padding for(i = 0; i < n; i++){ if ( myfile[i]->d_name[0] == '.' && !allSet){ continue; } stat(myfile[i]->d_name, &mystat); sprintf(lengBuf, "%d", (int)mystat.st_ino); if (inodeLen < (int) strlen(lengBuf)) inodeLen = (int) strlen(lengBuf); sprintf(lengBuf, "%d", (int)mystat.st_nlink); if (linkLen < (int) strlen(lengBuf)) linkLen = (int) strlen(lengBuf); strcpy(lengBuf, getpwuid(mystat.st_uid)->pw_name); if (unameLen < (int) strlen(lengBuf)) unameLen = (int) strlen(lengBuf); strcpy(lengBuf, getgrgid(mystat.st_gid)->gr_name); if (gnameLen < (int) strlen(lengBuf)) gnameLen = (int) strlen(lengBuf); sprintf(lengBuf, "%d", (int)mystat.st_size); if (sizeLen < (int) strlen(lengBuf)) sizeLen = (int) strlen(lengBuf); strcpy(lengBuf, myfile[i]->d_name); if (filenameLen < (int) strlen(lengBuf)) filenameLen = (int) strlen(lengBuf); } if (listSet){ for(i = 0; i < n; i++){ if ( myfile[i]->d_name[0] == '.' && !allSet){ continue; } //stat stat(myfile[i]->d_name, &mystat); //mode mode = mystat.st_mode; //uid, gid pw = getpwuid(mystat.st_uid); grp = getgrgid(mystat.st_gid); //time t = mystat.st_ctime; tms = gmtime(&t); time(&t2); t2 = t2 - t; getAutho(autho, mode); if (inodeSet){ printf("%*d ", inodeLen, (int)mystat.st_ino); } printf("%c%s ", getKind(mode), autho); printf("%*d ", linkLen, (int)mystat.st_nlink); printf("%*s ", unameLen, pw->pw_name); printf("%*s ", gnameLen, grp->gr_name); printf("%*d ", sizeLen, (int)mystat.st_size); if (t2 < 15811200) printf("%02d월 %02d %02d:%02d ", tms->tm_mon, tms->tm_mday, tms->tm_hour, tms->tm_min); else printf("%02d월 %02d %5d ", tms->tm_mon, tms->tm_mday, tms->tm_year + 1900); printf("%s ", myfile[i]->d_name); if (i < n+1) printf("\n"); } } else { for(i = 0; i < n; i++){ if ( myfile[i]->d_name[0] == '.' && !allSet){ continue; } stat(myfile[i]->d_name, &mystat); if (inodeSet){ printf("%*d %-*s ", inodeLen, (int)mystat.st_ino, filenameLen, myfile[i]->d_name); sprintf(tempBuf, "%d", (int)mystat.st_ino); newlineCount += (inodeLen + filenameLen); } else { printf("%-*s ", filenameLen, myfile[i]->d_name); newlineCount += filenameLen; } if ( newlineCount > 80){ printf("\n"); newlineCount = 0; } } printf("\n"); } if (recurSet){ for(i = 0; i < n; i++){ if ( myfile[i]->d_name[0] == '.' && !allSet){ continue; } stat(myfile[i]->d_name, &mystat); mode = mystat.st_mode; if (getKind(mode) == 'd' && !( strcmp(".", myfile[i]->d_name) == 0 || strcmp("..", myfile[i]->d_name) == 0)){ printf("\n"); sprintf(dirBuf, "%s",myfile[i]->d_name); sprintf(previousDir, "%s/%s", preDir, myfile[i]->d_name); lsDir(dirBuf, previousDir, allSet, inodeSet, listSet, recurSet); } } } chdir(cwd); }
void DeclarationNode::declare(SymbolTable* stab) { // BIG TODO std::vector<Symbol*> symList; if (!stab) { error("declare() : SymbolTable pointer supplied is null."); } TypeInfo tInfo = declSpecifier->getTypeInfo(); // std::cout << "InideDeclList.size() : " << initDeclList->declaratorList.size()<< std::endl; // debug InitDeclaratorListNode* list = initDeclList; while( list != 0 ) { Type* t = 0; Symbol* s = 0; SymbolLocation sloc; // seg fault here since some of these are mutually exlusive pointers auto decl = list->initDeclarator->declarationNode; // auto init = initDecl->initNode; auto dirDecl = decl->dirDeclNode; auto dirDeclId = dirDecl->id; // auto ptr = decl->ptrNode; int dKind = dirDecl->getKind(); std::string id; SymbolTableInfo info; Symbol::TACOperandType tacType = ( stab->isGlobalScope() ) ? Symbol::GLOB : Symbol::LOCAL; // TODO SymbolLocation switch(dKind) { case DirectDeclaratorNode::Id: id = dirDecl->id->getId(); info = stab->getSymbolInfo( id , true ); if( info.symbol == 0 ) std::cout << "Symbol Lookup was null" << endl; //This needs to be dynamic t = new BuiltinType( Type::Int ); info.symbol->symbolType = t; info.symbol->operandType = tacType; break; case DirectDeclaratorNode::None: //TODO: fix this ish //t = buildType(tInfo); id = dirDeclId->getId(); info = stab->getSymbolInfo( id , true ); if( info.symbol == 0 ) std::cout << "Symbol Lookup was null" << endl; //This needs to be dynamic t = new BuiltinType( Type::Int ); info.symbol->symbolType = t; info.symbol->operandType = tacType; //s = new Symbol(id, sloc, t); //cout << "declre() : before insertSymbol" << endl; //stab->insertSymbol(s); //cout << "declre() : after insertSymbol" << endl; break; case DirectDeclaratorNode::Array: break; case DirectDeclaratorNode::ArrayWithSize: id = dirDecl->dirDeclNode->id->getId(); info = stab->getSymbolInfo( id , true ); if( info.symbol == 0 ) std::cout << "Symbol Lookup was null" << endl; // TODO Asuming int for now t = new ArrayType( decl->nodeData->value , new BuiltinType( Type::Int ) ); info.symbol->symbolType = t; info.symbol->operandType = tacType; break; case DirectDeclaratorNode::FunctionDefinition: id = dirDecl->dirDeclNode->id->getId(); info = stab->getSymbolInfo( id , true ); if( info.symbol == 0 ) std::cout << "Symbol Lookup was null" << endl; // TODO Asuming int for now t = new FunctionType(); info.symbol->symbolType = t; info.symbol->operandType = tacType; break; case DirectDeclaratorNode::FunctionDefinitionWithParam: break; // TODO: These two should not reduce to declaration node ? case DirectDeclaratorNode::FunctionCall: break; case DirectDeclaratorNode::FunctionCallWithParam: break; } list = list->initDeclaratorList; } }
//Determines if statement is well-formed int statement(char list[][20], int size, char* token, int i) { //Case where statement begins with identifier if (atoi(token) == identsym) { char* name = list[i+1]; i+=2; token = list[i]; int kind = getKind(name); //Identifier must be assigned a value in this case if (atoi(token) != becomessym) { error(4); err = i; err2 = 4; return -1; } i++; token = list[i]; //Determines if identifier will be assigned to well-formed expression i = expression(list, size, token, i); if (i == -1) return -1; token = list[i]; //If identifier is variable, emit intermediate code if(kind == 2) { int level = getLevel(name); level = abs(level - lev); emit(STO, level, getVal(name), i); } else if (kind == 1 || kind == 3) //Cannot assign to constant or procedure { error(14); err = i; err2 = 14; return -1; } else //Cannot assign to identifier not previously declared { error(13); err = i; err2 = 13; return -1; } } else if (atoi(token) == callsym) //Case where statement makes procedure call { i++; token = list[i]; //Call must be followed by a procedure identifier if (atoi(token) != identsym) { error(10); err = i; err2 = 10; return -1; } else { token = list[i+1]; emit(CAL, getLevel(token), getVal(token), i); i+=2; token = list[i]; } } else if (atoi(token) == beginsym) //Case where statement begins procedure { i++; token = list[i]; //Determines if contained statement is well-formed i = statement(list, size, token, i); if (i == -1) return -1; token = list[i]; //Accepts additional statements while(atoi(token) == semicolonsym) { i++; token = list[i]; i = statement(list, size, token, i); if (i == -1) return -1; token = list[i]; if (atoi(token) != semicolonsym && atoi(token) != endsym) { int j = i; j = statement(list, size, token, j); if (j != -1) { error(3); err = i; err2 = 3; return -1; } else { printf("here\n"); break; } } } if (atoi(token) != endsym) //Begin must have end { error(5); err = i; err2 = 5; return -1; } i++; token = list[i]; } else if (atoi(token) == ifsym) //Case where statement begins with if { i++; token = list[i]; //If must be followed by well-formed condition i = condition(list, size, token, i); if (i == -1) return -1; token = list[i]; //Condition must be followed by then if (atoi(token) != thensym) { error(6); err = i; err2 = 6; return -1; } i++; token = list[i]; //Generates jump code for condition int ctemp = cx; emit(JPC, 0, 0, i); //Determines if conditional statement is well-formed i = statement(list, size, token, i); if (i == -1) return -1; token = list[i]; operations[ctemp].m = cx; } else if (atoi(token) == whilesym) //Case where statement begisn with while { int cx1 = cx; i++; token = list[i]; //Determines if while condition is well-formed i = condition(list, size, token, i); if (i == -1) return -1; token = list[i]; //Generates jump code for while loop int cx2 = cx; emit(JPC, 0, 0, i); //Condition must be followed by do if (atoi(token) != dosym) { error(7); err = i; err2 = 7; return -1; } i++; token = list[i]; //While must execute well-formed statement i = statement(list, size, token, i); if (i == -1) return -1; token = list[i]; emit(JMP, 0, cx1, i); operations[cx2].m = cx; } else { //error(16); err = i; err2 = 16; //return -1; } return i; }
bool Cursor::isDeclaration() const { return clang().isDeclaration(getKind()); }