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

Tagged as

Go to top

ObjectScript: A new programming language

, 9 Oct 2012
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/bind.os
[1] print "getcwd: "..getcwd()

begin function
  begin locals, total 7
    0 _E
    1 _G
    2 data
    3 t
    4 t2
    5 t2
    6 t3
  end locals
  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "getcwd: "
        begin call method
          get local var _E (0 0)
          begin params 1
            push const string "getcwd"
          end params ret values 1
        end call method ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[4] var data = {a=10 b=20}

  begin set local var
    begin object 2
      begin set by name
        push const number 10
      end set by name: [a]
      ,
      begin set by name
        push const number 20
      end set by name: [b]
    end object
  end set local var data (2 0)


[5] printTestStruct(data)

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


[6] data = changeTestStruct(data)

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


[7] printTestStruct(data)

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


[8] print data

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


[10] var t = TestClass(1, 0.25)

  begin set local var
    begin call method
      get local var _E (0 0)
      begin params 3
        push const string "TestClass"
        ,
        push const number 1
        ,
        push const number 0.25
      end params ret values 3
    end call method ret values 1
  end set local var t (3 0)


[11] print "t.i: "..t.i

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "t.i: "
        begin get property
          get local var t (3 0)
          push const string "i"
        end get property ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[12] print "t.j: "..t.j

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "t.j: "
        begin get property
          get local var t (3 0)
          push const string "j"
        end get property ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[14] var t2 = TestClass(2, 0.5)

  begin set local var
    begin call method
      get local var _E (0 0)
      begin params 3
        push const string "TestClass"
        ,
        push const number 2
        ,
        push const number 0.5
      end params ret values 3
    end call method ret values 1
  end set local var t2 (4 0)


[15] t2.i = t2.i + t.j

  begin set property
    begin operator +
      begin get property
        get local var t2 (4 0)
        push const string "i"
      end get property ret values 1
      begin get property
        get local var t (3 0)
        push const string "j"
      end get property ret values 1
    end operator +
    get local var auto create t2 (4 0)
    push const string "i"
  end set property ret values 0


[16] print "t2"

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


[17] t2.print()

  begin call method
    get local var t2 (4 0)
    begin params 1
      push const string "print"
    end params ret values 1
  end call method ret values 0


[19] print "t.doSomething(10, 100.001, 1000.1, t2): "..t.doSomething(10, 100.001, 1000.1, t2)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "t.doSomething(10, 100.001, 1000.1, t2): "
        begin call method
          get local var t (3 0)
          begin params 5
            push const string "doSomething"
            ,
            push const number 10
            ,
            push const number 100.001
            ,
            push const number 1000.1
            ,
            get local var t2 (4 0)
          end params ret values 5
        end call method ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[21] var t2 = clone t

  begin set local var
    begin clone
      get local var t (3 0)
    end clone
  end set local var t2 (5 0)


[22] t2.i = t2.i + 10

  begin set property
    begin operator +
      begin get property
        get local var t2 (5 0)
        push const string "i"
      end get property ret values 1
      push const number 10
    end operator +
    get local var auto create t2 (5 0)
    push const string "i"
  end set property ret values 0


[23] t2.j = t2.j + 20.5

  begin set property
    begin operator +
      begin get property
        get local var t2 (5 0)
        push const string "j"
      end get property ret values 1
      push const number 20.5
    end operator +
    get local var auto create t2 (5 0)
    push const string "j"
  end set property ret values 0


[25] var t3 = t + t2

  begin set local var by bin operator locals
    begin binary operator by locals
      begin operator +
        get local var t (3 0)
        get local var t2 (5 0)
      end operator +
    end binary operator by locals
  end set local var by bin operator locals t3 (6 0)


[26] t3.print()

  begin call method
    get local var t3 (6 0)
    begin params 1
      push const string "print"
    end params ret values 1
  end call method ret values 0


[28] print "isdigit(123): "..my.isdigit("123")

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "isdigit(123): "
        begin call method
          get env var my
          begin params 2
            push const string "isdigit"
            ,
            push const string "123"
          end params ret values 2
        end call method ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[29] print "isdigit(123q): "..my.isdigit("123q")

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "isdigit(123q): "
        begin call method
          get env var my
          begin params 2
            push const string "isdigit"
            ,
            push const string "123q"
          end params ret values 2
        end call method ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[31] print "my.hash(123): "..my.hash(123)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "my.hash(123): "
        begin call method
          get env var my
          begin params 2
            push const string "hash"
            ,
            push const number 123
          end params ret values 2
        end call method ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[33] print "call my.print_num(123.5)"

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


[34] my.print_num(123.5)

  begin call method
    get env var my
    begin params 2
      push const string "print_num"
      ,
      push const number 123.5
    end params ret values 2
  end call method ret values 0


[35] print "call my.print_void()"

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


[36] my.print_void()

  begin call method
    get env var my
    begin params 1
      push const string "print_void"
    end params ret values 1
  end call method ret values 0


[37] print "my.abs(-12): "..my.abs(-12)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "my.abs(-12): "
        begin call method
          get env var my
          begin params 2
            push const string "abs"
            ,
            begin neg
              push const number 12
            end neg
          end params ret values 2
        end call method ret values 1
      end operator ..
    end params ret values 2
  end call method ret values 0


[38] print "my.fabs(-123.5): "..my.fabs(-123.5)

  begin call method
    get local var _E (0 0)
    begin params 2
      push const string "print"
      ,
      begin operator ..
        push const string "my.fabs(-123.5): "
        begin call method
          get env var my
          begin params 2
            push const string "fabs"
            ,
            begin neg
              push const number 123.5
            end neg
          end params ret values 2
        end call method ret values 1
      end operator ..
    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 | Mobile
Web04 | 2.8.140916.1 | Last Updated 9 Oct 2012
Article Copyright 2012 by unitpoint
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid