package org.shedlang.compiler.shid.instructions; import org.shedlang.compiler.sources.Sources; import org.shedlang.compiler.types.NamespaceName; import org.shedlang.compiler.types.SimpleNativeType; import org.shedlang.compiler.types.SimpleStructType; import org.shedlang.compiler.types.UserDefinedEffect; import java.math.BigInteger; import java.util.List; public class Shid { private Shid() { } public static ShidBlock block(List boundVariables, List instructions) { return new ShidBlock(boundVariables, instructions, Sources.NULL); } public static ShidBlock block(List instructions) { return block(List.of(), instructions); } public static ShidInstruction call(int positionalArgCount, List namedArgNames) { return new ShidCall(positionalArgCount, namedArgNames, Sources.NULL); } public static ShidInstruction declareNativeType( SimpleNativeType type ) { return new ShidDeclareNativeType( type, Sources.NULL ); } public static ShidInstruction defineEffect(UserDefinedEffect effect) { return new ShidDefineEffect(effect, Sources.NULL); } public static ShidInstruction defineStruct( SimpleStructType type, List fields ) { return new ShidDefineStruct( type, fields, Sources.NULL ); } public static ShidDefineStruct.Field defineStructField(String name) { return new ShidDefineStruct.Field(name, Sources.NULL); } public static ShidInstruction discard() { return new ShidDiscard(Sources.NULL); } public static ShidInstruction duplicate() { return new ShidDuplicate(Sources.NULL); } public static ShidInstruction effectHandlerBreak(UserDefinedEffect effect) { return new ShidEffectHandlerBreak(effect, Sources.NULL); } public static ShidInstruction fieldLoad(NamespaceName namespaceName, String fieldName) { return new ShidFieldLoad( new ShidFieldLoad.Receiver.Namespace(namespaceName), fieldName, Sources.NULL ); } public static ShidInstruction fieldLoad(SimpleStructType type, String fieldName) { return new ShidFieldLoad( new ShidFieldLoad.Receiver.Struct(type), fieldName, Sources.NULL ); } public static ShidInstruction fieldLoad(UserDefinedEffect effect, String fieldName) { return new ShidFieldLoad( new ShidFieldLoad.Receiver.Effect(effect), fieldName, Sources.NULL ); } public static ShidInstruction if_( int resultCount, ShidBlock trueBody, ShidBlock falseBody ) { return new ShidIf(resultCount, trueBody, falseBody, Sources.NULL); } public static ShidInstruction intAdd() { return new ShidIntAdd(Sources.NULL); } public static ShidInstruction intEquals() { return new ShidIntEquals(Sources.NULL); } public static ShidInstruction intGreaterThan() { return new ShidIntGreaterThan(Sources.NULL); } public static ShidInstruction intGreaterThanOrEqual() { return new ShidIntGreaterThanOrEqual(Sources.NULL); } public static ShidInstruction intLessThan() { return new ShidIntLessThan(Sources.NULL); } public static ShidInstruction intLessThanOrEqual() { return new ShidIntLessThanOrEqual(Sources.NULL); } public static ShidInstruction intMultiply() { return new ShidIntMultiply(Sources.NULL); } public static ShidInstruction intNotEqual() { return new ShidIntNotEqual(Sources.NULL); } public static ShidInstruction intSub() { return new ShidIntSub(Sources.NULL); } public static ShidInstruction localDrop(String name) { return new ShidLocalDrop(name, Sources.NULL); } public static ShidInstruction localLoad(String name) { return new ShidLocalLoad(name, Sources.NULL); } public static ShidInstruction localStore(String name) { return new ShidLocalStore(name, Sources.NULL); } public static ShidInstruction loop(ShidBlock body) { return new ShidLoop(body, Sources.NULL); } public static ShidInstruction loopBreak() { return new ShidLoopBreak(Sources.NULL); } public static ShidInstruction loopContinue() { return new ShidLoopContinue(Sources.NULL); } public static ShidInstruction methodLoad( SimpleStructType type, String methodName ) { return new ShidMethodLoad(type, methodName, Sources.NULL); } public static ShidInstruction methodStore( SimpleStructType type, String methodName ) { return new ShidMethodStore(type, methodName, Sources.NULL); } public static ShidInstruction namespaceFieldStore(NamespaceName namespaceName, String fieldName) { return new ShidNamespaceFieldStore(namespaceName, fieldName, Sources.NULL); } public static ShidInstruction namespaceImport(NamespaceName namespaceName) { return new ShidNamespaceImport(namespaceName, Sources.NULL); } public static ShidParam param(String name) { return new ShidParam(name, Sources.NULL); } public static ShidInstruction pushBool(boolean value) { return new ShidPushBool(value, Sources.NULL); } public static ShidInstruction pushInt(int value) { return new ShidPushInt(BigInteger.valueOf(value), Sources.NULL); } public static ShidInstruction pushString(String value) { return new ShidPushString(value, Sources.NULL); } public static ShidInstruction pushUnit() { return new ShidPushUnit(Sources.NULL); } public static ShidInstruction resume() { return new ShidResume(Sources.NULL); } public static ShidInstruction return_() { return new ShidReturn(Sources.NULL); } public static ShidInstruction stringAdd() { return new ShidStringAdd(Sources.NULL); } public static ShidInstruction switch_(List cases) { return new ShidSwitch(cases, Sources.NULL); } public static ShidSwitch.Case switchCase( SimpleStructType type, ShidBlock body ) { return new ShidSwitch.Case(type, body, Sources.NULL); } public static ShidInstruction try_( UserDefinedEffect handledEffect, List handlerMethodNames, ShidBlock body ) { return new ShidTry( handledEffect, handlerMethodNames, body, Sources.NULL ); } public static ShidInstruction tupleCreate(int elementCount) { return new ShidTupleCreate(elementCount, Sources.NULL); } public static ShidInstruction tupleGet(int elementIndex, int elementCount) { return new ShidTupleGet(elementIndex, elementCount, Sources.NULL); } public static ShidInstruction varLoad(String name) { return new ShidVarLoad(name, Sources.NULL); } public static ShidInstruction varStore(String name) { return new ShidVarStore(name, Sources.NULL); } }