180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2011 Google Inc.
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkOperand2_DEFINED
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkOperand2_DEFINED
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkScalar.h"
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkOpArray;
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkString;
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruunion SkOperand2 {
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum OpType {
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNoType,
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kS32 = 1,
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kScalar = 2,
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kString = 4,
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kArray = 8,
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kObject = 16
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkOpArray* fArray;
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void* fObject;
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    size_t fReference;
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int32_t fS32;
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar fScalar;
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkString* fString;
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct SkScriptValue2 {
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum IsConstant {
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kConstant,
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kVariable
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum IsWritten {
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUnwritten,
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kWritten
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkOperand2 fOperand;
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkOperand2::OpType fType : 8;
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    IsConstant fIsConstant : 8;
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    IsWritten fIsWritten : 8;
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkOpArray* getArray() { SkASSERT(fType == SkOperand2::kArray); return fOperand.fArray; }
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void* getObject() { SkASSERT(fType == SkOperand2::kObject); return fOperand.fObject; }
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int32_t getS32() { SkASSERT(fType == SkOperand2::kS32); return fOperand.fS32; }
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar getScalar() { SkASSERT(fType == SkOperand2::kScalar); return fOperand.fScalar; }
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkString* getString() { SkASSERT(fType == SkOperand2::kString); return fOperand.fString; }
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bool isConstant() const { return fIsConstant == kConstant; }
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif // SkOperand2_DEFINED
55