Summary: @public 1. Add support for `this` keyword. It will allow to access fields/methods of the object from the method body. 2. Fix problem with method formals to add pointer to type of first parameter (which corresponds to `this`) Reviewed By: @dulmarod Differential Revision: D2484882 fb-gh-sync-id: c318619master
parent
f8b8078538
commit
4d10c8d9f4
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
class A {
|
||||
int field;
|
||||
public:
|
||||
void init(int val) { field = val; }
|
||||
int method();
|
||||
};
|
||||
|
||||
int A::method() {
|
||||
init(10); // call method on the object
|
||||
return field;
|
||||
}
|
||||
|
||||
void test() {
|
||||
A *a_ptr;
|
||||
a_ptr->method();
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
digraph iCFG {
|
||||
10 [label="10: Call _fun_A_method \n n$0=*&a_ptr:class A * [line 24]\n n$1=_fun_A_method(n$0:class A ) [line 24]\n REMOVE_TEMPS(n$0,n$1); [line 24]\n NULLIFY(&a_ptr,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"]
|
||||
|
||||
|
||||
10 -> 9 ;
|
||||
9 [label="9: Exit test \n " color=yellow style=filled]
|
||||
|
||||
|
||||
8 [label="8: Start test\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 22]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
8 -> 10 ;
|
||||
7 [label="7: Call _fun_A_init \n n$2=*&this:class A * [line 18]\n _fun_A_init(n$2:class A ,10:int ) [line 18]\n REMOVE_TEMPS(n$2); [line 18]\n " shape="box"]
|
||||
|
||||
|
||||
7 -> 6 ;
|
||||
6 [label="6: Return Stmt \n n$0=*&this:class A * [line 19]\n n$1=*n$0.field:int [line 19]\n *&return:int =n$1 [line 19]\n REMOVE_TEMPS(n$0,n$1); [line 19]\n NULLIFY(&this,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: Exit A_method \n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 [label="4: Start A_method\nFormals: this:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 -> 7 ;
|
||||
3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class A * [line 13]\n n$1=*&val:int [line 13]\n *n$0.field:int =n$1 [line 13]\n REMOVE_TEMPS(n$0,n$1); [line 13]\n NULLIFY(&this,false); [line 13]\n NULLIFY(&val,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit A_init \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start A_init\nFormals: this:class A * val:int \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 3 ;
|
||||
}
|
Loading…
Reference in new issue