public AstNodeExprBinop(AstNodeExpr LeftNode, string Operator, AstNodeExpr RightNode)
 {
     this.LeftNode  = LeftNode;
     this.Operator  = Operator;
     this.RightNode = RightNode;
     CheckCompatibleTypes();
 }
 public AstNodeExprTerop(AstNodeExpr Cond, AstNodeExpr True, AstNodeExpr False)
 {
     if (True.Type != False.Type) throw(new Exception("Condition mismatch"));
     this.Cond = Cond;
     this.True = True;
     this.False = False;
 }
 public AstNodeExprBinop(AstNodeExpr LeftNode, string Operator, AstNodeExpr RightNode)
 {
     this.LeftNode = LeftNode;
     this.Operator = Operator;
     this.RightNode = RightNode;
     CheckCompatibleTypes();
 }
 public AstNodeStmSwitch(AstNodeExpr switchValue, IEnumerable <AstNodeCase> cases,
                         AstNodeCaseDefault caseDefault = null)
 {
     SwitchValue = switchValue;
     Cases       = cases.ToArray();
     CaseDefault = caseDefault;
 }
        public AstNodeStmAssign(AstNodeExprLValue LValue, AstNodeExpr Value)
        {
            if (LValue.Type != Value.Type) throw (new Exception(String.Format("Local.Type({0}) != Value.Type({1})", LValue.Type, Value.Type)));

            this.LValue = LValue;
            this.Value = Value;
        }
 public AstNodeStmIfElse(AstNodeExpr Condition, AstNodeStm True, AstNodeStm False = null)
 {
     //if (False == null) False = new AstNodeStmEmpty();
     this.Condition = Condition;
     this.True = True;
     this.False  = False;
 }
Example #7
0
 public AstNodeStmIfElse(AstNodeExpr Condition, AstNodeStm True, AstNodeStm False = null)
 {
     //if (False == null) False = new AstNodeStmEmpty();
     this.Condition = Condition;
     this.True      = True;
     this.False     = False;
 }
Example #8
0
 public AstNodeExprBinop(AstNodeExpr leftNode, string op, AstNodeExpr rightNode)
 {
     LeftNode  = leftNode;
     Operator  = op;
     RightNode = rightNode;
     CheckCompatibleTypes();
 }
 public AstNodeExprPropertyAccess(AstNodeExpr instance, PropertyInfo property, string propertyName = null)
 {
     if (property == null)
     {
         throw new Exception($"Property can't be null '{propertyName}'");
     }
     Instance = instance;
     Property = property;
 }
Example #10
0
 public AstNodeExprFieldAccess(AstNodeExpr instance, FieldInfo field, string fieldName = null)
 {
     if (field == null)
     {
         throw (new Exception($"Field can't be null '{fieldName}'"));
     }
     Instance = instance;
     Field    = field;
 }
 public AstNodeExprFieldAccess(AstNodeExpr Instance, FieldInfo Field, string FieldName = null)
 {
     if (Field == null)
     {
         throw (new Exception(String.Format("Field can't be null '{0}'", FieldName)));
     }
     this.Instance = Instance;
     this.Field    = Field;
 }
Example #12
0
 public AstNodeExprPropertyAccess(AstNodeExpr Instance, PropertyInfo Property, string PropertyName = null)
 {
     if (Property == null)
     {
         throw (new Exception(String.Format("Property can't be null '{0}'", PropertyName)));
     }
     this.Instance = Instance;
     this.Property = Property;
 }
Example #13
0
 public AstNodeExprTerop(AstNodeExpr cond, AstNodeExpr @true, AstNodeExpr @false)
 {
     if (@true.Type != @false.Type)
     {
         throw new Exception("Condition mismatch");
     }
     Cond  = cond;
     True  = @true;
     False = @false;
 }
