Skip to main content
summaryrefslogtreecommitdiffstats
blob: 15ae2ea6d5d864c2101d107d0bf5313d9d8eadcf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*******************************************************************************
 * Copyright (c) 2005, 2007 committers of openArchitectureWare and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     committers of openArchitectureWare - initial API and implementation
 *******************************************************************************/

package org.eclipse.internal.xpand2.ast;

import java.util.Set;

import org.eclipse.internal.xtend.expression.ast.Expression;
import org.eclipse.xpand2.XpandExecutionContext;
import org.eclipse.xtend.expression.AnalysationIssue;
import org.eclipse.xtend.expression.ExecutionContext;

/**
 * *
 * 
 * @author Sven Efftinge (http://www.efftinge.de) *
 */
public class ExpressionStatement extends org.eclipse.internal.xpand2.ast.Statement {

    private Expression expression;

    public ExpressionStatement( final Expression expression) {
        this.expression = expression;
    }

    public Expression getExpression() {
        return expression;
    }

    @Override
	public void analyzeInternal(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) {
        getExpression().analyze(ctx, issues);
    }

    @Override
    public void evaluateInternal(final XpandExecutionContext ctx) {
        final Object val = getExpression().evaluate(ctx);
        if (val != null) {
            ctx.getOutput().write(val.toString());
        }
    }

	@Override
	public String getNameString(ExecutionContext context) {
		if (expression != null)
			return "EXPRESSION: " + expression.getNameString(context);
		return super.toString();
	}

	@Override
	public String toString() {
		if (expression != null)
			return "EXPRESSION: " + expression.toString();
		return super.toString();
	}


}

Back to the top