本文整理汇总了C#中Expr类的典型用法代码示例。如果您正苦于以下问题:C# Expr类的具体用法?C# Expr怎么用?C# Expr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Expr类属于命名空间,在下文中一共展示了Expr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
private Expr Convert(Expr e, TypeReference toType) {
if (e == null) {
return null;
}
var eType = e.Type.FullResolve(e.Ctx);
if (eType.IsPointer) {
// HACK: ?? This is probably a hack, not quite sure yet
eType = ((PointerType)eType).ElementType;
}
if (eType.IsAssignableTo(toType)) {
return e;
}
if (e.ExprType == Expr.NodeType.Literal) {
var eLit = (ExprLiteral)e;
if (toType.IsChar()) {
if (eType.IsInt32()) {
return new ExprLiteral(e.Ctx, (char)(int)eLit.Value, e.Ctx.Char);
}
}
if (toType.IsBoolean()) {
if (eType.IsInt32()) {
return new ExprLiteral(e.Ctx, ((int)eLit.Value) != 0, e.Ctx.Boolean);
}
}
}
return e;
}
示例2: If
/// <summary>
/// Ctor
/// </summary>
/// <param name="expr"></param>
/// <param name="stmt"></param>
public If(Expr expr, Stmt stmt)
{
this.Expr = expr;
this.Stmt = stmt;
if(this.Expr.Type != Type.Bool)
this.Expr.Error("boolean required in if");
}
示例3: OnParseAssignComplete
/// <summary>
/// Called by the framework after the parse method is called
/// </summary>
/// <param name="node">The node returned by this implementations Parse method</param>
public void OnParseAssignComplete(Expr expr)
{
var stmt = expr as AssignMultiExpr;
if (stmt.Assignments == null || stmt.Assignments.Count == 0)
return;
foreach (var assignment in stmt.Assignments)
{
var exp = assignment.VarExp;
if (exp.IsNodeType(NodeTypes.SysVariable))
{
var varExp = exp as VariableExpr;
var valExp = assignment.ValueExp;
var name = varExp.Name;
var registeredTypeVar = false;
var ctx = this._parser.Context;
if (valExp != null && valExp.IsNodeType(NodeTypes.SysNew))
{
var newExp = valExp as NewExpr;
if (ctx.Types.Contains(newExp.TypeName))
{
var type = ctx.Types.Get(newExp.TypeName);
var ltype = LangTypeHelper.ConvertToLangTypeClass(type);
ctx.Symbols.DefineVariable(name, ltype);
registeredTypeVar = true;
}
}
if (!registeredTypeVar)
ctx.Symbols.DefineVariable(name, LTypes.Object);
}
}
}
示例4: ExprVariableAddress
public ExprVariableAddress(Ctx ctx, Expr variable, TypeReference type)
: base(ctx) {
//this.Index = index;
this.Variable = variable;
this.ElementType = type;
this.type = type.MakePointer();
}
示例5: ResolveAlias
static void ResolveAlias(Parse parse, ExprList list, int colId, Expr expr, string type, int subqueries)
{
Debug.Assert(colId >= 0 && colId < list.Exprs);
Expr orig = list.Ids[colId].Expr; // The iCol-th column of the result set
Debug.Assert(orig != null);
Debug.Assert((orig.Flags & EP.Resolved) != 0);
Context ctx = parse.Ctx; // The database connection
Expr dup = Expr.Dup(ctx, orig, 0); // Copy of pOrig
if (orig.OP != TK.COLUMN && (type.Length == 0 || type[0] != 'G'))
{
IncrAggFunctionDepth(dup, subqueries);
dup = Expr.PExpr_(parse, TK.AS, dup, null, null);
if (dup == null) return;
if (list.Ids[colId].Alias == 0)
list.Ids[colId].Alias = (ushort)(++parse.Alias.length);
dup.TableId = list.Ids[colId].Alias;
}
if (expr.OP == TK.COLLATE)
dup = Expr.AddCollateString(parse, dup, expr.u.Token);
// Before calling sqlite3ExprDelete(), set the EP_Static flag. This prevents ExprDelete() from deleting the Expr structure itself,
// allowing it to be repopulated by the memcpy() on the following line.
E.ExprSetProperty(expr, EP.Static);
Expr.Delete(ctx, ref expr);
expr.memcpy(dup);
if (!E.ExprHasProperty(expr, EP.IntValue) && expr.u.Token != null)
{
Debug.Assert((dup.Flags & (EP.Reduced | EP.TokenOnly)) == 0);
dup.u.Token = expr.u.Token;
dup.Flags2 |= EP2.MallocedToken;
}
C._tagfree(ctx, ref dup);
}
示例6: SetVariableValue
/// <summary>
/// Sets a value on a member of a basic type.
/// </summary>
/// <param name="ctx">The context of the runtime</param>
/// <param name="node">The assignment ast node</param>
/// <param name="isDeclaration">Whether or not this is a declaration</param>
/// <param name="varExp">The expression representing the index of the instance to set</param>
/// <param name="valExp">The expression representing the value to set</param>
public static void SetVariableValue(Context ctx, IAstVisitor visitor, AstNode node, bool isDeclaration, Expr varExp, Expr valExp)
{
string varname = ((VariableExpr)varExp).Name;
// Case 1: var result;
if (valExp == null)
{
ctx.Memory.SetValue(varname, LObjects.Null, isDeclaration);
}
// Case 2: var result = <expression>;
else
{
var result = valExp.Evaluate(visitor);
// Check for type: e.g. LFunction ? when using Lambda?
if (result != null && result != LObjects.Null)
{
var lobj = result as LObject;
if (lobj != null && lobj.Type.TypeVal == TypeConstants.Function)
{
// 1. Define the function in global symbol scope
SymbolHelper.ResetSymbolAsFunction(varExp.SymScope, varname, lobj);
}
}
// CHECK_LIMIT:
ctx.Limits.CheckStringLength(node, result);
ctx.Memory.SetValue(varname, result, isDeclaration);
}
// LIMIT CHECK
ctx.Limits.CheckScopeCount(varExp);
ctx.Limits.CheckScopeStringLength(varExp);
}
示例7: AssertCmd
public AssertCmd(IToken/*!*/ tok, Expr/*!*/ expr, QKeyValue kv)
: base(tok, expr, kv)
{
Contract.Requires(tok != null);
Contract.Requires(expr != null);
errorDataEnhanced = GenerateBoundVarMiningStrategy(expr);
}
示例8: ExprFieldAddress
public ExprFieldAddress(Ctx ctx, Expr obj, FieldReference field)
: base(ctx) {
this.Obj = obj;
this.Field = field;
this.ElementType = field.FieldType.FullResolve(field);
this.type = this.ElementType.MakePointer();
}
示例9: ExprAlloc
public ExprAlloc(string type, string name, Expr expr, bool isEqualSign)
{
this.Type = type;
this.Name = new List<string> { name };
this.ExprList = new List<Expr> { expr };
this.IsEqualSign = isEqualSign;
}
示例10: ExprJsResolvedMethod
public ExprJsResolvedMethod(Ctx ctx, TypeReference returnType, Expr obj, string methodName, IEnumerable<Expr> args)
: base(ctx) {
this.returnType = returnType;
this.Obj = obj;
this.MethodName = methodName;
this.Args = args;
}
示例11: InternalValidate
private void InternalValidate(Expr expr,object obj,out object output)
{
output = null;
var eqGoal = obj as EqGoal;
var query = obj as Query;
var equation = obj as Equation;
var shape = obj as ShapeSymbol;
if (eqGoal != null)
{
InternalValidate(expr, eqGoal, out output);
return;
}
if (query != null)
{
InternalValidate(expr, query, out output);
return;
}
if (equation != null)
{
InternalValidate(expr, equation, out output);
return;
}
if (shape != null)
{
InternalValidate(expr, shape, out output);
}
}
示例12: ExprAlloc
public ExprAlloc(SugarType type, string name, Expr expr, AllocType style)
{
this.Type = type;
this.Name = new List<string> { name };
this.ExprList = new List<Expr> { expr };
this.Style = style;
}
示例13: resolveAlias
/*
** 2008 August 18
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains routines used for walking the parser tree and
** resolve all identifiers by associating them with a particular
** table and column.
*************************************************************************
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
** C#-SQLite is an independent reimplementation of the SQLite software library
**
** SQLITE_SOURCE_ID: 2010-01-05 15:30:36 28d0d7710761114a44a1a3a425a6883c661f06e7
**
** $Header$
*************************************************************************
*/
//#include "sqliteInt.h"
//#include <stdlib.h>
//#include <string.h>
/*
** Turn the pExpr expression into an alias for the iCol-th column of the
** result set in pEList.
**
** If the result set column is a simple column reference, then this routine
** makes an exact copy. But for any other kind of expression, this
** routine make a copy of the result set column as the argument to the
** TK_AS operator. The TK_AS operator causes the expression to be
** evaluated just once and then reused for each alias.
**
** The reason for suppressing the TK_AS term when the expression is a simple
** column reference is so that the column reference will be recognized as
** usable by indices within the WHERE clause processing logic.
**
** Hack: The TK_AS operator is inhibited if zType[0]=='G'. This means
** that in a GROUP BY clause, the expression is evaluated twice. Hence:
**
** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x
**
** Is equivalent to:
**
** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5
**
** The result of random()%5 in the GROUP BY clause is probably different
** from the result in the result-set. We might fix this someday. Or
** then again, we might not...
*/
static void resolveAlias(
Parse pParse, /* Parsing context */
ExprList pEList, /* A result set */
int iCol, /* A column in the result set. 0..pEList.nExpr-1 */
Expr pExpr, /* Transform this into an alias to the result set */
string zType /* "GROUP" or "ORDER" or "" */
)
{
Expr pOrig; /* The iCol-th column of the result set */
Expr pDup; /* Copy of pOrig */
sqlite3 db; /* The database connection */
Debug.Assert( iCol >= 0 && iCol < pEList.nExpr );
pOrig = pEList.a[iCol].pExpr;
Debug.Assert( pOrig != null );
Debug.Assert( ( pOrig.flags & EP_Resolved ) != 0 );
db = pParse.db;
if ( pOrig.op != TK_COLUMN && ( zType.Length == 0 || zType[0] != 'G' ) )
{
pDup = sqlite3ExprDup( db, pOrig, 0 );
pDup = sqlite3PExpr( pParse, TK_AS, pDup, null, null );
if ( pDup == null ) return;
if ( pEList.a[iCol].iAlias == 0 )
{
pEList.a[iCol].iAlias = (u16)( ++pParse.nAlias );
}
pDup.iTable = pEList.a[iCol].iAlias;
}
else if ( ExprHasProperty( pOrig, EP_IntValue ) || pOrig.u.zToken == null )
{
pDup = sqlite3ExprDup( db, pOrig, 0 );
if ( pDup == null ) return;
}
else
{
string zToken = pOrig.u.zToken;
Debug.Assert( zToken != null );
pOrig.u.zToken = null;
pDup = sqlite3ExprDup( db, pOrig, 0 );
pOrig.u.zToken = zToken;
if ( pDup == null ) return;
Debug.Assert( ( pDup.flags & ( EP_Reduced | EP_TokenOnly ) ) == 0 );
pDup.flags2 |= EP2_MallocedToken;
pDup.u.zToken = zToken;// sqlite3DbStrDup( db, zToken );
}
//.........这里部分代码省略.........
示例14: sqlite3ExprAffinity
/*
** 2001 September 15
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
*************************************************************************
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
** C#-SQLite is an independent reimplementation of the SQLite software library
**
** SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2
**
*************************************************************************
*/
//#include "sqliteInt.h"
/*
** Return the 'affinity' of the expression pExpr if any.
**
** If pExpr is a column, a reference to a column via an 'AS' alias,
** or a sub-select with a column as the return value, then the
** affinity of that column is returned. Otherwise, 0x00 is returned,
** indicating no affinity for the expression.
**
** i.e. the WHERE clause expresssions in the following statements all
** have an affinity:
**
** CREATE TABLE t1(a);
** SELECT * FROM t1 WHERE a;
** SELECT a AS b FROM t1 WHERE b;
** SELECT * FROM t1 WHERE (select a from t1);
*/
static char sqlite3ExprAffinity( Expr pExpr )
{
int op = pExpr.op;
if ( op == TK_SELECT )
{
Debug.Assert( ( pExpr.flags & EP_xIsSelect ) != 0 );
return sqlite3ExprAffinity( pExpr.x.pSelect.pEList.a[0].pExpr );
}
#if !SQLITE_OMIT_CAST
if ( op == TK_CAST )
{
Debug.Assert( !ExprHasProperty( pExpr, EP_IntValue ) );
return sqlite3AffinityType( pExpr.u.zToken );
}
#endif
if ( ( op == TK_AGG_COLUMN || op == TK_COLUMN || op == TK_REGISTER )
&& pExpr.pTab != null
)
{
/* op==TK_REGISTER && pExpr.pTab!=0 happens when pExpr was originally
** a TK_COLUMN but was previously evaluated and cached in a register */
int j = pExpr.iColumn;
if ( j < 0 )
return SQLITE_AFF_INTEGER;
Debug.Assert( pExpr.pTab != null && j < pExpr.pTab.nCol );
return pExpr.pTab.aCol[j].affinity;
}
return pExpr.affinity;
}
示例15: ForExpr
/// <summary>
/// Initialize
/// </summary>
/// <param name="start">start expression</param>
/// <param name="condition">condition for loop</param>
/// <param name="inc">increment expression</param>
public ForExpr(Expr start, Expr condition, Expr inc)
: base(condition)
{
this.Nodetype = NodeTypes.SysFor;
InitBoundary(true, "}");
Init(start, condition, inc);
}