1 2 /* 3 * Copyright 2011 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 #ifndef SkScriptRuntime_DEFINED 9 #define SkScriptRuntime_DEFINED 10 11 #include "SkOperand2.h" 12 #include "SkTDArray_Experimental.h" 13 #include "SkTDStack.h" 14 15 class SkScriptCallBack; 16 17 typedef SkLongArray(SkString*) SkTDStringArray; 18 typedef SkLongArray(SkScriptCallBack*) SkTDScriptCallBackArray; 19 20 class SkScriptRuntime { 21 public: 22 enum SkError { 23 kNoError, 24 kArrayIndexOutOfBounds, 25 kCouldNotFindReferencedID, 26 kFunctionCallFailed, 27 kMemberOpFailed, 28 kPropertyOpFailed 29 }; 30 SkScriptRuntime(SkTDScriptCallBackArray & callBackArray)31 SkScriptRuntime(SkTDScriptCallBackArray& callBackArray) : fCallBackArray(callBackArray) 32 { } 33 ~SkScriptRuntime(); 34 bool executeTokens(unsigned char* opCode); 35 bool getResult(SkOperand2* result); 36 void untrack(SkOpArray* array); 37 void untrack(SkString* string); 38 private: 39 void track(SkOpArray* array); 40 void track(SkString* string); 41 SkTDScriptCallBackArray& fCallBackArray; 42 SkError fError; 43 SkTDStack<SkOperand2> fRunStack; 44 SkLongArray(SkOpArray*) fTrackArray; 45 SkTDStringArray fTrackString; 46 // illegal 47 SkScriptRuntime& operator=(const SkScriptRuntime&); 48 }; 49 50 #endif // SkScriptRuntime_DEFINED