GithubHelp home page GithubHelp logo

phunanon / chika Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 2.0 1.06 MB

S-expression programming language with VM targeting both PC and Arduino.

Home Page: https://phunanon.github.io/Chika

License: GNU General Public License v3.0

C++ 99.24% Shell 0.76%
arduino lisp operating-system os programming-language

chika's People

Contributors

phunanon avatar thelazurite-cell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chika's Issues

Globalise exeForm paramaters

Currently, on a 32-bit system, ChVM::exeForm requires 24B for parameters and 5B for locals.
Firstly, IType type before evaluating next argument can be made global, as can probably uint8_t* f. This would cut down the params to 16B and locals to 4B.

Next, itemnum firstParam and itemnum nArg can be managed through a bespoke stack, so that per function call these exist only once and not per every form.
Locals formCode, firstArgItem, and formData can be put on a bespoke stack also.

Finally, as the compiler is aware of the depth of recur's, implicit and explicit returns, it could inform the VM on how far to unroll.

Extend `if` for multiple conditionals

Syntax

(if cond1 (form)) //nil if false
(if cond1 (form1) (else))

(if
  cond1 (form1)
  cond2 (form2)
  ...
  (else))

Implementation

Extending the already existing if special form. Evaluates all true conditions' forms, or if no conditions were true the else form. May be possible to avoid inflation of SpecialFormData.

Investigate `ChVM::iBytes` global offset per native operation

It may be possible to have most native operations accept no parameters, as ChVM::iBytes et al could be globally configured with a pre-calculated byte offset. Then native operations, instead of using p0, p0 + 1, etc, could use i(0), i(1). This would not only simplify code, but pay off in performance as most op's right now calculate a byte offset repeatedly through ChVM::i or ChVM::iBytes.

Use s-forms for op's like `len`, to mitigate stack copies, using consts

Currently very innocuous op's like len, nth, type, not have their arguments duplicated to the stack before selecting only a small amount of data from them. A new special form for certain op's could ensure parameters and variable bindings are instead served as constants where appropriate. Even sect could benefit from this, with major rewriting.

Implement basic file IO: `file-read`, `file-write`, `file-append`

Syntax

(file-read "file path") => blob of file contents or nil
(file-write "file path" blob) => boolean of success
(file-append "file path" blob) => boolean of success

Implementation

The ChVM harness will expose these three functions for the same file system dependency as loading programs.

Implement `case` special form

Syntax

(case value
  case1 (form)
  case2 (form)
  ...
  (else form))

Implementation

As special form, providing short-circuited evaluation. Evaluates the form of the first matching value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.