Example #14
0
        public AstNodeStmAssign(AstNodeExprLValue LValue, AstNodeExpr Value)
        {
            if (LValue.Type != Value.Type)
            {
                throw (new Exception(String.Format("Local.Type({0}) != Value.Type({1})", LValue.Type, Value.Type)));
            }

            this.LValue = LValue;
            this.Value  = Value;
        }
 public AstNodeExprTerop(AstNodeExpr Cond, AstNodeExpr True, AstNodeExpr False)
 {
     if (True.Type != False.Type)
     {
         throw(new Exception("Condition mismatch"));
     }
     this.Cond  = Cond;
     this.True  = True;
     this.False = False;
 }
Example #16
0
        public AstNodeStmAssign(AstNodeExprLValue leftValue, AstNodeExpr value)
        {
            if (leftValue.Type != value.Type)
            {
                throw (new Exception($"Local.Type({leftValue.Type}) != Value.Type({value.Type})"));
            }

            LeftValue = leftValue;
            Value     = value;
        }
		public static AstNodeExpr AstMemoryGetPointer(AstNodeExpr Address, bool Safe, string ErrorDescription = "ERROR")
		{
			if (Safe)
			{
				return ast.CallInstance(
					CpuThreadStateArgument(),
					(AddressToPointerFunc)CpuThreadState.Methods.GetMemoryPtrSafe,
					ast.Cast<uint>(Address)
				);
			}
			else
			{
				return ast.CallInstance(
					CpuThreadStateArgument(),
					(AddressToPointerFunc)CpuThreadState.Methods.GetMemoryPtr,
					ast.Cast<uint>(Address)
				);
			}
		}
 public AstNodeExprArrayAccess(AstNodeExpr arrayInstance, AstNodeExpr index)
 {
     ArrayInstance = arrayInstance;
     Index         = index;
 }
 private static AstNodeExpr ReadMemory2(AstNodeExpr Address)
 {
     return ast.CallInstance(GetCpuContext(), (Func<ushort, ushort>)CpuContext._NullInstance.ReadMemory2, Address);
 }
 public AstNodeExprPropertyAccess(AstNodeExpr Instance, string PropertyName)
     : this(Instance, Instance.Type.GetProperty(PropertyName), PropertyName)
 {
 }
 private static AstNodeStm WriteMemory2(AstNodeExpr Address, AstNodeExpr Value)
 {
     return ast.Statement(ast.CallInstance(GetCpuContext(), (Action<ushort, ushort>)CpuContext._NullInstance.WriteMemory2, Address, Value));
 }
Example #22
0
 public AstNodeExprPropertyAccess(AstNodeExpr Instance, string PropertyName)
     : this(Instance, Instance.Type.GetProperty(PropertyName), PropertyName)
 {
 }
 public AstNodeExpr GetCallForAddress(AstNodeExpr Address)
 {
     return ast.CallInstance(GetCpuContext(), (Func<uint, Action<CpuContext>>)CpuContext._NullInstance.GetDelegateForAddress, ast.Cast<uint>(Address));
 }
 public AstNodeStmReturn(AstNodeExpr Expression = null)
 {
     this.Expression = Expression;
 }
 public AstNodeExprCallInstance(AstNodeExpr Instance, MethodInfo MethodInfo, params AstNodeExpr[] Parameters)
     : base(MethodInfo, Parameters)
 {
     this.Instance = Instance;
 }
Example #26
0
 public AstNodeExprIndirect(AstNodeExpr AstNodeExpr)
 {
     this.PointerExpression = AstNodeExpr;
 }
Example #27
0
 public AstNodeExprCallDelegate(AstNodeExpr Object, params AstNodeExpr[] parameters)
     : base(Object, GetInvoke(Object.Type), parameters)
 {
 }
 public AstNodeExprCallDelegate(AstNodeExpr Object, params AstNodeExpr[] Parameters)
     : base(Object, GetInvoke(Object.Type), Parameters)
 {
 }
