system/src/sc/lang/AbstractInterpreter.java
public void print(String def) {
      Object methObj = null;
      Object varObj = null;
      Object typeObj = null;
      JavaModel model = getModel();
      BodyTypeDeclaration curType = null;

      // Note: this is a bit wrong since we could have a method and member with the same name or a type
      // with the same name and this allows no way to override that.
      if (currentTypes.size() > 0) {
         curType = currentTypes.get(currentTypes.size()-1);
         methObj = curType.definesMethod(def, null, null, null, false, false, null, null);
         varObj = curType.definesMember(def, JavaSemanticNode.MemberType.AllSet, null, null);
         typeObj = curType.findType(def);
         if (typeObj == null)
            typeObj = ModelUtil.getInnerType(curType, def, null);
      }

      Object curObj = getCurrentObject();
      String initStr = null;
      if (typeObj == null)
         typeObj = model.getTypeDeclaration(def);
      if (typeObj == null && varObj == null && methObj == null)
         System.out.println("No type, method, or member named: " + def + (curType == null ? " for context: " + model.getPackagePrefix() : " for " + ModelUtil.getTypeName(curType)));
      if (varObj instanceof JavaSemanticNode) {
         if (varObj instanceof VariableDefinition) {
            VariableDefinition varDef = (VariableDefinition) varObj;
            if (curObj != null) {
               DestinationListener dl = Bind.getBinding(curObj, varDef.variableName);
               if (dl != null) {
                  System.out.println("Bound: " + dl.toString());
                  return;
               }
               else
                  initStr = " = " + String.valueOf(TypeUtil.getPropertyValue(curObj, varDef.variableName));
            }
            else if (curType != null) {
               Object initializer = curType.getPropertyInitializer(varDef.variableName);
               initStr = " = " + (initializer == null ? " null" :
                            (initializer instanceof JavaSemanticNode ? 
                                 ((JavaSemanticNode) initializer).toLanguageString() :
                                 initializer.toString()));
            }
         }
         System.out.println("Source: " + ((JavaSemanticNode) varObj).toLanguageString().trim() + (initStr == null ? "" : initStr));
      }
      else if (ModelUtil.isProperty(varObj)) {
         if (curObj != null) {
            DestinationListener dl = Bind.getBinding(curObj, ModelUtil.getPropertyName(varObj));
            if (dl != null)
               System.out.println("Bound: " + dl.toString());
            else
               System.out.println("Compiled property: " + varObj + " = " + TypeUtil.getPropertyValue(curObj, def));
         }
         else
            System.out.println("Compiled property: " + varObj);
      }
      if (methObj != null) {
         if (methObj instanceof AbstractMethodDefinition)
            System.out.println("Source method: " + ((AbstractMethodDefinition)methObj).toDefinitionString());
         else
            System.out.println("Compiled method: " + methObj);
      }
      if (typeObj != null) {
         if (typeObj instanceof BodyTypeDeclaration)
            System.out.println("Source type: " + ((BodyTypeDeclaration)typeObj).toDeclarationString());
         else
            System.out.println("Compiled type: " + typeObj);
      }
   }
/** General debug method to print out all information about a definition by its name */
General debug method to print out all information about a definition by its name
General debug method to print out all information about a definition by its name
public void print(String def) {
      Object methObj = null;
      Object varObj = null;
      Object typeObj = null;
      JavaModel model = getModel();
      BodyTypeDeclaration curType = null;
      if (currentTypes.size() > 0) {
         curType = currentTypes.get(currentTypes.size()-1);
         methObj = curType.definesMethod(def, null, null, null, false, false, null, null);
         varObj = curType.definesMember(def, JavaSemanticNode.MemberType.AllSet, null, null);
         typeObj = curType.findType(def);
         if (typeObj == null)
            typeObj = ModelUtil.getInnerType(curType, def, null);
      }
      Object curObj = getCurrentObject();
      String initStr = null;
      if (typeObj == null)
         typeObj = model.getTypeDeclaration(def);
      if (typeObj == null && varObj == null && methObj == null)
         System.out.println("No type, method, or member named: " + def + (curType == null ? " for context: " + model.getPackagePrefix() : " for " + ModelUtil.getTypeName(curType)));
      if (varObj instanceof JavaSemanticNode) {
         if (varObj instanceof VariableDefinition) {
            VariableDefinition varDef = (VariableDefinition) varObj;
            if (curObj != null) {
               DestinationListener dl = Bind.getBinding(curObj, varDef.variableName);
               if (dl != null) {
                  System.out.println("Bound: " + dl.toString());
                  return;
               }
               else
                  initStr = " = " + String.valueOf(TypeUtil.getPropertyValue(curObj, varDef.variableName));
            }
            else if (curType != null) {
               Object initializer = curType.getPropertyInitializer(varDef.variableName);
               initStr = " = " + (initializer == null ? " null" :
                            (initializer instanceof JavaSemanticNode ? 
                                 ((JavaSemanticNode) initializer).toLanguageString() :
                                 initializer.toString()));
            }
         }
         System.out.println("Source: " + ((JavaSemanticNode) varObj).toLanguageString().trim() + (initStr == null ? "" : initStr));
      }
      else if (ModelUtil.isProperty(varObj)) {
         if (curObj != null) {
            DestinationListener dl = Bind.getBinding(curObj, ModelUtil.getPropertyName(varObj));
            if (dl != null)
               System.out.println("Bound: " + dl.toString());
            else
               System.out.println("Compiled property: " + varObj + " = " + TypeUtil.getPropertyValue(curObj, def));
         }
         else
            System.out.println("Compiled property: " + varObj);
      }
      if (methObj != null) {
         if (methObj instanceof AbstractMethodDefinition)
            System.out.println("Source method: " + ((AbstractMethodDefinition)methObj).toDefinitionString());
         else
            System.out.println("Compiled method: " + methObj);
      }
      if (typeObj != null) {
         if (typeObj instanceof BodyTypeDeclaration)
            System.out.println("Source type: " + ((BodyTypeDeclaration)typeObj).toDeclarationString());
         else
            System.out.println("Compiled type: " + typeObj);
      }
   }
