Coder Social home page Coder Social logo

deeplang-org / deeplang Goto Github PK

View Code? Open in Web Editor NEW
79.0 79.0 16.0 1.7 MB

Deeplang is a new language for IoT device programming.

Home Page: http://www.deeplang.org

License: BSD 3-Clause "New" or "Revised" License

iot lite memory-safe programming-language vm

deeplang's People

Contributors

allanzyne avatar chiakicage avatar chinesebear avatar chrisslu avatar diaozhongpu avatar ignorancer avatar mmzk1526 avatar qwe12369 avatar thomasyonug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deeplang's Issues

add deeplang v0.2 features

将静态结构化类型\代数数据类型-ADT\委托\鸭子类型的相关特性添加到readme中.

数组指定类型的语法设计

相比 let arr: [i32;10] = [];,这样 let arr: i32[10] = []; 是否更易读呢?另外,请问 i32;10 用分号分隔而不是逗号有何特别原因吗?

deep

Describe the bug
int deep_wasm_eval (uint8 * wasm_buf, uint32 wasm_size);
call deep_wasm_eval error.

To Reproduce
Steps to reproduce the behavior:

  1. build dp
  2. ./dp example/method_call.dp

Expected behavior
finish and return 0;

Errors/Logs

/Users/yangwenzhang/workspace/deeplang/src/vm/deep_wasm_main.c:89, deep_wasm_eval(), [wasm_buf]: length = 128 (0x80)

    0x7ff73ae111f0  00 61 73 6D 01 00 00 00 - 01 0C 03 60 00 00 60 02         | .asm.......`..`.
    0x7ff73ae11200  7F 7F 00 60 00 00 03 04 - 03 00 01 00 07 14 03 03         | ...`............
    0x7ff73ae11210  66 6F 6F 00 00 03 62 61 - 72 00 01 04 6D 61 69 6E         | foo...bar...main
    0x7ff73ae11220  00 02 0A 4C 03 11 02 01 - 7F 01 7F 41 01 21 00 41         | ...L.......A.!.A
    0x7ff73ae11230  0A 20 00 6A 21 01 0B 21 - 05 01 7F 01 7F 01 7F 01         | . .j!..!........
    0x7ff73ae11240  7F 01 7F 41 02 21 02 41 - 05 21 03 20 03 20 02 20         | ...A.!.A.!. . . 
    0x7ff73ae11250  01 20 00 6A 6A 6A 21 04 - 0B 16 02 01 7F 01 7F 41         | . .jjj!........A
    0x7ff73ae11260  E3 00 21 00 41 E4 00 21 - 01 20 00 20 01 10 01 0B         | ..!.A..!. . ....

/Users/yangwenzhang/workspace/deeplang/src/vm/wasm_memory.c:111, wasm_runtime_malloc(), wasm_runtime_malloc failed: memory hasn't been initialized.

WASM module load failed: allocate memory failed.

Additional context
nop

[proposal] new interface in deeplang

  • discuss interface solution
  • update deeplang SPEC
  • plan of interface implementation

非侵入式接口

interface I {
    fun f()
    // var f: ()->unit
}

class Foo {
    fun f() {
        println("")
    }
}

class Bar implements I {
    fun f()
}

fun useI(i: I) {
    i.f()
}

useI( new Foo() )

struct String {
    fun f() {}
}

enum Color {
    fun f() {}
}

扩展

extension

在原来类型的基础上,添加新的函数。

class Foo {
}

extension Foo {
    fun run() {
        this.xxxx
    }
}
/*
fun Foo_run(this: Foo) {

}
*/

extension Foo {
    fun f() {}
}

fun main() {
    let x = new Foo()
    x.run()
    useI( new Foo() )
}

extension Foo implements I {
    fun f() {}
}

extension String {
    fun reverse() -> String {
        .....
    }
}

"123".reverse()

委托

将一个子字段field的成员(field,method)都委托到当前层级。

class A {
    let x: Int
    fun hello() {
        ......
    }
    fun f() {}
}

// class B : A {}

class B {
    as let a: A
}

let b = new B()
b.x // b.a.x
b.hello() // b.a.hello()
b.f()

useI( b )

// 如果委托的字段,有重现同名的成员(field,method),这个同名的成员就不会被委托。
class C {
    fun f() {}
}

class B {
    as let a: A
    as let c: C
    fun f() {
        c.f()
    }
}

struct D {
    fun f() {}
}

struct E {
    as let d: D
}
type A struct {
    v int
}

type B struct {
    A
}

"print" method support in deepvm frontend

"print" in frontend ,"puts" in backend.
"puts" is supported in wasm vm( backend).

  • build type/feature adding framework in deepvm frontend
  • add print feature
  • test print function

[proposal] control flow design

控制流

// now
if expr { 
  expr
} else { 
  expr
}

expr ? expr : expr
// new
func name() {
}
keyword name() {
}
=>
keyword () {
}
<=>
if () {}
for () {}
// c
if (expr) expr
for (expr) expr
fun (params) expr

keyword () (expr|'{' expr* '}')
// if
if (expr) expr else expr // expr ? expr : expr
if (expr) { expr } else { expr }
// for 
for (expr) expr
for (expr) { expr }
// while
while () expr
// fun
fun (params) expr // (parmas) => expr
fun (params) { expr } // (parmas) => { expr }

// change 
if (else if) else // else if
if expr {} else if expr {} else {}
if (expr) expr else ifexpr // == 'if (expr) {} else {}'' // 不需要定义 else if

// fun decl
let f = fun (params) f() // 因为是 let,所以可以优化成函数声明,可以递归
==> 
fun f(params) { return f() } // 等价于上面,可以递归

let mut f2 = fun (params) expr // 不能递归 f2
// 变量定义 | 类型定义

let fn = fun(arr:[int]) for(i in arr) if (i % 2 == 0 ) print(i)

let main = fun() expr

Rules for using issues

  • Always assign the issue to this project
  • Add label and assignee accordingly.
  • Try to use check box to list subtasks. You can click on it when the subtask is completed. Syntax
- [ ] this is a subtask
- [x] this is a completed subtask

[proposal] new enum type in deeplang

KOKA

struct A {
    v1 : string
    v2 : int
    // and
}

enum B {
    v1
    v2
    // or
}

let a : A = A{"123", 2}
let b : B = B.v1

enum C {
    v1(string)
    v2(int)
}
let c : C = C.v1("321")

enum Option<T> {
    None
    Some(T)
}
class Foo{ func f(){} }
var x : Foo = new Foo()
// x = Foo
var y : Option<Foo> = new Foo()
// y = Option.None
// y = Option.Some
var z : Foo? = new Foo()
z?.f()?.g()?.h()
let o : Foo = z ?? new Foo() // orElse(new Foo())
--->
match z {
    case Some(let v) => v.f()
    case None => break
}

enum Result<T> {
    Failure(Error)
    Success(T)
}

func DoSomething() -> Result<Foo> {...}
let a = DoSomething()
match a {
    case Success(let v) => v.f()
    case Failure(let log) => log.Print()
}


// new syntax
type id<T> {
    item
    item
}

type Option<T> {
    none
    some(T)
}

type Person {
    person(String, Int)
}

type Person((String, String), Int)

type Person(name: String, age: Int)
-->
struct Person {
    name: String
    age: Int
}

type Body {
    v1
    v2
}

type id {
    item(label: T1, label2: T2)
    item2(label2: T3)
}
class Foo {
    let a : Int = 1
    let mut b = f // ???
    func f(){} // this (Foo, ()) -> ()  => () -> () 
}
// KOKA 
func NewFoo() -> Foo {...}
type Foo (
    a : Int = 1,
    b : () -> () = () => () 
) {
    func f(){}
}

type f_Interface {
    func f(){}
}

type id [
    item(label: T1, label2: T2),
    item2(label2: T3)
] {
    func f(){}
}

Analyse Intel's WASM VM code

基本类型里面是否去掉char或者改成32位

文档里面有char这个基本类型,一般char用来表示一个字符,但是char只有16位,是不足以完整表示一个字符的,一个u32/i32 才能完整存储一个字符。是否去掉char类型,直接用i32。或者保留char, 像rust一样,char改成32位。

最早的unicode版本收录的字符少,16位就够了,后面unicode已经有100万+字符了,16位完全不够。这个时候,用16位的char就完全不够了。改成32位是一个比较好的选择

merge vm codes form wasmvm branch

wasmvm代码合入dev分支

  • add deep_wasm_eval ,可以执行在buffer中的wasm文件;
  • wait for print ready, #6
  • happy merge vm codes & test in deepvm

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.