Example #29
0
 public AstNodeStmSwitch(AstNodeExpr SwitchValue, IEnumerable <AstNodeCase> Cases, AstNodeCaseDefault CaseDefault = null)
 {
     this.SwitchValue = SwitchValue;
     this.Cases       = Cases.ToArray();
     this.CaseDefault = CaseDefault;
 }
Example #30
0
 public AstNodeExprUnop(string Operator, AstNodeExpr RightNode)
 {
     this.Operator = Operator;
     this.RightNode = RightNode;
 }
Example #31
0
 public AstNodeStmGotoIf(AstLabel AstLabel, AstNodeExpr Condition)
     : base(AstLabel)
 {
     this.Condition = Condition;
 }
		static public AstNodeExprCall MethodCacheInfoCallDynamicPC(AstNodeExpr PC)
		{
			return ast.CallInstance(MethodCacheInfoGetAtPC(PC), (Action<CpuThreadState>)MethodCacheInfo.Methods.CallDelegate, CpuThreadStateArgument());
		}
Example #33
0
 public AstNodeExprCast(Type CastedType, AstNodeExpr Expr, bool Explicit = true)
 {
     this.CastedType = CastedType;
     this.Expr = Expr;
     this.Explicit = Explicit;
 }
 public AstNodeExprCallInstance(AstNodeExpr Instance, Delegate Delegate, params AstNodeExpr[] Parameters)
     : this(Instance, Delegate.Method, Parameters)
 {
 }
Example #35
0
 public AstNodeStmGotoIfFalse(AstLabel AstLabel, AstNodeExpr Condition)
     : base(AstLabel, Condition)
 {
 }
 public AstNodeExprPropertyAccess(AstNodeExpr instance, string propertyName)
     : this(instance, instance.Type.GetProperty(propertyName), propertyName)
 {
 }
Example #37
0
 public AstNodeExprCallInstance(AstNodeExpr instance, MethodInfo methodInfo, params AstNodeExpr[] parameters)
     : base(methodInfo, parameters)
 {
     Instance = instance;
 }
		//public AstNodeExpr IMM_s() { return this.Immediate(IMM); }
		//public AstNodeExpr IMM_u() { return this.Immediate((uint)(ushort)IMM); }
		//public AstNodeExpr IMM_uex() { return this.Immediate((uint)IMM); }

		public AstNodeStm AssignREG(string RegName, AstNodeExpr Expr) { return ast.Assign(REG(RegName), Expr); }
Example #39
0
 public AstNodeExprCallInstance(AstNodeExpr instance, Delegate mydelegate, params AstNodeExpr[] parameters)
     : this(instance, mydelegate.Method, parameters)
 {
 }
 public AstNodeExprIndirect(AstNodeExpr astNodeExpr) => PointerExpression = astNodeExpr;
Example #41
0
 public AstNodeExprUnop(string op, AstNodeExpr rightNode)
 {
     Operator  = op;
     RightNode = rightNode;
 }
 public AstNodeExprCast(Type castedType, AstNodeExpr expr, bool Explicit = true)
 {
     CastedType    = castedType;
     Expr          = expr;
     this.Explicit = Explicit;
 }
		static public AstNodeExpr MethodCacheInfoGetAtPC(AstNodeExpr PC)
		{
			return ast.CallInstance(ast.FieldAccess(MipsMethodEmitter.CpuThreadStateArgument(), "MethodCache"), (Func<uint, MethodCacheInfo>)MethodCache.Methods.GetForPC, PC);
		}
