本文整理汇总了Java中org.spoofax.interpreter.terms.IStrategoTerm.TUPLE属性的典型用法代码示例。如果您正苦于以下问题:Java IStrategoTerm.TUPLE属性的具体用法?Java IStrategoTerm.TUPLE怎么用?Java IStrategoTerm.TUPLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.spoofax.interpreter.terms.IStrategoTerm
的用法示例。
在下文中一共展示了IStrategoTerm.TUPLE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeAnnotations
public static IStrategoTerm removeAnnotations(IStrategoTerm inTerm, final ITermFactory factory) {
TermTransformer trans = new TermTransformer(factory, true) {
@Override public IStrategoTerm preTransform(IStrategoTerm term) {
switch(term.getTermType()) {
case IStrategoTerm.APPL:
return factory.makeAppl(((IStrategoAppl) term).getConstructor(), term.getAllSubterms(), null);
case IStrategoTerm.LIST:
return factory.makeList(term.getAllSubterms(), null);
case IStrategoTerm.STRING:
return factory.makeString(((IStrategoString) term).stringValue());
case IStrategoTerm.TUPLE:
return factory.makeTuple(term.getAllSubterms(), null);
default:
return term;
}
}
};
return trans.transform(inTerm);
}
示例2: dispatch
private static boolean dispatch(IStrategoTermVisitor visitor, IStrategoTerm term) {
switch(term.getTermType()) {
case IStrategoTerm.APPL:
return visitor.visit((IStrategoAppl) term);
case IStrategoTerm.LIST:
return visitor.visit((IStrategoList) term);
case IStrategoTerm.TUPLE:
return visitor.visit((IStrategoTuple) term);
case IStrategoTerm.INT:
visitor.visit((IStrategoInt) term);
return false;
case IStrategoTerm.REAL:
visitor.visit((IStrategoReal) term);
return false;
case IStrategoTerm.STRING:
visitor.visit((IStrategoString) term);
return false;
case IStrategoTerm.REF:
visitor.visit((IStrategoRef) term);
return false;
case IStrategoTerm.PLACEHOLDER:
return visitor.visit((IStrategoPlaceholder) term);
default:
return visitor.visit(term);
}
}
示例3: getTermArguments
private IStrategoTerm getTermArguments(IContext env, IStrategoTerm t) throws InterpreterException {
switch(t.getTermType()) {
case IStrategoTerm.INT:
case IStrategoTerm.REAL:
return env.getFactory().makeList();
case IStrategoTerm.APPL:
IStrategoAppl a = (IStrategoAppl)t;
if (Tools.isNil(a, env) || Tools.isCons(a, env))
return t;
else
return env.getFactory().makeList(a.getAllSubterms());
case IStrategoTerm.LIST:
return t;
case IStrategoTerm.STRING:
return env.getFactory().makeList();
case IStrategoTerm.TUPLE:
IStrategoTuple tup = (IStrategoTuple) t;
IStrategoTerm[] args = new IStrategoTerm[tup.getSubtermCount()];
for(int i = 0; i < args.length; i++)
args[i] = tup.get(i);
return env.getFactory().makeList(args);
}
throw new InterpreterException("Unknown term '" + t + "'");
}
示例4: match
public static <T> T match(IStrategoTerm term, ICases<T> cases) {
switch(term.getTermType()) {
case IStrategoTerm.APPL:
return cases.caseAppl((IStrategoAppl) term);
case IStrategoTerm.LIST:
return cases.caseList((IStrategoList) term);
case IStrategoTerm.TUPLE:
return cases.caseTuple((IStrategoTuple) term);
case IStrategoTerm.INT:
return cases.caseInt((IStrategoInt) term);
case IStrategoTerm.REAL:
return cases.caseReal((IStrategoReal) term);
case IStrategoTerm.STRING:
return cases.caseString((IStrategoString) term);
default:
throw new IllegalArgumentException("Unsupported Stratego term type " + term.getTermType());
}
}
示例5: getTermArguments
private IStrategoTerm getTermArguments(IContext env, IStrategoTerm t) throws InterpreterException {
switch(t.getTermType()) {
case IStrategoTerm.INT:
case IStrategoTerm.REAL:
return env.getFactory().makeList();
case IStrategoTerm.APPL:
IStrategoAppl a = (IStrategoAppl)t;
if (Tools.isNil(a, env) || Tools.isCons(a, env))
return t;
else
return env.getFactory().makeList(a.getArguments());
case IStrategoTerm.LIST:
return t;
case IStrategoTerm.STRING:
return env.getFactory().makeList();
case IStrategoTerm.TUPLE:
IStrategoTuple tup = (IStrategoTuple) t;
IStrategoTerm[] args = new IStrategoTerm[tup.getSubtermCount()];
for(int i = 0; i < args.length; i++)
args[i] = tup.get(i);
return env.getFactory().makeList(args);
}
throw new InterpreterException("Unknown term '" + t + "'");
}
示例6: rebuildIfNecessary
private IStrategoTerm rebuildIfNecessary(IStrategoTerm term) {
if(term.getTermType() == IStrategoTerm.APPL) {
IStrategoAppl appl = (IStrategoAppl) term;
if(context.getConstructorSignatures().containsKey(appl.getConstructor().getName())
&& TypesmartSortAttachment.getSorts(appl) == null)
return makeAppl(appl.getConstructor(), appl.getAllSubterms(), appl.getAnnotations());
else
return appl;
} else {
IStrategoTerm[] kids = new IStrategoTerm[term.getSubtermCount()];
boolean changed = false;
int i = 0;
for(IStrategoTerm kid : term) {
IStrategoTerm newkid = rebuildIfNecessary(kid);
kids[i] = newkid;
changed = changed || kid != newkid;
}
if(changed) {
switch(term.getTermType()) {
case IStrategoTerm.LIST:
return makeList(kids, term.getAnnotations());
case IStrategoTerm.TUPLE:
return makeTuple(kids, term.getAnnotations());
default:
throw new IllegalStateException();
}
} else {
return term;
}
}
}
示例7: doSlowMatch
@Override
protected boolean doSlowMatch(IStrategoTerm second, int commonStorageType) {
if (second.getTermType() != IStrategoTerm.TUPLE)
return false;
IStrategoTuple snd = (IStrategoTuple) second;
if (size() != snd.size())
return false;
IStrategoTerm[] kids = this.kids;
IStrategoTerm[] secondKids = snd.getAllSubterms();
if (kids != secondKids) {
for (int i = 0, sz = kids.length; i < sz; i++) {
IStrategoTerm kid = kids[i];
IStrategoTerm secondKid = secondKids[i];
if (kid != secondKid && !kid.match(secondKid)) {
if (commonStorageType == SHARABLE && i != 0)
System.arraycopy(secondKids, 0, kids, 0, i);
return false;
}
}
if (commonStorageType == SHARABLE)
this.kids = secondKids;
}
IStrategoList annotations = getAnnotations();
IStrategoList secondAnnotations = second.getAnnotations();
if (annotations == secondAnnotations) {
return true;
} else if (annotations.match(secondAnnotations)) {
if (commonStorageType == SHARABLE) internalSetAnnotations(secondAnnotations);
return true;
} else {
return false;
}
}
示例8: match
public Results match(IContext env, IStrategoTerm t, IStrategoAppl p)
throws InterpreterException {
if (t == null) {
throw new InterpreterException("Null term while matching: term library or one of the primitives is defective");
}
switch (t.getTermType()) {
case IStrategoTerm.APPL:
return matchAppl(env, (IStrategoAppl) t, p);
case IStrategoTerm.INT:
return matchInt(env, (IStrategoInt) t, p);
case IStrategoTerm.REAL:
return matchReal(env, (IStrategoReal) t, p);
case IStrategoTerm.STRING:
return matchString(env, (IStrategoString) t, p);
case IStrategoTerm.LIST:
return matchList(env, (IStrategoList) t, p);
case IStrategoTerm.TUPLE:
return matchTuple(env, (IStrategoTuple) t, p);
case IStrategoTerm.REF:
return matchRef(env, (IStrategoRef)t, p);
case IStrategoTerm.BLOB:
return matchBlob(env, t, p);
default:
throw new InterpreterException("Unsupported term type : "
+ t.getClass().toString() + " [" + t.getTermType() + "]");
}
}
示例9: call
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
throws InterpreterException {
ITermFactory factory = env.getFactory();
switch(tvars[0].getTermType()) {
case IStrategoTerm.APPL:
IStrategoAppl a = (IStrategoAppl) tvars[0];
env.setCurrent(factory.makeString(a.getConstructor().getName()));
return true;
case IStrategoTerm.INT:
env.setCurrent(factory.makeInt(((IStrategoInt) tvars[0]).intValue()));
return true;
case IStrategoTerm.REAL:
env.setCurrent(factory.makeReal(((IStrategoReal) tvars[0]).realValue()));
return true;
case IStrategoTerm.BLOB:
env.setCurrent(factory.makeString("BLOB_" + tvars[0].toString()));
return true;
case IStrategoTerm.LIST:
env.setCurrent(factory.makeList());
return true;
case IStrategoTerm.STRING:
IStrategoString current = (IStrategoString) factory.annotateTerm(tvars[0], factory.makeList());
env.setCurrent(factory.makeString(current.toString()));
return true;
case IStrategoTerm.TUPLE:
env.setCurrent(factory.makeString(""));
return true;
case IStrategoTerm.PLACEHOLDER:
env.setCurrent(factory.makePlaceholder(factory.makeList()));
return true;
default:
throw new IllegalStateException("SSL_get_constructor failed for " + tvars[0]);
}
}
示例10: call
@Override
public boolean call(IContext env, Strategy[] svars, IStrategoTerm[] tvars)
throws InterpreterException {
switch(tvars[0].getTermType()) {
case IStrategoTerm.APPL:
IStrategoAppl a = (IStrategoAppl) tvars[0];
env.setCurrent(env.getFactory().makeList(a.getAllSubterms()));
return true;
case IStrategoTerm.INT:
case IStrategoTerm.STRING:
case IStrategoTerm.REAL:
case IStrategoTerm.BLOB:
env.setCurrent(env.getFactory().makeList());
return true;
case IStrategoTerm.LIST:
env.setCurrent(tvars[0]);
return true;
case IStrategoTerm.TUPLE:
IStrategoTuple tuple = (IStrategoTuple) tvars[0];
env.setCurrent(env.getFactory().makeList(tuple.getAllSubterms()));
return true;
case IStrategoTerm.PLACEHOLDER:
IStrategoPlaceholder placeholder = (IStrategoPlaceholder) tvars[0];
env.setCurrent(env.getFactory().makeList(placeholder.getTemplate()));
return true;
default:
throw new IllegalStateException("SSL_get_arguments failed for " + tvars[0]);
}
}
示例11: match
public Results match(IContext env, IStrategoTerm t, IStrategoAppl p)
throws InterpreterException {
if (t == null) {
throw new InterpreterException("Null term while matching: term library is defective");
}
switch (t.getTermType()) {
case IStrategoTerm.APPL:
return matchAppl(env, (IStrategoAppl) t, p);
case IStrategoTerm.INT:
return matchInt(env, (IStrategoInt) t, p);
case IStrategoTerm.REAL:
return matchReal(env, (IStrategoReal) t, p);
case IStrategoTerm.STRING:
return matchString(env, (IStrategoString) t, p);
case IStrategoTerm.LIST:
return matchList(env, (IStrategoList) t, p);
case IStrategoTerm.TUPLE:
return matchTuple(env, (IStrategoTuple) t, p);
case IStrategoTerm.REF:
return matchRef(env, (IStrategoRef)t, p);
case IStrategoTerm.BLOB:
return matchBlob(env, t, p);
default:
throw new InterpreterException("Unsupported term type : "
+ t.getClass().toString() + " [" + t.getTermType() + "]");
}
}
示例12: getTermType
public int getTermType() {
return IStrategoTerm.TUPLE;
}
示例13: isTermTuple
public static boolean isTermTuple(IStrategoTerm t) {
return t.getTermType() == IStrategoTerm.TUPLE;
}