void SICompiler::initialize() { assert(theSIC == NULL, "shouldn't have but one compiler at a time"); theSIC = lastSIC = this; theAssembler = new Assembler(SICInstructionsSize, SICInstructionsSize / 2, PrintSICCompiledCode, true); stackLocCount = argCount = 0; countID = 0; nodeGen = new NodeGen(L, send_desc, diLink); topScope = NULL; splitSig = NULL; bbIterator = new BBIterator; /* theAllocator = */ new SICAllocator(); if (theRecompilation && theRecompilation->recompileeVScopes) { vscopes = theRecompilation->recompileeVScopes; } else { vscopes = NULL; } if (baseLookupType(L->lookupType()) == NormalBaseLookupType) { // ignore the receiver static bit (same nmethod covers both cases) L->clearReceiverStatic(); } dispatchToCode(); SScope::currentScopeID = 0; ncodes = 0; rec = new ScopeDescRecorder(SICScopesSize, SICPCsSize); initTopScope(); initLimits(); initializeForPlatform(); }
MaHttp *maCreateHttp(MprCtx ctx) { MaHttp *http; http = mprAllocObjWithDestructorZeroed(ctx, MaHttp, httpDestructor); if (http == 0) { return 0; } mprGetMpr(ctx)->appwebHttpService = http; http->servers = mprCreateList(http); http->stages = mprCreateHash(http, 0); #if BLD_FEATURE_MULTITHREAD http->mutex = mprCreateLock(http); #endif initLimits(http); #if BLD_UNIX_LIKE { struct passwd *pp; struct group *gp; http->uid = getuid(); if ((pp = getpwuid(http->uid)) == 0) { mprError(http, "Can't read user credentials: %d. Check your /etc/passwd file.", http->uid); } else { http->username = mprStrdup(http, pp->pw_name); } http->gid = getgid(); if ((gp = getgrgid(http->gid)) == 0) { mprError(http, "Can't read group credentials: %d. Check your /etc/group file", http->gid); } else { http->groupname = mprStrdup(http, gp->gr_name); } } #else http->uid = http->gid = -1; #endif #if BLD_FEATURE_SEND maOpenSendConnector(http); #endif #if BLD_FEATURE_NET maOpenNetConnector(http); #endif maOpenPassHandler(http); return http; }
void Compiler::initialize(RScope* remote_scope) { //assert(VMProcess::vm_operation() != NULL, "must be in vmProcess to compile"); if (VMProcess::vm_operation() == NULL) warning("should be in vmProcess to compile"); //softened to a warning to support testing nofCompilations++; #ifdef DEBUG messages = new stringStream(250 * K); #endif if (remote_scope) { _uses_inlining_database = true; recompileeRScope = remote_scope; } else { _uses_inlining_database = false; } recompileeRScope = remote_scope; assert(theCompiler == NULL, "shouldn't have but one compiler at a time"); assert(theMacroAssm == NULL, "shouldn't have an assembler yet"); PReg::initPRegs(); // must come early (before any PReg allocation) initNodes(); // same here (before creating nodes) initLimits(); theCompiler = lastCompiler = this; _code = new CodeBuffer(CompilerInstrsSize, CompilerInstrsSize / 2); countID = -1; topScope = NULL; bbIterator = new BBIterator; /* theAllocator = */ new RegisterAllocator(); assert(method, "must have method"); Scope::initialize(); _totalNofBytes = 0; _special_handler_call_offset = -1; _entry_point_offset = -1; _verified_entry_point_offset = -1; _totalNofFloatTemporaries = -1; _float_section_size = 0; _float_section_start_offset = 0; rec = new ScopeDescRecorder(CompilerScopesSize, CompilerPCsSize); // Save dependency information in the scopeDesc recorder. rec->add_dependant(key); nlrTestPoints = new GrowableArray<NLRTestNode*>(50); contextList = NULL; scopes = new GrowableArray<InlinedScope*>(50); blockClosures = new GrowableArray<BlockPReg*>(50); firstNode = NULL; reporter = new PerformanceDebugger(this); initTopScope(); }
void StereotrodePlot::initAxes(){ initLimits(); int minX = BaseUIElement::xpos; int minY = BaseUIElement::ypos; double axesWidth = BaseUIElement::width/2; double axesHeight = BaseUIElement::height; wAxes[0] = WaveAxes(minX, minY, axesWidth/2, axesHeight, WAVE1); wAxes[1] = WaveAxes(minX + axesWidth/2, minY, axesWidth/2, axesHeight, WAVE2); pAxes = ProjectionAxes(minX + axesWidth, minY, axesWidth, axesHeight, PROJ1x2); wAxes[0].setWaveformColor(1.0, 1.0, 1.0); wAxes[1].setWaveformColor(1.0, 1.0, 1.0); pAxes.setPointColor(1.0, 1.0, 1.0); setLimitsOnAxes(); }
QString KicadSchematic2Svg::convert(const QString & filename, const QString & defName) { initLimits(); QFile file(filename); if (!file.open(QFile::ReadOnly)) { throw QObject::tr("unable to open %1").arg(filename); } QTextStream textStream(&file); QString metadata = makeMetadata(filename, "schematic part", defName); metadata += endMetadata(); QString reference; int textOffset = 0; bool drawPinNumber = true; bool drawPinName = true; bool gotDef = false; while (true) { QString line = textStream.readLine(); if (line.isNull()) { break; } if (line.startsWith("DEF") && line.contains(defName, Qt::CaseInsensitive)) { QStringList defs = splitLine(line); if (defs.count() < 8) { throw QObject::tr("bad schematic definition %1").arg(filename); } reference = defs[2]; textOffset = defs[4].toInt(); drawPinName = defs[6] == "Y"; drawPinNumber = defs[5] == "Y"; gotDef = true; break; } } if (!gotDef) { throw QObject::tr("schematic part %1 not found in %2").arg(defName).arg(filename); } QString contents = "<g id='schematic'>\n"; bool inFPLIST = false; while (true) { QString fline = textStream.readLine(); if (fline.isNull()) { throw QObject::tr("schematic %1 unexpectedly ends (1) in %2").arg(defName).arg(filename); } if (fline.contains("ENDDEF")) { throw QObject::tr("schematic %1 unexpectedly ends (2) in %2").arg(defName).arg(filename); } if (fline.startsWith("DRAW")) { break; } if (fline.startsWith("ALIAS")) continue; if (fline.startsWith("F")) { contents += convertField(fline); continue; } if (fline.startsWith("$FPLIST")) { inFPLIST = true; break; } } while (inFPLIST) { QString fline = textStream.readLine(); if (fline.isNull()) { throw QObject::tr("schematic %1 unexpectedly ends (1) in %2").arg(defName).arg(filename); } if (fline.startsWith("$ENDFPLIST")) { inFPLIST = false; break; } if (fline.contains("ENDDEF")) { throw QObject::tr("schematic %1 unexpectedly ends (2) in %2").arg(defName).arg(filename); } } int pinIndex = 0; while (true) { QString line = textStream.readLine(); if (line.isNull()) { throw QObject::tr("schematic %1 unexpectedly ends (3) in %2").arg(defName).arg(filename); } if (line.startsWith("DRAW")) { continue; } if (line.contains("ENDDEF")) { break; } if (line.contains("ENDDRAW")) { break; } if (line.startsWith("S")) { contents += convertRect(line); } else if (line.startsWith("X")) { // need to look at them all before formatting (I think) contents += convertPin(line, textOffset, drawPinName, drawPinNumber, pinIndex++); } else if (line.startsWith("C")) { contents += convertCircle(line); } else if (line.startsWith("P")) { contents += convertPoly(line); } else if (line.startsWith("A")) { contents += convertArc(line); } else if (line.startsWith("T")) { contents += convertText(line); } else { DebugDialog::debug("Unknown line " + line); } } contents += "</g>\n"; QString svg = TextUtils::makeSVGHeader(GraphicsUtils::StandardFritzingDPI, GraphicsUtils::StandardFritzingDPI, m_maxX - m_minX, m_maxY - m_minY) + m_title + m_description + metadata + offsetMin(contents) + "</svg>"; return svg; }
QString KicadModule2Svg::convert(const QString & filename, const QString & moduleName, bool allowPadsAndPins) { m_nonConnectorNumber = 0; initLimits(); QFile file(filename); if (!file.open(QFile::ReadOnly)) { throw QObject::tr("unable to open %1").arg(filename); } QString text; QTextStream textStream(&file); QString metadata = makeMetadata(filename, "module", moduleName); bool gotModule = false; while (true) { QString line = textStream.readLine(); if (line.isNull()) { break; } if (line.contains("$MODULE") && line.contains(moduleName, Qt::CaseInsensitive)) { gotModule = true; break; } } if (!gotModule) { throw QObject::tr("footprint %1 not found in %2").arg(moduleName).arg(filename); } bool gotT0; QString line; while (true) { line = textStream.readLine(); if (line.isNull()) { throw QObject::tr("unexpected end of file in footprint %1 in file %2").arg(moduleName).arg(filename); } if (line.startsWith("T0") || line.startsWith("DS") || line.startsWith("DA") || line.startsWith("DC")) { gotT0 = true; break; } else if (line.startsWith("Cd")) { metadata += m_comment.arg(TextUtils::stripNonValidXMLCharacters(TextUtils::escapeAnd(line.remove(0,3)))); } else if (line.startsWith("Kw")) { QStringList keywords = line.split(" "); for (int i = 1; i < keywords.count(); i++) { metadata += m_attribute.arg("keyword").arg(TextUtils::stripNonValidXMLCharacters(TextUtils::escapeAnd(keywords[i]))); } } } metadata += endMetadata(); if (!gotT0) { throw QObject::tr("unexpected format (1) in %1 from %2").arg(moduleName).arg(filename); } while (line.startsWith("T")) { line = textStream.readLine(); if (line.isNull()) { throw QObject::tr("unexpected end of file in footprint %1 in file %2").arg(moduleName).arg(filename); } } bool done = false; QString copper0; QString copper1; QString silkscreen0; QString silkscreen1; while (true) { if (line.startsWith("$PAD")) break; if (line.startsWith("$EndMODULE")) { done = true; break; } int layer = 0; QString svgElement; if (line.startsWith("DS")) { layer = drawDSegment(line, svgElement); } else if (line.startsWith("DA")) { layer = drawDArc(line, svgElement); } else if (line.startsWith("DC")) { layer = drawDCircle(line, svgElement); } switch (layer) { case KicadSilkscreenTop: silkscreen1 += svgElement; break; case KicadSilkscreenBottom: silkscreen0 += svgElement; break; default: break; } line = textStream.readLine(); if (line.isNull()) { throw QObject::tr("unexpected end of file in footprint %1 in file %2").arg(moduleName).arg(filename); } } if (!done) { QList<int> numbers; for (int i = 0; i < 512; i++) { numbers << i; } int pads = 0; int pins = 0; while (!done) { try { QString pad; PadLayer padLayer = convertPad(textStream, pad, numbers); switch (padLayer) { case ToCopper0: copper0 += pad; pins++; break; case ToCopper1: copper1 += pad; pads++; break; default: break; } } catch (const QString & msg) { DebugDialog::debug(QString("kicad pad %1 conversion failed in %2: %3").arg(moduleName).arg(filename).arg(msg)); } while (true) { line = textStream.readLine(); if (line.isNull()) { throw QObject::tr("unexpected end of file in footprint %1 in file %2").arg(moduleName).arg(filename); } if (line.contains("$SHAPE3D")) { done = true; break; } if (line.contains("$EndMODULE")) { done = true; break; } if (line.contains("$PAD")) { break; } } } if (!allowPadsAndPins && pins > 0 && pads > 0) { throw QObject::tr("Sorry, Fritzing can't yet handle both pins and pads together (in %1 in %2)").arg(moduleName).arg(filename); } } if (!copper0.isEmpty()) { copper0 = offsetMin("\n<g id='copper0'><g id='copper1'>" + copper0 + "</g></g>\n"); } if (!copper1.isEmpty()) { copper1 = offsetMin("\n<g id='copper1'>" + copper1 + "</g>\n"); } if (!silkscreen1.isEmpty()) { silkscreen1 = offsetMin("\n<g id='silkscreen'>" + silkscreen1 + "</g>\n"); } if (!silkscreen0.isEmpty()) { silkscreen0 = offsetMin("\n<g id='silkscreen0'>" + silkscreen0 + "</g>\n"); } QString svg = TextUtils::makeSVGHeader(10000, 10000, m_maxX - m_minX, m_maxY - m_minY) + m_title + m_description + metadata + copper0 + copper1 + silkscreen0 + silkscreen1 + "</svg>"; return svg; }