Files

1 line
4.7 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" width="640" height="880" viewBox="0 0 640 880" role="img" aria-labelledby="title desc"><title id="title">CTFE и выполнение программы</title><desc id="desc">Одна функция square используется компилятором для вычисления enum, а с данными пользователя выполняется после запуска программы.</desc><defs><marker id="arrow" markerWidth="9" markerHeight="9" refX="7" refY="4" orient="auto"><path d="M0 0 8 4 0 8" fill="none" stroke="#b64d26" stroke-width="1.6"/></marker><pattern id="hatch" width="9" height="9" patternUnits="userSpaceOnUse"><path d="M-2 2 2-2 M0 9 9 0 M7 11 11 7" stroke="#d8d0c0" stroke-width="2"/></pattern></defs><rect width="640" height="880" rx="4" fill="#fbf8f1"/><g font-family="Arial,Helvetica,sans-serif" fill="#242824"><text x="32" y="44" font-size="20" font-weight="bold" fill="#b64d26" text-anchor="start" font-family="monospace">01 / D</text><text x="32" y="87" font-size="33" font-weight="bold" fill="#242824" text-anchor="start">Когда выполняется функция</text><text x="32" y="122" font-size="24" font-weight="normal" fill="#676961" text-anchor="start">Решает контекст вызова, а не имя функции.</text><path d="M32 148 H608" fill="none" stroke="#d8d0c0" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/><rect x="32" y="176" width="576" height="95" rx="10" fill="white" stroke="#d8d0c0" stroke-width="2"/><text x="54" y="210" font-size="23" font-weight="normal" fill="#676961" text-anchor="start">Одна функция</text><text x="54" y="247" font-size="28" font-weight="normal" fill="#327057" text-anchor="start" font-family="monospace">int square(int x) =&gt; x * x;</text><path d="M320 272 V310 H170 V338" fill="none" stroke="#b64d26" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrow)"/><path d="M320 310 H470 V338" fill="none" stroke="#b64d26" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrow)"/><text x="170" y="380" font-size="22" font-weight="bold" fill="#b64d26" text-anchor="middle">КОМПИЛЯЦИЯ</text><text x="470" y="380" font-size="22" font-weight="bold" fill="#b64d26" text-anchor="middle">ЗАПУСК</text><rect x="32" y="405" width="276" height="120" rx="10" fill="white" stroke="#d8d0c0" stroke-width="2"/><text x="52" y="442" font-size="27" font-weight="normal" fill="#327057" text-anchor="start" font-family="monospace">enum n =</text><text x="52" y="481" font-size="27" font-weight="normal" fill="#327057" text-anchor="start" font-family="monospace">square(3);</text><rect x="332" y="405" width="276" height="120" rx="10" fill="white" stroke="#d8d0c0" stroke-width="2"/><text x="352" y="442" font-size="25" font-weight="normal" fill="#242824" text-anchor="start">Ввод пользователя</text><text x="352" y="481" font-size="25" font-weight="normal" fill="#327057" text-anchor="start" font-family="monospace">square(input)</text><path d="M170 526 V573" fill="none" stroke="#b64d26" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrow)"/><path d="M470 526 V573" fill="none" stroke="#b64d26" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrow)"/><path d="M62 595 H277 L302 650 277 705 H62 L37 650 Z" fill="#efe9dd" stroke="#242824" stroke-width="2"/><text x="170" y="642" font-size="31" font-weight="bold" fill="#242824" text-anchor="middle">CTFE</text><text x="170" y="676" font-size="23" font-weight="normal" fill="#676961" text-anchor="middle">в компиляторе</text><rect x="336" y="596" width="268" height="109" rx="10" fill="#242824" stroke="#242824" stroke-width="2"/><text x="470" y="641" font-size="25" font-weight="normal" fill="#fbf8f1" text-anchor="middle">Машинный код</text><text x="470" y="676" font-size="23" font-weight="normal" fill="#d8d0c0" text-anchor="middle">в процессе</text><path d="M170 706 V751" fill="none" stroke="#b64d26" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrow)"/><path d="M470 706 V751" fill="none" stroke="#b64d26" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrow)"/><text x="170" y="792" font-size="31" font-weight="bold" fill="#242824" text-anchor="middle" font-family="monospace">n = 9</text><text x="470" y="792" font-size="25" font-weight="bold" fill="#242824" text-anchor="middle">Результат ввода</text><text x="32" y="844" font-size="24" font-weight="normal" fill="#676961" text-anchor="start">CTFE: значение нужно ещё до запуска программы.</text></g></svg>