本文整理汇总了C#中JSIL.Ast.JSVariable类的典型用法代码示例。如果您正苦于以下问题:C# JSVariable类的具体用法?C# JSVariable怎么用?C# JSVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSVariable类属于JSIL.Ast命名空间,在下文中一共展示了JSVariable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EliminateVariable
protected void EliminateVariable (JSNode context, JSVariable variable, JSExpression replaceWith, QualifiedMemberIdentifier method) {
{
var replacer = new VariableEliminator(
variable,
JSChangeTypeExpression.New(replaceWith, variable.GetActualType(TypeSystem), TypeSystem)
);
replacer.Visit(context);
}
{
var replacer = new VariableEliminator(variable, replaceWith);
var assignments = (from a in FirstPass.Assignments where
variable.Equals(a.NewValue) ||
a.NewValue.SelfAndChildrenRecursive.Any(variable.Equals)
select a).ToArray();
foreach (var a in assignments) {
if (!variable.Equals(a.NewValue))
replacer.Visit(a.NewValue);
}
}
Variables.Remove(variable.Identifier);
FunctionSource.InvalidateFirstPass(method);
}
开发者ID:Don191,项目名称:JSIL,代码行数:25,代码来源:EliminateSingleUseTemporaries.cs
示例2: ILBlockTranslator
public ILBlockTranslator(AssemblyTranslator translator, DecompilerContext context, MethodReference methodReference, MethodDefinition methodDefinition, ILBlock ilb, IEnumerable<ILVariable> parameters, IEnumerable<ILVariable> allVariables)
{
Translator = translator;
Context = context;
ThisMethodReference = methodReference;
ThisMethod = methodDefinition;
Block = ilb;
SpecialIdentifiers = new JSIL.SpecialIdentifiers(TypeSystem);
if (methodReference.HasThis)
Variables.Add("this", JSThisParameter.New(methodReference.DeclaringType, methodReference));
foreach (var parameter in parameters) {
if ((parameter.Name == "this") && (parameter.OriginalParameter.Index == -1))
continue;
ParameterNames.Add(parameter.Name);
Variables.Add(parameter.Name, new JSParameter(parameter.Name, parameter.Type, methodReference));
}
foreach (var variable in allVariables) {
var v = JSVariable.New(variable, methodReference);
if (Variables.ContainsKey(v.Identifier)) {
v = new JSVariable(variable.OriginalVariable.Name, variable.Type, methodReference);
RenamedVariables[variable] = v;
Variables.Add(v.Identifier, v);
} else {
Variables.Add(v.Identifier, v);
}
}
}
开发者ID:aprishchepov,项目名称:JSIL,代码行数:32,代码来源:ILBlockTranslator.cs
示例3: MatchesConstructedReference
protected bool MatchesConstructedReference (JSExpression lhs, JSVariable rhs) {
var jsv = lhs as JSVariable;
if ((jsv != null) && (jsv.Identifier == rhs.Identifier))
return true;
return false;
}
开发者ID:cbsistem,项目名称:JSIL,代码行数:7,代码来源:IntroduceVariableReferences.cs
示例4: VisitNode
public void VisitNode(JSVariable variable)
{
int count;
if (ReferenceCounts.TryGetValue(variable.Identifier, out count))
ReferenceCounts[variable.Identifier] = count + 1;
else
ReferenceCounts[variable.Identifier] = 1;
VisitChildren(variable);
}
开发者ID:kyle1235,项目名称:JSIL,代码行数:10,代码来源:EmulateStructAssignment.cs
示例5: VisitNode
public void VisitNode(JSVariable variable)
{
// If our parent node is the function, we're in the argument list
if (ParentNode is JSFunctionExpression)
return;
int count;
if (ReferenceCounts.TryGetValue(variable.Identifier, out count))
ReferenceCounts[variable.Identifier] = count + 1;
else
ReferenceCounts[variable.Identifier] = 1;
}
开发者ID:rozgo,项目名称:JSIL,代码行数:12,代码来源:EmulateStructAssignment.cs
示例6: TransformParameterIntoReference
protected void TransformParameterIntoReference(JSVariable parameter, JSBlockStatement block)
{
var newParameter = new JSParameter("$" + parameter.Identifier, parameter.Type);
var newVariable = new JSVariable(parameter.Identifier, new ByReferenceType(parameter.Type));
var newDeclaration = new JSVariableDeclarationStatement(
new JSBinaryOperatorExpression(
JSOperator.Assignment,
// We have to use parameter here, not newVariable or newParameter, otherwise the resulting
// assignment looks like 'x.value = initializer' instead of 'x = initializer'
parameter,
JSIL.NewReference(newParameter),
newVariable.Type
)
);
if (Tracing)
Debug.WriteLine(String.Format("Transformed {0} into {1}={2}", parameter, newVariable, newParameter));
Variables[newVariable.Identifier] = newVariable;
Variables.Add(newParameter.Identifier, newParameter);
ParameterNames.Remove(parameter.Identifier);
ParameterNames.Add(newParameter.Identifier);
block.Statements.Insert(0, newDeclaration);
}
开发者ID:rozgo,项目名称:JSIL,代码行数:24,代码来源:IntroduceVariableReferences.cs
示例7: VisitNode
public void VisitNode (JSVariable variable) {
if (CurrentName == "FunctionSignature") {
// In argument list
return;
}
if (Variable.Equals(variable)) {
ParentNode.ReplaceChild(variable, Replacement);
} else {
VisitChildren(variable);
}
}
开发者ID:Don191,项目名称:JSIL,代码行数:12,代码来源:EliminateSingleUseTemporaries.cs
示例8: IsEffectivelyConstant
protected bool IsEffectivelyConstant(JSVariable target, JSExpression source)
{
if ((source == null) || (source.IsNull))
return false;
// Handle special cases where our interpretation of 'constant' needs to be more flexible
{
var ie = source as JSIndexerExpression;
if (ie != null) {
if (
IsEffectivelyConstant(target, ie.Target) &&
IsEffectivelyConstant(target, ie.Index)
)
return true;
}
}
{
var ae = source as JSArrayExpression;
if (
(ae != null) &&
(from av in ae.Values select IsEffectivelyConstant(target, av)).All((b) => b)
)
return true;
}
{
var de = source as JSDotExpression;
if (
(de != null) &&
IsEffectivelyConstant(target, de.Target) &&
IsEffectivelyConstant(target, de.Member)
)
return true;
}
{
var ie = source as JSInvocationExpression;
if (
(ie != null) && ie.ConstantIfArgumentsAre &&
IsEffectivelyConstant(target, ie.ThisReference) &&
ie.Arguments.All((a) => IsEffectivelyConstant(target, a))
)
return true;
}
if ((source is JSUnaryOperatorExpression) || (source is JSBinaryOperatorExpression)) {
if (source.Children.OfType<JSExpression>().All((_v) => IsEffectivelyConstant(target, _v)))
return true;
}
if (source.IsConstant)
return true;
// Try to find a spot between the source variable's assignments where all of our
// copies and accesses can fit. If we find one, our variable is effectively constant.
var v = source as JSVariable;
if (v != null) {
var assignments = (from a in FirstPass.Assignments where v.Equals(a.Target) select a).ToArray();
if (assignments.Length < 1)
return v.IsParameter;
var targetAssignments = (from a in FirstPass.Assignments where v.Equals(a.Target) select a).ToArray();
if (targetAssignments.Length < 1)
return false;
var targetAccesses = (from a in FirstPass.Accesses where target.Equals(a.Source) select a).ToArray();
if (targetAccesses.Length < 1)
return false;
var targetFirstAssigned = targetAssignments.FirstOrDefault();
var targetLastAssigned = targetAssignments.LastOrDefault();
var targetFirstAccessed = targetAccesses.FirstOrDefault();
var targetLastAccessed = targetAccesses.LastOrDefault();
bool foundAssignmentSlot = false;
for (int i = 0, c = assignments.Length; i < c; i++) {
int assignment = assignments[i].StatementIndex, nextAssignment = int.MaxValue;
if (i < c - 1)
nextAssignment = assignments[i + 1].StatementIndex;
if (
(targetFirstAssigned.StatementIndex >= assignment) &&
(targetFirstAssigned.StatementIndex < nextAssignment) &&
(targetFirstAccessed.StatementIndex >= assignment) &&
(targetLastAccessed.StatementIndex <= nextAssignment)
) {
foundAssignmentSlot = true;
break;
}
}
if (!foundAssignmentSlot)
return false;
return true;
}
//.........这里部分代码省略.........
开发者ID:robashton,项目名称:JSIL,代码行数:101,代码来源:EliminateSingleUseTemporaries.cs
示例9: ReplaceChild
public override void ReplaceChild(JSNode oldChild, JSNode newChild)
{
if (oldChild == null)
throw new ArgumentNullException("oldChild");
if (CatchVariable == oldChild)
CatchVariable = (JSVariable)newChild;
if (Catch == oldChild)
Catch = (JSStatement)newChild;
if (Finally == oldChild)
Finally = (JSStatement)newChild;
Body.ReplaceChild(oldChild, newChild);
}
开发者ID:poizan42,项目名称:JSIL,代码行数:16,代码来源:JSStatementTypes.cs
示例10: IsVarEffectivelyConstantHere
private bool IsVarEffectivelyConstantHere (JSVariable variable) {
if (variable == null)
return false;
if (variable.IsParameter)
return false;
// If we're making a copy of a local variable, and this is the last reference to
// the variable, we can eliminate the copy.
if (
!SecondPass.Data.VariablesPassedByRef.Contains(variable.Identifier) &&
SecondPass.Data.Accesses
.Where(a => a.Source == variable.Identifier)
// FIXME: This should probably be NodeIndex but that gets out of sync somehow? Outdated analysis data?
.All(a => a.StatementIndex <= StatementIndex) &&
SecondPass.Data.Assignments
.Where(a => a.Target == variable.Identifier)
// FIXME: This should probably be NodeIndex but that gets out of sync somehow? Outdated analysis data?
.All(a => a.StatementIndex < StatementIndex)
) {
return true;
}
return false;
}
开发者ID:cbsistem,项目名称:JSIL,代码行数:26,代码来源:EmulateStructAssignment.cs
示例11: VisitNode
public void VisitNode(JSVariable v)
{
SeenAlready.Add(v);
VisitChildren(v);
}
开发者ID:nateleroux,项目名称:JSIL,代码行数:6,代码来源:IntroduceVariableDeclarations.cs
示例12: VariableReferenceAccessTransformer
public VariableReferenceAccessTransformer (JSILIdentifier jsil, JSVariable variable, IFunctionSource functionSource) {
JSIL = jsil;
Variable = variable;
FunctionSource = functionSource;
}
开发者ID:cbsistem,项目名称:JSIL,代码行数:5,代码来源:IntroduceVariableReferences.cs
示例13: EmitFieldIntrinsics
private void EmitFieldIntrinsics(int heapSize)
{
// FIXME: Gross
var tis = (ITypeInfoSource)Translator.TypeInfoProvider;
Formatter.WriteRaw(";; Compiler-generated field accessors");
Formatter.NewLine();
foreach (var kvp in FieldTable.OrderBy(kvp => kvp.Value.Offset)) {
var fd = kvp.Value.Field;
var fi = (FieldInfo)tis.Get(fd);
var name = WasmUtil.FormatMemberName(fi.Member);
var typeSystem = fd.FieldType.Module.TypeSystem;
// HACK
var baseAddressParam = new JSVariable("address", typeSystem.Int32, null);
// HACK
var valueParam = new JSVariable("value", fd.FieldType, null);
JSExpression address;
if (fd.IsStatic) {
address = JSLiteral.New(kvp.Value.Offset + heapSize);
} else {
address = new JSBinaryOperatorExpression(
JSOperator.Add,
baseAddressParam,
JSLiteral.New(kvp.Value.Offset),
typeSystem.Int32
);
}
Formatter.ConditionalNewLine();
Formatter.WriteRaw(
"(func $__get_{0} (result {1}){2}(return ",
name,
WasmUtil.PickTypeKeyword(fd.FieldType),
fd.IsStatic
? " "
: " (param $address i32) "
);
var gm = new GetMemory(
fd.FieldType, /* FIXME: Align addresses */ false,
address
);
// HACK
EntryPointAstEmitter.Emit(gm);
Formatter.WriteRaw(") )");
if (fd.IsInitOnly)
continue;
Formatter.NewLine();
Formatter.WriteRaw(
"(func $__set_{0}{2}(param $value {1}) ",
name,
WasmUtil.PickTypeKeyword(fd.FieldType),
fd.IsStatic
? " "
: " (param $address i32) "
);
Formatter.Indent();
Formatter.NewLine();
var sm = new SetMemory(
fd.FieldType, /* FIXME: Align addresses */ false,
address, valueParam
);
// HACK
EntryPointAstEmitter.Emit(sm);
Formatter.Unindent();
Formatter.ConditionalNewLine();
Formatter.WriteRaw(")");
}
Formatter.NewLine();
Formatter.NewLine();
}
开发者ID:WebAssembly,项目名称:ilwasm,代码行数:81,代码来源:AssemblyEmitter.cs
示例14: JSVariableReference
public JSVariableReference(JSVariable referent, MethodReference function)
: base(referent.Identifier, null, function)
{
Referent = referent;
}
开发者ID:kyle1235,项目名称:JSIL,代码行数:5,代码来源:JSIdentifierTypes.cs
示例15: TransformVariableIntoReference
protected void TransformVariableIntoReference(JSVariable variable, JSVariableDeclarationStatement statement, int declarationIndex)
{
if (variable.IsReference)
Debugger.Break();
var oldDeclaration = statement.Declarations[declarationIndex];
var newVariable = variable.Reference();
var newDeclaration = new JSBinaryOperatorExpression(
JSOperator.Assignment,
// We have to use a constructed ref to the variable here, otherwise
// the declaration will look like 'var x.value = foo'
new JSVariable(variable.Identifier, variable.Type),
JSIL.NewReference(oldDeclaration.Right),
newVariable.Type
);
if (Tracing)
Debug.WriteLine(String.Format("Transformed {0} into {1} in {2}", variable, newVariable, statement));
Variables[variable.Identifier] = newVariable;
statement.Declarations[declarationIndex] = newDeclaration;
TransformedVariables.Add(variable.Identifier);
}
开发者ID:rozgo,项目名称:JSIL,代码行数:23,代码来源:IntroduceVariableReferences.cs
示例16: VariableReferenceAccessTransformer
public VariableReferenceAccessTransformer(JSILIdentifier jsil, JSVariable variable)
{
JSIL = jsil;
Variable = variable;
}
开发者ID:poizan42,项目名称:JSIL,代码行数:5,代码来源:IntroduceVariableReferences.cs
示例17: VisitNode
public void VisitNode(JSVariable variable)
{
if (
(ParentNode is JSFunctionExpression) &&
(this.CurrentName == "FunctionSignature")
) {
VisitChildren(variable);
return;
}
if (
(variable.Identifier != Variable.Identifier) ||
// Don't transform if we're inside a read-through already
(ParentNode is JSReadThroughReferenceExpression) ||
(
// If we're inside a write-through and on the LHS, don't transform
(ParentNode is JSWriteThroughReferenceExpression) &&
(this.CurrentName == "Left")
)
) {
VisitChildren(variable);
return;
}
// If we're inside a pass-by-reference (ref x) then don't transform
if (
Stack.OfType<JSPassByReferenceExpression>().Any()
) {
VisitChildren(variable);
return;
}
var replacement = new JSReadThroughReferenceExpression(variable);
ParentNode.ReplaceChild(variable, replacement);
VisitReplacement(replacement);
}
开发者ID:poizan42,项目名称:JSIL,代码行数:36,代码来源:IntroduceVariableReferences.cs
示例18: MakeTemporaryVariable
private JSVariable MakeTemporaryVariable (TypeReference type, out string id, JSExpression defaultValue = null) {
string _id = id = string.Format("$hoisted{0:X2}", HoistedVariableCount++);
MethodReference methodRef = null;
if (Function.Method != null)
methodRef = Function.Method.Reference;
// So introspection knows about it
var result = new JSVariable(id, type, methodRef);
Function.AllVariables.Add(_id, result);
ToDeclare.Add(new PendingDeclaration(id, type, result, defaultValue));
return result;
}
开发者ID:cbsistem,项目名称:JSIL,代码行数:13,代码来源:AllocationHoisting.cs
示例19: JSTryCatchBlock
public JSTryCatchBlock(JSStatement body, JSVariable catchVariable = null, JSStatement @catch = null, JSStatement @finally = null)
{
Body = body;
CatchVariable = catchVariable;
Catch = @catch;
Finally = @finally;
}
开发者ID:poizan42,项目名称:JSIL,代码行数:7,代码来源:JSStatementTypes.cs
示例20: Create
internal JSFunctionExpression Create (
MethodInfo info, MethodDefinition methodDef, MethodReference method,
QualifiedMemberIdentifier identifier, ILBlockTranslator translator,
JSVariable[] parameters, JSBlockStatement body
) {
var args = new PopulatedCacheEntryArgs {
Info = info,
Method = method,
Translator = translator,
Parameters = parameters,
Body = body,
};
return Cache.GetOrCreate(identifier, args, MakePopulatedCacheEntry).Expression;
}
开发者ID:cbsistem,项目名称:JSIL,代码行数:15,代码来源:FunctionCache.cs
注:本文中的JSIL.Ast.JSVariable类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论