From 55219078698866155d7d3879f1378f75ba2ba3ee Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 29 Dec 2019 22:41:46 -0400 Subject: FIX the names of function classes are now prefixed with their originating module. --- new-luxc/source/luxc/lang/translation/jvm.lux | 24 +++++++++++++++++----- .../source/luxc/lang/translation/jvm/function.lux | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'new-luxc/source/luxc') diff --git a/new-luxc/source/luxc/lang/translation/jvm.lux b/new-luxc/source/luxc/lang/translation/jvm.lux index fccbd14bf..cf04d2a1a 100644 --- a/new-luxc/source/luxc/lang/translation/jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm.lux @@ -87,9 +87,25 @@ (def: class-path-separator ".") +(def: #export bytecode-name + (-> Text Text) + (text.replace-all ..class-path-separator .module-separator)) + +## TODO: This is a hackish solution to the issue I have. +## It should be cleaned up ASAP. +(def: #export class-name' + (-> Text Text) + (text.replace-all .module-separator ..class-path-separator)) + +(def: #export (class-name [module name]) + (-> Name Text) + (format (text.replace-all .module-separator ..class-path-separator module) + ..class-path-separator (name.normalize name) + "___" (%.nat (text@hash name)))) + (def: (evaluate! library loader eval-class valueI) (-> Library ClassLoader Text Inst (Try [Any Definition])) - (let [bytecode-name (text.replace-all class-path-separator .module-separator eval-class) + (let [bytecode-name (..bytecode-name eval-class) bytecode (def.class #jvm.V1_6 #jvm.Public jvm.noneC bytecode-name @@ -122,11 +138,9 @@ (loader.store class-name class-bytecode library))] (loader.load class-name loader)))) -(def: (define! library loader [module name] valueI) +(def: (define! library loader definition-name valueI) (-> Library ClassLoader Name Inst (Try [Text Any Definition])) - (let [class-name (format (text.replace-all .module-separator class-path-separator module) - class-path-separator (name.normalize name) - "___" (%.nat (text@hash name)))] + (let [class-name (..class-name definition-name)] (do try.monad [[value definition] (evaluate! library loader class-name valueI)] (wrap [class-name value definition])))) diff --git a/new-luxc/source/luxc/lang/translation/jvm/function.lux b/new-luxc/source/luxc/lang/translation/jvm/function.lux index 7a4bbef4e..d141b2392 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/function.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/function.lux @@ -298,6 +298,7 @@ [function-class bodyI] (generation.with-context (generation.with-anchor [@begin 1] (generate bodyS))) + #let [function-class (//.class-name' function-class)] [functionD instanceI] (with-function @begin function-class env arity bodyI) _ (generation.save! true ["" function-class] [function-class -- cgit v1.2.3