1) Fixed issue #828: Non initialized variable warnings doesn't work with variables...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / TrueLiteral.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
17
18 public class TrueLiteral extends MagicLiteral {
19         static final char[] source = { 't', 'r', 'u', 'e' };
20
21         public TrueLiteral(int s, int e) {
22                 super(s, e);
23         }
24
25         public void computeConstant() {
26
27                 constant = Constant.fromValue(true);
28         }
29
30         /**
31          * Code generation for the true literal
32          * 
33          * @param currentScope
34          *            net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
35          * @param codeStream
36          *            net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
37          * @param valueRequired
38          *            boolean
39          */
40         // public void generateCode(BlockScope currentScope, CodeStream codeStream,
41         // boolean valueRequired) {
42         // int pc = codeStream.position;
43         // if (valueRequired)
44         // codeStream.iconst_1();
45         // codeStream.recordPositionsFrom(pc, this.sourceStart);
46         // }
47         // public void generateOptimizedBoolean(BlockScope currentScope, CodeStream
48         // codeStream, Label trueLabel, Label falseLabel, boolean valueRequired) {
49         //
50         // // trueLabel being not nil means that we will not fall through into the
51         // TRUE case
52         //
53         // int pc = codeStream.position;
54         // // constant == true
55         // if (valueRequired) {
56         // if (falseLabel == null) {
57         // // implicit falling through the FALSE case
58         // if (trueLabel != null) {
59         // codeStream.goto_(trueLabel);
60         // }
61         // }
62         // }
63         // codeStream.recordPositionsFrom(pc, this.sourceStart);
64         // }
65         public TypeBinding literalType(BlockScope scope) {
66                 return BooleanBinding;
67         }
68
69         /**
70          * 
71          */
72         public char[] source() {
73                 return source;
74         }
75
76         public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
77                 visitor.visit(this, scope);
78                 visitor.endVisit(this, scope);
79         }
80 }