root/as2/E3Engine/ExpressionResult.as

リビジョン 299, 2.1 kB (コミッタ: yossy, コミット時期: 4 年 前)

Imported Lab code.

Line 
1 class ExpressionResult
2 {
3         public var type:String;
4         public var value:Object;
5        
6         public var isLeftHandSide:Boolean = false;
7        
8         public function ExpressionResult ()
9         {
10                 initialize();
11         }
12        
13         public static function createLiteral (value:Object) : ExpressionResult
14         {
15                 var instance:ExpressionResult = new ExpressionResult();
16                 instance.setTypeLiteral(value);
17                 return instance;
18         }
19         public static function createStack () : ExpressionResult
20         {
21                 var instance:ExpressionResult = new ExpressionResult();
22                 instance.setTypeStack();
23                 return instance;
24         }
25        
26         public function clone () : ExpressionResult
27         {
28                 var instance:ExpressionResult = new ExpressionResult();
29                 instance.setTypeAndValue(type, value);
30                 return instance;
31         }
32        
33         public function initialize () : Void
34         {
35                 type = 'empty';
36                 value = null;
37         }
38         public function setType (type:String) : Void
39         {
40                 this.type = type;
41         }
42         public function isType (type:String) : Boolean
43         {
44                 return (this.type == type);
45         }
46         public function setValue (value:Object) : Void
47         {
48                 this.value = value;
49         }
50         public function setTypeAndValue (type:String, value:Object) : Void
51         {
52                 this.type = type;
53                 this.value = value;
54         }
55         public function isLiteral () : Boolean
56         {
57                 return isType('literal');
58         }
59         public function isVariableOrMember () : Boolean
60         {
61                 return isVariable() || isMember();
62         }
63         public function isVariable () : Boolean
64         {
65                 return isType('variable');
66         }
67         public function isMember () : Boolean
68         {
69                 return isType('member');
70         }
71         public function setTypeStack () : Void
72         {
73                 setType('stack');
74         }
75         public function setTypeLiteral (value:Object) : Void
76         {
77                 setTypeAndValue('literal', value);
78         }
79         public function setTypeMember (objectExpression:ExpressionResult, memberExpression:ExpressionResult) : Void
80         {
81                 setTypeAndValue('member', {object: objectExpression, member: memberExpression});
82         }
83         public function getObjectExpression () : ExpressionResult
84         {
85                 if (!isMember()) return null;
86                
87                 return value.object;
88         }
89         public function getMemberExpression () : ExpressionResult
90         {
91                 if (!isMember()) return null;
92                
93                 return value.member;
94         }
95 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。