Skip to content

Commit

Permalink
New type for Lux (part 2).
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Apr 23, 2024
1 parent b78b907 commit 72d2058
Show file tree
Hide file tree
Showing 41 changed files with 840 additions and 747 deletions.
16 changes: 8 additions & 8 deletions lux-jvm/source/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
[language
[lux
[translation (.only Operation)]
[analysis
["[0]" analysis (.only)
[macro (.only Expander)]]
["[0]" phase (.only)
["[0]" extension (.only)
["[0]" analysis
["[1]" jvm]]
["[2]/[1]" jvm]]
["[0]" translation
["[1]" jvm]]
["[2]/[1]" jvm]]
["[0]" declaration
["[1]" jvm]]]
["[2]/[1]" jvm]]]
[translation
["/" jvm (.only)
["[1][0]" runtime (.only Anchor Definition)]
Expand Down Expand Up @@ -94,7 +94,7 @@
(as java/lang/Object)
(java/lang/Object::getClass [])
(java/lang/Class::getMethod [(ffi.as_string "apply") _apply2_args]))]
(as (Try (Try [Lux (List @type.Code)]))
(as (Try (Try [analysis.State (List @type.Code)]))
(java/lang/reflect/Method::invoke
[(as java/lang/Object macro)
(ffi.array java/lang/Object
Expand Down Expand Up @@ -164,10 +164,10 @@
_ (compositor.compiler (|>> (as platform.Custom))
context
..expander
(analysis.bundle loader host)
(extension/analysis.bundle loader host)
(io.io platform)
translation.bundle
(declaration.bundle loader ..extender)
extension/translation.bundle
(extension/declaration.bundle loader ..extender)
(/program.program /runtime.class_name)
/reference.constant
..extender
Expand Down
178 changes: 89 additions & 89 deletions lux-ruby/source/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -71,84 +71,84 @@
["/" compositor]])

(import java/lang/String
"[1]::[0]")
"[1]::[0]")

(import (java/lang/Class a)
"[1]::[0]"
(getSuperclass [] (java/lang/Class ?))
(isInstance [java/lang/Object] boolean))
"[1]::[0]"
(getSuperclass [] (java/lang/Class ?))
(isInstance [java/lang/Object] boolean))

(import java/lang/Object
"[1]::[0]"
(toString [] java/lang/String)
(getClass [] (java/lang/Class java/lang/Object)))
"[1]::[0]"
(toString [] java/lang/String)
(getClass [] (java/lang/Class java/lang/Object)))

(import java/lang/Integer
"[1]::[0]"
(longValue [] long))
"[1]::[0]"
(longValue [] long))

(import java/lang/Long
"[1]::[0]"
(intValue [] int))
"[1]::[0]"
(intValue [] int))

(import org/jruby/RubyString
"[1]::[0]"
("static" newInternalFromJavaExternal [org/jruby/Ruby java/lang/String] org/jruby/RubyString)
(asJavaString [] java/lang/String))
"[1]::[0]"
("static" newInternalFromJavaExternal [org/jruby/Ruby java/lang/String] org/jruby/RubyString)
(asJavaString [] java/lang/String))

(import org/jruby/RubySymbol
"[1]::[0]"
(asJavaString [] java/lang/String))
"[1]::[0]"
(asJavaString [] java/lang/String))

(import org/jruby/runtime/builtin/IRubyObject
"[1]::[0]")
"[1]::[0]")

(import org/jruby/Ruby
"[1]::[0]"
(getCurrentContext [] org/jruby/runtime/ThreadContext)
(getNil [] org/jruby/runtime/builtin/IRubyObject))
"[1]::[0]"
(getCurrentContext [] org/jruby/runtime/ThreadContext)
(getNil [] org/jruby/runtime/builtin/IRubyObject))

(import org/jruby/RubyClass
"[1]::[0]")
"[1]::[0]")

(import (org/jruby/RubyArray a)
"[1]::[0]"
(getLength [] int)
(get [int] "?" java/lang/Object))
"[1]::[0]"
(getLength [] int)
(get [int] "?" java/lang/Object))

