Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // copper.spark:
- .name COPPER
- USE standard;
- NATIVE print(…);
- OBJ demo1 : "object";
- OBJ demo2 : "object";
- PUB main() | i : INT
- BEGIN
- demo1.setGlobal(10);
- demo1.setStatic(15);
- demo1.setShared(20);
- demo2.setGlobal(30);
- demo2.setStatic(35);
- demo2.setShared(40);
- print(demo1.getGlobal(), "\n");
- print(demo1.getStatic(), "\n");
- print(demo1.getShared(), "\n");
- print(demo2.getGlobal(), "\n");
- print(demo2.getStatic(), "\n");
- print(demo2.getShared(), "\n");
- END
- // object.cu
- .name object
- GLOBAL VAR global : INT;
- STATIC VAR static : INT;
- SHARED VAR shared : INT;
- PUB setGlobal(i : INT)
- BEGIN
- i → global;
- END
- PUB setShared(i : INT)
- BEGIN
- i → shared;
- END
- PUB getGlobal() → i : INT
- BEGIN
- global → i;
- END
- PUB getShared() → i : INT
- BEGIN
- shared → i;
- END
- PUB setStatic(i : INT)
- BEGIN
- i → static;
- END
- PUB getStatic() → i : INT
- BEGIN
- static → i;
- END
- // copper.spark:
- ; =============================================
- ; compiled with Copper 1.0
- ; 2015-11-20 11:57:25
- ; =============================================
- ; USE /home/felix/projects/Electronics/libs/standard.cul
- ; native method: toInt8(…) → INT8
- ; native method: toInt16(…) → INT16
- ; native method: toInt32(…) → INT32
- ; native method: toUInt8(…) → UINT8
- ; native method: toUInt16(…) → UINT16
- ; native method: toUInt32(…) → UINT32
- .name COPPER
- ; native method: print(…)
- .obj demo1 "object"
- .obj demo2 "object"
- ; 1, main
- .export main
- main:
- pushnil ; return value
- pushnil ; i:INT32
- pushi 2 10
- callo demo1 setGlobal 1
- pushi 2 15
- callo demo1 setStatic 1
- pushi 2 20
- callo demo1 setShared 1
- pushi 2 30
- callo demo2 setGlobal 1
- pushi 2 35
- callo demo2 setStatic 1
- pushi 2 40
- callo demo2 setShared 1
- pusht "\n"
- callor demo1 getGlobal 0
- calln print 2
- pusht "\n"
- callor demo1 getStatic 0
- calln print 2
- pusht "\n"
- callor demo1 getShared 0
- calln print 2
- pusht "\n"
- callor demo2 getGlobal 0
- calln print 2
- pusht "\n"
- callor demo2 getStatic 0
- calln print 2
- pusht "\n"
- callor demo2 getShared 0
- calln print 2
- ret
- ; end of main
- // object.spark:
- ; =============================================
- ; compiled with Copper 1.0
- ; 2015-11-20 11:57:15
- ; =============================================
- .name object
- .global global INT32
- .static static INT32
- .shared shared INT32
- ; 1, setGlobal
- .export setGlobal
- setGlobal:
- pushnil ; return value
- load -1
- storeg global
- ret
- ; end of setGlobal
- ; 1, setShared
- .export setShared
- setShared:
- pushnil ; return value
- load -1
- storeg shared
- ret
- ; end of setShared
- ; 1, getGlobal
- .export getGlobal
- getGlobal:
- pushnil ; return value
- loadg global
- store 0
- load 0
- retr
- ; end of getGlobal
- ; 1, getShared
- .export getShared
- getShared:
- pushnil ; return value
- loadg shared
- store 0
- load 0
- retr
- ; end of getShared
- ; 1, setStatic
- .export setStatic
- setStatic:
- pushnil ; return value
- load -1
- storeg static
- ret
- ; end of setStatic
- ; 1, getStatic
- .export getStatic
- getStatic:
- pushnil ; return value
- loadg static
- store 0
- load 0
- retr
- ; end of getStatic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement