private static bool TryConstSet(Function fct, Variable v, string stringValue) { int i = 0; float f = 0; if (v.Type == TypeFlag.Float && Single.TryParse(stringValue, out f)) { NewSetInstruction ins = new NewSetInstruction { Destination = v, Source = new ConstValue(f) }; fct.Instructions.Add(ins); return(true); } if (v.Type == TypeFlag.Int && Int32.TryParse(stringValue, out i)) { NewSetInstruction ins = new NewSetInstruction { Destination = v, Source = new ConstValue(i) }; fct.Instructions.Add(ins); return(true); } return(false); }
private static bool TryPtrSet(Function fct, Variable v, string stringValue) { Variable ptr = fct.GetVariable(stringValue); if (v is DereferencedPointer) { NewSetInstruction ins = new NewSetInstruction { Destination = v, Source = ptr }; fct.Instructions.Add(ins); return(true); } if (ptr is ConstPtrVariable) { NewSetInstruction ins = new NewSetInstruction { Destination = v, Source = ptr }; fct.Instructions.Add(ins); return(true); } return(false); }