(import org/jruby/RubyHash
"[1]::[0]"
(get [java/lang/Object] "?" java/lang/Object))
"[1]::[0]"
(get [java/lang/Object] "?" java/lang/Object))

(import org/jruby/runtime/ThreadContext
"[1]::[0]")
"[1]::[0]")

(import org/jruby/RubyRange
"[1]::[0]"
(first [org/jruby/runtime/ThreadContext] org/jruby/runtime/builtin/IRubyObject)
(size [org/jruby/runtime/ThreadContext] org/jruby/runtime/builtin/IRubyObject))
"[1]::[0]"
(first [org/jruby/runtime/ThreadContext] org/jruby/runtime/builtin/IRubyObject)
(size [org/jruby/runtime/ThreadContext] org/jruby/runtime/builtin/IRubyObject))

(import org/jruby/runtime/JavaSites$CheckedSites
"[1]::[0]")
"[1]::[0]")

(import org/jruby/runtime/builtin/Variable
"[1]::[0]")
"[1]::[0]")

(import org/jruby/runtime/builtin/InstanceVariables
"[1]::[0]")
"[1]::[0]")

(import org/jruby/runtime/builtin/InternalVariables
"[1]::[0]")
"[1]::[0]")

(import org/jruby/embed/internal/LocalContextProvider
"[1]::[0]"
(getRuntime [] org/jruby/Ruby))
"[1]::[0]"
(getRuntime [] org/jruby/Ruby))

(import org/jruby/embed/ScriptingContainer
"[1]::[0]"
(new [])
(runScriptlet [java/lang/String] "try" "?" java/lang/Object)
(getProvider [] org/jruby/embed/internal/LocalContextProvider))
"[1]::[0]"
(new [])
(runScriptlet [java/lang/String] "try" "?" java/lang/Object)
(getProvider [] org/jruby/embed/internal/LocalContextProvider))

... TODO; Figure out a way to not need "interpreter" to be a global variable.
(the interpreter
Expand All @@ -169,64 +169,64 @@
(!ruby_runtime))

(import org/jruby/java/proxies/JavaProxy
"[1]::[0]"
(new [org/jruby/Ruby org/jruby/RubyClass java/lang/Object])
(getObject [] java/lang/Object))
"[1]::[0]"
(new [org/jruby/Ruby org/jruby/RubyClass java/lang/Object])
(getObject [] java/lang/Object))

(import org/jruby/internal/runtime/methods/DynamicMethod
"[1]::[0]")
"[1]::[0]")

(import org/jruby/runtime/callsite/CacheEntry
"[1]::[0]"
(new [org/jruby/internal/runtime/methods/DynamicMethod int]))
"[1]::[0]"
(new [org/jruby/internal/runtime/methods/DynamicMethod int]))

(import org/jruby/RubyFixnum
"[1]::[0]"
(new [org/jruby/Ruby long])
(getLongValue [] long))
"[1]::[0]"
(new [org/jruby/Ruby long])
(getLongValue [] long))

(import org/jruby/RubyFloat
"[1]::[0]"
(new [org/jruby/Ruby double]))
"[1]::[0]"
(new [org/jruby/Ruby double]))

(import org/jruby/RubyBoolean
"[1]::[0]"
("static" newBoolean [org/jruby/Ruby boolean] org/jruby/RubyBoolean))
"[1]::[0]"
("static" newBoolean [org/jruby/Ruby boolean] org/jruby/RubyBoolean))

(import org/jruby/RubyNil
"[1]::[0]"
(new [org/jruby/Ruby]))
"[1]::[0]"
(new [org/jruby/Ruby]))

(import org/jruby/runtime/Block$Type
"[1]::[0]"
("enum" PROC))
"[1]::[0]"
("enum" PROC))

(import org/jruby/runtime/Signature
"[1]::[0]"
("read_only" "static" THREE_ARGUMENTS org/jruby/runtime/Signature))
"[1]::[0]"
("read_only" "static" THREE_ARGUMENTS org/jruby/runtime/Signature))

(import org/jruby/parser/StaticScope
"[1]::[0]")
"[1]::[0]")