public void print ( String def ) { Object methObj = null ; Object varObj = null ; Object typeObj = null ; JavaModel model = getModel ( ) ; BodyTypeDeclaration curType = null ; if ( currentTypes . size ( ) > 0 ) { curType = currentTypes . get ( currentTypes . size ( ) - 1 ) ; methObj = curType . definesMethod ( def , null , null , null , false , false , null , null ) ; varObj = curType . definesMember ( def , JavaSemanticNode . MemberType . AllSet , null , null ) ; typeObj = curType . findType ( def ) ; if ( typeObj == null ) typeObj = ModelUtil . getInnerType ( curType , def , null ) ; } Object curObj = getCurrentObject ( ) ; String initStr = null ; if ( typeObj == null ) typeObj = model . getTypeDeclaration ( def ) ; if ( typeObj == null && varObj == null && methObj == null ) System . out . println ( "No type, method, or member named: " + def + ( curType == null ? " for context: " + model . getPackagePrefix ( ) : " for " + ModelUtil . getTypeName ( curType ) ) ) ; if ( varObj instanceof JavaSemanticNode ) { if ( varObj instanceof VariableDefinition ) { VariableDefinition varDef = ( VariableDefinition ) varObj ; if ( curObj != null ) { DestinationListener dl = Bind . getBinding ( curObj , varDef . variableName ) ; if ( dl != null ) { System . out . println ( "Bound: " + dl . toString ( ) ) ; return ; } else initStr = " = " + String . valueOf ( TypeUtil . getPropertyValue ( curObj , varDef . variableName ) ) ; } else if ( curType != null ) { Object initializer = curType . getPropertyInitializer ( varDef . variableName ) ; initStr = " = " + ( initializer == null ? " null" : ( initializer instanceof JavaSemanticNode ? ( ( JavaSemanticNode ) initializer ) . toLanguageString ( ) : initializer . toString ( ) ) ) ; } } System . out . println ( "Source: " + ( ( JavaSemanticNode ) varObj ) . toLanguageString ( ) . trim ( ) + ( initStr == null ? "" : initStr ) ) ; } else if ( ModelUtil . isProperty ( varObj ) ) { if ( curObj != null ) { DestinationListener dl = Bind . getBinding ( curObj , ModelUtil . getPropertyName ( varObj ) ) ; if ( dl != null ) System . out . println ( "Bound: " + dl . toString ( ) ) ; else System . out . println ( "Compiled property: " + varObj + " = " + TypeUtil . getPropertyValue ( curObj , def ) ) ; } else System . out . println ( "Compiled property: " + varObj ) ; } if ( methObj != null ) { if ( methObj instanceof AbstractMethodDefinition ) System . out . println ( "Source method: " + ( ( AbstractMethodDefinition ) methObj ) . toDefinitionString ( ) ) ; else System . out . println ( "Compiled method: " + methObj ) ; } if ( typeObj != null ) { if ( typeObj instanceof BodyTypeDeclaration ) System . out . println ( "Source type: " + ( ( BodyTypeDeclaration ) typeObj ) . toDeclarationString ( ) ) ; else System . out . println ( "Compiled type: " + typeObj ) ; } }
General debug method to print out all information about a definition by its name
General debug method to print out all information about a definition by its name
// Note: this is a bit wrong since we could have a method and member with the same name or a type // with the same name and this allows no way to override that.