修正了部分代码的表达方式,最后可用版本,mlirlite 已基本完善
This commit is contained in:
1 parent
0d77b68cc4
commit
0f556463e7
116 files changed
+13896
-4938
No files matched your search
+25
-23
@@ -1,35 +1,18 @@
|
||||
import stdint as __stdint
|
||||
import t
|
||||
|
||||
# ============================================================
|
||||
# 内置函数(Python 语义,自动与 builtins 关联,无需显式 import)
|
||||
# ord: 字符 → ASCII 码(int)
|
||||
# chr: ASCII 码 → 字符(t.CChar)
|
||||
# min/max: 数值比较取小/大值(double 参数,int/float 实参经
|
||||
# coerce_to_type 无损提升;返回值由调用侧 coerce 到目标类型)
|
||||
# ============================================================
|
||||
|
||||
def ord(s: t.CChar) -> int:
|
||||
return s
|
||||
def ord(s: char) -> int: return int(s)
|
||||
def chr(i: int) -> char: return char(i)
|
||||
|
||||
def chr(i: int) -> t.CChar:
|
||||
return i
|
||||
|
||||
def min(a: double, b: double) -> double:
|
||||
if a < b:
|
||||
return a
|
||||
return b
|
||||
|
||||
def max(a: double, b: double) -> double:
|
||||
if a > b:
|
||||
return a
|
||||
return b
|
||||
def min(a: double, b: double) -> double: return a if a < b else b
|
||||
def max(a: double, b: double) -> double: return a if a > b else b
|
||||
|
||||
# rawptr 已内置于编译器(TPC/TPV 双端),作为语法保留字,不可重定义:
|
||||
# rawptr[T] 固定表示"裸指针,指向原始类型 T"(等价 t.CPtr[T])。
|
||||
size_t: t.CTypedef = t.CSizeT
|
||||
uzt: t.CTypedef = t.CSizeT
|
||||
sizet: t.CTypedef = t.CSizeT
|
||||
size_t: t.CTypedef = sizet
|
||||
uzt: t.CTypedef = sizet
|
||||
int8: t.CTypedef = t.CInt8T
|
||||
int16: t.CTypedef = t.CInt16T
|
||||
int32: t.CTypedef = t.CInt32T
|
||||
@@ -56,3 +39,22 @@ uintleast8: t.CTypedef = t.CUIntLeast8T
|
||||
uintleast16: t.CTypedef = t.CUIntLeast16T
|
||||
uintleast32: t.CTypedef = t.CUIntLeast32T
|
||||
uintleast64: t.CTypedef = t.CUIntLeast64T
|
||||
|
||||
# C 基础类型名裸名别名(裸名家族,不随 import 注入;编译器最后匹配本文件兜底解析)
|
||||
# 目标 x86_64-pc-windows-gnu(Windows/mingw-w64,LLP64):
|
||||
# uchar = 8 位无符号(t.CUnsignedChar,固定 Size=8;C 的 unsigned char)
|
||||
# short = 16 位有符号(t.CShort,固定 Size=16)
|
||||
# ushort = 16 位无符号(t.CUnsignedShort,固定 Size=16)
|
||||
# uint = u32,32 位无符号(等价 uint32/u32,底层 t.CUnsignedInt Size=32)
|
||||
# long = 32 位有符号(t.CLong,Size 由 t.configure_platform 依 triple 置 32)
|
||||
# ulong = 32 位无符号(t.CUnsignedLong,Size 由 t.configure_platform 依 triple 置 32)
|
||||
# longlong = 64 位有符号(t.CLongLong,固定 Size=64)
|
||||
# ulonglong = 64 位无符号(t.CUnsignedLongLong,固定 Size=64)
|
||||
uchar: t.CTypedef = t.CUnsignedChar
|
||||
short: t.CTypedef = t.CShort
|
||||
ushort: t.CTypedef = t.CUnsignedShort
|
||||
uint: t.CTypedef = t.CUnsignedInt
|
||||
long: t.CTypedef = t.CLong
|
||||
ulong: t.CTypedef = t.CUnsignedLong
|
||||
longlong: t.CTypedef = t.CLongLong
|
||||
ulonglong: t.CTypedef = t.CUnsignedLongLong
|
||||
Reference in new issue
Block a user