Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Tagged as

ObjectScript: A new programming language

, 9 Oct 2012 MIT
The ObjectScript is a new programing language that mixes benefits of JavaScript, Lua, and PHP. The ObjectScript has syntax from JavaScript, multiple results from Lua, OOP from PHP and much more.
OS-0.98-rc-noexe.ZIP
OS
examples-os
add_user_module.os
bind.os
core.os
run_os_prog.os
test.os
proj.win32
add_user_module
add_user_module.vcxproj.filters
os
os.vcxproj.filters
osbind
osbind.vcxproj.filters
profile_benchmark
profile_benchmark.vcxproj.filters
scripts
test_fannkuch.lua
test_fannkuch.os
run_os_prog
run_os_prog.vcxproj.filters
stack_usage
stack_usage.vcxproj.filters
README.md
source
os-binder-FunctionClassImp.tpl
os-binder-FunctionImp.tpl
os-binder-FunctionImpVoid.tpl
OS-0.98-rc.ZIP
bin
os.exe
add_user_module.os
bind.os
core.os
run_os_prog.os
test.os
Makefile
add_user_module.vcxproj.filters
os.vcxproj.filters
osbind.vcxproj.filters
profile_benchmark.vcxproj.filters
test_fannkuch.lua
test_fannkuch.os
run_os_prog.vcxproj.filters
stack_usage.vcxproj.filters
README.md
os-binder-FunctionClassImp.tpl
os-binder-FunctionImp.tpl
os-binder-FunctionImpVoid.tpl
unitpoint-objectscript-86f30d7-noexe.zip
unitpoint-objectscript-86f30d7
.gitignore
README.md
bin
.gitignore
examples-os
add_user_module.os
bind.os
core.os
run_os_prog.os
test.os
proj.win32
.gitignore
add_user_module
.gitignore
os
.gitignore
test_fannkuch.osc
test_fannkuch.osd
osbind
.gitignore
profile_benchmark
.gitignore
scripts
test_fannkuch.lua
test_fannkuch.os
run_os_prog
.gitignore
stack_usage
.gitignore
source
.gitignore
os-binder-FunctionClassImp.tpl
os-binder-FunctionImp.tpl
os-binder-FunctionImpVoid.tpl
unitpoint-objectscript-86f30d7.zip
.gitignore
Makefile
README.md
.gitignore
os.exe
add_user_module.os
bind.os
core.os
run_os_prog.os
test.os
.gitignore
.gitignore
.gitignore
test_fannkuch.osc
test_fannkuch.osd
.gitignore
.gitignore
test_fannkuch.lua
test_fannkuch.os
.gitignore
.gitignore
.gitignore
os-binder-FunctionClassImp.tpl
os-binder-FunctionImp.tpl
os-binder-FunctionImpVoid.tpl
[FILE] ../../examples-os/test.os
[2] print(5 " differences")

begin function
  begin locals, total 48
    0 _E
    1 _G
    32 Person
    33 p
    34 IvanPerson
    35 p
    36 vec3
    37 v1
    38 v2
    39 v3
    43 a
    44 transform
    45 core
    46 __planet
    47 testFunc
  end locals
  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const number 5
      ,
      push const string " differences"
    end params ret values 3
  end call method ret values 0


[5] var i = 4

  begin scope
    begin locals 4
      2 i
      3 name
      4 count
      5 time
    end locals
    begin set local var
      push const number 4
    end set local var i (2 0)


[7] var name, count, time = "Smith", 3 + 2/i, 1.23

    begin set local var
      begin set local var
        begin set local var
          begin params 3
            push const string "Smith"
            ,
            begin operator +
              push const number 3
              begin operator /
                push const number 2
                get local var i (2 0)
              end operator /
            end operator +
            ,
            push const number 1.23
          end params ret values 3
        end set local var time (5 0)
      end set local var count (4 0)
    end set local var name (3 0)


[9] print concat("name: " name ", count: " count ", time: " time)

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin call method
          get local var _E (0 0)
          begin params 7
            push const string "concat"
            ,
            push const string "name: "
            ,
            get local var name (3 0)
            ,
            push const string ", count: "
            ,
            get local var count (4 0)
            ,
            push const string ", time: "
            ,
            get local var time (5 0)
          end params ret values 7
        end call method ret values 1
      end params ret values 2
    end call method ret values 0
  end scope ret values 0


[13] print {firstname="Ivan" lastname="Petrov"}

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin object 2
        begin set by name
          push const string "Ivan"
        end set by name: [firstname]
        ,
        begin set by name
          push const string "Petrov"
        end set by name: [lastname]
      end object
    end params ret values 2
  end call method ret values 0


[17] var a = {x=1, y=3; "zero" "one", "two" last:7,}

  begin scope
    begin locals 11
      6 a
      7 b
      8 i
      9 j
      10 k
      11 test
      12 a
      13 b
      14 a
      15 b
      16 c
    end locals
    begin set local var
      begin object 6
        begin set by name
          push const number 1
        end set by name: [x]
        ,
        begin set by name
          push const number 3
        end set by name: [y]
        ,
        begin set auto index
          push const string "zero"
        end set auto index
        ,
        begin set auto index
          push const string "one"
        end set auto index
        ,
        begin set auto index
          push const string "two"
        end set auto index
        ,
        begin set by name
          push const number 7
        end set by name: [last]
      end object
    end set local var a (6 0)


[18] print a[1]

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin get property by local & number
          get local var a (6 0)
          push const number 1
        end get property by local & number ret values 1
      end params ret values 2
    end call method ret values 0


[19] print a

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        get local var a (6 0)
      end params ret values 2
    end call method ret values 0


[22] a = {[2+3]="five" y=3}

    begin set local var
      begin object 2
        begin set by exp
          push const number 5
          push const string "five"
        end set by exp
        ,
        begin set by name
          push const number 3
        end set by name: [y]
      end object
    end set local var a (6 0)


[23] print a[5]

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin get property by local & number
          get local var a (6 0)
          push const number 5
        end get property by local & number ret values 1
      end params ret values 2
    end call method ret values 0


[24] print a

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        get local var a (6 0)
      end params ret values 2
    end call method ret values 0


[26] a = {x=1 y=2}

    begin set local var
      begin object 2
        begin set by name
          push const number 1
        end set by name: [x]
        ,
        begin set by name
          push const number 2
        end set by name: [y]
      end object
    end set local var a (6 0)


[28] var b = {[a]="powerful" 7="greate"}

    begin set local var
      begin object 2
        begin set by exp
          get local var a (6 0)
          push const string "powerful"
        end set by exp
        ,
        begin set by index
          push const string "greate"
        end set by index: [7]
      end object
    end set local var b (7 0)


[29] print b[a]

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin get property by locals
          get local var b (7 0)
          get local var a (6 0)
        end get property by locals ret values 1
      end params ret values 2
    end call method ret values 0


[31] print([10, 20, 30, 40])

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin array 4
          begin set auto index
            push const number 10
          end set auto index
          ,
          begin set auto index
            push const number 20
          end set auto index
          ,
          begin set auto index
            push const number 30
          end set auto index
          ,
          begin set auto index
            push const number 40
          end set auto index
        end array
      end params ret values 2
    end call method ret values 0


[33] print([10 20 30 40])

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin array 4
          begin set auto index
            push const number 10
          end set auto index
          ,
          begin set auto index
            push const number 20
          end set auto index
          ,
          begin set auto index
            push const number 30
          end set auto index
          ,
          begin set auto index
            push const number 40
          end set auto index
        end array
      end params ret values 2
    end call method ret values 0


[36] var i, j, k = 0, 1, 3

    begin set local var
      begin set local var
        begin set local var
          begin params 3
            push const number 0
            ,
            push const number 1
            ,
            push const number 3
          end params ret values 3
        end set local var k (10 0)
      end set local var j (9 0)
    end set local var i (8 0)


[37] echo("i="i", j="j", k="k"\n")

    begin call method
      get local var _E (0 0)
      begin params 8
        push const string "echo"
        ,
        push const string "i="
        ,
        get local var i (8 0)
        ,
        push const string ", j="
        ,
        get local var j (9 0)
        ,
        push const string ", k="
        ,
        get local var k (10 0)
        ,
        push const string "
"
      end params ret values 8
    end call method ret values 0


