Program: 61610
Project: 61610
Buggy source:
public int method(boolean subMethod,boolean isInterface,List<MethodBody> callStack,String pkg,boolean needsActivation,List<AssignableAVM2Item> subvariables,int initScope,boolean hasRest,int line,String className,String superType,boolean constructor,SourceGeneratorLocalData localData,List<GraphTargetItem> paramTypes,List<String> paramNames,List<GraphTargetItem> paramValues,List<GraphTargetItem> body,GraphTargetItem retType) throws CompilationException {
  SourceGeneratorLocalData newlocalData=new SourceGeneratorLocalData(new HashMap<String,Integer>(),1,true,0);
  newlocalData.currentClass=className;
  newlocalData.pkg=localData.pkg;
  newlocalData.callStack.addAll(localData.callStack);
  newlocalData.traitUsages=localData.traitUsages;
  newlocalData.currentScript=localData.currentScript;
  newlocalData.documentClass=localData.documentClass;
  newlocalData.subMethod=subMethod;
  localData=newlocalData;
  localData.activationReg=0;
  for (int i=0; i < subvariables.size(); i++) {
    AssignableAVM2Item an=subvariables.get(i);
    if (an instanceof UnresolvedAVM2Item) {
      UnresolvedAVM2Item n=(UnresolvedAVM2Item)an;
      if (n.resolved == null) {
        String fullClass=localData.getFullClass();
        GraphTargetItem res=n.resolve(new TypeItem(fullClass),paramTypes,paramNames,abc,allABCs,callStack,subvariables);
        if (res instanceof AssignableAVM2Item) {
          subvariables.set(i,(AssignableAVM2Item)res);
        }
 else {
          subvariables.remove(i);
          i--;
        }
      }
    }
  }
  for (int t=0; t < paramTypes.size(); t++) {
    GraphTargetItem an=paramTypes.get(t);
    if (an instanceof UnresolvedAVM2Item) {
      UnresolvedAVM2Item n=(UnresolvedAVM2Item)an;
      if (n.resolved == null) {
        String fullClass=localData.getFullClass();
        GraphTargetItem res=n.resolve(new TypeItem(fullClass),paramTypes,paramNames,abc,allABCs,callStack,subvariables);
        paramTypes.set(t,res);
      }
    }
  }
  boolean hasArguments=false;
  List<String> slotNames=new ArrayList<>();
  List<String> slotTypes=new ArrayList<>();
  slotNames.add("String_Node_Str");
  slotTypes.add("String_Node_Str");
  List<String> registerNames=new ArrayList<>();
  List<String> registerTypes=new ArrayList<>();
  if (className != null) {
    String fullClassName=pkg == null || pkg.isEmpty() ? className : pkg + "String_Node_Str" + className;
    registerTypes.add(fullClassName);
    localData.scopeStack.add(new LocalRegAVM2Item(null,registerNames.size(),null));
    registerNames.add("String_Node_Str");
  }
 else {
    registerTypes.add("String_Node_Str");
    registerNames.add("String_Node_Str");
  }
  for (  GraphTargetItem t : paramTypes) {
    registerTypes.add(t.toString());
    slotTypes.add(t.toString());
  }
  registerNames.addAll(paramNames);
  slotNames.addAll(paramNames);
  if (hasRest) {
    slotTypes.add("String_Node_Str");
  }
  localData.registerVars.clear();
  for (  AssignableAVM2Item an : subvariables) {
    if (an instanceof NameAVM2Item) {
      NameAVM2Item n=(NameAVM2Item)an;
      if (n.getVariableName().equals("String_Node_Str") & !n.isDefinition()) {
        registerNames.add("String_Node_Str");
        registerTypes.add("String_Node_Str");
        hasArguments=true;
        break;
      }
    }
  }
  int paramRegCount=registerNames.size();
  if (needsActivation) {
    registerNames.add("String_Node_Str");
    localData.activationReg=registerNames.size() - 1;
    registerTypes.add("String_Node_Str");
    localData.scopeStack.add(new LocalRegAVM2Item(null,localData.activationReg,null));
  }
  for (  AssignableAVM2Item an : subvariables) {
    if (an instanceof NameAVM2Item) {
      NameAVM2Item n=(NameAVM2Item)an;
      if (n.isDefinition()) {
        if (!needsActivation || (n.getSlotScope() <= 0)) {
          registerNames.add(n.getVariableName());
          registerTypes.add(n.type.toString());
          slotNames.add(n.getVariableName());
          slotTypes.add(n.type.toString());
        }
      }
    }
  }
  int slotScope=className == null ? 0 : 1;
  for (  AssignableAVM2Item an : subvariables) {
    if (an instanceof NameAVM2Item) {
      NameAVM2Item n=(NameAVM2Item)an;
      if (n.getVariableName() != null) {
        if (!n.getVariableName().equals("String_Node_Str") && needsActivation) {
          if (n.getSlotNumber() <= 0) {
            n.setSlotNumber(slotNames.indexOf(n.getVariableName()));
            n.setSlotScope(slotScope);
          }
        }
 else {
          n.setRegNumber(registerNames.indexOf(n.getVariableName()));
        }
      }
    }
  }
  for (int i=0; i < registerNames.size(); i++) {
    if (needsActivation && i > localData.activationReg) {
      break;
    }
    localData.registerVars.put(registerNames.get(i),i);
  }
  List<NameAVM2Item> declarations=new ArrayList<>();
  loopn:   for (  AssignableAVM2Item an : subvariables) {
    if (an instanceof NameAVM2Item) {
      NameAVM2Item n=(NameAVM2Item)an;
      if (needsActivation) {
        if (n.getSlotScope() != slotScope) {
          continue;
        }
 else {
          if (n.getSlotNumber() < paramRegCount) {
            continue;
          }
        }
      }
      for (      NameAVM2Item d : declarations) {
        if (n.getVariableName() != null && n.getVariableName().equals(d.getVariableName())) {
          continue loopn;
        }
      }
      for (      GraphTargetItem it : body) {
        if (it instanceof NameAVM2Item) {
          NameAVM2Item n2=(NameAVM2Item)it;
          if (n2.isDefinition() && n2.getAssignedValue() != null && n2.getVariableName().equals(n.getVariableName())) {
            continue loopn;
          }
          if (!n2.isDefinition() && n2.getVariableName() != null && n2.getVariableName().equals(n.getVariableName())) {
            break;
          }
        }
      }
      if (n.unresolved) {
        continue;
      }
      if (n.redirect != null) {
        continue;
      }
      if (n.getNs() != null) {
        continue;
      }
      if ("String_Node_Str".equals(n.getVariableName()) || paramNames.contains(n.getVariableName()) || "String_Node_Str".equals(n.getVariableName())) {
        continue;
      }
      NameAVM2Item d=new NameAVM2Item(n.type,n.line,n.getVariableName(),NameAVM2Item.getDefaultValue("String_Node_Str" + n.type),true,n.openedNamespaces);
      if (needsActivation) {
        if (d.getSlotNumber() <= 0) {
          d.setSlotNumber(n.getSlotNumber());
          d.setSlotScope(n.getSlotScope());
        }
      }
 else {
        d.setRegNumber(n.getRegNumber());
      }
      declarations.add(d);
    }
  }
  int param_types[]=new int[paramTypes.size()];
  ValueKind optional[]=new ValueKind[paramValues.size()];
  for (int i=0; i < paramTypes.size(); i++) {
    param_types[i]=typeName(localData,paramTypes.get(i));
  }
  for (int i=0; i < paramValues.size(); i++) {
    optional[i]=getValueKind(Namespace.KIND_NAMESPACE,paramTypes.get(paramTypes.size() - paramValues.size() + i),paramValues.get(i));
    if (optional[i] == null) {
      throw new CompilationException("String_Node_Str",line);
    }
  }
  MethodInfo mi=new MethodInfo(param_types,constructor ? 0 : typeName(localData,retType),0,0,optional,new int[0]);
  if (hasArguments) {
    mi.setFlagNeed_Arguments();
  }
  if (!paramValues.isEmpty()) {
    mi.setFlagHas_optional();
  }
  if (hasRest) {
    mi.setFlagNeed_rest();
  }
  int mindex;
  if (!isInterface) {
    MethodBody mbody=new MethodBody();
    if (needsActivation) {
      mbody.traits=new Traits();
      int slotId=1;
      for (int i=1; i < slotNames.size(); i++) {
        TraitSlotConst tsc=new TraitSlotConst();
        tsc.slot_id=slotId++;
        tsc.name_index=abc.constants.getMultinameId(new Multiname(Multiname.QNAME,abc.constants.getStringId(slotNames.get(i),true),abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE_INTERNAL,abc.constants.getStringId(pkg,true)),0,true),0,0,new ArrayList<Integer>()),true);
        tsc.type_index=typeName(localData,new TypeItem(slotTypes.get(i)));
        mbody.traits.traits.add(tsc);
      }
      for (int i=1; i < paramRegCount; i++) {
        NameAVM2Item param=new NameAVM2Item(new TypeItem(registerTypes.get(i)),0,registerNames.get(i),null,false,new ArrayList<Integer>());
        param.setRegNumber(i);
        NameAVM2Item d=new NameAVM2Item(new TypeItem(registerTypes.get(i)),0,registerNames.get(i),param,true,new ArrayList<Integer>());
        d.setSlotScope(slotScope);
        d.setSlotNumber(slotNames.indexOf(registerNames.get(i)));
        declarations.add(d);
      }
    }
    if (body != null) {
      body.addAll(0,declarations);
    }
    localData.exceptions=new ArrayList<>();
    localData.callStack.add(mbody);
    List<GraphSourceItem> src=body == null ? new ArrayList<GraphSourceItem>() : generate(localData,body);
    mbody.method_info=abc.addMethodInfo(mi);
    mi.setBody(mbody);
    List<AVM2Instruction> mbodyCode=toInsList(src);
    mbody.setCode(new AVM2Code());
    mbody.getCode().code=mbodyCode;
    if (needsActivation) {
      if (localData.traitUsages.containsKey(mbody)) {
        List<Integer> usages=localData.traitUsages.get(mbody);
        for (int i=0; i < mbody.traits.traits.size(); i++) {
          if (usages.contains(i)) {
            TraitSlotConst tsc=(TraitSlotConst)mbody.traits.traits.get(i);
            GraphTargetItem type=TypeItem.UNBOUNDED;
            if (tsc.type_index > 0) {
              type=new TypeItem(abc.constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(abc.constants,true));
            }
            NameAVM2Item d=new NameAVM2Item(type,0,tsc.getName(abc).getName(abc.constants,new ArrayList<String>(),true),NameAVM2Item.getDefaultValue("String_Node_Str" + type),true,new ArrayList<Integer>());
            d.setSlotNumber(tsc.slot_id);
            d.setSlotScope(slotScope);
            mbodyCode.addAll(0,toInsList(d.toSourceIgnoreReturnValue(localData,this)));
          }
        }
      }
      List<AVM2Instruction> acts=new ArrayList<>();
      acts.add(ins(new NewActivationIns()));
      acts.add(ins(new DupIns()));
      acts.add(AssignableAVM2Item.generateSetLoc(localData.activationReg));
      acts.add(ins(new PushScopeIns()));
      mbodyCode.addAll(0,acts);
    }
    if (constructor) {
      List<ABC> abcs=new ArrayList<>();
      abcs.add(abc);
      abcs.addAll(allABCs);
      int parentConstMinAC=0;
      for (      ABC a : abcs) {
        int ci=a.findClassByName(superType);
        if (ci > -1) {
          MethodInfo pmi=a.method_info.get(a.instance_info.get(ci).iinit_index);
          parentConstMinAC=pmi.param_types.length;
          if (pmi.flagHas_optional()) {
            parentConstMinAC-=pmi.optional.length;
          }
        }
      }
      int ac=-1;
      for (      AVM2Instruction ins : mbodyCode) {
        if (ins.definition instanceof ConstructSuperIns) {
          ac=ins.operands[0];
          if (parentConstMinAC > ac) {
            throw new CompilationException("String_Node_Str",line);
          }
        }
      }
      if (ac == -1) {
        if (parentConstMinAC == 0) {
          mbodyCode.add(0,new AVM2Instruction(0,new GetLocal0Ins(),null));
          mbodyCode.add(1,new AVM2Instruction(0,new ConstructSuperIns(),new int[]{0}));
        }
 else {
          throw new CompilationException("String_Node_Str",line);
        }
      }
    }
    if (className != null && !subMethod) {
      mbodyCode.add(0,new AVM2Instruction(0,new GetLocal0Ins(),null));
      mbodyCode.add(1,new AVM2Instruction(0,new PushScopeIns(),null));
    }
    boolean addRet=false;
    if (!mbodyCode.isEmpty()) {
      InstructionDefinition lastDef=mbodyCode.get(mbodyCode.size() - 1).definition;
      if (!((lastDef instanceof ReturnVoidIns) || (lastDef instanceof ReturnValueIns))) {
        addRet=true;
      }
    }
 else {
      addRet=true;
    }
    if (addRet) {
      if (retType.toString().equals("String_Node_Str") || retType.toString().equals("String_Node_Str") || constructor) {
        mbodyCode.add(new AVM2Instruction(0,new ReturnVoidIns(),null));
      }
 else {
        mbodyCode.add(new AVM2Instruction(0,new PushUndefinedIns(),null));
        mbodyCode.add(new AVM2Instruction(0,new ReturnValueIns(),null));
      }
    }
    mbody.exceptions=localData.exceptions.toArray(new ABCException[localData.exceptions.size()]);
    int offset=0;
    for (int i=0; i < mbodyCode.size(); i++) {
      AVM2Instruction ins=mbodyCode.get(i);
      if (ins instanceof ExceptionMarkAVM2Instruction) {
        ExceptionMarkAVM2Instruction m=(ExceptionMarkAVM2Instruction)ins;
switch (m.markType) {
case MARK_E_START:
          mbody.exceptions[m.exceptionId].start=offset;
        break;
case MARK_E_END:
      mbody.exceptions[m.exceptionId].end=offset;
    break;
case MARK_E_TARGET:
  mbody.exceptions[m.exceptionId].target=offset;
break;
}
mbodyCode.remove(i);
i--;
continue;
}
offset+=ins.getBytes().length;
}
mbody.markOffsets();
mbody.autoFillStats(abc,initScope,className != null);
abc.addMethodBody(mbody);
mindex=mbody.method_info;
}
 else {
mindex=abc.addMethodInfo(mi);
}
return mindex;
}

