Skip to content

Commit

Permalink
tag cleanup (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq authored Feb 14, 2025
1 parent b9e2177 commit e7bbca2
Show file tree
Hide file tree
Showing 13 changed files with 938 additions and 946 deletions.
6 changes: 2 additions & 4 deletions doc/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
| sizeof | C, X | `sizeof` operation |
| alignof | C, X | `alignof` operation |
| offsetof | C, X | `offsetof` operation |
| oconstr | C | object constructor |
| obj | X, L | object constructor |
| aconstr | C | array constructor |
| arr | X | array constructor |
| oconstr | C, X, L | object constructor |
| aconstr | C, X | array constructor |
| bracket | X, L | untyped array constructor |
| curly | X, L | untyped set constructor |
| curlyat | X, L | curly expression `a{i}` |
Expand Down
20 changes: 10 additions & 10 deletions src/models/callconv_tags.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
type
CallConv* = enum
NoCallConv
Cdecl = (113, "cdecl") ## `cdecl` calling convention
Stdcall = (114, "stdcall") ## `stdcall` calling convention
Safecall = (115, "safecall") ## `safecall` calling convention
Syscall = (116, "syscall") ## `syscall` calling convention
Fastcall = (117, "fastcall") ## `fastcall` calling convention
Thiscall = (118, "thiscall") ## `thiscall` calling convention
Noconv = (119, "noconv") ## no explicit calling convention
Member = (120, "member") ## `member` calling convention
Nimcall = (121, "nimcall") ## `nimcall` calling convention
Cdecl = (111, "cdecl") ## `cdecl` calling convention
Stdcall = (112, "stdcall") ## `stdcall` calling convention
Safecall = (113, "safecall") ## `safecall` calling convention
Syscall = (114, "syscall") ## `syscall` calling convention
Fastcall = (115, "fastcall") ## `fastcall` calling convention
Thiscall = (116, "thiscall") ## `thiscall` calling convention
Noconv = (117, "noconv") ## no explicit calling convention
Member = (118, "member") ## `member` calling convention
Nimcall = (119, "nimcall") ## `nimcall` calling convention

proc rawTagIsCallConv*(raw: uint32): bool {.inline.} =
raw >= 113'u32 and raw <= 121'u32
raw >= 111'u32 and raw <= 119'u32

206 changes: 103 additions & 103 deletions src/models/nifc_tags.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,151 +25,151 @@ type
AlignofC = (20, "alignof") ## `alignof` operation
OffsetofC = (21, "offsetof") ## `offsetof` operation
OconstrC = (22, "oconstr") ## object constructor
AconstrC = (24, "aconstr") ## array constructor
AddC = (31, "add")
SubC = (32, "sub")
MulC = (33, "mul")
DivC = (34, "div")
ModC = (35, "mod")
ShrC = (36, "shr")
ShlC = (37, "shl")
BitandC = (38, "bitand")
BitorC = (39, "bitor")
BitxorC = (40, "bitxor")
BitnotC = (41, "bitnot")
EqC = (42, "eq")
NeqC = (43, "neq")
LeC = (44, "le")
LtC = (45, "lt")
CastC = (46, "cast") ## `cast` operation
ConvC = (47, "conv") ## type conversion
CallC = (48, "call") ## call operation
ErrvC = (254, "errv") ## error flag for `NIFC`
AconstrC = (23, "aconstr") ## array constructor
AddC = (29, "add")
SubC = (30, "sub")
MulC = (31, "mul")
DivC = (32, "div")
ModC = (33, "mod")
ShrC = (34, "shr")
ShlC = (35, "shl")
BitandC = (36, "bitand")
BitorC = (37, "bitor")
BitxorC = (38, "bitxor")
BitnotC = (39, "bitnot")
EqC = (40, "eq")
NeqC = (41, "neq")
LeC = (42, "le")
LtC = (43, "lt")
CastC = (44, "cast") ## `cast` operation
ConvC = (45, "conv") ## type conversion
CallC = (46, "call") ## call operation
ErrvC = (252, "errv") ## error flag for `NIFC`

proc rawTagIsNifcExpr*(raw: uint32): bool {.inline.} =
let r = raw - 2'u32
r <= 255'u32 and r.uint8 in {0'u8, 1'u8, 2'u8, 3'u8, 4'u8, 5'u8, 6'u8, 7'u8, 8'u8, 9'u8, 10'u8, 11'u8, 12'u8, 13'u8, 14'u8, 15'u8, 16'u8, 17'u8, 18'u8, 19'u8, 20'u8, 22'u8, 29'u8, 30'u8, 31'u8, 32'u8, 33'u8, 34'u8, 35'u8, 36'u8, 37'u8, 38'u8, 39'u8, 40'u8, 41'u8, 42'u8, 43'u8, 44'u8, 45'u8, 46'u8, 252'u8}
r <= 255'u32 and r.uint8 in {0'u8, 1'u8, 2'u8, 3'u8, 4'u8, 5'u8, 6'u8, 7'u8, 8'u8, 9'u8, 10'u8, 11'u8, 12'u8, 13'u8, 14'u8, 15'u8, 16'u8, 17'u8, 18'u8, 19'u8, 20'u8, 21'u8, 27'u8, 28'u8, 29'u8, 30'u8, 31'u8, 32'u8, 33'u8, 34'u8, 35'u8, 36'u8, 37'u8, 38'u8, 39'u8, 40'u8, 41'u8, 42'u8, 43'u8, 44'u8, 250'u8}

