本文整理汇总了C#中Expr类的典型用法代码示例。如果您正苦于以下问题:C# Expr类的具体用法?C# Expr怎么用?C# Expr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expr类属于命名空间,在下文中一共展示了Expr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:chrisdunelm,项目名称:DotNetWebToolkit,代码行数:27,代码来源:VisitorRemoveCasts.cs
示例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");
}
开发者ID:ShuntaoChen,项目名称:Compiler,代码行数:12,代码来源:Stmt.cs
示例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);
}
}
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:35,代码来源:ExprParser.cs
示例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();
}
开发者ID:chrisdunelm,项目名称:DotNetWebToolkit,代码行数:7,代码来源:ExprVariableAddress.cs
示例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);
}
开发者ID:BclEx,项目名称:GpuStructs,代码行数:33,代码来源:Walker+Resolve.cs
示例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);
}
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:41,代码来源:AssignHelper.cs
示例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);
}
开发者ID:Chenguang-Zhu,项目名称:ICE-C5,代码行数:7,代码来源:AbsyCmd.cs
示例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();
}
开发者ID:chrisdunelm,项目名称:DotNetWebToolkit,代码行数:7,代码来源:ExprFieldAddress.cs
示例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;
}
开发者ID:BYVoid,项目名称:SugarCpp,代码行数:7,代码来源:Expr.cs
示例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;
}
开发者ID:chrisdunelm,项目名称:DotNetWebToolkit,代码行数:7,代码来源:JsResolved.cs
示例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);
}
}
开发者ID:buptkang,项目名称:MathCog,代码行数:28,代码来源:Reasoner.Validate.cs
示例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;
}
开发者ID:Connect2Begin,项目名称:SugarCpp,代码行数:7,代码来源:Expr.cs
示例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 );
}
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Asuna,代码行数:101,代码来源:resolve_c.cs
示例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;
}
开发者ID:laboratoryyingong,项目名称:BARLESS,代码行数:68,代码来源:expr_c.cs
示例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);
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:13,代码来源:ForExpr.cs
示例16: AssignExpr
/// <summary>
/// Initialize
/// </summary>
/// <param name="isDeclaration">Whether or not the variable is being declared in addition to assignment.</param>
/// <param name="varExp">Expression representing the variable name to set</param>
/// <param name="valueExp">Expression representing the value to set variable to.</param>
public AssignExpr(bool isDeclaration, Expr varExp, Expr valueExp)
{
this.Nodetype = NodeTypes.SysAssign;
this.IsDeclaration = isDeclaration;
this.VarExp = varExp;
this.ValueExp = valueExp;
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:13,代码来源:AssignExpr.cs
示例17: SetIndexValue
/// <summary>
/// Sets a value on a member of a basic type.
/// </summary>
/// <param name="ctx">The context of the runtime</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>
/// <param name="node">The assignment ast node</param>
public static void SetIndexValue(Context ctx, IAstVisitor visitor, AstNode node, Expr varExp, Expr valExp)
{
// 1. Get the value that is being assigned.
var val = valExp.Evaluate(visitor) as LObject;
// 2. Check the limit if string.
ctx.Limits.CheckStringLength(node, val);
// 3. Evaluate expression to get index info.
var indexExp = varExp.Evaluate(visitor) as IndexAccess;
if (indexExp == null)
throw ComLib.Lang.Helpers.ExceptionHelper.BuildRunTimeException(node, "Value to assign is null");
// 4. Get the target of the index access and the name / number to set.
var target = indexExp.Instance;
var memberNameOrIndex = indexExp.MemberName;
// Get methods associated with type.
var methods = ctx.Methods.Get(target.Type);
// Case 1: users[0] = 'kishore'
if (target.Type == LTypes.Array)
{
var index = Convert.ToInt32(((LNumber)memberNameOrIndex).Value);
methods.SetByNumericIndex(target, index, val);
}
// Case 2: users['total'] = 20
else if (target.Type == LTypes.Map)
{
var name = ((LString)memberNameOrIndex).Value;
methods.SetByStringMember(target, name, val);
}
}
开发者ID:shuxingliu,项目名称:SambaPOS-3,代码行数:40,代码来源:AssignHelper.cs
示例18: PredicateCmd
void PredicateCmd(Expr p, Expr pDom, List<Block> blocks, Block block, Cmd cmd, out Block nextBlock) {
var cCmd = cmd as CallCmd;
if (cCmd != null && !useProcedurePredicates(cCmd.Proc)) {
if (p == null) {
block.Cmds.Add(cmd);
nextBlock = block;
return;
}
var trueBlock = new Block();
blocks.Add(trueBlock);
trueBlock.Label = block.Label + ".call.true";
trueBlock.Cmds.Add(new AssumeCmd(Token.NoToken, p));
trueBlock.Cmds.Add(cmd);
var falseBlock = new Block();
blocks.Add(falseBlock);
falseBlock.Label = block.Label + ".call.false";
falseBlock.Cmds.Add(new AssumeCmd(Token.NoToken, Expr.Not(p)));
var contBlock = new Block();
blocks.Add(contBlock);
contBlock.Label = block.Label + ".call.cont";
block.TransferCmd =
new GotoCmd(Token.NoToken, new List<Block> { trueBlock, falseBlock });
trueBlock.TransferCmd = falseBlock.TransferCmd =
new GotoCmd(Token.NoToken, new List<Block> { contBlock });
nextBlock = contBlock;
} else {
PredicateCmd(p, pDom, block.Cmds, cmd);
nextBlock = block;
}
}
开发者ID:qunyanm,项目名称:boogie,代码行数:34,代码来源:SmartBlockPredicator.cs
示例19: ExprTernary
public ExprTernary(Ctx ctx, Expr condition, Expr ifTrue, Expr ifFalse)
: base(ctx) {
this.Condition = condition;
this.IfTrue = ifTrue;
this.IfFalse = ifFalse;
this.type = TypeCombiner.Combine(ctx, ifTrue, ifFalse);
}
开发者ID:chrisdunelm,项目名称:DotNetWebToolkit,代码行数:7,代码来源:ExprTernary.cs
示例20: ForItemDownTo
public ForItemDownTo(string var, Expr from, Expr to, Expr by)
{
this.Var = var;
this.From = from;
this.To = to;
this.By = by;
}
开发者ID:BYVoid,项目名称:SugarCpp,代码行数:7,代码来源:StmtFor.cs
注:本文中的Expr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论