/******************************************************************************* * Copyright (c) 2005, 2016 IBM Corporation 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 * *******************************************************************************/ package org.eclipse.dltk.ruby.typeinference.evaluators; import org.eclipse.dltk.ast.ASTNode; import org.eclipse.dltk.ruby.ast.RubyAssignment; import org.eclipse.dltk.ti.GoalState; import org.eclipse.dltk.ti.goals.ExpressionTypeGoal; import org.eclipse.dltk.ti.goals.GoalEvaluator; import org.eclipse.dltk.ti.goals.IGoal; import org.eclipse.dltk.ti.types.IEvaluatedType; public class AssignmentEvaluator extends GoalEvaluator { private IEvaluatedType result; public AssignmentEvaluator(IGoal goal) { super(goal); } @Override public IGoal[] init() { ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal; ASTNode expression = (typedGoal).getExpression(); if (!(expression instanceof RubyAssignment)) { return IGoal.NO_GOALS; } RubyAssignment expr = (RubyAssignment) expression; return new IGoal[] { new ExpressionTypeGoal(typedGoal.getContext(), expr.getRight()) }; } @Override public IGoal[] subGoalDone(IGoal subgoal, Object result, GoalState state) { this.result = (IEvaluatedType) result; return IGoal.NO_GOALS; } @Override public Object produceResult() { return result; } }