From 59ededb795732e04ac8e1eaceb2b1509a1c1cc23 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 20 Aug 2019 22:00:59 -0400 Subject: WIP: Make new-luxc instructions rely on the Descriptor type. --- new-luxc/source/luxc/lang/statement/jvm.lux | 45 +++++++++++++++-------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'new-luxc/source/luxc/lang/statement/jvm.lux') diff --git a/new-luxc/source/luxc/lang/statement/jvm.lux b/new-luxc/source/luxc/lang/statement/jvm.lux index 9ded2083b..4ca0744db 100644 --- a/new-luxc/source/luxc/lang/statement/jvm.lux +++ b/new-luxc/source/luxc/lang/statement/jvm.lux @@ -16,6 +16,7 @@ ["." check (#+ Check)]] [target [jvm + ["." descriptor (#+ Descriptor)] ["." type (#+ Var Parameter Class Argument Typed Return) [".T" lux]]]] [tool @@ -35,7 +36,6 @@ [lang [host ["$" jvm (#+ Anchor Inst Definition Operation Phase) - ["_" inst] ["_." def]]]]]) (type: Declaration @@ -75,8 +75,14 @@ (Parser Annotation) .any) +(def: field-descriptor + (Parser (Descriptor descriptor.Field)) + (:: <>.monad map + (|>> (:coerce (Descriptor descriptor.Field))) + .text)) + (type: Constant - [Text (List Annotation) type.Type Code]) + [Text (List Annotation) (Descriptor descriptor.Field) Code]) (def: constant (Parser Constant) @@ -85,12 +91,12 @@ ($_ <>.and .text (.tuple (<>.some ..annotation)) - jvm.type + ..field-descriptor .any ))) (type: Variable - [Text jvm.Visibility State (List Annotation) type.Type]) + [Text jvm.Visibility State (List Annotation) (Descriptor descriptor.Field)]) (def: variable (Parser Variable) @@ -101,7 +107,7 @@ jvm.visibility ..state (.tuple (<>.some ..annotation)) - jvm.type + ..field-descriptor ))) (type: Field @@ -134,8 +140,6 @@ (-> Text Parameter) [name [type.object-class (list)] (list)]) -(def: string-descriptor (type.descriptor (type.class "java.lang.String" (list)))) - (def: jvm::class (Handler Anchor Inst Definition) (/.custom @@ -169,21 +173,20 @@ (case field ## TODO: Handle annotations. (#Constant [name annotations type value]) - (case [(type.descriptor type) value] - (^template [ ] - (^ [(static ) [_ ( value)]]) + (case value + (^template [ ] + [_ ( value)] ( #$.Public ($.++F $.staticF $.finalF) name value)) - ([type.boolean-descriptor #.Bit _def.boolean-field] - [type.byte-descriptor #.Int _def.byte-field] - [type.short-descriptor #.Int _def.short-field] - [type.int-descriptor #.Int _def.int-field] - [type.long-descriptor #.Int _def.long-field] - [type.float-descriptor #.Frac _def.float-field] - [type.double-descriptor #.Frac _def.double-field] - [type.char-descriptor #.Nat _def.char-field] - [string-descriptor #.Text _def.string-field]) - - ## TODO: Handle constants better. + ([#.Bit _def.boolean-field] + [#.Int _def.byte-field] + [#.Int _def.short-field] + [#.Int _def.int-field] + [#.Int _def.long-field] + [#.Frac _def.float-field] + [#.Frac _def.double-field] + [#.Nat _def.char-field] + [#.Text _def.string-field]) + _ (undefined)) -- cgit v1.2.3