void ExpressionNode::GetLane(const mtlChars &val, int lane, mtlString &out) const { out.Free(); if (val.IsFloat()) { out.Copy(val); } else { int index = val.FindLastChar(Accessor); if (index != -1) { out.Append(mtlChars(val, 0, index)); out.Append(Accessor); int size = val.GetSize() - (index + 1); out.Append(lane < size ? mtlChars(val, index+1, val.GetSize())[lane] : '0'); } else { out.Append(val); out.Append(Accessor); out.Append(lane < Members.GetSize() ? Members[lane] : '0'); } } }
mtlChars GetBaseMembers(const mtlChars &name) { const int mem_index = name.FindLastChar(Accessor); mtlChars ret_val = (mem_index < 0) ? "" : mtlChars(name, mem_index + 1, name.GetSize()); return ret_val; }
mtlChars GetBaseName(const mtlChars &name) { const int mem_index = name.FindLastChar(Accessor); mtlChars ret_val = (mem_index < 0) ? name : mtlChars(name, 0, mem_index); return ret_val; }
bool GenerateTree(ExpressionNode *&node, mtlChars expr) { static const char zero_str[] = "0"; static const int OperationClasses = 2; static const char *Operations[OperationClasses] = { "+-", "*/" //,"|&" }; Parser p; p.SetBuffer(expr); mtlList<mtlChars> params; switch (p.Match("(%s)%|%s", params)) { case 0: case 1: expr = params.GetFirst()->GetItem(); break; default: return false; } if (expr.GetSize() == 0) { node = NULL; return false; } bool retval = true; int opIndex = -1; for (int i = 0; i < OperationClasses; ++i) { mtlChars ops = mtlChars::FromDynamic(Operations[i]); opIndex = FindOperation(ops, expr); if (opIndex != -1) { break; } } if (opIndex != -1) { OperationNode *op_node = new OperationNode; op_node->operation = expr[opIndex]; op_node->left = NULL; op_node->right = NULL; mtlChars lexpr = mtlChars(expr, 0, opIndex); mtlChars rexpr = mtlChars(expr, opIndex + 1, expr.GetSize()); if (expr[opIndex] == '-' && lexpr.GetSize() == 0) { lexpr = zero_str; } retval = GenerateTree(op_node->left, lexpr) && GenerateTree(op_node->right, rexpr); node = op_node; } else { // STOPPING CONDITION ValueNode *val_node = new ValueNode; val_node->term.Copy(expr); node = val_node; } return retval; }
mtlChars Dbg_Str( void ) const { return mtlChars(operation); }
}; struct CompileInstance { mtlList<swsl::Instruction> program; swsl::addr_t *prog_entry; swsl::addr_t *prog_inputs; mtlList<swsl::CompilerMessage> errors; mtlList<swsl::CompilerMessage> warnings; mtlList<Scope> scopes; int stack_manip; int main; }; static const TypeInfo gTypes[TYPE_COUNT] = { { mtlChars("void"), Void, 0 }, { mtlChars("bool"), Bool, 1 }, { mtlChars("float"), Float, 1 }, { mtlChars("float2"), Float2, 2 }, { mtlChars("float3"), Float3, 3 }, { mtlChars("float4"), Float4, 4 } }; static const TypeInfo gSubTypes[TYPE_COUNT] = { { mtlChars("void"), Void, 0 }, { mtlChars("bool"), Bool, 1 }, { mtlChars("float"), Float, 1 }, { mtlChars("float"), Float, 1 }, { mtlChars("float"), Float, 1 }, { mtlChars("float"), Float, 1 } };
mtlChars mtlDirectory::GetFilename( void ) const { if (m_file1 < 0) { return mtlChars(); } return m_dir.GetSubstring(m_file0, m_file1); }
mtlChars mtlDirectory::GetFolders( void ) const { if (m_file0 < 0) { return mtlChars(); } return m_dir.GetSubstring(0, m_file0); }
mtlChars mtlDirectory::GetExtension( void ) const { if (m_dir.GetSize() == 0) { return mtlChars(); } return m_dir.GetSubstring(m_ext0, m_dir.GetSize()); }