- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
function s(v: any): v is string
{
	return typeof v === "string";
}
function main()
{
	print(s("sss"));
}Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
function s(v: any): v is string
{
	return typeof v === "string";
}
function main()
{
	print(s("sss"));
}А ты так можешь на С/C++ .. а я могу....
0
function test_nest_capture_of_this() {
    let deck = {
        val: 1,
        funcWithCapture: function () {
            return () => {
                return this.val;
            };
        },
    };
    let funcInst = deck.funcWithCapture();
    print(funcInst());
}
function main() {
    test_nest_capture_of_this();
    print("done.");
}
            а вот мой компилятор может так говнокодить ..  а ваш?  (коментов не будет - сайт все блокирует) на этот раз скину дампик 
https://pastebin.com/MXVLGnGM
результат работы
C:\temp\MLIR_to_exe>1.exe
1
done.+1
// https://github.com/j123123/sexpr_parse/blob/584fc23de71bebe02545214f819e16b720a2c1e2/my_struct_utils.c#L119
blob *
blob_scan_fromstream
(
  FILE *stream
)
{
  size_t st_len = 0;
  size_t st_alloc;
  uint8_t *st = NULL;
  while(true)
  {
    const int fg = getc(stream);
    if(fg == EOF)
    {
      PRV_ERR_MACRO();
    }
    uint8_t c = fg;
    if(!isprint(fg))
    {
      PRV_ERR_MACRO();
    }
    switch(c)
    {
      case '\\':
        {
          int c2 = getc(stream);
          switch(c2)
          {
            case 'x':
              {
                int c3[2] =
                {
                  getc(stream),
                  getc(stream)
                };
                uint8_t tmp[2];
                for(size_t i = 0; i < 2; ++i)
                {
                  switch(c3[i])
                  {
                    case '0' ... '9':
                      tmp[i] = c3[i]-'0';
                      break;
                    case 'a' ... 'f':
                      tmp[i] = c3[i]+10-'a';
                      break;
                    case 'A' ... 'F':
                      tmp[i] = c3[i]+10-'A';
                      break;
                    default:
                      PRV_ERR_MACRO();
                  }
                }
                M_PUSH(tmp[1] | tmp[0] << 4);
              }
              break;
            case '\\':
              M_PUSH('\\');
              break;
            case 't':
              M_PUSH('\t');
              break;
            case 'n':
              M_PUSH('\n');
              break;
            case '"':
              M_PUSH('"');
              break;
            default:
              PRV_ERR_MACRO();
          }
        }
        break;
//      case '\t':
//      case '\n':
//        PRV_ERR_MACRO();
//        break;
      case '"':
        goto end;
      default:
        M_PUSH(c);
    }
  }
end:
  ;
  blob *tmp = blob_init(st_len, st);
  PRV_FREE(st);
  return tmp;
}Эта вот хрень вычитывает из "FILE *" одно "слово".
−2
Узнал, что доблестный Робин-гуд был активным гомо, чья пассивная банда резала и жгла натурастов за их "натурастность"..Мой мир никогда не будtт прежним.
0
class RayTracer {
    private maxDepth = 5;
    private intersections(ray: Ray, scene: Scene) {
        let closest = +Infinity;
        let closestInter: Intersection = undefined;
        for (let i in scene.things) {
            let inter = scene.things[i].intersect(ray);
            if (inter != null && inter.dist < closest) {
                closestInter = inter;
                closest = inter.dist;
            }
        }
        return closestInter;
    }
    private testRay(ray: Ray, scene: Scene) {
        let isect = this.intersections(ray, scene);
        if (isect != null) {
            return isect.dist;
        } else {
            return undefined;
        }
    }
    private traceRay(ray: Ray, scene: Scene, depth: number): Color {
        let isect = this.intersections(ray, scene);
        if (isect === undefined) {
            return Color.background;
        } else {
            return this.shade(isect, scene, depth);
        }
    }
    private shade(isect: Intersection, scene: Scene, depth: number) {
        let d = isect.ray.dir;
        let pos = Vector.plus(Vector.times(isect.dist, d), isect.ray.start);
        let normal = isect.thing.normal(pos);
        let reflectDir = Vector.minus(d, Vector.times(2, Vector.times(Vector.dot(normal, d), normal)));
        let naturalColor = Color.plus(Color.background,
            this.getNaturalColor(isect.thing, pos, normal, reflectDir, scene));
        let reflectedColor = (depth >= this.maxDepth) ? Color.grey : this.getReflectionColor(isect.thing, pos, normal, reflectDir, scene, depth);
        return Color.plus(naturalColor, reflectedColor);
    }
    private getReflectionColor(thing: Thing, pos: Vector, normal: Vector, rd: Vector, scene: Scene, depth: number) {
        return Color.scale(thing.surface.reflect(pos), this.traceRay({ start: pos, dir: rd }, scene, depth + 1));
    }
    private getNaturalColor(thing: Thing, pos: Vector, norm: Vector, rd: Vector, scene: Scene) {
        const addLight = (col: Color, light: Light) => {
            let ldis = Vector.minus(light.pos, pos);
            let livec = Vector.norm(ldis);
            let neatIsect = this.testRay({ start: pos, dir: livec }, scene);
            let isInShadow = (neatIsect === undefined) ? false : (neatIsect <= Vector.mag(ldis));
            if (isInShadow) {
                return col;
            } else {
                let illum = Vector.dot(livec, norm);
                let lcolor = (illum > 0) ? Color.scale(illum, light.color)
                    : Color.defaultColor;
                let specular = Vector.dot(livec, Vector.norm(rd));
                let scolor = (specular > 0) ? Color.scale(Math.pow(specular, thing.surface.roughness), light.color)
                    : Color.defaultColor;
                return Color.plus(col, Color.plus(Color.times(thing.surface.diffuse(pos), lcolor),
                    Color.times(thing.surface.specular(pos), scolor)));
            }
        }
        //return scene.lights.reduce(addLight, Color.defaultColor);
        let resColor = Color.defaultColor;
        for (const light of scene.lights) {
            resColor = addLight(resColor, light);
        }
        return resColor;
    }
    render(scene: Scene, screenWidth: number, screenHeight: number) {
        const getPoint = (x: number, y: number, camera: Camera) => {
            const recenterX = (x: number) => (x - (screenWidth / 2.0)) / 2.0 / screenWidth;
            const recenterY = (y: number) => - (y - (screenHeight / 2.0)) / 2.0 / screenHeight;
            return Vector.norm(Vector.plus(camera.forward, Vector.plus(Vector.times(recenterX(x), camera.right), Vector.times(recenterY(y), camera.up))));
        }
        for (let y = 0; y < screenHeight; y++) {
            for (let x = 0; x < screenWidth; x++) {
                let color = this.traceRay({ start: scene.camera.pos, dir: getPoint(x, y, scene.camera) }, scene, 0);
                let c = Color.toDrawingColor(color);
                //ctx.fillStyle = "rgb(" + String(c.r) + ", " + String(c.g) + ", " + String(c.b) + ")";
                //ctx.fillRect(x, y, x + 1, y + 1);
		// next line eats stack (or memory?)
		print(`<rect x="${x}" y="${y}" width="1" height="1" style="fill:rgb(${c.r},${c.g},${c.b});" />`);
            }
        }
    }
}
function defaultScene(): Scene {шас я вас залью кодик т.к. все не влазит ловите код на https://pastebin.com/qMZmnCqT так вот это вот компилиться и работает на новом компиляторе
−2
a     G    a      G C         G C
Deszcze niespokojne      potargaly sad
a               G     F      G    a
 А my na tej wojnie ladnych pare lat
      a                       b      a          b
Do domu wrocimy, w piecu napalimy, nakarmimy psa
       a                     B7 e           B7     e    a E7 a
Przed noca zdazymy, tylko zwyciezymy, a to wazna gra
a       G      a  G C               G  C
Na niebie obloki,     po wsiach pelno bzu,
a                   G       F     G       a
 Gdziez ten swiat daleki, pelen dobrych snow
      a                           b     a             b
Powrocimy wierni my czterej pancerni, "Rudy" i nasz pies
        a                  B7    e         B7     e
My czterej pancerni powrocimy wierni po wiosenny bez.
+3
Пиздец-оффтоп #33
            #4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
#5: https://govnokod.ru/26784 https://govnokod.xyz/_26784
#5: https://govnokod.ru/26839 https://govnokod.xyz/_26839
#6: https://govnokod.ru/26986 https://govnokod.xyz/_26986
#7: https://govnokod.ru/27007 https://govnokod.xyz/_27007
#8: https://govnokod.ru/27023 https://govnokod.xyz/_27023
#9: https://govnokod.ru/27098 https://govnokod.xyz/_27098
#10: https://govnokod.ru/27125 https://govnokod.xyz/_27125
#11: https://govnokod.ru/27129 https://govnokod.xyz/_27129
#12: https://govnokod.ru/27184 https://govnokod.xyz/_27184
#13: https://govnokod.ru/27286 https://govnokod.xyz/_27286
#14: https://govnokod.ru/27298 https://govnokod.xyz/_27298
#15: https://govnokod.ru/27322 https://govnokod.xyz/_27322
#16: https://govnokod.ru/27328 https://govnokod.xyz/_27328
#17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
#18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
#19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
#20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
#21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
#22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
#23: https://govnokod.ru/27493 https://govnokod.xyz/_27493
#24: https://govnokod.ru/27501 https://govnokod.xyz/_27501
#25: https://govnokod.ru/27521 https://govnokod.xyz/_27521
#26: https://govnokod.ru/27545 https://govnokod.xyz/_27545
#27: https://govnokod.ru/27572 https://govnokod.xyz/_27572
#28: https://govnokod.ru/27580 https://govnokod.xyz/_27580
#29: https://govnokod.ru/27738 https://govnokod.xyz/_27738
#30: https://govnokod.ru/27751 https://govnokod.xyz/_27751
#31: https://govnokod.ru/27754 https://govnokod.xyz/_27754
#32: https://govnokod.ru/27786 https://govnokod.xyz/_27786
        
−2
_                         _
    |_|                       |_|
    | |         /^^^\         | |
   _| |_      (| "o" |)      _| |_
 _| | | | _    (_---_)    _ | | | |_ 
| | | | |' |    _| |_    | `| | | | |
\          /   /     \   \          /
 \        /  / /(. .)\ \  \        /
   \    /  / /  | . |  \ \  \    /
     \  \/ /    ||Y||    \ \/  /
       \_/      || ||      \_/
                () ()
                || ||
               ooO OooБитч
−2
мдееемдеее
+1
#include <stdio.h>
#define new(class) _##class##_##new
#define impl(class, method) _##class##_##method
struct Calculate
{
	int(*getOne)(struct Calculate*);
};
int impl(Calculate, getOne)(struct Calculate* this) { return 1; }
void* new(Calculate)(void)
{
	struct Calculate* class = malloc(sizeof(struct Calculate));
	class->getOne = impl(Calculate, getOne);
	return class;
}
struct CalculateProxy
{
	struct Calculate;
};
int impl(CalculateProxy, getOne)(struct Calculate* this)
{
	printf("Method call!\n");
	return impl(Calculate, getOne)(this);
}
void* new(CalculateProxy)(void)
{
	struct CalculateProxy* class = malloc(sizeof(struct CalculateProxy));
	class->getOne = impl(CalculateProxy, getOne);
	return class;
}
int main(void)
{
	struct Calculate* calc = new(CalculateProxy)();
	printf("%X!\n", calc->getOne(calc));
}жавашок попросил реализовать паттерн прокси на Си