Кресты / Говнокод #27838 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
#include <iostream>
#include <cstdio>
 
namespace std {
    namespace ios_base2 {
	    extern struct sync_with_stdio_t {
	    	void h(bool sync = true) {
		    	ios_base::sync_with_stdio(sync);
		    }
	    } sync_with_stdio;
    }
}
 
int main() {
	std::ios_base2::sync_with_stdio.h(false);
	std::cout << "1";
	printf("2");
	std::cout << "3";
	puts("");
	return 0;
}

132

https://ideone.com/NkGYUL

3_dar 3_dar, (Updated )

Комментарии (6, +6)

Кресты / Говнокод #27823 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
// @param n `0 <= n`
// @param m `1 <= m`
// @return `(x ** n) % m`
constexpr long long pow_mod_constexpr(long long x, long long n, int m) {
    if (m == 1) return 0;
    unsigned int _m = (unsigned int)(m);
    unsigned long long r = 1;
    unsigned long long y = safe_mod(x, m);
    while (n) {
        if (n & 1) r = (r * y) % _m;
        y = (y * y) % _m;
        n >>= 1;
    }
    return r;
}
 
// Reference:
// M. Forisek and J. Jancina,
// Fast Primality Testing for Integers That Fit into a Machine Word
// @param n `0 <= n`
constexpr bool is_prime_constexpr(int n) {
    if (n <= 1) return false;
    if (n == 2 || n == 7 || n == 61) return true;
    if (n % 2 == 0) return false;
    long long d = n - 1;
    while (d % 2 == 0) d /= 2;
    constexpr long long bases[3] = {2, 7, 61};
    for (long long a : bases) {
        long long t = d;
        long long y = pow_mod_constexpr(a, t, n);
        while (t != n - 1 && y != 1 && y != n - 1) {
            y = y * y % n;
            t <<= 1;
        }
        if (y != n - 1 && t % 2 == 0) {
            return false;
        }
    }
    return true;
}
template <int n> constexpr bool is_prime = is_prime_constexpr(n);

https://codeforces.com/contest/1508/submission/113222414

> if (n == 2 || n == 7 || n == 61) return true;

Помню я как делал: подобрал 3 базовых числа, прогнал на всех интах, там где алгоритм ошибался - проифал вручную )))

3_dar 3_dar, (Updated )

Комментарии (44, +44)

Кресты / Говнокод #27810 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99
  100. 100
