public void Ret_ParseCheck_i32_Value_Ok() { LValueRef valueRef = new LValueRef(LType.Int32Type(), "12"); LRet ret = new LRet(valueRef); Assert.AreEqual($"{LKeywords.Ret} i32 12", LHelper.Trim(ret.ParseInstruction())); }
public void Ret_ParseCheck_i32_Identifier_Ok() { LValueRef valueRef = new LValueRef(LType.Int32Type(), _function.GetValueRefIdentifier()); LRet ret = new LRet(valueRef); Assert.AreEqual($"{LKeywords.Ret} i32 {valueRef.ValueOrIdentifier}", LHelper.Trim(ret.ParseInstruction())); }
private Type ToType(LType s) { Type type; switch (s.type) { case "any": type = Type.GetType("System.Object"); break; case "int": type = Type.GetType("System.Int32"); break; case "float": type = Type.GetType("System.Double"); break; case "string": type = Type.GetType("System.String"); break; case "void": type = Type.GetType("System.Void"); break; default: throw new Exception($"Cannot convert type {s.type} to a .NET type"); } return(s.isArray ? type.MakeArrayType() : type); }
public void SimpleAllocaParse_Expected_True() { LAlloca alloca = new LAlloca(_function, LType.Int32Type()); Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}", LHelper.Trim(alloca.ParseInstruction())); }
public void buttonSave_Click(object sender, EventArgs e, string thisMIEN) { if (listBoxShow.Items.Count < 1) { MessageBox.Show("You must have at least one item chosen to show!"); } else { //Save to VistA string[] SendListToRPC = new string[listBoxShow.Items.Count]; //Send arguments as List Type for (int q = 0; q < listBoxShow.Items.Count; q++) { LType anItem = new LType { filtertext = ((LType)(listBoxShow.Items)[q]).filtertext, filterien = ((LType)(listBoxShow.Items)[q]).filterien }; SendListToRPC[q] = anItem.filterien + "^" + anItem.filtertext; } string THIS_ARG = RpcFormatter.FormatArgs(true, thisMIEN, SendListToRPC); //thisMIEN is ModuleIEN;Instance string res9 = GlobalVars.RunRPC("C9C DASHBOARD PUT USER FILTERS", THIS_ARG); if (res9 == "1") { FiltersJustSaved = true; DialogResult = DialogResult.OK; } else { MessageBox.Show("Error Saving Filters!"); } } }
public LValue(LType _type, object _val) { this.Number = 0; this.String = ""; this.I32 = 0; this.I64 = 0; this.Array = null; this.Undefined = false; this.Type = _type; switch (this.Type) { case LType.Number: this.Number = (double)_val; break; case LType.String: this.String = (string)_val; break; case LType.Int32: this.I32 = (Int32)_val; break; case LType.Int64: this.I64 = (Int64)_val; break; case LType.Array: this.Array = (LValue[])_val; break; case LType.Undefined: this.Undefined = true; break; } }
public SelectInstruction(LType type, Value condition, TypedValue value1, TypedValue value2) { Type = type; Condition = condition; Value1 = value1; Value2 = value2; }
public void SimpleFunctionType_ParseCheck() { var returnVal = new LValueRef(LType.F32Type(), ""); var parameter = new LPointerRef(new LValueRef(LType.F32Type(), ""), ""); LFunctionType fnType = new LFunctionType(returnVal, parameter); Assert.AreEqual("float (float*)", fnType.Parse()); }
public IcmpInstruction(IcmpCondition condition, LType type, Value op1, Value op2) { Condition = condition; Type = type; Op1 = op1; Op2 = op2; }
public CallInstruction(LType returnType, Value pointer, IEnumerable <Argument> arguments, bool tail) { ReturnType = returnType; Pointer = pointer; Arguments = arguments.ToArray(); Tail = tail; }
public LinkDataClass(string name, System.Drawing.Icon icon, LType i, string execute) { this.MyLink = name; this.MyIcon = icon; this.MyType = i; this.Execute = execute; }
public void Save(BinaryWriter W) { W.Write(List.Count); for (int i = 0; i < List.Count; i++) { LType T = List[i].Item1; W.WriteLuaType(T); switch (T) { case LType.Nil: break; case LType.Bool: W.Write((bool)List[i].Item2); break; case LType.Number: W.Write((double)List[i].Item2); break; case LType.String: W.WriteLuaString((string)List[i].Item2); break; default: throw new Exception("Type " + T.ToString() + " not implemented"); } } W.Write(Functions.Count); foreach (Function Func in Functions) { Func.Save(W); } }
public void SimpleAnd_WithConstant_ParseCheck() { LValueRef op2 = new LValueRef(LType.Int32Type(), "12"); LAnd and = new LAnd(_valueResult, _valueOp1, op2); Assert.AreEqual($"{_valueResult.Identifier} = and {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {op2.ValueOrIdentifier}", LHelper.Trim(and.ParseInstruction())); }
public void SimpleAnd_FloatingPointResultType_Expected_Exception() { LAnd and; Assert.Throws <Exception>(() => and = new LAnd(new LValueRef(LType.F32Type(), "%result"), _valueOp1, _valueOp2) ); }
public void SimpleAnd_Op1FromDifferentType_Expected_Exception() { LAnd and; Assert.Throws <Exception>(() => and = new LAnd(_valueResult, new LValueRef(LType.Int128Type(), "%op1"), _valueOp2) ); }
public void BasicGlobalVariable_ParseCheck_Expected_Equal() { string globalVariableIdentifier = "@my_global_int"; string value = "12345"; var global = new LGlobal(new LValueRef(LType.UInt32Type(), globalVariableIdentifier), value); Assert.AreEqual($"{globalVariableIdentifier} = {LKeywords.Global} i32 {value}", global.Parse()); }
/// <summary> /// Is match with the type supplied and the /// </summary> /// <param name="type"></param> /// <param name="obj1"></param> /// <param name="obj2"></param> /// <returns></returns> private bool IsTypeMatch(LType type, LObject obj1, LObject obj2) { if (obj1.Type == type && obj2.Type == type) { return(true); } return(false); }
public void SimpleFadd_ResultFromDifferentType_Expected_Exception() { LFadd fadd; Assert.Throws <Exception>(() => fadd = new LFadd(new LValueRef(LType.Int128Type(), "%result"), _valueOp1, _valueOp2) ); }
public void SimpleLshr_Op1FromDifferentType_Expected_Exception() { LShl shl; Assert.Throws <Exception>(() => shl = new LShl(_valueResult, new LValueRef(LType.Int128Type(), "%op1"), _valueOp2) ); }
public InvokeInstruction(LType returnType, Value pointer, IEnumerable <Argument> arguments, LabelValue normalLabel, LabelValue exceptionLabel) { ReturnType = returnType; Pointer = pointer; Arguments = arguments.ToArray(); NormalLabel = normalLabel; ExceptionLabel = exceptionLabel; }
public void DoubleValueArrayRef_ParseCheck_Expected_Equals() { LArrayRef arrayRef = new LArrayRef("arrayRef", new LValueRef(LType.Int32Type(), ""), 5); LArrayRef arrayRef2 = new LArrayRef("arrayRef2", arrayRef, 5); Assert.AreEqual("[5 x i32]", arrayRef.ParseType()); Assert.AreEqual("[5 x [5 x i32]]", arrayRef2.ParseType()); }
public void SimpleXor_FloatingPointResultType_Expected_Exception() { LXor xor; Assert.Throws <Exception>(() => xor = new LXor(new LValueRef(LType.F32Type(), "%result"), _valueOp1, _valueOp2) ); }
public void SimpleXor_Op1FromDifferentType_Expected_Exception() { LXor xor; Assert.Throws <Exception>(() => xor = new LXor(_valueResult, new LValueRef(LType.Int128Type(), "%op1"), _valueOp2) ); }
public void SimpleLoadParse_Expected_True() { LLoad load = new LLoad(_function, _alloca.PointerRef); Assert.AreEqual( $"{load.ValueRef.Identifier} = {LKeywords.Load} {LType.Int32Type().Parse()}, {load.PointerRef.ParseType()} {load.PointerRef.Identifier}", LHelper.Trim(load.ParseInstruction())); }
public void SimpleLshr_ResultFromDifferentType_Expected_Exception() { LLshr lshr; Assert.Throws <Exception>(() => lshr = new LLshr(new LValueRef(LType.Int128Type(), "%result"), _valueOp1, _valueOp2) ); }
public void SimpleLshr_FloatingPointResultType_Expected_Exception() { LShl shl; Assert.Throws <Exception>(() => shl = new LShl(new LValueRef(LType.F32Type(), "%result"), _valueOp1, _valueOp2) ); }
protected override BaseEntity CreateModel(BaseEntity entity) { LType type = entity as LType; type.ID = (int)reader["ID"]; type.Type = reader["type"].ToString(); return(type); }
public void SimpleLshr_WithConstant_ParseCheck() { LValueRef op2 = new LValueRef(LType.Int32Type(), "12"); LShl shl = new LShl(_valueResult, _valueOp1, op2); Assert.AreEqual($"{_valueResult.Identifier} = shl {_valueResult.ParseType()} {_valueOp1.ValueOrIdentifier}, {op2.ValueOrIdentifier}", LHelper.Trim(shl.ParseInstruction())); }
/// <summary> /// Expects the objects type to be of the supplied type. /// </summary> /// <param name="node"></param> /// <param name="result"></param> /// <param name="lType"></param> public static void ExpectType(AstNode node, object result, LType lType) { if (!(result is LObject) || ((LObject)result).Type != lType) { throw new LangException("Runtime Error", "Expected type " + lType.Name, node.Ref.ScriptName, node.Ref.Line, node.Ref.CharPos); } }
public void SimpleAdd_Op1FromDifferentType_Expected_Exception() { LAdd add; Assert.Throws <Exception>(() => add = new LAdd(_valueResult, new LValueRef(LType.F64Type(), "%op1"), _valueOp2) ); }
public void SimpleAdd_IntegerResultType_Expected_Exception() { LAdd add; Assert.Throws <Exception>(() => add = new LAdd(new LValueRef(LType.F64Type(), "%result"), _valueOp1, _valueOp2) ); }
public LinkDataClass(string name, System.Drawing.Icon icon,LType i) { this.MyLink = name; this.MyIcon = icon; this.MyType = i; }
public string LTypeToString(LType leaderType) { return lTypeTo [leaderType]; }