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());
   }
 }
Example #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);
  }