blob: 3e73801148945ccf03747154b4928daff2c6e24d [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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 */
reed@android.com8a1c16f2008-12-17 15:59:43 +00008#ifndef SkScriptRuntime_DEFINED
9#define SkScriptRuntime_DEFINED
10
11#include "SkOperand2.h"
12#include "SkTDArray_Experimental.h"
13#include "SkTDStack.h"
14
15class SkScriptCallBack;
16
rmistry@google.comd6176b02012-08-23 18:14:13 +000017typedef SkLongArray(SkString*) SkTDStringArray;
18typedef SkLongArray(SkScriptCallBack*) SkTDScriptCallBackArray;
reed@android.com8a1c16f2008-12-17 15:59:43 +000019
20class SkScriptRuntime {
21public:
rmistry@google.comd6176b02012-08-23 18:14:13 +000022 enum SkError {
23 kNoError,
24 kArrayIndexOutOfBounds,
25 kCouldNotFindReferencedID,
26 kFunctionCallFailed,
27 kMemberOpFailed,
28 kPropertyOpFailed
29 };
reed@android.com8a1c16f2008-12-17 15:59:43 +000030
rmistry@google.comd6176b02012-08-23 18:14:13 +000031 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);
reed@android.com8a1c16f2008-12-17 15:59:43 +000038private:
rmistry@google.comd6176b02012-08-23 18:14:13 +000039 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&);
reed@android.com8a1c16f2008-12-17 15:59:43 +000048};
49
caryclark@google.com16230cb2012-06-06 12:11:55 +000050#endif // SkScriptRuntime_DEFINED