type
NifcStmt* = enum
NoStmt
CallS = (48, "call") ## call operation
GvarS = (52, "gvar") ## global variable declaration
TvarS = (53, "tvar") ## thread local variable declaration
VarS = (54, "var") ## variable declaration
ConstS = (56, "const") ## const variable declaration
ProcS = (63, "proc") ## proc declaration
TypeS = (70, "type") ## type declaration
EmitS = (75, "emit") ## emit statement
AsgnS = (76, "asgn") ## assignment statement
ScopeS = (77, "scope") ## explicit scope annotation, like `stmts`
IfS = (78, "if") ## if statement header
BreakS = (83, "break") ## `break` statement
WhileS = (86, "while") ## `while` statement
CaseS = (87, "case") ## `case` statement
LabS = (89, "lab") ## label, target of a `jmp` instruction
JmpS = (90, "jmp") ## jump/goto instruction
RetS = (91, "ret") ## `return` instruction
StmtsS = (93, "stmts") ## list of statements
ImpS = (133, "imp") ## import declaration
InclS = (135, "incl") ## `#include` statement or `incl` set operation
DiscardS = (145, "discard") ## `discard` statement
TryS = (146, "try") ## `try` statement
RaiseS = (147, "raise") ## `raise` statement
OnerrS = (148, "onerr") ## error handling statement
CallS = (46, "call") ## call operation
GvarS = (50, "gvar") ## global variable declaration
TvarS = (51, "tvar") ## thread local variable declaration
VarS = (52, "var") ## variable declaration
ConstS = (54, "const") ## const variable declaration
ProcS = (61, "proc") ## proc declaration
TypeS = (68, "type") ## type declaration
EmitS = (73, "emit") ## emit statement
AsgnS = (74, "asgn") ## assignment statement
ScopeS = (75, "scope") ## explicit scope annotation, like `stmts`
IfS = (76, "if") ## if statement header
BreakS = (81, "break") ## `break` statement
WhileS = (84, "while") ## `while` statement
CaseS = (85, "case") ## `case` statement
LabS = (87, "lab") ## label, target of a `jmp` instruction
JmpS = (88, "jmp") ## jump/goto instruction
RetS = (89, "ret") ## `return` instruction
StmtsS = (91, "stmts") ## list of statements
ImpS = (131, "imp") ## import declaration
InclS = (133, "incl") ## `#include` statement or `incl` set operation
DiscardS = (143, "discard") ## `discard` statement
TryS = (144, "try") ## `try` statement
RaiseS = (145, "raise") ## `raise` statement
OnerrS = (146, "onerr") ## error handling statement