(import org/jruby/parser/StaticScopeFactory
"[1]::[0]"
(new [org/jruby/Ruby])
(getDummyScope [] org/jruby/parser/StaticScope))
"[1]::[0]"
(new [org/jruby/Ruby])
(getDummyScope [] org/jruby/parser/StaticScope))

(import org/jruby/runtime/BlockBody
"[1]::[0]")
"[1]::[0]")

(import org/jruby/runtime/Block
"[1]::[0]"
("read_only" "static" NULL_BLOCK org/jruby/runtime/Block)
("read_only" type org/jruby/runtime/Block$Type)
(getBody [] org/jruby/runtime/BlockBody))
"[1]::[0]"
("read_only" "static" NULL_BLOCK org/jruby/runtime/Block)
("read_only" type org/jruby/runtime/Block$Type)
(getBody [] org/jruby/runtime/BlockBody))

(import org/jruby/RubyProc
"[1]::[0]"
("static" newProc [org/jruby/Ruby org/jruby/runtime/Block org/jruby/runtime/Block$Type] org/jruby/RubyProc)
(call [org/jruby/runtime/ThreadContext [org/jruby/runtime/builtin/IRubyObject]]
"try" org/jruby/runtime/builtin/IRubyObject))
"[1]::[0]"
("static" newProc [org/jruby/Ruby org/jruby/runtime/Block org/jruby/runtime/Block$Type] org/jruby/RubyProc)
(call [org/jruby/runtime/ThreadContext [org/jruby/runtime/builtin/IRubyObject]]
"try" org/jruby/runtime/builtin/IRubyObject))

(every Translator
(-> java/lang/Object (Try Any)))
Expand All @@ -238,18 +238,18 @@
output (is (Array Any)
(array.empty size))])
(if (n.< size idx)
(when (org/jruby/RubyArray::get [(ffi.as_int (.integer idx))] host_object)
{.#None}
(again (++ idx) output)

{.#Some value}
(when (read value)
{try.#Success lux_value}
(again (++ idx) (array.has! idx lux_value output))

failure
failure))
{try.#Success output}))))
(when (org/jruby/RubyArray::get [(ffi.as_int (.integer idx))] host_object)
{.#None}
(again (++ idx) output)
{.#Some value}
(when (read value)
{try.#Success lux_value}
(again (++ idx) (array.has! idx lux_value output))

failure
failure))
{try.#Success output}))))

(exception.the (unknown_kind_of_object object)
(Exception java/lang/Object)
Expand Down Expand Up @@ -286,7 +286,7 @@
(the (read host_object)
Translator
(`` (<| (if (ffi.null? host_object)
(exception.except ..nil_has_no_lux_representation []))
(exception.except ..nil_has_no_lux_representation []))
(,, (template.with [<class> <post_processing>]
[(when (ffi.as <class> host_object)
{.#Some typed_object}
Expand Down Expand Up @@ -366,8 +366,8 @@
ffi.of_string)])))

(import java/util/Arrays
"[1]::[0]"
("static" [t] copyOfRange [[t] int int] [t]))
"[1]::[0]"
("static" [t] copyOfRange [[t] int int] [t]))

(exception.the (invalid_arity arity)
(Exception Natural)
Expand Down Expand Up @@ -866,13 +866,13 @@
(list.each' ! (|>> (ffi.is java/lang/Object) ..read)))])
(when inputs
... It seems that org/jruby/runtime/Block::call can misbehave when getting called with a Lux state value.
(list info source provenance current_module modules scopes type_context expected seed scope_type_vars extensions eval host)
(list info source provenance current_module modules scopes type_context expected seed eval)
(when partial_application
(stack partial/0 partial/1)
(in (..to_host ((as (-> Any Any Any Any) phase)
partial/0
partial/1
[info source provenance current_module modules scopes type_context expected seed scope_type_vars extensions eval host])))
[info source provenance current_module modules scopes type_context expected seed eval])))

_
(exception.except ..invaid_phase_application [(list.of_stack partial_application) inputs]))
Expand Down
Loading

0 comments on commit 72d2058

Please sign in to comment.