// https://github.com/gcc-mirror/gcc/blob/b0c83d59f44bf677c8d74acae228acf32719acb3/libstdc%2B%2B-v3/include/bits/regex_compiler.tcc#L446
  template<typename _TraitsT>
  template<bool __icase, bool __collate>
    bool
    _Compiler<_TraitsT>::
    _M_expression_term(pair<bool, _CharT>& __last_char,
		       _BracketMatcher<_TraitsT, __icase, __collate>& __matcher)
    {
      if (_M_match_token(_ScannerT::_S_token_bracket_end))
	return false;

      const auto __push_char = [&](_CharT __ch)
      {
	if (__last_char.first)
	  __matcher._M_add_char(__last_char.second);
	else
	  __last_char.first = true;
	__last_char.second = __ch;
      };
      const auto __flush = [&]
      {
	if (__last_char.first)
	  {
	    __matcher._M_add_char(__last_char.second);
	    __last_char.first = false;
	  }
      };

      if (_M_match_token(_ScannerT::_S_token_collsymbol))
	{
	  auto __symbol = __matcher._M_add_collate_element(_M_value);
	  if (__symbol.size() == 1)
	    __push_char(__symbol[0]);
	  else
	    __flush();
	}
      else if (_M_match_token(_ScannerT::_S_token_equiv_class_name))
	{
	  __flush();
	  __matcher._M_add_equivalence_class(_M_value);
	}
      else if (_M_match_token(_ScannerT::_S_token_char_class_name))
	{
	  __flush();
	  __matcher._M_add_character_class(_M_value, false);
	}
      else if (_M_try_char())
	__push_char(_M_value[0]);
      // POSIX doesn't allow '-' as a start-range char (say [a-z--0]),
      // except when the '-' is the first or last character in the bracket
      // expression ([--0]). ECMAScript treats all '-' after a range as a
      // normal character. Also see above, where _M_expression_term gets called.
      //
      // As a result, POSIX rejects [-----], but ECMAScript doesn't.
      // Boost (1.57.0) always uses POSIX style even in its ECMAScript syntax.
      // Clang (3.5) always uses ECMAScript style even in its POSIX syntax.
      //
      // It turns out that no one reads BNFs ;)
      else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
	{
	  if (!__last_char.first)
	    {
	      if (!(_M_flags & regex_constants::ECMAScript))
		{
		  if (_M_match_token(_ScannerT::_S_token_bracket_end))
		    {
		      __push_char('-');
		      return false;
		    }
		  __throw_regex_error(
		    regex_constants::error_range,
		    "Unexpected dash in bracket expression. For POSIX syntax, "
		    "a dash is not treated literally only when it is at "
		    "beginning or end.");
		}
	      __push_char('-');
	    }
	  else
	    {
	      if (_M_try_char())
		{
		  __matcher._M_make_range(__last_char.second, _M_value[0]);
		  __last_char.first = false;
		}
	      else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
		{
		  __matcher._M_make_range(__last_char.second, '-');
		  __last_char.first = false;
		}
	      else
		{
		  if (_M_scanner._M_get_token()
		      != _ScannerT::_S_token_bracket_end)
		    __throw_regex_error(
		      regex_constants::error_range,
		      "Character is expected after a dash.");
		  __push_char('-');
		}
	    }
	}

Читаю тут реализацию стандартной говнокрестовой библиотеки из GCC
Какой багор )))

j123123 j123123, (Updated )

Комментарии (54, +54)

Кресты / Говнокод #27796 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
#include <iostream>
#include <cmath>
#include <signal.h>

#define lovu struct
#define cpp ptrdiff_t
struct forever{};

lovu forever hactehbka(void) {return {};}
int love(void) {return 0;}
void bacbka(void) {}
auto bormand = (cpp(hactehbka) + cpp(bacbka)) != cpp(love);
int main(void)
{
    if(bormand)
        kill(bormand, SIGINT);

    auto sad = cpp(bacbka) - cpp(love),
        chance = cpp(love) - cpp(hactehbka),
        never = cpp(bacbka) - cpp(hactehbka);
    auto usocute = [chance, never, sad](void) -> void
    {
        putchar(sad * (chance - never / chance / 2) - sad / chance);
        putchar(sad * (chance - never / chance / 2) + sad / chance);
    };
    auto mydear = [chance, sad, never](void) -> void
    {
        putchar(sad * chance / (never / chance) + never / chance / 2 + (never + cpp(love) / (never / chance) - cpp(hactehbka) / (never / chance)) + never - (never / chance * 1.5));
        putchar(9 * chance + never / chance);
        putchar(std::abs(cpp(signal) - cpp(hactehbka) + chance * 2 + never * 3 + sad - 9) / std::pow(never / chance, 3));
    };

    putchar(sad * (chance - never / chance / 2));
    usocute();
    putchar(never * (chance - never / chance) + sad - (sad / (cpp(love) - cpp(hactehbka))) * (never / chance * 1.5));
    mydear();
    putchar(chance * 10 + never / chance);
    usocute();
    putchar((chance + never / chance / 2) * 10 + (never / chance) * 2);
    auto ohyes = 69.8886;
    putchar(ohyes);
    putchar(chance * 10 + never / chance);
    putchar(chance + never / chance / 2);
    putchar(never * (chance - never / chance) + sad - (sad / (cpp(love) - cpp(hactehbka))) * (never / chance * 1.5));
    mydear();
    for(auto&& c : {1.5f, 3.f, 6.5f})
        putchar(ohyes + M_PI + never / chance * c);
    putchar(ohyes);
    putchar(chance + never / chance * 1.5);
    return 0;
}