Fixed version (ground truth):
public int method(boolean subMethod,boolean isInterface,List<MethodBody> callStack,String pkg,boolean needsActivation,List<AssignableAVM2Item> subvariables,int initScope,boolean hasRest,int line,String className,String superType,boolean constructor,SourceGeneratorLocalData localData,List<GraphTargetItem> paramTypes,List<String> paramNames,List<GraphTargetItem> paramValues,List<GraphTargetItem> body,GraphTargetItem retType) throws CompilationException {
  SourceGeneratorLocalData newlocalData=new SourceGeneratorLocalData(new HashMap<String,Integer>(),1,true,0);
  newlocalData.currentClass=className;
  newlocalData.pkg=localData.pkg;
  newlocalData.callStack.addAll(localData.callStack);
  newlocalData.traitUsages=localData.traitUsages;
  newlocalData.currentScript=localData.currentScript;
  newlocalData.documentClass=localData.documentClass;
  newlocalData.subMethod=subMethod;
  localData=newlocalData;
  localData.activationReg=0;
  for (int i=0; i < subvariables.size(); i++) {
    AssignableAVM2Item an=subvariables.get(i);
    if (an instanceof UnresolvedAVM2Item) {
      UnresolvedAVM2Item n=(UnresolvedAVM2Item)an;
      if (n.resolved == null) {
        String fullClass=localData.getFullClass();
        GraphTargetItem res=n.resolve(new TypeItem(fullClass),paramTypes,paramNames,abc,allABCs,callStack,subvariables);
        if (res instanceof AssignableAVM2Item) {
          subvariables.set(i,(AssignableAVM2Item)res);
        }
 else {
          subvariables.remove(i);
          i--;
        }
      }
    }
  }
  for (int t=0; t < paramTypes.size(); t++) {
    GraphTargetItem an=paramTypes.get(t);
    if (an instanceof UnresolvedAVM2Item) {
      UnresolvedAVM2Item n=(UnresolvedAVM2Item)an;
      if (n.resolved == null) {
        String fullClass=localData.getFullClass();
        GraphTargetItem res=n.resolve(new TypeItem(fullClass),paramTypes,paramNames,abc,allABCs,callStack,subvariables);
        paramTypes.set(t,res);
      }
    }
  }
  boolean hasArguments=false;
  List<String> slotNames=new ArrayList<>();
  List<String> slotTypes=new ArrayList<>();
  slotNames.add("String_Node_Str");
  slotTypes.add("String_Node_Str");
  List<String> registerNames=new ArrayList<>();
  List<String> registerTypes=new ArrayList<>();
  if (className != null) {
    String fullClassName=pkg == null || pkg.isEmpty() ? className : pkg + "String_Node_Str" + className;
    registerTypes.add(fullClassName);
    localData.scopeStack.add(new LocalRegAVM2Item(null,registerNames.size(),null));
    registerNames.add("String_Node_Str");
  }
 else {
    registerTypes.add("String_Node_Str");
    registerNames.add("String_Node_Str");
  }
  for (  GraphTargetItem t : paramTypes) {
    registerTypes.add(t.toString());
    slotTypes.add(t.toString());
  }
  registerNames.addAll(paramNames);
  slotNames.addAll(paramNames);
  if (hasRest) {
    slotTypes.add("String_Node_Str");
  }
  localData.registerVars.clear();
  for (  AssignableAVM2Item an : subvariables) {
    if (an instanceof NameAVM2Item) {
      NameAVM2Item n=(NameAVM2Item)an;
      if (n.getVariableName().equals("String_Node_Str") & !n.isDefinition()) {
        registerNames.add("String_Node_Str");
        registerTypes.add("String_Node_Str");
        hasArguments=true;
        break;
      }
    }
  }
  int paramRegCount=registerNames.size();
  if (needsActivation) {
    registerNames.add("String_Node_Str");
    localData.activationReg=registerNames.size() - 1;
    registerTypes.add("String_Node_Str");
    localData.scopeStack.add(new LocalRegAVM2Item(null,localData.activationReg,null));
  }
  for (  AssignableAVM2Item an : subvariables) {
    if (an instanceof NameAVM2Item) {
      NameAVM2Item n=(NameAVM2Item)an;
      if (n.isDefinition()) {
        if (!needsActivation || (n.getSlotScope() <= 0)) {
          registerNames.add(n.getVariableName());
          registerTypes.add(n.type.toString());
          slotNames.add(n.getVariableName());
          slotTypes.add(n.type.toString());
        }
      }
    }
  }
  int slotScope=subMethod ? 0 : 1;
  for (  AssignableAVM2Item an : subvariables) {
    if (an instanceof NameAVM2Item) {
      NameAVM2Item n=(NameAVM2Item)an;
      if (n.getVariableName() != null) {
        if (!n.getVariableName().equals("String_Node_Str") && needsActivation) {
          if (n.getSlotNumber() <= 0) {
            n.setSlotNumber(slotNames.indexOf(n.getVariableName()));
            n.setSlotScope(slotScope);
          }
        }
 else {
          n.setRegNumber(registerNames.indexOf(n.getVariableName()));
        }
      }
    }
  }
  for (int i=0; i < registerNames.size(); i++) {
    if (needsActivation && i > localData.activationReg) {
      break;
    }
    localData.registerVars.put(registerNames.get(i),i);
  }
  List<NameAVM2Item> declarations=new ArrayList<>();
  loopn:   for (  AssignableAVM2Item an : subvariables) {
    if (an instanceof NameAVM2Item) {
      NameAVM2Item n=(NameAVM2Item)an;
      if (needsActivation) {
        if (n.getSlotScope() != slotScope) {
          continue;
        }
 else {
          if (n.getSlotNumber() < paramRegCount) {
            continue;
          }
        }
      }
      for (      NameAVM2Item d : declarations) {
        if (n.getVariableName() != null && n.getVariableName().equals(d.getVariableName())) {
          continue loopn;
        }
      }
      for (      GraphTargetItem it : body) {
        if (it instanceof NameAVM2Item) {
          NameAVM2Item n2=(NameAVM2Item)it;
          if (n2.isDefinition() && n2.getAssignedValue() != null && n2.getVariableName().equals(n.getVariableName())) {
            continue loopn;
          }
          if (!n2.isDefinition() && n2.getVariableName() != null && n2.getVariableName().equals(n.getVariableName())) {
            break;
          }
        }
      }
      if (n.unresolved) {
        continue;
      }
      if (n.redirect != null) {
        continue;
      }
      if (n.getNs() != null) {
        continue;
      }
      if ("String_Node_Str".equals(n.getVariableName()) || paramNames.contains(n.getVariableName()) || "String_Node_Str".equals(n.getVariableName())) {
        continue;
      }
      NameAVM2Item d=new NameAVM2Item(n.type,n.line,n.getVariableName(),NameAVM2Item.getDefaultValue("String_Node_Str" + n.type),true,n.openedNamespaces);
      if (needsActivation) {
        if (d.getSlotNumber() <= 0) {
          d.setSlotNumber(n.getSlotNumber());
          d.setSlotScope(n.getSlotScope());
        }
      }
 else {
        d.setRegNumber(n.getRegNumber());
      }
      declarations.add(d);
    }
  }
  int param_types[]=new int[paramTypes.size()];
  ValueKind optional[]=new ValueKind[paramValues.size()];
  for (int i=0; i < paramTypes.size(); i++) {
    param_types[i]=typeName(localData,paramTypes.get(i));
  }
  for (int i=0; i < paramValues.size(); i++) {
    optional[i]=getValueKind(Namespace.KIND_NAMESPACE,paramTypes.get(paramTypes.size() - paramValues.size() + i),paramValues.get(i));
    if (optional[i] == null) {
      throw new CompilationException("String_Node_Str",line);
    }
  }
  MethodInfo mi=new MethodInfo(param_types,constructor ? 0 : typeName(localData,retType),0,0,optional,new int[0]);
  if (hasArguments) {
    mi.setFlagNeed_Arguments();
  }
  if (!paramValues.isEmpty()) {
    mi.setFlagHas_optional();
  }
  if (hasRest) {
    mi.setFlagNeed_rest();
  }
  int mindex;
  if (!isInterface) {
    MethodBody mbody=new MethodBody();
    if (needsActivation) {
      mbody.traits=new Traits();
      int slotId=1;
      for (int i=1; i < slotNames.size(); i++) {
        TraitSlotConst tsc=new TraitSlotConst();
        tsc.slot_id=slotId++;
        tsc.name_index=abc.constants.getMultinameId(new Multiname(Multiname.QNAME,abc.constants.getStringId(slotNames.get(i),true),abc.constants.getNamespaceId(new Namespace(Namespace.KIND_PACKAGE_INTERNAL,abc.constants.getStringId(pkg,true)),0,true),0,0,new ArrayList<Integer>()),true);
        tsc.type_index=typeName(localData,new TypeItem(slotTypes.get(i)));
        mbody.traits.traits.add(tsc);
      }
      for (int i=1; i < paramRegCount; i++) {
        NameAVM2Item param=new NameAVM2Item(new TypeItem(registerTypes.get(i)),0,registerNames.get(i),null,false,new ArrayList<Integer>());
        param.setRegNumber(i);
        NameAVM2Item d=new NameAVM2Item(new TypeItem(registerTypes.get(i)),0,registerNames.get(i),param,true,new ArrayList<Integer>());
        d.setSlotScope(slotScope);
        d.setSlotNumber(slotNames.indexOf(registerNames.get(i)));
        declarations.add(d);
      }
    }
    if (body != null) {
      body.addAll(0,declarations);
    }
    localData.exceptions=new ArrayList<>();
    localData.callStack.add(mbody);
    List<GraphSourceItem> src=body == null ? new ArrayList<GraphSourceItem>() : generate(localData,body);
    mbody.method_info=abc.addMethodInfo(mi);
    mi.setBody(mbody);
    List<AVM2Instruction> mbodyCode=toInsList(src);
    mbody.setCode(new AVM2Code());
    mbody.getCode().code=mbodyCode;
    if (needsActivation) {
      if (localData.traitUsages.containsKey(mbody)) {
        List<Integer> usages=localData.traitUsages.get(mbody);
        for (int i=0; i < mbody.traits.traits.size(); i++) {
          if (usages.contains(i)) {
            TraitSlotConst tsc=(TraitSlotConst)mbody.traits.traits.get(i);
            GraphTargetItem type=TypeItem.UNBOUNDED;
            if (tsc.type_index > 0) {
              type=new TypeItem(abc.constants.constant_multiname.get(tsc.type_index).getNameWithNamespace(abc.constants,true));
            }
            NameAVM2Item d=new NameAVM2Item(type,0,tsc.getName(abc).getName(abc.constants,new ArrayList<String>(),true),NameAVM2Item.getDefaultValue("String_Node_Str" + type),true,new ArrayList<Integer>());
            d.setSlotNumber(tsc.slot_id);
            d.setSlotScope(slotScope);
            mbodyCode.addAll(0,toInsList(d.toSourceIgnoreReturnValue(localData,this)));
          }
        }
      }
      List<AVM2Instruction> acts=new ArrayList<>();
      acts.add(ins(new NewActivationIns()));
      acts.add(ins(new DupIns()));
      acts.add(AssignableAVM2Item.generateSetLoc(localData.activationReg));
      acts.add(ins(new PushScopeIns()));
      mbodyCode.addAll(0,acts);
    }
    if (constructor) {
      List<ABC> abcs=new ArrayList<>();
      abcs.add(abc);
      abcs.addAll(allABCs);
      int parentConstMinAC=0;
      for (      ABC a : abcs) {
        int ci=a.findClassByName(superType);
        if (ci > -1) {
          MethodInfo pmi=a.method_info.get(a.instance_info.get(ci).iinit_index);
          parentConstMinAC=pmi.param_types.length;
          if (pmi.flagHas_optional()) {
            parentConstMinAC-=pmi.optional.length;
          }
        }
      }
      int ac=-1;
      for (      AVM2Instruction ins : mbodyCode) {
        if (ins.definition instanceof ConstructSuperIns) {
          ac=ins.operands[0];
          if (parentConstMinAC > ac) {
            throw new CompilationException("String_Node_Str",line);
          }
        }
      }
      if (ac == -1) {
        if (parentConstMinAC == 0) {
          mbodyCode.add(0,new AVM2Instruction(0,new GetLocal0Ins(),null));
          mbodyCode.add(1,new AVM2Instruction(0,new ConstructSuperIns(),new int[]{0}));
        }
 else {
          throw new CompilationException("String_Node_Str",line);
        }
      }
    }
    if (className != null && !subMethod) {
      mbodyCode.add(0,new AVM2Instruction(0,new GetLocal0Ins(),null));
      mbodyCode.add(1,new AVM2Instruction(0,new PushScopeIns(),null));
    }
    boolean addRet=false;
    if (!mbodyCode.isEmpty()) {
      InstructionDefinition lastDef=mbodyCode.get(mbodyCode.size() - 1).definition;
      if (!((lastDef instanceof ReturnVoidIns) || (lastDef instanceof ReturnValueIns))) {
        addRet=true;
      }
    }
 else {
      addRet=true;
    }
    if (addRet) {
      if (retType.toString().equals("String_Node_Str") || retType.toString().equals("String_Node_Str") || constructor) {
        mbodyCode.add(new AVM2Instruction(0,new ReturnVoidIns(),null));
      }
 else {
        mbodyCode.add(new AVM2Instruction(0,new PushUndefinedIns(),null));
        mbodyCode.add(new AVM2Instruction(0,new ReturnValueIns(),null));
      }
    }
    mbody.exceptions=localData.exceptions.toArray(new ABCException[localData.exceptions.size()]);
    int offset=0;
    for (int i=0; i < mbodyCode.size(); i++) {
      AVM2Instruction ins=mbodyCode.get(i);
      if (ins instanceof ExceptionMarkAVM2Instruction) {
        ExceptionMarkAVM2Instruction m=(ExceptionMarkAVM2Instruction)ins;
switch (m.markType) {
case MARK_E_START:
          mbody.exceptions[m.exceptionId].start=offset;
        break;
case MARK_E_END:
      mbody.exceptions[m.exceptionId].end=offset;
    break;
case MARK_E_TARGET:
  mbody.exceptions[m.exceptionId].target=offset;
break;
}
mbodyCode.remove(i);
i--;
continue;
}
offset+=ins.getBytes().length;
}
mbody.markOffsets();
mbody.autoFillStats(abc,initScope,className != null);
abc.addMethodBody(mbody);
mindex=mbody.method_info;
}
 else {
mindex=abc.addMethodInfo(mi);
}
return mindex;
}