diff options
author | chai <chaifix@163.com> | 2018-06-08 18:26:18 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-06-08 18:26:18 +0800 |
commit | 4e9d6b9a1b416c5ca31b441a2bcf40c214da1658 (patch) | |
tree | b06094a86d655add176cc2f427f168dbdf755ec9 | |
parent | 726fa81bf2597aa4b3d14a89915993eaa9d62908 (diff) |
增加mask
-rw-r--r-- | lls/lls.c | 3 | ||||
-rw-r--r-- | test/hello.lls | 67 |
2 files changed, 67 insertions, 3 deletions
@@ -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 + @@ -266,4 +266,67 @@ 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 , +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |