Examples of DeclSequence


Examples of wyvern.tools.typedAST.core.declarations.DeclSequence

public class TrivDSLParser implements ExtParser {
  @Override
  public TypedAST parse(ParseBuffer input) {
    New newv = new New(new HashMap<>(), null);
    TypedAST dbody = new IntegerConstant(Integer.parseInt(input.getSrcString().trim()));
    newv.setBody(new DeclSequence(Arrays.asList(new DefDeclaration("getValue", new Arrow(Unit.getInstance(), Int.getInstance()), new ArrayList<>(), dbody, false))));
    return newv;
  }
View Full Code Here

Examples of wyvern.tools.typedAST.core.declarations.DeclSequence

        decls.add(new JavaMeth(entry.getKey(), getJavaInvokableMethods(clazz, entry)));
      }
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
    DeclSequence ds = new DeclSequence(decls);
    return ds;
  }
View Full Code Here

Examples of wyvern.tools.typedAST.core.declarations.DeclSequence

        = new DefDeclaration(entry.getKey(), new Arrow(Unit.getInstance(), Unit.getInstance()), new LinkedList<>(), entry.getValue(), false));

    classDecls[cdIdx.getAndIncrement()] = new DefDeclaration("create", new Arrow(Unit.getInstance(),
        new UnresolvedType(wyvClassName)),
        Arrays.asList(),
        new New(new DeclSequence(), unkLoc), true);


    ArrayList<TypedAST> pairedObjDecls = new ArrayList<>();
    pairedObjDecls.addAll(Arrays.asList(classDecls));
    TypedAST pairedObj = new ClassDeclaration(wyvClassName, "", "", new DeclSequence(pairedObjDecls), unkLoc);

    Type parseBufferType = Util.javaToWyvType(ParseBuffer.class);


    Type javaClassType = Util.javaToWyvType(javaClass);
    TypedAST bufGet = new Application(
        new Invocation(new Variable(new NameBindingImpl("buf", null), unkLoc), "getSrcString", null, unkLoc),
        UnitVal.getInstance(unkLoc),
        unkLoc);
    ClassType emptyType =
        new ClassType(new Reference<>(Environment.getEmptyEnvironment()), new Reference<>(Environment.getEmptyEnvironment()), new LinkedList<>(), "empty");
    TypedAST javaObjInit = new Application(new ExternalFunction(new Arrow(emptyType, Util.javaToWyvType(Value.class)), (env,arg)->{
      return Util.toWyvObj(arg);
    }),
        new Application(
            new Invocation(new Variable(new NameBindingImpl(wyvClassName, null), unkLoc), "create", null, unkLoc),
            UnitVal.getInstance(unkLoc), unkLoc), unkLoc);
    TypedAST body = new Application(new ExternalFunction(new Arrow(Util.javaToWyvType(Object.class), Util.javaToWyvType(TypedAST.class)),
          (env,arg)-> (Value)Util.toJavaObject(arg,Value.class)),
        new Application(new Invocation(new Application(
          new Invocation(new Variable(new NameBindingImpl(javaClassName, null), unkLoc), "create", null, unkLoc),
          javaObjInit, unkLoc), "parse", null, unkLoc),
          new TupleObject(new TypedAST[] {bufGet, new StringConstant("TSL code")}), unkLoc), unkLoc);

    DefDeclaration parseDef =
        new DefDeclaration("parse",
            new Arrow(parseBufferType, Util.javaToWyvType(TypedAST.class)),
            Arrays.asList(new NameBindingImpl("buf", parseBufferType)),
            body,
            false);

    return new New(new DeclSequence(Arrays.asList(pairedObj, jcd, parseDef)), unkLoc);
  }
View Full Code Here

Examples of wyvern.tools.typedAST.core.declarations.DeclSequence

      LinkedList<Declaration> decls = new LinkedList<>();

      mockEnv = getGenericDecls(env, mockEnv, decls);
      Environment nnames = (seq.extendName(mockEnv,mockEnv.extend(env)));

      ClassDeclaration classDeclaration = new ClassDeclaration("generic" + generic_num++, "", "", new DeclSequence(decls), mockEnv, new LinkedList<String>(), getLocation());
      cls = classDeclaration;
      Environment tee = TypeDeclUtils.getTypeEquivalentEnvironment(nnames.extend(mockEnv));
     
      ct = new ClassType(new Reference<>(nnames.extend(mockEnv)), new Reference<>(tee), new LinkedList<String>(), null);
      return ct;
View Full Code Here

Examples of wyvern.tools.typedAST.core.declarations.DeclSequence

      LinkedList<Declaration> decls = new LinkedList<>();

      mockEnv = getGenericDecls(env, mockEnv, decls);

      classDecl = new ClassDeclaration("generic" + generic_num++, "", "", new DeclSequence(), mockEnv, new LinkedList<String>(), getLocation());
    }

    AtomicReference<Value> objRef = new AtomicReference<>();
    Environment evalEnv = env.extend(new LateValueBinding("this", objRef, ct));
    classDecl.evalDecl(evalEnv, classDecl.extendWithValue(Environment.getEmptyEnvironment()));
View Full Code Here

Examples of wyvern.tools.typedAST.core.declarations.DeclSequence

  }

  @Override
  public Map<String, TypedAST> getChildren() {
    HashMap<String,TypedAST> outMap = new HashMap<>();
    outMap.put("seq", (seq==null)? new DeclSequence(Arrays.asList()) : seq);
    return outMap;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.