BACbKA BACbKA, (Updated )

Комментарии (3, +3)

Кресты / Говнокод #27794 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
#include <cstdio>

int main(void)
{
    static char data[] = "sosu hui\n";
    __asm
    {
        mov eax, 0
        ploop:
            mov bl, [data + eax]
            push eax
            push bx
            call putchar
            pop bx
            pop eax
            inc eax
            cmp bl, 0
            jnz ploop

    }

    return 0;
}

digitalEugene digitalEugene, (Updated )

Комментарии (4, +4)

Кресты / Говнокод #27787 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
#include <string>
#include <type_traits>
#include <iostream>

template<int N> struct tag {};

template<typename T, int N>
struct loophole_t
{
    friend auto loophole(tag<N>) { return T{}; };
};

#define BA(c) auto loophole(tag< (c) >);
#define Cb(c) BA(c) BA(c+1) BA(c+2) BA(c+3) BA(c+4)
#define KA(c) Cb(c) Cb(c+5) Cb(c+10) Cb(c+15) Cb(c+20)
#define ZDES(c) KA(c) KA(c+20) KA(c+40) KA(c+60) KA(c+80)
#define BACbKAZDES ZDES(0) ZDES(80) ZDES(160) ZDES(240) ZDES(300)

BACbKAZDES

template<int I>
struct wrp
{
    int a;
};
int main(void)
{
    sizeof(loophole_t<wrp<67>, 0>);
    sizeof(loophole_t<wrp<66>, 1>);
    sizeof(loophole_t<wrp<68>, 2>);
    sizeof(loophole_t<wrp<99>, 3>);
    sizeof(loophole_t<wrp<76>, 4>);
    sizeof(loophole_t<wrp<66>, 5>);
    sizeof(loophole_t<wrp<33>, 6>);
    sizeof(loophole_t<wrp<73>, 7>);
    sizeof(loophole_t<wrp<66>, 8>);
    sizeof(loophole_t<wrp<68>, 9>);
    sizeof(loophole_t<wrp<85>, 10>);
    sizeof(loophole_t<wrp<70>, 11>);
    sizeof(loophole_t<wrp<79>, 12>);
    sizeof(loophole_t<wrp<99>, 13>);
    sizeof(loophole_t<wrp<76>, 14>);
    sizeof(loophole_t<wrp<66>, 15>);
    sizeof(loophole_t<wrp<33>, 16>);
    sizeof(loophole_t<wrp<109>, 17>);
    sizeof(loophole_t<wrp<112>, 18>);
    sizeof(loophole_t<wrp<119>, 19>);
    sizeof(loophole_t<wrp<102>, 20>);

    std::string nactenbka;
#define L(c, i) if(std::is_same< wrp< (c) >, decltype( loophole(tag< (i) >{}) )>::value) nactenbka.push_back((char)( c-1 ) );
#define O(c, i) L(c, i) L(c+1, i) L(c+2, i) L(c+3, i) L(c+4, i)
#define V(c, i) O(c, i) O(c+5, i) O(c+10,i) O(c+15,i) O(c+20,i)
#define E(c, i) V(c, i) V(c+20,i) V(c+40,i) V(c+60,i) V(c+80,i)
#define LOVE(c, i) E(c, i) V(c+80, i) V(c+100, i)

#define FORE(i) LOVE(0, i)
#define VER(i) FORE(i) FORE(i+1) FORE(i+2) FORE(i+3) FORE(i+4)
#define FOREVER VER(0) VER(5) VER(10) VER(15) FORE(20)
    FOREVER

    std::cout << nactenbka << std::endl;
    return 0;

}

<3

BACbKA BACbKA, (Updated )

Комментарии (9, +9)

