Browse Source

Don't bind the results of specified function calls to temp vars. Mark some cpp functions as such.

Hugh 10 years ago
parent
commit
9f019f9f8c
3 changed files with 17 additions and 2 deletions
  1. 1 0
      analyzer.ml
  2. 6 1
      std/cpp/ConstPointer.hx
  3. 10 1
      std/cpp/Pointer.hx

+ 1 - 0
analyzer.ml

@@ -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

+ 6 - 1
std/cpp/ConstPointer.hx

@@ -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;
@@ -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>;

+ 10 - 1
std/cpp/Pointer.hx

@@ -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>;
@@ -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;