[40] i, j = j, i

    begin set local var
      begin set local var
        begin params 2
          get local var j (9 0)
          ,
          get local var i (8 0)
        end params ret values 2
      end set local var j (9 0)
    end set local var i (8 0)


[41] echo("after swap: i="i", j="j"\n")

    begin call method
      get local var _E (0 0)
      begin params 6
        push const string "echo"
        ,
        push const string "after swap: i="
        ,
        get local var i (8 0)
        ,
        push const string ", j="
        ,
        get local var j (9 0)
        ,
        push const string "
"
      end params ret values 6
    end call method ret values 0


[44] var test = function(){ return 1, 2 }

    begin set local var
      begin function
        begin locals, total 2
          0 _E
          1 _G
        end locals
        begin return
          push const number 1
          ,
          push const number 2
        end return values 2
      end function
    end set local var test (11 0)


[45] var a, b = test()

    begin set local var
      begin set local var
        begin call
          get local var test (11 0)
          begin params 0
          end params ret values 0
        end call ret values 2
      end set local var b (13 0)
    end set local var a (12 0)


[46] print("results from function" "a="..a "b="..b)

    begin call method
      get local var _E (0 0)
      begin params 4
        push const string "print"
        ,
        push const string "results from function"
        ,
        begin operator ..
          push const string "a="
          get local var a (12 0)
        end operator ..
        ,
        begin operator ..
          push const string "b="
          get local var b (13 0)
        end operator ..
      end params ret values 4
    end call method ret values 0


[49] var a, b, c = test()

    begin set local var
      begin set local var
        begin set local var
          begin call
            get local var test (11 0)
            begin params 0
            end params ret values 0
          end call ret values 3
        end set local var c (16 0)
      end set local var b (15 0)
    end set local var a (14 0)


[50] print("results from function" "a="..a "b="..b "c="..c)

    begin call method
      get local var _E (0 0)
      begin params 5
        push const string "print"
        ,
        push const string "results from function"
        ,
        begin operator ..
          push const string "a="
          get local var a (14 0)
        end operator ..
        ,
        begin operator ..
          push const string "b="
          get local var b (15 0)
        end operator ..
        ,
        begin operator ..
          push const string "c="
          get local var c (16 0)
        end operator ..
      end params ret values 5
    end call method ret values 0
  end scope ret values 0


[54] print "Object iterator test"

  begin scope
    begin locals 2
      17 obj
      26 range
    end locals
    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        push const string "Object iterator test"
      end params ret values 2
    end call method ret values 0


[55] var obj = { null awesome=true 12 "excellent" }

    begin set local var
      begin object 4
        begin set auto index
          const null
        end set auto index
        ,
        begin set by name
          const true
        end set by name: [awesome]
        ,
        begin set auto index
          push const number 12
        end set auto index
        ,
        begin set auto index
          push const string "excellent"
        end set auto index
      end object
    end set local var obj (17 0)