proc rawTagIsNifcStmt*(raw: uint32): bool {.inline.} =
let r = raw - 48'u32
let r = raw - 46'u32
r <= 255'u32 and r.uint8 in {0'u8, 4'u8, 5'u8, 6'u8, 8'u8, 15'u8, 22'u8, 27'u8, 28'u8, 29'u8, 30'u8, 35'u8, 38'u8, 39'u8, 41'u8, 42'u8, 43'u8, 45'u8, 85'u8, 87'u8, 97'u8, 98'u8, 99'u8, 100'u8}

type
NifcType* = enum
NoType
ParamsT = (94, "params") ## list of proc parameters, also used as a "proc type"
UnionT = (95, "union") ## union declaration
ObjectT = (96, "object") ## object type declaration
EnumT = (97, "enum") ## enum type declaration
ProctypeT = (98, "proctype") ## proc type declaration (soon obsolete, use params instead)
IT = (103, "i") ## `int` builtin type
UT = (104, "u") ## `uint` builtin type
FT = (105, "f") ## `float` builtin type
CT = (106, "c") ## `char` builtin type
BoolT = (107, "bool") ## `bool` builtin type
VoidT = (108, "void") ## `void` return type
PtrT = (109, "ptr") ## `ptr` type contructor
ArrayT = (110, "array") ## `array` type constructor
FlexarrayT = (111, "flexarray") ## `flexarray` type constructor
AptrT = (112, "aptr") ## "pointer to array of" type constructor
ParamsT = (92, "params") ## list of proc parameters, also used as a "proc type"
UnionT = (93, "union") ## union declaration
ObjectT = (94, "object") ## object type declaration
EnumT = (95, "enum") ## enum type declaration
ProctypeT = (96, "proctype") ## proc type declaration (soon obsolete, use params instead)
IT = (101, "i") ## `int` builtin type
UT = (102, "u") ## `uint` builtin type
FT = (103, "f") ## `float` builtin type
CT = (104, "c") ## `char` builtin type
BoolT = (105, "bool") ## `bool` builtin type
VoidT = (106, "void") ## `void` return type
PtrT = (107, "ptr") ## `ptr` type contructor
ArrayT = (108, "array") ## `array` type constructor
FlexarrayT = (109, "flexarray") ## `flexarray` type constructor
AptrT = (110, "aptr") ## "pointer to array of" type constructor

proc rawTagIsNifcType*(raw: uint32): bool {.inline.} =
let r = raw - 94'u32
let r = raw - 92'u32
r <= 255'u32 and r.uint8 in {0'u8, 1'u8, 2'u8, 3'u8, 4'u8, 9'u8, 10'u8, 11'u8, 12'u8, 13'u8, 14'u8, 15'u8, 16'u8, 17'u8, 18'u8}

type
NifcOther* = enum
NoSub
KvU = (29, "kv") ## key-value pair
RangeU = (50, "range") ## `(range a b)` construct
RangesU = (51, "ranges")
ParamU = (55, "param") ## parameter declaration
TypevarU = (60, "typevar") ## type variable declaration
EfldU = (61, "efld") ## enum field declaration
FldU = (62, "fld") ## field declaration
ElifU = (80, "elif") ## pair of (condition, action)
ElseU = (81, "else") ## `else` action
OfU = (88, "of") ## `of` branch within a `case` statement
PragmasU = (128, "pragmas") ## begin of pragma section
KvU = (27, "kv") ## key-value pair
RangeU = (48, "range") ## `(range a b)` construct
RangesU = (49, "ranges")
ParamU = (53, "param") ## parameter declaration
TypevarU = (58, "typevar") ## type variable declaration
EfldU = (59, "efld") ## enum field declaration
FldU = (60, "fld") ## field declaration
ElifU = (78, "elif") ## pair of (condition, action)
ElseU = (79, "else") ## `else` action
OfU = (86, "of") ## `of` branch within a `case` statement
PragmasU = (126, "pragmas") ## begin of pragma section

proc rawTagIsNifcOther*(raw: uint32): bool {.inline.} =
let r = raw - 29'u32
let r = raw - 27'u32
r <= 255'u32 and r.uint8 in {0'u8, 21'u8, 22'u8, 26'u8, 31'u8, 32'u8, 33'u8, 51'u8, 52'u8, 59'u8, 99'u8}

