本文整理汇总了Java中li.cil.oc.api.machine.Value类的典型用法代码示例。如果您正苦于以下问题:Java Value类的具体用法?Java Value怎么用?Java Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Value类属于li.cil.oc.api.machine包,在下文中一共展示了Value类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: save
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
@Override
public void save(NBTTagCompound nbt) {
mmu.save(nbt);
for(Map.Entry<Value,Byte> pair : valueToHandle.entrySet()) {
Value val = pair.getKey();
NBTTagCompound saved = new NBTTagCompound();
val.save(saved);
if(saved.hasKey("__class")) {
MainClass.logger.warn("While saving a Value: It already gave itself a __class key, but we're about to override it!");
saved.setString("__class", val.getClass().getName());
}
nbt.setTag("Value"+(pair.getValue()&0xFF), saved);
}
nbt.setByte("NextValue", nextValueHandle);
nbt.setByte("A", cpu.readA());
nbt.setByte("P", cpu.readP());
nbt.setByte("S", cpu.readS());
nbt.setByte("X", cpu.readX());
nbt.setByte("Y", cpu.readY());
nbt.setShort("PC", cpu.readPC());
if(cpu.getState() != State.RUNNING) nbt.setString("State", cpu.getState().toString());
if(cpu.getNMIWasSeen()) nbt.setBoolean("NMIWasSeen", true);
if(cpu.getSOWasSeen()) nbt.setBoolean("SOWasSeen", true);
}
开发者ID:SolraBizna,项目名称:j6502,代码行数:25,代码来源:OCMOS.java
示例2: mapValue
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public byte mapValue(Value value) throws IOException {
Byte wat = valueToHandle.get(value);
if(wat != null) throw new RuntimeException("Same Value mapped more than once!");
byte lastNextValueHandle = nextValueHandle;
while(handleToValue.containsKey(nextValueHandle)) {
++nextValueHandle;
if(nextValueHandle == lastNextValueHandle) throw new IOException("Attempted to map too many values");
}
handleToValue.put(nextValueHandle, value);
valueToHandle.put(value, nextValueHandle);
return nextValueHandle++;
}
开发者ID:SolraBizna,项目名称:j6502,代码行数:13,代码来源:OCMOS.java
示例3: disposeValue
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public void disposeValue(byte handle, Context ctx) {
Value v = handleToValue.get(handle);
if(v != null) {
handleToValue.remove(handle);
valueToHandle.remove(v);
v.dispose(ctx);
}
}
开发者ID:SolraBizna,项目名称:j6502,代码行数:9,代码来源:OCMOS.java
示例4: disposeAllValues
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public void disposeAllValues(Context ctx) {
for(Value v : valueToHandle.keySet()) {
v.dispose(ctx);
}
handleToValue.clear();
valueToHandle.clear();
}
开发者ID:SolraBizna,项目名称:j6502,代码行数:8,代码来源:OCMOS.java
示例5: mapValue
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public int mapValue(Value value) {
Integer wat = valueToHandle.get(value);
if(wat != null)
throw new RuntimeException("Same Value mapped more than once");
else {
// unhardcode this for the main mod
//if(handleToValue.size() >= 32) throw new RuntimeException("Too many Values");
while(nextValueHandle == 0 || handleToValue.get(nextValueHandle) != null) ++nextValueHandle;
valueToHandle.put(value, nextValueHandle);
handleToValue.put(nextValueHandle, value);
System.err.println("Mapped value: "+nextValueHandle);
return nextValueHandle++;
}
}
开发者ID:SolraBizna,项目名称:jarm,代码行数:15,代码来源:JARMArchitecture.java
示例6: disposeValue
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public void disposeValue(int handle, Context ctx) {
Value v = handleToValue.get(handle);
if(v != null) {
System.err.println("Disposed value: "+handle);
v.dispose(ctx);
handleToValue.remove(handle);
valueToHandle.remove(v);
}
else System.err.println("NONEXISTENT VALUE DISPOSED: "+handle);
}
开发者ID:SolraBizna,项目名称:jarm,代码行数:11,代码来源:JARMArchitecture.java
示例7: disposeAllValues
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public void disposeAllValues(Context ctx) {
System.err.println("Disposed all values");
for(Value v : valueToHandle.keySet()) {
v.dispose(ctx);
}
valueToHandle.clear();
handleToValue.clear();
}
开发者ID:SolraBizna,项目名称:jarm,代码行数:9,代码来源:JARMArchitecture.java
示例8: mapValue
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public int mapValue(Value value) {
Integer wat = valueToHandle.get(value);
if(wat != null)
throw new RuntimeException("Same Value mapped more than once");
else {
if(handleToValue.size() >= MAX_VALUES) throw new RuntimeException("Value limit exceeded");
while(nextValueHandle == 0 || handleToValue.get(nextValueHandle) != null) ++nextValueHandle;
valueToHandle.put(value, nextValueHandle);
handleToValue.put(nextValueHandle, value);
System.err.println("Mapped value: "+nextValueHandle);
return nextValueHandle++;
}
}
开发者ID:SolraBizna,项目名称:jarm,代码行数:14,代码来源:JARMArchitecture.java
示例9: disposeValue
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public void disposeValue(int handle, Context ctx) {
Value v = handleToValue.get(handle);
if(v != null) {
OCARM.logger.debug("Disposed value: "+handle);
v.dispose(ctx);
handleToValue.remove(handle);
valueToHandle.remove(v);
}
else OCARM.logger.debug("NONEXISTENT VALUE DISPOSED: "+handle);
}
开发者ID:SolraBizna,项目名称:jarm,代码行数:11,代码来源:JARMArchitecture.java
示例10: init
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public static void init() {
final MethodSelector peripheralSelector = new MethodSelector(Constants.ARCH_OPEN_COMPUTERS)
.allowReturnSignal()
.addDefaultEnv()
.addProvidedEnv(Constants.ARG_ACCESS, IArchitectureAccess.class)
.addProvidedEnv(Constants.ARG_CONTEXT, Context.class)
.addProvidedEnv(Constants.ARG_NODE, Node.class);
PERIPHERAL_METHODS_FACTORY = new EnvironmentMethodsFactory<ManagedEnvironment>(
AdapterRegistry.PERIPHERAL_ADAPTERS,
peripheralSelector,
PERIPHERAL_CLASS_PREFIX,
new PeripheralCodeGenerator());
InjectedClassesManager.instance.registerProvider(PERIPHERAL_CLASS_PREFIX, new EnvironmentClassBytesProvider<ManagedEnvironment>(PERIPHERAL_METHODS_FACTORY));
final MethodSelector objectSelector = new MethodSelector(Constants.ARCH_OPEN_COMPUTERS)
// .allowReturnSignal() // for symmetry with CC
.addDefaultEnv()
.addProvidedEnv(Constants.ARG_CONTEXT, Context.class);
OBJECT_METHODS_FACTORY = new EnvironmentMethodsFactory<Value>(
AdapterRegistry.OBJECT_ADAPTERS,
objectSelector,
OBJECT_CLASS_PREFIX,
new ObjectCodeGenerator());
InjectedClassesManager.instance.registerProvider(OBJECT_CLASS_PREFIX, new EnvironmentClassBytesProvider<Value>(OBJECT_METHODS_FACTORY));
CommandDump.addArchSerializer("OpenComputers", "peripheral", DocBuilder.TILE_ENTITY_DECORATOR, PERIPHERAL_METHODS_FACTORY);
CommandDump.addArchSerializer("OpenComputers", "object", DocBuilder.SCRIPT_OBJECT_DECORATOR, OBJECT_METHODS_FACTORY);
final IConverter converter = new TypeConversionRegistryOC();
TypeConvertersProvider.INSTANCE.registerConverter(Constants.ARCH_OPEN_COMPUTERS, converter);
TypeClassifier.INSTANCE.registerType(Value.class, SingleArgType.OBJECT);
ENV = new OpenComputersEnv(converter);
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:40,代码来源:ModuleOpenComputers.java
示例11: wrapObject
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
@Override
public Value wrapObject(Object target) {
try {
return wrap(target, ModuleOpenComputers.OBJECT_METHODS_FACTORY);
} catch (Throwable t) {
throw new GenerationFailedException(String.format("%s (%s)", target, target.getClass()), t);
}
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:9,代码来源:AdapterFactoryWrapperOC.java
示例12: testObject
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
@Test
public void testObject() throws Exception {
setupEnvMocks();
Map<String, Pair<IMethodExecutor, IMethodCall>> mocks = Maps.newHashMap();
addDefaultMethods(mocks);
Map<String, IMethodExecutor> methods = extractExecutors(mocks);
ICodeGenerator generator = new ObjectCodeGenerator();
Class<?> cls = generateClass("TestClass\u2656", TargetClass.class, ImmutableSet.of(InterfaceA.class, InterfaceB.class), methods, generator);
final TargetClass target = mock(TargetClass.class);
Object o = cls.getConstructor(TargetClass.class).newInstance(target);
Assert.assertTrue(o instanceof ICallerBase);
Assert.assertTrue(o instanceof Value);
Assert.assertTrue(o instanceof InterfaceA);
Assert.assertTrue(o instanceof InterfaceB);
verifyCallThrough(target, o);
testMethods(mocks, cls, target, o, new ArgVerifier() {
@Override
public void verifyCall(IMethodCall call, Context context) {
verify(ModuleOpenComputers.ENV).addObjectArgs(call, context);
}
});
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:31,代码来源:EnvironmentGeneratorTest.java
示例13: getValue
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public Value getValue(byte handle) {
return handleToValue.get(handle);
}
开发者ID:SolraBizna,项目名称:j6502,代码行数:4,代码来源:OCMOS.java
示例14: invoke
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
@Override
public Object[] invoke(Value value, String method, Object[] args)
throws Exception {
// TODO Auto-generated method stub
return null;
}
开发者ID:SolraBizna,项目名称:jarm,代码行数:7,代码来源:FakeMachine.java
示例15: getValue
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public Value getValue(int handle) {
return handleToValue.get(handle);
}
开发者ID:SolraBizna,项目名称:jarm,代码行数:4,代码来源:JARMArchitecture.java
示例16: wrapObject
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public static Value wrapObject(Object target) {
Preconditions.checkNotNull(target, "Can't wrap null");
IEnviromentInstanceWrapper<Value> wrapper = OBJECT_METHODS_FACTORY.getAdaptedClass(target.getClass());
return wrapper.isEmpty()? null : wrapper.createEnvironment(target);
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:6,代码来源:ModuleOpenComputers.java
示例17: TypeConversionRegistryOC
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
public TypeConversionRegistryOC() {
super(LUA_OFFSET);
registerIgnored(Value.class, true);
outbound.addFirst(new ConverterCallableOC());
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:6,代码来源:TypeConversionRegistryOC.java
示例18: testObjectNullConstructor
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testObjectNullConstructor() throws Throwable {
setupEnvMocks();
Map<String, Pair<IMethodExecutor, IMethodCall>> mocks = Maps.newHashMap();
addMethod(mocks, "a1", true, "desc1");
Map<String, IMethodExecutor> methods = extractExecutors(mocks);
ICodeGenerator generator = new ObjectCodeGenerator();
Class<?> cls = generateClass("TestClass\u2657", TargetClass.class, ImmutableSet.<Class<?>> of(), methods, generator);
// argument-less ctor, for serialization
Object o = cls.getConstructor().newInstance();
Assert.assertTrue(o instanceof Value);
Method m = getMethod(cls, "a1");
Arguments args = mock(Arguments.class);
Context context = mock(Context.class);
try {
m.invoke(o, context, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:31,代码来源:EnvironmentGeneratorTest.java
示例19: wrapObject
import li.cil.oc.api.machine.Value; //导入依赖的package包/类
/**
* @throws GenerationFailedException
*/
public Value wrapObject(Object target);
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:5,代码来源:IOpenComputersObjectsFactory.java
注:本文中的li.cil.oc.api.machine.Value类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论