Skip to content

Commit

Permalink
Don't bind the results of specified function calls to temp vars. Mark…
Browse files Browse the repository at this point in the history
… some cpp functions as such.
  • Loading branch information
hughsando committed Nov 1, 2014
1 parent 41cf47f commit 9f019f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ module Simplifier = struct
| TParenthesis e1 | TCast(e1,None) | TEnumParameter(e1,_,_) -> Type.iter loop e
| TField(_,(FStatic(c,cf) | FInstance(c,_,cf))) when has_analyzer_option cf.cf_meta flag_no_simplification || has_analyzer_option c.cl_meta flag_no_simplification -> ()
| TField({eexpr = TLocal _},_) when allow_tlocal -> ()
| TCall({eexpr = TField(_,(FStatic(c,cf) | FInstance(c,_,cf)))},el) when has_analyzer_option cf.cf_meta flag_no_simplification || has_analyzer_option c.cl_meta flag_no_simplification -> ()
| _ -> raise Exit
in
try
Expand Down
7 changes: 6 additions & 1 deletion std/cpp/ConstPointer.hx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package cpp;

@:coreType @:include("cpp/Pointer.h") @:native("cpp.Pointer")
@:analyzer(no_simplification)
extern class ConstPointer<T>
{
// ptr actually returns the pointer - not strictly a 'T' - for pointers to smart pointers
// Use value or ref to get dereferenced value
private var ptr:T;

@:analyzer(no_simplification)
public var value(get,never):T;
public var raw(get,never):RawConstPointer<T>;

public function get_raw() : RawConstPointer<T>;
@:analyzer(no_simplification)
public function get_value() : T;

public function lt(inOther:Pointer<T>):Bool;
public function leq(inOther:Pointer<T>):Bool;
Expand All @@ -23,10 +26,12 @@ extern class ConstPointer<T>

public function reinterpret<Other>():Pointer<Other>;

@:analyzer(no_simplification)
public function at(inIndex:Int):T;

public function inc():ConstPointer<T>;
public function dec():ConstPointer<T>;
@:analyzer(no_simplification)
public function postIncVal():T;
public function incBy(inT:Int):ConstPointer<T>;
public function add(inT:Int):ConstPointer<T>;
Expand Down
11 changes: 10 additions & 1 deletion std/cpp/Pointer.hx
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package cpp;

@:coreType
@:analyzer(no_simplification)
extern class Pointer<T> extends ConstPointer<T> implements ArrayAccess<T>
{
@:analyzer(no_simplification)
public var ref(get,set):T;

@:analyzer(no_simplification)
public function get_ref() : T;
@:analyzer(no_simplification)
public function set_ref(t:T) : T;


public static function fromHandle<T>(inHandle:Dynamic,?inKind:String) : Pointer<T>;

public static function fromPointer<T>(inNativePointer:Dynamic) : Pointer<T>;
Expand All @@ -13,13 +21,14 @@ extern class Pointer<T> extends ConstPointer<T> implements ArrayAccess<T>

public static function arrayElem<T>(array:Array<T>, inElem:Int):Pointer<T>;

override public function get_raw() : RawPointer<T>;
public function get_raw() : RawPointer<T>;

override public function inc():Pointer<T>;
override public function dec():Pointer<T>;
override public function incBy(inT:Int):Pointer<T>;
override public function add(inT:Int):Pointer<T>;

@:analyzer(no_simplification)
public function postIncRef():T;

public function destroy():Void;
Expand Down

0 comments on commit 9f019f9

Please sign in to comment.