From db3879f7a51c5413e1c17e17cd6949d711132468 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Sun, 7 Apr 2024 21:41:40 -0700 Subject: [PATCH] Re-add `_non_virtual` and add `_unedited` for methods --- src/struct.ts | 3 +++ src/vtable.ts | 3 +++ syntax-highlighting/def.nanorc | 21 +++++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/struct.ts b/src/struct.ts index 6589297..a3d2850 100644 --- a/src/struct.ts +++ b/src/struct.ts @@ -212,6 +212,7 @@ export class Struct { for (const method of this.#methods) { out += method.generateTypedef(); out += `extern ${method.generateDefinition()}`; + out += `extern ${method.generateDefinition('_unedited')}`; out += method.generateNewMethodTest(this.#directParent, '', ''); } @@ -288,6 +289,8 @@ export class Struct { for (const method of this.#methods) { init += `${INDENT}${method.getName()} = (${method.getType()}) ${toHex(method.address)};\n`; declarations += method.generateDefinition(); + init += `${INDENT}${method.getName()}_unedited = (${method.getType()}) ${toHex(method.address)};\n`; + declarations += method.generateDefinition('_unedited'); } // VTable diff --git a/src/vtable.ts b/src/vtable.ts index 84c44a2..1038b3c 100644 --- a/src/vtable.ts +++ b/src/vtable.ts @@ -126,6 +126,7 @@ export class VTable implements Property { if (info) { const type = `${info.getType()} *`; out += `extern ${type}${info.getName()}_vtable_addr;\n`; + out += `extern ${info.generateDefinition('_non_virtual')}`; out += info.generateNewMethodTest(directParent, '*', '_vtable_addr'); } } @@ -161,6 +162,8 @@ export class VTable implements Property { const type = `${info.getType()} *`; init += `${INDENT}${info.getName()}_vtable_addr = (${type}) ${toHex(vtableAddress)};\n`; declarations += `${type}${info.getName()}_vtable_addr;\n`; + init += `${INDENT}${info.getName()}_non_virtual = *${info.getName()}_vtable_addr;\n`; + declarations += info.generateDefinition('_non_virtual'); } } } diff --git a/syntax-highlighting/def.nanorc b/syntax-highlighting/def.nanorc index 199975f..fb66156 100644 --- a/syntax-highlighting/def.nanorc +++ b/syntax-highlighting/def.nanorc @@ -1,17 +1,34 @@ syntax def "\.def$" comment "//" +# Mistakes +# Missing semicolon +color red "[^;]$" +# Missing type +color red "^(((static|virtual)-)?method|property|static-property(-array)?) [a-zA-Z_][a-zA-Z0-9_]* ?(\(|=)" +# Missing prefix +color red "^[^ ]+" +# Missing vtable +color red "^(vtable(-size|-destructor-offset))? .+$" + +# Reset +color normal "(\(|\))" + # Commands -color magenta "\<(extends|size|vtable(-size|-destructor-offset)?|property|static-property(-array)?|((static|virtual)-)?method|constructor)\>" +color magenta "^(extends|size|vtable(-size|-destructor-offset)?|property|static-property(-array)?|((static|virtual)-)?method|constructor)\>" # Types -color green "\<(char|uchar|short|ushort|int|uint|float|bool|void|std::(string|vector|map))\>" +color green "\<((u?(char|short|int))|float|bool|void|std::(string|vector|map))\>" # Numbers color yellow "0x[a-f0-9]+" +# Non-hex numbers +color red " [0-9][a-f0-9]+;" # Comments color brightblue "//.*" +# Whitespace. +color normal "[[:space:]]+" # Trailing whitespace. color ,green "[[:space:]]+$" -- 2.45.2