Кресты / Говнокод #27785 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
template<typename T>
static ALWAYS_INLINE void FormatLogMessageAndPrintW(
                                             const char* channelName, 
                                             const char* functionName, 
                                             LOGLEVEL level,
                                             const char* message, 
                                             bool timestamp, 
                                             bool ansi_color_code,
                                             bool newline, 
                                             const T& callback)
{
  char buf[512];
  char* message_buf = buf;
  int message_len;
  if ((message_len = FormatLogMessageForDisplay(message_buf,
                       sizeof(buf), channelName, functionName,
                       level, 
                       message, timestamp,
                       ansi_color_code, newline)) > (sizeof(buf) - 1))
  {
    message_buf = static_cast<char*>(std::malloc(message_len + 1));
    message_len = FormatLogMessageForDisplay(message_buf, 
                 message_len + 1, channelName, functionName, 
                 level, message, timestamp, ansi_color_code, newline);
  }
  if (message_len <= 0)
    return;

  // Convert to UTF-16 first so unicode characters display correctly.
  // NT is going to do it anyway...
  wchar_t wbuf[512];
  wchar_t* wmessage_buf = wbuf;
  int wmessage_buflen = countof(wbuf) - 1;
  if (message_len >= countof(wbuf))
  {
    wmessage_buflen = message_len;
    wmessage_buf = static_cast<wchar_t*>
               (std::malloc((wmessage_buflen + 1) * sizeof(wchar_t)));
  }

  wmessage_buflen = MultiByteToWideChar(CP_UTF8, 0, message_buf,
                    message_len, wmessage_buf, wmessage_buflen);

  if (wmessage_buflen <= 0)
    return;

  wmessage_buf[wmessage_buflen] = '\0';
  callback(wmessage_buf, wmessage_buflen);

  if (wmessage_buf != wbuf)
  {
    std::free(wbuf);                        // <=
  }

  if (message_buf != buf)
  {
    std::free(message_buf);
  }
}

Отсюда:
https://pvs-studio.com/ru/blog/posts/cpp/0880/

HO9I6PbCKuu_neTyx HO9I6PbCKuu_neTyx, (Updated )

Комментарии (26, +26)

Кресты / Говнокод #27781 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
uint16_t Mnemonic::describeMnemonics(void) const
{
	uint16_t result = 0;
	size_t i = 0;
	for (auto&& m : mnemonics)
		result += m.index() << i++ * 4;

	return result;
}
...
switch(mnemonic.describeMnemonics())
{
	case constructDescription(REGISTER, REGISTER):
	{
...
	}
	break;

	case constructDescription(REGISTER, CONSTANT):
	{
...
	}
	break;

	case constructDescription(REGISTER, LABEL):
	{
...
	}
	break;

	case constructDescription(REGISTER, INDIRECT_ADDRESS):
	{
...
	}
	break;

	case constructDescription(INDIRECT_ADDRESS, REGISTER):
	{
...
	}
	break;

	default:
		break;

}

спасибо папочка за паттерн матчинг

digitalEugene digitalEugene, (Updated )

Комментарии (9, +9)

