use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class CommandData method addUserInput.
// non-interactive
public void addUserInput(final List<String> input) {
final List<OtpErlangObject> argsTmp = new LinkedList<>();
final OtpErlangObject[] userInput = new OtpErlangObject[input.size()];
int i = 0;
for (final String text : input) {
userInput[i] = new OtpErlangString(text);
i++;
}
for (final OtpErlangObject arg : args) {
if (arg instanceof OtpErlangTuple && ((OtpErlangTuple) arg).elementAt(0).equals(new OtpErlangAtom("prompt"))) {
argsTmp.add(new OtpErlangList(userInput));
// TODO make it so that it adds input only once, check repeat
// interactive
} else {
argsTmp.add(arg);
}
}
args = argsTmp.toArray(new OtpErlangObject[0]);
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class ErlangProcess method setStackFrames.
public void setStackFrames(final String module, final int line, final OtpErlangList erlStackFrames, final OtpErlangList bs) {
stackFrames = new ArrayList<>();
final IDebugTarget target = getDebugTarget();
stackFrames.add(new ErlangStackFrame(module, this, target, line, null, bs, erlStackFrames.arity() + 2));
for (final OtpErlangObject o : erlStackFrames) {
final OtpErlangTuple t = (OtpErlangTuple) o;
final OtpErlangTuple mfa;
final OtpErlangObject el0 = t.elementAt(0);
final OtpErlangObject el1 = t.elementAt(1);
if (el0 instanceof OtpErlangTuple) {
mfa = (OtpErlangTuple) el0;
} else if (el1 instanceof OtpErlangTuple) {
mfa = (OtpErlangTuple) el1;
} else {
mfa = t;
}
int stackFrameNo;
final OtpErlangObject mfa0 = mfa.elementAt(0);
if (!(mfa0 instanceof OtpErlangAtom)) {
ErlLogger.debug("%s", mfa0);
}
final OtpErlangAtom m = (OtpErlangAtom) mfa0;
final OtpErlangLong l = (OtpErlangLong) t.elementAt(1);
final OtpErlangList bindings = (OtpErlangList) t.elementAt(2);
final OtpErlangLong n = (OtpErlangLong) t.elementAt(3);
int lin;
try {
lin = l.intValue();
} catch (final OtpErlangRangeException e) {
lin = -1;
}
final String mod = m.atomValue();
try {
stackFrameNo = n.intValue();
} catch (final OtpErlangRangeException e) {
stackFrameNo = -1;
}
stackFrames.add(new ErlangStackFrame(mod, this, target, lin, null, bindings, stackFrameNo));
}
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class CoverEventHandler method gotResults.
/**
* When coverage results came
*
* @param msg
* @return
*/
private boolean gotResults(final OtpErlangObject msg) {
if (msg instanceof OtpErlangTuple) {
final OtpErlangTuple resTuple = (OtpErlangTuple) msg;
if (resTuple.elementAt(0) instanceof OtpErlangAtom && ((OtpErlangAtom) resTuple.elementAt(0)).atomValue().equals(CoverEventHandler.COVER_RES)) {
final String moduleName = resTuple.elementAt(1).toString();
String htmlPath = resTuple.elementAt(2).toString();
htmlPath = htmlPath.substring(1, htmlPath.length() - 1);
final int allLines = Integer.parseInt(resTuple.elementAt(3).toString());
final int coveredLines = Integer.parseInt(resTuple.elementAt(4).toString());
final double percent = Double.parseDouble(resTuple.elementAt(5).toString());
log.info(String.format("Module %s %s %d %d %f", moduleName, htmlPath, allLines, coveredLines, percent));
final ModuleStats moduleStats = new ModuleStats();
moduleStats.setLabel(moduleName);
moduleStats.setHtmlPath(htmlPath);
moduleStats.setLiniesCount(allLines);
moduleStats.setCoverCount(coveredLines);
try {
final File file = new File(ErlangEngine.getInstance().getModel().findModule(moduleName).getFilePath());
moduleStats.setMd5(MD5Checksum.getMD5(file));
} catch (final Exception e) {
ErlLogger.error(e);
}
//
prepLineResults((OtpErlangList) resTuple.elementAt(6), moduleStats);
prepFuncResults((OtpErlangList) resTuple.elementAt(7), moduleStats);
addModuleToTree(moduleStats);
ModuleSet.add(moduleStats);
return true;
}
}
return false;
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class ErlParser method addOtherAttribute.
private IErlAttribute addOtherAttribute(final IErlModule module, final OtpErlangObject pos, final OtpErlangObject val, final OtpErlangObject extra, final String nameS) {
// user-defined attribute? or maybe if else endif...
// OtpErlangObject val1 = concreteTerm(val);
// if (val instanceof OtpErlangList) {
// final OtpErlangList list = (OtpErlangList) val;
// if (list.arity() == 0) {
// val1 = null;
// }
// }
// final ErlAttribute a = new ErlAttribute(parent, nameS, val1, null);
OtpErlangObject o = val;
if (o instanceof OtpErlangAtom) {
final OtpErlangAtom u = (OtpErlangAtom) o;
if ("u".equals(u.atomValue())) {
o = null;
}
}
final ErlAttribute a = new ErlAttribute(module, nameS, o, Util.stringValue(extra));
setPos(a, pos);
// a.setParseTree(val);
return a;
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class ErlParser method makeErlFunction.
/**
* @param module
* module
* @param el
* -record(function, {pos, name, arity, args, head, clauses, name_pos,
* comment, exported}).
* @return ErlFunction
*/
private ErlFunction makeErlFunction(final IErlModule module, final OtpErlangTuple el) {
final OtpErlangTuple pos = (OtpErlangTuple) el.elementAt(1);
final OtpErlangAtom name = (OtpErlangAtom) el.elementAt(2);
final OtpErlangLong arity = (OtpErlangLong) el.elementAt(3);
final OtpErlangList parameters = (OtpErlangList) el.elementAt(4);
final OtpErlangObject head = el.elementAt(5);
final OtpErlangTuple namePos = (OtpErlangTuple) el.elementAt(7);
ErlFunction f = null;
final OtpErlangAtom exportedA = (OtpErlangAtom) el.elementAt(8);
final boolean exported = Boolean.parseBoolean(exportedA.atomValue());
try {
f = new ErlFunction(module, name.atomValue(), arity.intValue(), Util.stringValue(head), exported, parameters);
} catch (final OtpErlangRangeException e) {
return f;
}
setPos(f, pos);
try {
setNamePos(f, namePos);
} catch (final OtpErlangRangeException e) {
}
return f;
}
Aggregations