• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java OtpErlangList类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.ericsson.otp.erlang.OtpErlangList的典型用法代码示例。如果您正苦于以下问题:Java OtpErlangList类的具体用法?Java OtpErlangList怎么用?Java OtpErlangList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

OtpErlangList类属于com.ericsson.otp.erlang包,在下文中一共展示了OtpErlangList类的38个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: load

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Loads the differences from Erlang structure
 * 
 * @param obj where to load from
 */
public static ChangesToGraph load(OtpErlangObject obj)
{
	ChangesToGraph recorder = new ChangesToGraph();
	OtpErlangTuple difference = (OtpErlangTuple)obj;
	if (difference.arity() != 7)
		throw new IllegalArgumentException("expected 7 components in diff");
	if (!((OtpErlangAtom)difference.elementAt(0)).atomValue().equals("statemachinedifference"))
		throw new IllegalArgumentException("first element of a record should be \"statemachinedifference\"");
	OtpErlangList addedTransitions = (OtpErlangList)difference.elementAt(1),removedTransitions = (OtpErlangList)difference.elementAt(2),addedStates = (OtpErlangList)difference.elementAt(3);
	OtpErlangAtom initial_state = (OtpErlangAtom)difference.elementAt(6);			
	
	Synapse.StatechumProcess.parseStatemachine(addedStates,addedTransitions,new OtpErlangList(new OtpErlangObject[0]),initial_state,recorder.added,null,false);
	Synapse.StatechumProcess.parseStatemachine(new OtpErlangList(new OtpErlangObject[0]),removedTransitions,new OtpErlangList(new OtpErlangObject[0]),null,recorder.removed,null,false);
	recorder.relabelling.clear();
	Synapse.StatechumProcess.updateMap(difference.elementAt(5),recorder.relabelling);
	return recorder;
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:22,
代码来源:DifferenceVisualiser.java

示例2: updateConfiguration

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Using the supplied Erlang tuple, updates a supplied configuration. 
 * 
 * @param obj details to make to the pair.
 * @return null if everything went well or a text of an error message (mostly java-related) if it went wrong.
 */
public static String updateConfiguration(Configuration config, OtpErlangObject obj)
{
	String outcome = null;
	try
	{
		OtpErlangList list = (OtpErlangList) obj;
		for(OtpErlangObject p:list.elements())
		{
			OtpErlangTuple pair = (OtpErlangTuple) p;
			if (pair.arity() != 2)
				throw new IllegalArgumentException("key-value pair is not a pair, got "+p);
			config.assignValue(pair.elementAt(0).toString(), ((OtpErlangAtom)pair.elementAt(1)).atomValue(), true);
		}
	}
	catch(Throwable ex)
	{
		System.out.println(ex);
		outcome = ex.getMessage();
	}
	
	return outcome;
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:28,
代码来源:ErlangRunner.java

示例3: addFunctionToAlphabet

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** 
 * Used to take an existing function and generate an i/o pair for inclusion in an alphabet.
 * 
 * @param callName how the function should be called in traces. Important for OTP functions but should be the same as function name for ordinary exported functions. 
 * @param function function to be associated with this i/o pair.
 * @param config determines whether outputs are to be ignored.
 */
@Override
void addFunctionToAlphabet(String callName, FuncSignature function, Configuration config)
{
	List<List<OtpErlangObject>> args = function.instantiateAllArgs();
	List<OtpErlangObject> output = function.instantiateAllResults();

	for (List<OtpErlangObject> funcArgs : args) {
		OtpErlangList argsAsList = new OtpErlangList(funcArgs.toArray(new OtpErlangObject[]{}));
		
		if (config.getUseErlangOutputs()) {
			for (OtpErlangObject result : output) {
				alphabet.add(new ErlangLabel(function, callName, argsAsList, result));
			}
		} else {
			alphabet.add(new ErlangLabel(function, callName, argsAsList));
		}
	}
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:26,
代码来源:OTPUnknownBehaviour.java

示例4: loadDependencies

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/**
 * Extracts dependencies of the supplied module, assuming the module has
 * been successfully compiled and .beam file exists.
 * 
 * @param file
 *            the file of the module
 * @throws IOException
 *             if this fails.
 */
public void loadDependencies(File file, Configuration config) {
	OtpErlangTuple response = ErlangRunner.getRunner(config.getErlangMboxName()).call(
			new OtpErlangObject[] { new OtpErlangAtom("dependencies"),
					new OtpErlangAtom(ErlangRunner.getName(file, ErlangRunner.ERL.BEAM, config.getErlangCompileIntoBeamDirectory())) },
			"Could not load dependencies of " + file.getName());
	
	// the first element is 'ok'
	OtpErlangList listOfDepTuples = (OtpErlangList) response.elementAt(1);
	for (OtpErlangObject tup : listOfDepTuples.elements()) {
		String mod = ((OtpErlangAtom) ((OtpErlangTuple) tup).elementAt(0)).atomValue();
		if (!stdModsList.contains(mod) && !dependencies.contains(mod)) {
			dependencies.add(mod);
		}
	}
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:25,
代码来源:OTPBehaviour.java

示例5: parseStatemachine

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Given a representation of FSM in a form of Erlang tuple, builds the corresponding graph.
		 * 
		 * @param obj FSM to parse
		 * @param gr graph to fill in (whatever was in there will be replaced by the data loaded from the graph, this is necessary since we do not know the specific type to instantiate here).
		 * @param converter label converter
		 * @param checkStates if true, will check that all source and target states have been defined earlier. If false, will add them if needed.
		 */
		public static <TARGET_TYPE,CACHE_TYPE extends CachedData<TARGET_TYPE,CACHE_TYPE>> void parseStatemachine(OtpErlangObject obj,AbstractLearnerGraph<TARGET_TYPE,CACHE_TYPE> gr, ConvertALabel converter, boolean checkStates)
		{
//		1	  states :: list(state()),
//		2	  transitions :: list(transition()),
//		3	  initial_state :: state(),
//		4	  alphabet :: list(event())
			OtpErlangTuple machine = (OtpErlangTuple)obj;
			if (machine.arity() != 5)
				throw new IllegalArgumentException("expected 5 components in FSM");
			if (!((OtpErlangAtom)machine.elementAt(0)).atomValue().equals("statemachine"))
				throw new IllegalArgumentException("first element of a record should be \"statemachine\"");
			OtpErlangList states = (OtpErlangList)machine.elementAt(1),transitions = (OtpErlangList)machine.elementAt(2),alphabet = (OtpErlangList)machine.elementAt(4);
			OtpErlangAtom initial_state = (OtpErlangAtom)machine.elementAt(3);
			
			parseStatemachine(states,transitions,alphabet,initial_state,gr,converter,checkStates);
		}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:24,
代码来源:Synapse.java

示例6: constructFSM

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Turns the supplied graph into an Erlang tuple. 
 * @param gr graph to convert. 
 */
public static <TARGET_TYPE,CACHE_TYPE extends CachedData<TARGET_TYPE,CACHE_TYPE>> OtpErlangTuple constructFSM(AbstractLearnerGraph<TARGET_TYPE,CACHE_TYPE> gr)
{
	List<OtpErlangObject> statesList = new LinkedList<OtpErlangObject>(), transitions = new LinkedList<OtpErlangObject>();
	Map<String,OtpErlangObject> alphabet = new TreeMap<String,OtpErlangObject>();
	
	for(Entry<CmpVertex,Map<Label,TARGET_TYPE>> entry:gr.transitionMatrix.entrySet()) 
	{
		statesList.add(new OtpErlangAtom(entry.getKey().getStringId()));
		for(Entry<Label,TARGET_TYPE> transition:entry.getValue().entrySet())
		{
			String lblStr = transition.getKey().toErlangTerm();OtpErlangAtom lblAtom = new OtpErlangAtom(lblStr);
			alphabet.put(lblStr,lblAtom);
			for(CmpVertex target:gr.getTargets(transition.getValue()))
				transitions.add(new OtpErlangTuple(new OtpErlangObject[]{new OtpErlangAtom(entry.getKey().getStringId()), lblAtom, new OtpErlangAtom(target.getStringId())}));
		}
	}
	return new OtpErlangTuple(new OtpErlangObject[]{new OtpErlangAtom("statemachine"),new OtpErlangList(statesList.toArray(new OtpErlangObject[0])),
			new OtpErlangList(transitions.toArray(new OtpErlangObject[0])),
			new OtpErlangAtom(gr.getInit().getStringId()),new OtpErlangList(alphabet.values().toArray(new OtpErlangObject[alphabet.size()])),
	});
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:25,
代码来源:Synapse.java

示例7: updateFrom

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Deserialises a map of functions to their types and updates a provided map with their values.
 * 
 * @param list what to deserialise
 * @param map what to update.
 */
public static void updateFrom(OtpErlangList list,Map<String,OtpErlangTuple> map)
{
	for(OtpErlangObject obj:list.elements())
	{
		if (!(obj instanceof OtpErlangTuple))
			throw new IllegalArgumentException("element of a list should be a tuple");
		OtpErlangTuple t=(OtpErlangTuple)obj;
		if (t.arity() != 2)
			throw new IllegalArgumentException("tuple should contain exactly two elements");
		
		if (!(t.elementAt(0) instanceof OtpErlangAtom))
			throw new IllegalArgumentException("type name should be an atom");
		if (!(t.elementAt(1) instanceof OtpErlangTuple))
			throw new IllegalArgumentException("type value should be a tuple");
		map.put( ((OtpErlangAtom)t.elementAt(0)).atomValue(), (OtpErlangTuple)t.elementAt(1));
	}
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:23,
代码来源:Synapse.java

示例8: IntSignature

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
public IntSignature(@SuppressWarnings("unused") Configuration config, OtpErlangList attributes)
  {
  	long lowerValue = Long.MIN_VALUE, upperValue = Long.MAX_VALUE;values = null;
      for(OtpErlangObject obj:attributes.elements())
      	if (obj.equals(PositiveAtom))
      	{
      		lowerValue = 1;upperValue = Long.MAX_VALUE;
      	}
      	else
      		if (obj.equals(NegativeAtom))
      		{
      			lowerValue=Long.MIN_VALUE;upperValue=-1;
      		}
      		else
          		if (obj.equals(NonNegativeAtom))
          		{
          			lowerValue=0;upperValue = Long.MAX_VALUE;
          		}
      			else
      				throw new IllegalArgumentException("Unknown attribute "+obj+" in the list of attributes for IntSignature");

      lower=lowerValue;upper=upperValue;
erlangTermForThisType = erlangTypeToString(attributes, null);
 }
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:25,
代码来源:IntSignature.java

示例9: RecordSignature

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
public RecordSignature(Configuration config, OtpErlangList attributes,OtpErlangList fieldDetails) {
	if (attributes.arity() != 1) throw new IllegalArgumentException("RecordSignature expects a single attribute containing its name tag");
	orderedSignatures = new ArrayList<Signature>(fieldDetails.arity());
	nameTag = (OtpErlangAtom)attributes.elementAt(0);
	orderedSignatures.add(new AtomSignature(config,new OtpErlangList(),new OtpErlangList(new OtpErlangObject[]{
			nameTag
	})));
	name = nameTag.atomValue();
    fields = new TreeMap<String, Signature>();
    for(OtpErlangObject obj:fieldDetails)
    {
    	OtpErlangTuple nameValue = (OtpErlangTuple)obj;
    	if (nameValue.arity() != 2) throw new IllegalArgumentException("Invalid name-type field "+obj+" passed to RecordSignature");
    	Signature sig = Signature.buildFromType(config, nameValue.elementAt(1));
    	orderedSignatures.add(sig);
    	fields.put(((OtpErlangAtom)nameValue.elementAt(0)).atomValue(),sig);
    }
    erlangTermForThisType = erlangTypeToString(attributes,fieldDetails);
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:20,
代码来源:RecordSignature.java

示例10: checkEmptyList

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** This method is used to check a tail of an improper list. 
 * It returns true if a term can be used to make an improper list, false
 * otherwise and throws an exception if the supplied term represents a non-empty list. */
public static boolean checkEmptyList(OtpErlangObject term) {
	boolean outcome = false;
	if (term instanceof OtpErlangList) {
		if (((OtpErlangList) term).arity() > 0)
			throw new IllegalArgumentException(
					"the tail of an improper list cannot be a non-empty list");
		outcome = true;
	} else if (term instanceof OtpErlangString) {
		if (!((OtpErlangString) term).stringValue().isEmpty())
			throw new IllegalArgumentException(
					"the tail of an improper list cannot be a non-empty string (which is a list)");
		outcome = true;
	}

	return outcome;
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:20,
代码来源:ListSignature.java

示例11: dump

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
@Override
public void dump(OtpErlangObject arg, StringBuffer resultHolder) {
	OtpErlangList list = (OtpErlangList) arg;

	resultHolder.append("[");
	boolean first = true;
	for (OtpErlangObject obj : list.elements()) {
		if (!first)
			resultHolder.append(',');
		else
			first = false;
		classToDumper.get(obj.getClass()).dump(obj, resultHolder);
	}
	
	if (!list.isProper())
	{
		OtpErlangObject lastTail = list.getLastTail();resultHolder.append(" | ");
		classToDumper.get(lastTail.getClass()).dump(lastTail, resultHolder);
	}
	resultHolder.append("]");
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:22,
代码来源:ErlangLabel.java

示例12: testClosedRunner2

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Tests that an attempt to use a closed runner ID fails. */
@Test
public void testClosedRunner2()
{
	final ErlangRunner r = new ErlangRunner(erlRuntime.traceRunnerNode);
	Assert.assertFalse(r.mboxOpen);
	r.initRunner();
	Assert.assertTrue(r.mboxOpen);
	
	OtpErlangTuple response = (OtpErlangTuple)r.call(new OtpErlangObject[]{new OtpErlangAtom("echo"),
			new OtpErlangList(new OtpErlangObject[]{ new OtpErlangAtom(dataHead)})},
			0);
	Assert.assertEquals(dataHead,((OtpErlangAtom)response.elementAt(0)).atomValue());

	Assert.assertTrue(registeredProcessExists(r));

	r.close();
	Assert.assertFalse(r.mboxOpen);
	Assert.assertFalse(registeredProcessExists(r));
	
	// verify failure
	checkForCorrectException(new whatToRun() { public @Override void run() {
		r.call(new OtpErlangObject[]{new OtpErlangAtom("echoA")},200);
	}},IllegalArgumentException.class,"is closed");
	
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:27,
代码来源:TestErlangRunner.java

示例13: testToString12

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** A bigger structure to dump. */
@Test
public void testToString12()
{
	Assert.assertEquals("{\'this is an atom\',\"this is a string\",[[-234],{}]}",
			ErlangLabel.dumpErlangObject(new OtpErlangTuple(new OtpErlangObject[]{
					new OtpErlangAtom("this is an atom"),
					new OtpErlangString("this is a string"),
					new OtpErlangList(new OtpErlangObject[]{
							new OtpErlangList(new OtpErlangObject[]{
									new OtpErlangInt(-234)
							}),
							new OtpErlangTuple(new OtpErlangObject[]{
							})
					})
			})));
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:18,
代码来源:TestErlangParser.java

示例14: testParseBig

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
@Test
public void testParseBig()
{
	final String text = "{\'this is an atom\',\"this is a string\",[[-234],{}]}";
	OtpErlangObject obtained = ErlangLabel.parseText(text);
	checkResponse(runner, text, text);
	Assert.assertEquals(new OtpErlangTuple(new OtpErlangObject[]{
					new OtpErlangAtom("this is an atom"),
					new OtpErlangString("this is a string"),
					new OtpErlangList(new OtpErlangObject[]{
							new OtpErlangList(new OtpErlangObject[]{
									new OtpErlangInt(-234)
							}),
							new OtpErlangTuple(new OtpErlangObject[]{
							})
					})
			}),obtained);
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:19,
代码来源:TestErlangParser.java

示例15: testSetRed1

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
@Test
public void testSetRed1()
{
	Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
	LearnerGraphND grA = new LearnerGraphND(config);
	OtpErlangObject grAerlang = ErlangLabel.parseText("{statemachine,['P1000','P1002','N1000'],"+
            "[{'P1000',a,'P1000'},"+
            " {'P1000',b,'P1002'},"+
            " {'P1000',c,'N1000'},"+
            " {'P1002',c,'P1002'},"+
            " {'P1002',d,'P1002'}],"+
            "'P1000',"+
            "[d,b,c,a]}");
	Synapse.StatechumProcess.parseStatemachine(grAerlang,grA,null,true);
	Assert.assertEquals(0, grA.getRedStateNumber());
	Synapse.StatechumProcess.setReds(new OtpErlangList(new OtpErlangObject[]{new OtpErlangAtom("P1002")}), grA);
	Assert.assertEquals(JUConstants.RED,grA.findVertex("P1002").getColour());
	Assert.assertEquals(1, grA.getRedStateNumber());
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:20,
代码来源:TestSynapseAuxiliaryFunctions.java

示例16: testSetRed3

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
@Test
public void testSetRed3()
{
	Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
	final LearnerGraphND grA = new LearnerGraphND(config);
	OtpErlangObject grAerlang = ErlangLabel.parseText("{statemachine,['P1000','P1002','N1000'],"+
            "[{'P1000',a,'P1000'},"+
            " {'P1000',b,'P1002'},"+
            " {'P1000',c,'N1000'},"+
            " {'P1002',c,'P1002'},"+
            " {'P1002',d,'P1002'}],"+
            "'P1000',"+
            "[d,b,c,a]}");
	Synapse.StatechumProcess.parseStatemachine(grAerlang,grA,null,true);
	Assert.assertEquals(0, grA.getRedStateNumber());
	checkForCorrectException(new whatToRun() { public @Override void run() {
		Synapse.StatechumProcess.setReds(new OtpErlangList(new OtpErlangObject[]{new OtpErlangString("P1002")}), grA);
	}},ClassCastException.class,"OtpErlangString");
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:20,
代码来源:TestSynapseAuxiliaryFunctions.java

示例17: testSetRed4

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
@Test
public void testSetRed4()
{
	Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
	final LearnerGraphND grA = new LearnerGraphND(config);
	OtpErlangObject grAerlang = ErlangLabel.parseText("{statemachine,['P1000','P1002','N1000'],"+
            "[{'P1000',a,'P1000'},"+
            " {'P1000',b,'P1002'},"+
            " {'P1000',c,'N1000'},"+
            " {'P1002',c,'P1002'},"+
            " {'P1002',d,'P1002'}],"+
            "'P1000',"+
            "[d,b,c,a]}");
	Synapse.StatechumProcess.parseStatemachine(grAerlang,grA,null,true);
	Assert.assertEquals(0, grA.getRedStateNumber());
	checkForCorrectException(new whatToRun() { public @Override void run() {
		Synapse.StatechumProcess.setReds(new OtpErlangList(new OtpErlangObject[]{new OtpErlangAtom("P1009")}), grA);
	}},IllegalArgumentException.class,"not found");
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:20,
代码来源:TestSynapseAuxiliaryFunctions.java

示例18: testLayoutOptions4

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
@Test
public void testLayoutOptions4()
{
	final LayoutOptions options = new LayoutOptions();
	
	Assert.assertNull(options.ignoredStates);
	Synapse.StatechumProcess.setStateNamesToBeIgnored(options, new OtpErlangList(new OtpErlangObject[]{new OtpErlangAtom("a")}));
	Assert.assertNotNull(options.ignoredStates);
	Assert.assertEquals(1,options.ignoredStates.size());Assert.assertEquals("a",options.ignoredStates.iterator().next());
	
	Synapse.StatechumProcess.setStateNamesToBeIgnored(options, new OtpErlangList(new OtpErlangObject[]{new OtpErlangAtom("b"),new OtpErlangAtom("a")}));
	Assert.assertNotNull(options.ignoredStates);
	Assert.assertEquals(2,options.ignoredStates.size());
	Iterator<String> ignoreIterator = options.ignoredStates.iterator();
	Assert.assertEquals("a",ignoreIterator.next());Assert.assertEquals("b",ignoreIterator.next());
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:17,
代码来源:TestSynapseAuxiliaryFunctions.java

示例19: runDialyzerAndTyperAsAProcessInsideErlang

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Only used for testing against runTyperAsAProcess. 
  * @throws IOException */
 protected String runDialyzerAndTyperAsAProcessInsideErlang(File f) throws IOException
 {
 	ErlangRunner.compileErl(f, runner, true);
 	OtpErlangObject otpArgs[] = new OtpErlangObject[]{
     		null, 
	new OtpErlangList(new OtpErlangObject[]{new OtpErlangString(ErlangRunner.getName(f, ERL.BEAM, true))}),
	new OtpErlangString(ErlangRunner.getName(f, ERL.PLT, true)),
	new OtpErlangList(new OtpErlangObject[]{new OtpErlangString(ErlangRunner.getName(f, ERL.ERL, false))}),
	new OtpErlangAtom("text")
};
 	otpArgs[0]=new OtpErlangAtom("dialyzer");
 	runner.call(otpArgs,"Could not run dialyzer");
 	otpArgs[0]=new OtpErlangAtom("typer");
 	OtpErlangTuple response = runner.call(otpArgs,"Could not run typer");
 	return ((OtpErlangString)response.elementAt(1)).stringValue();
 }
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:19,
代码来源:TestErlangModule.java

示例20: testTyperUnreadableBeamFile

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
@Test
  public void testTyperUnreadableBeamFile()
  {
  	final File f = new File(ErlangExamples,"locker/locker.erl");
  	new File(ErlangRunner.getName(f, ERL.PLT,true)).delete();new File(ErlangRunner.getName(f, ERL.BEAM,true)).delete();
     	final OtpErlangObject otpArgs[] = new OtpErlangObject[]{
      		null, 
		new OtpErlangList(new OtpErlangObject[]{new OtpErlangString(ErlangRunner.getName(f, ERL.BEAM, true))}),
		new OtpErlangString(ErlangRunner.getName(f, ERL.PLT, true)),
		new OtpErlangList(new OtpErlangObject[]{new OtpErlangString(ErlangRunner.getName(f, ERL.ERL, false))}),
		new OtpErlangAtom("text")
	};
  	otpArgs[0]=new OtpErlangAtom("dialyzer");
Helper.checkForCorrectException(new statechum.Helper.whatToRun() {
	public @Override void run() throws IOException {
		runner.call(otpArgs,"Could not run dialyzer");
	}},ErlangThrownException.class,"Failed to obtain file info");
  }
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:19,
代码来源:TestErlangModule.java

示例21: populateFromMfaList

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
public void populateFromMfaList(OtpErlangList stackTrace) {
    try {
        for (OtpErlangObject obj : stackTrace) {
            if(obj instanceof OtpErlangString) {
                OtpErlangString errorMessage = (OtpErlangString) obj;
                getItems().add(new ErlyberlyStackTraceElement(errorMessage.stringValue()));
            }
            else {
                OtpErlangTuple tuple = OtpUtil.toTuple(obj);
                OtpErlangAtom module = (OtpErlangAtom) tuple.elementAt(0);
                OtpErlangAtom function = (OtpErlangAtom) tuple.elementAt(1);
                OtpErlangLong arity = (OtpErlangLong) tuple.elementAt(2);
                ModFunc modFunc = mfaToModFunc(module, function, arity);
                getItems().add(new ErlyberlyStackTraceElement(modFunc, "", 0L));
            }
        }
    }
    catch (Exception e) {
        // try/catch so if there is a problem decoding the process_dump, it won't
        // stop the trace log from being shown.
        e.printStackTrace();
    }
}
 

开发者ID:andytill,
项目名称:erlyberly,
代码行数:24,
代码来源:StackTraceView.java

示例22: onViewDict

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
public void onViewDict(ActionEvent e) {
    TreeItem<TermTreeItem> item = getSelectionModel().getSelectedItem();
    if(item == null)
        return;
    if(item.getValue() == null || !DICT_ATOM.equals(item.getValue().getObject()))
        return;
    if(item.getParent() == null || !(item.getParent().getValue().getObject() instanceof OtpErlangTuple))
        return;

    OtpErlangObject dict = item.getParent().getValue().getObject();

    try {
        OtpErlangList props = ErlyBerly.nodeAPI().dictToPropslist(dict);
        TermTreeView parentControl = new TermTreeView();
        parentControl.populateFromTerm(props);
        ErlyBerly.showPane("dict_to_list", ErlyBerly.wrapInPane(parentControl));
    }
    catch (Exception e1) {
        e1.printStackTrace();
    }
}
 

开发者ID:andytill,
项目名称:erlyberly,
代码行数:22,
代码来源:TermTreeView.java

示例23: modFuncArgsToString

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/**
 * Convert an MFA tuple to a string, where the MFA must have the type:
 *
 * {Module::atom(), Function::atom(), Args::[any()]}.
 */
@Override
public String modFuncArgsToString(OtpErlangTuple mfa) {
    StringBuilder sb = new StringBuilder();
    sb.append(moduleNameToString((OtpErlangAtom) mfa.elementAt(0)))
      .append(".")
      .append(funToStringNoQuotes((OtpErlangAtom) mfa.elementAt(1)))
      .append("(");
    OtpErlangList args = (OtpErlangList) mfa.elementAt(2);
    ArrayList<String> stringArgs = new ArrayList<>();
    for (OtpErlangObject arg : args) {
        stringArgs.add(toString(arg));
    }
    sb.append(String.join(", ", stringArgs));
    sb.append(")");
    return sb.toString();
}
 

开发者ID:andytill,
项目名称:erlyberly,
代码行数:22,
代码来源:ElixirFormatter.java

示例24: modFuncArgsToString

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/**
 * Convert an MFA tuple to a string, where the MFA must have the type:
 *
 * {Module::atom(), Function::atom(), Args::[any()]}.
 */
@Override
public String modFuncArgsToString(OtpErlangTuple mfa) {
    StringBuilder sb = new StringBuilder();
    sb.append("(")
      .append(mfa.elementAt(0))
      .append(":")
      .append(mfa.elementAt(1));
    OtpErlangList args = (OtpErlangList) mfa.elementAt(2);
    ArrayList<String> stringArgs = new ArrayList<>();
    for (OtpErlangObject arg : args) {
        stringArgs.add(toString(arg));
    }
    sb.append(String.join(", ", stringArgs))
      .append(")");
    return sb.toString();
}
 

开发者ID:andytill,
项目名称:erlyberly,
代码行数:22,
代码来源:LFEFormatter.java

示例25: modFuncArgsToString

点赞 3

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/**
 * Convert an MFA tuple to a string, where the MFA must have the type:
 *
 * {Module::atom(), Function::atom(), Args::[any()]}.
 */
@Override
public String modFuncArgsToString(OtpErlangTuple mfa) {
    StringBuilder sb = new StringBuilder();
    sb.append(atomToStringNoQuotes((OtpErlangAtom) mfa.elementAt(0)))
      .append(":")
      .append(atomToStringNoQuotes((OtpErlangAtom) mfa.elementAt(1)))
      .append("(");
    OtpErlangList args = (OtpErlangList) mfa.elementAt(2);
    ArrayList<String> stringArgs = new ArrayList<>();
    for (OtpErlangObject arg : args) {
        stringArgs.add(toString(arg));
    }
    sb.append(String.join(", ", stringArgs));
    sb.append(")");
    return sb.toString();
}
 

开发者ID:andytill,
项目名称:erlyberly,
代码行数:22,
代码来源:ErlangFormatter.java

示例26: readSequenceFromErlangObject

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
public List<String> readSequenceFromErlangObject(OtpErlangObject obj) 
{
	if (!(obj instanceof OtpErlangList))
		throw new IllegalArgumentException("expected a sequence, got "+obj);
	List<String> outcome = new LinkedList<String>();
	for(OtpErlangObject o:((OtpErlangList)obj))
	{
		if (!(o instanceof OtpErlangString))
			throw new IllegalArgumentException("expected a string, got "+o);
		outcome.add(((OtpErlangString)o).stringValue());
	}
	return outcome;
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:14,
代码来源:StatechumXML.java

示例27: readSequenceList

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Loads a collection of sequences of the form [ [elem1,elem2, ... ], [elem11,elem12, ... ] ] */
@Override
public List<List<String>> readSequenceList(String sequence) 
{
	OtpErlangObject obj = ErlangLabel.parseText(sequence);
	if (!(obj instanceof OtpErlangList))
		throw new IllegalArgumentException("expected a sequence of sequences, got "+obj);
	List<List<String>> outcome = new LinkedList<List<String>>();
	for(OtpErlangObject o:((OtpErlangList)obj))
		outcome.add(readSequenceFromErlangObject(o));
	return outcome;
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:13,
代码来源:StatechumXML.java

示例28: readInputSequenceFromErlangObject

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Given a string containing the whole of the expression to parse, parses the text and returns the
    * corresponding Erlang trace. This is not a complete trace - it cannot really be passed to Erlang 
    * for execution because labels of which it consists are not associated with actual functions.
    *  
    * @param str label to parse
    * @param config configuration to use 
    * Uses the module in the configuration to provide definitions of functions to associated with labels. Will 
    * generic name <em>ErlangLabel.missing</em> if <em>mod</em> is null.
    * @param conv converter for labels, not used if null.
    * @return the outcome.
    */
public static List<Label> readInputSequenceFromErlangObject(OtpErlangObject obj,Configuration config, ConvertALabel conv) 
{
	if (!(obj instanceof OtpErlangList))
		throw new IllegalArgumentException("expected a sequence, got "+obj);
   	OtpErlangList list = (OtpErlangList)obj;
   	List<Label> outcome = new LinkedList<Label>();
   	
   	for(OtpErlangObject o:list.elements())
   	{
   		Label label = null;
   		switch(config.getLabelKind())
   		{
   		case LABEL_STRING:
   			if (!(o instanceof OtpErlangAtom))
   				throw new IllegalArgumentException("a string label has to look like Erlang Atom");
   			label = new StringLabel( ((OtpErlangAtom)o).atomValue() );
   			break;
   		case LABEL_ERLANG:
   			label = ErlangLabel.erlangObjectToLabel(o,config);
   			break;
   		default:
   			throw new IllegalArgumentException("No parser available for traces of type "+config.getLabelKind());
   		}
   		
   		if (conv != null) label = conv.convertLabelToLabel(label);
   		outcome.add(label);
   		
   	}
   	return outcome;
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:42,
代码来源:StatechumXML.java

示例29: serialiseDoubleArray

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Converts the supplied array to the corresponding Erlang representation. */
private static OtpErlangList serialiseDoubleArray(double []array)
{
	if (array == null)
		return new OtpErlangList();// empty list
	OtpErlangDouble convertedArray[] = new OtpErlangDouble[array.length];for(int i=0;i<array.length;++i) convertedArray[i]=new OtpErlangDouble(array[i]);
	return new OtpErlangList(convertedArray);
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:9,
代码来源:GD.java

示例30: compileErl

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/**
 * Compiles the supplied file into .beam if .erl has been modified after an
 * existing .beam (date of last change is 0 if file does not exist).
 * 
 * @param whatToCompile
 *            file to compile
 * @param useRunner
 *            ask Erlang compiler to perform the compile - no need to launch
 *            compiler as a separate process.
 * @param beamDirectory where to place the compiled file. If null, will use the file name of the Erlang module to determine where to place the compiled .beam file.
 * @throws IOException
 *             if something goes wrong.
 */
public static void compileErl(File whatToCompile, ErlangRunner useRunner, File whereToPlaceBeam)	throws IOException 
{
	String erlFileName = getName(whatToCompile, ERL.ERL,null);
	if (whatToCompile.getParentFile() == null)
		throw new IllegalArgumentException(
				"File does not have a parent directory " + whatToCompile);

	if (!whatToCompile.canRead())
		throw new IOException("file " + erlFileName + " does not exist");
	
	File beamDirectory = whereToPlaceBeam != null? whereToPlaceBeam:whatToCompile.getAbsoluteFile().getParentFile();
	
	if (whatToCompile.lastModified() > new File(getName(whatToCompile, ERL.BEAM,whereToPlaceBeam)).lastModified()) 
	{
		if (useRunner == null) {
			Process p = Runtime.getRuntime().exec(
					new String[] { ErlangRunner.getErlangBin() + "erlc",
							"+debug_info", erlFileName }, null, beamDirectory);
			ErlangRuntime.dumpProcessOutputOnFailure("erlc " + whatToCompile.getName(), p);
		} else 
		{
			useRunner.call(new OtpErlangObject[] {
							new OtpErlangAtom("compile"),
							new OtpErlangList(
									new OtpErlangObject[] { new OtpErlangAtom(
											erlFileName) }),
							new OtpErlangAtom("erlc"),
							new OtpErlangAtom(beamDirectory.getAbsolutePath()) },
							"cannot compile ");
		}
	}
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:46,
代码来源:ErlangRunner.java

示例31: killProcesses

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
public OtpErlangTuple killProcesses(OtpErlangList proclist) 
{
	OtpErlangTuple outcome = null;
	if (proclist != null) 
	{
		outcome = call(new OtpErlangObject[] {
				new OtpErlangAtom("killProcesses"), proclist },
				"Failed to kill processes.");
	}
	
	return outcome;
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:13,
代码来源:ErlangRunner.java

示例32: parseTraces

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
protected void parseTraces(OtpErlangObject traces)
{
	OtpErlangList listOfTraces = (OtpErlangList)traces;
	for(OtpErlangObject entryObj:listOfTraces)
	{
		OtpErlangTuple entry = (OtpErlangTuple)entryObj;
		if (entry.arity() != 2)
			throw new IllegalArgumentException("invalid trace: more than a pair of pos/neg and data");
		
		boolean positive = false;
		OtpErlangAtom traceType = (OtpErlangAtom)entry.elementAt(0);
		if (traceType.atomValue().equals("pos"))
			positive = true;
		else
			if (traceType.atomValue().equals("neg"))
				positive = false;
			else
				throw new IllegalArgumentException("invalid trace: got "+entry.elementAt(0)+" instead of pos/neg");
		
		OtpErlangList traceData = (OtpErlangList)entry.elementAt(1);
		List<Label> data = new LinkedList<Label>();
		for(OtpErlangObject traceElement:traceData)
			data.add(AbstractLearnerGraph.generateNewLabel( ((OtpErlangAtom)traceElement).atomValue(), learnerInitConfiguration.config, learnerInitConfiguration.getLabelConverter()));
		
		if (positive) sPlus.add(data);else sMinus.add(data);
	}		
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:28,
代码来源:Synapse.java

示例33: updateMap

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
public static void updateMap(OtpErlangObject obj, Map<VertID,VertID> outcome)
{
	OtpErlangList map = (OtpErlangList)obj;
	for(OtpErlangObject entry:map)
	{
		OtpErlangTuple entryTuple = (OtpErlangTuple)entry;
		if (entryTuple.arity() != 2)
			throw new IllegalArgumentException("invalid tuple "+entryTuple);
		
		String stateA = ((OtpErlangAtom)entryTuple.elementAt(0)).atomValue();if (stateA.isEmpty()) throw new IllegalArgumentException("empty first state name");
		String stateB = ((OtpErlangAtom)entryTuple.elementAt(1)).atomValue();if (stateB.isEmpty()) throw new IllegalArgumentException("empty second state name");
		outcome.put(VertexID.parseID( stateA ),VertexID.parseID( stateB ) );
	}
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:15,
代码来源:Synapse.java

示例34: mapToObject

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
public static OtpErlangList mapToObject(Map<VertID,VertID> map)
{
	List<OtpErlangObject> outcome = new LinkedList<OtpErlangObject>();
	for(Entry<VertID,VertID> entry:map.entrySet())
	{
		outcome.add(new OtpErlangTuple(new OtpErlangObject[]{new OtpErlangAtom(entry.getKey().getStringId()),new OtpErlangAtom(entry.getValue().getStringId())}));
	}
	return new OtpErlangList(outcome.toArray(new OtpErlangObject[0]));
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:10,
代码来源:Synapse.java

示例35: setReds

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Given a list of states in the supplied object, assigns red colour to the matching states in the supplied graph.
 *  
 * @param obj list of red states
 * @param gr graph to modify
 */
public static <TARGET_TYPE,CACHE_TYPE extends CachedData<TARGET_TYPE,CACHE_TYPE>> void setReds(OtpErlangObject obj,AbstractLearnerGraph<TARGET_TYPE,CACHE_TYPE> gr)
{
	for(OtpErlangObject st:(OtpErlangList)obj)
	{
		String state = ((OtpErlangAtom)st).atomValue();if (state.isEmpty()) throw new IllegalArgumentException("empty state name");
		CmpVertex v=gr.findVertex(VertexID.parseID(state));
		if (v == null) throw new IllegalArgumentException(state+" state not found");
		v.setColour(JUConstants.RED);
	}
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:16,
代码来源:Synapse.java

示例36: setStateNamesToBeIgnored

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Given an Erlang tuple, extract names of states to be ignored and adds them to the options. If any cast goes wrong, throws a cast exception.
 * 
 * @param options layout options where to add names
 * @param stateNamesAsObject where to get the names from 
 */
public static void setStateNamesToBeIgnored(LayoutOptions options, OtpErlangObject stateNamesAsObject)
{
	
	OtpErlangList statesToBeIgnored = (OtpErlangList)stateNamesAsObject;
	if (statesToBeIgnored.arity() > 0 && options != null)
	{
		if (options.ignoredStates == null)
			options.ignoredStates = new TreeSet<String>();
		for(OtpErlangObject obj:statesToBeIgnored)
			options.ignoredStates.add( ((OtpErlangAtom)obj).atomValue() );
	}
	
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:19,
代码来源:Synapse.java

示例37: setOptions

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Goes through the options provided in a message, starting with the specific index and updates the graph to be visualised to respect those options. Returns the window number in which to pop the graph, negative for a test mode. 
 * 
 * @param message OTP tuple with options
 * @param startFrom the starting position in the tuple to go through
 * @param fsmPicture graph to update
 * @return window number to use or negative for a test mode.
 * @throws OtpErlangRangeException 
 */
public static int setOptions(final OtpErlangTuple message, int startFrom, DirectedSparseGraph fsmPicture) throws OtpErlangRangeException
{
	int windowNumber = 0;
	OtpErlangObject name = message.elementAt(startFrom);
	if (name instanceof OtpErlangList && ((OtpErlangList)name).arity() == 0)
		windowNumber =-1;
	else
	{
		fsmPicture.setUserDatum(JUConstants.TITLE, ((OtpErlangAtom)name).atomValue(), UserData.SHARED);
	
		if (message.arity() > startFrom+1)
		{
			OtpErlangObject stateNamesAsObject = message.elementAt(startFrom+1);
			setStateNamesToBeIgnored(((LayoutOptions)fsmPicture.getUserDatum(JUConstants.LAYOUTOPTIONS)),stateNamesAsObject);
		}
		if (message.arity() > startFrom+2)
		{
			OtpErlangLong windowNum = ((OtpErlangLong)message.elementAt(startFrom+2));windowNumber = windowNum.intValue();
		}
		if (message.arity() > startFrom+3)
		{
			OtpErlangLong abstraction = ((OtpErlangLong)message.elementAt(startFrom+3));
			((LayoutOptions)fsmPicture.getUserDatum(JUConstants.LAYOUTOPTIONS)).componentsToPick=abstraction.intValue();
		}
	}
	return windowNumber;
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:36,
代码来源:Synapse.java

示例38: typeMapToList

点赞 2

import com.ericsson.otp.erlang.OtpErlangList; //导入依赖的package包/类
/** Given a map of object names to their types, serialises it into an Erlang list.
 *  
 * @param map what to serialise
 * @return Erlang list
 */
public static OtpErlangList typeMapToList(Map<String,OtpErlangTuple> map)
{
	OtpErlangTuple mapping [] = new OtpErlangTuple[map.size()];
	int i=0;
	for(Entry<String,OtpErlangTuple> entry:map.entrySet())
		mapping[i++]=new OtpErlangTuple(new OtpErlangObject[]{new OtpErlangAtom(entry.getKey()),entry.getValue()});
	return new OtpErlangList(mapping);
}
 

开发者ID:kirilluk,
项目名称:statechum,
代码行数:14,
代码来源:Synapse.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)