Example #44
0
 public AstNodeStmGotoIfFalse(AstLabel AstLabel, AstNodeExpr Condition)
     : base(AstLabel, Condition)
 {
 }
		public AstNodeStm AssignGPR(int Index, AstNodeExpr Expr) { if (Index == 0) return new AstNodeStmEmpty(); return ast.Assign(GPR(Index), ast.Cast<uint>(Expr)); }
 public AstNodeExprFieldAccess(AstNodeExpr Instance, string FieldName)
     : this(Instance, Instance.Type.GetField(FieldName), FieldName)
 {
 }
 public AstNodeExprArrayAccess(AstNodeExpr ArrayInstance, AstNodeExpr Index)
 {
     this.ArrayInstance = ArrayInstance;
     this.Index         = Index;
 }
 public AstNodeExprFieldAccess(AstNodeExpr Instance, FieldInfo Field, string FieldName = null)
 {
     if (Field == null) throw (new Exception(String.Format("Field can't be null '{0}'", FieldName)));
     this.Instance = Instance;
     this.Field = Field;
 }
 public AstNodeStmExpr(AstNodeExpr AstNodeExpr)
 {
     this.AstNodeExpr = AstNodeExpr;
 }
 public AstNodeStmSwitch(AstNodeExpr SwitchValue, IEnumerable<AstNodeCase> Cases, AstNodeCaseDefault CaseDefault = null)
 {
     this.SwitchValue = SwitchValue;
     this.Cases = Cases.ToArray();
     this.CaseDefault = CaseDefault;
 }
Example #51
0
 public AstNodeExprFieldAccess(AstNodeExpr instance, string fieldName)
     : this(instance, instance.Type.GetField(fieldName), fieldName)
 {
 }
		static private DynarecResult _SUB(DynarecContextChip8 Context, byte X, AstNodeExpr Value)
		{
			return ast.Statements(
				ast.Assign(Context.GetRegister(15), ast.Cast<byte>(ast.Binary(ast.Cast<uint>(Context.GetRegister(X)), ">", ast.Cast<uint>(Value)))),
				ast.Assign(Context.GetRegister(X), Context.GetRegister(X) - Value)
			);
		}
 public AstNodeExprSetGetLValue(AstNodeExpr SetExpression, AstNodeExpr GetExpression)
 {
     this.SetExpression = SetExpression;
     this.GetExpression = GetExpression;
 }
 public AstNodeExprSetGetLValue(AstNodeExpr SetExpression, AstNodeExpr GetExpression)
 {
     this.SetExpression = SetExpression;
     this.GetExpression = GetExpression;
 }
 public AstNodeExprPropertyAccess(AstNodeExpr Instance, PropertyInfo Property, string PropertyName = null)
 {
     if (Property == null) throw (new Exception(String.Format("Property can't be null '{0}'", PropertyName)));
     this.Instance = Instance;
     this.Property = Property;
 }
Example #56
0
 public AstNodeExprSetGetLValue(AstNodeExpr setExpression, AstNodeExpr getExpression)
 {
     SetExpression = setExpression;
     GetExpression = getExpression;
 }
 public AstNodeExprNewArray AddValue(AstNodeExpr astNodeExpr)
 {
     Values.Add(astNodeExpr);
     return(this);
 }
Example #58
0
		//static public void DumpStackTrace()
		//{
		//	Console.WriteLine(Environment.StackTrace);
		//}

		private AstNodeStm ReturnFromFunction(AstNodeExpr AstNodeExpr)
		{
#if ENABLE_NATIVE_CALLS

			return ast.Statements(
				AssignREG("PC", GPR(31)),
				ast.Statement(ast.CallInstance(MipsMethodEmitter.CpuThreadStateArgument(), (Action)CpuThreadState.Methods.Tick)),
				//ast.Statement(ast.CallStatic((Action)DumpStackTrace)),
				ast.Return()
			);
#else
			return JumpToAddress(AstNodeExpr);
#endif
		}
Example #59
0
 public AstNodeStmExpr(AstNodeExpr AstNodeExpr)
 {
     this.AstNodeExpr = AstNodeExpr;
 }
Example #60
0
		private AstNodeStm AssignBranchFlag(AstNodeExpr Expr, bool AndLink = false)
		{
			this.AndLink = AndLink;
			this.BranchPC = PC;
			return ast.Assign(BranchFlag(), ast.Cast<bool>(Expr, Explicit: false));
		}