system/src/sc/lang/java/JavaModel.java
public Object resolveName(String name, boolean create, boolean addExternalReference, boolean returnTypes) {
      if (!initialized)
         return null;
      Object type = findType(name);
      if (type != null) {
         if (type instanceof TypeDeclaration) {
            TypeDeclaration td = (TypeDeclaration) type;
            if (!td.isLayerType) {
               if (ModelUtil.isObjectType(td)) {
                  Object sysObj = layeredSystem != null ? layeredSystem.resolveName(name, create, getLayer(), isLayerModel, returnTypes) : null;
                  if (sysObj != null)
                     return sysObj;
                  else
                     System.err.println("*** Object type has no globally registered instance");
               }
               if (returnTypes) {
                  Class cl = td.getCompiledClass();
                  if (cl != null)
                     return cl;
               }
            }
         }
      }
      Object sysObj = layeredSystem != null ? layeredSystem.resolveName(name, create, getLayer(), isLayerModel, returnTypes) : null;
      if (sysObj != null)
         return sysObj;

      // Could be a little cleaner - only allocate the full name if at least the package matches.
      if (layer != null) {
         String prefix = getPackagePrefix();
         if (prefix == null) {
            if (name.equals(layer.getLayerUniqueName()))
               return layer;
         }
         else {
            if (name.startsWith(getPackagePrefix()) && name.equals(CTypeUtil.prefixPath(getPackagePrefix(), layer.getLayerUniqueName())))
               return layer;
         }
      }
      if (!returnTypes && commandInterpreter == null)
         return null;
      type = findTypeDeclaration(name, addExternalReference);

      // This implements the ability to refer to a non-static object in the command interpreter - either we select
      // a singleton or the wizard may have chosen a default instance for this type.
      if (commandInterpreter != null && type != null) {
         sysObj = commandInterpreter.getDefaultCurrentObj(type);
         if (sysObj != null)
            return sysObj;
      }
      return type;
   }
/**
    * This is called when evaluating an expression and we want to evaluate an identifier expression.  It first
    * looks for a local type in this file, then will go resolve a global one from the system.
    */
This is called when evaluating an expression and we want to evaluate an identifier expression.  It first
looks for a local type in this file, then will go resolve a global one from the system.
This is called when evaluating an expression and we want to evaluate an identifier expression . It first looks for a local type in this file then will go resolve a global one from the system .
public Object resolveName(String name, boolean create, boolean addExternalReference, boolean returnTypes) {
      if (!initialized)
         return null;
      Object type = findType(name);
      if (type != null) {
         if (type instanceof TypeDeclaration) {
            TypeDeclaration td = (TypeDeclaration) type;
            if (!td.isLayerType) {
               if (ModelUtil.isObjectType(td)) {
                  Object sysObj = layeredSystem != null ? layeredSystem.resolveName(name, create, getLayer(), isLayerModel, returnTypes) : null;
                  if (sysObj != null)
                     return sysObj;
                  else
                     System.err.println("*** Object type has no globally registered instance");
               }
               if (returnTypes) {
                  Class cl = td.getCompiledClass();
                  if (cl != null)
                     return cl;
               }
            }
         }
      }
      Object sysObj = layeredSystem != null ? layeredSystem.resolveName(name, create, getLayer(), isLayerModel, returnTypes) : null;
      if (sysObj != null)
         return sysObj;
      if (layer != null) {
         String prefix = getPackagePrefix();
         if (prefix == null) {
            if (name.equals(layer.getLayerUniqueName()))
               return layer;
         }
         else {
            if (name.startsWith(getPackagePrefix()) && name.equals(CTypeUtil.prefixPath(getPackagePrefix(), layer.getLayerUniqueName())))
               return layer;
         }
      }
      if (!returnTypes && commandInterpreter == null)
         return null;
      type = findTypeDeclaration(name, addExternalReference);
      if (commandInterpreter != null && type != null) {
         sysObj = commandInterpreter.getDefaultCurrentObj(type);
         if (sysObj != null)
            return sysObj;
      }
      return type;
   }
public Object resolveName ( String name , boolean create , boolean addExternalReference , boolean returnTypes ) { if ( ! initialized ) return null ; Object type = findType ( name ) ; if ( type != null ) { if ( type instanceof TypeDeclaration ) { TypeDeclaration td = ( TypeDeclaration ) type ; if ( ! td . isLayerType ) { if ( ModelUtil . isObjectType ( td ) ) { Object sysObj = layeredSystem != null ? layeredSystem . resolveName ( name , create , getLayer ( ) , isLayerModel , returnTypes ) : null ; if ( sysObj != null ) return sysObj ; else System . err . println ( "*** Object type has no globally registered instance" ) ; } if ( returnTypes ) { Class cl = td . getCompiledClass ( ) ; if ( cl != null ) return cl ; } } } } Object sysObj = layeredSystem != null ? layeredSystem . resolveName ( name , create , getLayer ( ) , isLayerModel , returnTypes ) : null ; if ( sysObj != null ) return sysObj ; if ( layer != null ) { String prefix = getPackagePrefix ( ) ; if ( prefix == null ) { if ( name . equals ( layer . getLayerUniqueName ( ) ) ) return layer ; } else { if ( name . startsWith ( getPackagePrefix ( ) ) && name . equals ( CTypeUtil . prefixPath ( getPackagePrefix ( ) , layer . getLayerUniqueName ( ) ) ) ) return layer ; } } if ( ! returnTypes && commandInterpreter == null ) return null ; type = findTypeDeclaration ( name , addExternalReference ) ; if ( commandInterpreter != null && type != null ) { sysObj = commandInterpreter . getDefaultCurrentObj ( type ) ; if ( sysObj != null ) return sysObj ; } return type ; }
This is called when evaluating an expression and we want to evaluate an identifier expression.
This is called when evaluating an expression and we want to evaluate an identifier expression .
// Could be a little cleaner - only allocate the full name if at least the package matches. // This implements the ability to refer to a non-static object in the command interpreter - either we select // a singleton or the wizard may have chosen a default instance for this type.