- 1
Class HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Class HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor
https://javadoc.io/doc/org.aspectj/aspectjweaver/1.8.10/org/aspectj/weaver/patterns/HasThisTypePatternTriedToSneakInSomeGene ricOrParameterizedTypePatternMatchingStu ffAnywhereVisitor.html
+1
// https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Common-Function-Attributes.html
access
access (access-mode, ref-index)
access (access-mode, ref-index, size-index)
// примеры:
__attribute__ ((access (read_only, 1))) int puts (const char*);
__attribute__ ((access (read_only, 1, 2))) void* memcpy (void*, const void*, size_t);
__attribute__ ((access (read_write, 1), access (read_only, 2))) char* strcat (char*, const char*);
__attribute__ ((access (write_only, 1), access (read_only, 2))) char* strcpy (char*, const char*);
__attribute__ ((access (write_only, 1, 2), access (read_write, 3))) int fgets (char*, int, FILE*);
В GCC 10 какой-то новый атрибут access появился, чтоб более строго что-то там гарантировать:
The access attribute enables the detection of invalid or unsafe accesses by functions to which they apply or their callers, as well as write-only accesses to objects that are never read from. Such accesses may be diagnosed by warnings such as -Wstringop-overflow, -Wuninitialized, -Wunused, and others.
The access attribute specifies that a function to whose by-reference arguments the attribute applies accesses the referenced object according to access-mode. The access-mode argument is required and must be one of three names: read_only, read_write, or write_only. The remaining two are positional arguments.
The required ref-index positional argument denotes a function argument of pointer (or in C++, reference) type that is subject to the access. The same pointer argument can be referenced by at most one distinct access attribute.
The optional size-index positional argument denotes a function argument of integer type that specifies the maximum size of the access. The size is the number of elements of the type referenced by ref-index, or the number of bytes when the pointer type is void*. When no size-index argument is specified, the pointer argument must be either null or point to a space that is suitably aligned and large for at least one object of the referenced type (this implies that a past-the-end pointer is not a valid argument). The actual size of the access may be less but it must not be more.
+1
function main() {
print("Hello", 1, false, true, parseInt("01"), parseFloat("00.1"));
}
// ASM
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
@__true__ = internal constant [5 x i8] c"true\00"
@__false__ = internal constant [6 x i8] c"false\00"
@frmt_9481649210695450612 = internal constant [19 x i8] c"%s %d %s %s %d %f\0A\00"
@s_3144841719139014728 = internal constant [5 x i8] c"00.1\00"
@s_12300967985959445949 = internal constant [3 x i8] c"01\00"
@s_1772061916968062023 = internal constant [6 x i8] c"Hello\00"
declare i8* @malloc(i64)
declare void @free(i8*)
declare i32 @printf(i8*, ...)
declare float @atof(i8*)
declare i32 @atoi(i8*)
define void @main() !dbg !3 {
%1 = call i32 @atoi(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @s_12300967985959445949, i64 0, i64 0)), !dbg !7
%2 = call float @atof(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @s_3144841719139014728, i64 0, i64 0)), !dbg !9
%3 = fpext float %2 to double, !dbg !10
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @frmt_9481649210695450612, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s_1772061916968062023, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__false__, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__true__, i64 0, i64 0), i32 %1, double %3), !dbg !10
br label %5, !dbg !11
5: ; preds = %0
ret void, !dbg !11
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2}
Продолжение писания уе..(зачеркнуто) супер компилятора с TypeScript (JavaScript) в нативный код.
как обычно компилим просто
set LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\SDK\ScopeCppSDK\vc 15\VC\lib
set SDKPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\SDK\ScopeCppSDK\vc 15\SDK\lib
tsc.exe --emit=llvm C:\temp\1.ts 2>1.ll
llc.exe --filetype=obj -o=out.o 1.ll
lld.exe -flavor link out.o "%LIBPATH%\libcmt.lib" "%LIBPATH%\libvcruntime.lib" "%SDKPATH%\kernel32.lib" "%SDKPATH%\libucrt.lib" "%SDKPATH%\uuid.lib"
получаетм Ехе и грузим его. и результат
=====================================
и выполнение
C:\>out.exe
Hello 1 false true 1 0.100000
+1
Просто оффтоп #16
#1: https://govnokod.ru/20162 https://govnokod.xyz/_20162
#2: https://govnokod.ru/25329 https://govnokod.xyz/_25329
#3: https://govnokod.ru/25415 https://govnokod.xyz/_25415
#4: (vanished) https://govnokod.xyz/_25472
#5: https://govnokod.ru/25693 https://govnokod.xyz/_25693
#6: (vanished) https://govnokod.xyz/_26649
#7: https://govnokod.ru/26672 https://govnokod.xyz/_26672
#8: https://govnokod.ru/26924 https://govnokod.xyz/_26924
#9: https://govnokod.ru/27072 https://govnokod.xyz/_27072
#10: https://govnokod.ru/27086 https://govnokod.xyz/_27086
#11: https://govnokod.ru/27122 https://govnokod.xyz/_27122
#12: https://govnokod.ru/27153 https://govnokod.xyz/_27153
#13: https://govnokod.ru/27159 https://govnokod.xyz/_27159
#14: https://govnokod.ru/27200 https://govnokod.xyz/_27200
#15: https://govnokod.ru/27237 https://govnokod.xyz/_27237
+1
// https://docs.docker.com/engine/api/v1.24/#create-a-container
POST /v1.24/containers/create HTTP/1.1
Content-Type: application/json
Content-Length: 12345
{
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"FOO=bar",
"BAZ=quux"
],
...
}
Ядро предоставляет сисколл execve. Execve принимает переменные окружения в виде массива строк A=B -
не знаю конкретных причин, почему так сделано, но скорее всего просто потому что писать хэшмапу под
это дело, которая еще и будет выкинута из памяти через относительно небольшое время - дело дорогое и
ненужное, плюс наверняка какой-нибудь лишний пердолинг со стеком.
https://man7.org/linux/man-pages/man2/execve.2.html
Го, "человеческий язык" с поддержкой обычных мап из коробки, ничтоже сумляшеся не замечает никакой
проблемы и заставляет пользователя передавать переменные окружения в том же формате, потому что у
языка не только синтаксис должен быть таким же тупым, как программист на нём и вообще мы же тут
делаем вид, что мы C, только лучше.
https://golang.org/pkg/os/exec/#example_Command_environment
Докер, "человеческий сервис" с HTTP API, использующим формат JSON с поддержкой обычных мап из коробки,
ничтоже сумляшеся не замечает никакой проблемы и заставляет пользователя передавать переменные
окружения в том же формате, потому что на программист на языке должен быть тупым, как этот язык.
https://docs.docker.com/engine/api/v1.24/#create-a-container
В результате мы имеем пачку долбоебов, из-за которых оперирующие (мапами / объектами / словарями / как угодно назовите)
нормальные люди должны вести себя как типичные гошники.
+1
.
https://vc.ru/flood/149783-podgotovte-nomer-pablik-steytik-dzhava-tochka-pomoshchnik-oleg-zachital-sboy-vo-vremya-testa-v-koll-centre-tinkoff
+1
Запрос = Новый Запрос;
Запрос.УстановитьПараметр("Регистратор", ЭтотОбъект.Отбор.Регистратор.Значение);
Запрос.УстановитьПараметр("НачалоПериода", ЭтотОбъект.Отбор.Регистратор.Значение.МоментВремени());
Запрос.УстановитьПараметр("КонецПериода", ЭтотОбъект.Отбор.Регистратор.Значение.МоментВремени());
Запрос.Текст =
"ВЫБРАТЬ
| ТаблицаСоставаДокумента.Склад,
| ТаблицаСоставаДокумента.Номенклатура,
| ТаблицаСоставаДокумента.Качество,
| ТаблицаСоставаДокумента.ХарактеристикаНоменклатуры,
| ТаблицаСоставаДокумента.СерияНоменклатуры
|ПОМЕСТИТЬ ВТ_Состава_Документа
|ИЗ
| &ТаблицаСоставаДокумента КАК ТаблицаСоставаДокумента
|;
|
|////////////////////////////////////////////////////////////////////////////////
|ВЫБРАТЬ
| СвободныеОстаткиОстаткиИОбороты.Склад,
| СвободныеОстаткиОстаткиИОбороты.Номенклатура,
| СвободныеОстаткиОстаткиИОбороты.Качество,
| СвободныеОстаткиОстаткиИОбороты.ХарактеристикаНоменклатуры,
| СвободныеОстаткиОстаткиИОбороты.СерияНоменклатуры,
| СвободныеОстаткиОстаткиИОбороты.КоличествоНачальныйОстаток,
| СвободныеОстаткиОстаткиИОбороты.КоличествоКонечныйОстаток
|ИЗ
| РегистрНакопления.ТоварыНаСкладах.ОстаткиИОбороты(
| &НачалоПериода,
| &КонецПериода,
| Запись,
| Движения,
| НЕ Номенклатура.ВидНоменклатуры = ЗНАЧЕНИЕ(Справочник.ВидыНоменклатуры.Продукция)
| И НЕ Номенклатура.ВестиУчетПоСериям
| И (Склад, Номенклатура, Качество, ХарактеристикаНоменклатуры, СерияНоменклатуры) В
| (ВЫБРАТЬ
| ВТ_СоставаДокумента.Склад,
| ВТ_СоставаДокумента.Номенклатура,
| ВТ_СоставаДокумента.Качество,
| ВТ_СоставаДокумента.ХарактеристикаНоменклатуры,
| ВТ_СоставаДокумента.СерияНоменклатуры
| ИЗ
| ВТ_Состава_Документа КАК ВТ_СоставаДокумента)) КАК СвободныеОстаткиОстаткиИОбороты
|ГДЕ
| СвободныеОстаткиОстаткиИОбороты.Регистратор = &Регистратор
| И СвободныеОстаткиОстаткиИОбороты.КоличествоКонечныйОстаток < 0";
Проверка на отрицательные остатки.....
+1
$txtdd = $DI_Date;
$DI_Date = explode(".",$DI_Date);
$DI_YY = $DI_Date[2];
$DI_LYY = $DI_YY;
$DI_NYY = $DI_YY;
$MY = $DI_Date[1].".".$DI_Date[2];
$DI_MM = $DI_Date[1]-1;
$DI_LMM = $DI_MM-1;
if ($DI_LMM<0) $DI_LMM = 11;
$DI_NMM = $DI_MM+1;
if ($DI_NMM>11) $DI_NMM = 0;
if ($DI_MM==0) $DI_LYY = $DI_YY-1;
if ($DI_MM==11) $DI_NYY = $DI_YY+1;
$DI_DD = 1;
$lastM = $DI_MM;
$yy = $DI_YY;
if ($lastM<1) {
$lastM = 12+$lastM;
$yy = $yy - 1;
}
$lastM = $DI_DD.".".$lastM.".".$yy;
$nextM = $DI_MM+2;
$yy = $DI_YY;
if ($nextM>12) {
$nextM = $nextM-12;
$yy = $yy + 1;
}
$nextM = $DI_DD.".".$nextM.".".$yy;
$lastY = $DI_DD.".".($DI_MM+1).".".($DI_YY-1);
$nextY = $DI_DD.".".($DI_MM+1).".".($DI_YY+1);
+1
Немного богословия.
In the beginning was the word; and version of this Word was 1.0
+1
// https://quuxplusone.github.io/blog/2021/01/13/conversion-operator-lookup/
struct A {
using T = T1;
using U = U1;
operator U1 T1::*();
operator U1 T2::*();
operator U2 T1::*();
operator U2 T2::*();
};
inline auto which(U1 T1::*) { return "gcc"; }
inline auto which(U1 T2::*) { return "icc"; }
inline auto which(U2 T1::*) { return "msvc"; }
inline auto which(U2 T2::*) { return "clang"; }
int main() {
A a;
using T = T2;
using U = U2;
puts(which(a.operator U T::*()));
}
> As of this writing (but perhaps not for very much longer!) the four mainstream compilers on Godbolt Compiler Explorer give four different answers for this simple C++ program:
> According to the current draft standard, it sounds like the conforming answer is “they should both be looked up in the scope of A”; i.e., GCC’s answer is correct and the others are wrong in three different ways.
Какой багор )))