1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 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 org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.impl.*;
15 import org.eclipse.jdt.internal.compiler.codegen.*;
16 import org.eclipse.jdt.internal.compiler.lookup.*;
17
18 public class FalseLiteral extends MagicLiteral {
19 static final char[] source = {'f', 'a', 'l', 's', 'e'};
FalseLiteral(int s , int e)20 public FalseLiteral(int s , int e) {
21 super(s,e);
22 }
computeConstant()23 public void computeConstant() {
24
25 constant = Constant.fromValue(false);}
26 /**
27 * Code generation for false literal
28 *
29 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
30 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
31 * @param valueRequired boolean
32 */
generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired)33 public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
34 int pc = codeStream.position;
35 if (valueRequired)
36 codeStream.iconst_0();
37 codeStream.recordPositionsFrom(pc, this.sourceStart);
38 }
generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStream, Label trueLabel, Label falseLabel, boolean valueRequired)39 public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStream, Label trueLabel, Label falseLabel, boolean valueRequired) {
40
41 // falseLabel being not nil means that we will not fall through into the FALSE case
42
43 int pc = codeStream.position;
44 if (valueRequired) {
45 if (falseLabel != null) {
46 // implicit falling through the TRUE case
47 if (trueLabel == null) {
48 codeStream.goto_(falseLabel);
49 }
50 }
51 }
52 codeStream.recordPositionsFrom(pc, this.sourceStart);
53 }
literalType(BlockScope scope)54 public TypeBinding literalType(BlockScope scope) {
55 return BooleanBinding;
56 }
57 /**
58 *
59 */
source()60 public char[] source() {
61 return source;
62 }
traverse(ASTVisitor visitor, BlockScope scope)63 public void traverse(ASTVisitor visitor, BlockScope scope) {
64 visitor.visit(this, scope);
65 visitor.endVisit(this, scope);
66 }
67 }
68