/// <summary> /// Init new variable declaration. /// </summary> /// <param name="position">Position.</param> /// <param name="vartype">Variable type.</param> /// <param name="varname">Variable name.</param> /// <param name="value">Variable initial value.</param> public VariableDecl(ExprPosition position, ExpressionType vartype, string varname, Expression value) : base(position) { this.VariableName = varname; this.VariableType = vartype; this.InitialValue = value; }
public StringLiteral(ExprPosition position, string value) : base(position) { Debug.Assert(value != null); this.Value = value; }
public ExpressionAssign(ExprPosition position, Expression lValue, Expression rValue) : base(position, lValue, rValue) { if (!(lValue is VariableUse)) { throw new ArgumentException("L-Value must be a VariableUse."); } }
public ClassDecl(ExprPosition position, string classname, List <VariableDecl> properties) : base(position) { Debug.Assert(!String.IsNullOrEmpty(classname)); this.ClassName = classname; this.ClassProperties = properties; }
public MethodDecl(ExprPosition position, string methodname, List <VariableDecl> arguments, Expression body) : base(position) { this.DeclMethodName = methodname; this.GeneratedMethodName = methodname + "_" + position.StartLine + "_" + position.StartColumn; this.MethodArguments = arguments; this.Body = body; }
public MethodDecl(ExprPosition position, string methodname, List <VariableDecl> arguments, string bodycsharp, ExpressionType ReturnType) : base(position) { this.DeclMethodName = methodname; this.GeneratedMethodName = methodname + "_" + position.StartLine + "_" + position.StartColumn; this.MethodArguments = arguments; this.BodyCSharp = bodycsharp; this.ReturnType = ReturnType; }
public TernaryCondExpression(ExprPosition position, Expression condition, Expression expr1, Expression expr2) : base(position) { if (condition == null || expr1 == null || expr2 == null) { throw new ArgumentNullException(); } this.ConditionExpr = condition; this.Expr1 = expr1; this.Expr2 = expr2; }
/// <summary> /// Init declarations list with one class declaration. /// </summary> /// <param name="position"></param> /// <param name="classdecl"></param> public DeclarationsList(ExprPosition position, DeclarationsList decls, ClassDecl classdecl) : this(position) { if (decls != null) { Classes = decls.Classes; Methods.AddRange(decls.Methods); } if (classdecl != null) { Classes.Add(classdecl.ClassName, classdecl); } }
public ExpressionType GetLocalVarType(ExprPosition position, string varname) { if (string.IsNullOrEmpty(varname)) { return(null); } string[] chainName = varname.Split(new char[] { '.' }); ExpressionType retType; if (!DeclaredLocalVars.TryGetValue(chainName[0], out retType)) { return(null); } if (chainName.Length > 1) { for (int i = 1; i < chainName.Length; ++i) { if (retType.UserTypeName == null) { throw new GeneratorException(position, "Member chain of non-user class not supported."); } ClassDecl classdecl; if (!Declarations.Classes.TryGetValue(retType.UserTypeName, out classdecl)) { throw new GeneratorException(position, "Undeclared type " + retType.UserTypeName); } retType = classdecl.ContainsProperty(chainName[i]); if (retType == null) { throw new GeneratorException(position, "Undeclared property " + chainName[i]); } } } return(retType); }
/// <summary> /// Init declarations list with one method declaration. /// </summary> /// <param name="position"></param> /// <param name="methoddecl"></param> public DeclarationsList(ExprPosition position, DeclarationsList decls, MethodDecl methoddecl) : this(position) { if (decls != null) { Classes = decls.Classes; Methods.AddRange(decls.Methods); } if (methoddecl != null) { if (!methoddecl.IsMainMethod) { foreach (var m in Methods) { if (m.DeclMethodName == methoddecl.DeclMethodName) { // arguments must match if (m.MethodArguments.Count != methoddecl.MethodArguments.Count) { throw new GeneratorException(position, "Methods " + methoddecl.DeclMethodName + ": Arguments mishmash."); } for (int arg = 0; arg < m.MethodArguments.Count; ++arg) { if (!m.MethodArguments[arg].VariableType.Equals(methoddecl.MethodArguments[arg].VariableType)) { throw new GeneratorException(position, "Methods " + methoddecl.DeclMethodName + ": Arguments mishmash."); } if (m.MethodArguments[arg].VariableName != methoddecl.MethodArguments[arg].VariableName) { throw new GeneratorException(position, "Methods " + methoddecl.DeclMethodName + ": Arguments mishmash."); } } } } } Methods.Insert(0, methoddecl); } }
public ExpressionSubOneBefore(ExprPosition position, Expression value) : base(position, value) { }
public ExpressionAddElement(ExprPosition position, VariableUse lvalue, Expression rvalue) : base(position) { this.lvalue = lvalue; this.rvalue = rvalue; }
/// <summary> /// Constructs the expression node. /// </summary> /// <param name="position"></param> public Expression(ExprPosition position) { this.Position = position; }
public CustomExpression(ExprPosition position, ExpressionType exprType, string csCode) : base(position) { this.CsCode = csCode; this.ExprType = exprType; }
public TypeCastExpression(ExprPosition position, ExpressionType newType, Expression expr) : base(position, expr) { this.NewType = newType; }
public ExpressionLogicalXor(ExprPosition position, Expression lValue, Expression rValue) : base(position, lValue, rValue) { }
public MethodCall(ExprPosition position, string methodName, List <Expression> callArguments) : base(position) { this.MethodName = methodName; this.CallArguments = callArguments; }
public ExpressionLogicalNot(ExprPosition position, Expression value) : base(position, value) { }
public ExpressionGreaterEq(ExprPosition position, Expression lValue, Expression rValue) : base(position, lValue, rValue) { }
/// <summary> /// Init empty declarations list. /// </summary> /// <param name="position"></param> public DeclarationsList(ExprPosition position) : base(position) { }
public ExpressionSubOneAfter(ExprPosition position, Expression value) : base(position, value) { }
/// <summary> /// Constructs a binary expression. /// </summary> /// <param name="position">Expression position.</param> /// <param name="lValue">Left operand.</param> /// <param name="rValue">Right operand.</param> public BinaryExpr(ExprPosition position, Expression lValue, Expression rValue) : base(position) { this.LValue = lValue; this.RValue = rValue; }
/// <summary> /// Unary expression initialization. /// </summary> /// <param name="position"></param> /// <param name="value"></param> public UnaryExpr(ExprPosition position, Expression value) : base(position) { this.Value = value; }
public ExpressionSub(ExprPosition position, Expression lValue, Expression rValue) : base(position, lValue, rValue) { }
public ExpressionUnaryMinus(ExprPosition position, Expression value) : base(position, value) { }
/// <summary> /// Init exception. /// </summary> /// <param name="position"></param> /// <param name="message"></param> public GeneratorException(ExprPosition position, string message) : base(message) { this.Position = position; }
/// <summary> /// Init new variable declaration. /// </summary> /// <param name="position">Position.</param> /// <param name="vartype">Type of the variable/property.</param> /// <param name="varname">Name of the variable/property.</param> public VariableDecl(ExprPosition position, ExpressionType vartype, string varname) : this(position, vartype, varname, null) { }
public VariableUse(ExprPosition position, string name) : base(position) { VariableName = name; }
public Statement(ExprPosition position, Expression expr) : base(position) { ExpressionInside = expr; }
/// <summary> /// Create statements block. /// </summary> /// <param name="position"></param> /// <param name="statements"></param> public CodeBlock(ExprPosition position, List <Expression> statements) : base(position) { this.Statements = (statements != null) ? statements : new List <Expression>(); }