@@ -78,6 +78,7 @@ public class Compiler implements Opcodes{
7878static final Symbol _AMP_ = Symbol .intern ("&" );
7979static final Symbol ISEQ = Symbol .intern ("clojure.lang.ISeq" );
8080
81+ static final Keyword loadNs = Keyword .intern (null , "load-ns" );
8182static final Keyword inlineKey = Keyword .intern (null , "inline" );
8283static final Keyword inlineAritiesKey = Keyword .intern (null , "inline-arities" );
8384static final Keyword staticKey = Keyword .intern (null , "static" );
@@ -4091,6 +4092,8 @@ static public class ObjExpr implements Expr{
40914092
40924093 Object src ;
40934094
4095+ IPersistentMap opts = PersistentHashMap .EMPTY ;
4096+
40944097 final static Method voidctor = Method .getMethod ("void <init>()" );
40954098 protected IPersistentMap classMeta ;
40964099 protected boolean isStatic ;
@@ -4299,6 +4302,22 @@ void compile(String superName, String[] interfaceNames, boolean oneTimeUse) thro
42994302 clinitgen.mark(endLabel);
43004303 }
43014304 */
4305+
4306+ if (isDeftype () && RT .booleanCast (RT .get (opts , loadNs ))) {
4307+ String nsname = ((Symbol )RT .second (src )).getNamespace ();
4308+ if (!nsname .equals ("clojure.core" )) {
4309+ clinitgen .push ("clojure.core" );
4310+ clinitgen .push ("require" );
4311+ clinitgen .invokeStatic (RT_TYPE , Method .getMethod ("clojure.lang.Var var(String,String)" ));
4312+ clinitgen .invokeVirtual (VAR_TYPE ,Method .getMethod ("Object getRawRoot()" ));
4313+ clinitgen .checkCast (IFN_TYPE );
4314+ clinitgen .push (nsname );
4315+ clinitgen .invokeStatic (SYMBOL_TYPE , Method .getMethod ("clojure.lang.Symbol create(String)" ));
4316+ clinitgen .invokeInterface (IFN_TYPE , Method .getMethod ("Object invoke(Object)" ));
4317+ clinitgen .pop ();
4318+ }
4319+ }
4320+
43024321 clinitgen .returnValue ();
43034322
43044323 clinitgen .endMethod ();
@@ -7540,7 +7559,7 @@ public Expr parse(C context, final Object frm) {
75407559 ISeq rform = (ISeq ) frm ;
75417560 //(deftype* tagname classname [fields] :implements [interfaces] :tag tagname methods*)
75427561 rform = RT .next (rform );
7543- String tagname = ((Symbol ) rform .first ()).toString ();
7562+ String tagname = ((Symbol ) rform .first ()).getName ();
75447563 rform = rform .next ();
75457564 Symbol classname = (Symbol ) rform .first ();
75467565 rform = rform .next ();
@@ -7554,7 +7573,7 @@ public Expr parse(C context, final Object frm) {
75547573 }
75557574
75567575 ObjExpr ret = build ((IPersistentVector )RT .get (opts ,implementsKey ,PersistentVector .EMPTY ),fields ,null ,tagname , classname ,
7557- (Symbol ) RT .get (opts ,RT .TAG_KEY ),rform , frm );
7576+ (Symbol ) RT .get (opts ,RT .TAG_KEY ),rform , frm , opts );
75587577 return ret ;
75597578 }
75607579 }
@@ -7578,7 +7597,7 @@ public Expr parse(C context, Object frm) {
75787597 rform = RT .next (rform );
75797598
75807599
7581- ObjExpr ret = build (interfaces , null , null , classname , Symbol .intern (classname ), null , rform , frm );
7600+ ObjExpr ret = build (interfaces , null , null , classname , Symbol .intern (classname ), null , rform , frm , null );
75827601 if (frm instanceof IObj && ((IObj ) frm ).meta () != null )
75837602 return new MetaExpr (ret , MapExpr
75847603 .parse (context == C .EVAL ? context : C .EXPRESSION , ((IObj ) frm ).meta ()));
@@ -7589,14 +7608,15 @@ public Expr parse(C context, Object frm) {
75897608
75907609 static ObjExpr build (IPersistentVector interfaceSyms , IPersistentVector fieldSyms , Symbol thisSym ,
75917610 String tagName , Symbol className ,
7592- Symbol typeTag , ISeq methodForms , Object frm ) {
7611+ Symbol typeTag , ISeq methodForms , Object frm , IPersistentMap opts ) {
75937612 NewInstanceExpr ret = new NewInstanceExpr (null );
75947613
75957614 ret .src = frm ;
75967615 ret .name = className .toString ();
75977616 ret .classMeta = RT .meta (className );
75987617 ret .internalName = ret .name .replace ('.' , '/' );
75997618 ret .objtype = Type .getObjectType (ret .internalName );
7619+ ret .opts = opts ;
76007620
76017621 if (thisSym != null )
76027622 ret .thisName = thisSym .name ;
0 commit comments