本文整理汇总了C#中PHP.Core.AST.ExInfoFromParent类的典型用法代码示例。如果您正苦于以下问题:C# ExInfoFromParent类的具体用法?C# ExInfoFromParent怎么用?C# ExInfoFromParent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExInfoFromParent类属于PHP.Core.AST命名空间,在下文中一共展示了ExInfoFromParent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
ExInfoFromParent operand_info = ExInfoFromParent.DefaultExInfo;
Evaluation left_eval = leftExpr.Analyze(analyzer, operand_info);
Evaluation right_eval;
// Boolean expression evaluation semantics:
if (operation == Operations.Or)
{
analyzer.EnterConditionalCode();
right_eval = rightExpr.Analyze(analyzer, operand_info);
analyzer.LeaveConditionalCode();
}
else
{
right_eval = rightExpr.Analyze(analyzer, operand_info);
}
Evaluation result = Evaluation.Evaluate(this, left_eval, out leftExpr, right_eval, out rightExpr);
// division by zero check:
if ((operation == Operations.Div || operation == Operations.Mod) && result.HasValue && result.Value is bool && (bool)result.Value == false)
{
analyzer.ErrorSink.Add(Warnings.DivisionByZero, analyzer.SourceUnit, rightExpr.Position);
}
else if ((operation == Operations.Div || operation == Operations.Mod) && right_eval.HasValue && right_eval.Value is int && (int)right_eval.Value == 0)
{
result = new Evaluation(this, false);
analyzer.ErrorSink.Add(Warnings.DivisionByZero, analyzer.SourceUnit, rightExpr.Position);
}
return result;
}
示例2: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
bool already_resolved = constant != null;
if (!already_resolved)
{
access = info.Access;
ResolveName(analyzer);
}
if (constant.IsUnknown)
return new Evaluation(this);
KnownConstant known_const = (KnownConstant)constant;
if (known_const.HasValue)
{
// constant value is known:
return new Evaluation(this, known_const.Value);
}
else if (already_resolved)
{
// circular definition:
constant.ReportCircularDefinition(analyzer.ErrorSink);
return new Evaluation(this);
}
else
{
// value is not known yet, try to resolve it:
if (known_const.Node != null)
known_const.Node.Analyze(analyzer);
return (known_const.HasValue) ? new Evaluation(this, known_const.Value) : new Evaluation(this);
}
}
示例3: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
Evaluation cond_eval = condExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
if (cond_eval.HasValue)
{
if (Convert.ObjectToBoolean(cond_eval.Value))
{
if (trueExpr != null)
return trueExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
else
return cond_eval; // condExpr ?: falseExpr // ternary shortcut
}
else
return falseExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo);
}
else
{
if (trueExpr != null)
{
analyzer.EnterConditionalCode();
trueExpr = trueExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
analyzer.LeaveConditionalCode();
}
analyzer.EnterConditionalCode();
falseExpr = falseExpr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
analyzer.LeaveConditionalCode();
return new Evaluation(this);
}
}
示例4: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
fileNameEx = fileNameEx.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
analyzer.AddCurrentRoutineProperty(RoutineProperties.ContainsInclude);
analyzer.CurrentScope = this.scope;
return new Evaluation(this);
}
示例5: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
foreach (Item i in items)
if (i != null) i.Analyze(analyzer);
return new Evaluation(this);
}
示例6: Analyze
public void Analyze(ActualParam/*!*/node, Analyzer/*!*/ analyzer, bool isBaseCtorCallConstrained)
{
// TODO: isBaseCtorCallConstrained
ExInfoFromParent info = new ExInfoFromParent(node);
analyzer.EnterActParam();
if (node.IsVariadic) throw new NotImplementedException();
if (analyzer.ActParamDeclIsUnknown())
{
// we don't know whether the parameter will be passed by reference at run-time:
if (node.Expression.AllowsPassByReference)
{
info.Access = AccessType.ReadUnknown;
// Although we prepare to pass reference, value can be really passed.
// That's why we report warning when user use '&' in calling,
// because it has no influence.
if (node.Ampersand)
analyzer.ErrorSink.Add(Warnings.ActualParamWithAmpersand, analyzer.SourceUnit, node.Span);
}
else
{
info.Access = AccessType.Read;
}
}
else
{
if (analyzer.ActParamPassedByRef())
{
if (node.Expression.AllowsPassByReference)
{
info.Access = AccessType.ReadRef;
}
else
{
analyzer.ErrorSink.Add(Errors.NonVariablePassedByRef, analyzer.SourceUnit, node.Expression.Span);
analyzer.LeaveActParam();
return;
}
}
else
{
info.Access = AccessType.Read;
if (node.Ampersand) analyzer.ErrorSink.Add(Warnings.ActualParamWithAmpersand, analyzer.SourceUnit, node.Span);
}
}
node._expression = node.Expression.Analyze(analyzer, info).Literalize();
// TODO: if signature is known, act. param has type hint and expression has known type; check if type hint matches expression
analyzer.LeaveActParam();
}
示例7: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
ExInfoFromParent var_info = new ExInfoFromParent(this);
var_info.Access = AccessType.ReadAndWrite;
variable.Analyze(analyzer, var_info);
return new Evaluation(this);
}
示例8: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
type = analyzer.ResolveTypeName(typeName, analyzer.CurrentType, analyzer.CurrentRoutine, position, false);
analyzer.AnalyzeConstructedType(type);
return new Evaluation(this);
}
示例9: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
this.typeRef.Analyze(analyzer);
this.type = this.typeRef.ResolvedTypeOrUnknown;
analyzer.AnalyzeConstructedType(type);
return new Evaluation(this);
}
示例10: Analyze
internal void Analyze(Analyzer/*!*/ analyzer, bool isBaseCtorCallConstrained)
{
// TODO: isBaseCtorCallConstrained
ExInfoFromParent info = new ExInfoFromParent(this);
analyzer.EnterActParam();
if (analyzer.ActParamDeclIsUnknown())
{
// we don't know whether the parameter will be passed by reference at run-time:
if (expression.AllowsPassByReference)
{
info.Access = AccessType.ReadUnknown;
// Although we prepare to pass reference, value can be really passed.
// That's why we report warning when user use '&' in calling,
// because it has no influence.
if (ampersand)
analyzer.ErrorSink.Add(Warnings.ActualParamWithAmpersand, analyzer.SourceUnit, position);
}
else
{
info.Access = AccessType.Read;
}
}
else
{
if (analyzer.ActParamPassedByRef())
{
if (expression.AllowsPassByReference)
{
info.Access = AccessType.ReadRef;
}
else
{
analyzer.ErrorSink.Add(Errors.NonVariablePassedByRef, analyzer.SourceUnit, expression.Position);
analyzer.LeaveActParam();
return;
}
}
else
{
info.Access = AccessType.Read;
if (ampersand) analyzer.ErrorSink.Add(Warnings.ActualParamWithAmpersand, analyzer.SourceUnit, position);
}
}
expression = expression.Analyze(analyzer, info).Literalize();
analyzer.LeaveActParam();
}
示例11: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
// if the expression should be emitted:
if (characteristic == Characteristic.Dynamic || characteristic == Characteristic.StaticArgEvaluated)
{
fileNameEx = fileNameEx.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
}
analyzer.AddCurrentRoutineProperty(RoutineProperties.ContainsInclude);
analyzer.CurrentScope = this.scope;
return new Evaluation(this);
}
示例12: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
bool var_shall_be_ref;
access = info.Access;
base.Analyze(analyzer, info);
var_shall_be_ref = !(access == AccessType.Read || access == AccessType.Write || access == AccessType.ReadAndWrite ||
access == AccessType.None);
//If this VarUse is in GlobalCode, value of var_shall_be_ref does not matter.
//All global vars are refs.
//$this has special meaning, but $a->this has NOT
if (varName.IsThisVariableName && isMemberOf == null)
{
// report misuse of $this if we are sure about it, that is in a static routine:
if (analyzer.CurrentRoutine != null && analyzer.CurrentRoutine.IsStatic)
{
analyzer.ErrorSink.Add(Warnings.ThisOutOfMethod, analyzer.SourceUnit, position);
}
if (!(info.Parent is VarLikeConstructUse) // $this->a = 1; is ok, but $this has write AT
&& !(access == AccessType.None
|| access == AccessType.Read
|| access == AccessType.ReadRef
|| access == AccessType.ReadUnknown))
{
analyzer.ErrorSink.Add(Warnings.ThisInWriteContext, analyzer.SourceUnit, position);
}
}
if (isMemberOf == null)
{
if (analyzer.CurrentVarTable == null)
{
Debug.Assert(analyzer.SourceUnit.CompilationUnit.IsPure);
// variables used in global context when we do not have global variable table:
analyzer.ErrorSink.Add(Errors.GlobalCodeInPureUnit, analyzer.SourceUnit, position);
}
else
analyzer.CurrentVarTable.Set(varName, var_shall_be_ref);
}
return new Evaluation(this);
}
示例13: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
switch (operation)
{
case Operations.Print:
case Operations.Clone:
case Operations.ObjectCast:
case Operations.ArrayCast:
expr = expr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
return new Evaluation(this);
default:
return expr.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Evaluate(this, out expr);
}
}
示例14: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Expression.Analyze"]/*'/>
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
// checks for write context of key-less array operator ($a =& $x[] is ok):
if (index == null
&& (access == AccessType.Read
|| access == AccessType.ReadAndWrite
|| access == AccessType.ReadAndWriteAndReadRef
|| access == AccessType.ReadAndWriteAndReadUnknown))
{
analyzer.ErrorSink.Add(Errors.EmptyIndexInReadContext, analyzer.SourceUnit, position);
return new Evaluation(this);
}
base.Analyze(analyzer, info);
ExInfoFromParent sinfo = new ExInfoFromParent(this);
switch (info.Access)
{
case AccessType.Write:
case AccessType.WriteRef:
case AccessType.ReadRef: sinfo.Access = AccessType.Write; break;
case AccessType.ReadAndWriteAndReadRef:
case AccessType.WriteAndReadRef:
case AccessType.ReadAndWrite: sinfo.Access = AccessType.ReadAndWrite; break;
case AccessType.WriteAndReadUnknown:
case AccessType.ReadAndWriteAndReadUnknown: sinfo.Access = info.Access; break;
case AccessType.ReadUnknown: sinfo.Access = AccessType.ReadUnknown; break;
default: sinfo.Access = AccessType.Read; break;
}
array.Analyze(analyzer, sinfo);
if (index != null)
index = index.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
return new Evaluation(this);
}
示例15: Analyze
internal override Evaluation Analyze(Analyzer/*!*/ analyzer, ExInfoFromParent info)
{
access = info.Access;
ExInfoFromParent sinfo = new ExInfoFromParent(this);
// r-value
if (RValue != null)
RValue = RValue.Analyze(analyzer, sinfo).Literalize();
// l-values
sinfo.Access = AccessType.Write;
for (int i = 0; i < LValues.Count; i++)
{
if (LValues[i] != null)
LValues[i] = LValues[i].Analyze(analyzer, sinfo).Expression;
}
return new Evaluation(this);
}