Skip to main content

Logic

Compiling Logic​

CommandDescription
compile <name>Compile the coco.nut project in the current directory
compile <name> from coco(<path>)Compile the project that holds the file at <path>
compile <name> from manifest(<path or 0x hex>)Load a manifest: .yaml, .yml, .json, .polo or POLO hex
>>> compile ContextFlipper
logic 'ContextFlipper' [0xbe8f...47ee] compiled with 345 FUEL

<name> is what the session calls the logic, and it doesn't have to match [module] name.

compile <name> and from coco(...) compile inside Cocolab, so coco doesn't need to be on PATH and no manifest file is written. Relative imports resolve from the project, even when you compile from another directory, and [target.pisa] version is honored. They always compile at -O2. For another level, run coco compile -O <level> and load the result with from manifest(...).

from coco(...) only uses the directory of the path, and it always compiles the whole project. coco(sub/calc.coco) and coco(sub/coco.nut) do the same thing.

Name a file, not a folder

coco(sub) and coco(sub/) don't compile the project in sub. The path resolves to its parent directory, so they compile the project in the current directory without reporting an error.

Changed in v0.9.4

Before v0.9.4, compile <name> and from coco(...) ran the first coco on PATH and read back the manifest it wrote.

Compile errors​

SituationMessage
Bad source or coco.nuterror: FAILED to compile <details>
Path doesn't existerror: Read error `<path>`: No such file or directory (os error 2)
No [target] section in coco.nutno [target] section in the coco.nut file
Target architecture isn't PISAonly PISA target architecture is supported, requested '<arch>'
Invalid JSON manifestFailed to deserialize json manifest: ...

Viewing Logics​

CommandDescription
logicsList all loaded logics
get <name>Show logic details (endpoints, ID, state)
>>> logics
[0] ContextFlipper [0xbe8f...47ee]

>>> get ContextFlipper
===== [ ContextFlipper ] [Address: 0xbe8f...47ee]
[Edition: 0] [Logic ID: 0x0400...47ee]
[Engine: PISA] [Manifest: e83f...defc]
[Ready: true] [Persistent: false] [Ephemeral: false]
===== [Endpoints]
[0] invoke Flip() -> ()
[1] invoke Mode() -> (value bool)
[2] invoke Set(value bool) -> ()
=====

get also lists a module's functions and class methods. Functions show as internal, and methods have a blank kind. Only endpoints can be called, so neither can be invoked.

[1]  Get() -> (v u64)
[4] internal helper(a u64) -> (b u64)

Removing Logics​

CommandDescription
wipe logicsRemove all logics
wipe <name>Remove specific logic