當前位置: 首頁>>代碼示例>>Java>>正文


Java Value類代碼示例

本文整理匯總了Java中org.manifold.compiler.Value的典型用法代碼示例。如果您正苦於以下問題:Java Value類的具體用法?Java Value怎麽用?Java Value使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Value類屬於org.manifold.compiler包,在下文中一共展示了Value類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: annotateConnectionAttribute

import org.manifold.compiler.Value; //導入依賴的package包/類
public void annotateConnectionAttribute(
    String connectionName, String attrName, Value attrValue)
    throws UndeclaredIdentifierException {
  // make sure the original schematic contains this connection
  if (!(originalSchematic.getConnections().containsKey(connectionName))) {
    throw new UndeclaredIdentifierException(
        "connection '" + connectionName +
        "' not present on original schematic");
  }
  // record the change
  if (!(connectionAttributeAnnotations.containsKey(connectionName))) {
    connectionAttributeAnnotations.put(
        connectionName, new HashMap<String, Value>());
  }
  connectionAttributeAnnotations.get(connectionName).put(attrName, attrValue);
}
 
開發者ID:manifold-lang,項目名稱:manifold-core,代碼行數:17,代碼來源:BackAnnotationBuilder.java

示例2: verify

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
public void verify() throws Exception {
  // Elaborate function
  ExpressionVertex vFunction = functionEdge.getSource();
  vFunction.elaborate();
  // now find out what kind of function we are about to invoke
  Value function = vFunction.getValue();
  if (function instanceof FunctionValue) {
    // verify all the variables in the function body
    FunctionValue functionValue = (FunctionValue) function;
    for (Map.Entry<VariableIdentifier, VariableReferenceVertex> entry
        : functionValue.getBody().getVariableVertices().entrySet()) {
      entry.getValue().verify();
    }
  }
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:17,代碼來源:FunctionInvocationVertex.java

示例3: elaborateNodeInstantiation

import org.manifold.compiler.Value; //導入依賴的package包/類
private void elaborateNodeInstantiation(Value function,
    ExpressionVertex vFunction) throws Exception {
  log.debug("function invocation is node instantiation");
  NodeTypeValue nodeType = (NodeTypeValue) function;
  FunctionTypeValue signature = (FunctionTypeValue) vFunction.getType();
  NodeValueVertex vNode = new NodeValueVertex(getExpressionGraph(),
      nodeType, signature, inputEdge);
  // now inputEdge.target is vNode
  getExpressionGraph().addVertex(vNode);
  // change source of all edges out from this vertex
  // to have vNode as their source
  for (ExpressionEdge e : getExpressionGraph().getEdgesFromSource(this)) {
    e.setSource(vNode);
  }
  // destroy the function edge
  getExpressionGraph().removeEdge(functionEdge);
  // now remove this vertex from the graph
  getExpressionGraph().removeVertex(this);

  // Now actually elaborate the new node, since if this was a non-primitive
  // it would be resolved and that's what consumers of this API expect
  vNode.elaborate();
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:24,代碼來源:FunctionInvocationVertex.java

示例4: elaborate

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
public void elaborate() throws Exception {
  if (elaborated) {
    return;
  }
  // Elaborate argument
  ExpressionVertex vInput = inputEdge.getSource();
  vInput.elaborate();
  // Elaborate function
  ExpressionVertex vFunction = functionEdge.getSource();
  vFunction.elaborate();
  // now find out what kind of function we are about to invoke
  Value function = vFunction.getValue();
  if (function instanceof NodeTypeValue) {
    // we're not calling a function; we're instantiating a node!
    elaborateNodeInstantiation(function, vFunction);
  } else if (function instanceof FunctionValue) {
    // non-primitive function elaboration
    elaborateNonPrimitiveFunction(function, vInput);
  } else {
    throw new UndefinedBehaviourError("don't know how to invoke '"
        + function.toString() + "'");
  }
  elaborated = true;
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:26,代碼來源:FunctionInvocationVertex.java

示例5: elaborate

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
public void elaborate() throws Exception {
  super.elaborate();
  type = super.getType();
  vType.elaborate();
  Value value = vType.getValue();
  TypeValue declaredType = TypeAssertions.assertIsType(value);
  // check if assigned value is of the correct declaredType
  if (!declaredType.isSubtypeOf(type)) {
    throw new TypeMismatchException(declaredType, type);
  }

  type = declaredType;

  // if vType == 'Type'
  if (value == TypeTypeValue.getInstance()) {
    TypeValue assignedType = TypeAssertions.assertIsType(super.getValue());
    this.value = new TypeVariable(id, assignedType);
  }
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:21,代碼來源:VariableDeclarationVertex.java

示例6: toString

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("( ");
  for (MappedArray<String, Value>.Entry e : entries) {
    String key = e.getKey();
    Value value = e.getValue();

    sb.append(key).append(":");
    if (value == null) {
      sb.append("null");
    } else {
      sb.append(value.toString());
    }
    sb.append(" ");
  }
  sb.append(")");
  return sb.toString();
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:20,代碼來源:TupleValue.java

示例7: elaborate

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
public void elaborate() throws Exception {
  log.debug("elaborating tuple value");

  MappedArray<String, Value> values = new MappedArray<>();
  MappedArray<String, TypeValue> types = new MappedArray<>();
  for (MappedArray<String, ExpressionEdge>.Entry entry : valueEdges) {
    log.debug("elaborating tuple entry '" + entry.getKey() + "'");
    ExpressionVertex vSource = entry.getValue().getSource();
    vSource.elaborate();

    // If the source was a function invocation then the source edge will now point to something else, probably a node
    // query the source again to get the updated source
    vSource = entry.getValue().getSource();
    values.put(entry.getKey(), vSource.getValue());
    types.put(entry.getKey(), vSource.getType());
  }
  // construct a type
  TupleTypeValue tupleType = new TupleTypeValue(types);
  this.value = new TupleValue(tupleType, values);
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:22,代碼來源:TupleValueVertex.java

示例8: serializeValueAttr

import org.manifold.compiler.Value; //導入依賴的package包/類
private JsonObject serializeValueAttr(Map<String, Value> valueAttr) {
  JsonObject attrs = new JsonObject();
  // unlike types which are always back references, values come in 2 flavours
  // if they exist in the rValueMap, then they are a reference
  // otherwise they are a primitive and we call toString
  valueAttr.forEach((key, val) -> {
      JsonElement elem = rValueMap.containsKey(val) ?
          new JsonPrimitive(rValueMap.get(val)) :
          val.toJson();
      attrs.add(key, elem);
    });
  return attrs;
}
 
開發者ID:manifold-lang,項目名稱:manifold-core,代碼行數:14,代碼來源:SchematicSerializer.java

示例9: annotateConstraintAttribute

import org.manifold.compiler.Value; //導入依賴的package包/類
public void annotateConstraintAttribute(
    String constraintName, String attrName, Value attrValue)
        throws UndeclaredIdentifierException, UndeclaredAttributeException,
        TypeMismatchException {
  // make sure the original schematic contains this constraint
  if (!(originalSchematic.getConstraints().containsKey(constraintName))) {
    throw new UndeclaredIdentifierException(
        "constraint '" + constraintName
        + "' not present on original schematic");
  }
  // make sure the constraint has such an attribute
  ConstraintValue originalConstraint =
      originalSchematic.getConstraint(constraintName);
  ConstraintType originalConstraintType = (ConstraintType)
      originalConstraint.getType();
  if (!(originalConstraintType.getAttributes().containsKey(attrName))) {
    throw new UndeclaredAttributeException(
        "attribute '" + attrName + "' not present on this constraint type");
  }
  // make sure the value has the correct type for the attribute
  TypeValue expectedType = originalConstraintType.getAttributes()
      .get(attrName);
  if (expectedType instanceof UserDefinedTypeValue) {
    expectedType = ((UserDefinedTypeValue) expectedType).getTypeAlias();
  }
  TypeValue actualType = attrValue.getType();
  if (!actualType.isSubtypeOf(expectedType)) {
    throw new TypeMismatchException(expectedType, actualType);
  }
  // record the change
  if (!(constraintAttributeAnnotations.containsKey(constraintName))) {
    constraintAttributeAnnotations.put(
        constraintName, new HashMap<String, Value>());
  }
  constraintAttributeAnnotations.get(constraintName).put(attrName, attrValue);
}
 
開發者ID:manifold-lang,項目名稱:manifold-core,代碼行數:37,代碼來源:BackAnnotationBuilder.java

示例10: annotateNodeAttribute

import org.manifold.compiler.Value; //導入依賴的package包/類
public void annotateNodeAttribute(
    String nodeName, String attrName, Value attrValue)
        throws UndeclaredIdentifierException, UndeclaredAttributeException,
        TypeMismatchException {
  // make sure the original schematic contains this node
  if (!(originalSchematic.getNodes().containsKey(nodeName))) {
    throw new UndeclaredIdentifierException(
        "node '" + nodeName + "' not present on original schematic");
  }
  // make sure the node has such an attribute
  NodeValue originalNode = originalSchematic.getNode(nodeName);
  NodeTypeValue originalNodeType = (NodeTypeValue) originalNode.getType();
  if (!(originalNodeType.getAttributes().containsKey(attrName))) {
    throw new UndeclaredAttributeException(
        "attribute '" + attrName + "' not present on this node type");
  }
  // make sure the value has the correct type for the attribute
  TypeValue expectedType = originalNodeType.getAttributes().get(attrName);
  if (expectedType instanceof UserDefinedTypeValue) {
    expectedType = ((UserDefinedTypeValue) expectedType).getTypeAlias();
  }
  TypeValue actualType = attrValue.getType();
  if (!actualType.isSubtypeOf(expectedType)) {
    throw new TypeMismatchException(expectedType, actualType);
  }

  // record the change
  if (!(nodeAttributeAnnotations.containsKey(nodeName))) {
    nodeAttributeAnnotations.put(nodeName, new HashMap<String, Value>());
  }
  nodeAttributeAnnotations.get(nodeName).put(attrName, attrValue);
}
 
開發者ID:manifold-lang,項目名稱:manifold-core,代碼行數:33,代碼來源:BackAnnotationBuilder.java

示例11: assertIsType

import org.manifold.compiler.Value; //導入依賴的package包/類
public static TypeValue assertIsType(Value v) throws TypeMismatchException {
  if (v != null && v instanceof TypeValue) {
    return (TypeValue) v;
  } else {
    throw new TypeMismatchException(TypeTypeValue.getInstance(), v);
  }
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:8,代碼來源:TypeAssertions.java

示例12: getValue

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
public Value getValue() {
  if (value == null) {
    return super.getValue();
  }
  return value;
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:8,代碼來源:VariableDeclarationVertex.java

示例13: getEntry

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
public Value getEntry(String key) throws Exception {
  VariableIdentifier id = new VariableIdentifier(namespace, key);
  if (!exprGraph.containsVariable(id)) {
    throw new VariableNotDefinedException(id);
  }

  VariableReferenceVertex source = exprGraph.getVariableVertex(id);
  source.elaborate();
  return source.getValue();
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:12,代碼來源:ImportValue.java

示例14: elaborate

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
public void elaborate() throws Exception {
  log.debug("elaborating static attribute access");
  ExpressionVertex vExpr = exprEdge.getSource();
  vExpr.elaborate();

  Value val = vExpr.getValue();
  this.value = getValEntry(val);

  TypeValue t = vExpr.getType();
  this.type = getTypeEntry(t);
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:13,代碼來源:StaticAttributeAccessVertex.java

示例15: getValEntry

import org.manifold.compiler.Value; //導入依賴的package包/類
@Override
protected final Value getValEntry(Value v) throws Exception {
  if (!(v instanceof NamedEntryValue)) {
    throw new RuntimeException("Cannot get entry by attribute of " + v.toString());
  }
  return ((NamedEntryValue) v).getEntry(attributeID);
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:8,代碼來源:StaticAttributeAccessVertex.java


注:本文中的org.manifold.compiler.Value類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。