fixed accelerator problem; slightly improved PHP Perspective
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / FalseLiteral.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.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.codegen.CodeStream;
15 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
16 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
17 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
18 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
19
20 public class FalseLiteral extends MagicLiteral {
21         static final char[] source = {'f', 'a', 'l', 's', 'e'};
22 public FalseLiteral(int s , int e) {
23         super(s,e);
24 }
25 public void computeConstant() {
26
27         constant = Constant.fromValue(false);}
28 /**
29  * Code generation for false literal
30  *
31  * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
32  * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
33  * @param valueRequired boolean
34  */
35 public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
36         int pc = codeStream.position;
37         if (valueRequired)
38                 codeStream.iconst_0();
39         codeStream.recordPositionsFrom(pc, this.sourceStart);
40 }
41 public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStream, Label trueLabel, Label falseLabel, boolean valueRequired) {
42
43         // falseLabel being not nil means that we will not fall through into the FALSE case
44
45         int pc = codeStream.position;
46         if (valueRequired) {
47                 if (falseLabel != null) {
48                         // implicit falling through the TRUE case
49                         if (trueLabel == null) {
50                                 codeStream.goto_(falseLabel);
51                         }
52                 }
53         }
54         codeStream.recordPositionsFrom(pc, this.sourceStart);
55 }
56 public TypeBinding literalType(BlockScope scope) {
57         return BooleanBinding;
58 }
59 /**
60  * 
61  */
62 public char[] source() {
63         return source;
64 }
65 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
66         visitor.visit(this, scope);
67         visitor.endVisit(this, scope);
68 }
69 }