protected IRExpression compile_impl() {
    ISymbol symbol = _expr().getSymbol();

    ICompilableType gsClass = getGosuClass();
    if ((Keyword.KW_this.equals(symbol.getName()) || Keyword.KW_super.equals(symbol.getName()))
        &&
        // 'this' must be an external symbol when in a program e.g., studio debugger expression
        (!(gsClass instanceof IGosuProgram) || gsClass.isAnonymous())) {
      if (_cc().isBlockInvoke() && _cc().currentlyCompilingBlock()) {
        while (gsClass instanceof IBlockClass) {
          gsClass = gsClass.getEnclosingType();
        }
        return pushOuter(gsClass);
      } else {
        return pushThis();
      }
    } else if (symbol instanceof DynamicPropertySymbol
        && ((DynamicPropertySymbol) symbol).getGetterDfs() instanceof OuterFunctionSymbol) {
      // 'outer'
      return pushOuterForOuterSymbol();
    } else {
      return pushSymbolValue(symbol);
    }
  }
Пример #2
0
 @Override
 public IModifierInfo getModifierInfo() {
   return symbol.getModifierInfo();
 }
Пример #3
0
 @Override
 public boolean isWritable() {
   return symbol.isWritable();
 }
Пример #4
0
 @Override
 public void setDefaultValueExpression(IExpression defaultValue) {
   symbol.setDefaultValueExpression(defaultValue);
 }
Пример #5
0
 @Override
 public boolean hasDynamicSymbolTable() {
   return symbol.hasDynamicSymbolTable();
 }
Пример #6
0
 @Override
 public void setType(IType type) {
   symbol.setType(type);
 }
Пример #7
0
 @Override
 public void setValue(Object value) {
   symbol.setValue(value);
 }
Пример #8
0
 @Override
 public boolean isInternal() {
   return symbol.isInternal();
 }
Пример #9
0
 @Override
 public boolean isProtected() {
   return symbol.isProtected();
 }
Пример #10
0
 @Override
 public String getFullDescription() {
   return symbol.getFullDescription();
 }
Пример #11
0
 @Override
 public boolean isPrivate() {
   return symbol.isPrivate();
 }
Пример #12
0
 @Override
 public List<IGosuAnnotation> getAnnotations() {
   return symbol.getAnnotations();
 }
Пример #13
0
 @Override
 public int getModifiers() {
   return symbol.getModifiers();
 }
Пример #14
0
 @Override
 public IReducedSymbol createReducedSymbol() {
   return symbol.createReducedSymbol();
 }
Пример #15
0
 @Override
 public String getDisplayName() {
   return symbol.getDisplayName();
 }
Пример #16
0
 @Override
 public boolean isPublic() {
   return symbol.isPublic();
 }
Пример #17
0
 @Override
 public IType getType() {
   return symbol.getType();
 }
Пример #18
0
 @Override
 public boolean isAbstract() {
   return symbol.isAbstract();
 }
Пример #19
0
 @Override
 public Object getValue() {
   return symbol.getValue();
 }
Пример #20
0
 @Override
 public boolean isFinal() {
   return symbol.isFinal();
 }
Пример #21
0
 @Override
 public IExpression getDefaultValueExpression() {
   return symbol.getDefaultValueExpression();
 }
Пример #22
0
 @Override
 public IScriptPartId getScriptPart() {
   return symbol.getScriptPart();
 }
Пример #23
0
 @Override
 public void setDynamicSymbolTable(ISymbolTable symTable) {
   symbol.setDynamicSymbolTable(symTable);
 }
Пример #24
0
 @Override
 public IGosuClass getGosuClass() {
   return symbol.getGosuClass();
 }
Пример #25
0
 @Override
 public ISymbolTable getDynamicSymbolTable() {
   return symbol.getDynamicSymbolTable();
 }
Пример #26
0
 @Override
 public boolean hasTypeVariables() {
   return symbol.hasTypeVariables();
 }
Пример #27
0
 @Override
 public void setValueIsBoxed(boolean b) {
   symbol.setValueIsBoxed(b);
 }
