From 4e9d6b9a1b416c5ca31b441a2bcf40c214da1658 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 8 Jun 2018 18:26:18 +0800 Subject: =?UTF-8?q?=E5=A2=9E=E5=8A=A0mask?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lls/lls.c | 3 ++- test/hello.lls | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/lls/lls.c b/lls/lls.c index 8599cfd..a34b5e6 100644 --- a/lls/lls.c +++ b/lls/lls.c @@ -18,7 +18,8 @@ typedef struct int type; union { - float _real; + int _integer; + float _decimal; char* _string; char _bool; void* _set; diff --git a/test/hello.lls b/test/hello.lls index c29ff3c..1124b43 100644 --- a/test/hello.lls +++ b/test/hello.lls @@ -142,10 +142,10 @@ Bat += { /* 或者下面这样,可以实现多重继承 -Bat = new Monster + { +Bat = Monster + { fly = 20, wings = true, -} + new Foo; +} + Foo; Bat = Monster + Foo + @@ -265,5 +265,68 @@ Bird = { bird = new Bird; bird:fly(); // 或者限制函数只能拷贝地址 + +// 枚举和mask会在编译时被替换为数字 +// 枚举 +local /* global */enum { + STAT_BOY = 01, + STAT_MAN = 010, + STAT_WOMAN = 0100, + STAT_TALL = 01000, + STAT_SMART = 010000, +} +// 等价于下面的 +// 掩码 +local /* global */mask { + STAT_BOY , + STAT_MAN , + STAT_WOMAN , + STAT_TALL , + STAT_SMART , +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1-26-g67d0