load.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>Test Page</title>
  6. <script type="text/javascript" src="build/dev/runtime.js"></script>
  7. <script type="text/javascript">
  8. /*
  9. Object.assign(window, KumaChan)
  10. var_declare = (scope, name, value) => KumaChan.var_declare(scope)(name,value)
  11. var_assign = (scope, name, value) => KumaChan.var_assign(scope)(name,value)
  12. var_lookup = (scope, name) => KumaChan.var_lookup(scope)(name)
  13. let f = fun('local f (Int x, Int y) -> Int', (x,y) => x+y)
  14. console.log(f(1,2))
  15. let F = sig([G.Int, G.Int], G.Int)
  16. console.log(is(f,F))
  17. let g = fun('local f(List &x, Int y) -> Void', (x,y) => (x.push(y),G.Void) )
  18. console.log(is(g, sig([G.List, G.String], G.Void)))
  19. console.log(g([],1))
  20. let A = create_class('A', [], fun('local init() -> Any', s=>var_declare(s,'abc',123)), { m1: fun('local m1() -> Int', s=>s.lookup('abc')) })
  21. console.log(A.create())
  22. let I1 = create_interface('I1',{m1:sig([],G.Int),m2:fun('local m2 () -> Int', s=> { return (s.lookup('m1'))()*2 + 1 } )})
  23. let C = create_class('C', [I1], fun('local init() -> Any', s=>var_declare(s,'def',4567)), { m1: fun('local m1() -> Int', s=>var_lookup(s,'def')) })
  24. console.log(call_method(Global,call(C,[]),'m2',[]))
  25. let I = create_interface('I',{q:sig([],G.String)})
  26. let D = create_class('D', [I], fun('local init() -> Any', s=>var_declare(s,'uv','gergveriner')), { q: fun('local q() -> String', s=>var_lookup(s,'uv')+'cfergv') })
  27. let X = create_class('X',[D,I],fun('local init() -> Any',(s,expose)=> { let d = D.create(); expose(d); } ), { v: fun('local v () -> Int', s=>999) } )
  28. let x = call(X,[])
  29. console.log(x)
  30. console.log(call_method(Global,x,'v',[]), x.methods.q())
  31. */
  32. </script>
  33. </head>
  34. <body>
  35. <h1>我能吞下玻璃而不傷身體</h1>
  36. <p>KumaChan Programming Language (Refactor Version)</p>
  37. </body>
  38. </html>