Пример #28
0
 @Override
 public Class<?> getSymbolClass() {
   return symbol.getSymbolClass();
 }
  public IRExpression pushSymbolValue(ISymbol symbol) {
    IType type = symbol.getType();
    Class symClass;
    IReducedSymbol reducedSym;
    if (symbol instanceof ReducedSymbol.SyntheticSymbol) {
      reducedSym = ((ReducedSymbol.SyntheticSymbol) symbol).getReducedSymbol();
      symClass = reducedSym.getSymbolClass();
    } else {
      reducedSym = symbol;
      symClass = symbol.getClass();
    }
    if (_cc().isExternalSymbol(reducedSym.getName())) {
      // unbox( symbols.getValue( name ) )
      return unboxValueToType(
          reducedSym.getType(),
          callMethod(
              IExternalSymbolMap.class,
              "getValue",
              new Class[] {String.class, int.class},
              pushExternalSymbolsMap(),
              Arrays.asList(
                  pushConstant(reducedSym.getName()), pushConstant(getArrayDims(reducedSym)))));
    } else if (DynamicSymbol.class.isAssignableFrom(symClass)) {
      // Instance or Static field

      IRProperty irProp = IRPropertyFactory.createIRProperty(reducedSym);
      if (!irProp.isStatic()) {
        if (isMemberOnEnclosingType(reducedSym) != null) {
          // Instance field from 'outer'
          return getField_new(
              irProp, pushOuter(reducedSym.getGosuClass()), getDescriptor(reducedSym.getType()));
        } else {
          // Instance field from 'this'
          return getField_new(irProp, pushThis(), getDescriptor(reducedSym.getType()));
        }
      } else {
        // Static field
        return getField_new(irProp, null, getDescriptor(reducedSym.getType()));
      }
    } else if (CapturedSymbol.class.isAssignableFrom(symClass)) {
      // Captured symbol is stored as a Field on an anonymous inner class (one elem array of
      // symbol's type)
      // e.g., val$myFiield[0] = value. Note a captured symbol is duplicated in all nested classes.
      IRProperty irProp = IRPropertyFactory.createIRProperty(getGosuClass(), reducedSym);
      return getField_new(irProp, pushThis(), getDescriptor(reducedSym.getType()));
    } else if (reducedSym.getIndex() >= 0) {
      // Local var

      if (reducedSym.isValueBoxed()) {
        // Local var is captured in an anonymous inner class.
        // Symbol's value maintained as a one elem array of symbol's type.
        return buildArrayLoad(
            identifier(_cc().getSymbol(reducedSym.getName())), 0, getDescriptor(type));
      } else {
        // Simple local var
        return identifier(_cc().getSymbol(reducedSym.getName()));
      }
    } else if (DynamicPropertySymbol.class.isAssignableFrom(symClass)) {
      IRProperty irProp;
      if (reducedSym instanceof DynamicPropertySymbol) {
        irProp = IRPropertyFactory.createIRProperty((DynamicPropertySymbol) reducedSym);
      } else {
        irProp = IRPropertyFactory.createIRProperty((ReducedDynamicPropertySymbol) reducedSym);
      }

      IRExpression root;
      if (irProp.isStatic()) {
        root = null;
      } else {
        ICompilableType targetType = isMemberOnEnclosingType(reducedSym);
        if (targetType != null) {
          root = pushOuter(targetType);
        } else {
          root = pushThis();
        }
      }
      IRExpression getterCall =
          callMethod(irProp.getGetterMethod(), root, Collections.<IRExpression>emptyList());
      return castResultingTypeIfNecessary(
          getDescriptor(reducedSym.getType()), irProp.getType(), getterCall);
    } else {
      throw new UnsupportedOperationException(
          "Don't know how to compile symbol: "
              + reducedSym.getClass().getSimpleName()
              + ": "
              + reducedSym.getName()
              + ": "
              + reducedSym.getType());
    }
  }
Пример #30
0
 @Override
 public boolean isValueBoxed() {
   return symbol.isValueBoxed();
 }