< prev index next >

buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java

Print this page

        

*** 150,159 **** --- 150,160 ---- // initialize data fields initDataFields(mi); } if (constructor != null) { + initPrototype(mi); final int arity = constructor.getArity(); if (arity != MemberInfo.DEFAULT_ARITY) { mi.loadThis(); mi.push(arity); mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETARITY,
*** 191,200 **** --- 192,202 ---- mi.invokeSpecial(superClass, INIT, superDesc); } private void initFunctionFields(final MethodGenerator mi) { + assert memberCount > 0; for (final MemberInfo memInfo : scriptClassInfo.getMembers()) { if (!memInfo.isConstructorFunction()) { continue; } mi.loadThis();
*** 202,211 **** --- 204,214 ---- mi.putField(className, memInfo.getJavaName(), OBJECT_DESC); } } private void initDataFields(final MethodGenerator mi) { + assert memberCount > 0; for (final MemberInfo memInfo : scriptClassInfo.getMembers()) { if (!memInfo.isConstructorProperty() || memInfo.isFinal()) { continue; } final Object value = memInfo.getValue();
*** 220,231 **** mi.dup(); mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC); mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc()); } } ! if (constructor != null) { mi.loadThis(); final String protoName = scriptClassInfo.getPrototypeClassName(); mi.newObject(protoName); mi.dup(); mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC); --- 223,236 ---- mi.dup(); mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC); mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc()); } } + } ! private void initPrototype(final MethodGenerator mi) { ! assert constructor != null; mi.loadThis(); final String protoName = scriptClassInfo.getPrototypeClassName(); mi.newObject(protoName); mi.dup(); mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC);
*** 233,243 **** mi.loadThis(); mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR, PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC); mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC); } - } /** * Entry point for ConstructorGenerator run separately as an application. Will display * usage. Takes one argument, a class name. * @param args args vector --- 238,247 ----
< prev index next >