[56] for(var k, v in obj){

    begin scope
      begin locals 4
        18 k
        19 v
        20 #func
        21 #valid
      end locals
      new local var k (18 0)

      new local var v (19 0)

      new local var #func (20 0 temp)

      new local var #valid (21 0 temp)

      begin code list
        begin set local var
          begin call method
            get local var obj (17 0)
            begin params 1
              push const string "__iter"
            end params ret values 1
          end call method ret values 1
        end set local var #func (20 0 temp)

        begin loop
          begin set local var
            begin set local var
              begin set local var
                begin call
                  get local var #func (20 0 temp)
                  begin params 0
                  end params ret values 0
                end call ret values 3
              end set local var v (19 0)
            end set local var k (18 0)
          end set local var #valid (21 0 temp)

          begin if
            begin bool exp
              begin logic not
                get local var #valid (21 0 temp)
              end logic not
            end bool exp
            begin then
              break
            end then
          end if ret values 0


[57] print( k " --> " v )

          begin scope
            begin call method
              get local var _E (0 0)
              begin params 4
                push const string "print"
                ,
                get local var k (18 0)
                ,
                push const string " --> "
                ,
                get local var v (19 0)
              end params ret values 4
            end call method ret values 0
          end scope ret values 0
        end loop ret values 0
      end code list ret values 0
    end scope ret values 0


[60] print "Object iterator test, only keys"

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        push const string "Object iterator test, only keys"
      end params ret values 2
    end call method ret values 0


[61] for(k in obj){

    begin scope
      begin locals 2
        22 #func
        23 #valid
      end locals
      nop

      new local var #func (22 0 temp)

      new local var #valid (23 0 temp)

      begin code list
        begin set local var
          begin call method
            get local var obj (17 0)
            begin params 1
              push const string "__iter"
            end params ret values 1
          end call method ret values 1
        end set local var #func (22 0 temp)

        begin loop
          begin set local var
            begin set env var
              begin call
                get local var #func (22 0 temp)
                begin params 0
                end params ret values 0
              end call ret values 2
            end set env var k
          end set local var #valid (23 0 temp)

          begin if
            begin bool exp
              begin logic not
                get local var #valid (23 0 temp)
              end logic not
            end bool exp
            begin then
              break
            end then
          end if ret values 0


[62] print k

          begin scope
            begin call method
              get local var _E (0 0)
              begin params 2
                push const string "print"
                ,
                get env var k
              end params ret values 2
            end call method ret values 0
          end scope ret values 0
        end loop ret values 0
      end code list ret values 0
    end scope ret values 0


[65] print "Array iterator test"

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        push const string "Array iterator test"
      end params ret values 2
    end call method ret values 0


[66] Array.__iter = function(){

    begin set property
      begin function
        begin locals, total 4
          0 _E
          1 _G
          2 i
          3 self
        end locals

[67] var i, self = 0, this

        begin set local var
          begin set local var
            begin params 2
              push const number 0
              ,
              push this
            end params ret values 2
          end set local var self (3 0)
        end set local var i (2 0)


[68] return function(){

        begin code list
          begin return
            begin function
              begin locals, total 3
                0 _E
                1 _G
              end locals

[69] if(i < #self){

              begin if
                begin bool exp
                  begin logic <
                    get local var i (2 1)
                    begin length
                      get local var self (3 1)
                    end length
                  end logic <
                end bool exp
                begin then

[70] print("... inside of array iter func: " i self[i])

                  begin scope
                    begin locals 1
                      2 #temp
                    end locals
                    begin call method
                      get local var _E (0 0)
                      begin params 4
                        push const string "print"
                        ,
                        push const string "... inside of array iter func: "
                        ,
                        get local var i (2 1)
                        ,
                        begin get property
                          get local var self (3 1)
                          get local var i (2 1)
                        end get property ret values 1
                      end params ret values 4
                    end call method ret values 0


[71] return true, i, self[i++]

                    begin code list
                      begin return
                        const true
                        ,
                        get local var i (2 1)
                        ,
                        begin get property
                          get local var self (3 1)
                          begin code list
                            begin set local var
                              get local var i (2 1)
                            end set local var #temp (2 0)

                            begin set local var
                              begin operator +
                                get local var i (2 1)
                                push const number 1
                              end operator +
                            end set local var i (2 1)

                            get local var #temp (2 0)
                          end code list ret values 1
                        end get property ret values 1
                      end return values 3
                    end code list ret values 0
                  end scope ret values 0
                end then
              end if ret values 0
            end function
          end return values 1
        end code list ret values 0
      end function

[66] Array.__iter = function(){

      get env var auto create Array
      push const string "__iter"
    end set property ret values 0


[75] for(k, v in [10 20 30 40 50]){

    begin scope
      begin locals 2
        24 #func
        25 #valid
      end locals
      nop

      nop

      new local var #func (24 0 temp)

      new local var #valid (25 0 temp)

      begin code list
        begin set local var
          begin call method
            begin array 5
              begin set auto index
                push const number 10
              end set auto index
              ,
              begin set auto index
                push const number 20
              end set auto index
              ,
              begin set auto index
                push const number 30
              end set auto index
              ,
              begin set auto index
                push const number 40
              end set auto index
              ,
              begin set auto index
                push const number 50
              end set auto index
            end array
            begin params 1
              push const string "__iter"
            end params ret values 1
          end call method ret values 1
        end set local var #func (24 0 temp)

        begin loop
          begin set local var
            begin set env var
              begin set env var
                begin call
                  get local var #func (24 0 temp)
                  begin params 0
                  end params ret values 0
                end call ret values 3
              end set env var v
            end set env var k
          end set local var #valid (25 0 temp)

          begin if
            begin bool exp
              begin logic not
                get local var #valid (25 0 temp)
              end logic not
            end bool exp
            begin then
              break
            end then
          end if ret values 0


[76] print( k " --> " v )

          begin scope
            begin call method
              get local var _E (0 0)
              begin params 4
                push const string "print"
                ,
                get env var k
                ,
                push const string " --> "
                ,
                get env var v
              end params ret values 4
            end call method ret values 0
          end scope ret values 0
        end loop ret values 0
      end code list ret values 0
    end scope ret values 0


[79] print("Test array prototype:", [1 2 3].prototype === Array)

    begin call method
      get local var _E (0 0)
      begin params 3
        push const string "print"
        ,
        push const string "Test array prototype:"
        ,
        begin logic ===
          begin get property
            begin array 3
              begin set auto index
                push const number 1
              end set auto index
              ,
              begin set auto index
                push const number 2
              end set auto index
              ,
              begin set auto index
                push const number 3
              end set auto index
            end array
            push const string "prototype"
          end get property ret values 1
          get env var Array
        end logic ===
      end params ret values 3
    end call method ret values 0


[81] print "Test range iterator"

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        push const string "Test range iterator"
      end params ret values 2
    end call method ret values 0


[82] var range = function(a, b){

    begin set local var
      begin function
        begin locals, total 4
          0 a (param)
          1 b (param)
          2 _E
          3 _G
        end locals

[83] return function(){

        begin return
          begin function
            begin locals, total 3
              0 _E
              1 _G
            end locals

[84] if(a <= b){

            begin if
              begin bool exp
                begin logic <=
                  get local var a (0 1 param)
                  get local var b (1 1 param)
                end logic <=
              end bool exp
              begin then

[85] return true, a++

                begin scope
                  begin locals 1
                    2 #temp
                  end locals
                  begin return
                    const true
                    ,
                    begin code list
                      begin set local var
                        get local var a (0 1 param)
                      end set local var #temp (2 0)

                      begin set local var
                        begin operator +
                          get local var a (0 1 param)
                          push const number 1
                        end operator +
                      end set local var a (0 1 param)

                      get local var #temp (2 0)
                    end code list ret values 1
                  end return values 2
                end scope ret values 0
              end then
            end if ret values 0
          end function
        end return values 1
      end function
    end set local var range (26 0)


[89] for(var i in range(10, 13)){

    begin scope
      begin locals 3
        27 i
        28 #func
        29 #valid
      end locals
      new local var i (27 0)

      new local var #func (28 0 temp)

      new local var #valid (29 0 temp)

      begin code list
        begin set local var
          begin call method
            begin call
              get local var range (26 0)
              begin params 2
                push const number 10
                ,
                push const number 13
              end params ret values 2
            end call ret values 1
            begin params 1
              push const string "__iter"
            end params ret values 1
          end call method ret values 1
        end set local var #func (28 0 temp)

        begin loop
          begin set local var
            begin set local var
              begin call
                get local var #func (28 0 temp)
                begin params 0
                end params ret values 0
              end call ret values 2
            end set local var i (27 0)
          end set local var #valid (29 0 temp)

          begin if
            begin bool exp
              begin logic not
                get local var #valid (29 0 temp)
              end logic not
            end bool exp
            begin then
              break
            end then
          end if ret values 0


[90] print "i = "..i

          begin scope
            begin call method
              get local var _E (0 0)
              begin params 2
                push const string "print"
                ,
                begin operator ..
                  push const string "i = "
                  get local var i (27 0)
                end operator ..
              end params ret values 2
            end call method ret values 0
          end scope ret values 0
        end loop ret values 0
      end code list ret values 0
    end scope ret values 0
  end scope ret values 0


[95] print "7 && 9 = "..(7 && 9)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "7 && 9 = "
        begin logic &&
          push const number 7
          push const number 9
        end logic &&
      end operator ..
    end params ret values 2
  end call method ret values 0


[96] print "7 || 9 = "..(7 || 9)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "7 || 9 = "
        begin logic ||
          push const number 7
          push const number 9
        end logic ||
      end operator ..
    end params ret values 2
  end call method ret values 0


[101] var v1 = {x=1 y=2}

  begin scope
    begin locals 2
      30 v1
      31 a
    end locals
    begin set local var
      begin object 2
        begin set by name
          push const number 1
        end set by name: [x]
        ,
        begin set by name
          push const number 2
        end set by name: [y]
      end object
    end set local var v1 (30 0)


[102] var a = {[v1]="vv1" v2="vv2"}

    begin set local var
      begin object 2
        begin set by exp
          get local var v1 (30 0)
          push const string "vv1"
        end set by exp
        ,
        begin set by name
          push const string "vv2"
        end set by name: [v2]
      end object
    end set local var a (31 0)


[103] print( a[v1] a.v2 )

    begin call method
      get local var _E (0 0)
      begin params 3
        push const string "print"
        ,
        begin get property by locals
          get local var a (31 0)
          get local var v1 (30 0)
        end get property by locals ret values 1
        ,
        begin get property
          get local var a (31 0)
          push const string "v2"
        end get property ret values 1
      end params ret values 3
    end call method ret values 0
  end scope ret values 0


[108] var Person = {

  begin set local var
    begin object 3

[109] __construct: function(firstname, lastname){

      begin set by name
        begin function
          begin locals, total 4
            0 firstname (param)
            1 lastname (param)
            2 _E
            3 _G
          end locals

[110] this.firstname = firstname

          begin set property
            get local var firstname (0 0 param)
            push this
            push const string "firstname"
          end set property ret values 0


[111] this.lastname = lastname

          begin set property
            get local var lastname (1 0 param)
            push this
            push const string "lastname"
          end set property ret values 0
        end function
      end set by name: [__construct]
      ,

[113] walk = function(){

      begin set by name
        begin function
          begin locals, total 2
            0 _E
            1 _G
          end locals

[114] print this.fullname .. " is walking!"

          begin call method
            get local var _E (0 0)
            begin params 2
              push const string "print"
              ,
              begin operator ..
                begin get this property by string
                  push this
                  push const string "fullname"
                end get this property by string ret values 1
                push const string " is walking!"
              end operator ..
            end params ret values 2
          end call method ret values 0
        end function
      end set by name: [walk]
      ,

[116] __get@fullname = function(){

      begin set by name
        begin function
          begin locals, total 2
            0 _E
            1 _G
          end locals

[117] return this.firstname .. " " .. this.lastname

          begin return
            begin operator ..
              begin operator ..
                begin get this property by string
                  push this
                  push const string "firstname"
                end get this property by string ret values 1
                push const string " "
              end operator ..
              begin get this property by string
                push this
                push const string "lastname"
              end get this property by string ret values 1
            end operator ..
          end return values 1
        end function
      end set by name: [__get@fullname]
    end object
  end set local var Person (32 0)


[121] var p = Person("James", "Bond")

  begin set local var
    begin call
      get local var Person (32 0)
      begin params 2
        push const string "James"
        ,
        push const string "Bond"
      end params ret values 2
    end call ret values 1
  end set local var p (33 0)


[122] p.walk()

  begin call method
    get local var p (33 0)
    begin params 1
      push const string "walk"
    end params ret values 1
  end call method ret values 0


[123] print p

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      get local var p (33 0)
    end params ret values 2
  end call method ret values 0


[126] var IvanPerson = extends Person {

  begin set local var
    begin extends
      get local var Person (32 0)
      begin object 2

[127] __construct: function(){

        begin set by name
          begin function
            begin locals, total 2
              0 _E
              1 _G
            end locals

[128] super("Ivan", "Petrov")

            begin call
              super
              begin params 2
                push const string "Ivan"
                ,
                push const string "Petrov"
              end params ret values 2
            end call ret values 0
          end function
        end set by name: [__construct]
        ,

[130] walk = function(){

        begin set by name
          begin function
            begin locals, total 2
              0 _E
              1 _G
            end locals

[131] echo "Soneone named "

            begin call method
              get local var _E (0 0)
              begin params 2
                push const string "echo"
                ,
                push const string "Soneone named "
              end params ret values 2
            end call method ret values 0


[132] super()

            begin call
              super
              begin params 0
              end params ret values 0
            end call ret values 0
          end function
        end set by name: [walk]
      end object
    end extends ret values 1
  end set local var IvanPerson (34 0)


[136] var p = IvanPerson()

  begin set local var
    begin call
      get local var IvanPerson (34 0)
      begin params 0
      end params ret values 0
    end call ret values 1
  end set local var p (35 0)


[137] p.walk()

  begin call method
    get local var p (35 0)
    begin params 1
      push const string "walk"
    end params ret values 1
  end call method ret values 0


[138] print p

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      get local var p (35 0)
    end params ret values 2
  end call method ret values 0


[140] print "Person.walk.call"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Person.walk.call"
    end params ret values 2
  end call method ret values 0


[141] Person.walk.call(p)

  begin call method
    begin get property
      get local var Person (32 0)
      push const string "walk"
    end get property ret values 1
    begin params 2
      push const string "call"
      ,
      get local var p (35 0)
    end params ret values 2
  end call method ret values 0


[145] function foo(a, b){ return a + b }

  begin set env var
    begin function
      begin locals, total 4
        0 a (param)
        1 b (param)
        2 _E
        3 _G
      end locals
      begin return
        begin binary operator by locals
          begin operator +
            get local var a (0 0 param)
            get local var b (1 0 param)
          end operator +
        end binary operator by locals
      end return values 1
    end function
  end set env var foo


[146] function bar(){ return foo.apply(null, arguments) }

  begin set env var
    begin function
      begin locals, total 2
        0 _E
        1 _G
      end locals
      begin tail call method
        get env var foo
        begin params 3
          push const string "apply"
          ,
          const null
          ,
          push arguments
        end params ret values 3
      end tail call method
    end function
  end set env var bar


[147] print "should be 5: "..bar(2 3)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "should be 5: "
        begin call method
          get local var _E (0 0)
          begin params 3
            push const string "bar"
            ,
            push const number 2
            ,
            push const number 3
          end params ret values 3
        end call method ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[148] print "should be 9: "..bar(4 5)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "should be 9: "
        begin call method
          get local var _E (0 0)
          begin params 3
            push const string "bar"
            ,
            push const number 4
            ,
            push const number 5
          end params ret values 3
        end call method ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[152] var vec3 = {

  begin set local var
    begin object 3

[153] __construct = function(x, y, z){

      begin set by name
        begin function
          begin locals, total 5
            0 x (param)
            1 y (param)
            2 z (param)
            3 _E
            4 _G
          end locals

[154] this.x = x

          begin set property
            get local var x (0 0 param)
            push this
            push const string "x"
          end set property ret values 0


[155] this.y = y

          begin set property
            get local var y (1 0 param)
            push this
            push const string "y"
          end set property ret values 0


[156] this.z = z

          begin set property
            get local var z (2 0 param)
            push this
            push const string "z"
          end set property ret values 0
        end function
      end set by name: [__construct]
      ,

[158] __add = function(a, b){

      begin set by name
        begin function
          begin locals, total 4
            0 a (param)
            1 b (param)
            2 _E
            3 _G
          end locals

[159] return vec3(a.x + b.x, a.y + b.y, a.z + b.z)

          begin tail call
            get local var vec3 (36 1)
            begin params 3
              begin operator +
                begin get property
                  get local var a (0 0 param)
                  push const string "x"
                end get property ret values 1
                begin get property
                  get local var b (1 0 param)
                  push const string "x"
                end get property ret values 1
              end operator +
              ,
              begin operator +
                begin get property
                  get local var a (0 0 param)
                  push const string "y"
                end get property ret values 1
                begin get property
                  get local var b (1 0 param)
                  push const string "y"
                end get property ret values 1
              end operator +
              ,
              begin operator +
                begin get property
                  get local var a (0 0 param)
                  push const string "z"
                end get property ret values 1
                begin get property
                  get local var b (1 0 param)
                  push const string "z"
                end get property ret values 1
              end operator +
            end params ret values 3
          end tail call
        end function
      end set by name: [__add]
      ,

[161] __mul = function(a, b){

      begin set by name
        begin function
          begin locals, total 4
            0 a (param)
            1 b (param)
            2 _E
            3 _G
          end locals

[162] return vec3(a.x * b.x, a.y * b.y, a.z * b.z)

          begin tail call
            get local var vec3 (36 1)
            begin params 3
              begin operator *
                begin get property
                  get local var a (0 0 param)
                  push const string "x"
                end get property ret values 1
                begin get property
                  get local var b (1 0 param)
                  push const string "x"
                end get property ret values 1
              end operator *
              ,
              begin operator *
                begin get property
                  get local var a (0 0 param)
                  push const string "y"
                end get property ret values 1
                begin get property
                  get local var b (1 0 param)
                  push const string "y"
                end get property ret values 1
              end operator *
              ,
              begin operator *
                begin get property
                  get local var a (0 0 param)
                  push const string "z"
                end get property ret values 1
                begin get property
                  get local var b (1 0 param)
                  push const string "z"
                end get property ret values 1
              end operator *
            end params ret values 3
          end tail call
        end function
      end set by name: [__mul]
    end object
  end set local var vec3 (36 0)


[166] var v1 = vec3(10 20 30)

  begin set local var
    begin call
      get local var vec3 (36 0)
      begin params 3
        push const number 10
        ,
        push const number 20
        ,
        push const number 30
      end params ret values 3
    end call ret values 1
  end set local var v1 (37 0)


[167] var v2 = vec3(1 2 3)

  begin set local var
    begin call
      get local var vec3 (36 0)
      begin params 3
        push const number 1
        ,
        push const number 2
        ,
        push const number 3
      end params ret values 3
    end call ret values 1
  end set local var v2 (38 0)


[168] var v3 = v1 + v2 * v2

  begin set local var
    begin operator +
      get local var v1 (37 0)
      begin binary operator by locals
        begin operator *
          get local var v2 (38 0)
          get local var v2 (38 0)
        end operator *
      end binary operator by locals
    end operator +
  end set local var v3 (39 0)


[169] print "should be {x:11,y:24,z:39} " .. v3

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "should be {x:11,y:24,z:39} "
        get local var v3 (39 0)
      end operator ..
    end params ret values 2
  end call method ret values 0


[172] print "Test properties"

  begin scope
    begin locals 1
      40 a
    end locals
    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        push const string "Test properties"
      end params ret values 2
    end call method ret values 0


[174] var a = {

    begin set local var
      begin object 3

[175] _color = "red"

        begin set by name
          push const string "red"
        end set by name: [_color]
        ,

[176] __get@color = function(){ return this._color }

        begin set by name
          begin function
            begin locals, total 2
              0 _E
              1 _G
            end locals
            begin return
              begin get this property by string
                push this
                push const string "_color"
              end get this property by string ret values 1
            end return values 1
          end function
        end set by name: [__get@color]
        ,

[177] __set@color = function(v){ this._color = v }

        begin set by name
          begin function
            begin locals, total 3
              0 v (param)
              1 _E
              2 _G
            end locals
            begin set property
              get local var v (0 0 param)
              push this
              push const string "_color"
            end set property ret values 0
          end function
        end set by name: [__set@color]
      end object
    end set local var a (40 0)


[181] print "should be red: " .. a["color"]

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin operator ..
          push const string "should be red: "
          begin get property
            get local var a (40 0)
            push const string "color"
          end get property ret values 1
        end operator ..
      end params ret values 2
    end call method ret values 0


[183] a.color = "blue"

    begin set property
      push const string "blue"
      get local var auto create a (40 0)
      push const string "color"
    end set property ret values 0


[184] print "should be blue: " .. a.color

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin operator ..
          push const string "should be blue: "
          begin get property
            get local var a (40 0)
            push const string "color"
          end get property ret values 1
        end operator ..
      end params ret values 2
    end call method ret values 0


[186] a = {

    begin set local var
      begin object 4

[187] _color = "white"

        begin set by name
          push const string "white"
        end set by name: [_color]
        ,

[188] __get = function(name){

        begin set by name
          begin function
            begin locals, total 3
              0 name (param)
              1 _E
              2 _G
            end locals

[189] if(name == "color")

            begin if
              begin bool exp
                begin logic ==
                  get local var name (0 0 param)
                  push const string "color"
                end logic ==
              end bool exp
              begin then

[190] return this._color

                begin code list
                  begin return
                    begin get this property by string
                      push this
                      push const string "_color"
                    end get this property by string ret values 1
                  end return values 1
                end code list ret values 0
              end then
            end if ret values 0
          end function
        end set by name: [__get]
        ,

[192] __set = function(name, v){

        begin set by name
          begin function
            begin locals, total 4
              0 name (param)
              1 v (param)
              2 _E
              3 _G
            end locals

[193] if(name == "color")

            begin if
              begin bool exp
                begin logic ==
                  get local var name (0 0 param)
                  push const string "color"
                end logic ==
              end bool exp
              begin then

[194] this._color = v

                begin set property
                  get local var v (1 0 param)
                  push this
                  push const string "_color"
                end set property ret values 0
              end then
            end if ret values 0
          end function
        end set by name: [__set]
        ,

[196] __del = function(name){

        begin set by name
          begin function
            begin locals, total 3
              0 name (param)
              1 _E
              2 _G
            end locals

[197] if(name == "color")

            begin if
              begin bool exp
                begin logic ==
                  get local var name (0 0 param)
                  push const string "color"
                end logic ==
              end bool exp
              begin then

[198] delete this._color

                begin delete
                  push this
                  push const string "_color"
                end delete
              end then
            end if ret values 0
          end function
        end set by name: [__del]
      end object
    end set local var a (40 0)


[203] print "should be white: " .. a.color

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin operator ..
          push const string "should be white: "
          begin get property
            get local var a (40 0)
            push const string "color"
          end get property ret values 1
        end operator ..
      end params ret values 2
    end call method ret values 0


[204] print "should be null: " .. a.color2

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin operator ..
          push const string "should be null: "
          begin get property
            get local var a (40 0)
            push const string "color2"
          end get property ret values 1
        end operator ..
      end params ret values 2
    end call method ret values 0


[206] a.color = "green"

    begin set property
      push const string "green"
      get local var auto create a (40 0)
      push const string "color"
    end set property ret values 0


[207] print "should be green: " .. a.color

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin operator ..
          push const string "should be green: "
          begin get property
            get local var a (40 0)
            push const string "color"
          end get property ret values 1
        end operator ..
      end params ret values 2
    end call method ret values 0


[209] delete a.color

    begin delete
      get local var a (40 0)
      push const string "color"
    end delete


[210] print "should be null: " .. a.color

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin operator ..
          push const string "should be null: "
          begin get property
            get local var a (40 0)
            push const string "color"
          end get property ret values 1
        end operator ..
      end params ret values 2
    end call method ret values 0


[212] print "Test multi dimensional properties"

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        push const string "Test multi dimensional properties"
      end params ret values 2
    end call method ret values 0


[213] a = {

    begin set local var
      begin object 4

[214] _matrix = {}

        begin set by name
          begin object 0
          end object
        end set by name: [_matrix]
        ,

[215] __getdim = function(x, y){

        begin set by name
          begin function
            begin locals, total 4
              0 x (param)
              1 y (param)
              2 _E
              3 _G
            end locals

[216] return this._matrix[y*4 + x]

            begin return
              begin get property
                begin get this property by string
                  push this
                  push const string "_matrix"
                end get this property by string ret values 1
                begin operator +
                  begin binary operator by local & number
                    begin operator *
                      get local var y (1 0 param)
                      push const number 4
                    end operator *
                  end binary operator by local & number
                  get local var x (0 0 param)
                end operator +
              end get property ret values 1
            end return values 1
          end function
        end set by name: [__getdim]
        ,

[218] __setdim = function(value, x, y){

        begin set by name
          begin function
            begin locals, total 5
              0 value (param)
              1 x (param)
              2 y (param)
              3 _E
              4 _G
            end locals

[219] this._matrix[y*4 + x] = value

            begin set property
              get local var value (0 0 param)
              begin get property auto create
                push this
                push const string "_matrix"
              end get property auto create ret values 1
              begin operator +
                begin binary operator by local & number
                  begin operator *
                    get local var y (2 0 param)
                    push const number 4
                  end operator *
                end binary operator by local & number
                get local var x (1 0 param)
              end operator +
            end set property ret values 0
          end function
        end set by name: [__setdim]
        ,

[221] __deldim = function(x, y){

        begin set by name
          begin function
            begin locals, total 4
              0 x (param)
              1 y (param)
              2 _E
              3 _G
            end locals

[222] delete this._matrix[y*4 + x]

            begin delete
              begin get this property by string
                push this
                push const string "_matrix"
              end get this property by string ret values 1
              begin operator +
                begin binary operator by local & number
                  begin operator *
                    get local var y (1 0 param)
                    push const number 4
                  end operator *
                end binary operator by local & number
                get local var x (0 0 param)
              end operator +
            end delete
          end function
        end set by name: [__deldim]
      end object
    end set local var a (40 0)


[226] a[1, 2] = 5		// a.__setdim(5, 1, 2)

    begin set dim
      push const number 5
      get local var a (40 0)
      begin params 2
        push const number 1
        ,
        push const number 2
      end params ret values 2
    end set dim ret values 0


[228] print "should be 5: " .. a[1, 2]	// print(a.__getdim(1, 2))

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin operator ..
          push const string "should be 5: "
          begin call method
            get local var a (40 0)
            begin params 3
              push const string "__getdim"
              ,
              push const number 1
              ,
              push const number 2
            end params ret values 3
          end call method ret values 1
        end operator ..
      end params ret values 2
    end call method ret values 0


[230] delete a[1, 2]	// a.__deldim(1, 2)

    begin call method
      get local var a (40 0)
      begin params 3
        push const string "__deldim"
        ,
        push const number 1
        ,
        push const number 2
      end params ret values 3
    end call method ret values 0


[231] print "should be null: " .. a[1, 2]	// print(a.__getdim(1, 2))

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        begin operator ..
          push const string "should be null: "
          begin call method
            get local var a (40 0)
            begin params 3
              push const string "__getdim"
              ,
              push const number 1
              ,
              push const number 2
            end params ret values 3
          end call method ret values 1
        end operator ..
      end params ret values 2
    end call method ret values 0
  end scope ret values 0


[234] print "Test function inline call"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Test function inline call"
    end params ret values 2
  end call method ret values 0


[235] print "should be 7: " .. (function(a b c){ return a + b * c }(1 2 3))

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "should be 7: "
        begin single value
          begin call
            begin function
              begin locals, total 5
                0 a (param)
                1 b (param)
                2 c (param)
                3 _E
                4 _G
              end locals
              begin return
                begin operator +
                  get local var a (0 0 param)
                  begin binary operator by locals
                    begin operator *
                      get local var b (1 0 param)
                      get local var c (2 0 param)
                    end operator *
                  end binary operator by locals
                end operator +
              end return values 1
            end function
            begin params 3
              push const number 1
              ,
              push const number 2
              ,
              push const number 3
            end params ret values 3
          end call ret values 1
        end single value
      end operator ..
    end params ret values 2
  end call method ret values 0


[238] print "Test local vars scope"

  begin scope
    begin locals 1
      41 i
    end locals
    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        push const string "Test local vars scope"
      end params ret values 2
    end call method ret values 0


[239] var i = 1;

    begin set local var
      push const number 1
    end set local var i (41 0)


[241] var i = i

    begin scope
      begin locals 1
        42 i
      end locals
      begin set local var
        get local var i (41 0)
      end set local var i (42 0)


[242] i++

      begin code list
        begin set local var by bin operator local & number
          begin binary operator by local & number
            begin operator +
              get local var i (42 0)
              push const number 1
            end operator +
          end binary operator by local & number
        end set local var by bin operator local & number i (42 0)
      end code list ret values 0


[243] print i

      begin call method
        get local var _E (0 0)
        begin params 2
          push const string "print"
          ,
          get local var i (42 0)
        end params ret values 2
      end call method ret values 0
    end scope ret values 0


[245] print i

    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "print"
        ,
        get local var i (41 0)
      end params ret values 2
    end call method ret values 0
  end scope ret values 0


[248] print "Test debuglocals"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Test debuglocals"
    end params ret values 2
  end call method ret values 0


[255] }(10)

  begin call

[249] function(a){

    begin function
      begin locals, total 5
        0 a (param)
        1 _E
        2 _G
        3 c
      end locals

[250] var c = a * 2;

      begin set local var by bin operator local & number
        begin binary operator by local & number
          begin operator *
            get local var a (0 0 param)
            push const number 2
          end operator *
        end binary operator by local & number
      end set local var by bin operator local & number c (3 0)


[252] var c = a - 1

      begin scope
        begin locals 1
          4 c
        end locals
        begin set local var by bin operator local & number
          begin binary operator by local & number
            begin operator -
              get local var a (0 0 param)
              push const number 1
            end operator -
          end binary operator by local & number
        end set local var by bin operator local & number c (4 0)


[253] print debuglocals

        begin call method
          get local var _E (1 0)
          begin params 2
            push const string "print"
            ,
            begin debug locals
              begin object 13
                begin set by name
                  get local var Person (32 1)
                end set by name: [Person]
                ,
                begin set by name
                  get local var IvanPerson (34 1)
                end set by name: [IvanPerson]
                ,
                begin set by name
                  get local var p (35 1)
                end set by name: [p]
                ,
                begin set by name
                  get local var vec3 (36 1)
                end set by name: [vec3]
                ,
                begin set by name
                  get local var v1 (37 1)
                end set by name: [v1]
                ,
                begin set by name
                  get local var v2 (38 1)
                end set by name: [v2]
                ,
                begin set by name
                  get local var v3 (39 1)
                end set by name: [v3]
                ,
                begin set by name
                  get local var transform (44 1)
                end set by name: [transform]
                ,
                begin set by name
                  get local var core (45 1)
                end set by name: [core]
                ,
                begin set by name
                  get local var __planet (46 1)
                end set by name: [__planet]
                ,
                begin set by name
                  get local var testFunc (47 1)
                end set by name: [testFunc]
                ,
                begin set by name
                  get local var a (0 0 param)
                end set by name: [a]
                ,
                begin set by name
                  get local var c (4 0)
                end set by name: [c]
              end object
            end debug locals
          end params ret values 2
        end call method ret values 0
      end scope ret values 0
    end function

[255] }(10)

    begin params 1
      push const number 10
    end params ret values 1
  end call ret values 0


[257] print "Script environment"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Script environment"
    end params ret values 2
  end call method ret values 0


[258] print _E

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      get local var _E (0 0)
    end params ret values 2
  end call method ret values 0


[260] print "Math functions"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Math functions"
    end params ret values 2
  end call method ret values 0


[261] var a = [math.random() math.random() math.random() math.random() math.random() math.random()]

  begin set local var
    begin array 6
      begin set auto index
        begin call method
          get env var math
          begin params 1
            push const string "random"
          end params ret values 1
        end call method ret values 1
      end set auto index
      ,
      begin set auto index
        begin call method
          get env var math
          begin params 1
            push const string "random"
          end params ret values 1
        end call method ret values 1
      end set auto index
      ,
      begin set auto index
        begin call method
          get env var math
          begin params 1
            push const string "random"
          end params ret values 1
        end call method ret values 1
      end set auto index
      ,
      begin set auto index
        begin call method
          get env var math
          begin params 1
            push const string "random"
          end params ret values 1
        end call method ret values 1
      end set auto index
      ,
      begin set auto index
        begin call method
          get env var math
          begin params 1
            push const string "random"
          end params ret values 1
        end call method ret values 1
      end set auto index
      ,
      begin set auto index
        begin call method
          get env var math
          begin params 1
            push const string "random"
          end params ret values 1
        end call method ret values 1
      end set auto index
    end array
  end set local var a (43 0)


[262] print("random" a)

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "random"
      ,
      get local var a (43 0)
    end params ret values 3
  end call method ret values 0


[265] delete Array.__iter // delete our iterator, use default one

  begin delete
    get env var Array
    push const string "__iter"
  end delete


[267] var transform = function(a f){

  begin set local var
    begin function
      begin locals, total 9
        0 a (param)
        1 f (param)
        2 _E
        3 _G
        4 r
      end locals

[268] var r = typeof a === "array" && [] || {}

      begin set local var
        begin logic ||
          begin logic &&
            begin logic ===
              begin typeof
                get local var a (0 0 param)
              end typeof
              push const string "array"
            end logic ===
            begin array 0
            end array
          end logic &&
          begin object 0
          end object
        end logic ||
      end set local var r (4 0)


[269] for(var i, v in a){

      begin scope
        begin locals 4
          5 i
          6 v
          7 #func
          8 #valid
        end locals
        new local var i (5 0)

        new local var v (6 0)

        new local var #func (7 0 temp)

        new local var #valid (8 0 temp)

        begin code list
          begin set local var
            begin call method
              get local var a (0 0 param)
              begin params 1
                push const string "__iter"
              end params ret values 1
            end call method ret values 1
          end set local var #func (7 0 temp)

          begin loop
            begin set local var
              begin set local var
                begin set local var
                  begin call
                    get local var #func (7 0 temp)
                    begin params 0
                    end params ret values 0
                  end call ret values 3
                end set local var v (6 0)
              end set local var i (5 0)
            end set local var #valid (8 0 temp)

            begin if
              begin bool exp
                begin logic not
                  get local var #valid (8 0 temp)
                end logic not
              end bool exp
              begin then
                break
              end then
            end if ret values 0


[270] r[i] = f(v)

            begin scope
              begin set property by locals auto create
                begin call
                  get local var f (1 0 param)
                  begin params 1
                    get local var v (6 0)
                  end params ret values 1
                end call ret values 1
                get local var auto create r (4 0)
                get local var i (5 0)
              end set property by locals auto create ret values 0
            end scope ret values 0
          end loop ret values 0
        end code list ret values 0
      end scope ret values 0


[272] return r

      begin code list
        begin return
          get local var r (4 0)
        end return values 1
      end code list ret values 0
    end function
  end set local var transform (44 0)


[274] a = transform(a function(a){ return a*100 })

  begin set local var
    begin call
      get local var transform (44 0)
      begin params 2
        get local var a (43 0)
        ,
        begin function
          begin locals, total 3
            0 a (param)
            1 _E
            2 _G
          end locals
          begin return
            begin binary operator by local & number
              begin operator *
                get local var a (0 0 param)
                push const number 100
              end operator *
            end binary operator by local & number
          end return values 1
        end function
      end params ret values 2
    end call ret values 1
  end set local var a (43 0)


[275] print("mult 100" a)

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "mult 100"
      ,
      get local var a (43 0)
    end params ret values 3
  end call method ret values 0


[276] print("math.ceil" transform(a math.ceil))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "math.ceil"
      ,
      begin call
        get local var transform (44 0)
        begin params 2
          get local var a (43 0)
          ,
          begin get property
            get env var math
            push const string "ceil"
          end get property ret values 1
        end params ret values 2
      end call ret values 1
    end params ret values 3
  end call method ret values 0


[277] print("math.floor" transform(a math.floor))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "math.floor"
      ,
      begin call
        get local var transform (44 0)
        begin params 2
          get local var a (43 0)
          ,
          begin get property
            get env var math
            push const string "floor"
          end get property ret values 1
        end params ret values 2
      end call ret values 1
    end params ret values 3
  end call method ret values 0


[278] print("math.round(-1)" transform(a function(a){ return math.round(a, -1) }))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "math.round(-1)"
      ,
      begin call
        get local var transform (44 0)
        begin params 2
          get local var a (43 0)
          ,
          begin function
            begin locals, total 3
              0 a (param)
              1 _E
              2 _G
            end locals
            begin tail call method
              get env var math
              begin params 3
                push const string "round"
                ,
                get local var a (0 0 param)
                ,
                begin neg
                  push const number 1
                end neg
              end params ret values 3
            end tail call method
          end function
        end params ret values 2
      end call ret values 1
    end params ret values 3
  end call method ret values 0


[279] print("math.round(2)" transform(a function(a){ return math.round(a, 2) }))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "math.round(2)"
      ,
      begin call
        get local var transform (44 0)
        begin params 2
          get local var a (43 0)
          ,
          begin function
            begin locals, total 3
              0 a (param)
              1 _E
              2 _G
            end locals
            begin tail call method
              get env var math
              begin params 3
                push const string "round"
                ,
                get local var a (0 0 param)
                ,
                push const number 2
              end params ret values 3
            end tail call method
          end function
        end params ret values 2
      end call ret values 1
    end params ret values 3
  end call method ret values 0


[280] print("math.sin" transform(a math.sin))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "math.sin"
      ,
      begin call
        get local var transform (44 0)
        begin params 2
          get local var a (43 0)
          ,
          begin get property
            get env var math
            push const string "sin"
          end get property ret values 1
        end params ret values 2
      end call ret values 1
    end params ret values 3
  end call method ret values 0


[281] print("math.cos" transform(a math.cos))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "math.cos"
      ,
      begin call
        get local var transform (44 0)
        begin params 2
          get local var a (43 0)
          ,
          begin get property
            get env var math
            push const string "cos"
          end get property ret values 1
        end params ret values 2
      end call ret values 1
    end params ret values 3
  end call method ret values 0


[282] print("math.tan" transform(a math.tan))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "math.tan"
      ,
      begin call
        get local var transform (44 0)
        begin params 2
          get local var a (43 0)
          ,
          begin get property
            get env var math
            push const string "tan"
          end get property ret values 1
        end params ret values 2
      end call ret values 1
    end params ret values 3
  end call method ret values 0


[284] _E = extends _E math

  begin set local var
    begin extends
      get local var _E (0 0)
      get env var math
    end extends ret values 1
  end set local var _E (0 0)


[285] print "Extend local environment to be able to use math module without namespace"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Extend local environment to be able to use math module without namespace"
    end params ret values 2
  end call method ret values 0


[286] print("round(3)" transform(a function(a){ return round(a, 3) }))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "round(3)"
      ,
      begin call
        get local var transform (44 0)
        begin params 2
          get local var a (43 0)
          ,
          begin function
            begin locals, total 3
              0 a (param)
              1 _E
              2 _G
            end locals
            begin tail call method
              get local var _E (1 0)
              begin params 3
                push const string "round"
                ,
                get local var a (0 0 param)
                ,
                push const number 3
              end params ret values 3
            end tail call method
          end function
        end params ret values 2
      end call ret values 1
    end params ret values 3
  end call method ret values 0


[287] print("PI" PI)

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "PI"
      ,
      get env var PI
    end params ret values 3
  end call method ret values 0


[289] var core = require("core")

  begin set local var
    begin call method
      get local var _E (0 0)
      begin params 2
        push const string "require"
        ,
        push const string "core"
      end params ret values 2
    end call method ret values 1
  end set local var core (45 0)


[290] print("core.eval(math.round(13.5))" core.eval("return math.round(13.5)"))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "core.eval(math.round(13.5))"
      ,
      begin call method
        get local var core (45 0)
        begin params 2
          push const string "eval"
          ,
          push const string "return math.round(13.5)"
        end params ret values 2
      end call method ret values 1
    end params ret values 3
  end call method ret values 0


[291] print("eval(math.round(13.5))" eval("return math.round(13.5)"))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "eval(math.round(13.5))"
      ,
      begin call method
        get local var _E (0 0)
        begin params 2
          push const string "eval"
          ,
          push const string "return math.round(13.5)"
        end params ret values 2
      end call method ret values 1
    end params ret values 3
  end call method ret values 0


[292] print("==============")

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "=============="
    end params ret values 2
  end call method ret values 0


[293] print("Next: math namespace is not used\nbut eval executes code in global environment by default\nso eval(round(13.5))" eval("return round(13.5)"))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "Next: math namespace is not used
but eval executes code in global environment by default
so eval(round(13.5))"
      ,
      begin call method
        get local var _E (0 0)
        begin params 2
          push const string "eval"
          ,
          push const string "return round(13.5)"
        end params ret values 2
      end call method ret values 1
    end params ret values 3
  end call method ret values 0


[294] print("run eval in space of the current environment (round(13.5))" eval("return round(13.5)", _E))

  begin call method
    get local var _E (0 0)
    begin params 3
      push const string "print"
      ,
      push const string "run eval in space of the current environment (round(13.5))"
      ,
      begin call method
        get local var _E (0 0)
        begin params 3
          push const string "eval"
          ,
          push const string "return round(13.5)"
          ,
          get local var _E (0 0)
        end params ret values 3
      end call method ret values 1
    end params ret values 3
  end call method ret values 0


[296] var __planet = "Mars"

  begin set local var
    push const string "Mars"
  end set local var __planet (46 0)


[297] function get planet(){ return __planet }

  begin set env var
    begin function
      begin locals, total 2
        0 _E
        1 _G
      end locals
      begin return
        get local var __planet (46 1)
      end return values 1
    end function
  end set env var __get@planet


[298] function set planet(a){ __planet = a }

  begin set env var
    begin function
      begin locals, total 3
        0 a (param)
        1 _E
        2 _G
      end locals
      begin set local var
        get local var a (0 0 param)
      end set local var __planet (46 1)
    end function
  end set env var __set@planet


[300] print "Planet should be Mars: "..planet

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "Planet should be Mars: "
        get env var planet
      end operator ..
    end params ret values 2
  end call method ret values 0


[301] planet = "Mercury"

  begin set env var
    push const string "Mercury"
  end set env var planet


[302] print "Planet should be Mercury: "..planet

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "Planet should be Mercury: "
        get env var planet
      end operator ..
    end params ret values 2
  end call method ret values 0


[304] print "Sorted array"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Sorted array"
    end params ret values 2
  end call method ret values 0


[305] print([9 4 0 276 15 39 3].sort())

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin array 7
          begin set auto index
            push const number 9
          end set auto index
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set auto index
            push const number 0
          end set auto index
          ,
          begin set auto index
            push const number 276
          end set auto index
          ,
          begin set auto index
            push const number 15
          end set auto index
          ,
          begin set auto index
            push const number 39
          end set auto index
          ,
          begin set auto index
            push const number 3
          end set auto index
        end array
        begin params 1
          push const string "sort"
        end params ret values 1
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[307] print "User sorted array by keys"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "User sorted array by keys"
    end params ret values 2
  end call method ret values 0


[308] print([0 1 2 3 4 5 6 7 8 9].ksort(function(a b){return (a%3) - (b%3)}))

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin array 10
          begin set auto index
            push const number 0
          end set auto index
          ,
          begin set auto index
            push const number 1
          end set auto index
          ,
          begin set auto index
            push const number 2
          end set auto index
          ,
          begin set auto index
            push const number 3
          end set auto index
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set auto index
            push const number 5
          end set auto index
          ,
          begin set auto index
            push const number 6
          end set auto index
          ,
          begin set auto index
            push const number 7
          end set auto index
          ,
          begin set auto index
            push const number 8
          end set auto index
          ,
          begin set auto index
            push const number 9
          end set auto index
        end array
        begin params 2
          push const string "ksort"
          ,
          begin function
            begin locals, total 4
              0 a (param)
              1 b (param)
              2 _E
              3 _G
            end locals
            begin return
              begin operator -
                begin binary operator by local & number
                  begin operator %
                    get local var a (0 0 param)
                    push const number 3
                  end operator %
                end binary operator by local & number
                begin binary operator by local & number
                  begin operator %
                    get local var b (1 0 param)
                    push const number 3
                  end operator %
                end binary operator by local & number
              end operator -
            end return values 1
          end function
        end params ret values 2
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[310] print "Sorted array (reverse)"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Sorted array (reverse)"
    end params ret values 2
  end call method ret values 0


[311] print([9 4 0 276 15 39 3].rsort())

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin array 7
          begin set auto index
            push const number 9
          end set auto index
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set auto index
            push const number 0
          end set auto index
          ,
          begin set auto index
            push const number 276
          end set auto index
          ,
          begin set auto index
            push const number 15
          end set auto index
          ,
          begin set auto index
            push const number 39
          end set auto index
          ,
          begin set auto index
            push const number 3
          end set auto index
        end array
        begin params 1
          push const string "rsort"
        end params ret values 1
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[313] print "User sorted array"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "User sorted array"
    end params ret values 2
  end call method ret values 0


[314] print([9 4 0 276 15 39 3].sort(function(a b){return (a % 10) - (b % 10)}))

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin array 7
          begin set auto index
            push const number 9
          end set auto index
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set auto index
            push const number 0
          end set auto index
          ,
          begin set auto index
            push const number 276
          end set auto index
          ,
          begin set auto index
            push const number 15
          end set auto index
          ,
          begin set auto index
            push const number 39
          end set auto index
          ,
          begin set auto index
            push const number 3
          end set auto index
        end array
        begin params 2
          push const string "sort"
          ,
          begin function
            begin locals, total 4
              0 a (param)
              1 b (param)
              2 _E
              3 _G
            end locals
            begin return
              begin operator -
                begin binary operator by local & number
                  begin operator %
                    get local var a (0 0 param)
                    push const number 10
                  end operator %
                end binary operator by local & number
                begin binary operator by local & number
                  begin operator %
                    get local var b (1 0 param)
                    push const number 10
                  end operator %
                end binary operator by local & number
              end operator -
            end return values 1
          end function
        end params ret values 2
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[316] print "Sorted object by values"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Sorted object by values"
    end params ret values 2
  end call method ret values 0


[317] print({b=9 4 d=0 c=276 15 a=39 3}.sort())

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin object 7
          begin set by name
            push const number 9
          end set by name: [b]
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set by name
            push const number 0
          end set by name: [d]
          ,
          begin set by name
            push const number 276
          end set by name: [c]
          ,
          begin set auto index
            push const number 15
          end set auto index
          ,
          begin set by name
            push const number 39
          end set by name: [a]
          ,
          begin set auto index
            push const number 3
          end set auto index
        end object
        begin params 1
          push const string "sort"
        end params ret values 1
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[319] print "Sorted object by values (reverse)"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Sorted object by values (reverse)"
    end params ret values 2
  end call method ret values 0


[320] print({b=9 4 d=0 c=276 15 a=39 3}.rsort())

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin object 7
          begin set by name
            push const number 9
          end set by name: [b]
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set by name
            push const number 0
          end set by name: [d]
          ,
          begin set by name
            push const number 276
          end set by name: [c]
          ,
          begin set auto index
            push const number 15
          end set auto index
          ,
          begin set by name
            push const number 39
          end set by name: [a]
          ,
          begin set auto index
            push const number 3
          end set auto index
        end object
        begin params 1
          push const string "rsort"
        end params ret values 1
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[322] print "Sorted object by keys"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Sorted object by keys"
    end params ret values 2
  end call method ret values 0


[323] print({b=9 4 d=0 c=276 15 a=39 3}.ksort())

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin object 7
          begin set by name
            push const number 9
          end set by name: [b]
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set by name
            push const number 0
          end set by name: [d]
          ,
          begin set by name
            push const number 276
          end set by name: [c]
          ,
          begin set auto index
            push const number 15
          end set auto index
          ,
          begin set by name
            push const number 39
          end set by name: [a]
          ,
          begin set auto index
            push const number 3
          end set auto index
        end object
        begin params 1
          push const string "ksort"
        end params ret values 1
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[325] print "Sorted object by keys (reverse)"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Sorted object by keys (reverse)"
    end params ret values 2
  end call method ret values 0


[326] print({b=9 4 d=0 c=276 15 a=39 3}.krsort())

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin object 7
          begin set by name
            push const number 9
          end set by name: [b]
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set by name
            push const number 0
          end set by name: [d]
          ,
          begin set by name
            push const number 276
          end set by name: [c]
          ,
          begin set auto index
            push const number 15
          end set auto index
          ,
          begin set by name
            push const number 39
          end set by name: [a]
          ,
          begin set auto index
            push const number 3
          end set auto index
        end object
        begin params 1
          push const string "krsort"
        end params ret values 1
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[328] print "User sorted object by keys (reverse)"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "User sorted object by keys (reverse)"
    end params ret values 2
  end call method ret values 0


[329] print({b=9 4 d=0 c=276 15 a=39 3}.krsort(function(a b){return (a % 10) - (b % 10)}))

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin call method
        begin object 7
          begin set by name
            push const number 9
          end set by name: [b]
          ,
          begin set auto index
            push const number 4
          end set auto index
          ,
          begin set by name
            push const number 0
          end set by name: [d]
          ,
          begin set by name
            push const number 276
          end set by name: [c]
          ,
          begin set auto index
            push const number 15
          end set auto index
          ,
          begin set by name
            push const number 39
          end set by name: [a]
          ,
          begin set auto index
            push const number 3
          end set auto index
        end object
        begin params 2
          push const string "krsort"
          ,
          begin function
            begin locals, total 4
              0 a (param)
              1 b (param)
              2 _E
              3 _G
            end locals
            begin return
              begin operator -
                begin binary operator by local & number
                  begin operator %
                    get local var a (0 0 param)
                    push const number 10
                  end operator %
                end binary operator by local & number
                begin binary operator by local & number
                  begin operator %
                    get local var b (1 0 param)
                    push const number 10
                  end operator %
                end binary operator by local & number
              end operator -
            end return values 1
          end function
        end params ret values 2
      end call method ret values 1
    end params ret values 2
  end call method ret values 0


[331] var function testFunc(arg1, arg2){

  begin set local var
    begin function
      begin locals, total 5
        0 arg1 (param)
        1 arg2 (param)
        2 _E
        3 _G
        4 testFunc2
      end locals

[332] var function testFunc2(arg1, arg2, arg3){

      begin set local var
        begin function
          begin locals, total 6
            0 arg1 (param)
            1 arg2 (param)
            2 arg3 (param)
            3 _E
            4 _G
            5 testFunc3
          end locals

[333] var function testFunc3(arg1){

          begin set local var
            begin function
              begin locals, total 3
                0 arg1 (param)
                1 _E
                2 _G
              end locals

[334] printBackTrace()

              begin call method
                get local var _E (1 0)
                begin params 1
                  push const string "printBackTrace"
                end params ret values 1
              end call method ret values 0
            end function
          end set local var testFunc3 (5 0)


[336] testFunc3(1, 2)

          begin call
            get local var testFunc3 (5 0)
            begin params 2
              push const number 1
              ,
              push const number 2
            end params ret values 2
          end call ret values 0
        end function
      end set local var testFunc2 (4 0)


[338] testFunc2(1, 2)

      begin call
        get local var testFunc2 (4 0)
        begin params 2
          push const number 1
          ,
          push const number 2
        end params ret values 2
      end call ret values 0
    end function
  end set local var testFunc (47 0)


[340] print "Test back trace"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "Test back trace"
    end params ret values 2
  end call method ret values 0


[341] testFunc(1, 2)

  begin call
    get local var testFunc (47 0)
    begin params 2
      push const number 1
      ,
      push const number 2
    end params ret values 2
  end call ret values 0


[343] print "Test 5 < 10 ? 7 : 3 --> "..(5 < 10 ? 7 : 3)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "Test 5 < 10 ? 7 : 3 --> "
        begin question
          begin bool exp
            begin logic <
              push const number 5
              push const number 10
            end logic <
          end bool exp
          begin then value
            push const number 7
          end then value
          begin else value
            push const number 3
          end else value
        end question ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[344] print "Test in operator (should be true) "..("name" in {x = 0 y = 0 name = 0 index = 0})

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "Test in operator (should be true) "
        begin in
          push const string "name"
          begin object 4
            begin set by name
              push const number 0
            end set by name: [x]
            ,
            begin set by name
              push const number 0
            end set by name: [y]
            ,
            begin set by name
              push const number 0
            end set by name: [name]
            ,
            begin set by name
              push const number 0
            end set by name: [index]
          end object
        end in
      end operator ..
    end params ret values 2
  end call method ret values 0


[346] terminate()

  begin call method
    get local var _E (0 0)
    begin params 1
      push const string "terminate"
    end params ret values 1
  end call method ret values 0


[347] print "This is never printed"

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      push const string "This is never printed"
    end params ret values 2
  end call method ret values 0

  begin code list
    begin return
      get local var _E (0 0)
    end return values 1
  end code list ret values 0
end function

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

unitpoint

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141216.1 | Last Updated 9 Oct 2012
Article Copyright 2012 by unitpoint
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid