public MethodContext MethodFromLean(TripMethod method)
        {
            if (!typeConverter.IsStructIdentifier(method.ReturnType))
            {
                throw new ArgumentException(
                    string.Format("Return type of method must be a struct type, method {0}, return type {1}.", method.Name, method.ReturnType.Name));
            }
            if (!typeConverter.IsStructIdentifier(method.ArgumentType))
            {
                throw new ArgumentException(
                    string.Format("Argument type of method must be a struct type, method {0}, argument type {1}.", method.Name, method.ArgumentType.Name));
            }

            return new MethodContext(method.Name, false, MangleJavaMethodName(method.Name), typeConverter.ConvertToString(method.ReturnType),
                MangleJavaArgumentName(method.ArgumentName), typeConverter.ConvertToString(method.ArgumentType));
        }
Exemplo n.º 2
0
 public void Visit(TripMethod tripMethod)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 3
0
 public void Visit(TripMethod tripMethod)
 {
     sb.Append("  "); // identation
     VisitTripType(tripMethod.ReturnType);
     sb.Append(" ").Append(tripMethod.Name).Append("(");
     VisitTripType(tripMethod.ArgumentType);
     sb.Append(" ").Append(tripMethod.ArgumentName);
     sb.Append(") ");
 }
Exemplo n.º 4
0
        public static List<TripMethod> BuildTripMethods(ParseTreeNode tripMethodNodes)
        {
            List<TripMethod> tripMethods = new List<TripMethod>();
            foreach (var methodNode in tripMethodNodes.ChildNodes)
            {
                IdentifierType returnType = new IdentifierType(methodNode.ChildNodes[0].Token.Text);
                string name = methodNode.ChildNodes[1].Token.Text;
                IdentifierType argumentType = new IdentifierType(methodNode.ChildNodes[2].Token.Text);
                string argumentName = methodNode.ChildNodes[3].Token.Text;
                var tripMethod = new TripMethod(name, returnType, argumentType, argumentName);
                tripMethods.Add(tripMethod);
            }

            return tripMethods;
        }