private void UpdateActualMethodCalled(InvocationExpression node, MethodDefinition method, bool specializeOrCreate) { node.ActualMethodCalled = method.TypeExpr; TypeExpression returnTypeExpresion = ((MethodType)node.ActualMethodCalled).Return; if (!specializeOrCreate && node.ExpressionType is TypeVariable) //TODO: FieldAcces, UnionType, etc. { ((TypeVariable)node.ExpressionType).EquivalenceClass.add(returnTypeExpresion, SortOfUnification.Equivalent, previouslyUnified); } node.ExpressionType = returnTypeExpresion; node.FrozenTypeExpression = node.ExpressionType.Freeze(); if (node.Identifier is FieldAccessExpression) { FieldAccessExpression fae = new FieldAccessExpression(((FieldAccessExpression)node.Identifier).Expression, method.IdentifierExp, node.Location); fae.FieldName.IndexOfSSA = -1; fae.ExpressionType = node.ActualMethodCalled; node.Identifier = fae; } else { node.Identifier = method.IdentifierExp; } }
public override Object Visit(FieldAccessExpression node, Object obj) { node.Expression.Accept(this, obj); node.FieldName.Accept(this, obj); return(null); }
public override Object Visit(FieldAccessExpression node, Object obj) { node.Expression.Accept(this, obj); node.FieldName.Accept(this, obj); // * If the first name is a namespace, then the result could be... NameSpaceType nst = node.Expression.ExpressionType as NameSpaceType; if (nst != null) { // * ... another namepace or ... nst = nst.concat(node.FieldName.Identifier); // * ... a class TypeExpression userType = TypeTable.Instance.GetType(nst.Name, node.Location); if (userType != null) { // The class node.ExpressionType = userType; } else // The namespace { node.ExpressionType = nst; } // * We notify the following visitors that the type has been inferred in the type definition node.TypeInferredInVisitorTypeDefinition = true; } return(null); }
public override object Exec(UnionType ut, object arg) { // No need to ask if is the original Expression (first time) //this.areThereNonValidObjects = ut.IsDynamic; // ESTO NO SIRVe FieldAccessExpression fa = this.node.Identifier as FieldAccessExpression; this.areThereNonValidObjects = fa.Expression.ExpressionType.IsDynamic; bool oldFirstTime = this.firstTime; this.firstTime = false; // * 1.2.1.1 The implicit object has unknown type (union types) Dictionary <MethodInvocationArgument, object> dic = new Dictionary <MethodInvocationArgument, object>(); arg = dic; dic[MethodInvocationArgument.Clean] = false; dic[MethodInvocationArgument.MakeBox] = ut.ContainsDifferentReturns(); /// indicates whether is neccesary to make a boxing dic[MethodInvocationArgument.DecorationAttributes] = this.node.Identifier.Accept(this.visitor, this.objInv); // object o; foreach (TypeExpression ti in ut.TypeSet) { ti.AcceptOperation(this, arg); } if (oldFirstTime) { // we leave firstTime in false o maintain coherency in the object status //this.codeGenerator.WriteLabel(this.indent, this.methodLabel); this.EndInvocationMethod((bool)dic[MethodInvocationArgument.Clean]); } return(dic[MethodInvocationArgument.DecorationAttributes]); }
public override Object Visit(InvocationExpression node, Object obj) { InheritedAttributes ia = (InheritedAttributes)obj; Object objArgs = obj; MethodType actualMethodCalled = TypeExpression.As <MethodType>(node.ActualMethodCalled); if (actualMethodCalled != null) { objArgs = new InheritedAttributes(ia.CurrentMethod, ia.Assignment, ia.Reference, ia.ArrayAccessFound, actualMethodCalled, ia.IsParentNodeAnInvocation); } FieldAccessExpression fieldAccessExpression = node.Identifier as FieldAccessExpression; if (fieldAccessExpression != null) { // * A message has been sent with the syntax "obj.method(...)" Object o = node.Identifier.Accept(this, obj); node.Arguments.Accept(this, objArgs); if ((o is SynthesizedAttributes) && (((SynthesizedAttributes)o).IdentifierExpressionMode == IdentifierMode.Instance)) { TypeExpression klass = null; // * When the implicit object is a fresh var reference if (actualMethodCalled != null) { klass = actualMethodCalled.MemberInfo.Class; } this.codeGenerator.CallVirt(this.indent, actualMethodCalled, klass, fieldAccessExpression.FieldName.Identifier, node.Arguments); } else { this.codeGenerator.Call(this.indent, actualMethodCalled, actualMethodCalled.MemberInfo.Class, actualMethodCalled.MemberInfo.MemberIdentifier); } } else { // * A message is sent with without the implicit object "method(...)" if (node.Identifier is SingleIdentifierExpression) { if ((((MethodType)node.Identifier.ExpressionType).MemberInfo.ModifierMask & Modifier.Static) == 0) { this.codeGenerator.ldarg(this.indent, 0); } node.Arguments.Accept(this, objArgs); this.codeGenerator.Call(this.indent, actualMethodCalled, actualMethodCalled.MemberInfo.Class, ((SingleIdentifierExpression)node.Identifier).Identifier); } else { if (node.Identifier is BaseExpression) { node.Arguments.Accept(this, objArgs); this.codeGenerator.constructorCall(this.indent, actualMethodCalled, ((BaseExpression)node.Identifier).ExpressionType, ".ctor"); } } } //TODO: OJO AQUÏ: MIRAR DONDE SE CORRESPONDE CON CODEGENERATOR, PORQUE GENERAR UNA LÍNEA DESDE EL VISITOR // ES un poco chapuzaCHAPUZA this.codeGenerator.WriteLine(); return(null); }
public override object Visit(FieldAccessExpression node, object obj) { if (node.Location == ((AstNode)obj).Location || found) { found = true; return(this.table); } return(base.Visit(node, obj)); }
public override Object Visit(FieldAccessExpression node, Object obj) { int indent = Convert.ToInt32(obj); this.printIndentation(indent); this.output.WriteLine("FieldAccessExpression Type: {0} [{1}:{2}]", printType(node.ExpressionType), node.Location.Line, node.Location.Column); node.Expression.Accept(this, indent + 1); node.FieldName.Accept(this, indent + 1); return(null); }
public override Object Visit(FieldAccessExpression node, Object obj) { FieldAccessExpression clonedFieldAccessExpression = new FieldAccessExpression((Expression)node.Expression.Accept(this, obj), (SingleIdentifierExpression)node.FieldName.Accept(this, obj), new Location("", 1000, 1000)); if (node.ExpressionType != null) { clonedFieldAccessExpression.ExpressionType = node.ExpressionType.CloneType(this.typeVariableMappings, this.typeExpresionVariableMapping); } return(clonedFieldAccessExpression); }
public override Object Visit(FieldAccessExpression node, Object obj) { Object aux = null; if ((aux = node.Expression.Accept(this, false)) is SingleIdentifierExpression) { node.Expression = (SingleIdentifierExpression)aux; } node.FieldName.Accept(this, true); return(null); }
public override object Exec(FieldAccessExpression f, object arg) { // * 1. A message has been sent with the syntax "obj.method(...)" TypeExpression caller = this.node.ActualMethodCalled; if (caller != null) { return(caller.AcceptOperation(new CGILMethodInvocationOperation <T>( this.indent, this.visitor, this.codeGenerator, this.node, this.inheritedAttributes, this.objArgs, this.objInv), arg)); } throw new FieldAccessException(); }
public override Object Visit(FieldAccessExpression node, Object obj) { if (node.Expression.ExpressionType.IsValueType()) { SingleIdentifierExpression sId = new SingleIdentifierExpression(auxiliarValue + this.CurrentAuxiliarSuffix++, node.Location); IdDeclaration id = new IdDeclaration(sId, node.Expression.ExpressionType.ILType(), node.Location); id.TypeExpr = node.Expression.ExpressionType; // temporal variables of the same type are forbidden if (TemporalVariablesTable.Instance.SearchId(id.FullName) == null) // it's a new inserction { TemporalVariablesTable.Instance.Insert(id.FullName, id.ILName); decls.Add(id); } } node.FieldName.Accept(this, obj); return(null); }
/// <summary> /// Adds new assignment statements at the end of the specified block. /// </summary> /// <param name="vars">Information of the current scope in SSAMap.</param> /// <param name="node">Block of statement to add the new declarations.</param> private void addAssignmentStatements(Dictionary <string, SSAElement> vars, Block node) { FieldAccessExpression op1; SingleIdentifierExpression eop1; SingleIdentifierExpression op2; ThisExpression th = new ThisExpression(node.Location); foreach (KeyValuePair <string, SSAElement> pair in vars) { if (pair.Value.IndexSSA > 0) { eop1 = new SingleIdentifierExpression(pair.Key.Substring(6, pair.Key.Length - 6), node.Location); eop1.IndexOfSSA = -1; op1 = new FieldAccessExpression(th, eop1, node.Location); op2 = new SingleIdentifierExpression(pair.Key, node.Location); op2.IndexOfSSA = pair.Value.IndexSSA; node.AddStatement(new AssignmentExpression(op1, op2, AssignmentOperator.Assign, node.Location)); } } }
public CGILMethodInvocationOperation(int indent, VisitorCLRCodeGeneration <T> visitor, T codeGenerator, InvocationExpression node, InheritedAttributes inheritedAttributes, object objArgs, InheritedAttributes objInv) { this.indent = indent; this.codeGenerator = codeGenerator; this.visitor = visitor; this.node = node; this.inheritedAttributes = inheritedAttributes; this.objArgs = objArgs; this.objInv = objInv; this.endLabel = this.codeGenerator.NewLabel + "_END_LABEL"; this.nonValidObjectsLabel = this.codeGenerator.NewLabel + "_NON_VALID_OBJECT_CALLS"; this.reflectionLabel = this.codeGenerator.NewLabel + "_REFLECTION_CALLS"; this.areThereNonValidObjects = false; this.hasTypeVariable = false; this.firstTime = true; FieldAccessExpression fieldAccessExpression = node.Identifier as FieldAccessExpression; this.nonValidObjectsList = (List <TypeExpression>)fieldAccessExpression.Expression.ExpressionType.AcceptOperation(new CGPlainTypeExpressionOperation(), null); }
public void field_not_defined() { var target = new FieldAccessExpression { FieldName = new IdentifierNode { Name = "Foo" }, Target = new StringLiteralExpression("abc") }; AstHelper helper = Mother.CreateRuntime(); try { target.Compile(helper); } catch (SemanticException e) { var error = e.Errors.First() as FieldNotFoundError; Assert.IsNotNull(error); Assert.Pass(); } Assert.Fail(); }
public virtual TReturn Visit(FieldAccessExpression node, TParam param) { node.SubExpression.Accept(this, param); return(DefaultReturn); }
public virtual TypeExpression MakeCall(int indent, InvocationExpression node, Object o, MethodType actualMethodCalled, FieldAccessExpression fieldAccessExpression, object arg) { // shortcut evaluation. Null pointed error suprimed if (o is SynthesizedAttributes && ((SynthesizedAttributes)o).IdentifierExpressionMode == IdentifierMode.Instance) { // * 1.1.1 The implicit parameter is an object (not a class) this.CallVirt(indent, actualMethodCalled, actualMethodCalled.MemberInfo.Class, fieldAccessExpression.FieldName.Identifier, node.Arguments); } else { // * 1.1.2 The implicit parameter is a class (not an object) this.Call(indent, actualMethodCalled, actualMethodCalled.MemberInfo.Class, actualMethodCalled.MemberInfo.MemberIdentifier); } return(actualMethodCalled.Return); }
public override object Exec(FieldAccessExpression f, object arg) { return(f.ExpressionType); }
public virtual object Exec(FieldAccessExpression f, object arg) { return(Exec((Expression)f, arg)); }
public virtual TReturn Visit(FieldAccessExpression node, TParam param) => throw new NotImplementedException();
public abstract Object Visit(FieldAccessExpression node, Object obj);
public override void CGFieldAddress(CodeGenerator cg, FieldAccessExpression expr) { cg.EmitAddress(expr.SubExpression); cg.EmitOffset(OffsetOfField(expr.FieldName)); }