Package org.sugarj.driver.transformations.primitive

Source Code of org.sugarj.driver.transformations.primitive.ATermToString

package org.sugarj.driver.transformations.primitive;

import org.spoofax.interpreter.core.IContext;
import org.spoofax.interpreter.core.InterpreterException;
import org.spoofax.interpreter.library.AbstractPrimitive;
import org.spoofax.interpreter.stratego.Strategy;
import org.spoofax.interpreter.terms.IStrategoTerm;
import org.sugarj.common.ATermCommands;

/**
* Primitive for looking up and loading a model according to the current environment.
* If successful, this primitive returns the loaded model as a term.
*
* @author seba
*/
class ATermToString extends AbstractPrimitive {

  public ATermToString() {
    super("SUGARJ_aterm_to_string", 0, 0);
  }

  @Override
  public boolean call(IContext context, Strategy[] svars, IStrategoTerm[] tvars) throws InterpreterException {
    IStrategoTerm term = context.current();
    String s = term.toString();
    context.setCurrent(ATermCommands.makeString(s));
    return true;
  }
 
}
TOP

Related Classes of org.sugarj.driver.transformations.primitive.ATermToString

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.