| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- static int32_t num32 = 32; //static is accepted but ignored
- static int32_t count32; //C/C++ style declarations
- print(num32, count32);
- int32_t doIt(int32_t a, char_t b) //C/C++ style declarations
- {
- static int32_t i =0; //static is accepted but ignored, inside functions a warning is emmited
- print("doIt", i, a, b);
- }
- doIt(3, "dad");
- void_t sleepOnly(uint16_t sec)
- {
- print("sleeping", sec);
- }
- sleepOnly(12);
- class K
- {
- v1 = 0;
- v2 = 0;
-
- function f1(){}
- }
- struct Person //struct is handled internally as a class
- {
- int32_t age; //C/C++ style declarations
- string_t name;
- int32_t weight;
- };
- Person person;
- Person checkCredit(int64_t id)
- {
- Person p = Person();
- p.name = "Bert";
- return p;
- }
- print(checkCredit(12).name);
- class BaseVector {
- constructor(...)
- {
- if(vargv.len() >= 3) {
- x = vargv[0];
- y = vargv[1];
- z = vargv[2];
- }
- }
-
-
- x = 0;
- y = 0;
- z = 0;
- int32_t i32;
- }
- class Vector3 extends BaseVector {
- function _add(other)
- {
- if(other instanceof this.getclass())
- return ::Vector3(x+other.x,y+other.y,z+other.z);
- else
- throw "wrong parameter";
- }
- function Print()
- {
- ::print(x+","+y+","+z+"\n");
- }
-
- bool_t isEmpty()
- {
- return true;
- }
- }
- class Vector4 : public Vector3 //C/C++ style declarations
- {
- bool_t isFull()
- {
- return false;
- }
- }
- local v0 = Vector3(1,2,3)
- local v1 = Vector3(11,12,13)
- local v2 = v0 + v1;
- v2.Print();
- print(v2.isEmpty());
- Vector4 v4 = Vector4();
- print(v4.isFull());
- FakeNamespace <- {
- Utils = {}
- }
- class FakeNamespace.Utils.SuperClass {
- constructor()
- {
- ::print("FakeNamespace.Utils.SuperClass")
- }
- }
- local testy = FakeNamespace.Utils.SuperClass();
|