mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-06 18:54:12 +00:00
Obfuscate #line
This commit is contained in:
@@ -8164,8 +8164,12 @@ gb_internal ExprKind check_basic_directive_expr(CheckerContext *c, Operand *o, A
|
||||
o->type = t_untyped_string;
|
||||
o->value = exact_value_string(file);
|
||||
} else if (name == "line") {
|
||||
i32 line = bd->token.pos.line;
|
||||
if (build_context.obfuscate_source_code_locations) {
|
||||
line = obfuscate_i32(line);
|
||||
}
|
||||
o->type = t_untyped_integer;
|
||||
o->value = exact_value_i64(bd->token.pos.line);
|
||||
o->value = exact_value_i64(line);
|
||||
} else if (name == "procedure") {
|
||||
if (c->curr_proc_decl == nullptr) {
|
||||
error(node, "#procedure may only be used within procedures");
|
||||
|
||||
@@ -364,6 +364,14 @@ gb_internal String obfuscate_string(String const &s, char const *prefix) {
|
||||
return make_string_c(res);
|
||||
}
|
||||
|
||||
gb_internal i32 obfuscate_i32(i32 i) {
|
||||
i32 x = cast(i32)gb_fnv64a(&i, sizeof(i));
|
||||
if (x < 0) {
|
||||
x = 1-x;
|
||||
}
|
||||
return cast(i32)x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct StringIntern {
|
||||
|
||||
@@ -287,13 +287,6 @@ gb_internal lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type
|
||||
return lb_const_value(m, t, tv.value);
|
||||
}
|
||||
|
||||
gb_internal i32 lb_obfuscate_i32(i32 i) {
|
||||
i32 x = cast(i32)gb_fnv64a(&i, sizeof(i));
|
||||
if (x < 0) {
|
||||
x = 1-x;
|
||||
}
|
||||
return cast(i32)x;
|
||||
}
|
||||
|
||||
gb_internal lbValue lb_const_source_code_location_const(lbModule *m, String const &procedure_, TokenPos const &pos) {
|
||||
String file = get_file_path_string(pos.file_id);
|
||||
@@ -306,8 +299,8 @@ gb_internal lbValue lb_const_source_code_location_const(lbModule *m, String cons
|
||||
file = obfuscate_string(file, "F");
|
||||
procedure = obfuscate_string(procedure, "P");
|
||||
|
||||
line = lb_obfuscate_i32(line);
|
||||
column = lb_obfuscate_i32(column);
|
||||
line = obfuscate_i32(line);
|
||||
column = obfuscate_i32(column);
|
||||
}
|
||||
|
||||
LLVMValueRef fields[4] = {};
|
||||
|
||||
Reference in New Issue
Block a user