// IPE: Provide the name of the symbol/variable being defined const char* DefExpr::name() const { const char* retval = 0; if (isLcnSymbol(sym) == true || isTypeSymbol(sym) == true || isFnSymbol(sym) == true || isModuleSymbol(sym) == true) { retval = sym->name; } return retval; }
void AstDumpToHtml::exitDefExpr(DefExpr* node) { if (isFnSymbol(node->sym) || (isTypeSymbol(node->sym) && isAggregateType(node->sym->type))) { fprintf(mFP, "</UL>\n"); if (FnSymbol* fn = toFnSymbol(node->sym)) { fprintf(mFP, "<CHPLTAG=\"FN%d\">\n", fn->id); } fprintf(mFP, "</UL>\n"); } if (isBlockStmt(node->parentExpr)) { fprintf(mFP, "</DL>\n"); } }
void AstDumpToHtml::writeSymbol(Symbol* sym, bool def) { if (def) { fprintf(mFP, "<A NAME=\"SYM%d\">", sym->id); } else if (sym->defPoint && sym->defPoint->parentSymbol && sym->defPoint->getModule()) { INT_ASSERT(hasHref(sym)); fprintf(mFP, "<A HREF=\"%s#SYM%d\">", html_file_name(sPassIndex, sym->defPoint->getModule()->name), sym->id); } else { INT_ASSERT(!hasHref(sym)); fprintf(mFP, "<A>"); } if (isFnSymbol(sym)) { fprintf(mFP, "<FONT COLOR=\"blue\">"); } else if (isTypeSymbol(sym)) { fprintf(mFP, "<FONT COLOR=\"green\">"); } else { fprintf(mFP, "<FONT COLOR=\"red\">"); } fprintf(mFP, "%s", sym->name); fprintf(mFP, "</FONT>"); fprintf(mFP, "<FONT COLOR=\"grey\">[%d]</FONT>", sym->id); fprintf(mFP, "</A>"); if (def && !toTypeSymbol(sym) && sym->type && sym->type->symbol && sym->type != dtUnknown) { fprintf(mFP, ":"); writeSymbol(sym->type->symbol, false); } }
void VarSymbol::codegenDefC(bool global, bool isHeader) { GenInfo* info = gGenInfo; if (this->hasFlag(FLAG_EXTERN)) return; if (type == dtVoid) return; AggregateType* ct = toAggregateType(type); QualifiedType qt = qualType(); if (qt.isRef() && !qt.isRefType()) { Type* refType = getOrMakeRefTypeDuringCodegen(type); ct = toAggregateType(refType); } if (qt.isWideRef() && !qt.isWideRefType()) { Type* refType = getOrMakeRefTypeDuringCodegen(type); Type* wideType = getOrMakeWideTypeDuringCodegen(refType); ct = toAggregateType(wideType); } Type* useType = type; if (ct) useType = ct; std::string typestr = (this->hasFlag(FLAG_SUPER_CLASS) ? std::string(toAggregateType(useType)->classStructName(true)) : useType->codegen().c); // // a variable can be codegen'd as static if it is global and neither // exported nor external. // std::string str; if(fIncrementalCompilation) { bool addExtern = global && isHeader; str = (addExtern ? "extern " : "") + typestr + " " + cname; } else { bool isStatic = global && !hasFlag(FLAG_EXPORT) && !hasFlag(FLAG_EXTERN); str = (isStatic ? "static " : "") + typestr + " " + cname; } if (ct) { if (ct->isClass()) { if (isFnSymbol(defPoint->parentSymbol)) { str += " = NULL"; } } else if (ct->symbol->hasFlag(FLAG_WIDE_REF) || ct->symbol->hasFlag(FLAG_WIDE_CLASS)) { if (isFnSymbol(defPoint->parentSymbol)) { if (widePointersStruct) { // // CHPL_LOCALEID_T_INIT is #defined in the chpl-locale-model.h // file in the runtime, for the selected locale model. // str += " = {CHPL_LOCALEID_T_INIT, NULL}"; } else { str += " = ((wide_ptr_t) NULL)"; } } } } if (fGenIDS) str = idCommentTemp(this) + str; if (printCppLineno && !isHeader && !isTypeSymbol(defPoint->parentSymbol)) str = zlineToString(this) + str; info->cLocalDecls.push_back(str); }
// // DefExpr // bool AstDumpToHtml::enterDefExpr(DefExpr* node) { bool retval = true; if (isBlockStmt(node->parentExpr)) { fprintf(mFP, "<DL>\n"); } fprintf(mFP, " "); if (FnSymbol* fn = toFnSymbol(node->sym)) { fprintf(mFP, "<UL CLASS =\"mktree\">\n<LI>"); adjacent_passes(fn); fprintf(mFP, "<CHPLTAG=\"FN%d\">\n", fn->id); fprintf(mFP, "<B>function "); writeFnSymbol(fn); fprintf(mFP, "</B><UL>\n"); } else if (isTypeSymbol(node->sym)) { if (toAggregateType(node->sym->type)) { fprintf(mFP, "<UL CLASS =\"mktree\">\n"); fprintf(mFP, "<LI>"); if (node->sym->hasFlag(FLAG_SYNC)) fprintf(mFP, "<B>sync</B> "); if (node->sym->hasFlag(FLAG_SINGLE)) fprintf(mFP, "<B>single</B> "); fprintf(mFP, "<B>type "); writeSymbol(node->sym, true); fprintf(mFP, "</B><UL>\n"); } else { fprintf(mFP, "<B>type </B> "); writeSymbol(node->sym, true); } } else if (VarSymbol* vs = toVarSymbol(node->sym)) { if (vs->type->symbol->hasFlag(FLAG_SYNC)) fprintf(mFP, "<B>sync </B>"); if (vs->type->symbol->hasFlag(FLAG_SINGLE)) fprintf(mFP, "<B>single </B>"); fprintf(mFP, "<B>var </B> "); writeSymbol(node->sym, true); } else if (ArgSymbol* s = toArgSymbol(node->sym)) { switch (s->intent) { case INTENT_IN: fprintf(mFP, "<B>in</B> "); break; case INTENT_INOUT: fprintf(mFP, "<B>inout</B> "); break; case INTENT_OUT: fprintf(mFP, "<B>out</B> "); break; case INTENT_CONST: fprintf(mFP, "<B>const</B> "); break; case INTENT_CONST_IN: fprintf(mFP, "<B>const in</B> "); break; case INTENT_CONST_REF: fprintf(mFP, "<B>const ref</B> "); break; case INTENT_REF: fprintf(mFP, "<B>ref</B> "); break; case INTENT_PARAM: fprintf(mFP, "<B>param</B> "); break; case INTENT_TYPE: fprintf(mFP, "<B>type</B> "); break; case INTENT_BLANK: break; } fprintf(mFP, "<B>arg</B> "); writeSymbol(node->sym, true); } else if (isLabelSymbol(node->sym)) { fprintf(mFP, "<B>label</B> "); writeSymbol(node->sym, true); } else if (isModuleSymbol(node->sym)) { fprintf(mFP, "</DL>\n"); // Don't process nested modules -- they'll be handled at the top-level retval = false; } else { fprintf(mFP, "<B>def</B> "); writeSymbol(node->sym, true); } return retval; }