Package wycs.core

Examples of wycs.core.SemanticType$Tuple


      SyntacticType.Set t = (SyntacticType.Set) type;
      return SemanticType.Set(true,convert(t.element,generics,context));
    } else if(type instanceof SyntacticType.Map) {
      // FIXME: need to include the map constraints here
      SyntacticType.Map t = (SyntacticType.Map) type;
      SemanticType key = convert(t.key,generics,context);
      SemanticType value = convert(t.value,generics,context);
      if (key instanceof SemanticType.Void
          || value instanceof SemanticType.Void) {
        // surprisingly, this case is possible and does occur.
        return SemanticType.Set(true, SemanticType.Void);
      } else {
        return SemanticType.Set(true, SemanticType.Tuple(key, value));
      }
    } else if(type instanceof SyntacticType.List) {
      // FIXME: need to include the list constraints here
      SyntacticType.List t = (SyntacticType.List) type;
      SemanticType element = convert(t.element,generics,context);
      if (element instanceof SemanticType.Void) {
        // surprisingly, this case is possible and does occur.
        return SemanticType.Set(true, SemanticType.Void);
      } else {
        return SemanticType.Set(true,
View Full Code Here


  private WycsFile getModuleStub(WyalFile wyalFile) {
    ArrayList<WycsFile.Declaration> declarations = new ArrayList<WycsFile.Declaration>();
    for (WyalFile.Declaration d : wyalFile.declarations()) {
      if (d instanceof WyalFile.Macro) {
        WyalFile.Macro def = (WyalFile.Macro) d;
        SemanticType from = convert(def.from, def.generics, d);
        SemanticType to = SemanticType.Bool;
        SemanticType.Var[] generics = new SemanticType.Var[def.generics
            .size()];
        for (int i = 0; i != generics.length; ++i) {
          generics[i] = SemanticType.Var(def.generics.get(i));
        }
        SemanticType.Function type = SemanticType.Function(from, to,
            generics);
        declarations.add(new WycsFile.Macro(def.name, type, null, def
            .attribute(Attribute.Source.class)));
      } else if (d instanceof WyalFile.Function) {
        WyalFile.Function fun = (WyalFile.Function) d;
        SemanticType from = convert(fun.from, fun.generics, d);
        SemanticType to = convert(fun.to, fun.generics, d);
        SemanticType.Var[] generics = new SemanticType.Var[fun.generics
            .size()];
        for (int i = 0; i != generics.length; ++i) {
          generics[i] = SemanticType.Var(fun.generics.get(i));
        }
View Full Code Here

    HashMap<String,Integer> nEnvironment = new HashMap<String,Integer>(environment);
    Pair<SemanticType,Integer>[] variables = code.types;
    int[] vars = new int[variables.length];
    for (int i = 0; i != variables.length; ++i) {
      Pair<SemanticType,Integer> p = variables[i];
      SemanticType type = p.first();
      String var = "r" + p.second();
      int varIdx = Var(automaton, var);
      nEnvironment.put(var, varIdx);
      int srcIdx;
      // FIXME: generate actual type of variable here
View Full Code Here

    if(s.constraint != null) {
      HashSet<String> generics = new HashSet<String>(s.generics);
      HashMap<String,SemanticType> environment = new HashMap<String,SemanticType>();
      addDeclaredVariables(s.from, environment,generics,s);
      addDeclaredVariables(s.to, environment,generics,s);
      SemanticType r = propagate(s.constraint,environment,generics,s);
      checkIsSubtype(SemanticType.Bool,r,s.constraint);
    }
  }
View Full Code Here

  private void propagate(WyalFile.Macro s) {
    HashSet<String> generics = new HashSet<String>(s.generics);
    HashMap<String,SemanticType> environment = new HashMap<String,SemanticType>();
    addDeclaredVariables(s.from, environment,generics,s);
    SemanticType r = propagate(s.body,environment,generics,s);
    checkIsSubtype(SemanticType.Bool,r,s.body);
  }
View Full Code Here

      }
    } else {
      TypePattern.Leaf lp = (TypePattern.Leaf) pattern;

      if (lp.var != null) {
        SemanticType type = builder.convert(pattern.toSyntacticType(),
            generics, context);
        environment.put(lp.var.name, type);
      }
    }
View Full Code Here

    return environment;
  }

  private void propagate(WyalFile.Assert s) {
    HashMap<String,SemanticType> environment = new HashMap<String,SemanticType>();
    SemanticType t = propagate(s.expr, environment, new HashSet<String>(), s);
    checkIsSubtype(SemanticType.Bool,t, s.expr);
  }
View Full Code Here

   * @return
   */
  private SemanticType propagate(Expr e,
      HashMap<String, SemanticType> environment,
      HashSet<String> generics, WyalFile.Context context) {
    SemanticType t;
    if(e instanceof Expr.Variable) {
      t = propagate((Expr.Variable)e, environment, generics, context);
    } else if(e instanceof Expr.Constant) {
      t = propagate((Expr.Constant)e, environment, generics, context);
    } else if(e instanceof Expr.Unary) {
View Full Code Here

  }

  private SemanticType propagate(Expr.Variable e,
      HashMap<String, SemanticType> environment,
      HashSet<String> generics, WyalFile.Context context) {
    SemanticType t = environment.get(e.name);
    if(t == null) {
      internalFailure("undeclared variable encountered (" + e + ")",
          filename, e);
    }
    return t;
View Full Code Here

  }

  private SemanticType propagate(Expr.Unary e,
      HashMap<String, SemanticType> environment,
      HashSet<String> generics, WyalFile.Context context) {
    SemanticType op_type = propagate(e.operand,environment,generics,context);

    switch(e.op) {
    case NOT:
      checkIsSubtype(SemanticType.Bool,op_type,e);
      break;
View Full Code Here

TOP

Related Classes of wycs.core.SemanticType$Tuple

Copyright © 2018 www.massapicom. 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.