public void pushScope(boolean bInitialInstanceMethodScope) {
   if (_scopes == null) {
     _scopes = new Stack<IRScope>();
   }
   IRScope parent = _scopes.isEmpty() ? null : _scopes.peek();
   _scopes.push(new IRScope(parent));
   if (bInitialInstanceMethodScope) {
     assert parent == null;
     _scopes.peek().addSymbol(Keyword.KW_this.getName(), _context.getIRTypeForCurrentClass());
   }
 }
Exemplo n.º 2
0
  private void implementToString() {
    Identifier thisId = new Identifier();
    thisId.setSymbol(new Symbol(Keyword.KW_this.getName(), this, null), new StandardSymbolTable());
    thisId.setType(this);

    BeanMethodCallExpression toStrCall = new BeanMethodCallExpression();
    toStrCall.setMethodDescriptor(JavaTypes.IBLOCK().getTypeInfo().getMethod("toString"));
    toStrCall.setRootExpression(thisId);
    toStrCall.setType(JavaTypes.STRING());

    ReturnStatement returnStmt = new ReturnStatement();
    returnStmt.setValue(toStrCall);
  }
  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);
    }
  }
 public String getDisplayName() {
   return Keyword.KW_this.toString();
 }