Кресты / Говнокод #27777 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
if (op.size() == 1)
				{
					if (op[0].id == LexemID::REGISTER)
					{
						if (isSIBbase(registerName2registerId.at( std::get<std::string>(op[0].lexemas))))
							mnemonic.mnemonics.emplace_back(IndirectAddress{
								.base = Register(std::get<std::string>(op[0].lexemas))
								});
						else
							mnemonic.mnemonics.emplace_back(IndirectAddress{
								.index = Register(std::get<std::string>(op[0].lexemas))
								});
					}
					else if (op[0].id == LexemID::LABEL_USE)
						mnemonic.mnemonics.emplace_back(IndirectAddress{
							.disp = LabelUse(std::get<std::string>(op[0].lexemas))
							});
					else if (op[0].id == LexemID::NUMBER)
						mnemonic.mnemonics.emplace_back(IndirectAddress{
							.disp = Constant(std::get<int>(op[0].lexemas))
							});
				}
				else if (op.size() == 3)
				{
					if (const auto operation = std::get<std::string>(op[1].lexemas)[0]; operation == '+')
					{
						if (op[0].id == LexemID::REGISTER && op[2].id == LexemID::REGISTER)
						{
							if (isSIBbase(registerName2registerId.at(std::get<std::string>(op[0].lexemas))))
								mnemonic.mnemonics.emplace_back(IndirectAddress{
									.base = Register(std::get<std::string>(op[0].lexemas)),
									.index = Register(std::get<std::string>(op[2].lexemas))
									});
							else
								mnemonic.mnemonics.emplace_back(IndirectAddress{
									.base = Register(std::get<std::string>(op[2].lexemas)),
									.index = Register(std::get<std::string>(op[0].lexemas))
									});
						}
						else if (op[0].id == LexemID::REGISTER && op[2].id == LexemID::NUMBER)
						{
							if (isSIBbase(registerName2registerId.at(std::get<std::string>(op[0].lexemas))))
								mnemonic.mnemonics.emplace_back(IndirectAddress{
									.base = Register(std::get<std::string>(op[0].lexemas)),
									.disp = Constant(std::get<int>(op[2].lexemas))
									});
							else
								mnemonic.mnemonics.emplace_back(IndirectAddress{
									.index = Register(std::get<std::string>(op[0].lexemas)),
									.disp = Constant(std::get<int>(op[2].lexemas))
									});
						}
						else if (op[0].id == LexemID::REGISTER && op[2].id == LexemID::LABEL_USE)
						{
							if (isSIBbase(registerName2registerId.at(std::get<std::string>(op[0].lexemas))))
								mnemonic.mnemonics.emplace_back(IndirectAddress{
									.base = Register(std::get<std::string>(op[0].lexemas)),
									.disp = LabelUse(std::get<std::string>(op[2].lexemas))
									});
							else
								mnemonic.mnemonics.emplace_back(IndirectAddress{
								.index = Register(std::get<std::string>(op[0].lexemas)),
								.disp = LabelUse(std::get<std::string>(op[2].lexemas))
									});
						}
					}
					else if (operation == '*')
					{
						if (op[0].id == LexemID::NUMBER && op[2].id == LexemID::REGISTER)
							mnemonic.mnemonics.emplace_back(IndirectAddress{
								.base = Register(std::get<std::string>(op[2].lexemas)),
								.scale = static_cast<uint8_t>(std::get<int>(op[0].lexemas))
								});
					}
				}
				else if(op.size() == 5)
				{

					if (op[4].id == LexemID::REGISTER)
						mnemonic.mnemonics.emplace_back(IndirectAddress{
							.base  = Register(std::get<std::string>(op[4].lexemas)),
							.index = Register(std::get<std::string>(op[2].lexemas)),
							.scale = static_cast<uint8_t>(std::get<int>(op[0].lexemas))
							});
					else if (op[4].id == LexemID::NUMBER)
						mnemonic.mnemonics.emplace_back(IndirectAddress{
							.index = Register(std::get<std::string>(op[2].lexemas)),
							.scale = static_cast<uint8_t>(std::get<int>(op[0].lexemas)),
							.disp = Constant(std::get<int>(op[4].lexemas))
							});
					else if (op[4].id == LexemID::LABEL_USE)
						mnemonic.mnemonics.emplace_back(IndirectAddress{
							.index = Register(std::get<std::string>(op[2].lexemas)),
							.scale = static_cast<uint8_t>(std::get<int>(op[0].lexemas)),
							.disp = LabelUse(std::get<std::string>(op[4].lexemas))
							});
...

чё к щам близко?

https://github.com/kcalbSphere/PVC-16/blob/master/pvc-asm/syntaxer.cpp

digitalEugene digitalEugene, (Updated )

Комментарии (22, +22)

Кресты / Говнокод #27776 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
// a.h
inline struct $q1 {unsigned a;} $q1i;

// main.cpp
#include "a.h"
int main(int argc, char** args) 
{
    $q1i.a = argc; 
    return $q1i.a;
};

у некоторых линукс-юзеров может упасть на этапе линковки

digitalEugene digitalEugene, (Updated )

Комментарии (3, +3)