type
NifcPragma* = enum
NoPragma
InlineP = (122, "inline") ## `inline` proc annotation
NoinlineP = (123, "noinline") ## `noinline` proc annotation
AttrP = (124, "attr") ## general attribute annoation
VarargsP = (125, "varargs") ## `varargs` proc annotation
WasP = (126, "was")
SelectanyP = (127, "selectany")
AlignP = (130, "align")
BitsP = (131, "bits")
VectorP = (132, "vector")
NodeclP = (134, "nodecl") ## `nodecl` annotation
RaisesP = (149, "raises") ## proc annotation
ErrsP = (150, "errs") ## proc annotation
StaticP = (151, "static") ## `static` type or annotation
InlineP = (120, "inline") ## `inline` proc annotation
NoinlineP = (121, "noinline") ## `noinline` proc annotation
AttrP = (122, "attr") ## general attribute annoation
VarargsP = (123, "varargs") ## `varargs` proc annotation
WasP = (124, "was")
SelectanyP = (125, "selectany")
AlignP = (128, "align")
BitsP = (129, "bits")
VectorP = (130, "vector")
NodeclP = (132, "nodecl") ## `nodecl` annotation
RaisesP = (147, "raises") ## proc annotation
ErrsP = (148, "errs") ## proc annotation
StaticP = (149, "static") ## `static` type or annotation

proc rawTagIsNifcPragma*(raw: uint32): bool {.inline.} =
let r = raw - 122'u32
let r = raw - 120'u32
r <= 255'u32 and r.uint8 in {0'u8, 1'u8, 2'u8, 3'u8, 4'u8, 5'u8, 8'u8, 9'u8, 10'u8, 12'u8, 27'u8, 28'u8, 29'u8}

type
NifcTypeQualifier* = enum
NoQualifier
AtomicQ = (99, "atomic") ## `atomic` type qualifier for NIFC
RoQ = (100, "ro") ## `readonly` (= `const`) type qualifier for NIFC
RestrictQ = (101, "restrict") ## type qualifier for NIFC
CpprefQ = (102, "cppref") ## type qualifier for NIFC that provides a C++ reference
AtomicQ = (97, "atomic") ## `atomic` type qualifier for NIFC
RoQ = (98, "ro") ## `readonly` (= `const`) type qualifier for NIFC
RestrictQ = (99, "restrict") ## type qualifier for NIFC
CpprefQ = (100, "cppref") ## type qualifier for NIFC that provides a C++ reference

proc rawTagIsNifcTypeQualifier*(raw: uint32): bool {.inline.} =
raw >= 99'u32 and raw <= 102'u32
raw >= 97'u32 and raw <= 100'u32

type
NifcSym* = enum
NoSym
GvarY = (52, "gvar") ## global variable declaration
TvarY = (53, "tvar") ## thread local variable declaration
VarY = (54, "var") ## variable declaration
ParamY = (55, "param") ## parameter declaration
ConstY = (56, "const") ## const variable declaration
EfldY = (61, "efld") ## enum field declaration
FldY = (62, "fld") ## field declaration
ProcY = (63, "proc") ## proc declaration
LabY = (89, "lab") ## label, target of a `jmp` instruction
GvarY = (50, "gvar") ## global variable declaration
TvarY = (51, "tvar") ## thread local variable declaration
VarY = (52, "var") ## variable declaration
ParamY = (53, "param") ## parameter declaration
ConstY = (54, "const") ## const variable declaration
EfldY = (59, "efld") ## enum field declaration
FldY = (60, "fld") ## field declaration
ProcY = (61, "proc") ## proc declaration
LabY = (87, "lab") ## label, target of a `jmp` instruction

proc rawTagIsNifcSym*(raw: uint32): bool {.inline.} =
let r = raw - 52'u32
let r = raw - 50'u32
r <= 255'u32 and r.uint8 in {0'u8, 1'u8, 2'u8, 3'u8, 4'u8, 9'u8, 10'u8, 11'u8, 37'u8}

Loading

0 comments on commit e7bbca2

Please sign in to comment.